diff options
Diffstat (limited to 'crypto/src/asn1/pkcs/CrlBag.cs')
-rw-r--r-- | crypto/src/asn1/pkcs/CrlBag.cs | 25 |
1 files changed, 14 insertions, 11 deletions
diff --git a/crypto/src/asn1/pkcs/CrlBag.cs b/crypto/src/asn1/pkcs/CrlBag.cs index 0198c341c..28cc19fb1 100644 --- a/crypto/src/asn1/pkcs/CrlBag.cs +++ b/crypto/src/asn1/pkcs/CrlBag.cs @@ -7,38 +7,41 @@ namespace Org.BouncyCastle.Asn1.Pkcs { public static CrlBag GetInstance(object obj) { - if (obj is CrlBag crlBag) - return crlBag; if (obj == null) return null; + if (obj is CrlBag crlBag) + return crlBag; return new CrlBag(Asn1Sequence.GetInstance(obj)); } + public static CrlBag GetInstance(Asn1TaggedObject taggedObject, bool declaredExplicit) + { + return new CrlBag(Asn1Sequence.GetInstance(taggedObject, declaredExplicit)); + } + 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)); + int count = seq.Count; + if (count != 2) + throw new ArgumentException("Bad sequence size: " + count, nameof(seq)); m_crlID = DerObjectIdentifier.GetInstance(seq[0]); - m_crlValue = Asn1TaggedObject.GetInstance(seq[1]).GetExplicitBaseObject(); + m_crlValue = Asn1TaggedObject.GetInstance(seq[1], Asn1Tags.ContextSpecific, 0).GetExplicitBaseObject(); } public CrlBag(DerObjectIdentifier crlID, Asn1Encodable crlValue) { - m_crlID = crlID; - m_crlValue = crlValue; + m_crlID = crlID ?? throw new ArgumentNullException(nameof(crlID)); + m_crlValue = crlValue ?? throw new ArgumentNullException(nameof(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)); - } + public override Asn1Object ToAsn1Object() => new DerSequence(m_crlID, new DerTaggedObject(0, m_crlValue)); } } |