summary refs log tree commit diff
path: root/crypto/src/x509
diff options
context:
space:
mode:
Diffstat (limited to 'crypto/src/x509')
-rw-r--r--crypto/src/x509/SubjectPublicKeyInfoFactory.cs4
-rw-r--r--crypto/src/x509/X509CertPairParser.cs19
-rw-r--r--crypto/src/x509/X509Certificate.cs4
-rw-r--r--crypto/src/x509/X509Crl.cs27
-rw-r--r--crypto/src/x509/X509CrlEntry.cs5
-rw-r--r--crypto/src/x509/X509V1CertificateGenerator.cs4
-rw-r--r--crypto/src/x509/X509V2AttributeCertificate.cs14
-rw-r--r--crypto/src/x509/X509V2AttributeCertificateGenerator.cs6
-rw-r--r--crypto/src/x509/X509V2CRLGenerator.cs12
-rw-r--r--crypto/src/x509/extension/X509ExtensionUtil.cs65
-rw-r--r--crypto/src/x509/store/X509AttrCertStoreSelector.cs50
-rw-r--r--crypto/src/x509/store/X509CertStoreSelector.cs15
-rw-r--r--crypto/src/x509/store/X509CrlStoreSelector.cs10
13 files changed, 105 insertions, 130 deletions
diff --git a/crypto/src/x509/SubjectPublicKeyInfoFactory.cs b/crypto/src/x509/SubjectPublicKeyInfoFactory.cs
index d085601e3..b80e298ce 100644
--- a/crypto/src/x509/SubjectPublicKeyInfoFactory.cs
+++ b/crypto/src/x509/SubjectPublicKeyInfoFactory.cs
@@ -143,7 +143,7 @@ namespace Org.BouncyCastle.X509
                 if (_key.AlgorithmName == "ECGOST3410")
                 {
                     if (_key.PublicKeyParamSet == null)
-                        throw Platform.CreateNotImplementedException("Not a CryptoPro parameter set");
+                        throw new NotImplementedException("Not a CryptoPro parameter set");
 
                     ECPoint q = _key.Q.Normalize();
                     BigInteger bX = q.AffineXCoord.ToBigInteger();
@@ -192,7 +192,7 @@ namespace Org.BouncyCastle.X509
                 Gost3410PublicKeyParameters _key = (Gost3410PublicKeyParameters) publicKey;
 
                 if (_key.PublicKeyParamSet == null)
-                    throw Platform.CreateNotImplementedException("Not a CryptoPro parameter set");
+                    throw new NotImplementedException("Not a CryptoPro parameter set");
 
                 byte[] keyEnc = _key.Y.ToByteArrayUnsigned();
                 byte[] keyBytes = new byte[keyEnc.Length];
diff --git a/crypto/src/x509/X509CertPairParser.cs b/crypto/src/x509/X509CertPairParser.cs
index 89a8a8e96..26b417898 100644
--- a/crypto/src/x509/X509CertPairParser.cs
+++ b/crypto/src/x509/X509CertPairParser.cs
@@ -1,11 +1,10 @@
 using System;
-using System.Collections;
+using System.Collections.Generic;
 using System.IO;
 
 using Org.BouncyCastle.Asn1;
 using Org.BouncyCastle.Asn1.X509;
 using Org.BouncyCastle.Security.Certificates;
-using Org.BouncyCastle.Utilities;
 using Org.BouncyCastle.Utilities.IO;
 
 namespace Org.BouncyCastle.X509
@@ -27,8 +26,7 @@ namespace Org.BouncyCastle.X509
 		/// Create loading data from byte array.
 		/// </summary>
 		/// <param name="input"></param>
-		public X509CertificatePair ReadCertPair(
-			byte[] input)
+		public X509CertificatePair ReadCertPair(byte[] input)
 		{
 			return ReadCertPair(new MemoryStream(input, false));
 		}
@@ -37,14 +35,12 @@ namespace Org.BouncyCastle.X509
 		/// Create loading data from byte array.
 		/// </summary>
 		/// <param name="input"></param>
-		public ICollection ReadCertPairs(
-			byte[] input)
+		public IList<X509CertificatePair> ReadCertPairs(byte[] input)
 		{
 			return ReadCertPairs(new MemoryStream(input, false));
 		}
 
-		public X509CertificatePair ReadCertPair(
-			Stream inStream)
+		public X509CertificatePair ReadCertPair(Stream inStream)
 		{
 			if (inStream == null)
 				throw new ArgumentNullException("inStream");
@@ -85,12 +81,11 @@ namespace Org.BouncyCastle.X509
 			}
 		}
 
