From db9b19e3f17a2aee8afcd673ef9327bb8646b87a Mon Sep 17 00:00:00 2001 From: Peter Dettman Date: Wed, 1 Feb 2023 21:07:46 +0700 Subject: Overhaul Asn1.Cmp --- crypto/src/asn1/cmp/PKIMessages.cs | 26 +++++++++++++++++--------- 1 file changed, 17 insertions(+), 9 deletions(-) (limited to 'crypto/src/asn1/cmp/PKIMessages.cs') diff --git a/crypto/src/asn1/cmp/PKIMessages.cs b/crypto/src/asn1/cmp/PKIMessages.cs index 8e2e8a1ed..ea7550b9a 100644 --- a/crypto/src/asn1/cmp/PKIMessages.cs +++ b/crypto/src/asn1/cmp/PKIMessages.cs @@ -7,6 +7,20 @@ namespace Org.BouncyCastle.Asn1.Cmp public class PkiMessages : Asn1Encodable { + public static PkiMessages GetInstance(object obj) + { + if (obj == null) + return null; + if (obj is PkiMessages pkiMessages) + return pkiMessages; + return new PkiMessages(Asn1Sequence.GetInstance(obj)); + } + + public static PkiMessages GetInstance(Asn1TaggedObject taggedObject, bool declaredExplicit) + { + return GetInstance(Asn1Sequence.GetInstance(taggedObject, declaredExplicit)); + } + private Asn1Sequence m_content; internal PkiMessages(Asn1Sequence seq) @@ -14,18 +28,12 @@ namespace Org.BouncyCastle.Asn1.Cmp m_content = seq; } - public static PkiMessages GetInstance(object obj) + internal PkiMessages(PkiMessages other) { - if (obj is PkiMessages pkiMessages) - return pkiMessages; - - if (obj is Asn1Sequence asn1Sequence) - return new PkiMessages(asn1Sequence); - - throw new ArgumentException("Invalid object: " + Platform.GetTypeName(obj), nameof(obj)); + m_content = other.m_content; } - public PkiMessages(params PkiMessage[] msgs) + public PkiMessages(params PkiMessage[] msgs) { m_content = new DerSequence(msgs); } -- cgit 1.4.1