summary refs log tree commit diff
path: root/crypto/src/asn1/Asn1ObjectDescriptor.cs
diff options
context:
space:
mode:
authorPeter Dettman <peter.dettman@bouncycastle.org>2021-11-08 16:45:05 +0700
committerPeter Dettman <peter.dettman@bouncycastle.org>2021-11-08 16:45:05 +0700
commit43ca80887364141adace03abe88b52f211f0e07e (patch)
treef4f851abab8f11c75ce61031d8a4dfe0e64b2936 /crypto/src/asn1/Asn1ObjectDescriptor.cs
parentMore tagged object work from bc-java (diff)
downloadBouncyCastle.NET-ed25519-43ca80887364141adace03abe88b52f211f0e07e.tar.xz
ASN.1 refactoring
Diffstat (limited to 'crypto/src/asn1/Asn1ObjectDescriptor.cs')
-rw-r--r--crypto/src/asn1/Asn1ObjectDescriptor.cs15
1 files changed, 8 insertions, 7 deletions
diff --git a/crypto/src/asn1/Asn1ObjectDescriptor.cs b/crypto/src/asn1/Asn1ObjectDescriptor.cs
index 20158af8e..e5cc42450 100644
--- a/crypto/src/asn1/Asn1ObjectDescriptor.cs
+++ b/crypto/src/asn1/Asn1ObjectDescriptor.cs
@@ -1,4 +1,5 @@
 using System;
+using System.IO;
 
 using Org.BouncyCastle.Utilities;
 
@@ -20,21 +21,21 @@ namespace Org.BouncyCastle.Asn1
             {
                 return (Asn1ObjectDescriptor)obj;
             }
-            else if (obj is Asn1Encodable)
+            else if (obj is IAsn1Convertible)
             {
-                Asn1Object asn1 = ((Asn1Encodable)obj).ToAsn1Object();
-                if (asn1 is Asn1ObjectDescriptor)
-                    return (Asn1ObjectDescriptor)asn1;
+                Asn1Object asn1Object = ((IAsn1Convertible)obj).ToAsn1Object();
+                if (asn1Object is Asn1ObjectDescriptor)
+                    return (Asn1ObjectDescriptor)asn1Object;
             }
-            if (obj is byte[])
+            else if (obj is byte[])
             {
                 try
                 {
                     return GetInstance(FromByteArray((byte[])obj));
                 }
-                catch (Exception e)
+                catch (IOException e)
                 {
-                    throw new ArgumentException("encoding error in GetInstance: " + e.ToString(), "obj");
+                    throw new ArgumentException("failed to construct object descriptor from byte[]: " + e.Message);
                 }
             }