-		public ICollection ReadCertPairs(
-			Stream inStream)
+		public IList<X509CertificatePair> ReadCertPairs(Stream inStream)
 		{
-			X509CertificatePair certPair;
-			IList certPairs = Platform.CreateArrayList();
+			var certPairs = new List<X509CertificatePair>();
 
+			X509CertificatePair certPair;
 			while ((certPair = ReadCertPair(inStream)) != null)
 			{
 				certPairs.Add(certPair);
diff --git a/crypto/src/x509/X509Certificate.cs b/crypto/src/x509/X509Certificate.cs
index cc390f360..275b3f19e 100644
--- a/crypto/src/x509/X509Certificate.cs
+++ b/crypto/src/x509/X509Certificate.cs
@@ -56,8 +56,8 @@ namespace Org.BouncyCastle.X509
         }
 
         private readonly X509CertificateStructure c;
-        //private Hashtable pkcs12Attributes = Platform.CreateHashtable();
-        //private ArrayList pkcs12Ordering = Platform.CreateArrayList();
+        //private Dictionary<> pkcs12Attributes = new Dictionary<>();
+        //private List<> pkcs12Ordering = new List<>();
         private readonly string sigAlgName;
         private readonly byte[] sigAlgParams;
         private readonly BasicConstraints basicConstraints;
diff --git a/crypto/src/x509/X509Crl.cs b/crypto/src/x509/X509Crl.cs
index 9acebf2dd..921e9881b 100644
--- a/crypto/src/x509/X509Crl.cs
+++ b/crypto/src/x509/X509Crl.cs
@@ -1,5 +1,5 @@
 using System;
-using System.Collections;
+using System.Collections.Generic;
 using System.IO;
 using System.Text;
 
@@ -12,7 +12,6 @@ using Org.BouncyCastle.Math;
 using Org.BouncyCastle.Security;
 using Org.BouncyCastle.Security.Certificates;
 using Org.BouncyCastle.Utilities;
-using Org.BouncyCastle.Utilities.Collections;
 using Org.BouncyCastle.Utilities.Date;
 using Org.BouncyCastle.Utilities.Encoders;
 using Org.BouncyCastle.X509.Extension;
@@ -174,13 +173,13 @@ namespace Org.BouncyCastle.X509
 			}
 		}
 
