summary refs log tree commit diff
path: root/crypto/src/asn1/pkcs/CrlBag.cs
blob: 5cc68ace407f77167ea49b1d48dd7664363366c6 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
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));
        }
    }
}