diff options
Diffstat (limited to 'crypto/src/asn1/cmp/Challenge.cs')
-rw-r--r-- | crypto/src/asn1/cmp/Challenge.cs | 24 |
1 files changed, 15 insertions, 9 deletions
diff --git a/crypto/src/asn1/cmp/Challenge.cs b/crypto/src/asn1/cmp/Challenge.cs index ca3d06339..21958da67 100644 --- a/crypto/src/asn1/cmp/Challenge.cs +++ b/crypto/src/asn1/cmp/Challenge.cs @@ -35,13 +35,16 @@ namespace Org.BouncyCastle.Asn1.Cmp { public static Challenge GetInstance(object obj) { + if (obj == null) + return null; if (obj is Challenge challenge) return challenge; + return new Challenge(Asn1Sequence.GetInstance(obj)); + } - if (obj != null) - return new Challenge(Asn1Sequence.GetInstance(obj)); - - return null; + public static Challenge GetInstance(Asn1TaggedObject taggedObject, bool declaredExplicit) + { + return GetInstance(Asn1Sequence.GetInstance(taggedObject, declaredExplicit)); } private readonly AlgorithmIdentifier m_owf; @@ -122,13 +125,16 @@ namespace Org.BouncyCastle.Asn1.Cmp { public static Rand GetInstance(object obj) { + if (obj == null) + return null; if (obj is Rand rand) return rand; + return new Rand(Asn1Sequence.GetInstance(obj)); + } - if (obj != null) - return new Rand(Asn1Sequence.GetInstance(obj)); - - return null; + public static Rand GetInstance(Asn1TaggedObject taggedObject, bool declaredExplicit) + { + return GetInstance(Asn1Sequence.GetInstance(taggedObject, declaredExplicit)); } private readonly DerInteger m_intVal; @@ -143,7 +149,7 @@ namespace Org.BouncyCastle.Asn1.Cmp public Rand(Asn1Sequence seq) { if (seq.Count != 2) - throw new ArgumentException("expected sequence size of 2"); + throw new ArgumentException("expected sequence size of 2", nameof(seq)); m_intVal = DerInteger.GetInstance(seq[0]); m_sender = GeneralName.GetInstance(seq[1]); |