summary refs log tree commit diff
diff options
context:
space:
mode:
authorPeter Dettman <peter.dettman@bouncycastle.org>2023-02-07 14:41:18 +0700
committerPeter Dettman <peter.dettman@bouncycastle.org>2023-02-07 14:41:18 +0700
commitd64e59eacdcbcb676ea758ddc0f75d70bffd8042 (patch)
treed2d01de763fa86eef5407e0464f43a40fc455e92
parentRefactor DistributionPointName (diff)
downloadBouncyCastle.NET-ed25519-d64e59eacdcbcb676ea758ddc0f75d70bffd8042.tar.xz
Refactor PopoPrivKey
-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;