diff options
Diffstat (limited to 'crypto/src/asn1/cmp/PKIHeader.cs')
-rw-r--r-- | crypto/src/asn1/cmp/PKIHeader.cs | 29 |
1 files changed, 17 insertions, 12 deletions
diff --git a/crypto/src/asn1/cmp/PKIHeader.cs b/crypto/src/asn1/cmp/PKIHeader.cs index 7db9cde1d..6914ae613 100644 --- a/crypto/src/asn1/cmp/PKIHeader.cs +++ b/crypto/src/asn1/cmp/PKIHeader.cs @@ -16,6 +16,20 @@ namespace Org.BouncyCastle.Asn1.Cmp public static readonly int CMP_1999 = 1; public static readonly int CMP_2000 = 2; + public static PkiHeader GetInstance(object obj) + { + if (obj == null) + return null; + if (obj is PkiHeader pkiHeader) + return pkiHeader; + return new PkiHeader(Asn1Sequence.GetInstance(obj)); + } + + public static PkiHeader GetInstance(Asn1TaggedObject taggedObject, bool declaredExplicit) + { + return GetInstance(Asn1Sequence.GetInstance(taggedObject, declaredExplicit)); + } + private readonly DerInteger pvno; private readonly GeneralName sender; private readonly GeneralName recipient; @@ -37,7 +51,9 @@ namespace Org.BouncyCastle.Asn1.Cmp for (int pos = 3; pos < seq.Count; ++pos) { - Asn1TaggedObject tObj = (Asn1TaggedObject)seq[pos]; + Asn1TaggedObject tObj = Asn1TaggedObject.GetInstance(seq[pos]); + if (Asn1Tags.ContextSpecific != tObj.TagClass) + continue; switch (tObj.TagNo) { @@ -74,17 +90,6 @@ namespace Org.BouncyCastle.Asn1.Cmp } } - public static PkiHeader GetInstance(object obj) - { - if (obj is PkiHeader pkiHeader) - return pkiHeader; - - if (obj is Asn1Sequence asn1Sequence) - return new PkiHeader(asn1Sequence); - - throw new ArgumentException("Invalid object: " + Platform.GetTypeName(obj), nameof(obj)); - } - public PkiHeader( int pvno, GeneralName sender, |