summary refs log tree commit diff
path: root/crypto/src/asn1
diff options
context:
space:
mode:
authorPeter Dettman <peter.dettman@bouncycastle.org>2023-02-07 17:19:28 +0700
committerPeter Dettman <peter.dettman@bouncycastle.org>2023-02-07 17:19:28 +0700
commitd4978555b33327c750d59dc2cf2aa9874d122964 (patch)
tree17db33a8f9afdab5e2de187fd0b8616679849715 /crypto/src/asn1
parentFix serial number comparison (diff)
downloadBouncyCastle.NET-ed25519-d4978555b33327c750d59dc2cf2aa9874d122964.tar.xz
Misc. refactoring
Diffstat (limited to 'crypto/src/asn1')
-rw-r--r--crypto/src/asn1/x509/OtherName.cs27
1 files changed, 13 insertions, 14 deletions
diff --git a/crypto/src/asn1/x509/OtherName.cs b/crypto/src/asn1/x509/OtherName.cs
index 3e6a61499..bd80fe9ec 100644
--- a/crypto/src/asn1/x509/OtherName.cs
+++ b/crypto/src/asn1/x509/OtherName.cs
@@ -13,9 +13,6 @@ namespace Org.BouncyCastle.Asn1.X509
     public class OtherName
         : Asn1Encodable
     {
-        private readonly DerObjectIdentifier typeID;
-        private readonly Asn1Encodable value;
-
         /**
          * OtherName factory method.
          * @param obj the object used to construct an instance of <code>
@@ -29,13 +26,21 @@ namespace Org.BouncyCastle.Asn1.X509
          */
         public static OtherName GetInstance(object obj)
         {
-            if (obj is OtherName)
-                return (OtherName)obj;
             if (obj == null)
                 return null;
+            if (obj is OtherName otherName)
+                return otherName;
             return new OtherName(Asn1Sequence.GetInstance(obj));
         }
 
+        public static OtherName GetInstance(Asn1TaggedObject taggedObject, bool declaredExplicit)
+        {
+            return GetInstance(Asn1Sequence.GetInstance(taggedObject, declaredExplicit));
+        }
+
+        private readonly DerObjectIdentifier typeID;
+        private readonly Asn1Encodable value;
+
         /**
          * Base constructor.
          * @param typeID the type of the other name.
@@ -50,18 +55,12 @@ namespace Org.BouncyCastle.Asn1.X509
         private OtherName(Asn1Sequence seq)
         {
             this.typeID = DerObjectIdentifier.GetInstance(seq[0]);
-            this.value = DerTaggedObject.GetInstance(seq[1]).GetObject(); // explicitly tagged
+            this.value = Asn1Utilities.GetExplicitContextBaseObject(Asn1TaggedObject.GetInstance(seq[1]), tagNo: 0);
         }
 
-        public virtual DerObjectIdentifier TypeID
-        {
-            get { return typeID; }
-        }
+        public virtual DerObjectIdentifier TypeID => typeID;
 
-        public Asn1Encodable Value
-        {
-            get { return value; }
-        }
+        public Asn1Encodable Value => value;
 
         public override Asn1Object ToAsn1Object()
         {