summary refs log tree commit diff
path: root/crypto/src/asn1
diff options
context:
space:
mode:
authorPeter Dettman <peter.dettman@bouncycastle.org>2022-06-24 12:47:51 +0700
committerPeter Dettman <peter.dettman@bouncycastle.org>2022-06-24 12:47:51 +0700
commit3b73fe21b3de97c0df89fe72109c8450b7242fa7 (patch)
tree35bc2dbfb5dc40ec05ea7eb5d3a2481d68432582 /crypto/src/asn1
parentCleanup Platform (diff)
downloadBouncyCastle.NET-ed25519-3b73fe21b3de97c0df89fe72109c8450b7242fa7.tar.xz
Use generics instead of dynamic checks
Diffstat (limited to 'crypto/src/asn1')
-rw-r--r--crypto/src/asn1/esf/CertificateValues.cs7
-rw-r--r--crypto/src/asn1/esf/CompleteCertificateRefs.cs7
-rw-r--r--crypto/src/asn1/esf/CompleteRevocationRefs.cs7
-rw-r--r--crypto/src/asn1/esf/CrlListID.cs7
-rw-r--r--crypto/src/asn1/esf/OcspListID.cs7
-rw-r--r--crypto/src/asn1/esf/OtherSigningCertificate.cs14
-rw-r--r--crypto/src/asn1/esf/RevocationValues.cs15
-rw-r--r--crypto/src/asn1/esf/SignaturePolicyId.cs12
8 files changed, 22 insertions, 54 deletions
diff --git a/crypto/src/asn1/esf/CertificateValues.cs b/crypto/src/asn1/esf/CertificateValues.cs
index 30a719177..ee0d2830c 100644
--- a/crypto/src/asn1/esf/CertificateValues.cs
+++ b/crypto/src/asn1/esf/CertificateValues.cs
@@ -1,9 +1,8 @@
 using System;
-using System.Collections;
+using System.Collections.Generic;
 
 using Org.BouncyCastle.Asn1.X509;
 using Org.BouncyCastle.Utilities;
