diff options
author | Peter Dettman <peter.dettman@bouncycastle.org> | 2021-11-18 13:46:18 +0700 |
---|---|---|
committer | Peter Dettman <peter.dettman@bouncycastle.org> | 2021-11-18 13:46:18 +0700 |
commit | 4fccb8f490eefe7181558b2c3376ab23c33632ee (patch) | |
tree | fe8c1877bb5567cb4823823af77e5c8a38423db8 /crypto/src/asn1/DerApplicationSpecific.cs | |
parent | ASN.1: Staged encoding (diff) | |
download | BouncyCastle.NET-ed25519-4fccb8f490eefe7181558b2c3376ab23c33632ee.tar.xz |
ASN.1: Port of bc-java TYPE instances
- we use Meta.Instance here due to syntax restrictions - also reworked some ASN.1 string types
Diffstat (limited to 'crypto/src/asn1/DerApplicationSpecific.cs')
-rw-r--r-- | crypto/src/asn1/DerApplicationSpecific.cs | 45 |
1 files changed, 2 insertions, 43 deletions
diff --git a/crypto/src/asn1/DerApplicationSpecific.cs b/crypto/src/asn1/DerApplicationSpecific.cs index 13b725325..15a4cdcc2 100644 --- a/crypto/src/asn1/DerApplicationSpecific.cs +++ b/crypto/src/asn1/DerApplicationSpecific.cs @@ -94,6 +94,7 @@ namespace Org.BouncyCastle.Asn1 get { return m_taggedObject.TagNo; } } + [Obsolete("Will be removed")] public byte[] GetContents() { return m_taggedObject.GetContents(); @@ -112,21 +113,7 @@ namespace Org.BouncyCastle.Asn1 public Asn1Object GetObject(int tagNo) { - // TODO[asn1] Implement Asn1TaggedObject.GetBaseUniversal - //return taggedObject.GetBaseUniversal(false, tagNo); - - if (tagNo >= 0x1F) - throw new IOException("unsupported tag number"); - - byte[] orig = this.GetEncoded(); - byte[] tmp = ReplaceTagNumber(tagNo, orig); - - if ((orig[0] & Asn1Tags.Constructed) != 0) - { - tmp[0] |= Asn1Tags.Constructed; - } - - return FromByteArray(tmp); + return m_taggedObject.GetBaseUniversal(false, tagNo); } public bool HasApplicationTag(int tagNo) @@ -186,34 +173,6 @@ namespace Org.BouncyCastle.Asn1 return m_taggedObject.GetEncodingImplicit(encoding, tagClass, tagNo); } - private byte[] ReplaceTagNumber(int newTag, byte[] input) - { - int tagNo = input[0] & 0x1f; - int index = 1; - - // with tagged object tag number is bottom 5 bits, or stored at the start of the content - if (tagNo == 0x1f) - { - int b = input[index++]; - - // 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) // Note: -1 will pass - throw new IOException("corrupted stream - invalid high tag number found"); - - while ((b & 0x80) != 0) - { - b = input[index++]; - } - } - - int remaining = input.Length - index; - byte[] tmp = new byte[1 + remaining]; - tmp[0] = (byte)newTag; - Array.Copy(input, index, tmp, 1, remaining); - return tmp; - } - private static int CheckTagClass(int tagClass) { if (Asn1Tags.Application != tagClass) |