summary refs log tree commit diff
path: root/crypto/src/asn1/pkcs/CrlBag.cs
diff options
context:
space:
mode:
authorPeter Dettman <peter.dettman@bouncycastle.org>2023-01-24 17:22:28 +0700
committerPeter Dettman <peter.dettman@bouncycastle.org>2023-01-24 17:22:28 +0700
commit5e731b9091c735bc0e301cc0d341efbed031c73c (patch)
treed87dadedfa7b8a0e98d4cc09bfdd4744f0b693e8 /crypto/src/asn1/pkcs/CrlBag.cs
parentMark custom curves internal (diff)
downloadBouncyCastle.NET-ed25519-5e731b9091c735bc0e301cc0d341efbed031c73c.tar.xz
Add Asn1.Pkcs.CrlBag
Diffstat (limited to '')
-rw-r--r--crypto/src/asn1/pkcs/CrlBag.cs44
1 files changed, 44 insertions, 0 deletions
diff --git a/crypto/src/asn1/pkcs/CrlBag.cs b/crypto/src/asn1/pkcs/CrlBag.cs
new file mode 100644
index 000000000..5cc68ace4
--- /dev/null
+++ b/crypto/src/asn1/pkcs/CrlBag.cs
@@ -0,0 +1,44 @@
+using System;
+
+namespace Org.BouncyCastle.Asn1.Pkcs
+{
+    public class CrlBag
+        : Asn1Encodable
+    {
+        public static CrlBag GetInstance(object obj)
+        {
+            if (obj is CrlBag crlBag)
+                return crlBag;
+            if (obj == null)
+                return null;
+            return new CrlBag(Asn1Sequence.GetInstance(obj));
+        }
+
+        private readonly DerObjectIdentifier m_crlID;
+        private readonly Asn1Encodable m_crlValue;
+
+        private CrlBag(Asn1Sequence seq)
+        {
+            if (seq.Count != 2)
+                throw new ArgumentException("Wrong number of elements in sequence", nameof(seq));
+
+            m_crlID = DerObjectIdentifier.GetInstance(seq[0]);
+            m_crlValue = Asn1TaggedObject.GetInstance(seq[1]).GetObject();
+        }
+
+        public CrlBag(DerObjectIdentifier crlID, Asn1Encodable crlValue)
+        {
+            m_crlID = crlID;
+            m_crlValue = crlValue;
+        }
+
+        public virtual DerObjectIdentifier CrlID => m_crlID;
+
+        public virtual Asn1Encodable CrlValue => m_crlValue;
+
+        public override Asn1Object ToAsn1Object()
+        {
+            return new DerSequence(m_crlID, new DerTaggedObject(0, m_crlValue));
+        }
+    }
+}