summary refs log tree commit diff
path: root/crypto/src/asn1/pkcs
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/pkcs
parentFix missing Dispose(s) of BcpgOutputStream (diff)
downloadBouncyCastle.NET-ed25519-a86c8ebc95aa0757ae20c6d5f850158bf588d3f0.tar.xz
Refactoring
Diffstat (limited to 'crypto/src/asn1/pkcs')
-rw-r--r--crypto/src/asn1/pkcs/EncryptionScheme.cs32
1 files changed, 14 insertions, 18 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(); }