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/Challenge.cs | |
parent | Add GetInstanceFromChoice helper (diff) | |
download | BouncyCastle.NET-ed25519-db9b19e3f17a2aee8afcd673ef9327bb8646b87a.tar.xz |
Overhaul Asn1.Cmp
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]); |