From abe0572ea59671d9444b61bf3ad4458518c2805d Mon Sep 17 00:00:00 2001 From: Peter Dettman Date: Thu, 1 Aug 2019 15:20:29 +0700 Subject: Misc. ASN.1 updates from bc-java --- crypto/src/asn1/DerObjectIdentifier.cs | 30 +++++++++++++++--------------- 1 file changed, 15 insertions(+), 15 deletions(-) (limited to 'crypto/src/asn1/DerObjectIdentifier.cs') diff --git a/crypto/src/asn1/DerObjectIdentifier.cs b/crypto/src/asn1/DerObjectIdentifier.cs index 1c8032f45..fb38d5f05 100644 --- a/crypto/src/asn1/DerObjectIdentifier.cs +++ b/crypto/src/asn1/DerObjectIdentifier.cs @@ -210,36 +210,36 @@ namespace Org.BouncyCastle.Asn1 return identifier; } - private static bool IsValidBranchID( - string branchID, int start) + private static bool IsValidBranchID(string branchID, int start) { - bool periodAllowed = false; + int digitCount = 0; int pos = branchID.Length; while (--pos >= start) { char ch = branchID[pos]; - // TODO Leading zeroes? - if ('0' <= ch && ch <= '9') - { - periodAllowed = true; - continue; - } - if (ch == '.') { - if (!periodAllowed) + if (0 == digitCount || (digitCount > 1 && branchID[pos + 1] == '0')) return false; - periodAllowed = false; - continue; + digitCount = 0; + } + else if ('0' <= ch && ch <= '9') + { + ++digitCount; } + else + { + return false; + } + } + if (0 == digitCount || (digitCount > 1 && branchID[pos + 1] == '0')) return false; - } - return periodAllowed; + return true; } private static bool IsValidIdentifier(string identifier) -- cgit 1.4.1