summary refs log tree commit diff
path: root/crypto/src/asn1/x9/X962Parameters.cs
diff options
context:
space:
mode:
authorPeter Dettman <peter.dettman@bouncycastle.org>2023-07-18 12:06:03 +0700
committerPeter Dettman <peter.dettman@bouncycastle.org>2023-07-18 12:06:03 +0700
commit913eada3ad9394f1327a1feb80a3261f7c6e55bb (patch)
tree6366c1e196ad2ac249edf12a4d41d52ee2d28629 /crypto/src/asn1/x9/X962Parameters.cs
parentRefactoring around PrivateKeyInfo (diff)
downloadBouncyCastle.NET-ed25519-913eada3ad9394f1327a1feb80a3261f7c6e55bb.tar.xz
Deprecated Asn1TaggedObject.GetObject and refactor
Diffstat (limited to '')
-rw-r--r--crypto/src/asn1/x9/X962Parameters.cs29
1 files changed, 16 insertions, 13 deletions
diff --git a/crypto/src/asn1/x9/X962Parameters.cs b/crypto/src/asn1/x9/X962Parameters.cs
index b863f4bfd..af1fce1db 100644
--- a/crypto/src/asn1/x9/X962Parameters.cs
+++ b/crypto/src/asn1/x9/X962Parameters.cs
@@ -9,24 +9,22 @@ namespace Org.BouncyCastle.Asn1.X9
     {
         private readonly Asn1Object _params;
 
-		public static X962Parameters GetInstance(
-			object obj)
+		public static X962Parameters GetInstance(object obj)
 		{
-			if (obj == null || obj is X962Parameters) 
-			{
-				return (X962Parameters)obj;
-			}
+            if (obj == null)
+                return null;
 
-			if (obj is Asn1Object) 
-			{
-				return new X962Parameters((Asn1Object)obj);
-			}
+			if (obj is X962Parameters x962Parameters)
+				return x962Parameters;
 
-			if (obj is byte[])
+			if (obj is Asn1Object asn1Object)
+				return new X962Parameters(asn1Object);
+
+			if (obj is byte[] bytes)
 			{
 				try
 				{
-					return new X962Parameters(Asn1Object.FromByteArray((byte[])obj));
+					return new X962Parameters(Asn1Object.FromByteArray(bytes));
 				}
 				catch (Exception e)
 				{
@@ -34,9 +32,14 @@ namespace Org.BouncyCastle.Asn1.X9
 				}
 			}
 
-			throw new ArgumentException("unknown object in getInstance()");
+			throw new ArgumentException("unknown object in GetInstance()");
 		}
 
+        public static X962Parameters GetInstance(Asn1TaggedObject taggedObject, bool declaredExplicit)
+        {
+            return Asn1Utilities.GetInstanceFromChoice(taggedObject, declaredExplicit, GetInstance);
+        }
+
 		public X962Parameters(
             X9ECParameters ecParameters)
         {