summary refs log tree commit diff
path: root/crypto/src/asn1/isismtt
diff options
context:
space:
mode:
Diffstat (limited to 'crypto/src/asn1/isismtt')
-rw-r--r--crypto/src/asn1/isismtt/ISISMTTObjectIdentifiers.cs3
-rw-r--r--crypto/src/asn1/isismtt/ocsp/RequestedCertificate.cs29
-rw-r--r--crypto/src/asn1/isismtt/x509/AdmissionSyntax.cs9
-rw-r--r--crypto/src/asn1/isismtt/x509/DeclarationOfMajority.cs4
-rw-r--r--crypto/src/asn1/isismtt/x509/ProcurationSyntax.cs8
-rw-r--r--crypto/src/asn1/isismtt/x509/ProfessionInfo.cs43
6 files changed, 30 insertions, 66 deletions
diff --git a/crypto/src/asn1/isismtt/ISISMTTObjectIdentifiers.cs b/crypto/src/asn1/isismtt/ISISMTTObjectIdentifiers.cs
index af60b030a..3c65e0024 100644
--- a/crypto/src/asn1/isismtt/ISISMTTObjectIdentifiers.cs
+++ b/crypto/src/asn1/isismtt/ISISMTTObjectIdentifiers.cs
@@ -1,6 +1,7 @@
 namespace Org.BouncyCastle.Asn1.IsisMtt
 {
-	public abstract class IsisMttObjectIdentifiers
+    // TODO[api] Make static
+    public abstract class IsisMttObjectIdentifiers
 	{
 		public static readonly DerObjectIdentifier IdIsisMtt = new DerObjectIdentifier("1.3.36.8");
 
diff --git a/crypto/src/asn1/isismtt/ocsp/RequestedCertificate.cs b/crypto/src/asn1/isismtt/ocsp/RequestedCertificate.cs
index 413b3bd7f..e2de8882d 100644
--- a/crypto/src/asn1/isismtt/ocsp/RequestedCertificate.cs
+++ b/crypto/src/asn1/isismtt/ocsp/RequestedCertificate.cs
@@ -53,35 +53,26 @@ namespace Org.BouncyCastle.Asn1.IsisMtt.Ocsp
 		private readonly byte[]						publicKeyCert;
 		private readonly byte[]						attributeCert;
 
-		public static RequestedCertificate GetInstance(
-			object obj)
+		public static RequestedCertificate GetInstance(object obj)
 		{
-			if (obj == null || obj is RequestedCertificate)
-			{
-				return (RequestedCertificate) obj;
-			}
+			if (obj == null)
+				return null;
+
+			if (obj is RequestedCertificate requestedCertificate)
+				return requestedCertificate;
 
 			if (obj is Asn1Sequence)
-			{
 				return new RequestedCertificate(X509CertificateStructure.GetInstance(obj));
-			}
 
-			if (obj is Asn1TaggedObject)
-			{
-				return new RequestedCertificate((Asn1TaggedObject) obj);
-			}
+            if (obj is Asn1TaggedObject taggedObject)
+                return new RequestedCertificate(taggedObject);
 
             throw new ArgumentException("unknown object in factory: " + Platform.GetTypeName(obj), "obj");
 		}
 
-		public static RequestedCertificate GetInstance(
-			Asn1TaggedObject	obj,
-			bool				isExplicit)
+		public static RequestedCertificate GetInstance(Asn1TaggedObject obj, bool isExplicit)
 		{
-			if (!isExplicit)
-				throw new ArgumentException("choice item must be explicitly tagged");
-
-			return GetInstance(obj.GetObject());
+			return Asn1Utilities.GetInstanceFromChoice(obj, isExplicit, GetInstance);
 		}
 
 		private RequestedCertificate(
diff --git a/crypto/src/asn1/isismtt/x509/AdmissionSyntax.cs b/crypto/src/asn1/isismtt/x509/AdmissionSyntax.cs
index 424d73c69..d7f4779d6 100644
--- a/crypto/src/asn1/isismtt/x509/AdmissionSyntax.cs
+++ b/crypto/src/asn1/isismtt/x509/AdmissionSyntax.cs
@@ -261,14 +261,7 @@ namespace Org.BouncyCastle.Asn1.IsisMtt.X509
         */
         public virtual Admissions[] GetContentsOfAdmissions()
         {
-            Admissions[] result = new Admissions[contentsOfAdmissions.Count];
-
-            for (int i = 0; i < contentsOfAdmissions.Count; ++i)
-            {
-                result[i] = Admissions.GetInstance(contentsOfAdmissions[i]);
-            }
-
-            return result;
+            return contentsOfAdmissions.MapElements(Admissions.GetInstance);
         }
     }
 }
diff --git a/crypto/src/asn1/isismtt/x509/DeclarationOfMajority.cs b/crypto/src/asn1/isismtt/x509/DeclarationOfMajority.cs
index 471776630..f20d17f6b 100644
--- a/crypto/src/asn1/isismtt/x509/DeclarationOfMajority.cs
+++ b/crypto/src/asn1/isismtt/x509/DeclarationOfMajority.cs
@@ -73,8 +73,8 @@ namespace Org.BouncyCastle.Asn1.IsisMtt.X509
 			if (obj is DeclarationOfMajority declarationOfMajority)
 				return declarationOfMajority;
 
-			if (obj is Asn1TaggedObject asn1TaggedObject)
-				return new DeclarationOfMajority(asn1TaggedObject);
+			if (obj is Asn1TaggedObject taggedObject)
+				return new DeclarationOfMajority(Asn1Utilities.CheckTagClass(taggedObject, Asn1Tags.ContextSpecific));
 
             throw new ArgumentException("unknown object in factory: " + Platform.GetTypeName(obj), nameof(obj));
 		}
