From 0661cf3bc3259e0f14fc70d660c44c47f0b03a83 Mon Sep 17 00:00:00 2001 From: Peter Dettman Date: Sat, 6 Nov 2021 19:07:02 +0700 Subject: Add Asn1Utilities class --- crypto/src/asn1/Asn1Utilities.cs | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) create mode 100644 crypto/src/asn1/Asn1Utilities.cs (limited to 'crypto/src') diff --git a/crypto/src/asn1/Asn1Utilities.cs b/crypto/src/asn1/Asn1Utilities.cs new file mode 100644 index 000000000..bdeb46483 --- /dev/null +++ b/crypto/src/asn1/Asn1Utilities.cs @@ -0,0 +1,28 @@ +using System; + +namespace Org.BouncyCastle.Asn1 +{ + public abstract class Asn1Utilities + { + public static string GetTagText(Asn1TaggedObject taggedObject) + { + // TODO[asn1] Implement and use taggedObject.TagClass + return GetTagText(Asn1Tags.ContextSpecific, taggedObject.TagNo); + } + + public static string GetTagText(int tagClass, int tagNo) + { + switch (tagClass) + { + case Asn1Tags.Application: + return "[APPLICATION " + tagNo + "]"; + case Asn1Tags.ContextSpecific: + return "[CONTEXT " + tagNo + "]"; + case Asn1Tags.Private: + return "[PRIVATE " + tagNo + "]"; + default: + return "[UNIVERSAL " + tagNo + "]"; + } + } + } +} -- cgit 1.5.1