From 545bd8d72f1be98af7ce0dc85f713a5f47b01d9d Mon Sep 17 00:00:00 2001 From: Peter Dettman Date: Sat, 6 Nov 2021 19:31:27 +0700 Subject: Add TagClass property to Asn1TaggedObject --- crypto/src/asn1/Asn1TaggedObject.cs | 5 +++++ crypto/src/asn1/Asn1Utilities.cs | 3 +-- crypto/src/asn1/BerTaggedObject.cs | 2 +- crypto/src/asn1/DerTaggedObject.cs | 6 +++--- 4 files changed, 10 insertions(+), 6 deletions(-) diff --git a/crypto/src/asn1/Asn1TaggedObject.cs b/crypto/src/asn1/Asn1TaggedObject.cs index 42c6db381..501f877ab 100644 --- a/crypto/src/asn1/Asn1TaggedObject.cs +++ b/crypto/src/asn1/Asn1TaggedObject.cs @@ -103,6 +103,11 @@ namespace Org.BouncyCastle.Asn1 return code; } + public int TagClass + { + get { return Asn1Tags.ContextSpecific; } + } + public int TagNo { get { return tagNo; } diff --git a/crypto/src/asn1/Asn1Utilities.cs b/crypto/src/asn1/Asn1Utilities.cs index bdeb46483..dca2253ec 100644 --- a/crypto/src/asn1/Asn1Utilities.cs +++ b/crypto/src/asn1/Asn1Utilities.cs @@ -6,8 +6,7 @@ namespace Org.BouncyCastle.Asn1 { public static string GetTagText(Asn1TaggedObject taggedObject) { - // TODO[asn1] Implement and use taggedObject.TagClass - return GetTagText(Asn1Tags.ContextSpecific, taggedObject.TagNo); + return GetTagText(taggedObject.TagClass, taggedObject.TagNo); } public static string GetTagText(int tagClass, int tagNo) diff --git a/crypto/src/asn1/BerTaggedObject.cs b/crypto/src/asn1/BerTaggedObject.cs index b41df44ec..447aebecf 100644 --- a/crypto/src/asn1/BerTaggedObject.cs +++ b/crypto/src/asn1/BerTaggedObject.cs @@ -58,7 +58,7 @@ namespace Org.BouncyCastle.Asn1 { if (withID) { - asn1Out.WriteIdentifier(true, Asn1Tags.Constructed | Asn1Tags.ContextSpecific, tagNo); + asn1Out.WriteIdentifier(true, Asn1Tags.Constructed | TagClass, TagNo); } asn1Out.WriteByte(0x80); diff --git a/crypto/src/asn1/DerTaggedObject.cs b/crypto/src/asn1/DerTaggedObject.cs index 5ef4310e6..053d32f0a 100644 --- a/crypto/src/asn1/DerTaggedObject.cs +++ b/crypto/src/asn1/DerTaggedObject.cs @@ -57,15 +57,15 @@ namespace Org.BouncyCastle.Asn1 if (explicitly) { - asn1Out.WriteEncodingDL(withID, Asn1Tags.Constructed | Asn1Tags.ContextSpecific, tagNo, bytes); + asn1Out.WriteEncodingDL(withID, Asn1Tags.Constructed | TagClass, TagNo, bytes); } else { if (withID) { // need to mark constructed types... (preserve Constructed tag) - int flags = (bytes[0] & Asn1Tags.Constructed) | Asn1Tags.ContextSpecific; - asn1Out.WriteIdentifier(true, flags, tagNo); + int flags = (bytes[0] & Asn1Tags.Constructed) | TagClass; + asn1Out.WriteIdentifier(true, flags, TagNo); } asn1Out.Write(bytes, 1, bytes.Length - 1); -- cgit 1.4.1