diff --git a/crypto/src/asn1/isismtt/x509/ProcurationSyntax.cs b/crypto/src/asn1/isismtt/x509/ProcurationSyntax.cs
index 2fb7323c6..96047f9bd 100644
--- a/crypto/src/asn1/isismtt/x509/ProcurationSyntax.cs
+++ b/crypto/src/asn1/isismtt/x509/ProcurationSyntax.cs
@@ -85,11 +85,9 @@ namespace Org.BouncyCastle.Asn1.IsisMtt.X509
 			if (seq.Count < 1 || seq.Count > 3)
 				throw new ArgumentException("Bad sequence size: " + seq.Count);
 
-			var e = seq.GetEnumerator();
-
-			while (e.MoveNext())
+			foreach (var element in seq)
 			{
-				Asn1TaggedObject o = Asn1TaggedObject.GetInstance(e.Current);
+				Asn1TaggedObject o = Asn1TaggedObject.GetInstance(element, Asn1Tags.ContextSpecific);
 				switch (o.TagNo)
 				{
 				case 1:
@@ -99,7 +97,7 @@ namespace Org.BouncyCastle.Asn1.IsisMtt.X509
 					typeOfSubstitution = DirectoryString.GetInstance(o, true);
 					break;
 				case 3:
-					Asn1Object signingFor = o.GetObject();
+					Asn1Encodable signingFor = o.GetExplicitBaseObject();
 					if (signingFor is Asn1TaggedObject)
 					{
 						thirdPerson = GeneralName.GetInstance(signingFor);
diff --git a/crypto/src/asn1/isismtt/x509/ProfessionInfo.cs b/crypto/src/asn1/isismtt/x509/ProfessionInfo.cs
index 32ad31d9a..87e2aaa4f 100644
--- a/crypto/src/asn1/isismtt/x509/ProfessionInfo.cs
+++ b/crypto/src/asn1/isismtt/x509/ProfessionInfo.cs
@@ -326,45 +326,26 @@ namespace Org.BouncyCastle.Asn1.IsisMtt.X509
 			get { return namingAuthority; }
 		}
 
-		/**
+        /**
 		* @return Returns the professionItems.
 		*/
-		public virtual DirectoryString[] GetProfessionItems()
-		{
-			DirectoryString[] result = new DirectoryString[professionItems.Count];
-
-			for (int i = 0; i < professionItems.Count; ++i)
-			{
-				result[i] = DirectoryString.GetInstance(professionItems[i]);
-			}
-
-			return result;
-		}
+        public virtual DirectoryString[] GetProfessionItems()
+        {
+            return professionItems.MapElements(DirectoryString.GetInstance);
+        }
 
-		/**
+        /**
 		* @return Returns the professionOids.
 		*/
-		public virtual DerObjectIdentifier[] GetProfessionOids()
-		{
-			if (professionOids == null)
-			{
-				return new DerObjectIdentifier[0];
-			}
-
-			DerObjectIdentifier[] result = new DerObjectIdentifier[professionOids.Count];
-
-			for (int i = 0; i < professionOids.Count; ++i)
-			{
-				result[i] = DerObjectIdentifier.GetInstance(professionOids[i]);
-			}
-
-			return result;
-		}
+        public virtual DerObjectIdentifier[] GetProfessionOids()
+        {
+            return professionOids?.MapElements(DerObjectIdentifier.GetInstance) ?? new DerObjectIdentifier[0];
+        }
 
-		/**
+        /**
 		* @return Returns the registrationNumber.
 		*/
-		public virtual string RegistrationNumber
+        public virtual string RegistrationNumber
 		{
 			get { return registrationNumber; }
 		}