diff options
author | Peter Dettman <peter.dettman@bouncycastle.org> | 2023-02-01 21:07:46 +0700 |
---|---|---|
committer | Peter Dettman <peter.dettman@bouncycastle.org> | 2023-02-01 21:07:46 +0700 |
commit | db9b19e3f17a2aee8afcd673ef9327bb8646b87a (patch) | |
tree | a16cf94d902be26f7f00a5218cafa15fe28cf233 /crypto/src/asn1/cmp/RootCaKeyUpdateContent.cs | |
parent | Add GetInstanceFromChoice helper (diff) | |
download | BouncyCastle.NET-ed25519-db9b19e3f17a2aee8afcd673ef9327bb8646b87a.tar.xz |
Overhaul Asn1.Cmp
Diffstat (limited to 'crypto/src/asn1/cmp/RootCaKeyUpdateContent.cs')
-rw-r--r-- | crypto/src/asn1/cmp/RootCaKeyUpdateContent.cs | 20 |
1 files changed, 11 insertions, 9 deletions
diff --git a/crypto/src/asn1/cmp/RootCaKeyUpdateContent.cs b/crypto/src/asn1/cmp/RootCaKeyUpdateContent.cs index 696b08b94..64da80d6c 100644 --- a/crypto/src/asn1/cmp/RootCaKeyUpdateContent.cs +++ b/crypto/src/asn1/cmp/RootCaKeyUpdateContent.cs @@ -22,13 +22,16 @@ namespace Org.BouncyCastle.Asn1.Cmp { public static RootCaKeyUpdateContent GetInstance(object obj) { + if (obj == null) + return null; if (obj is RootCaKeyUpdateContent rootCaKeyUpdateContent) return rootCaKeyUpdateContent; + return new RootCaKeyUpdateContent(Asn1Sequence.GetInstance(obj)); + } - if (obj != null) - return new RootCaKeyUpdateContent(Asn1Sequence.GetInstance(obj)); - - return null; + public static RootCaKeyUpdateContent GetInstance(Asn1TaggedObject taggedObject, bool declaredExplicit) + { + return GetInstance(Asn1Sequence.GetInstance(taggedObject, declaredExplicit)); } private readonly CmpCertificate m_newWithNew; @@ -50,20 +53,19 @@ namespace Org.BouncyCastle.Asn1.Cmp if (seq.Count < 1 || seq.Count > 3) throw new ArgumentException("expected sequence of 1 to 3 elements only"); - CmpCertificate newWithNew; + CmpCertificate newWithNew = CmpCertificate.GetInstance(seq[0]); CmpCertificate newWithOld = null; CmpCertificate oldWithNew = null; - newWithNew = CmpCertificate.GetInstance(seq[0]); - for (int pos = 1; pos < seq.Count; ++pos) { Asn1TaggedObject ato = Asn1TaggedObject.GetInstance(seq[pos]); - if (ato.TagNo == 0) + + if (ato.HasContextTag(0)) { newWithOld = CmpCertificate.GetInstance(ato, true); } - else if (ato.TagNo == 1) + else if (ato.HasContextTag(1)) { oldWithNew = CmpCertificate.GetInstance(ato, true); } |