summary refs log tree commit diff
path: root/crypto/src/asn1/cmp/PKIMessages.cs
diff options
context:
space:
mode:
Diffstat (limited to 'crypto/src/asn1/cmp/PKIMessages.cs')
-rw-r--r--crypto/src/asn1/cmp/PKIMessages.cs26
1 files changed, 17 insertions, 9 deletions
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);
         }