-		private ISet LoadCrlEntries()
+		private ISet<X509CrlEntry> LoadCrlEntries()
 		{
-			ISet entrySet = new HashSet();
-			IEnumerable certs = c.GetRevokedCertificateEnumeration();
+			var entrySet = new HashSet<X509CrlEntry>();
+			var revoked = c.GetRevokedCertificateEnumeration();
 
 			X509Name previousCertificateIssuer = IssuerDN;
-			foreach (CrlEntry entry in certs)
+			foreach (CrlEntry entry in revoked)
 			{
 				X509CrlEntry crlEntry = new X509CrlEntry(entry, isIndirect, previousCertificateIssuer);
 				entrySet.Add(crlEntry);
@@ -193,7 +192,7 @@ namespace Org.BouncyCastle.X509
 		public virtual X509CrlEntry GetRevokedCertificate(
 			BigInteger serialNumber)
 		{
-			IEnumerable certs = c.GetRevokedCertificateEnumeration();
+			var certs = c.GetRevokedCertificateEnumeration();
 
 			X509Name previousCertificateIssuer = IssuerDN;
 			foreach (CrlEntry entry in certs)
@@ -211,14 +210,12 @@ namespace Org.BouncyCastle.X509
 			return null;
 		}
 
-		public virtual ISet GetRevokedCertificates()
+		public virtual ISet<X509CrlEntry> GetRevokedCertificates()
 		{
-			ISet entrySet = LoadCrlEntries();
+			var entrySet = LoadCrlEntries();
 
 			if (entrySet.Count > 0)
-			{
-				return entrySet; // TODO? Collections.unmodifiableSet(entrySet);
-			}
+				return entrySet;
 
 			return null;
 		}
@@ -339,7 +336,7 @@ namespace Org.BouncyCastle.X509
 
 			if (extensions != null)
 			{
-				IEnumerator e = extensions.ExtensionOids.GetEnumerator();
+				var e = extensions.ExtensionOids.GetEnumerator();
 
 				if (e.MoveNext())
 				{
@@ -348,7 +345,7 @@ namespace Org.BouncyCastle.X509
 
 				do
 				{
-					DerObjectIdentifier oid = (DerObjectIdentifier) e.Current;
+					DerObjectIdentifier oid = e.Current;
 					X509Extension ext = extensions.GetExtension(oid);
 
 					if (ext.Value != null)
@@ -404,7 +401,7 @@ namespace Org.BouncyCastle.X509
 				while (e.MoveNext());
 			}
 
-			ISet certSet = GetRevokedCertificates();
+			var certSet = GetRevokedCertificates();
 			if (certSet != null)
 			{
 				foreach (X509CrlEntry entry in certSet)
diff --git a/crypto/src/x509/X509CrlEntry.cs b/crypto/src/x509/X509CrlEntry.cs
index 9660a7099..30e0da2db 100644
--- a/crypto/src/x509/X509CrlEntry.cs
+++ b/crypto/src/x509/X509CrlEntry.cs
@@ -1,5 +1,4 @@
 using System;
-using System.Collections;
 using System.Text;
 
 using Org.BouncyCastle.Asn1;
@@ -176,14 +175,14 @@ namespace Org.BouncyCastle.X509
 
 			if (extensions != null)
 			{
-				IEnumerator e = extensions.ExtensionOids.GetEnumerator();
+				var e = extensions.ExtensionOids.GetEnumerator();
 				if (e.MoveNext())
 				{
 					buf.Append("   crlEntryExtensions:").Append(nl);
 
 					do
 					{
-						DerObjectIdentifier oid = (DerObjectIdentifier)e.Current;
+						DerObjectIdentifier oid = e.Current;
 						X509Extension ext = extensions.GetExtension(oid);
 
 						if (ext.Value != null)
diff --git a/crypto/src/x509/X509V1CertificateGenerator.cs b/crypto/src/x509/X509V1CertificateGenerator.cs
index 99543778b..aae263450 100644
--- a/crypto/src/x509/X509V1CertificateGenerator.cs
+++ b/crypto/src/x509/X509V1CertificateGenerator.cs
@@ -1,5 +1,5 @@
 using System;
-using System.Collections;
+using System.Collections.Generic;
 
 using Org.BouncyCastle.Asn1;
 using Org.BouncyCastle.Asn1.X509;
@@ -144,7 +144,7 @@ namespace Org.BouncyCastle.X509
 		/// <summary>
 		/// Allows enumeration of the signature names supported by the generator.
 		/// </summary>
-		public IEnumerable SignatureAlgNames
+		public IEnumerable<string> SignatureAlgNames
 		{
 			get { return X509Utilities.GetAlgNames(); }
 		}
diff --git a/crypto/src/x509/X509V2AttributeCertificate.cs b/crypto/src/x509/X509V2AttributeCertificate.cs
index 61bb8c879..8c6ff0062 100644
--- a/crypto/src/x509/X509V2AttributeCertificate.cs
+++ b/crypto/src/x509/X509V2AttributeCertificate.cs
@@ -1,5 +1,5 @@
 using System;
-using System.Collections;
+using System.Collections.Generic;
 using System.IO;
 
 using Org.BouncyCastle.Asn1;
@@ -235,7 +235,7 @@ namespace Org.BouncyCastle.X509
 			string oid)
 		{
 			Asn1Sequence seq = cert.ACInfo.Attributes;
-			IList list = Platform.CreateArrayList();
+			var list = new List<X509Attribute>();
 
 			for (int i = 0; i != seq.Count; i++)
 			{
@@ -251,16 +251,10 @@ namespace Org.BouncyCastle.X509
 				return null;
 			}
 
-            X509Attribute[] result = new X509Attribute[list.Count];
-            for (int i = 0; i < list.Count; ++i)
-            {
-                result[i] = (X509Attribute)list[i];
-            }
-            return result;
+			return list.ToArray();
 		}
 
-		public override bool Equals(
-			object obj)
+		public override bool Equals(object obj)
 		{
 			if (obj == this)
 				return true;
diff --git a/crypto/src/x509/X509V2AttributeCertificateGenerator.cs b/crypto/src/x509/X509V2AttributeCertificateGenerator.cs
index 2baf10c63..2e5c9c863 100644
--- a/crypto/src/x509/X509V2AttributeCertificateGenerator.cs
+++ b/crypto/src/x509/X509V2AttributeCertificateGenerator.cs
@@ -1,5 +1,5 @@
 using System;
-using System.Collections;
+using System.Collections.Generic;
 
 using Org.BouncyCastle.Asn1;
 using Org.BouncyCastle.Asn1.X509;
@@ -74,7 +74,7 @@ namespace Org.BouncyCastle.X509
 		{
 			// TODO convert bool array to bit string
 			//acInfoGen.SetIssuerUniqueID(iui);
-			throw Platform.CreateNotImplementedException("SetIssuerUniqueId()");
+			throw new NotImplementedException("SetIssuerUniqueId()");
 		}
 
 		/// <summary>Add a given extension field for the standard extensions tag.</summary>
@@ -142,7 +142,7 @@ namespace Org.BouncyCastle.X509
 		/// <summary>
 		/// Allows enumeration of the signature names supported by the generator.
 		/// </summary>
-		public IEnumerable SignatureAlgNames
+		public IEnumerable<string> SignatureAlgNames
 		{
 			get { return X509Utilities.GetAlgNames(); }
 		}
diff --git a/crypto/src/x509/X509V2CRLGenerator.cs b/crypto/src/x509/X509V2CRLGenerator.cs
index ba5c7de2d..cb316f21b 100644
--- a/crypto/src/x509/X509V2CRLGenerator.cs
+++ b/crypto/src/x509/X509V2CRLGenerator.cs
@@ -1,16 +1,13 @@
 using System;
-using System.Collections;
+using System.Collections.Generic;
 using System.IO;
 
 using Org.BouncyCastle.Asn1;
 using Org.BouncyCastle.Asn1.X509;
 using Org.BouncyCastle.Crypto;
-using Org.BouncyCastle.Crypto.Operators;
 using Org.BouncyCastle.Math;
-using Org.BouncyCastle.Security;
 using Org.BouncyCastle.Security.Certificates;
 using Org.BouncyCastle.Utilities;
-using Org.BouncyCastle.Utilities.Collections;
 
 namespace Org.BouncyCastle.X509
 {
@@ -101,13 +98,12 @@ namespace Org.BouncyCastle.X509
 		*
 		* @param other the X509Crl to source the other entries from.
 		*/
-		public void AddCrl(
-			X509Crl other)
+		public void AddCrl(X509Crl other)
 		{
 			if (other == null)
 				throw new ArgumentNullException("other");
 
-			ISet revocations = other.GetRevokedCertificates();
+			var revocations = other.GetRevokedCertificates();
 
 			if (revocations != null)
 			{
@@ -216,7 +212,7 @@ namespace Org.BouncyCastle.X509
 		/// <summary>
 		/// Allows enumeration of the signature names supported by the generator.
 		/// </summary>
-		public IEnumerable SignatureAlgNames
+		public IEnumerable<string> SignatureAlgNames
 		{
 			get { return X509Utilities.GetAlgNames(); }
 		}
diff --git a/crypto/src/x509/extension/X509ExtensionUtil.cs b/crypto/src/x509/extension/X509ExtensionUtil.cs
index 5f65ebfda..b751658e1 100644
--- a/crypto/src/x509/extension/X509ExtensionUtil.cs
+++ b/crypto/src/x509/extension/X509ExtensionUtil.cs
@@ -1,11 +1,10 @@
 using System;
-using System.Collections;
+using System.Collections.Generic;
 using System.IO;
 
 using Org.BouncyCastle.Asn1;
 using Org.BouncyCastle.Asn1.X509;
 using Org.BouncyCastle.Security.Certificates;
-using Org.BouncyCastle.Utilities;
 
 namespace Org.BouncyCastle.X509.Extension
 {
@@ -17,66 +16,64 @@ namespace Org.BouncyCastle.X509.Extension
 			return Asn1Object.FromByteArray(extensionValue.GetOctets());
 		}
 
-		public static ICollection GetIssuerAlternativeNames(
-			X509Certificate cert)
+		public static IList<IList<object>> GetIssuerAlternativeNames(X509Certificate cert)
 		{
 			Asn1OctetString extVal = cert.GetExtensionValue(X509Extensions.IssuerAlternativeName);
 
 			return GetAlternativeName(extVal);
 		}
 
-		public static ICollection GetSubjectAlternativeNames(
-			X509Certificate cert)
+		public static IList<IList<object>> GetSubjectAlternativeNames(X509Certificate cert)
 		{
 			Asn1OctetString extVal = cert.GetExtensionValue(X509Extensions.SubjectAlternativeName);
 
 			return GetAlternativeName(extVal);
 		}
 
-		private static ICollection GetAlternativeName(
+		private static IList<IList<object>> GetAlternativeName(
 			Asn1OctetString extVal)
 		{
-			IList temp = Platform.CreateArrayList();
+			var result = new List<IList<object>>();
 
 			if (extVal != null)
 			{
 				try
 				{
-					Asn1Sequence seq = DerSequence.GetInstance(FromExtensionValue(extVal));
+					Asn1Sequence seq = Asn1Sequence.GetInstance(FromExtensionValue(extVal));
 
 					foreach (Asn1Encodable primName in seq)
 					{
-                        IList list = Platform.CreateArrayList();
-                        GeneralName genName = GeneralName.GetInstance(primName);
+						GeneralName genName = GeneralName.GetInstance(primName);
 
+						var list = new List<object>(2);
 						list.Add(genName.TagNo);
 
 						switch (genName.TagNo)
 						{
-							case GeneralName.EdiPartyName:
-							case GeneralName.X400Address:
-							case GeneralName.OtherName:
-								list.Add(genName.Name.ToAsn1Object());
-								break;
-							case GeneralName.DirectoryName:
-								list.Add(X509Name.GetInstance(genName.Name).ToString());
-								break;
-							case GeneralName.DnsName:
-							case GeneralName.Rfc822Name:
-							case GeneralName.UniformResourceIdentifier:
-								list.Add(((IAsn1String)genName.Name).GetString());
-								break;
-							case GeneralName.RegisteredID:
-								list.Add(DerObjectIdentifier.GetInstance(genName.Name).Id);
-								break;
-							case GeneralName.IPAddress:
-								list.Add(DerOctetString.GetInstance(genName.Name).GetOctets());
-								break;
-							default:
-								throw new IOException("Bad tag number: " + genName.TagNo);
+						case GeneralName.EdiPartyName:
+						case GeneralName.X400Address:
+						case GeneralName.OtherName:
+							list.Add(genName.Name.ToAsn1Object());
+							break;
+						case GeneralName.DirectoryName:
+							list.Add(X509Name.GetInstance(genName.Name).ToString());
+							break;
+						case GeneralName.DnsName:
+						case GeneralName.Rfc822Name:
+						case GeneralName.UniformResourceIdentifier:
+							list.Add(((IAsn1String)genName.Name).GetString());
+							break;
+						case GeneralName.RegisteredID:
+							list.Add(DerObjectIdentifier.GetInstance(genName.Name).Id);
+							break;
+						case GeneralName.IPAddress:
+							list.Add(Asn1OctetString.GetInstance(genName.Name).GetOctets());
+							break;
+						default:
+							throw new IOException("Bad tag number: " + genName.TagNo);
 						}
 
-						temp.Add(list);
+						result.Add(list);
 					}
 				}
 				catch (Exception e)
@@ -85,7 +82,7 @@ namespace Org.BouncyCastle.X509.Extension
 				}
 			}
 
-			return temp;
+			return result;
 		}
 	}
 }
diff --git a/crypto/src/x509/store/X509AttrCertStoreSelector.cs b/crypto/src/x509/store/X509AttrCertStoreSelector.cs
index b25d0de19..5744289e9 100644
--- a/crypto/src/x509/store/X509AttrCertStoreSelector.cs
+++ b/crypto/src/x509/store/X509AttrCertStoreSelector.cs
@@ -1,5 +1,5 @@
 using System;
-using System.Collections;
+using System.Collections.Generic;
 
 using Org.BouncyCastle.Asn1;
 using Org.BouncyCastle.Asn1.X509;
@@ -27,8 +27,8 @@ namespace Org.BouncyCastle.X509.Store
 		private AttributeCertificateHolder holder;
 		private AttributeCertificateIssuer issuer;
 		private BigInteger serialNumber;
-		private ISet targetNames = new HashSet();
-		private ISet targetGroups = new HashSet();
+		private ISet<GeneralName> targetNames = new HashSet<GeneralName>();
+		private ISet<GeneralName> targetGroups = new HashSet<GeneralName>();
 
 		public X509AttrCertStoreSelector()
 		{
@@ -42,8 +42,8 @@ namespace Org.BouncyCastle.X509.Store
 			this.holder = o.holder;
 			this.issuer = o.issuer;
 			this.serialNumber = o.serialNumber;
-			this.targetGroups = new HashSet(o.targetGroups);
-			this.targetNames = new HashSet(o.targetNames);
+			this.targetGroups = new HashSet<GeneralName>(o.targetGroups);
+			this.targetNames = new HashSet<GeneralName>(o.targetNames);
 		}
 
 		/// <summary>
@@ -225,8 +225,7 @@ namespace Org.BouncyCastle.X509.Store
 		* @param name a byte array containing the name in ASN.1 DER encoded form of a GeneralName
 		* @throws IOException if a parsing error occurs.
 		*/
-		public void AddTargetName(
-			byte[] name)
+		public void AddTargetName(byte[] name)
 		{
 			AddTargetName(GeneralName.GetInstance(Asn1Object.FromByteArray(name)));
 		}
@@ -244,8 +243,7 @@ namespace Org.BouncyCastle.X509.Store
 		* @see #AddTargetName(byte[])
 		* @see #AddTargetName(GeneralName)
 		*/
-		public void SetTargetNames(
-			IEnumerable names)
+		public void SetTargetNames(IEnumerable<object> names)
 		{
 			targetNames = ExtractGeneralNames(names);
 		}
@@ -259,9 +257,9 @@ namespace Org.BouncyCastle.X509.Store
 		* @return The collection of target names
 		* @see #setTargetNames(Collection)
 		*/
-		public IEnumerable GetTargetNames()
+		public IEnumerable<GeneralName> GetTargetNames()
 		{
-			return new EnumerableProxy(targetNames);
+			return CollectionUtilities.Proxy(targetNames);
 		}
 
 		/**
@@ -277,8 +275,7 @@ namespace Org.BouncyCastle.X509.Store
 		*
 		* @param group The group as GeneralName form (not <code>null</code>)
 		*/
-		public void AddTargetGroup(
-			GeneralName group)
+		public void AddTargetGroup(GeneralName group)
 		{
 			targetGroups.Add(group);
 		}
@@ -297,8 +294,7 @@ namespace Org.BouncyCastle.X509.Store
 		* @param name a byte array containing the group in ASN.1 DER encoded form of a GeneralName
 		* @throws IOException if a parsing error occurs.
 		*/
-		public void AddTargetGroup(
-			byte[] name)
+		public void AddTargetGroup(byte[] name)
 		{
 			AddTargetGroup(GeneralName.GetInstance(Asn1Object.FromByteArray(name)));
 		}
@@ -316,8 +312,7 @@ namespace Org.BouncyCastle.X509.Store
 		* @see #AddTargetGroup(byte[])
 		* @see #AddTargetGroup(GeneralName)
 		*/
-		public void SetTargetGroups(
-			IEnumerable names)
+		public void SetTargetGroups(IEnumerable<object> names)
 		{
 			targetGroups = ExtractGeneralNames(names);
 		}
@@ -331,28 +326,31 @@ namespace Org.BouncyCastle.X509.Store
 		* @return The collection of target groups.
 		* @see #setTargetGroups(Collection)
 		*/
-		public IEnumerable GetTargetGroups()
+		public IEnumerable<GeneralName> GetTargetGroups()
 		{
-			return new EnumerableProxy(targetGroups);
+			return CollectionUtilities.Proxy(targetGroups);
 		}
 
-		private ISet ExtractGeneralNames(
-			IEnumerable names)
+		private ISet<GeneralName> ExtractGeneralNames(IEnumerable<object> names)
 		{
-			ISet result = new HashSet();
+			var result = new HashSet<GeneralName>();
 
 			if (names != null)
 			{
 				foreach (object o in names)
 				{
-					if (o is GeneralName)
+					if (o is GeneralName gn)
 					{
-						result.Add(o);
+						result.Add(gn);
 					}
-					else
+					else if (o is byte[] bs)
 					{
-						result.Add(GeneralName.GetInstance(Asn1Object.FromByteArray((byte[]) o)));
+						result.Add(GeneralName.GetInstance(Asn1Object.FromByteArray(bs)));
 					}
+					else
+                    {
+						throw new InvalidOperationException();
+                    }
 				}
 			}
 
diff --git a/crypto/src/x509/store/X509CertStoreSelector.cs b/crypto/src/x509/store/X509CertStoreSelector.cs
index 197e8f26d..71b5419a7 100644
--- a/crypto/src/x509/store/X509CertStoreSelector.cs
+++ b/crypto/src/x509/store/X509CertStoreSelector.cs
@@ -1,5 +1,5 @@
 using System;
-using System.Collections;
+using System.Collections.Generic;
 
 using Org.BouncyCastle.Asn1;
 using Org.BouncyCastle.Asn1.X509;
@@ -20,11 +20,11 @@ namespace Org.BouncyCastle.X509.Store
 		private int basicConstraints = -1;
 		private X509Certificate certificate;
 		private DateTimeObject certificateValid;
-		private ISet extendedKeyUsage;
+		private ISet<DerObjectIdentifier> extendedKeyUsage;
         private bool ignoreX509NameOrdering;
 		private X509Name issuer;
 		private bool[] keyUsage;
-		private ISet policy;
+		private ISet<DerObjectIdentifier> policy;
 		private DateTimeObject privateKeyValid;
 		private BigInteger serialNumber;
 		private X509Name subject;
@@ -91,7 +91,7 @@ namespace Org.BouncyCastle.X509.Store
 			set { certificateValid = value; }
 		}
 
-		public ISet ExtendedKeyUsage
+		public ISet<DerObjectIdentifier> ExtendedKeyUsage
 		{
 			get { return CopySet(extendedKeyUsage); }
 			set { extendedKeyUsage = CopySet(value); }
@@ -118,7 +118,7 @@ namespace Org.BouncyCastle.X509.Store
 		/// <summary>
 		/// An <code>ISet</code> of <code>DerObjectIdentifier</code> objects.
 		/// </summary>
-		public ISet Policy
+		public ISet<DerObjectIdentifier> Policy
 		{
 			get { return CopySet(policy); }
 			set { policy = CopySet(value); }
@@ -300,10 +300,9 @@ namespace Org.BouncyCastle.X509.Store
 			return b == null ? null : (bool[]) b.Clone();
 		}
 
-		private static ISet CopySet(
-			ISet s)
+		private static ISet<T> CopySet<T>(ISet<T> s)
 		{
-			return s == null ? null : new HashSet(s);
+			return s == null ? null : new HashSet<T>(s);
 		}
 
 		private static SubjectPublicKeyInfo GetSubjectPublicKey(
diff --git a/crypto/src/x509/store/X509CrlStoreSelector.cs b/crypto/src/x509/store/X509CrlStoreSelector.cs
index dcf8f8876..365ec1d38 100644
--- a/crypto/src/x509/store/X509CrlStoreSelector.cs
+++ b/crypto/src/x509/store/X509CrlStoreSelector.cs
@@ -1,5 +1,5 @@
 using System;
-using System.Collections;
+using System.Collections.Generic;
 
 using Org.BouncyCastle.Asn1;
 using Org.BouncyCastle.Asn1.X509;
@@ -18,7 +18,7 @@ namespace Org.BouncyCastle.X509.Store
 
 		private X509Certificate certificateChecking;
 		private DateTimeObject dateAndTime;
-		private ICollection issuers;
+		private IList<X509Name> issuers;
 		private BigInteger maxCrlNumber;
 		private BigInteger minCrlNumber;
 
@@ -70,10 +70,10 @@ namespace Org.BouncyCastle.X509.Store
 		/// <summary>
 		/// An <code>ICollection</code> of <code>X509Name</code> objects
 		/// </summary>
-		public ICollection Issuers
+		public IList<X509Name> Issuers
 		{
-			get { return Platform.CreateArrayList(issuers); }
-            set { issuers = Platform.CreateArrayList(value); }
+			get { return new List<X509Name>(issuers); }
+            set { issuers = new List<X509Name>(value); }
 		}
 
 		public BigInteger MaxCrlNumber