summary refs log tree commit diff
path: root/crypto/src/asn1/DerObjectIdentifier.cs
diff options
context:
space:
mode:
authorDavid Hook <david.hook@keyfactor.com>2022-11-07 17:30:00 +1100
committerDavid Hook <david.hook@keyfactor.com>2022-11-07 17:30:00 +1100
commit146be77300207031b6b9477b8e48428278e841b8 (patch)
treed7342aad04bca424b56229d1d5eba558bbb4afd3 /crypto/src/asn1/DerObjectIdentifier.cs
parentresolve conflicts (diff)
parentGOST 2012 private key reading (diff)
downloadBouncyCastle.NET-ed25519-146be77300207031b6b9477b8e48428278e841b8.tar.xz
Merge branch 'master' of gitlab.cryptoworkshop.com:root/bc-csharp
Diffstat (limited to 'crypto/src/asn1/DerObjectIdentifier.cs')
-rw-r--r--crypto/src/asn1/DerObjectIdentifier.cs22
1 files changed, 12 insertions, 10 deletions
diff --git a/crypto/src/asn1/DerObjectIdentifier.cs b/crypto/src/asn1/DerObjectIdentifier.cs
index b10f8f8b6..cb5771958 100644
--- a/crypto/src/asn1/DerObjectIdentifier.cs
+++ b/crypto/src/asn1/DerObjectIdentifier.cs
@@ -34,21 +34,23 @@ namespace Org.BouncyCastle.Asn1
          */
         public static DerObjectIdentifier GetInstance(object obj)
         {
-            if (obj == null || obj is DerObjectIdentifier)
-            {
-                return (DerObjectIdentifier)obj;
-            }
-            else if (obj is IAsn1Convertible)
+            if (obj == null)
+                return null;
+
+            if (obj is DerObjectIdentifier derObjectIdentifier)
+                return derObjectIdentifier;
+
+            if (obj is IAsn1Convertible asn1Convertible)
             {
-                Asn1Object asn1Object = ((IAsn1Convertible)obj).ToAsn1Object();
-                if (asn1Object is DerObjectIdentifier)
-                    return (DerObjectIdentifier)asn1Object;
+                Asn1Object asn1Object = asn1Convertible.ToAsn1Object();
+                if (asn1Object is DerObjectIdentifier converted)
+                    return converted;
             }
-            else if (obj is byte[])
+            else if (obj is byte[] bytes)
             {
                 try
                 {
-                    return (DerObjectIdentifier)Meta.Instance.FromByteArray((byte[])obj);
+                    return (DerObjectIdentifier)Meta.Instance.FromByteArray(bytes);
                 }
                 catch (IOException e)
                 {