summary refs log tree commit diff
path: root/crypto/src/cms
diff options
context:
space:
mode:
authorPeter Dettman <peter.dettman@bouncycastle.org>2022-06-28 11:01:05 +0700
committerPeter Dettman <peter.dettman@bouncycastle.org>2022-06-28 11:01:05 +0700
commit18c67ac1339c9ca4f3604f5e5d44da0263b9ad21 (patch)
tree32fe34fa1251ddb8c5529d9a39a31a68641dd257 /crypto/src/cms
parentGenerics migration in Bcpg, Bzip2, Cmp (diff)
downloadBouncyCastle.NET-ed25519-18c67ac1339c9ca4f3604f5e5d44da0263b9ad21.tar.xz
Generics migration in Cms
Diffstat (limited to 'crypto/src/cms')
-rw-r--r--crypto/src/cms/CMSAttributeTableGenerator.cs5
-rw-r--r--crypto/src/cms/CMSAuthEnvelopedData.cs1
-rw-r--r--crypto/src/cms/CMSAuthenticatedData.cs1
-rw-r--r--crypto/src/cms/CMSAuthenticatedDataGenerator.cs1
-rw-r--r--crypto/src/cms/CMSAuthenticatedDataParser.cs1
-rw-r--r--crypto/src/cms/CMSCompressedDataGenerator.cs1
-rw-r--r--crypto/src/cms/CMSCompressedDataParser.cs1
-rw-r--r--crypto/src/cms/CMSEnvelopedData.cs3
-rw-r--r--crypto/src/cms/CMSEnvelopedDataGenerator.cs16
-rw-r--r--crypto/src/cms/CMSEnvelopedDataParser.cs2
-rw-r--r--crypto/src/cms/CMSEnvelopedDataStreamGenerator.cs10
-rw-r--r--crypto/src/cms/CMSEnvelopedGenerator.cs11
-rw-r--r--crypto/src/cms/CMSEnvelopedHelper.cs36
-rw-r--r--crypto/src/cms/CMSProcessableByteArray.cs1
-rw-r--r--crypto/src/cms/CMSSignedData.cs50
-rw-r--r--crypto/src/cms/CMSSignedDataGenerator.cs26
-rw-r--r--crypto/src/cms/CMSSignedDataParser.cs25
-rw-r--r--crypto/src/cms/CMSSignedDataStreamGenerator.cs58
-rw-r--r--crypto/src/cms/CMSSignedGenerator.cs582
-rw-r--r--crypto/src/cms/CMSSignedHelper.cs160
-rw-r--r--crypto/src/cms/DefaultAuthenticatedAttributeTableGenerator.cs5
-rw-r--r--crypto/src/cms/DefaultSignedAttributeTableGenerator.cs13
-rw-r--r--crypto/src/cms/EnvelopedDataHelper.cs52
-rw-r--r--crypto/src/cms/KeyAgreeRecipientInfoGenerator.cs9
-rw-r--r--crypto/src/cms/KeyAgreeRecipientInformation.cs6
-rw-r--r--crypto/src/cms/RecipientInformationStore.cs41
-rw-r--r--crypto/src/cms/SignerInformation.cs6
-rw-r--r--crypto/src/cms/SignerInformationStore.cs47
-rw-r--r--crypto/src/cms/SimpleAttributeTableGenerator.cs5
29 files changed, 542 insertions, 633 deletions
diff --git a/crypto/src/cms/CMSAttributeTableGenerator.cs b/crypto/src/cms/CMSAttributeTableGenerator.cs
index 92c9a29d9..a113bd8d4 100644
--- a/crypto/src/cms/CMSAttributeTableGenerator.cs
+++ b/crypto/src/cms/CMSAttributeTableGenerator.cs
@@ -1,5 +1,4 @@
-using System;
-using System.Collections;
+using System.Collections.Generic;
 
 using Org.BouncyCastle.Asn1.Cms;
 
@@ -20,6 +19,6 @@ namespace Org.BouncyCastle.Cms
 
 	public interface CmsAttributeTableGenerator
 	{
-		AttributeTable GetAttributes(IDictionary parameters);
+		AttributeTable GetAttributes(IDictionary<CmsAttributeTableParameter, object> parameters);
 	}
 }
diff --git a/crypto/src/cms/CMSAuthEnvelopedData.cs b/crypto/src/cms/CMSAuthEnvelopedData.cs
index d35e946ae..28a959b74 100644
--- a/crypto/src/cms/CMSAuthEnvelopedData.cs
+++ b/crypto/src/cms/CMSAuthEnvelopedData.cs
@@ -1,5 +1,4 @@
 using System;
-using System.Collections;
 using System.IO;
 
 using Org.BouncyCastle.Asn1;
diff --git a/crypto/src/cms/CMSAuthenticatedData.cs b/crypto/src/cms/CMSAuthenticatedData.cs
index 33b4cc22c..7fccad07d 100644
--- a/crypto/src/cms/CMSAuthenticatedData.cs
+++ b/crypto/src/cms/CMSAuthenticatedData.cs
@@ -1,5 +1,4 @@
 using System;
-using System.Collections;
 using System.IO;
 
 using Org.BouncyCastle.Asn1;
diff --git a/crypto/src/cms/CMSAuthenticatedDataGenerator.cs b/crypto/src/cms/CMSAuthenticatedDataGenerator.cs
index addd14c7d..9bfabe8b1 100644
--- a/crypto/src/cms/CMSAuthenticatedDataGenerator.cs
+++ b/crypto/src/cms/CMSAuthenticatedDataGenerator.cs
@@ -5,7 +5,6 @@ using Org.BouncyCastle.Asn1;
 using Org.BouncyCastle.Asn1.Cms;
 using Org.BouncyCastle.Asn1.X509;
 using Org.BouncyCastle.Crypto;
-using Org.BouncyCastle.Crypto.Generators;
 using Org.BouncyCastle.Crypto.IO;
 using Org.BouncyCastle.Crypto.Parameters;
 using Org.BouncyCastle.Security;
diff --git a/crypto/src/cms/CMSAuthenticatedDataParser.cs b/crypto/src/cms/CMSAuthenticatedDataParser.cs
index 7defafc07..bfd613229 100644
--- a/crypto/src/cms/CMSAuthenticatedDataParser.cs
+++ b/crypto/src/cms/CMSAuthenticatedDataParser.cs
@@ -1,5 +1,4 @@
 using System;
-using System.Collections;
 using System.IO;
 
 using Org.BouncyCastle.Asn1;
diff --git a/crypto/src/cms/CMSCompressedDataGenerator.cs b/crypto/src/cms/CMSCompressedDataGenerator.cs
index d51de1026..bea04752a 100644
--- a/crypto/src/cms/CMSCompressedDataGenerator.cs
+++ b/crypto/src/cms/CMSCompressedDataGenerator.cs
@@ -1,5 +1,4 @@
 using System;
-using System.Collections;
 using System.IO;
 
 using Org.BouncyCastle.Asn1;
diff --git a/crypto/src/cms/CMSCompressedDataParser.cs b/crypto/src/cms/CMSCompressedDataParser.cs
index 93dfa1286..b107ff608 100644
--- a/crypto/src/cms/CMSCompressedDataParser.cs
+++ b/crypto/src/cms/CMSCompressedDataParser.cs
@@ -1,5 +1,4 @@
 using System;
-using System.Collections;
 using System.IO;
 
 using Org.BouncyCastle.Asn1;
diff --git a/crypto/src/cms/CMSEnvelopedData.cs b/crypto/src/cms/CMSEnvelopedData.cs
index 223d0ca73..8ecdcc8d7 100644
--- a/crypto/src/cms/CMSEnvelopedData.cs
+++ b/crypto/src/cms/CMSEnvelopedData.cs
@@ -1,12 +1,9 @@
 using System;
-using System.Collections;
 using System.IO;
 
 using Org.BouncyCastle.Asn1;
 using Org.BouncyCastle.Asn1.Cms;
 using Org.BouncyCastle.Asn1.X509;
