summary refs log tree commit diff
diff options
context:
space:
mode:
authorPeter Dettman <peter.dettman@bouncycastle.org>2022-02-08 14:22:16 +0700
committerPeter Dettman <peter.dettman@bouncycastle.org>2022-02-08 14:22:16 +0700
commit2b87844c3c93d420f8151fa21e11a00b65ff47af (patch)
treeec9e1e1f321b19e1c88bda1607d690a9ae4aa4a3
parentSmall performance optimization for important curves (diff)
downloadBouncyCastle.NET-ed25519-2b87844c3c93d420f8151fa21e11a00b65ff47af.tar.xz
Minor optimization
-rw-r--r--crypto/src/asn1/Asn1InputStream.cs12
1 files changed, 6 insertions, 6 deletions
diff --git a/crypto/src/asn1/Asn1InputStream.cs b/crypto/src/asn1/Asn1InputStream.cs

index aa1bb0571..33e7b0e0c 100644 --- a/crypto/src/asn1/Asn1InputStream.cs +++ b/crypto/src/asn1/Asn1InputStream.cs
@@ -258,8 +258,6 @@ namespace Org.BouncyCastle.Asn1 // if (tagNo == 0x1f) { - tagNo = 0; - int b = s.ReadByte(); if (b < 31) { @@ -269,9 +267,11 @@ namespace Org.BouncyCastle.Asn1 throw new IOException("corrupted stream - high tag number < 31 found"); } + tagNo = b & 0x7f; + // X.690-0207 8.1.2.4.2 // "c) bits 7 to 1 of the first subsequent octet shall not all be zero." - if ((b & 0x7f) == 0) + if (0 == tagNo) throw new IOException("corrupted stream - invalid high tag number found"); while ((b & 0x80) != 0) @@ -279,14 +279,14 @@ namespace Org.BouncyCastle.Asn1 if (((uint)tagNo >> 24) != 0U) throw new IOException("Tag number more than 31 bits"); - tagNo |= b & 0x7f; tagNo <<= 7; + b = s.ReadByte(); if (b < 0) throw new EndOfStreamException("EOF found inside tag value."); - } - tagNo |= b & 0x7f; + tagNo |= b & 0x7f; + } } return tagNo;