From 2ee089e648a2aefe6d84244855b5c923b1496881 Mon Sep 17 00:00:00 2001 From: Peter Dettman Date: Mon, 22 Nov 2021 15:22:28 +0700 Subject: Add BitString parsers --- crypto/src/asn1/DLBitString.cs | 55 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 55 insertions(+) create mode 100644 crypto/src/asn1/DLBitString.cs (limited to 'crypto/src/asn1/DLBitString.cs') diff --git a/crypto/src/asn1/DLBitString.cs b/crypto/src/asn1/DLBitString.cs new file mode 100644 index 000000000..5d8f3ac5e --- /dev/null +++ b/crypto/src/asn1/DLBitString.cs @@ -0,0 +1,55 @@ +using System; + +namespace Org.BouncyCastle.Asn1 +{ + /// A Definite length BIT STRING + public class DLBitString + : DerBitString + { + public DLBitString(byte data, int padBits) + : base(data, padBits) + { + } + + public DLBitString(byte[] data) + : this(data, 0) + { + } + + public DLBitString(byte[] data, int padBits) + : base(data, padBits) + { + } + + public DLBitString(int namedBits) + : base(namedBits) + { + } + + public DLBitString(Asn1Encodable obj) + : this(obj.GetDerEncoded(), 0) + { + } + + internal DLBitString(byte[] contents, bool check) + : base(contents, check) + { + } + + internal override IAsn1Encoding GetEncoding(int encoding) + { + if (Asn1OutputStream.EncodingDer == encoding) + return base.GetEncoding(encoding); + + return new PrimitiveEncoding(Asn1Tags.Universal, Asn1Tags.BitString, contents); + } + + internal override IAsn1Encoding GetEncodingImplicit(int encoding, int tagClass, int tagNo) + { + if (Asn1OutputStream.EncodingDer == encoding) + return base.GetEncodingImplicit(encoding, tagClass, tagNo); + + return new PrimitiveEncoding(tagClass, tagNo, contents); + } + } +} -- cgit 1.4.1