summary refs log tree commit diff
path: root/crypto/src/asn1
diff options
context:
space:
mode:
authorPeter Dettman <peter.dettman@bouncycastle.org>2023-04-21 00:48:58 +0700
committerPeter Dettman <peter.dettman@bouncycastle.org>2023-04-21 00:48:58 +0700
commita86c8ebc95aa0757ae20c6d5f850158bf588d3f0 (patch)
tree22f0a14234768db88ea00be6b435d6bfeea307ab /crypto/src/asn1
parentFix missing Dispose(s) of BcpgOutputStream (diff)
downloadBouncyCastle.NET-ed25519-a86c8ebc95aa0757ae20c6d5f850158bf588d3f0.tar.xz
Refactoring
Diffstat (limited to 'crypto/src/asn1')
-rw-r--r--crypto/src/asn1/pkcs/EncryptionScheme.cs32
-rw-r--r--crypto/src/asn1/x509/NameConstraints.cs6
2 files changed, 17 insertions, 21 deletions
diff --git a/crypto/src/asn1/pkcs/EncryptionScheme.cs b/crypto/src/asn1/pkcs/EncryptionScheme.cs
index 34d26e172..a073f8c17 100644
--- a/crypto/src/asn1/pkcs/EncryptionScheme.cs
+++ b/crypto/src/asn1/pkcs/EncryptionScheme.cs
@@ -1,13 +1,24 @@
-using System;
-
 using Org.BouncyCastle.Asn1.X509;
-using Org.BouncyCastle.Utilities;
 
 namespace Org.BouncyCastle.Asn1.Pkcs
 {
     public class EncryptionScheme
         : AlgorithmIdentifier
     {
+        public new static EncryptionScheme GetInstance(object obj)
+        {
+            if (obj == null)
+                return null;
+            if (obj is EncryptionScheme encryptionScheme)
+                return encryptionScheme;
+            return new EncryptionScheme(Asn1Sequence.GetInstance(obj));
+        }
+
+        public new static EncryptionScheme GetInstance(Asn1TaggedObject taggedObject, bool declaredExplicit)
+        {
+            return GetInstance(Asn1Sequence.GetInstance(taggedObject, declaredExplicit));
+        }
+
         public EncryptionScheme(
             DerObjectIdentifier	objectID)
             : base(objectID)
@@ -27,21 +38,6 @@ namespace Org.BouncyCastle.Asn1.Pkcs
         {
         }
 
-		public new static EncryptionScheme GetInstance(object obj)
-		{
-			if (obj is EncryptionScheme)
-			{
-				return (EncryptionScheme)obj;
-			}
-
-			if (obj is Asn1Sequence)
-			{
-				return new EncryptionScheme((Asn1Sequence)obj);
-			}
-
-			throw new ArgumentException("Unknown object in factory: " + Platform.GetTypeName(obj), "obj");
-		}
-
 		public Asn1Object Asn1Object
 		{
 			get { return Parameters.ToAsn1Object(); }
diff --git a/crypto/src/asn1/x509/NameConstraints.cs b/crypto/src/asn1/x509/NameConstraints.cs
index 031b71ceb..87db1e534 100644
--- a/crypto/src/asn1/x509/NameConstraints.cs
+++ b/crypto/src/asn1/x509/NameConstraints.cs
@@ -6,7 +6,7 @@ namespace Org.BouncyCastle.Asn1.X509
     public class NameConstraints
 		: Asn1Encodable
 	{
-		private Asn1Sequence m_permitted, m_excluded;
+		private readonly Asn1Sequence m_permitted, m_excluded;
 
 		public static NameConstraints GetInstance(object obj)
 		{
@@ -53,12 +53,12 @@ namespace Org.BouncyCastle.Asn1.X509
 		{
 			if (permitted != null)
 			{
-				this.m_permitted = CreateSequence(permitted);
+				m_permitted = CreateSequence(permitted);
 			}
 
 			if (excluded != null)
 			{
-				this.m_excluded = CreateSequence(excluded);
+				m_excluded = CreateSequence(excluded);
 			}
 		}