summary refs log tree commit diff
path: root/crypto/src/asn1/crmf/PopoPrivKey.cs
diff options
context:
space:
mode:
Diffstat (limited to 'crypto/src/asn1/crmf/PopoPrivKey.cs')
-rw-r--r--crypto/src/asn1/crmf/PopoPrivKey.cs19
1 files changed, 14 insertions, 5 deletions
diff --git a/crypto/src/asn1/crmf/PopoPrivKey.cs b/crypto/src/asn1/crmf/PopoPrivKey.cs
index e7cef784c..6e2d695da 100644
--- a/crypto/src/asn1/crmf/PopoPrivKey.cs
+++ b/crypto/src/asn1/crmf/PopoPrivKey.cs
@@ -13,6 +13,20 @@ namespace Org.BouncyCastle.Asn1.Crmf
         public const int agreeMAC = 3;
         public const int encryptedKey = 4;
 
+        public static PopoPrivKey GetInstance(object obj)
+        {
+            if (obj == null)
+                return null;
+            if (obj is PopoPrivKey popoPrivKey)
+                return popoPrivKey;
+            return new PopoPrivKey(Asn1TaggedObject.GetInstance(obj, Asn1Tags.ContextSpecific));
+        }
+
+        public static PopoPrivKey GetInstance(Asn1TaggedObject tagged, bool isExplicit)
+        {
+            return Asn1Utilities.GetInstanceFromChoice(tagged, isExplicit, GetInstance);
+        }
+
         private readonly int tagNo;
         private readonly Asn1Encodable obj;
 
@@ -42,11 +56,6 @@ namespace Org.BouncyCastle.Asn1.Crmf
             }
         }
 
-        public static PopoPrivKey GetInstance(Asn1TaggedObject tagged, bool isExplicit)
-        {
-            return new PopoPrivKey(Asn1TaggedObject.GetInstance(tagged, true));
-        }
-
         public PopoPrivKey(PKMacValue pkMacValue)
         {
             this.tagNo = agreeMAC;