-using Org.BouncyCastle.Utilities.Collections;
 
 namespace Org.BouncyCastle.Asn1.Esf
 {
@@ -57,12 +56,10 @@ namespace Org.BouncyCastle.Asn1.Esf
 		}
 
 		public CertificateValues(
-			IEnumerable certificates)
+			IEnumerable<X509CertificateStructure> certificates)
 		{
 			if (certificates == null)
 				throw new ArgumentNullException("certificates");
-			if (!CollectionUtilities.CheckElementsAreOfType(certificates, typeof(X509CertificateStructure)))
-				throw new ArgumentException("Must contain only 'X509CertificateStructure' objects", "certificates");
 
 			this.certificates = new DerSequence(
 				Asn1EncodableVector.FromEnumerable(certificates));
diff --git a/crypto/src/asn1/esf/CompleteCertificateRefs.cs b/crypto/src/asn1/esf/CompleteCertificateRefs.cs
index af93700be..2ed66e3dc 100644
--- a/crypto/src/asn1/esf/CompleteCertificateRefs.cs
+++ b/crypto/src/asn1/esf/CompleteCertificateRefs.cs
@@ -1,8 +1,7 @@
 using System;
-using System.Collections;
+using System.Collections.Generic;
 
 using Org.BouncyCastle.Utilities;
-using Org.BouncyCastle.Utilities.Collections;
 
 namespace Org.BouncyCastle.Asn1.Esf
 {
@@ -56,12 +55,10 @@ namespace Org.BouncyCastle.Asn1.Esf
 		}
 
 		public CompleteCertificateRefs(
-			IEnumerable otherCertIDs)
+			IEnumerable<OtherCertID> otherCertIDs)
 		{
 			if (otherCertIDs == null)
 				throw new ArgumentNullException("otherCertIDs");
-			if (!CollectionUtilities.CheckElementsAreOfType(otherCertIDs, typeof(OtherCertID)))
-				throw new ArgumentException("Must contain only 'OtherCertID' objects", "otherCertIDs");
 
 			this.otherCertIDs = new DerSequence(
 				Asn1EncodableVector.FromEnumerable(otherCertIDs));
diff --git a/crypto/src/asn1/esf/CompleteRevocationRefs.cs b/crypto/src/asn1/esf/CompleteRevocationRefs.cs
index 348e63fdb..9942cec8f 100644
--- a/crypto/src/asn1/esf/CompleteRevocationRefs.cs
+++ b/crypto/src/asn1/esf/CompleteRevocationRefs.cs
@@ -1,8 +1,7 @@
 using System;
-using System.Collections;
+using System.Collections.Generic;
 
 using Org.BouncyCastle.Utilities;
-using Org.BouncyCastle.Utilities.Collections;
 
 namespace Org.BouncyCastle.Asn1.Esf
 {
@@ -56,12 +55,10 @@ namespace Org.BouncyCastle.Asn1.Esf
 		}
 
 		public CompleteRevocationRefs(
-			IEnumerable crlOcspRefs)
+			IEnumerable<CrlOcspRef> crlOcspRefs)
 		{
 			if (crlOcspRefs == null)
 				throw new ArgumentNullException("crlOcspRefs");
-			if (!CollectionUtilities.CheckElementsAreOfType(crlOcspRefs, typeof(CrlOcspRef)))
-				throw new ArgumentException("Must contain only 'CrlOcspRef' objects", "crlOcspRefs");
 
 			this.crlOcspRefs = new DerSequence(
 				Asn1EncodableVector.FromEnumerable(crlOcspRefs));
diff --git a/crypto/src/asn1/esf/CrlListID.cs b/crypto/src/asn1/esf/CrlListID.cs
index fbd4fb27c..d3c4365c5 100644
--- a/crypto/src/asn1/esf/CrlListID.cs
+++ b/crypto/src/asn1/esf/CrlListID.cs
@@ -1,8 +1,7 @@
 using System;
-using System.Collections;
+using System.Collections.Generic;
 
 using Org.BouncyCastle.Utilities;
-using Org.BouncyCastle.Utilities.Collections;
 
 namespace Org.BouncyCastle.Asn1.Esf
 {
@@ -61,12 +60,10 @@ namespace Org.BouncyCastle.Asn1.Esf
 		}
 
 		public CrlListID(
-			IEnumerable crls)
+			IEnumerable<CrlValidatedID> crls)
 		{
 			if (crls == null)
 				throw new ArgumentNullException("crls");
-			if (!CollectionUtilities.CheckElementsAreOfType(crls, typeof(CrlValidatedID)))
-				throw new ArgumentException("Must contain only 'CrlValidatedID' objects", "crls");
 
 			this.crls = new DerSequence(
 				Asn1EncodableVector.FromEnumerable(crls));
diff --git a/crypto/src/asn1/esf/OcspListID.cs b/crypto/src/asn1/esf/OcspListID.cs
index 1c8edb16b..3918dfd42 100644
--- a/crypto/src/asn1/esf/OcspListID.cs
+++ b/crypto/src/asn1/esf/OcspListID.cs
@@ -1,8 +1,7 @@
 using System;
-using System.Collections;
+using System.Collections.Generic;
 
 using Org.BouncyCastle.Utilities;
-using Org.BouncyCastle.Utilities.Collections;
 
 namespace Org.BouncyCastle.Asn1.Esf
 {
@@ -60,12 +59,10 @@ namespace Org.BouncyCastle.Asn1.Esf
 		}
 
 		public OcspListID(
-			IEnumerable ocspResponses)
+			IEnumerable<OcspResponsesID> ocspResponses)
 		{
 			if (ocspResponses == null)
 				throw new ArgumentNullException("ocspResponses");
-			if (!CollectionUtilities.CheckElementsAreOfType(ocspResponses, typeof(OcspResponsesID)))
-				throw new ArgumentException("Must contain only 'OcspResponsesID' objects", "ocspResponses");
 
 			this.ocspResponses = new DerSequence(
 				Asn1EncodableVector.FromEnumerable(ocspResponses));
diff --git a/crypto/src/asn1/esf/OtherSigningCertificate.cs b/crypto/src/asn1/esf/OtherSigningCertificate.cs
index 2b6d646bc..a4f4a0727 100644
--- a/crypto/src/asn1/esf/OtherSigningCertificate.cs
+++ b/crypto/src/asn1/esf/OtherSigningCertificate.cs
@@ -1,9 +1,8 @@
 using System;
-using System.Collections;
+using System.Collections.Generic;
 
 using Org.BouncyCastle.Asn1.X509;
 using Org.BouncyCastle.Utilities;
-using Org.BouncyCastle.Utilities.Collections;
 
 namespace Org.BouncyCastle.Asn1.Esf
 {
@@ -74,28 +73,23 @@ namespace Org.BouncyCastle.Asn1.Esf
 		}
 
 		public OtherSigningCertificate(
-			IEnumerable certs)
+			IEnumerable<OtherCertID> certs)
 			: this(certs, null)
 		{
 		}
 
 		public OtherSigningCertificate(
-			IEnumerable	certs,
-			IEnumerable	policies)
+			IEnumerable<OtherCertID> certs,
+			IEnumerable<PolicyInformation> policies)
 		{
 			if (certs == null)
 				throw new ArgumentNullException("certs");
-			if (!CollectionUtilities.CheckElementsAreOfType(certs, typeof(OtherCertID)))
-				throw new ArgumentException("Must contain only 'OtherCertID' objects", "certs");
 
 			this.certs = new DerSequence(
 				Asn1EncodableVector.FromEnumerable(certs));
 
 			if (policies != null)
 			{
-				if (!CollectionUtilities.CheckElementsAreOfType(policies, typeof(PolicyInformation)))
-					throw new ArgumentException("Must contain only 'PolicyInformation' objects", "policies");
-
 				this.policies = new DerSequence(
 					Asn1EncodableVector.FromEnumerable(policies));
 			}
diff --git a/crypto/src/asn1/esf/RevocationValues.cs b/crypto/src/asn1/esf/RevocationValues.cs
index 5be080f05..682728dde 100644
--- a/crypto/src/asn1/esf/RevocationValues.cs
+++ b/crypto/src/asn1/esf/RevocationValues.cs
@@ -1,9 +1,8 @@
 using System;
-using System.Collections;
+using System.Collections.Generic;
 
 using Org.BouncyCastle.Asn1.Ocsp;
 using Org.BouncyCastle.Asn1.X509;
-using Org.BouncyCastle.Utilities.Collections;
 
 namespace Org.BouncyCastle.Asn1.Esf
 {
@@ -90,24 +89,18 @@ namespace Org.BouncyCastle.Asn1.Esf
 		}
 
 		public RevocationValues(
-			IEnumerable			crlVals,
-			IEnumerable			ocspVals,
-			OtherRevVals		otherRevVals)
+			IEnumerable<CertificateList> crlVals,
+			IEnumerable<BasicOcspResponse> ocspVals,
+			OtherRevVals otherRevVals)
 		{
 			if (crlVals != null)
 			{
-				if (!CollectionUtilities.CheckElementsAreOfType(crlVals, typeof(CertificateList)))
-					throw new ArgumentException("Must contain only 'CertificateList' objects", "crlVals");
-
 				this.crlVals = new DerSequence(
 					Asn1EncodableVector.FromEnumerable(crlVals));
 			}
 
 			if (ocspVals != null)
 			{
-				if (!CollectionUtilities.CheckElementsAreOfType(ocspVals, typeof(BasicOcspResponse)))
-					throw new ArgumentException("Must contain only 'BasicOcspResponse' objects", "ocspVals");
-
 				this.ocspVals = new DerSequence(
 					Asn1EncodableVector.FromEnumerable(ocspVals));
 			}
diff --git a/crypto/src/asn1/esf/SignaturePolicyId.cs b/crypto/src/asn1/esf/SignaturePolicyId.cs
index 7146bb4c1..21bb40560 100644
--- a/crypto/src/asn1/esf/SignaturePolicyId.cs
+++ b/crypto/src/asn1/esf/SignaturePolicyId.cs
@@ -1,8 +1,7 @@
 using System;
-using System.Collections;
+using System.Collections.Generic;
 
 using Org.BouncyCastle.Utilities;
-using Org.BouncyCastle.Utilities.Collections;
 
 namespace Org.BouncyCastle.Asn1.Esf
 {
@@ -85,9 +84,9 @@ namespace Org.BouncyCastle.Asn1.Esf
 		}
 
 		public SignaturePolicyId(
-			DerObjectIdentifier		sigPolicyIdentifier,
-			OtherHashAlgAndValue	sigPolicyHash,
-			IEnumerable				sigPolicyQualifiers)
+			DerObjectIdentifier sigPolicyIdentifier,
+			OtherHashAlgAndValue sigPolicyHash,
+			IEnumerable<SigPolicyQualifierInfo> sigPolicyQualifiers)
 		{
 			if (sigPolicyIdentifier == null)
 				throw new ArgumentNullException("sigPolicyIdentifier");
@@ -99,9 +98,6 @@ namespace Org.BouncyCastle.Asn1.Esf
 
 			if (sigPolicyQualifiers != null)
 			{
-				if (!CollectionUtilities.CheckElementsAreOfType(sigPolicyQualifiers, typeof(SigPolicyQualifierInfo)))
-					throw new ArgumentException("Must contain only 'SigPolicyQualifierInfo' objects", "sigPolicyQualifiers");
-
 				this.sigPolicyQualifiers = new DerSequence(
 					Asn1EncodableVector.FromEnumerable(sigPolicyQualifiers));
 			}