-using Org.BouncyCastle.Crypto;
-using Org.BouncyCastle.Security;
 
 namespace Org.BouncyCastle.Cms
 {
diff --git a/crypto/src/cms/CMSEnvelopedDataGenerator.cs b/crypto/src/cms/CMSEnvelopedDataGenerator.cs
index c844ca6fa..d646480e0 100644
--- a/crypto/src/cms/CMSEnvelopedDataGenerator.cs
+++ b/crypto/src/cms/CMSEnvelopedDataGenerator.cs
@@ -1,22 +1,14 @@
-using System;
-using System.Collections;
+using System.Collections.Generic;
 using System.IO;
 
 using Org.BouncyCastle.Asn1;
 using Org.BouncyCastle.Asn1.Cms;
-using Org.BouncyCastle.Asn1.Nist;
-using Org.BouncyCastle.Asn1.Oiw;
 using Org.BouncyCastle.Asn1.X509;
-using Org.BouncyCastle.Asn1.X9;
 using Org.BouncyCastle.Crypto;
-using Org.BouncyCastle.Crypto.Generators;
 using Org.BouncyCastle.Crypto.IO;
 using Org.BouncyCastle.Crypto.Parameters;
-using Org.BouncyCastle.Math;
 using Org.BouncyCastle.Security;
 using Org.BouncyCastle.Utilities;
-using Org.BouncyCastle.Utilities.Date;
-using Org.BouncyCastle.X509;
 
 namespace Org.BouncyCastle.Cms
 {
@@ -124,7 +116,8 @@ namespace Org.BouncyCastle.Cms
 			Asn1Set unprotectedAttrSet = null;
             if (unprotectedAttributeGenerator != null)
             {
-                Asn1.Cms.AttributeTable attrTable = unprotectedAttributeGenerator.GetAttributes(Platform.CreateHashtable());
+                Asn1.Cms.AttributeTable attrTable = unprotectedAttributeGenerator.GetAttributes(
+                    new Dictionary<CmsAttributeTableParameter, object>());
 
                 unprotectedAttrSet = new BerSet(attrTable.ToAsn1EncodableVector());
             }
@@ -212,7 +205,8 @@ namespace Org.BouncyCastle.Cms
             Asn1Set unprotectedAttrSet = null;
             if (unprotectedAttributeGenerator != null)
             {
-                Asn1.Cms.AttributeTable attrTable = unprotectedAttributeGenerator.GetAttributes(Platform.CreateHashtable());
+                Asn1.Cms.AttributeTable attrTable = unprotectedAttributeGenerator.GetAttributes(
+                    new Dictionary<CmsAttributeTableParameter, object>());
 
                 unprotectedAttrSet = new BerSet(attrTable.ToAsn1EncodableVector());
             }
diff --git a/crypto/src/cms/CMSEnvelopedDataParser.cs b/crypto/src/cms/CMSEnvelopedDataParser.cs
index d5dfaf53d..d273ea648 100644
--- a/crypto/src/cms/CMSEnvelopedDataParser.cs
+++ b/crypto/src/cms/CMSEnvelopedDataParser.cs
@@ -1,11 +1,9 @@
 using System;
-using System.Collections;
 using System.IO;
 
 using Org.BouncyCastle.Asn1;
 using Org.BouncyCastle.Asn1.Cms;
 using Org.BouncyCastle.Asn1.X509;
-using Org.BouncyCastle.Crypto;
 
 namespace Org.BouncyCastle.Cms
 {
diff --git a/crypto/src/cms/CMSEnvelopedDataStreamGenerator.cs b/crypto/src/cms/CMSEnvelopedDataStreamGenerator.cs
index c08b30787..261f67a15 100644
--- a/crypto/src/cms/CMSEnvelopedDataStreamGenerator.cs
+++ b/crypto/src/cms/CMSEnvelopedDataStreamGenerator.cs
@@ -1,21 +1,16 @@
 using System;
-using System.Collections;
+using System.Collections.Generic;
 using System.IO;
 
 using Org.BouncyCastle.Asn1;
 using Org.BouncyCastle.Asn1.Cms;
-using Org.BouncyCastle.Asn1.Nist;
 using Org.BouncyCastle.Asn1.X509;
 using Org.BouncyCastle.Crypto;
-using Org.BouncyCastle.Crypto.Engines;
-using Org.BouncyCastle.Crypto.Generators;
 using Org.BouncyCastle.Crypto.IO;
 using Org.BouncyCastle.Crypto.Parameters;
 using Org.BouncyCastle.Security;
-using Org.BouncyCastle.Security.Certificates;
 using Org.BouncyCastle.Utilities;
 using Org.BouncyCastle.Utilities.IO;
-using Org.BouncyCastle.X509;
 
 namespace Org.BouncyCastle.Cms
 {
@@ -287,7 +282,8 @@ namespace Org.BouncyCastle.Cms
 
                 if (_outer.unprotectedAttributeGenerator != null)
                 {
-                    Asn1.Cms.AttributeTable attrTable = _outer.unprotectedAttributeGenerator.GetAttributes(Platform.CreateHashtable());
+					Asn1.Cms.AttributeTable attrTable = _outer.unprotectedAttributeGenerator.GetAttributes(
+						new Dictionary<CmsAttributeTableParameter, object>());
 
                     Asn1Set unprotectedAttrs = new BerSet(attrTable.ToAsn1EncodableVector());
 
diff --git a/crypto/src/cms/CMSEnvelopedGenerator.cs b/crypto/src/cms/CMSEnvelopedGenerator.cs
index d7d3e4bbf..e0a94c4d3 100644
--- a/crypto/src/cms/CMSEnvelopedGenerator.cs
+++ b/crypto/src/cms/CMSEnvelopedGenerator.cs
@@ -1,5 +1,5 @@
 using System;
-using System.Collections;
+using System.Collections.Generic;
 
 using Org.BouncyCastle.Asn1;
 using Org.BouncyCastle.Asn1.Cms;
@@ -13,7 +13,6 @@ using Org.BouncyCastle.Crypto;
 using Org.BouncyCastle.Crypto.Operators;
 using Org.BouncyCastle.Crypto.Parameters;
 using Org.BouncyCastle.Security;
-using Org.BouncyCastle.Utilities;
 using Org.BouncyCastle.X509;
 
 namespace Org.BouncyCastle.Cms
@@ -100,7 +99,7 @@ namespace Org.BouncyCastle.Cms
 		public static readonly string ECDHSha1Kdf		= X9ObjectIdentifiers.DHSinglePassStdDHSha1KdfScheme.Id;
 		public static readonly string ECMqvSha1Kdf		= X9ObjectIdentifiers.MqvSinglePassSha1KdfScheme.Id;
 
-		internal readonly IList recipientInfoGenerators = Platform.CreateArrayList();
+		internal readonly IList<RecipientInfoGenerator> recipientInfoGenerators = new List<RecipientInfoGenerator>();
 		internal readonly SecureRandom rand;
 
         internal CmsAttributeTableGenerator unprotectedAttributeGenerator = null;
@@ -216,7 +215,7 @@ namespace Org.BouncyCastle.Cms
 			X509Certificate			recipientCert,
 			string					cekWrapAlgorithm)
 		{
-            IList recipientCerts = Platform.CreateArrayList(1);
+            var recipientCerts = new List<X509Certificate>(1);
 			recipientCerts.Add(recipientCert);
 
 			AddKeyAgreementRecipients(agreementAlgorithm, senderPrivateKey, senderPublicKey,
@@ -238,7 +237,7 @@ namespace Org.BouncyCastle.Cms
 			string					agreementAlgorithm,
 			AsymmetricKeyParameter	senderPrivateKey,
 			AsymmetricKeyParameter	senderPublicKey,
-			ICollection				recipientCerts,
+			IEnumerable<X509Certificate> recipientCerts,
 			string					cekWrapAlgorithm)
 		{
 			if (!senderPrivateKey.IsPrivate)
@@ -254,7 +253,7 @@ namespace Org.BouncyCastle.Cms
 			KeyAgreeRecipientInfoGenerator karig = new KeyAgreeRecipientInfoGenerator();
 			karig.KeyAgreementOID = new DerObjectIdentifier(agreementAlgorithm);
 			karig.KeyEncryptionOID = new DerObjectIdentifier(cekWrapAlgorithm);
-			karig.RecipientCerts = recipientCerts;
+			karig.RecipientCerts = new List<X509Certificate>(recipientCerts);
 			karig.SenderKeyPair = new AsymmetricCipherKeyPair(senderPublicKey, senderPrivateKey);
 
 			recipientInfoGenerators.Add(karig);
diff --git a/crypto/src/cms/CMSEnvelopedHelper.cs b/crypto/src/cms/CMSEnvelopedHelper.cs
index 930ffcbf1..91f5ab910 100644
--- a/crypto/src/cms/CMSEnvelopedHelper.cs
+++ b/crypto/src/cms/CMSEnvelopedHelper.cs
@@ -1,5 +1,5 @@
 using System;
-using System.Collections;
+using System.Collections.Generic;
 using System.IO;
 
 using Org.BouncyCastle.Asn1;
@@ -9,7 +9,6 @@ using Org.BouncyCastle.Crypto;
 using Org.BouncyCastle.Crypto.IO;
 using Org.BouncyCastle.Crypto.Parameters;
 using Org.BouncyCastle.Security;
-using Org.BouncyCastle.Utilities;
 using Org.BouncyCastle.Utilities.IO;
 
 namespace Org.BouncyCastle.Cms
@@ -18,8 +17,8 @@ namespace Org.BouncyCastle.Cms
 	{
 		internal static readonly CmsEnvelopedHelper Instance = new CmsEnvelopedHelper();
 
-		private static readonly IDictionary KeySizes = Platform.CreateHashtable();
-		private static readonly IDictionary BaseCipherNames = Platform.CreateHashtable();
+		private static readonly IDictionary<string, int> KeySizes = new Dictionary<string, int>();
+		private static readonly IDictionary<string, string> BaseCipherNames = new Dictionary<string, string>();
 
 		static CmsEnvelopedHelper()
 		{
@@ -76,35 +75,32 @@ namespace Org.BouncyCastle.Cms
 			}
 		}
 
-		internal string GetRfc3211WrapperName(
-			string oid)
+		internal string GetRfc3211WrapperName(string oid)
 		{
 			if (oid == null)
-				throw new ArgumentNullException("oid");
+				throw new ArgumentNullException(nameof(oid));
 
-			string alg = (string) BaseCipherNames[oid];
-
-			if (alg == null)
-				throw new ArgumentException("no name for " + oid, "oid");
+			if (!BaseCipherNames.TryGetValue(oid, out var alg))
+				throw new ArgumentException("no name for " + oid, nameof(oid));
 
 			return alg + "RFC3211Wrap";
 		}
 
-		internal int GetKeySize(
-			string oid)
+		internal int GetKeySize(string oid)
 		{
-			if (!KeySizes.Contains(oid))
-			{
+			if (oid == null)
+				throw new ArgumentNullException(nameof(oid));
+
+			if (!KeySizes.TryGetValue(oid, out var keySize))
 				throw new ArgumentException("no keysize for " + oid, "oid");
-			}
 
-			return (int) KeySizes[oid];
+			return keySize;
 		}
 
 		internal static RecipientInformationStore BuildRecipientInformationStore(
 			Asn1Set recipientInfos, CmsSecureReadable secureReadable)
 		{
-			IList infos = Platform.CreateArrayList();
+			var infos = new List<RecipientInformation>();
 			for (int i = 0; i != recipientInfos.Count; i++)
 			{
 				RecipientInfo info = RecipientInfo.GetInstance(recipientInfos[i]);
@@ -114,8 +110,8 @@ namespace Org.BouncyCastle.Cms
 			return new RecipientInformationStore(infos);
 		}
 
-		private static void ReadRecipientInfo(
-			IList infos, RecipientInfo info, CmsSecureReadable secureReadable)
+		private static void ReadRecipientInfo(IList<RecipientInformation> infos, RecipientInfo info,
+			CmsSecureReadable secureReadable)
 		{
 			Asn1Encodable recipInfo = info.Info;
 			if (recipInfo is KeyTransRecipientInfo)
diff --git a/crypto/src/cms/CMSProcessableByteArray.cs b/crypto/src/cms/CMSProcessableByteArray.cs
index c0dd661f2..574fb5f19 100644
--- a/crypto/src/cms/CMSProcessableByteArray.cs
+++ b/crypto/src/cms/CMSProcessableByteArray.cs
@@ -1,5 +1,6 @@
 using System;
 using System.IO;
+
 using Org.BouncyCastle.Asn1;
 using Org.BouncyCastle.Asn1.Cms;
 
diff --git a/crypto/src/cms/CMSSignedData.cs b/crypto/src/cms/CMSSignedData.cs
index fdf1206a4..3d4ce05a6 100644
--- a/crypto/src/cms/CMSSignedData.cs
+++ b/crypto/src/cms/CMSSignedData.cs
@@ -1,11 +1,9 @@
 using System;
-using System.Collections;
 using System.Collections.Generic;
 using System.IO;
 
 using Org.BouncyCastle.Asn1;
 using Org.BouncyCastle.Asn1.Cms;
-using Org.BouncyCastle.Utilities;
 using Org.BouncyCastle.Utilities.Collections;
 using Org.BouncyCastle.X509;
 
@@ -42,10 +40,9 @@ namespace Org.BouncyCastle.Cms
 		private SignedData				signedData;
 		private ContentInfo				contentInfo;
 		private SignerInformationStore	signerInfoStore;
-		private IDictionary				hashes;
+		private IDictionary<string, byte[]> m_hashes;
 
-		private CmsSignedData(
-			CmsSignedData c)
+		private CmsSignedData(CmsSignedData c)
 		{
 			this.signedData = c.signedData;
 			this.contentInfo = c.contentInfo;
@@ -53,15 +50,12 @@ namespace Org.BouncyCastle.Cms
 			this.signerInfoStore = c.signerInfoStore;
 		}
 
-		public CmsSignedData(
-			byte[] sigBlock)
+		public CmsSignedData(byte[] sigBlock)
 			: this(CmsUtilities.ReadContentInfo(new MemoryStream(sigBlock, false)))
 		{
 		}
 
-		public CmsSignedData(
-			CmsProcessable	signedContent,
-			byte[]			sigBlock)
+		public CmsSignedData(CmsProcessable signedContent, byte[] sigBlock)
 			: this(signedContent, CmsUtilities.ReadContentInfo(new MemoryStream(sigBlock, false)))
 		{
 		}
@@ -72,9 +66,7 @@ namespace Org.BouncyCastle.Cms
 		 * @param hashes a map of precomputed digests for content indexed by name of hash.
 		 * @param sigBlock the signature object.
 		 */
-		public CmsSignedData(
-			IDictionary	hashes,
-			byte[]		sigBlock)
+		public CmsSignedData(IDictionary<string, byte[]> hashes, byte[] sigBlock)
 			: this(hashes, CmsUtilities.ReadContentInfo(sigBlock))
 		{
 		}
@@ -85,9 +77,7 @@ namespace Org.BouncyCastle.Cms
 		* @param signedContent the content that was signed.
 		* @param sigData the signature object.
 		*/
-		public CmsSignedData(
-			CmsProcessable	signedContent,
-			Stream			sigData)
+		public CmsSignedData(CmsProcessable signedContent, Stream sigData)
 			: this(signedContent, CmsUtilities.ReadContentInfo(sigData))
 		{
 		}
@@ -95,32 +85,26 @@ namespace Org.BouncyCastle.Cms
 		/**
 		* base constructor - with encapsulated content
 		*/
-		public CmsSignedData(
-			Stream sigData)
+		public CmsSignedData(Stream sigData)
 			: this(CmsUtilities.ReadContentInfo(sigData))
 		{
 		}
 
-		public CmsSignedData(
-			CmsProcessable  signedContent,
-			ContentInfo     sigData)
+		public CmsSignedData(CmsProcessable signedContent, ContentInfo sigData)
 		{
 			this.signedContent = signedContent;
 			this.contentInfo = sigData;
 			this.signedData = SignedData.GetInstance(contentInfo.Content);
 		}
 
-		public CmsSignedData(
-			IDictionary	hashes,
-			ContentInfo	sigData)
+		public CmsSignedData(IDictionary<string, byte[]> hashes, ContentInfo sigData)
 		{
-			this.hashes = hashes;
+			this.m_hashes = hashes;
 			this.contentInfo = sigData;
 			this.signedData = SignedData.GetInstance(contentInfo.Content);
 		}
 
-		public CmsSignedData(
-			ContentInfo sigData)
+		public CmsSignedData(ContentInfo sigData)
 		{
 			this.contentInfo = sigData;
 			this.signedData = SignedData.GetInstance(contentInfo.Content);
@@ -154,7 +138,7 @@ namespace Org.BouncyCastle.Cms
 		{
 			if (signerInfoStore == null)
 			{
-                IList signerInfos = Platform.CreateArrayList();
+				var signerInfos = new List<SignerInformation>();
 				Asn1Set s = signedData.SignerInfos;
 
 				foreach (object obj in s)
@@ -162,16 +146,18 @@ namespace Org.BouncyCastle.Cms
 					SignerInfo info = SignerInfo.GetInstance(obj);
 					DerObjectIdentifier contentType = signedData.EncapContentInfo.ContentType;
 
-					if (hashes == null)
+					if (m_hashes == null)
 					{
 						signerInfos.Add(new SignerInformation(info, contentType, signedContent, null));
 					}
-					else
+					else if (m_hashes.TryGetValue(info.DigestAlgorithm.Algorithm.Id, out var hash))
 					{
-                        byte[] hash = (byte[])hashes[info.DigestAlgorithm.Algorithm.Id];
-
 						signerInfos.Add(new SignerInformation(info, contentType, null, new BaseDigestCalculator(hash)));
 					}
+					else
+                    {
+						throw new InvalidOperationException();
+                    }
 				}
 
 				signerInfoStore = new SignerInformationStore(signerInfos);
diff --git a/crypto/src/cms/CMSSignedDataGenerator.cs b/crypto/src/cms/CMSSignedDataGenerator.cs
index 3db000896..596c6a130 100644
--- a/crypto/src/cms/CMSSignedDataGenerator.cs
+++ b/crypto/src/cms/CMSSignedDataGenerator.cs
@@ -1,5 +1,5 @@
 using System;
-using System.Collections;
+using System.Collections.Generic;
 using System.IO;
 
 using Org.BouncyCastle.Asn1;
@@ -38,13 +38,13 @@ namespace Org.BouncyCastle.Cms
     {
 		private static readonly CmsSignedHelper Helper = CmsSignedHelper.Instance;
 
-		private readonly IList signerInfs = Platform.CreateArrayList();
+		private readonly IList<SignerInf> signerInfs = new List<SignerInf>();
 
 		private class SignerInf
         {
             private readonly CmsSignedGenerator outer;
 
-			private readonly ISignatureFactory		sigCalc;
+			private readonly ISignatureFactory			sigCalc;
 			private readonly SignerIdentifier			signerIdentifier;
 			private readonly string						digestOID;
 			private readonly string						encOID;
@@ -87,7 +87,8 @@ namespace Org.BouncyCastle.Cms
                 this.outer = outer;
                 this.sigCalc = sigCalc;
                 this.signerIdentifier = signerIdentifier;
-                this.digestOID = new DefaultDigestAlgorithmIdentifierFinder().find((AlgorithmIdentifier)sigCalc.AlgorithmDetails).Algorithm.Id;
+                this.digestOID = new DefaultDigestAlgorithmIdentifierFinder().Find(
+					(AlgorithmIdentifier)sigCalc.AlgorithmDetails).Algorithm.Id;
                 this.encOID = ((AlgorithmIdentifier)sigCalc.AlgorithmDetails).Algorithm.Id;
                 this.sAttr = sAttr;
                 this.unsAttr = unsAttr;
@@ -118,13 +119,8 @@ namespace Org.BouncyCastle.Cms
 				string digestName = Helper.GetDigestAlgName(digestOID);
 
 				string signatureName = digestName + "with" + Helper.GetEncryptionAlgName(encOID);
-				
-                byte[] hash;
-                if (outer._digests.Contains(digestOID))
-                {
-                    hash = (byte[])outer._digests[digestOID];
-                }
-                else
+
+				if (!outer.m_digests.TryGetValue(digestOID, out var hash))
                 {
                     IDigest dig = Helper.GetDigestInstance(digestName);
                     if (content != null)
@@ -132,7 +128,7 @@ namespace Org.BouncyCastle.Cms
                         content.Write(new DigestSink(dig));
                     }
                     hash = DigestUtilities.DoFinal(dig);
-                    outer._digests.Add(digestOID, hash.Clone());
+                    outer.m_digests.Add(digestOID, (byte[])hash.Clone());
                 }
 
                 IStreamCalculator calculator = sigCalc.CreateCalculator();
@@ -141,7 +137,7 @@ namespace Org.BouncyCastle.Cms
 				Asn1Set signedAttr = null;
 				if (sAttr != null)
 				{
-					IDictionary parameters = outer.GetBaseParameters(contentType, digAlgId, hash);
+					var parameters = outer.GetBaseParameters(contentType, digAlgId, hash);
 
 //					Asn1.Cms.AttributeTable signed = sAttr.GetAttributes(Collections.unmodifiableMap(parameters));
 					Asn1.Cms.AttributeTable signed = sAttr.GetAttributes(parameters);
@@ -173,7 +169,7 @@ namespace Org.BouncyCastle.Cms
 				Asn1Set unsignedAttr = null;
 				if (unsAttr != null)
 				{
-					IDictionary baseParameters = outer.GetBaseParameters(contentType, digAlgId, hash);
+					var baseParameters = outer.GetBaseParameters(contentType, digAlgId, hash);
 					baseParameters[CmsAttributeTableParameter.Signature] = sigBytes.Clone();
 
 //					Asn1.Cms.AttributeTable unsigned = unsAttr.GetAttributes(Collections.unmodifiableMap(baseParameters));
@@ -456,7 +452,7 @@ namespace Org.BouncyCastle.Cms
             Asn1EncodableVector digestAlgs = new Asn1EncodableVector();
             Asn1EncodableVector signerInfos = new Asn1EncodableVector();
 
-			_digests.Clear(); // clear the current preserved digest state
+			m_digests.Clear(); // clear the current preserved digest state
 
 			//
             // add the precalculated SignerInfo objects.
diff --git a/crypto/src/cms/CMSSignedDataParser.cs b/crypto/src/cms/CMSSignedDataParser.cs
index fd65576ac..78e29e6a3 100644
--- a/crypto/src/cms/CMSSignedDataParser.cs
+++ b/crypto/src/cms/CMSSignedDataParser.cs
@@ -1,5 +1,4 @@
 using System;
-using System.Collections;
 using System.Collections.Generic;
 using System.IO;
 
@@ -62,7 +61,7 @@ namespace Org.BouncyCastle.Cms
 		private SignedDataParser        _signedData;
 		private DerObjectIdentifier		_signedContentType;
 		private CmsTypedStream          _signedContent;
-		private IDictionary				_digests;
+		private IDictionary<string, IDigest> m_digests;
 		private HashSet<string>			_digestOids;
 
 		private SignerInformationStore  _signerInfoStore;
@@ -106,7 +105,7 @@ namespace Org.BouncyCastle.Cms
 			{
 				this._signedContent = signedContent;
 				this._signedData = SignedDataParser.GetInstance(this.contentInfo.GetContent(Asn1Tags.Sequence));
-				this._digests = Platform.CreateHashtable();
+				this.m_digests = new Dictionary<string, IDigest>(StringComparer.OrdinalIgnoreCase);
 				this._digestOids = new HashSet<string>();
 
 				Asn1SetParser digAlgs = _signedData.GetDigestAlgorithms();
@@ -121,9 +120,9 @@ namespace Org.BouncyCastle.Cms
                         string digestOid = id.Algorithm.Id;
 						string digestName = Helper.GetDigestAlgName(digestOid);
 
-						if (!this._digests.Contains(digestName))
+						if (!this.m_digests.ContainsKey(digestName))
 						{
-							this._digests[digestName] = Helper.GetDigestInstance(digestName);
+							this.m_digests[digestName] = Helper.GetDigestInstance(digestName);
 							this._digestOids.Add(digestOid);
 						}
 					}
@@ -194,13 +193,12 @@ namespace Org.BouncyCastle.Cms
 			{
 				PopulateCertCrlSets();
 
-                IList signerInfos = Platform.CreateArrayList();
-                IDictionary hashes = Platform.CreateHashtable();
+				var signerInfos = new List<SignerInformation>();
+                var hashes = new Dictionary<string, byte[]>(StringComparer.OrdinalIgnoreCase);
 
-				foreach (object digestKey in _digests.Keys)
+				foreach (var digest in m_digests)
 				{
-					hashes[digestKey] = DigestUtilities.DoFinal(
-						(IDigest)_digests[digestKey]);
+					hashes[digest.Key] = DigestUtilities.DoFinal(digest.Value);
 				}
 
 				try
@@ -211,10 +209,9 @@ namespace Org.BouncyCastle.Cms
 					while ((o = s.ReadObject()) != null)
 					{
 						SignerInfo info = SignerInfo.GetInstance(o.ToAsn1Object());
-						string digestName = Helper.GetDigestAlgName(
-                            info.DigestAlgorithm.Algorithm.Id);
+						string digestName = Helper.GetDigestAlgName(info.DigestAlgorithm.Algorithm.Id);
 
-						byte[] hash = (byte[]) hashes[digestName];
+						byte[] hash = hashes[digestName];
 
 						signerInfos.Add(new SignerInformation(info, _signedContentType, null, new BaseDigestCalculator(hash)));
 					}
@@ -315,7 +312,7 @@ namespace Org.BouncyCastle.Cms
 
 			Stream digStream = _signedContent.ContentStream;
 
-			foreach (IDigest digest in _digests.Values)
+			foreach (var digest in m_digests.Values)
 			{
 				digStream = new DigestStream(digStream, digest, null);
 			}
diff --git a/crypto/src/cms/CMSSignedDataStreamGenerator.cs b/crypto/src/cms/CMSSignedDataStreamGenerator.cs
index 91a8b4a43..0dbdccbeb 100644
--- a/crypto/src/cms/CMSSignedDataStreamGenerator.cs
+++ b/crypto/src/cms/CMSSignedDataStreamGenerator.cs
@@ -1,5 +1,4 @@
 using System;
-using System.Collections;
 using System.Collections.Generic;
 using System.IO;
 
@@ -41,10 +40,13 @@ namespace Org.BouncyCastle.Cms
     {
 		private static readonly CmsSignedHelper Helper = CmsSignedHelper.Instance;
 
-		private readonly IList _signerInfs = Platform.CreateArrayList();
+		private readonly IList<DigestAndSignerInfoGeneratorHolder> _signerInfs =
+			new List<DigestAndSignerInfoGeneratorHolder>();
 		private readonly HashSet<string> _messageDigestOids = new HashSet<string>();
-        private readonly IDictionary _messageDigests = Platform.CreateHashtable();
-        private readonly IDictionary _messageHashes = Platform.CreateHashtable();
+		private readonly IDictionary<string, IDigest> m_messageDigests =
+			new Dictionary<string, IDigest>(StringComparer.OrdinalIgnoreCase);
+		private readonly IDictionary<string, byte[]> m_messageHashes =
+			new Dictionary<string, byte[]>(StringComparer.OrdinalIgnoreCase);
 		private bool _messageDigestsLocked;
         private int _bufferSize;
 
@@ -165,7 +167,7 @@ namespace Org.BouncyCastle.Cms
 					Asn1Set signedAttr = null;
 					if (_sAttr != null)
 					{
-						IDictionary parameters = outer.GetBaseParameters(contentType, digestAlgorithm, calculatedDigest);
+						var parameters = outer.GetBaseParameters(contentType, digestAlgorithm, calculatedDigest);
 
 //						Asn1.Cms.AttributeTable signed = _sAttr.GetAttributes(Collections.unmodifiableMap(parameters));
 						Asn1.Cms.AttributeTable signed = _sAttr.GetAttributes(parameters);
@@ -199,8 +201,7 @@ namespace Org.BouncyCastle.Cms
 					Asn1Set unsignedAttr = null;
 					if (_unsAttr != null)
 					{
-						IDictionary parameters = outer.GetBaseParameters(
-							contentType, digestAlgorithm, calculatedDigest);
+						var parameters = outer.GetBaseParameters(contentType, digestAlgorithm, calculatedDigest);
 						parameters[CmsAttributeTableParameter.Signature] = sigBytes.Clone();
 
 //						Asn1.Cms.AttributeTable unsigned = _unsAttr.getAttributes(Collections.unmodifiableMap(parameters));
@@ -245,20 +246,20 @@ namespace Org.BouncyCastle.Cms
         *
         * @param bufferSize length of octet strings to buffer the data.
         */
-        public void SetBufferSize(
-            int bufferSize)
+        public void SetBufferSize(int bufferSize)
         {
             _bufferSize = bufferSize;
         }
 
-		public void AddDigests(
-       		params string[] digestOids)
+		public void AddDigests(params string[] digestOids)
 		{
-       		AddDigests((IEnumerable) digestOids);
+			foreach (string digestOid in digestOids)
+			{
+				ConfigureDigest(digestOid);
+			}
 		}
 
-		public void AddDigests(
-			IEnumerable digestOids)
+		public void AddDigests(IEnumerable<string> digestOids)
 		{
 			foreach (string digestOid in digestOids)
 			{
@@ -579,7 +580,7 @@ namespace Org.BouncyCastle.Cms
 			Stream teeStream = GetSafeTeeOutputStream(dataOutputStream, encapStream);
 
         	// Let all the digests see the data as it is written
-			Stream digStream = AttachDigestsToOutputStream(_messageDigests.Values, teeStream);
+			Stream digStream = AttachDigestsToOutputStream(m_messageDigests.Values, teeStream);
 
 			return new CmsSignedDataOutputStream(this, digStream, signedContentType, sGen, sigGen, eiGen);
         }
@@ -598,20 +599,18 @@ namespace Org.BouncyCastle.Cms
        		}
 		}
 
-		private void ConfigureDigest(
-			string digestOid)
+		private void ConfigureDigest(string digestOid)
 		{
        		RegisterDigestOid(digestOid);
 
        		string digestName = Helper.GetDigestAlgName(digestOid);
-			IDigest dig = (IDigest)_messageDigests[digestName];
-			if (dig == null)
+
+			if (!m_messageDigests.ContainsKey(digestName))
 			{
 				if (_messageDigestsLocked)
 					throw new InvalidOperationException("Cannot configure new digests after the data stream is opened");
 
-            	dig = Helper.GetDigestInstance(digestName);
-            	_messageDigests[digestName] = dig;
+            	m_messageDigests[digestName] = Helper.GetDigestInstance(digestName);
             }
 		}
 
@@ -717,23 +716,20 @@ namespace Org.BouncyCastle.Cms
             return new DerInteger(1);
         }
 
-		private bool CheckForVersion3(
-			IList signerInfos)
+		private bool CheckForVersion3(IList<SignerInformation> signerInfos)
 		{
 			foreach (SignerInformation si in signerInfos)
 			{
 				SignerInfo s = SignerInfo.GetInstance(si.ToSignerInfo());
 
 				if (s.Version.IntValueExact == 3)
-				{
 					return true;
-				}
 			}
 
 			return false;
 		}
 
-		private static Stream AttachDigestsToOutputStream(ICollection digests, Stream s)
+		private static Stream AttachDigestsToOutputStream(IEnumerable<IDigest> digests, Stream s)
 		{
 			Stream result = s;
 			foreach (IDigest digest in digests)
@@ -822,7 +818,7 @@ namespace Org.BouncyCastle.Cms
 
                 _eiGen.Close();
 
-                outer._digests.Clear();    // clear the current preserved digest state
+                outer.m_digests.Clear();    // clear the current preserved digest state
 
 				if (outer._certs.Count > 0)
 				{
@@ -845,9 +841,9 @@ namespace Org.BouncyCastle.Cms
                 //
                 // Calculate the digest hashes
                 //
-                foreach (DictionaryEntry de in outer._messageDigests)
+                foreach (var de in outer.m_messageDigests)
                 {
-                    outer._messageHashes.Add(de.Key, DigestUtilities.DoFinal((IDigest)de.Value));
+                    outer.m_messageHashes.Add(de.Key, DigestUtilities.DoFinal(de.Value));
                 }
 
                 // TODO If the digest OIDs for precalculated signers weren't mixed in with
@@ -866,9 +862,9 @@ namespace Org.BouncyCastle.Cms
                     {
                         AlgorithmIdentifier digestAlgorithm = holder.DigestAlgorithm;
 
-                        byte[] calculatedDigest = (byte[])outer._messageHashes[
+                        byte[] calculatedDigest = outer.m_messageHashes[
                             Helper.GetDigestAlgName(holder.digestOID)];
-                        outer._digests[holder.digestOID] = calculatedDigest.Clone();
+                        outer.m_digests[holder.digestOID] = (byte[])calculatedDigest.Clone();
 
                         signerInfos.Add(holder.signerInf.Generate(_contentOID, digestAlgorithm, calculatedDigest));
                     }
diff --git a/crypto/src/cms/CMSSignedGenerator.cs b/crypto/src/cms/CMSSignedGenerator.cs
index acd353969..58f66f214 100644
--- a/crypto/src/cms/CMSSignedGenerator.cs
+++ b/crypto/src/cms/CMSSignedGenerator.cs
@@ -1,5 +1,4 @@
 using System;
-using System.Collections;
 using System.Collections.Generic;
 
 using Org.BouncyCastle.Asn1;
@@ -17,7 +16,6 @@ using Org.BouncyCastle.Asn1.TeleTrust;
 using Org.BouncyCastle.Asn1.X509;
 using Org.BouncyCastle.Asn1.X9;
 using Org.BouncyCastle.Security;
-using Org.BouncyCastle.Utilities;
 using Org.BouncyCastle.Utilities.Collections;
 using Org.BouncyCastle.X509;
 
@@ -25,11 +23,14 @@ namespace Org.BouncyCastle.Cms
 {
     public class DefaultSignatureAlgorithmIdentifierFinder
     {
-        private static readonly IDictionary algorithms = Platform.CreateHashtable();
+        private static readonly IDictionary<string, DerObjectIdentifier> m_algorithms =
+            new Dictionary<string, DerObjectIdentifier>(StringComparer.OrdinalIgnoreCase);
         private static readonly HashSet<DerObjectIdentifier> noParams = new HashSet<DerObjectIdentifier>();
-        private static readonly IDictionary _params = Platform.CreateHashtable();
+        private static readonly IDictionary<string, Asn1Encodable> m_params =
+            new Dictionary<string, Asn1Encodable>(StringComparer.OrdinalIgnoreCase);
         private static readonly HashSet<DerObjectIdentifier> pkcs15RsaEncryption = new HashSet<DerObjectIdentifier>();
-        private static readonly IDictionary digestOids = Platform.CreateHashtable();
+        private static readonly IDictionary<DerObjectIdentifier, DerObjectIdentifier> m_digestOids =
+            new Dictionary<DerObjectIdentifier, DerObjectIdentifier>();
 
         //private static readonly DerObjectIdentifier ENCRYPTION_RSA = PkcsObjectIdentifiers.RsaEncryption;
         //private static readonly DerObjectIdentifier ENCRYPTION_DSA = X9ObjectIdentifiers.IdDsaWithSha1;
@@ -42,123 +43,123 @@ namespace Org.BouncyCastle.Cms
 
         static DefaultSignatureAlgorithmIdentifierFinder()
         {
-            algorithms["MD2WITHRSAENCRYPTION"] = PkcsObjectIdentifiers.MD2WithRsaEncryption;
-            algorithms["MD2WITHRSA"] = PkcsObjectIdentifiers.MD2WithRsaEncryption;
-            algorithms["MD5WITHRSAENCRYPTION"] = PkcsObjectIdentifiers.MD5WithRsaEncryption;
-            algorithms["MD5WITHRSA"] = PkcsObjectIdentifiers.MD5WithRsaEncryption;
-            algorithms["SHA1WITHRSAENCRYPTION"] = PkcsObjectIdentifiers.Sha1WithRsaEncryption;
-            algorithms["SHA-1WITHRSAENCRYPTION"] = PkcsObjectIdentifiers.Sha1WithRsaEncryption;
-            algorithms["SHA1WITHRSA"] = PkcsObjectIdentifiers.Sha1WithRsaEncryption;
-            algorithms["SHA-1WITHRSA"] = PkcsObjectIdentifiers.Sha1WithRsaEncryption;
-            algorithms["SHA224WITHRSAENCRYPTION"] = PkcsObjectIdentifiers.Sha224WithRsaEncryption;
-            algorithms["SHA-224WITHRSAENCRYPTION"] = PkcsObjectIdentifiers.Sha224WithRsaEncryption;
-            algorithms["SHA224WITHRSA"] = PkcsObjectIdentifiers.Sha224WithRsaEncryption;
-            algorithms["SHA-224WITHRSA"] = PkcsObjectIdentifiers.Sha224WithRsaEncryption;
-            algorithms["SHA256WITHRSAENCRYPTION"] = PkcsObjectIdentifiers.Sha256WithRsaEncryption;
-            algorithms["SHA-256WITHRSAENCRYPTION"] = PkcsObjectIdentifiers.Sha256WithRsaEncryption;
-            algorithms["SHA256WITHRSA"] = PkcsObjectIdentifiers.Sha256WithRsaEncryption;
-            algorithms["SHA-256WITHRSA"] = PkcsObjectIdentifiers.Sha256WithRsaEncryption;
-            algorithms["SHA384WITHRSAENCRYPTION"] = PkcsObjectIdentifiers.Sha384WithRsaEncryption;
-            algorithms["SHA-384WITHRSAENCRYPTION"] = PkcsObjectIdentifiers.Sha384WithRsaEncryption;
-            algorithms["SHA384WITHRSA"] = PkcsObjectIdentifiers.Sha384WithRsaEncryption;
-            algorithms["SHA-384WITHRSA"] = PkcsObjectIdentifiers.Sha384WithRsaEncryption;
-            algorithms["SHA512WITHRSAENCRYPTION"] = PkcsObjectIdentifiers.Sha512WithRsaEncryption;
-            algorithms["SHA-512WITHRSAENCRYPTION"] = PkcsObjectIdentifiers.Sha512WithRsaEncryption;
-            algorithms["SHA512WITHRSA"] = PkcsObjectIdentifiers.Sha512WithRsaEncryption;
-            algorithms["SHA-512WITHRSA"] = PkcsObjectIdentifiers.Sha512WithRsaEncryption;
-            algorithms["SHA512(224)WITHRSAENCRYPTION"] = PkcsObjectIdentifiers.Sha512_224WithRSAEncryption;
-            algorithms["SHA-512(224)WITHRSAENCRYPTION"] = PkcsObjectIdentifiers.Sha512_224WithRSAEncryption;
-            algorithms["SHA512(224)WITHRSA"] = PkcsObjectIdentifiers.Sha512_224WithRSAEncryption;
-            algorithms["SHA-512(224)WITHRSA"] = PkcsObjectIdentifiers.Sha512_224WithRSAEncryption;
-            algorithms["SHA512(256)WITHRSAENCRYPTION"] = PkcsObjectIdentifiers.Sha512_256WithRSAEncryption;
-            algorithms["SHA-512(256)WITHRSAENCRYPTION"] = PkcsObjectIdentifiers.Sha512_256WithRSAEncryption;
-            algorithms["SHA512(256)WITHRSA"] = PkcsObjectIdentifiers.Sha512_256WithRSAEncryption;
-            algorithms["SHA-512(256)WITHRSA"] = PkcsObjectIdentifiers.Sha512_256WithRSAEncryption;
-            algorithms["SHA1WITHRSAANDMGF1"] = PkcsObjectIdentifiers.IdRsassaPss;
-            algorithms["SHA224WITHRSAANDMGF1"] = PkcsObjectIdentifiers.IdRsassaPss;
-            algorithms["SHA256WITHRSAANDMGF1"] = PkcsObjectIdentifiers.IdRsassaPss;
-            algorithms["SHA384WITHRSAANDMGF1"] = PkcsObjectIdentifiers.IdRsassaPss;
-            algorithms["SHA512WITHRSAANDMGF1"] = PkcsObjectIdentifiers.IdRsassaPss;
-            algorithms["SHA3-224WITHRSAANDMGF1"] = PkcsObjectIdentifiers.IdRsassaPss;
-            algorithms["SHA3-256WITHRSAANDMGF1"] = PkcsObjectIdentifiers.IdRsassaPss;
-            algorithms["SHA3-384WITHRSAANDMGF1"] = PkcsObjectIdentifiers.IdRsassaPss;
-            algorithms["SHA3-512WITHRSAANDMGF1"] = PkcsObjectIdentifiers.IdRsassaPss;
-            algorithms["RIPEMD160WITHRSAENCRYPTION"] = TeleTrusTObjectIdentifiers.RsaSignatureWithRipeMD160;
-            algorithms["RIPEMD160WITHRSA"] = TeleTrusTObjectIdentifiers.RsaSignatureWithRipeMD160;
-            algorithms["RIPEMD128WITHRSAENCRYPTION"] = TeleTrusTObjectIdentifiers.RsaSignatureWithRipeMD128;
-            algorithms["RIPEMD128WITHRSA"] = TeleTrusTObjectIdentifiers.RsaSignatureWithRipeMD128;
-            algorithms["RIPEMD256WITHRSAENCRYPTION"] = TeleTrusTObjectIdentifiers.RsaSignatureWithRipeMD256;
-            algorithms["RIPEMD256WITHRSA"] = TeleTrusTObjectIdentifiers.RsaSignatureWithRipeMD256;
-            algorithms["SHA1WITHDSA"] = X9ObjectIdentifiers.IdDsaWithSha1;
-            algorithms["SHA-1WITHDSA"] = X9ObjectIdentifiers.IdDsaWithSha1;
-            algorithms["DSAWITHSHA1"] = X9ObjectIdentifiers.IdDsaWithSha1;
-            algorithms["SHA224WITHDSA"] = NistObjectIdentifiers.DsaWithSha224;
-            algorithms["SHA256WITHDSA"] = NistObjectIdentifiers.DsaWithSha256;
-            algorithms["SHA384WITHDSA"] = NistObjectIdentifiers.DsaWithSha384;
-            algorithms["SHA512WITHDSA"] = NistObjectIdentifiers.DsaWithSha512;
-            algorithms["SHA3-224WITHDSA"] = NistObjectIdentifiers.IdDsaWithSha3_224;
-            algorithms["SHA3-256WITHDSA"] = NistObjectIdentifiers.IdDsaWithSha3_256;
-            algorithms["SHA3-384WITHDSA"] = NistObjectIdentifiers.IdDsaWithSha3_384;
-            algorithms["SHA3-512WITHDSA"] = NistObjectIdentifiers.IdDsaWithSha3_512;
-            algorithms["SHA3-224WITHECDSA"] = NistObjectIdentifiers.IdEcdsaWithSha3_224;
-            algorithms["SHA3-256WITHECDSA"] = NistObjectIdentifiers.IdEcdsaWithSha3_256;
-            algorithms["SHA3-384WITHECDSA"] = NistObjectIdentifiers.IdEcdsaWithSha3_384;
-            algorithms["SHA3-512WITHECDSA"] = NistObjectIdentifiers.IdEcdsaWithSha3_512;
-            algorithms["SHA3-224WITHRSA"] = NistObjectIdentifiers.IdRsassaPkcs1V15WithSha3_224;
-            algorithms["SHA3-256WITHRSA"] = NistObjectIdentifiers.IdRsassaPkcs1V15WithSha3_256;
-            algorithms["SHA3-384WITHRSA"] = NistObjectIdentifiers.IdRsassaPkcs1V15WithSha3_384;
-            algorithms["SHA3-512WITHRSA"] = NistObjectIdentifiers.IdRsassaPkcs1V15WithSha3_512;
-            algorithms["SHA3-224WITHRSAENCRYPTION"] = NistObjectIdentifiers.IdRsassaPkcs1V15WithSha3_224;
-            algorithms["SHA3-256WITHRSAENCRYPTION"] = NistObjectIdentifiers.IdRsassaPkcs1V15WithSha3_256;
-            algorithms["SHA3-384WITHRSAENCRYPTION"] = NistObjectIdentifiers.IdRsassaPkcs1V15WithSha3_384;
-            algorithms["SHA3-512WITHRSAENCRYPTION"] = NistObjectIdentifiers.IdRsassaPkcs1V15WithSha3_512;
-            algorithms["SHA1WITHECDSA"] = X9ObjectIdentifiers.ECDsaWithSha1;
-            algorithms["ECDSAWITHSHA1"] = X9ObjectIdentifiers.ECDsaWithSha1;
-            algorithms["SHA224WITHECDSA"] = X9ObjectIdentifiers.ECDsaWithSha224;
-            algorithms["SHA256WITHECDSA"] = X9ObjectIdentifiers.ECDsaWithSha256;
-            algorithms["SHA384WITHECDSA"] = X9ObjectIdentifiers.ECDsaWithSha384;
-            algorithms["SHA512WITHECDSA"] = X9ObjectIdentifiers.ECDsaWithSha512;
-
-
-            algorithms["GOST3411WITHGOST3410"] = CryptoProObjectIdentifiers.GostR3411x94WithGostR3410x94;
-            algorithms["GOST3411WITHGOST3410-94"] = CryptoProObjectIdentifiers.GostR3411x94WithGostR3410x94;
-            algorithms["GOST3411WITHECGOST3410"] = CryptoProObjectIdentifiers.GostR3411x94WithGostR3410x2001;
-            algorithms["GOST3411WITHECGOST3410-2001"] = CryptoProObjectIdentifiers.GostR3411x94WithGostR3410x2001;
-            algorithms["GOST3411WITHGOST3410-2001"] = CryptoProObjectIdentifiers.GostR3411x94WithGostR3410x2001;
-            algorithms["GOST3411WITHECGOST3410-2012-256"] = RosstandartObjectIdentifiers.id_tc26_signwithdigest_gost_3410_12_256;
-            algorithms["GOST3411WITHECGOST3410-2012-512"] = RosstandartObjectIdentifiers.id_tc26_signwithdigest_gost_3410_12_512;
-            algorithms["GOST3411WITHGOST3410-2012-256"] = RosstandartObjectIdentifiers.id_tc26_signwithdigest_gost_3410_12_256;
-            algorithms["GOST3411WITHGOST3410-2012-512"] = RosstandartObjectIdentifiers.id_tc26_signwithdigest_gost_3410_12_512;
-            algorithms["GOST3411-2012-256WITHECGOST3410-2012-256"] = RosstandartObjectIdentifiers.id_tc26_signwithdigest_gost_3410_12_256;
-            algorithms["GOST3411-2012-512WITHECGOST3410-2012-512"] = RosstandartObjectIdentifiers.id_tc26_signwithdigest_gost_3410_12_512;
-            algorithms["GOST3411-2012-256WITHGOST3410-2012-256"] = RosstandartObjectIdentifiers.id_tc26_signwithdigest_gost_3410_12_256;
-            algorithms["GOST3411-2012-512WITHGOST3410-2012-512"] = RosstandartObjectIdentifiers.id_tc26_signwithdigest_gost_3410_12_512;
-            algorithms["SHA1WITHPLAIN-ECDSA"] = BsiObjectIdentifiers.ecdsa_plain_SHA1;
-            algorithms["SHA224WITHPLAIN-ECDSA"] = BsiObjectIdentifiers.ecdsa_plain_SHA224;
-            algorithms["SHA256WITHPLAIN-ECDSA"] = BsiObjectIdentifiers.ecdsa_plain_SHA256;
-            algorithms["SHA384WITHPLAIN-ECDSA"] = BsiObjectIdentifiers.ecdsa_plain_SHA384;
-            algorithms["SHA512WITHPLAIN-ECDSA"] = BsiObjectIdentifiers.ecdsa_plain_SHA512;
-            algorithms["RIPEMD160WITHPLAIN-ECDSA"] = BsiObjectIdentifiers.ecdsa_plain_RIPEMD160;
-            algorithms["SHA1WITHCVC-ECDSA"] = EacObjectIdentifiers.id_TA_ECDSA_SHA_1;
-            algorithms["SHA224WITHCVC-ECDSA"] = EacObjectIdentifiers.id_TA_ECDSA_SHA_224;
-            algorithms["SHA256WITHCVC-ECDSA"] = EacObjectIdentifiers.id_TA_ECDSA_SHA_256;
-            algorithms["SHA384WITHCVC-ECDSA"] = EacObjectIdentifiers.id_TA_ECDSA_SHA_384;
-            algorithms["SHA512WITHCVC-ECDSA"] = EacObjectIdentifiers.id_TA_ECDSA_SHA_512;
-            algorithms["SHA3-512WITHSPHINCS256"] = BCObjectIdentifiers.sphincs256_with_SHA3_512;
-            algorithms["SHA512WITHSPHINCS256"] = BCObjectIdentifiers.sphincs256_with_SHA512;
-
-            algorithms["SHA256WITHSM2"] = GMObjectIdentifiers.sm2sign_with_sha256;
-            algorithms["SM3WITHSM2"] = GMObjectIdentifiers.sm2sign_with_sm3;
-
-            algorithms["SHA256WITHXMSS"] = BCObjectIdentifiers.xmss_with_SHA256;
-            algorithms["SHA512WITHXMSS"] = BCObjectIdentifiers.xmss_with_SHA512;
-            algorithms["SHAKE128WITHXMSS"] = BCObjectIdentifiers.xmss_with_SHAKE128;
-            algorithms["SHAKE256WITHXMSS"] = BCObjectIdentifiers.xmss_with_SHAKE256;
-
-            algorithms["SHA256WITHXMSSMT"] = BCObjectIdentifiers.xmss_mt_with_SHA256;
-            algorithms["SHA512WITHXMSSMT"] = BCObjectIdentifiers.xmss_mt_with_SHA512;
-            algorithms["SHAKE128WITHXMSSMT"] = BCObjectIdentifiers.xmss_mt_with_SHAKE128;
-            algorithms["SHAKE256WITHXMSSMT"] = BCObjectIdentifiers.xmss_mt_with_SHAKE256;
+            m_algorithms["MD2WITHRSAENCRYPTION"] = PkcsObjectIdentifiers.MD2WithRsaEncryption;
+            m_algorithms["MD2WITHRSA"] = PkcsObjectIdentifiers.MD2WithRsaEncryption;
+            m_algorithms["MD5WITHRSAENCRYPTION"] = PkcsObjectIdentifiers.MD5WithRsaEncryption;
+            m_algorithms["MD5WITHRSA"] = PkcsObjectIdentifiers.MD5WithRsaEncryption;
+            m_algorithms["SHA1WITHRSAENCRYPTION"] = PkcsObjectIdentifiers.Sha1WithRsaEncryption;
+            m_algorithms["SHA-1WITHRSAENCRYPTION"] = PkcsObjectIdentifiers.Sha1WithRsaEncryption;
+            m_algorithms["SHA1WITHRSA"] = PkcsObjectIdentifiers.Sha1WithRsaEncryption;
+            m_algorithms["SHA-1WITHRSA"] = PkcsObjectIdentifiers.Sha1WithRsaEncryption;
+            m_algorithms["SHA224WITHRSAENCRYPTION"] = PkcsObjectIdentifiers.Sha224WithRsaEncryption;
+            m_algorithms["SHA-224WITHRSAENCRYPTION"] = PkcsObjectIdentifiers.Sha224WithRsaEncryption;
+            m_algorithms["SHA224WITHRSA"] = PkcsObjectIdentifiers.Sha224WithRsaEncryption;
+            m_algorithms["SHA-224WITHRSA"] = PkcsObjectIdentifiers.Sha224WithRsaEncryption;
+            m_algorithms["SHA256WITHRSAENCRYPTION"] = PkcsObjectIdentifiers.Sha256WithRsaEncryption;
+            m_algorithms["SHA-256WITHRSAENCRYPTION"] = PkcsObjectIdentifiers.Sha256WithRsaEncryption;
+            m_algorithms["SHA256WITHRSA"] = PkcsObjectIdentifiers.Sha256WithRsaEncryption;
+            m_algorithms["SHA-256WITHRSA"] = PkcsObjectIdentifiers.Sha256WithRsaEncryption;
+            m_algorithms["SHA384WITHRSAENCRYPTION"] = PkcsObjectIdentifiers.Sha384WithRsaEncryption;
+            m_algorithms["SHA-384WITHRSAENCRYPTION"] = PkcsObjectIdentifiers.Sha384WithRsaEncryption;
+            m_algorithms["SHA384WITHRSA"] = PkcsObjectIdentifiers.Sha384WithRsaEncryption;
+            m_algorithms["SHA-384WITHRSA"] = PkcsObjectIdentifiers.Sha384WithRsaEncryption;
+            m_algorithms["SHA512WITHRSAENCRYPTION"] = PkcsObjectIdentifiers.Sha512WithRsaEncryption;
+            m_algorithms["SHA-512WITHRSAENCRYPTION"] = PkcsObjectIdentifiers.Sha512WithRsaEncryption;
+            m_algorithms["SHA512WITHRSA"] = PkcsObjectIdentifiers.Sha512WithRsaEncryption;
+            m_algorithms["SHA-512WITHRSA"] = PkcsObjectIdentifiers.Sha512WithRsaEncryption;
+            m_algorithms["SHA512(224)WITHRSAENCRYPTION"] = PkcsObjectIdentifiers.Sha512_224WithRSAEncryption;
+            m_algorithms["SHA-512(224)WITHRSAENCRYPTION"] = PkcsObjectIdentifiers.Sha512_224WithRSAEncryption;
+            m_algorithms["SHA512(224)WITHRSA"] = PkcsObjectIdentifiers.Sha512_224WithRSAEncryption;
+            m_algorithms["SHA-512(224)WITHRSA"] = PkcsObjectIdentifiers.Sha512_224WithRSAEncryption;
+            m_algorithms["SHA512(256)WITHRSAENCRYPTION"] = PkcsObjectIdentifiers.Sha512_256WithRSAEncryption;
+            m_algorithms["SHA-512(256)WITHRSAENCRYPTION"] = PkcsObjectIdentifiers.Sha512_256WithRSAEncryption;
+            m_algorithms["SHA512(256)WITHRSA"] = PkcsObjectIdentifiers.Sha512_256WithRSAEncryption;
+            m_algorithms["SHA-512(256)WITHRSA"] = PkcsObjectIdentifiers.Sha512_256WithRSAEncryption;
+            m_algorithms["SHA1WITHRSAANDMGF1"] = PkcsObjectIdentifiers.IdRsassaPss;
+            m_algorithms["SHA224WITHRSAANDMGF1"] = PkcsObjectIdentifiers.IdRsassaPss;
+            m_algorithms["SHA256WITHRSAANDMGF1"] = PkcsObjectIdentifiers.IdRsassaPss;
+            m_algorithms["SHA384WITHRSAANDMGF1"] = PkcsObjectIdentifiers.IdRsassaPss;
+            m_algorithms["SHA512WITHRSAANDMGF1"] = PkcsObjectIdentifiers.IdRsassaPss;
+            m_algorithms["SHA3-224WITHRSAANDMGF1"] = PkcsObjectIdentifiers.IdRsassaPss;
+            m_algorithms["SHA3-256WITHRSAANDMGF1"] = PkcsObjectIdentifiers.IdRsassaPss;
+            m_algorithms["SHA3-384WITHRSAANDMGF1"] = PkcsObjectIdentifiers.IdRsassaPss;
+            m_algorithms["SHA3-512WITHRSAANDMGF1"] = PkcsObjectIdentifiers.IdRsassaPss;
+            m_algorithms["RIPEMD160WITHRSAENCRYPTION"] = TeleTrusTObjectIdentifiers.RsaSignatureWithRipeMD160;
+            m_algorithms["RIPEMD160WITHRSA"] = TeleTrusTObjectIdentifiers.RsaSignatureWithRipeMD160;
+            m_algorithms["RIPEMD128WITHRSAENCRYPTION"] = TeleTrusTObjectIdentifiers.RsaSignatureWithRipeMD128;
+            m_algorithms["RIPEMD128WITHRSA"] = TeleTrusTObjectIdentifiers.RsaSignatureWithRipeMD128;
+            m_algorithms["RIPEMD256WITHRSAENCRYPTION"] = TeleTrusTObjectIdentifiers.RsaSignatureWithRipeMD256;
+            m_algorithms["RIPEMD256WITHRSA"] = TeleTrusTObjectIdentifiers.RsaSignatureWithRipeMD256;
+            m_algorithms["SHA1WITHDSA"] = X9ObjectIdentifiers.IdDsaWithSha1;
+            m_algorithms["SHA-1WITHDSA"] = X9ObjectIdentifiers.IdDsaWithSha1;
+            m_algorithms["DSAWITHSHA1"] = X9ObjectIdentifiers.IdDsaWithSha1;
+            m_algorithms["SHA224WITHDSA"] = NistObjectIdentifiers.DsaWithSha224;
+            m_algorithms["SHA256WITHDSA"] = NistObjectIdentifiers.DsaWithSha256;
+            m_algorithms["SHA384WITHDSA"] = NistObjectIdentifiers.DsaWithSha384;
+            m_algorithms["SHA512WITHDSA"] = NistObjectIdentifiers.DsaWithSha512;
+            m_algorithms["SHA3-224WITHDSA"] = NistObjectIdentifiers.IdDsaWithSha3_224;
+            m_algorithms["SHA3-256WITHDSA"] = NistObjectIdentifiers.IdDsaWithSha3_256;
+            m_algorithms["SHA3-384WITHDSA"] = NistObjectIdentifiers.IdDsaWithSha3_384;
+            m_algorithms["SHA3-512WITHDSA"] = NistObjectIdentifiers.IdDsaWithSha3_512;
+            m_algorithms["SHA3-224WITHECDSA"] = NistObjectIdentifiers.IdEcdsaWithSha3_224;
+            m_algorithms["SHA3-256WITHECDSA"] = NistObjectIdentifiers.IdEcdsaWithSha3_256;
+            m_algorithms["SHA3-384WITHECDSA"] = NistObjectIdentifiers.IdEcdsaWithSha3_384;
+            m_algorithms["SHA3-512WITHECDSA"] = NistObjectIdentifiers.IdEcdsaWithSha3_512;
+            m_algorithms["SHA3-224WITHRSA"] = NistObjectIdentifiers.IdRsassaPkcs1V15WithSha3_224;
+            m_algorithms["SHA3-256WITHRSA"] = NistObjectIdentifiers.IdRsassaPkcs1V15WithSha3_256;
+            m_algorithms["SHA3-384WITHRSA"] = NistObjectIdentifiers.IdRsassaPkcs1V15WithSha3_384;
+            m_algorithms["SHA3-512WITHRSA"] = NistObjectIdentifiers.IdRsassaPkcs1V15WithSha3_512;
+            m_algorithms["SHA3-224WITHRSAENCRYPTION"] = NistObjectIdentifiers.IdRsassaPkcs1V15WithSha3_224;
+            m_algorithms["SHA3-256WITHRSAENCRYPTION"] = NistObjectIdentifiers.IdRsassaPkcs1V15WithSha3_256;
+            m_algorithms["SHA3-384WITHRSAENCRYPTION"] = NistObjectIdentifiers.IdRsassaPkcs1V15WithSha3_384;
+            m_algorithms["SHA3-512WITHRSAENCRYPTION"] = NistObjectIdentifiers.IdRsassaPkcs1V15WithSha3_512;
+            m_algorithms["SHA1WITHECDSA"] = X9ObjectIdentifiers.ECDsaWithSha1;
+            m_algorithms["ECDSAWITHSHA1"] = X9ObjectIdentifiers.ECDsaWithSha1;
+            m_algorithms["SHA224WITHECDSA"] = X9ObjectIdentifiers.ECDsaWithSha224;
+            m_algorithms["SHA256WITHECDSA"] = X9ObjectIdentifiers.ECDsaWithSha256;
+            m_algorithms["SHA384WITHECDSA"] = X9ObjectIdentifiers.ECDsaWithSha384;
+            m_algorithms["SHA512WITHECDSA"] = X9ObjectIdentifiers.ECDsaWithSha512;
+
+
+            m_algorithms["GOST3411WITHGOST3410"] = CryptoProObjectIdentifiers.GostR3411x94WithGostR3410x94;
+            m_algorithms["GOST3411WITHGOST3410-94"] = CryptoProObjectIdentifiers.GostR3411x94WithGostR3410x94;
+            m_algorithms["GOST3411WITHECGOST3410"] = CryptoProObjectIdentifiers.GostR3411x94WithGostR3410x2001;
+            m_algorithms["GOST3411WITHECGOST3410-2001"] = CryptoProObjectIdentifiers.GostR3411x94WithGostR3410x2001;
+            m_algorithms["GOST3411WITHGOST3410-2001"] = CryptoProObjectIdentifiers.GostR3411x94WithGostR3410x2001;
+            m_algorithms["GOST3411WITHECGOST3410-2012-256"] = RosstandartObjectIdentifiers.id_tc26_signwithdigest_gost_3410_12_256;
+            m_algorithms["GOST3411WITHECGOST3410-2012-512"] = RosstandartObjectIdentifiers.id_tc26_signwithdigest_gost_3410_12_512;
+            m_algorithms["GOST3411WITHGOST3410-2012-256"] = RosstandartObjectIdentifiers.id_tc26_signwithdigest_gost_3410_12_256;
+            m_algorithms["GOST3411WITHGOST3410-2012-512"] = RosstandartObjectIdentifiers.id_tc26_signwithdigest_gost_3410_12_512;
+            m_algorithms["GOST3411-2012-256WITHECGOST3410-2012-256"] = RosstandartObjectIdentifiers.id_tc26_signwithdigest_gost_3410_12_256;
+            m_algorithms["GOST3411-2012-512WITHECGOST3410-2012-512"] = RosstandartObjectIdentifiers.id_tc26_signwithdigest_gost_3410_12_512;
+            m_algorithms["GOST3411-2012-256WITHGOST3410-2012-256"] = RosstandartObjectIdentifiers.id_tc26_signwithdigest_gost_3410_12_256;
+            m_algorithms["GOST3411-2012-512WITHGOST3410-2012-512"] = RosstandartObjectIdentifiers.id_tc26_signwithdigest_gost_3410_12_512;
+            m_algorithms["SHA1WITHPLAIN-ECDSA"] = BsiObjectIdentifiers.ecdsa_plain_SHA1;
+            m_algorithms["SHA224WITHPLAIN-ECDSA"] = BsiObjectIdentifiers.ecdsa_plain_SHA224;
+            m_algorithms["SHA256WITHPLAIN-ECDSA"] = BsiObjectIdentifiers.ecdsa_plain_SHA256;
+            m_algorithms["SHA384WITHPLAIN-ECDSA"] = BsiObjectIdentifiers.ecdsa_plain_SHA384;
+            m_algorithms["SHA512WITHPLAIN-ECDSA"] = BsiObjectIdentifiers.ecdsa_plain_SHA512;
+            m_algorithms["RIPEMD160WITHPLAIN-ECDSA"] = BsiObjectIdentifiers.ecdsa_plain_RIPEMD160;
+            m_algorithms["SHA1WITHCVC-ECDSA"] = EacObjectIdentifiers.id_TA_ECDSA_SHA_1;
+            m_algorithms["SHA224WITHCVC-ECDSA"] = EacObjectIdentifiers.id_TA_ECDSA_SHA_224;
+            m_algorithms["SHA256WITHCVC-ECDSA"] = EacObjectIdentifiers.id_TA_ECDSA_SHA_256;
+            m_algorithms["SHA384WITHCVC-ECDSA"] = EacObjectIdentifiers.id_TA_ECDSA_SHA_384;
+            m_algorithms["SHA512WITHCVC-ECDSA"] = EacObjectIdentifiers.id_TA_ECDSA_SHA_512;
+            m_algorithms["SHA3-512WITHSPHINCS256"] = BCObjectIdentifiers.sphincs256_with_SHA3_512;
+            m_algorithms["SHA512WITHSPHINCS256"] = BCObjectIdentifiers.sphincs256_with_SHA512;
+
+            m_algorithms["SHA256WITHSM2"] = GMObjectIdentifiers.sm2sign_with_sha256;
+            m_algorithms["SM3WITHSM2"] = GMObjectIdentifiers.sm2sign_with_sm3;
+
+            m_algorithms["SHA256WITHXMSS"] = BCObjectIdentifiers.xmss_with_SHA256;
+            m_algorithms["SHA512WITHXMSS"] = BCObjectIdentifiers.xmss_with_SHA512;
+            m_algorithms["SHAKE128WITHXMSS"] = BCObjectIdentifiers.xmss_with_SHAKE128;
+            m_algorithms["SHAKE256WITHXMSS"] = BCObjectIdentifiers.xmss_with_SHAKE256;
+
+            m_algorithms["SHA256WITHXMSSMT"] = BCObjectIdentifiers.xmss_mt_with_SHA256;
+            m_algorithms["SHA512WITHXMSSMT"] = BCObjectIdentifiers.xmss_mt_with_SHA512;
+            m_algorithms["SHAKE128WITHXMSSMT"] = BCObjectIdentifiers.xmss_mt_with_SHAKE128;
+            m_algorithms["SHAKE256WITHXMSSMT"] = BCObjectIdentifiers.xmss_mt_with_SHAKE256;
 
 
             //
@@ -239,117 +240,113 @@ namespace Org.BouncyCastle.Cms
             // explicit params
             //
             AlgorithmIdentifier sha1AlgId = new AlgorithmIdentifier(OiwObjectIdentifiers.IdSha1, DerNull.Instance);
-            _params["SHA1WITHRSAANDMGF1"] = CreatePssParams(sha1AlgId, 20);
+            m_params["SHA1WITHRSAANDMGF1"] = CreatePssParams(sha1AlgId, 20);
 
             AlgorithmIdentifier sha224AlgId = new AlgorithmIdentifier(NistObjectIdentifiers.IdSha224, DerNull.Instance);
-            _params["SHA224WITHRSAANDMGF1"] = CreatePssParams(sha224AlgId, 28);
+            m_params["SHA224WITHRSAANDMGF1"] = CreatePssParams(sha224AlgId, 28);
 
             AlgorithmIdentifier sha256AlgId = new AlgorithmIdentifier(NistObjectIdentifiers.IdSha256, DerNull.Instance);
-            _params["SHA256WITHRSAANDMGF1"] = CreatePssParams(sha256AlgId, 32);
+            m_params["SHA256WITHRSAANDMGF1"] = CreatePssParams(sha256AlgId, 32);
 
             AlgorithmIdentifier sha384AlgId = new AlgorithmIdentifier(NistObjectIdentifiers.IdSha384, DerNull.Instance);
-            _params["SHA384WITHRSAANDMGF1"] = CreatePssParams(sha384AlgId, 48);
+            m_params["SHA384WITHRSAANDMGF1"] = CreatePssParams(sha384AlgId, 48);
 
             AlgorithmIdentifier sha512AlgId = new AlgorithmIdentifier(NistObjectIdentifiers.IdSha512, DerNull.Instance);
-            _params["SHA512WITHRSAANDMGF1"] = CreatePssParams(sha512AlgId, 64);
+            m_params["SHA512WITHRSAANDMGF1"] = CreatePssParams(sha512AlgId, 64);
 
             AlgorithmIdentifier sha3_224AlgId = new AlgorithmIdentifier(NistObjectIdentifiers.IdSha3_224, DerNull.Instance);
-            _params["SHA3-224WITHRSAANDMGF1"] = CreatePssParams(sha3_224AlgId, 28);
+            m_params["SHA3-224WITHRSAANDMGF1"] = CreatePssParams(sha3_224AlgId, 28);
 
             AlgorithmIdentifier sha3_256AlgId = new AlgorithmIdentifier(NistObjectIdentifiers.IdSha3_256, DerNull.Instance);
-            _params["SHA3-256WITHRSAANDMGF1"] = CreatePssParams(sha3_256AlgId, 32);
+            m_params["SHA3-256WITHRSAANDMGF1"] = CreatePssParams(sha3_256AlgId, 32);
 
             AlgorithmIdentifier sha3_384AlgId = new AlgorithmIdentifier(NistObjectIdentifiers.IdSha3_384, DerNull.Instance);
-            _params["SHA3-384WITHRSAANDMGF1"] = CreatePssParams(sha3_384AlgId, 48);
+            m_params["SHA3-384WITHRSAANDMGF1"] = CreatePssParams(sha3_384AlgId, 48);
 
             AlgorithmIdentifier sha3_512AlgId = new AlgorithmIdentifier(NistObjectIdentifiers.IdSha3_512, DerNull.Instance);
-            _params["SHA3-512WITHRSAANDMGF1"] = CreatePssParams(sha3_512AlgId, 64);
+            m_params["SHA3-512WITHRSAANDMGF1"] = CreatePssParams(sha3_512AlgId, 64);
 
             //
             // digests
             //
-            digestOids[PkcsObjectIdentifiers.Sha224WithRsaEncryption] = NistObjectIdentifiers.IdSha224;
-            digestOids[PkcsObjectIdentifiers.Sha256WithRsaEncryption] = NistObjectIdentifiers.IdSha256;
-            digestOids[PkcsObjectIdentifiers.Sha384WithRsaEncryption] = NistObjectIdentifiers.IdSha384;
-            digestOids[PkcsObjectIdentifiers.Sha512WithRsaEncryption] = NistObjectIdentifiers.IdSha512;
-            digestOids[PkcsObjectIdentifiers.Sha512_224WithRSAEncryption] = NistObjectIdentifiers.IdSha512_224;
-            digestOids[PkcsObjectIdentifiers.Sha512_256WithRSAEncryption] = NistObjectIdentifiers.IdSha512_256;
-            digestOids[NistObjectIdentifiers.DsaWithSha224] = NistObjectIdentifiers.IdSha224;
-            digestOids[NistObjectIdentifiers.DsaWithSha256] = NistObjectIdentifiers.IdSha256;
-            digestOids[NistObjectIdentifiers.DsaWithSha384] = NistObjectIdentifiers.IdSha384;
-            digestOids[NistObjectIdentifiers.DsaWithSha512] = NistObjectIdentifiers.IdSha512;
-            digestOids[NistObjectIdentifiers.IdDsaWithSha3_224] = NistObjectIdentifiers.IdSha3_224;
-            digestOids[NistObjectIdentifiers.IdDsaWithSha3_256] = NistObjectIdentifiers.IdSha3_256;
-            digestOids[NistObjectIdentifiers.IdDsaWithSha3_384] = NistObjectIdentifiers.IdSha3_384;
-            digestOids[NistObjectIdentifiers.IdDsaWithSha3_512] = NistObjectIdentifiers.IdSha3_512;
-            digestOids[NistObjectIdentifiers.IdEcdsaWithSha3_224] = NistObjectIdentifiers.IdSha3_224;
-            digestOids[NistObjectIdentifiers.IdEcdsaWithSha3_256] = NistObjectIdentifiers.IdSha3_256;
-            digestOids[NistObjectIdentifiers.IdEcdsaWithSha3_384] = NistObjectIdentifiers.IdSha3_384;
-            digestOids[NistObjectIdentifiers.IdEcdsaWithSha3_512] = NistObjectIdentifiers.IdSha3_512;
-            digestOids[NistObjectIdentifiers.IdRsassaPkcs1V15WithSha3_224] = NistObjectIdentifiers.IdSha3_224;
-            digestOids[NistObjectIdentifiers.IdRsassaPkcs1V15WithSha3_256] = NistObjectIdentifiers.IdSha3_256;
-            digestOids[NistObjectIdentifiers.IdRsassaPkcs1V15WithSha3_384] = NistObjectIdentifiers.IdSha3_384;
-            digestOids[NistObjectIdentifiers.IdRsassaPkcs1V15WithSha3_512] = NistObjectIdentifiers.IdSha3_512;
-
-            digestOids[PkcsObjectIdentifiers.MD2WithRsaEncryption] = PkcsObjectIdentifiers.MD2;
-            digestOids[PkcsObjectIdentifiers.MD4WithRsaEncryption] = PkcsObjectIdentifiers.MD4;
-            digestOids[PkcsObjectIdentifiers.MD5WithRsaEncryption] = PkcsObjectIdentifiers.MD5;
-            digestOids[PkcsObjectIdentifiers.Sha1WithRsaEncryption] = OiwObjectIdentifiers.IdSha1;
-            digestOids[TeleTrusTObjectIdentifiers.RsaSignatureWithRipeMD128] = TeleTrusTObjectIdentifiers.RipeMD128;
-            digestOids[TeleTrusTObjectIdentifiers.RsaSignatureWithRipeMD160] = TeleTrusTObjectIdentifiers.RipeMD160;
-            digestOids[TeleTrusTObjectIdentifiers.RsaSignatureWithRipeMD256] = TeleTrusTObjectIdentifiers.RipeMD256;
-            digestOids[CryptoProObjectIdentifiers.GostR3411x94WithGostR3410x94] = CryptoProObjectIdentifiers.GostR3411;
-            digestOids[CryptoProObjectIdentifiers.GostR3411x94WithGostR3410x2001] = CryptoProObjectIdentifiers.GostR3411;
-            digestOids[RosstandartObjectIdentifiers.id_tc26_signwithdigest_gost_3410_12_256] = RosstandartObjectIdentifiers.id_tc26_gost_3411_12_256;
-            digestOids[RosstandartObjectIdentifiers.id_tc26_signwithdigest_gost_3410_12_512] = RosstandartObjectIdentifiers.id_tc26_gost_3411_12_512;
-
-            digestOids[GMObjectIdentifiers.sm2sign_with_sha256] = NistObjectIdentifiers.IdSha256;
-            digestOids[GMObjectIdentifiers.sm2sign_with_sm3] = GMObjectIdentifiers.sm3;
+            m_digestOids[PkcsObjectIdentifiers.Sha224WithRsaEncryption] = NistObjectIdentifiers.IdSha224;
+            m_digestOids[PkcsObjectIdentifiers.Sha256WithRsaEncryption] = NistObjectIdentifiers.IdSha256;
+            m_digestOids[PkcsObjectIdentifiers.Sha384WithRsaEncryption] = NistObjectIdentifiers.IdSha384;
+            m_digestOids[PkcsObjectIdentifiers.Sha512WithRsaEncryption] = NistObjectIdentifiers.IdSha512;
+            m_digestOids[PkcsObjectIdentifiers.Sha512_224WithRSAEncryption] = NistObjectIdentifiers.IdSha512_224;
+            m_digestOids[PkcsObjectIdentifiers.Sha512_256WithRSAEncryption] = NistObjectIdentifiers.IdSha512_256;
+            m_digestOids[NistObjectIdentifiers.DsaWithSha224] = NistObjectIdentifiers.IdSha224;
+            m_digestOids[NistObjectIdentifiers.DsaWithSha256] = NistObjectIdentifiers.IdSha256;
+            m_digestOids[NistObjectIdentifiers.DsaWithSha384] = NistObjectIdentifiers.IdSha384;
+            m_digestOids[NistObjectIdentifiers.DsaWithSha512] = NistObjectIdentifiers.IdSha512;
+            m_digestOids[NistObjectIdentifiers.IdDsaWithSha3_224] = NistObjectIdentifiers.IdSha3_224;
+            m_digestOids[NistObjectIdentifiers.IdDsaWithSha3_256] = NistObjectIdentifiers.IdSha3_256;
+            m_digestOids[NistObjectIdentifiers.IdDsaWithSha3_384] = NistObjectIdentifiers.IdSha3_384;
+            m_digestOids[NistObjectIdentifiers.IdDsaWithSha3_512] = NistObjectIdentifiers.IdSha3_512;
+            m_digestOids[NistObjectIdentifiers.IdEcdsaWithSha3_224] = NistObjectIdentifiers.IdSha3_224;
+            m_digestOids[NistObjectIdentifiers.IdEcdsaWithSha3_256] = NistObjectIdentifiers.IdSha3_256;
+            m_digestOids[NistObjectIdentifiers.IdEcdsaWithSha3_384] = NistObjectIdentifiers.IdSha3_384;
+            m_digestOids[NistObjectIdentifiers.IdEcdsaWithSha3_512] = NistObjectIdentifiers.IdSha3_512;
+            m_digestOids[NistObjectIdentifiers.IdRsassaPkcs1V15WithSha3_224] = NistObjectIdentifiers.IdSha3_224;
+            m_digestOids[NistObjectIdentifiers.IdRsassaPkcs1V15WithSha3_256] = NistObjectIdentifiers.IdSha3_256;
+            m_digestOids[NistObjectIdentifiers.IdRsassaPkcs1V15WithSha3_384] = NistObjectIdentifiers.IdSha3_384;
+            m_digestOids[NistObjectIdentifiers.IdRsassaPkcs1V15WithSha3_512] = NistObjectIdentifiers.IdSha3_512;
+
+            m_digestOids[PkcsObjectIdentifiers.MD2WithRsaEncryption] = PkcsObjectIdentifiers.MD2;
+            m_digestOids[PkcsObjectIdentifiers.MD4WithRsaEncryption] = PkcsObjectIdentifiers.MD4;
+            m_digestOids[PkcsObjectIdentifiers.MD5WithRsaEncryption] = PkcsObjectIdentifiers.MD5;
+            m_digestOids[PkcsObjectIdentifiers.Sha1WithRsaEncryption] = OiwObjectIdentifiers.IdSha1;
+            m_digestOids[TeleTrusTObjectIdentifiers.RsaSignatureWithRipeMD128] = TeleTrusTObjectIdentifiers.RipeMD128;
+            m_digestOids[TeleTrusTObjectIdentifiers.RsaSignatureWithRipeMD160] = TeleTrusTObjectIdentifiers.RipeMD160;
+            m_digestOids[TeleTrusTObjectIdentifiers.RsaSignatureWithRipeMD256] = TeleTrusTObjectIdentifiers.RipeMD256;
+            m_digestOids[CryptoProObjectIdentifiers.GostR3411x94WithGostR3410x94] = CryptoProObjectIdentifiers.GostR3411;
+            m_digestOids[CryptoProObjectIdentifiers.GostR3411x94WithGostR3410x2001] = CryptoProObjectIdentifiers.GostR3411;
+            m_digestOids[RosstandartObjectIdentifiers.id_tc26_signwithdigest_gost_3410_12_256] = RosstandartObjectIdentifiers.id_tc26_gost_3411_12_256;
+            m_digestOids[RosstandartObjectIdentifiers.id_tc26_signwithdigest_gost_3410_12_512] = RosstandartObjectIdentifiers.id_tc26_gost_3411_12_512;
+
+            m_digestOids[GMObjectIdentifiers.sm2sign_with_sha256] = NistObjectIdentifiers.IdSha256;
+            m_digestOids[GMObjectIdentifiers.sm2sign_with_sm3] = GMObjectIdentifiers.sm3;
         }
 
         private static AlgorithmIdentifier Generate(string signatureAlgorithm)
         {
             AlgorithmIdentifier sigAlgId;
-            AlgorithmIdentifier encAlgId;
-            AlgorithmIdentifier digAlgId;
+            //AlgorithmIdentifier encAlgId;
+            //AlgorithmIdentifier digAlgId;
 
-            string algorithmName = Strings.ToUpperCase(signatureAlgorithm);
-            DerObjectIdentifier sigOID = (DerObjectIdentifier)algorithms[algorithmName];
-            if (sigOID == null)
-            {
-                throw new ArgumentException("Unknown signature type requested: " + algorithmName);
-            }
+            if (!m_algorithms.TryGetValue(signatureAlgorithm, out var sigOid))
+                throw new ArgumentException("Unknown signature type requested: " + signatureAlgorithm);
 
-            if (noParams.Contains(sigOID))
+            if (noParams.Contains(sigOid))
             {
-                sigAlgId = new AlgorithmIdentifier(sigOID);
+                sigAlgId = new AlgorithmIdentifier(sigOid);
             }
-            else if (_params.Contains(algorithmName))
+            else if (m_params.TryGetValue(signatureAlgorithm, out var explicitParameters))
             {
-                sigAlgId = new AlgorithmIdentifier(sigOID, (Asn1Encodable)_params[algorithmName]);
+                sigAlgId = new AlgorithmIdentifier(sigOid, explicitParameters);
             }
             else
             {
-                sigAlgId = new AlgorithmIdentifier(sigOID, DerNull.Instance);
+                sigAlgId = new AlgorithmIdentifier(sigOid, DerNull.Instance);
             }
 
-            if (pkcs15RsaEncryption.Contains(sigOID))
-            {
-                encAlgId = new AlgorithmIdentifier(PkcsObjectIdentifiers.RsaEncryption, DerNull.Instance);
-            }
-            else
-            {
-                encAlgId = sigAlgId;
-            }
-
-            if (sigAlgId.Algorithm.Equals(PkcsObjectIdentifiers.IdRsassaPss))
-            {
-                digAlgId = ((RsassaPssParameters)sigAlgId.Parameters).HashAlgorithm;
-            }
-            else
-            {
-                digAlgId = new AlgorithmIdentifier((DerObjectIdentifier)digestOids[sigOID], DerNull.Instance);
-            }
+            //if (pkcs15RsaEncryption.Contains(sigOid))
+            //{
+            //    encAlgId = new AlgorithmIdentifier(PkcsObjectIdentifiers.RsaEncryption, DerNull.Instance);
+            //}
+            //else
+            //{
+            //    encAlgId = sigAlgId;
+            //}
+
+            //if (sigAlgId.Algorithm.Equals(PkcsObjectIdentifiers.IdRsassaPss))
+            //{
+            //    digAlgId = ((RsassaPssParameters)sigAlgId.Parameters).HashAlgorithm;
+            //}
+            //else
+            //{
+            //    digAlgId = new AlgorithmIdentifier(m_digestOids[sigOid], DerNull.Instance);
+            //}
 
             return sigAlgId;
         }
@@ -371,96 +368,98 @@ namespace Org.BouncyCastle.Cms
 
     public class DefaultDigestAlgorithmIdentifierFinder
     {
-        private static readonly IDictionary digestOids = Platform.CreateHashtable();
-        private static readonly IDictionary digestNameToOids = Platform.CreateHashtable();
+        private static readonly IDictionary<DerObjectIdentifier, DerObjectIdentifier> m_digestOids =
+            new Dictionary<DerObjectIdentifier, DerObjectIdentifier>();
+        private static readonly IDictionary<string, DerObjectIdentifier> m_digestNameToOids =
+            new Dictionary<string, DerObjectIdentifier>(StringComparer.OrdinalIgnoreCase);
 
         static DefaultDigestAlgorithmIdentifierFinder()
         {
             //
             // digests
             //
-            digestOids.Add(OiwObjectIdentifiers.MD4WithRsaEncryption, PkcsObjectIdentifiers.MD4);
-            digestOids.Add(OiwObjectIdentifiers.MD4WithRsa, PkcsObjectIdentifiers.MD4);
-            digestOids.Add(OiwObjectIdentifiers.MD5WithRsa, PkcsObjectIdentifiers.MD5);
-            digestOids.Add(OiwObjectIdentifiers.Sha1WithRsa, OiwObjectIdentifiers.IdSha1);
-            digestOids.Add(OiwObjectIdentifiers.DsaWithSha1, OiwObjectIdentifiers.IdSha1);
-
-            digestOids.Add(PkcsObjectIdentifiers.Sha224WithRsaEncryption, NistObjectIdentifiers.IdSha224);
-            digestOids.Add(PkcsObjectIdentifiers.Sha256WithRsaEncryption, NistObjectIdentifiers.IdSha256);
-            digestOids.Add(PkcsObjectIdentifiers.Sha384WithRsaEncryption, NistObjectIdentifiers.IdSha384);
-            digestOids.Add(PkcsObjectIdentifiers.Sha512WithRsaEncryption, NistObjectIdentifiers.IdSha512);
-            digestOids.Add(PkcsObjectIdentifiers.Sha512_224WithRSAEncryption, NistObjectIdentifiers.IdSha512_224);
-            digestOids.Add(PkcsObjectIdentifiers.Sha512_256WithRSAEncryption, NistObjectIdentifiers.IdSha512_256);
-
-            digestOids.Add(NistObjectIdentifiers.IdRsassaPkcs1V15WithSha3_224, NistObjectIdentifiers.IdSha3_224);
-            digestOids.Add(NistObjectIdentifiers.IdRsassaPkcs1V15WithSha3_256, NistObjectIdentifiers.IdSha3_256);
-            digestOids.Add(NistObjectIdentifiers.IdRsassaPkcs1V15WithSha3_384, NistObjectIdentifiers.IdSha3_384);
-            digestOids.Add(NistObjectIdentifiers.IdRsassaPkcs1V15WithSha3_512, NistObjectIdentifiers.IdSha3_512);
-
-            digestOids.Add(PkcsObjectIdentifiers.MD2WithRsaEncryption, PkcsObjectIdentifiers.MD2);
-            digestOids.Add(PkcsObjectIdentifiers.MD4WithRsaEncryption, PkcsObjectIdentifiers.MD4);
-            digestOids.Add(PkcsObjectIdentifiers.MD5WithRsaEncryption, PkcsObjectIdentifiers.MD5);
-            digestOids.Add(PkcsObjectIdentifiers.Sha1WithRsaEncryption, OiwObjectIdentifiers.IdSha1);
-
-            digestOids.Add(X9ObjectIdentifiers.ECDsaWithSha1, OiwObjectIdentifiers.IdSha1);
-            digestOids.Add(X9ObjectIdentifiers.ECDsaWithSha224, NistObjectIdentifiers.IdSha224);
-            digestOids.Add(X9ObjectIdentifiers.ECDsaWithSha256, NistObjectIdentifiers.IdSha256);
-            digestOids.Add(X9ObjectIdentifiers.ECDsaWithSha384, NistObjectIdentifiers.IdSha384);
-            digestOids.Add(X9ObjectIdentifiers.ECDsaWithSha512, NistObjectIdentifiers.IdSha512);
-            digestOids.Add(X9ObjectIdentifiers.IdDsaWithSha1, OiwObjectIdentifiers.IdSha1);
-
-            digestOids.Add(NistObjectIdentifiers.DsaWithSha224, NistObjectIdentifiers.IdSha224);
-            digestOids.Add(NistObjectIdentifiers.DsaWithSha256, NistObjectIdentifiers.IdSha256);
-            digestOids.Add(NistObjectIdentifiers.DsaWithSha384, NistObjectIdentifiers.IdSha384);
-            digestOids.Add(NistObjectIdentifiers.DsaWithSha512, NistObjectIdentifiers.IdSha512);
-
-            digestOids.Add(TeleTrusTObjectIdentifiers.RsaSignatureWithRipeMD128, TeleTrusTObjectIdentifiers.RipeMD128);
-            digestOids.Add(TeleTrusTObjectIdentifiers.RsaSignatureWithRipeMD160, TeleTrusTObjectIdentifiers.RipeMD160);
-            digestOids.Add(TeleTrusTObjectIdentifiers.RsaSignatureWithRipeMD256, TeleTrusTObjectIdentifiers.RipeMD256);
-
-            digestOids.Add(CryptoProObjectIdentifiers.GostR3411x94WithGostR3410x94, CryptoProObjectIdentifiers.GostR3411);
-            digestOids.Add(CryptoProObjectIdentifiers.GostR3411x94WithGostR3410x2001, CryptoProObjectIdentifiers.GostR3411);
-
-            digestNameToOids.Add("SHA-1", OiwObjectIdentifiers.IdSha1);
-            digestNameToOids.Add("SHA-224", NistObjectIdentifiers.IdSha224);
-            digestNameToOids.Add("SHA-256", NistObjectIdentifiers.IdSha256);
-            digestNameToOids.Add("SHA-384", NistObjectIdentifiers.IdSha384);
-            digestNameToOids.Add("SHA-512", NistObjectIdentifiers.IdSha512);
-            digestNameToOids.Add("SHA-512/224", NistObjectIdentifiers.IdSha512_224);
-            digestNameToOids.Add("SHA-512(224)", NistObjectIdentifiers.IdSha512_224);
-            digestNameToOids.Add("SHA-512/256", NistObjectIdentifiers.IdSha512_256);
-            digestNameToOids.Add("SHA-512(256)", NistObjectIdentifiers.IdSha512_256);
-
-            digestNameToOids.Add("SHA1", OiwObjectIdentifiers.IdSha1);
-            digestNameToOids.Add("SHA224", NistObjectIdentifiers.IdSha224);
-            digestNameToOids.Add("SHA256", NistObjectIdentifiers.IdSha256);
-            digestNameToOids.Add("SHA384", NistObjectIdentifiers.IdSha384);
-            digestNameToOids.Add("SHA512", NistObjectIdentifiers.IdSha512);
-            digestNameToOids.Add("SHA512/224", NistObjectIdentifiers.IdSha512_224);
-            digestNameToOids.Add("SHA512(224)", NistObjectIdentifiers.IdSha512_224);
-            digestNameToOids.Add("SHA512/256", NistObjectIdentifiers.IdSha512_256);
-            digestNameToOids.Add("SHA512(256)", NistObjectIdentifiers.IdSha512_256);
-
-            digestNameToOids.Add("SHA3-224", NistObjectIdentifiers.IdSha3_224);
-            digestNameToOids.Add("SHA3-256", NistObjectIdentifiers.IdSha3_256);
-            digestNameToOids.Add("SHA3-384", NistObjectIdentifiers.IdSha3_384);
-            digestNameToOids.Add("SHA3-512", NistObjectIdentifiers.IdSha3_512);
-
-            digestNameToOids.Add("SHAKE-128", NistObjectIdentifiers.IdShake128);
-            digestNameToOids.Add("SHAKE-256", NistObjectIdentifiers.IdShake256);
-
-            digestNameToOids.Add("GOST3411", CryptoProObjectIdentifiers.GostR3411);
-
-            digestNameToOids.Add("MD2", PkcsObjectIdentifiers.MD2);
-            digestNameToOids.Add("MD4", PkcsObjectIdentifiers.MD4);
-            digestNameToOids.Add("MD5", PkcsObjectIdentifiers.MD5);
-
-            digestNameToOids.Add("RIPEMD128", TeleTrusTObjectIdentifiers.RipeMD128);
-            digestNameToOids.Add("RIPEMD160", TeleTrusTObjectIdentifiers.RipeMD160);
-            digestNameToOids.Add("RIPEMD256", TeleTrusTObjectIdentifiers.RipeMD256);
+            m_digestOids.Add(OiwObjectIdentifiers.MD4WithRsaEncryption, PkcsObjectIdentifiers.MD4);
+            m_digestOids.Add(OiwObjectIdentifiers.MD4WithRsa, PkcsObjectIdentifiers.MD4);
+            m_digestOids.Add(OiwObjectIdentifiers.MD5WithRsa, PkcsObjectIdentifiers.MD5);
+            m_digestOids.Add(OiwObjectIdentifiers.Sha1WithRsa, OiwObjectIdentifiers.IdSha1);
+            m_digestOids.Add(OiwObjectIdentifiers.DsaWithSha1, OiwObjectIdentifiers.IdSha1);
+
+            m_digestOids.Add(PkcsObjectIdentifiers.Sha224WithRsaEncryption, NistObjectIdentifiers.IdSha224);
+            m_digestOids.Add(PkcsObjectIdentifiers.Sha256WithRsaEncryption, NistObjectIdentifiers.IdSha256);
+            m_digestOids.Add(PkcsObjectIdentifiers.Sha384WithRsaEncryption, NistObjectIdentifiers.IdSha384);
+            m_digestOids.Add(PkcsObjectIdentifiers.Sha512WithRsaEncryption, NistObjectIdentifiers.IdSha512);
+            m_digestOids.Add(PkcsObjectIdentifiers.Sha512_224WithRSAEncryption, NistObjectIdentifiers.IdSha512_224);
+            m_digestOids.Add(PkcsObjectIdentifiers.Sha512_256WithRSAEncryption, NistObjectIdentifiers.IdSha512_256);
+
+            m_digestOids.Add(NistObjectIdentifiers.IdRsassaPkcs1V15WithSha3_224, NistObjectIdentifiers.IdSha3_224);
+            m_digestOids.Add(NistObjectIdentifiers.IdRsassaPkcs1V15WithSha3_256, NistObjectIdentifiers.IdSha3_256);
+            m_digestOids.Add(NistObjectIdentifiers.IdRsassaPkcs1V15WithSha3_384, NistObjectIdentifiers.IdSha3_384);
+            m_digestOids.Add(NistObjectIdentifiers.IdRsassaPkcs1V15WithSha3_512, NistObjectIdentifiers.IdSha3_512);
+
+            m_digestOids.Add(PkcsObjectIdentifiers.MD2WithRsaEncryption, PkcsObjectIdentifiers.MD2);
+            m_digestOids.Add(PkcsObjectIdentifiers.MD4WithRsaEncryption, PkcsObjectIdentifiers.MD4);
+            m_digestOids.Add(PkcsObjectIdentifiers.MD5WithRsaEncryption, PkcsObjectIdentifiers.MD5);
+            m_digestOids.Add(PkcsObjectIdentifiers.Sha1WithRsaEncryption, OiwObjectIdentifiers.IdSha1);
+
+            m_digestOids.Add(X9ObjectIdentifiers.ECDsaWithSha1, OiwObjectIdentifiers.IdSha1);
+            m_digestOids.Add(X9ObjectIdentifiers.ECDsaWithSha224, NistObjectIdentifiers.IdSha224);
+            m_digestOids.Add(X9ObjectIdentifiers.ECDsaWithSha256, NistObjectIdentifiers.IdSha256);
+            m_digestOids.Add(X9ObjectIdentifiers.ECDsaWithSha384, NistObjectIdentifiers.IdSha384);
+            m_digestOids.Add(X9ObjectIdentifiers.ECDsaWithSha512, NistObjectIdentifiers.IdSha512);
+            m_digestOids.Add(X9ObjectIdentifiers.IdDsaWithSha1, OiwObjectIdentifiers.IdSha1);
+
+            m_digestOids.Add(NistObjectIdentifiers.DsaWithSha224, NistObjectIdentifiers.IdSha224);
+            m_digestOids.Add(NistObjectIdentifiers.DsaWithSha256, NistObjectIdentifiers.IdSha256);
+            m_digestOids.Add(NistObjectIdentifiers.DsaWithSha384, NistObjectIdentifiers.IdSha384);
+            m_digestOids.Add(NistObjectIdentifiers.DsaWithSha512, NistObjectIdentifiers.IdSha512);
+
+            m_digestOids.Add(TeleTrusTObjectIdentifiers.RsaSignatureWithRipeMD128, TeleTrusTObjectIdentifiers.RipeMD128);
+            m_digestOids.Add(TeleTrusTObjectIdentifiers.RsaSignatureWithRipeMD160, TeleTrusTObjectIdentifiers.RipeMD160);
+            m_digestOids.Add(TeleTrusTObjectIdentifiers.RsaSignatureWithRipeMD256, TeleTrusTObjectIdentifiers.RipeMD256);
+
+            m_digestOids.Add(CryptoProObjectIdentifiers.GostR3411x94WithGostR3410x94, CryptoProObjectIdentifiers.GostR3411);
+            m_digestOids.Add(CryptoProObjectIdentifiers.GostR3411x94WithGostR3410x2001, CryptoProObjectIdentifiers.GostR3411);
+
+            m_digestNameToOids.Add("SHA-1", OiwObjectIdentifiers.IdSha1);
+            m_digestNameToOids.Add("SHA-224", NistObjectIdentifiers.IdSha224);
+            m_digestNameToOids.Add("SHA-256", NistObjectIdentifiers.IdSha256);
+            m_digestNameToOids.Add("SHA-384", NistObjectIdentifiers.IdSha384);
+            m_digestNameToOids.Add("SHA-512", NistObjectIdentifiers.IdSha512);
+            m_digestNameToOids.Add("SHA-512/224", NistObjectIdentifiers.IdSha512_224);
+            m_digestNameToOids.Add("SHA-512(224)", NistObjectIdentifiers.IdSha512_224);
+            m_digestNameToOids.Add("SHA-512/256", NistObjectIdentifiers.IdSha512_256);
+            m_digestNameToOids.Add("SHA-512(256)", NistObjectIdentifiers.IdSha512_256);
+
+            m_digestNameToOids.Add("SHA1", OiwObjectIdentifiers.IdSha1);
+            m_digestNameToOids.Add("SHA224", NistObjectIdentifiers.IdSha224);
+            m_digestNameToOids.Add("SHA256", NistObjectIdentifiers.IdSha256);
+            m_digestNameToOids.Add("SHA384", NistObjectIdentifiers.IdSha384);
+            m_digestNameToOids.Add("SHA512", NistObjectIdentifiers.IdSha512);
+            m_digestNameToOids.Add("SHA512/224", NistObjectIdentifiers.IdSha512_224);
+            m_digestNameToOids.Add("SHA512(224)", NistObjectIdentifiers.IdSha512_224);
+            m_digestNameToOids.Add("SHA512/256", NistObjectIdentifiers.IdSha512_256);
+            m_digestNameToOids.Add("SHA512(256)", NistObjectIdentifiers.IdSha512_256);
+
+            m_digestNameToOids.Add("SHA3-224", NistObjectIdentifiers.IdSha3_224);
+            m_digestNameToOids.Add("SHA3-256", NistObjectIdentifiers.IdSha3_256);
+            m_digestNameToOids.Add("SHA3-384", NistObjectIdentifiers.IdSha3_384);
+            m_digestNameToOids.Add("SHA3-512", NistObjectIdentifiers.IdSha3_512);
+
+            m_digestNameToOids.Add("SHAKE-128", NistObjectIdentifiers.IdShake128);
+            m_digestNameToOids.Add("SHAKE-256", NistObjectIdentifiers.IdShake256);
+
+            m_digestNameToOids.Add("GOST3411", CryptoProObjectIdentifiers.GostR3411);
+
+            m_digestNameToOids.Add("MD2", PkcsObjectIdentifiers.MD2);
+            m_digestNameToOids.Add("MD4", PkcsObjectIdentifiers.MD4);
+            m_digestNameToOids.Add("MD5", PkcsObjectIdentifiers.MD5);
+
+            m_digestNameToOids.Add("RIPEMD128", TeleTrusTObjectIdentifiers.RipeMD128);
+            m_digestNameToOids.Add("RIPEMD160", TeleTrusTObjectIdentifiers.RipeMD160);
+            m_digestNameToOids.Add("RIPEMD256", TeleTrusTObjectIdentifiers.RipeMD256);
         }
 
-        public AlgorithmIdentifier find(AlgorithmIdentifier sigAlgId)
+        public AlgorithmIdentifier Find(AlgorithmIdentifier sigAlgId)
         {
             AlgorithmIdentifier digAlgId;
 
@@ -470,15 +469,15 @@ namespace Org.BouncyCastle.Cms
             }
             else
             {
-                digAlgId = new AlgorithmIdentifier((DerObjectIdentifier)digestOids[sigAlgId.Algorithm], DerNull.Instance);
+                digAlgId = new AlgorithmIdentifier(m_digestOids[sigAlgId.Algorithm], DerNull.Instance);
             }
 
             return digAlgId;
         }
 
-        public AlgorithmIdentifier find(string digAlgName)
+        public AlgorithmIdentifier Find(string digAlgName)
         {
-            return new AlgorithmIdentifier((DerObjectIdentifier)digestNameToOids[digAlgName], DerNull.Instance);
+            return new AlgorithmIdentifier(m_digestNameToOids[digAlgName], DerNull.Instance);
         }
     }
 
@@ -511,8 +510,9 @@ namespace Org.BouncyCastle.Cms
 
         internal List<Asn1Encodable> _certs = new List<Asn1Encodable>();
         internal List<Asn1Encodable> _crls = new List<Asn1Encodable>();
-        internal IList _signers = Platform.CreateArrayList();
-        internal IDictionary _digests = Platform.CreateHashtable();
+        internal IList<SignerInformation> _signers = new List<SignerInformation>();
+        internal IDictionary<string, byte[]> m_digests =
+            new Dictionary<string, byte[]>(StringComparer.OrdinalIgnoreCase);
         internal bool _useDerForCerts = false;
         internal bool _useDerForCrls = false;
 
@@ -531,12 +531,10 @@ namespace Org.BouncyCastle.Cms
             this.rand = rand;
         }
 
-        internal protected virtual IDictionary GetBaseParameters(
-            DerObjectIdentifier contentType,
-            AlgorithmIdentifier digAlgId,
-            byte[] hash)
+        internal protected virtual IDictionary<CmsAttributeTableParameter, object> GetBaseParameters(
+            DerObjectIdentifier contentType, AlgorithmIdentifier digAlgId, byte[] hash)
         {
-            IDictionary param = Platform.CreateHashtable();
+            var param = new Dictionary<CmsAttributeTableParameter, object>();
 
             if (contentType != null)
             {
@@ -607,9 +605,9 @@ namespace Org.BouncyCastle.Cms
 		 *
 		 * @return a map of oids (as string objects) and byte[] representing digests.
 		 */
-        public IDictionary GetGeneratedDigests()
+        public IDictionary<string, byte[]> GetGeneratedDigests()
         {
-            return Platform.CreateHashtable(_digests);
+            return new Dictionary<string, byte[]>(m_digests, StringComparer.OrdinalIgnoreCase);
         }
 
         public bool UseDerForCerts
diff --git a/crypto/src/cms/CMSSignedHelper.cs b/crypto/src/cms/CMSSignedHelper.cs
index e48041a50..0aced112e 100644
--- a/crypto/src/cms/CMSSignedHelper.cs
+++ b/crypto/src/cms/CMSSignedHelper.cs
@@ -1,5 +1,4 @@
 using System;
-using System.Collections;
 using System.Collections.Generic;
 
 using Org.BouncyCastle.Asn1;
@@ -14,7 +13,6 @@ using Org.BouncyCastle.Asn1.X9;
 using Org.BouncyCastle.Crypto;
 using Org.BouncyCastle.Crypto.Parameters;
 using Org.BouncyCastle.Security;
-using Org.BouncyCastle.Utilities;
 using Org.BouncyCastle.Utilities.Collections;
 using Org.BouncyCastle.X509;
 
@@ -30,18 +28,18 @@ namespace Org.BouncyCastle.Cms
         private static readonly string EncryptionECDsaWithSha384 = X9ObjectIdentifiers.ECDsaWithSha384.Id;
         private static readonly string EncryptionECDsaWithSha512 = X9ObjectIdentifiers.ECDsaWithSha512.Id;
 
-        private static readonly IDictionary encryptionAlgs = Platform.CreateHashtable();
-        private static readonly IDictionary digestAlgs = Platform.CreateHashtable();
-        private static readonly IDictionary digestAliases = Platform.CreateHashtable();
+		private static readonly IDictionary<string, string> m_encryptionAlgs = new Dictionary<string, string>();
+		private static readonly IDictionary<string, string> m_digestAlgs = new Dictionary<string, string>();
+		private static readonly IDictionary<string, string[]> m_digestAliases = new Dictionary<string, string[]>();
 
         private static readonly HashSet<string> noParams = new HashSet<string>();
-        private static readonly IDictionary ecAlgorithms = Platform.CreateHashtable();
+		private static readonly IDictionary<string, string> m_ecAlgorithms = new Dictionary<string, string>();
 
-        private static void AddEntries(DerObjectIdentifier oid, string digest, string encryption)
+		private static void AddEntries(DerObjectIdentifier oid, string digest, string encryption)
 		{
 			string alias = oid.Id;
-			digestAlgs.Add(alias, digest);
-			encryptionAlgs.Add(alias, encryption);
+			m_digestAlgs.Add(alias, digest);
+			m_encryptionAlgs.Add(alias, encryption);
 		}
 
 		static CmsSignedHelper()
@@ -85,41 +83,41 @@ namespace Org.BouncyCastle.Cms
 			AddEntries(EacObjectIdentifiers.id_TA_RSA_PSS_SHA_1, "SHA1", "RSAandMGF1");
 			AddEntries(EacObjectIdentifiers.id_TA_RSA_PSS_SHA_256, "SHA256", "RSAandMGF1");
 
-			encryptionAlgs.Add(X9ObjectIdentifiers.IdDsa.Id, "DSA");
-			encryptionAlgs.Add(PkcsObjectIdentifiers.RsaEncryption.Id, "RSA");
-			encryptionAlgs.Add(TeleTrusTObjectIdentifiers.TeleTrusTRsaSignatureAlgorithm.Id, "RSA");
-			encryptionAlgs.Add(X509ObjectIdentifiers.IdEARsa.Id, "RSA");
-			encryptionAlgs.Add(CmsSignedGenerator.EncryptionRsaPss, "RSAandMGF1");
-			encryptionAlgs.Add(CryptoProObjectIdentifiers.GostR3410x94.Id, "GOST3410");
-			encryptionAlgs.Add(CryptoProObjectIdentifiers.GostR3410x2001.Id, "ECGOST3410");
-			encryptionAlgs.Add("1.3.6.1.4.1.5849.1.6.2", "ECGOST3410");
-			encryptionAlgs.Add("1.3.6.1.4.1.5849.1.1.5", "GOST3410");
-
-			digestAlgs.Add(PkcsObjectIdentifiers.MD2.Id, "MD2");
-			digestAlgs.Add(PkcsObjectIdentifiers.MD4.Id, "MD4");
-			digestAlgs.Add(PkcsObjectIdentifiers.MD5.Id, "MD5");
-			digestAlgs.Add(OiwObjectIdentifiers.IdSha1.Id, "SHA1");
-			digestAlgs.Add(NistObjectIdentifiers.IdSha224.Id, "SHA224");
-			digestAlgs.Add(NistObjectIdentifiers.IdSha256.Id, "SHA256");
-			digestAlgs.Add(NistObjectIdentifiers.IdSha384.Id, "SHA384");
-			digestAlgs.Add(NistObjectIdentifiers.IdSha512.Id, "SHA512");
-            digestAlgs.Add(NistObjectIdentifiers.IdSha512_224.Id, "SHA512(224)");
-            digestAlgs.Add(NistObjectIdentifiers.IdSha512_256.Id, "SHA512(256)");
-            digestAlgs.Add(NistObjectIdentifiers.IdSha3_224.Id, "SHA3-224");
-            digestAlgs.Add(NistObjectIdentifiers.IdSha3_256.Id, "SHA3-256");
-            digestAlgs.Add(NistObjectIdentifiers.IdSha3_384.Id, "SHA3-384");
-            digestAlgs.Add(NistObjectIdentifiers.IdSha3_512.Id, "SHA3-512");
-            digestAlgs.Add(TeleTrusTObjectIdentifiers.RipeMD128.Id, "RIPEMD128");
-			digestAlgs.Add(TeleTrusTObjectIdentifiers.RipeMD160.Id, "RIPEMD160");
-			digestAlgs.Add(TeleTrusTObjectIdentifiers.RipeMD256.Id, "RIPEMD256");
-			digestAlgs.Add(CryptoProObjectIdentifiers.GostR3411.Id,  "GOST3411");
-			digestAlgs.Add("1.3.6.1.4.1.5849.1.2.1",  "GOST3411");
-
-			digestAliases.Add("SHA1", new string[] { "SHA-1" });
-			digestAliases.Add("SHA224", new string[] { "SHA-224" });
-			digestAliases.Add("SHA256", new string[] { "SHA-256" });
-			digestAliases.Add("SHA384", new string[] { "SHA-384" });
-			digestAliases.Add("SHA512", new string[] { "SHA-512" });
+			m_encryptionAlgs.Add(X9ObjectIdentifiers.IdDsa.Id, "DSA");
+			m_encryptionAlgs.Add(PkcsObjectIdentifiers.RsaEncryption.Id, "RSA");
+			m_encryptionAlgs.Add(TeleTrusTObjectIdentifiers.TeleTrusTRsaSignatureAlgorithm.Id, "RSA");
+			m_encryptionAlgs.Add(X509ObjectIdentifiers.IdEARsa.Id, "RSA");
+			m_encryptionAlgs.Add(CmsSignedGenerator.EncryptionRsaPss, "RSAandMGF1");
+			m_encryptionAlgs.Add(CryptoProObjectIdentifiers.GostR3410x94.Id, "GOST3410");
+			m_encryptionAlgs.Add(CryptoProObjectIdentifiers.GostR3410x2001.Id, "ECGOST3410");
+			m_encryptionAlgs.Add("1.3.6.1.4.1.5849.1.6.2", "ECGOST3410");
+			m_encryptionAlgs.Add("1.3.6.1.4.1.5849.1.1.5", "GOST3410");
+
+			m_digestAlgs.Add(PkcsObjectIdentifiers.MD2.Id, "MD2");
+			m_digestAlgs.Add(PkcsObjectIdentifiers.MD4.Id, "MD4");
+			m_digestAlgs.Add(PkcsObjectIdentifiers.MD5.Id, "MD5");
+			m_digestAlgs.Add(OiwObjectIdentifiers.IdSha1.Id, "SHA1");
+			m_digestAlgs.Add(NistObjectIdentifiers.IdSha224.Id, "SHA224");
+			m_digestAlgs.Add(NistObjectIdentifiers.IdSha256.Id, "SHA256");
+			m_digestAlgs.Add(NistObjectIdentifiers.IdSha384.Id, "SHA384");
+			m_digestAlgs.Add(NistObjectIdentifiers.IdSha512.Id, "SHA512");
+			m_digestAlgs.Add(NistObjectIdentifiers.IdSha512_224.Id, "SHA512(224)");
+			m_digestAlgs.Add(NistObjectIdentifiers.IdSha512_256.Id, "SHA512(256)");
+			m_digestAlgs.Add(NistObjectIdentifiers.IdSha3_224.Id, "SHA3-224");
+			m_digestAlgs.Add(NistObjectIdentifiers.IdSha3_256.Id, "SHA3-256");
+			m_digestAlgs.Add(NistObjectIdentifiers.IdSha3_384.Id, "SHA3-384");
+			m_digestAlgs.Add(NistObjectIdentifiers.IdSha3_512.Id, "SHA3-512");
+			m_digestAlgs.Add(TeleTrusTObjectIdentifiers.RipeMD128.Id, "RIPEMD128");
+			m_digestAlgs.Add(TeleTrusTObjectIdentifiers.RipeMD160.Id, "RIPEMD160");
+			m_digestAlgs.Add(TeleTrusTObjectIdentifiers.RipeMD256.Id, "RIPEMD256");
+			m_digestAlgs.Add(CryptoProObjectIdentifiers.GostR3411.Id,  "GOST3411");
+			m_digestAlgs.Add("1.3.6.1.4.1.5849.1.2.1",  "GOST3411");
+
+			m_digestAliases.Add("SHA1", new string[]{ "SHA-1" });
+			m_digestAliases.Add("SHA224", new string[]{ "SHA-224" });
+			m_digestAliases.Add("SHA256", new string[]{ "SHA-256" });
+			m_digestAliases.Add("SHA384", new string[]{ "SHA-384" });
+			m_digestAliases.Add("SHA512", new string[]{ "SHA-512" });
 
             noParams.Add(CmsSignedGenerator.EncryptionDsa);
             //			noParams.Add(EncryptionECDsa);
@@ -129,50 +127,36 @@ namespace Org.BouncyCastle.Cms
             noParams.Add(EncryptionECDsaWithSha384);
             noParams.Add(EncryptionECDsaWithSha512);
 
-            ecAlgorithms.Add(CmsSignedGenerator.DigestSha1, EncryptionECDsaWithSha1);
-            ecAlgorithms.Add(CmsSignedGenerator.DigestSha224, EncryptionECDsaWithSha224);
-            ecAlgorithms.Add(CmsSignedGenerator.DigestSha256, EncryptionECDsaWithSha256);
-            ecAlgorithms.Add(CmsSignedGenerator.DigestSha384, EncryptionECDsaWithSha384);
-            ecAlgorithms.Add(CmsSignedGenerator.DigestSha512, EncryptionECDsaWithSha512);
-    }
-
-       
+			m_ecAlgorithms.Add(CmsSignedGenerator.DigestSha1, EncryptionECDsaWithSha1);
+			m_ecAlgorithms.Add(CmsSignedGenerator.DigestSha224, EncryptionECDsaWithSha224);
+			m_ecAlgorithms.Add(CmsSignedGenerator.DigestSha256, EncryptionECDsaWithSha256);
+			m_ecAlgorithms.Add(CmsSignedGenerator.DigestSha384, EncryptionECDsaWithSha384);
+			m_ecAlgorithms.Add(CmsSignedGenerator.DigestSha512, EncryptionECDsaWithSha512);
+		}
 
-        /**
+		/**
         * Return the digest algorithm using one of the standard JCA string
         * representations rather than the algorithm identifier (if possible).
         */
-        internal string GetDigestAlgName(
-            string digestAlgOid)
+		internal string GetDigestAlgName(string digestAlgOid)
         {
-			string algName = (string)digestAlgs[digestAlgOid];
+			return m_digestAlgs.TryGetValue(digestAlgOid, out var algName) ? algName : digestAlgOid;
+        }
 
-			if (algName != null)
+		internal AlgorithmIdentifier GetEncAlgorithmIdentifier(DerObjectIdentifier encOid,
+			Asn1Encodable sigX509Parameters)
+		{
+			if (noParams.Contains(encOid.Id))
 			{
-				return algName;
+				return new AlgorithmIdentifier(encOid);
 			}
 
-			return digestAlgOid;
-        }
-
-    internal AlgorithmIdentifier GetEncAlgorithmIdentifier(
-    DerObjectIdentifier encOid,
-    Asn1Encodable sigX509Parameters)
-    {
-        if (noParams.Contains(encOid.Id))
-        {
-            return new AlgorithmIdentifier(encOid);
-        }
-
-        return new AlgorithmIdentifier(encOid, sigX509Parameters);
-    }
+			return new AlgorithmIdentifier(encOid, sigX509Parameters);
+		}
 
-    internal string[] GetDigestAliases(
-			string algName)
+		internal string[] GetDigestAliases(string algName)
 		{
-			string[] aliases = (string[]) digestAliases[algName];
-
-			return aliases == null ? new string[0] : (string[]) aliases.Clone();
+			return m_digestAliases.TryGetValue(algName, out var aliases) ? (string[])aliases.Clone() : new string[0];
 		}
 
 		/**
@@ -180,17 +164,9 @@ namespace Org.BouncyCastle.Cms
         * JCA string representations rather than the algorithm identifier (if
         * possible).
         */
-        internal string GetEncryptionAlgName(
-            string encryptionAlgOid)
+        internal string GetEncryptionAlgName(string encryptionAlgOid)
         {
-			string algName = (string) encryptionAlgs[encryptionAlgOid];
-
-			if (algName != null)
-			{
-				return algName;
-			}
-
-			return encryptionAlgOid;
+			return m_encryptionAlgs.TryGetValue(encryptionAlgOid, out var algName) ? algName : encryptionAlgOid;
         }
 
 		internal IDigest GetDigestInstance(
@@ -278,12 +254,10 @@ namespace Org.BouncyCastle.Cms
                     encOID = CmsSignedGenerator.EncryptionECGost3410;
                 }
                 else
-                {
-                    // TODO Should we insist on algName being one of "EC" or "ECDSA", as Java does?
-                    encOID = (string)ecAlgorithms[digestOID];
-
-                    if (encOID == null)
-                        throw new ArgumentException("can't mix ECDSA with anything but SHA family digests");
+				{
+					// TODO Should we insist on algName being one of "EC" or "ECDSA", as Java does?
+					if (!m_ecAlgorithms.TryGetValue(digestOID, out encOID))
+						throw new ArgumentException("can't mix ECDSA with anything but SHA family digests");
                 }
             }
             else if (key is Gost3410PrivateKeyParameters)
diff --git a/crypto/src/cms/DefaultAuthenticatedAttributeTableGenerator.cs b/crypto/src/cms/DefaultAuthenticatedAttributeTableGenerator.cs
index 678d8269b..fcbd2d504 100644
--- a/crypto/src/cms/DefaultAuthenticatedAttributeTableGenerator.cs
+++ b/crypto/src/cms/DefaultAuthenticatedAttributeTableGenerator.cs
@@ -1,5 +1,4 @@
 using System;
-using System.Collections;
 using System.Collections.Generic;
 
 using Org.BouncyCastle.Asn1;
@@ -52,7 +51,7 @@ namespace Org.BouncyCastle.Cms
 		 * @return a filled in IDictionary of attributes.
 		 */
 		protected virtual IDictionary<DerObjectIdentifier, object> CreateStandardAttributeTable(
-			IDictionary parameters)
+			IDictionary<CmsAttributeTableParameter, object> parameters)
 		{
             var std = new Dictionary<DerObjectIdentifier, object>(m_table);
 
@@ -80,7 +79,7 @@ namespace Org.BouncyCastle.Cms
 		 * @param parameters source parameters
 		 * @return the populated attribute table
 		 */
-		public virtual AttributeTable GetAttributes(IDictionary parameters)
+		public virtual AttributeTable GetAttributes(IDictionary<CmsAttributeTableParameter, object> parameters)
 		{
             var table = CreateStandardAttributeTable(parameters);
 			return new AttributeTable(table);
diff --git a/crypto/src/cms/DefaultSignedAttributeTableGenerator.cs b/crypto/src/cms/DefaultSignedAttributeTableGenerator.cs
index 8d0bca083..e1bec484a 100644
--- a/crypto/src/cms/DefaultSignedAttributeTableGenerator.cs
+++ b/crypto/src/cms/DefaultSignedAttributeTableGenerator.cs
@@ -1,10 +1,8 @@
 using System;
-using System.Collections;
 using System.Collections.Generic;
 
 using Org.BouncyCastle.Asn1;
 using Org.BouncyCastle.Asn1.Cms;
-using Org.BouncyCastle.Utilities;
 
 namespace Org.BouncyCastle.Cms
 {
@@ -51,18 +49,20 @@ namespace Org.BouncyCastle.Cms
 		 *
 		 * @return a filled in Hashtable of attributes.
 		 */
-		protected virtual IDictionary<DerObjectIdentifier, object> CreateStandardAttributeTable(IDictionary parameters)
+		protected virtual IDictionary<DerObjectIdentifier, object> CreateStandardAttributeTable(
+			IDictionary<CmsAttributeTableParameter, object> parameters)
 		{
             var std = new Dictionary<DerObjectIdentifier, object>(m_table);
             DoCreateStandardAttributeTable(parameters, std);
 			return std;
 		}
 
-        private void DoCreateStandardAttributeTable(IDictionary parameters,
+        private void DoCreateStandardAttributeTable(IDictionary<CmsAttributeTableParameter, object> parameters,
 			IDictionary<DerObjectIdentifier, object> std)
         {
             // contentType will be absent if we're trying to generate a counter signature.
-            if (parameters.Contains(CmsAttributeTableParameter.ContentType))
+
+            if (parameters.ContainsKey(CmsAttributeTableParameter.ContentType))
             {
                 if (!std.ContainsKey(CmsAttributes.ContentType))
                 {
@@ -94,8 +94,7 @@ namespace Org.BouncyCastle.Cms
 		 * @param parameters source parameters
 		 * @return the populated attribute table
 		 */
-		public virtual AttributeTable GetAttributes(
-			IDictionary parameters)
+		public virtual AttributeTable GetAttributes(IDictionary<CmsAttributeTableParameter, object> parameters)
 		{
             var table = CreateStandardAttributeTable(parameters);
 			return new AttributeTable(table);
diff --git a/crypto/src/cms/EnvelopedDataHelper.cs b/crypto/src/cms/EnvelopedDataHelper.cs
index 6d1c7bb3a..8c4dd7bf9 100644
--- a/crypto/src/cms/EnvelopedDataHelper.cs
+++ b/crypto/src/cms/EnvelopedDataHelper.cs
@@ -1,15 +1,11 @@
 using System;
-using System.Collections;
+using System.Collections.Generic;
 
 using Org.BouncyCastle.Asn1;
 using Org.BouncyCastle.Asn1.Nist;
-using Org.BouncyCastle.Asn1.Oiw;
 using Org.BouncyCastle.Asn1.Pkcs;
 using Org.BouncyCastle.Asn1.X509;
 using Org.BouncyCastle.Crypto;
-using Org.BouncyCastle.Crypto.Digests;
-using Org.BouncyCastle.Crypto.Engines;
-using Org.BouncyCastle.Crypto.Operators;
 using Org.BouncyCastle.Crypto.Parameters;
 using Org.BouncyCastle.Crypto.Utilities;
 using Org.BouncyCastle.Security;
@@ -19,29 +15,32 @@ namespace Org.BouncyCastle.Cms
 {
     internal class EnvelopedDataHelper
     {
-        private static readonly IDictionary BaseCipherNames = Platform.CreateHashtable();
-        private static readonly IDictionary MacAlgNames = Platform.CreateHashtable();
-        //private static readonly IDictionary PrfDigests = Platform.CreateHashtable();
+        //private static readonly IDictionary<DerObjectIdentifier, string> BaseCipherNames =
+        //    new Dictionary<DerObjectIdentifier, string>();
+        //private static readonly IDictionary<DerObjectIdentifier, string> MacAlgNames =
+        //    new Dictionary<DerObjectIdentifier, string>();
+        //private static readonly IDictionary<DerObjectIdentifier, string> PrfDigests =
+        //    new Dictionary<DerObjectIdentifier, string>();
 
-        static EnvelopedDataHelper()
-        {
-            //PrfDigests.Add(PkcsObjectIdentifiers.IdHmacWithSha1, "SHA-1");
-            //PrfDigests.Add(PkcsObjectIdentifiers.IdHmacWithSha224, "SHA-224");
-            //PrfDigests.Add(PkcsObjectIdentifiers.IdHmacWithSha256, "SHA-256");
-            //PrfDigests.Add(PkcsObjectIdentifiers.IdHmacWithSha384, "SHA-384");
-            //PrfDigests.Add(PkcsObjectIdentifiers.IdHmacWithSha512, "SHA-512");
+        //static EnvelopedDataHelper()
+        //{
+        //    PrfDigests.Add(PkcsObjectIdentifiers.IdHmacWithSha1, "SHA-1");
+        //    PrfDigests.Add(PkcsObjectIdentifiers.IdHmacWithSha224, "SHA-224");
+        //    PrfDigests.Add(PkcsObjectIdentifiers.IdHmacWithSha256, "SHA-256");
+        //    PrfDigests.Add(PkcsObjectIdentifiers.IdHmacWithSha384, "SHA-384");
+        //    PrfDigests.Add(PkcsObjectIdentifiers.IdHmacWithSha512, "SHA-512");
 
-            BaseCipherNames.Add(PkcsObjectIdentifiers.DesEde3Cbc, "DESEDE");
-            BaseCipherNames.Add(NistObjectIdentifiers.IdAes128Cbc, "AES");
-            BaseCipherNames.Add(NistObjectIdentifiers.IdAes192Cbc, "AES");
-            BaseCipherNames.Add(NistObjectIdentifiers.IdAes256Cbc, "AES");
+        //    BaseCipherNames.Add(PkcsObjectIdentifiers.DesEde3Cbc, "DESEDE");
+        //    BaseCipherNames.Add(NistObjectIdentifiers.IdAes128Cbc, "AES");
+        //    BaseCipherNames.Add(NistObjectIdentifiers.IdAes192Cbc, "AES");
+        //    BaseCipherNames.Add(NistObjectIdentifiers.IdAes256Cbc, "AES");
 
-            MacAlgNames.Add(PkcsObjectIdentifiers.DesEde3Cbc, "DESEDEMac");
-            MacAlgNames.Add(NistObjectIdentifiers.IdAes128Cbc, "AESMac");
-            MacAlgNames.Add(NistObjectIdentifiers.IdAes192Cbc, "AESMac");
-            MacAlgNames.Add(NistObjectIdentifiers.IdAes256Cbc, "AESMac");
-            MacAlgNames.Add(PkcsObjectIdentifiers.RC2Cbc, "RC2Mac");
-        }
+        //    MacAlgNames.Add(PkcsObjectIdentifiers.DesEde3Cbc, "DESEDEMac");
+        //    MacAlgNames.Add(NistObjectIdentifiers.IdAes128Cbc, "AESMac");
+        //    MacAlgNames.Add(NistObjectIdentifiers.IdAes192Cbc, "AESMac");
+        //    MacAlgNames.Add(NistObjectIdentifiers.IdAes256Cbc, "AESMac");
+        //    MacAlgNames.Add(PkcsObjectIdentifiers.RC2Cbc, "RC2Mac");
+        //}
 
         //internal static IDigest GetPrf(AlgorithmIdentifier algID)
         //{
@@ -82,7 +81,8 @@ namespace Org.BouncyCastle.Cms
             return CipherFactory.CreateContentCipher(forEncryption, encKey, encryptionAlgID);
         }
 
-        public AlgorithmIdentifier GenerateEncryptionAlgID(DerObjectIdentifier encryptionOID, KeyParameter encKey, SecureRandom random)
+        public AlgorithmIdentifier GenerateEncryptionAlgID(DerObjectIdentifier encryptionOID, KeyParameter encKey,
+            SecureRandom random)
         {
             return AlgorithmIdentifierFactory.GenerateEncryptionAlgID(encryptionOID, encKey.GetKey().Length * 8, random);
         }
diff --git a/crypto/src/cms/KeyAgreeRecipientInfoGenerator.cs b/crypto/src/cms/KeyAgreeRecipientInfoGenerator.cs
index 6bd2cea91..7686ee422 100644
--- a/crypto/src/cms/KeyAgreeRecipientInfoGenerator.cs
+++ b/crypto/src/cms/KeyAgreeRecipientInfoGenerator.cs
@@ -1,5 +1,5 @@
 using System;
-using System.Collections;
+using System.Collections.Generic;
 using System.IO;
 
 using Org.BouncyCastle.Asn1;
@@ -11,7 +11,6 @@ using Org.BouncyCastle.Crypto;
 using Org.BouncyCastle.Crypto.Parameters;
 using Org.BouncyCastle.Math;
 using Org.BouncyCastle.Security;
-using Org.BouncyCastle.Utilities;
 using Org.BouncyCastle.X509;
 
 namespace Org.BouncyCastle.Cms
@@ -22,7 +21,7 @@ namespace Org.BouncyCastle.Cms
 
 		private DerObjectIdentifier			keyAgreementOID;
 		private DerObjectIdentifier			keyEncryptionOID;
-		private IList					    recipientCerts;
+		private IList<X509Certificate>      recipientCerts;
 		private AsymmetricCipherKeyPair		senderKeyPair;
 
 		internal KeyAgreeRecipientInfoGenerator()
@@ -39,9 +38,9 @@ namespace Org.BouncyCastle.Cms
 			set { this.keyEncryptionOID = value; }
 		}
 
-		internal ICollection RecipientCerts
+		internal IEnumerable<X509Certificate> RecipientCerts
 		{
-			set { this.recipientCerts = Platform.CreateArrayList(value); }
+			set { this.recipientCerts = new List<X509Certificate>(value); }
 		}
 
 		internal AsymmetricCipherKeyPair SenderKeyPair
diff --git a/crypto/src/cms/KeyAgreeRecipientInformation.cs b/crypto/src/cms/KeyAgreeRecipientInformation.cs
index 73e57a76a..8843ede0d 100644
--- a/crypto/src/cms/KeyAgreeRecipientInformation.cs
+++ b/crypto/src/cms/KeyAgreeRecipientInformation.cs
@@ -1,12 +1,11 @@
 using System;
-using System.Collections;
+using System.Collections.Generic;
 using System.IO;
 
 using Org.BouncyCastle.Asn1;
 using Org.BouncyCastle.Asn1.Cms;
 using Org.BouncyCastle.Asn1.Cms.Ecc;
 using Org.BouncyCastle.Asn1.Pkcs;
-using Org.BouncyCastle.Asn1.Utilities;
 using Org.BouncyCastle.Asn1.X509;
 using Org.BouncyCastle.Asn1.X9;
 using Org.BouncyCastle.Crypto;
@@ -14,7 +13,6 @@ using Org.BouncyCastle.Crypto.Parameters;
 using Org.BouncyCastle.Math;
 using Org.BouncyCastle.Pkcs;
 using Org.BouncyCastle.Security;
-using Org.BouncyCastle.X509;
 
 namespace Org.BouncyCastle.Cms
 {
@@ -28,7 +26,7 @@ namespace Org.BouncyCastle.Cms
         private KeyAgreeRecipientInfo info;
         private Asn1OctetString       encryptedKey;
 
-        internal static void ReadRecipientInfo(IList infos, KeyAgreeRecipientInfo info,
+        internal static void ReadRecipientInfo(IList<RecipientInformation> infos, KeyAgreeRecipientInfo info,
             CmsSecureReadable secureReadable)
         {
             try
diff --git a/crypto/src/cms/RecipientInformationStore.cs b/crypto/src/cms/RecipientInformationStore.cs
index 33b472f9d..06d093805 100644
--- a/crypto/src/cms/RecipientInformationStore.cs
+++ b/crypto/src/cms/RecipientInformationStore.cs
@@ -1,5 +1,5 @@
 using System;
-using System.Collections;
+using System.Collections.Generic;
 
 using Org.BouncyCastle.Utilities;
 
@@ -7,26 +7,25 @@ namespace Org.BouncyCastle.Cms
 {
 	public class RecipientInformationStore
 	{
-		private readonly IList all; //ArrayList[RecipientInformation]
-		private readonly IDictionary table = Platform.CreateHashtable(); // Hashtable[RecipientID, ArrayList[RecipientInformation]]
+		private readonly IList<RecipientInformation> m_all;
+		private readonly IDictionary<RecipientID, IList<RecipientInformation>> m_table =
+			new Dictionary<RecipientID, IList<RecipientInformation>>();
 
-		public RecipientInformationStore(
-			ICollection recipientInfos)
+		public RecipientInformationStore(IEnumerable<RecipientInformation> recipientInfos)
 		{
 			foreach (RecipientInformation recipientInformation in recipientInfos)
 			{
 				RecipientID rid = recipientInformation.RecipientID;
-                IList list = (IList)table[rid];
 
-				if (list == null)
-				{
-					table[rid] = list = Platform.CreateArrayList(1);
+				if (!m_table.TryGetValue(rid, out var list))
+                {
+					m_table[rid] = list = new List<RecipientInformation>(1);
 				}
 
 				list.Add(recipientInformation);
 			}
 
-            this.all = Platform.CreateArrayList(recipientInfos);
+            this.m_all = new List<RecipientInformation>(recipientInfos);
 		}
 
 		public RecipientInformation this[RecipientID selector]
@@ -41,12 +40,12 @@ namespace Org.BouncyCastle.Cms
 		* @param selector to identify a recipient
 		* @return a single RecipientInformation object. Null if none matches.
 		*/
-		public RecipientInformation GetFirstRecipient(
-			RecipientID selector)
+		public RecipientInformation GetFirstRecipient(RecipientID selector)
 		{
-			IList list = (IList) table[selector];
+			if (!m_table.TryGetValue(selector, out var list))
+				return null;
 
-			return list == null ? null : (RecipientInformation) list[0];
+			return list[0];
 		}
 
 		/**
@@ -56,7 +55,7 @@ namespace Org.BouncyCastle.Cms
 		*/
 		public int Count
 		{
-			get { return all.Count; }
+			get { return m_all.Count; }
 		}
 
 		/**
@@ -64,9 +63,9 @@ namespace Org.BouncyCastle.Cms
 		*
 		* @return a collection of recipients.
 		*/
-		public ICollection GetRecipients()
+		public IList<RecipientInformation> GetRecipients()
 		{
-			return Platform.CreateArrayList(all);
+			return new List<RecipientInformation>(m_all);
 		}
 
 		/**
@@ -75,12 +74,12 @@ namespace Org.BouncyCastle.Cms
 		* @param selector a recipient id to select against.
 		* @return a collection of RecipientInformation objects.
 		*/
-		public ICollection GetRecipients(
-			RecipientID selector)
+		public IList<RecipientInformation> GetRecipients(RecipientID selector)
 		{
-            IList list = (IList)table[selector];
+			if (!m_table.TryGetValue(selector, out var list))
+				return new List<RecipientInformation>(0);
 
-            return list == null ? Platform.CreateArrayList() : Platform.CreateArrayList(list);
+			return new List<RecipientInformation>(list);
 		}
 	}
 }
diff --git a/crypto/src/cms/SignerInformation.cs b/crypto/src/cms/SignerInformation.cs
index 3ab1c09f9..551d9b737 100644
--- a/crypto/src/cms/SignerInformation.cs
+++ b/crypto/src/cms/SignerInformation.cs
@@ -1,5 +1,5 @@
 using System;
-using System.Collections;
+using System.Collections.Generic;
 using System.IO;
 
 using Org.BouncyCastle.Asn1;
@@ -256,10 +256,10 @@ namespace Org.BouncyCastle.Cms
 			Asn1.Cms.AttributeTable unsignedAttributeTable = UnsignedAttributes;
 			if (unsignedAttributeTable == null)
 			{
-                return new SignerInformationStore(Platform.CreateArrayList(0));
+                return new SignerInformationStore(new List<SignerInformation>(0));
 			}
 
-            IList counterSignatures = Platform.CreateArrayList();
+            var counterSignatures = new List<SignerInformation>();
 
 			/*
 			The UnsignedAttributes syntax is defined as a SET OF Attributes.  The
diff --git a/crypto/src/cms/SignerInformationStore.cs b/crypto/src/cms/SignerInformationStore.cs
index 27940865d..7fa3ef678 100644
--- a/crypto/src/cms/SignerInformationStore.cs
+++ b/crypto/src/cms/SignerInformationStore.cs
@@ -1,30 +1,27 @@
 using System;
-using System.Collections;
-using System.IO;
-
-using Org.BouncyCastle.Utilities;
+using System.Collections.Generic;
 
 namespace Org.BouncyCastle.Cms
 {
     public class SignerInformationStore
     {
-        private readonly IList all; //ArrayList[SignerInformation]
-        private readonly IDictionary table = Platform.CreateHashtable(); // Hashtable[SignerID, ArrayList[SignerInformation]]
+        private readonly IList<SignerInformation> all;
+        private readonly IDictionary<SignerID, IList<SignerInformation>> m_table =
+            new Dictionary<SignerID, IList<SignerInformation>>();
 
         /**
          * Create a store containing a single SignerInformation object.
          *
          * @param signerInfo the signer information to contain.
          */
-        public SignerInformationStore(
-            SignerInformation signerInfo)
+        public SignerInformationStore(SignerInformation signerInfo)
         {
-            this.all = Platform.CreateArrayList(1);
+            this.all = new List<SignerInformation>(1);
             this.all.Add(signerInfo);
 
             SignerID sid = signerInfo.SignerID;
 
-            table[sid] = all;
+            m_table[sid] = all;
         }
 
         /**
@@ -32,23 +29,21 @@ namespace Org.BouncyCastle.Cms
          *
          * @param signerInfos a collection signer information objects to contain.
          */
-        public SignerInformationStore(
-            ICollection signerInfos)
+        public SignerInformationStore(IEnumerable<SignerInformation> signerInfos)
         {
             foreach (SignerInformation signer in signerInfos)
             {
                 SignerID sid = signer.SignerID;
-                IList list = (IList)table[sid];
 
-                if (list == null)
+                if (!m_table.TryGetValue(sid, out var list))
                 {
-                    table[sid] = list = Platform.CreateArrayList(1);
+                    m_table[sid] = list = new List<SignerInformation>(1);
                 }
 
                 list.Add(signer);
             }
 
-            this.all = Platform.CreateArrayList(signerInfos);
+            this.all = new List<SignerInformation>(signerInfos);
         }
 
         /**
@@ -58,12 +53,12 @@ namespace Org.BouncyCastle.Cms
         * @param selector to identify a signer
         * @return a single SignerInformation object. Null if none matches.
         */
-        public SignerInformation GetFirstSigner(
-            SignerID selector)
+        public SignerInformation GetFirstSigner(SignerID selector)
         {
-            IList list = (IList) table[selector];
+            if (m_table.TryGetValue(selector, out var list))
+                return list[0];
 
-            return list == null ? null : (SignerInformation) list[0];
+            return null;
         }
 
         /// <summary>The number of signers in the collection.</summary>
@@ -73,9 +68,9 @@ namespace Org.BouncyCastle.Cms
         }
 
         /// <returns>An ICollection of all signers in the collection</returns>
-        public ICollection GetSigners()
+        public IList<SignerInformation> GetSigners()
         {
-            return Platform.CreateArrayList(all);
+            return new List<SignerInformation>(all);
         }
 
         /**
@@ -84,12 +79,12 @@ namespace Org.BouncyCastle.Cms
         * @param selector a signer id to select against.
         * @return a collection of SignerInformation objects.
         */
-        public ICollection GetSigners(
-            SignerID selector)
+        public IList<SignerInformation> GetSigners(SignerID selector)
         {
-            IList list = (IList) table[selector];
+            if (m_table.TryGetValue(selector, out var list))
+                return new List<SignerInformation>(list);
 
-            return list == null ? Platform.CreateArrayList() : Platform.CreateArrayList(list);
+            return new List<SignerInformation>(0);
         }
     }
 }
diff --git a/crypto/src/cms/SimpleAttributeTableGenerator.cs b/crypto/src/cms/SimpleAttributeTableGenerator.cs
index b3df21c29..7b20ac3e2 100644
--- a/crypto/src/cms/SimpleAttributeTableGenerator.cs
+++ b/crypto/src/cms/SimpleAttributeTableGenerator.cs
@@ -1,5 +1,5 @@
 using System;
-using System.Collections;
+using System.Collections.Generic;
 
 using Org.BouncyCastle.Asn1.Cms;
 
@@ -19,8 +19,7 @@ namespace Org.BouncyCastle.Cms
 			this.attributes = attributes;
 		}
 
-		public virtual AttributeTable GetAttributes(
-			IDictionary parameters)
+		public virtual AttributeTable GetAttributes(IDictionary<CmsAttributeTableParameter, object> parameters)
 		{
 			return attributes;
 		}