summary refs log tree commit diff
path: root/crypto/src/asn1/DerObjectIdentifier.cs
diff options
context:
space:
mode:
Diffstat (limited to 'crypto/src/asn1/DerObjectIdentifier.cs')
-rw-r--r--crypto/src/asn1/DerObjectIdentifier.cs30
1 files changed, 15 insertions, 15 deletions
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)