summary refs log tree commit diff
path: root/crypto/src/security/PbeUtilities.cs
diff options
context:
space:
mode:
authorPeter Dettman <peter.dettman@bouncycastle.org>2022-06-29 14:15:10 +0700
committerPeter Dettman <peter.dettman@bouncycastle.org>2022-06-29 14:15:10 +0700
commit435210f10fd927653ce8fbc04ec537ae5d8966b6 (patch)
tree27b6ed1c029db271c3429ac57629d7f0156c5fed /crypto/src/security/PbeUtilities.cs
parentRefactoring around Platform (diff)
downloadBouncyCastle.NET-ed25519-435210f10fd927653ce8fbc04ec537ae5d8966b6.tar.xz
Generics migration complete
Diffstat (limited to 'crypto/src/security/PbeUtilities.cs')
-rw-r--r--crypto/src/security/PbeUtilities.cs421
1 files changed, 210 insertions, 211 deletions
diff --git a/crypto/src/security/PbeUtilities.cs b/crypto/src/security/PbeUtilities.cs
index 622c6dd43..4121ddd7d 100644
--- a/crypto/src/security/PbeUtilities.cs
+++ b/crypto/src/security/PbeUtilities.cs
@@ -1,5 +1,5 @@
 using System;
-using System.Collections;
+using System.Collections.Generic;
 
 using Org.BouncyCastle.Asn1;
 using Org.BouncyCastle.Asn1.BC;
@@ -10,40 +10,36 @@ using Org.BouncyCastle.Asn1.TeleTrust;
 using Org.BouncyCastle.Asn1.X509;
 using Org.BouncyCastle.Crypto;
 using Org.BouncyCastle.Crypto.Digests;
-using Org.BouncyCastle.Crypto.Engines;
 using Org.BouncyCastle.Crypto.Generators;
-using Org.BouncyCastle.Crypto.Macs;
-using Org.BouncyCastle.Crypto.Modes;
-using Org.BouncyCastle.Crypto.Paddings;
 using Org.BouncyCastle.Crypto.Parameters;
 using Org.BouncyCastle.Utilities;
+using Org.BouncyCastle.Utilities.Collections;
 
 namespace Org.BouncyCastle.Security
 {
     /// <summary>
     ///
     /// </summary>
-    public sealed class PbeUtilities
+    public static class PbeUtilities
     {
-        private PbeUtilities()
-        {
-        }
-
         const string Pkcs5S1 = "Pkcs5S1";
         const string Pkcs5S2 = "Pkcs5S2";
         const string Pkcs12 = "Pkcs12";
         const string OpenSsl = "OpenSsl";
 
-        private static readonly IDictionary algorithms = Platform.CreateHashtable();
-        private static readonly IDictionary algorithmType = Platform.CreateHashtable();
-        private static readonly IDictionary oids = Platform.CreateHashtable();
+        private static readonly IDictionary<string, string> Algorithms =
+            new Dictionary<string, string>(StringComparer.OrdinalIgnoreCase);
+        private static readonly IDictionary<string, string> AlgorithmType =
+            new Dictionary<string, string>(StringComparer.OrdinalIgnoreCase);
+        private static readonly IDictionary<string, DerObjectIdentifier> Oids =
+            new Dictionary<string, DerObjectIdentifier>(StringComparer.OrdinalIgnoreCase);
 
         static PbeUtilities()
         {
-            algorithms["PKCS5SCHEME1"] = "Pkcs5scheme1";
-            algorithms["PKCS5SCHEME2"] = "Pkcs5scheme2";
-            algorithms["PBKDF2"] = "Pkcs5scheme2";
-            algorithms[PkcsObjectIdentifiers.IdPbeS2.Id] = "Pkcs5scheme2";
+            Algorithms["PKCS5SCHEME1"] = "Pkcs5scheme1";
+            Algorithms["PKCS5SCHEME2"] = "Pkcs5scheme2";
+            Algorithms["PBKDF2"] = "Pkcs5scheme2";
+            Algorithms[PkcsObjectIdentifiers.IdPbeS2.Id] = "Pkcs5scheme2";
 //			algorithms[PkcsObjectIdentifiers.IdPbkdf2.Id] = "Pkcs5scheme2";
 
             // FIXME Add support for these? (see Pkcs8Generator)
@@ -52,155 +48,155 @@ namespace Org.BouncyCastle.Security
 //			algorithms[NistObjectIdentifiers.IdAes192Cbc.Id] = "Pkcs5scheme2";
 //			algorithms[NistObjectIdentifiers.IdAes256Cbc.Id] = "Pkcs5scheme2";
 
-            algorithms["PBEWITHMD2ANDDES-CBC"] = "PBEwithMD2andDES-CBC";
-            algorithms[PkcsObjectIdentifiers.PbeWithMD2AndDesCbc.Id] = "PBEwithMD2andDES-CBC";
-            algorithms["PBEWITHMD2ANDRC2-CBC"] = "PBEwithMD2andRC2-CBC";
-            algorithms[PkcsObjectIdentifiers.PbeWithMD2AndRC2Cbc.Id] = "PBEwithMD2andRC2-CBC";
-            algorithms["PBEWITHMD5ANDDES-CBC"] = "PBEwithMD5andDES-CBC";
-            algorithms[PkcsObjectIdentifiers.PbeWithMD5AndDesCbc.Id] = "PBEwithMD5andDES-CBC";
-            algorithms["PBEWITHMD5ANDRC2-CBC"] = "PBEwithMD5andRC2-CBC";
-            algorithms[PkcsObjectIdentifiers.PbeWithMD5AndRC2Cbc.Id] = "PBEwithMD5andRC2-CBC";
-            algorithms["PBEWITHSHA1ANDDES"] = "PBEwithSHA-1andDES-CBC";
-            algorithms["PBEWITHSHA-1ANDDES"] = "PBEwithSHA-1andDES-CBC";
-            algorithms["PBEWITHSHA1ANDDES-CBC"] = "PBEwithSHA-1andDES-CBC";
-            algorithms["PBEWITHSHA-1ANDDES-CBC"] = "PBEwithSHA-1andDES-CBC";
-            algorithms[PkcsObjectIdentifiers.PbeWithSha1AndDesCbc.Id] = "PBEwithSHA-1andDES-CBC";
-            algorithms["PBEWITHSHA1ANDRC2"] = "PBEwithSHA-1andRC2-CBC";
-            algorithms["PBEWITHSHA-1ANDRC2"] = "PBEwithSHA-1andRC2-CBC";
-            algorithms["PBEWITHSHA1ANDRC2-CBC"] = "PBEwithSHA-1andRC2-CBC";
-            algorithms["PBEWITHSHA-1ANDRC2-CBC"] = "PBEwithSHA-1andRC2-CBC";
-            algorithms[PkcsObjectIdentifiers.PbeWithSha1AndRC2Cbc.Id] = "PBEwithSHA-1andRC2-CBC";
-            algorithms["PKCS12"] = "Pkcs12";
-            algorithms[BCObjectIdentifiers.bc_pbe_sha1_pkcs12_aes128_cbc.Id] = "PBEwithSHA-1and128bitAES-CBC-BC";
-            algorithms[BCObjectIdentifiers.bc_pbe_sha1_pkcs12_aes192_cbc.Id] = "PBEwithSHA-1and192bitAES-CBC-BC";
-            algorithms[BCObjectIdentifiers.bc_pbe_sha1_pkcs12_aes256_cbc.Id] = "PBEwithSHA-1and256bitAES-CBC-BC";
-            algorithms[BCObjectIdentifiers.bc_pbe_sha256_pkcs12_aes128_cbc.Id] = "PBEwithSHA-256and128bitAES-CBC-BC";
-            algorithms[BCObjectIdentifiers.bc_pbe_sha256_pkcs12_aes192_cbc.Id] = "PBEwithSHA-256and192bitAES-CBC-BC";
-            algorithms[BCObjectIdentifiers.bc_pbe_sha256_pkcs12_aes256_cbc.Id] = "PBEwithSHA-256and256bitAES-CBC-BC";
-            algorithms["PBEWITHSHAAND128BITRC4"] = "PBEwithSHA-1and128bitRC4";
-            algorithms["PBEWITHSHA1AND128BITRC4"] = "PBEwithSHA-1and128bitRC4";
-            algorithms["PBEWITHSHA-1AND128BITRC4"] = "PBEwithSHA-1and128bitRC4";
-            algorithms[PkcsObjectIdentifiers.PbeWithShaAnd128BitRC4.Id] = "PBEwithSHA-1and128bitRC4";
-            algorithms["PBEWITHSHAAND40BITRC4"] = "PBEwithSHA-1and40bitRC4";
-            algorithms["PBEWITHSHA1AND40BITRC4"] = "PBEwithSHA-1and40bitRC4";
-            algorithms["PBEWITHSHA-1AND40BITRC4"] = "PBEwithSHA-1and40bitRC4";
-            algorithms[PkcsObjectIdentifiers.PbeWithShaAnd40BitRC4.Id] = "PBEwithSHA-1and40bitRC4";
-            algorithms["PBEWITHSHAAND3-KEYDESEDE-CBC"] = "PBEwithSHA-1and3-keyDESEDE-CBC";
-            algorithms["PBEWITHSHAAND3-KEYTRIPLEDES-CBC"] = "PBEwithSHA-1and3-keyDESEDE-CBC";
-            algorithms["PBEWITHSHA1AND3-KEYDESEDE-CBC"] = "PBEwithSHA-1and3-keyDESEDE-CBC";
-            algorithms["PBEWITHSHA1AND3-KEYTRIPLEDES-CBC"] = "PBEwithSHA-1and3-keyDESEDE-CBC";
-            algorithms["PBEWITHSHA-1AND3-KEYDESEDE-CBC"] = "PBEwithSHA-1and3-keyDESEDE-CBC";
-            algorithms["PBEWITHSHA-1AND3-KEYTRIPLEDES-CBC"] = "PBEwithSHA-1and3-keyDESEDE-CBC";
-            algorithms[PkcsObjectIdentifiers.PbeWithShaAnd3KeyTripleDesCbc.Id] = "PBEwithSHA-1and3-keyDESEDE-CBC";
-            algorithms["PBEWITHSHAAND2-KEYDESEDE-CBC"] = "PBEwithSHA-1and2-keyDESEDE-CBC";
-            algorithms["PBEWITHSHAAND2-KEYTRIPLEDES-CBC"] = "PBEwithSHA-1and2-keyDESEDE-CBC";
-            algorithms["PBEWITHSHA1AND2-KEYDESEDE-CBC"] = "PBEwithSHA-1and2-keyDESEDE-CBC";
-            algorithms["PBEWITHSHA1AND2-KEYTRIPLEDES-CBC"] = "PBEwithSHA-1and2-keyDESEDE-CBC";
-            algorithms["PBEWITHSHA-1AND2-KEYDESEDE-CBC"] = "PBEwithSHA-1and2-keyDESEDE-CBC";
-            algorithms["PBEWITHSHA-1AND2-KEYTRIPLEDES-CBC"] = "PBEwithSHA-1and2-keyDESEDE-CBC";
-            algorithms[PkcsObjectIdentifiers.PbeWithShaAnd2KeyTripleDesCbc.Id] = "PBEwithSHA-1and2-keyDESEDE-CBC";
-            algorithms["PBEWITHSHAAND128BITRC2-CBC"] = "PBEwithSHA-1and128bitRC2-CBC";
-            algorithms["PBEWITHSHA1AND128BITRC2-CBC"] = "PBEwithSHA-1and128bitRC2-CBC";
-            algorithms["PBEWITHSHA-1AND128BITRC2-CBC"] = "PBEwithSHA-1and128bitRC2-CBC";
-            algorithms[PkcsObjectIdentifiers.PbeWithShaAnd128BitRC2Cbc.Id] = "PBEwithSHA-1and128bitRC2-CBC";
-            algorithms["PBEWITHSHAAND40BITRC2-CBC"] = "PBEwithSHA-1and40bitRC2-CBC";
-            algorithms["PBEWITHSHA1AND40BITRC2-CBC"] = "PBEwithSHA-1and40bitRC2-CBC";
-            algorithms["PBEWITHSHA-1AND40BITRC2-CBC"] = "PBEwithSHA-1and40bitRC2-CBC";
-            algorithms[PkcsObjectIdentifiers.PbewithShaAnd40BitRC2Cbc.Id] = "PBEwithSHA-1and40bitRC2-CBC";
-            algorithms["PBEWITHSHAAND128BITAES-CBC-BC"] = "PBEwithSHA-1and128bitAES-CBC-BC";
-            algorithms["PBEWITHSHA1AND128BITAES-CBC-BC"] = "PBEwithSHA-1and128bitAES-CBC-BC";
-            algorithms["PBEWITHSHA-1AND128BITAES-CBC-BC"] = "PBEwithSHA-1and128bitAES-CBC-BC";
-            algorithms["PBEWITHSHAAND192BITAES-CBC-BC"] = "PBEwithSHA-1and192bitAES-CBC-BC";
-            algorithms["PBEWITHSHA1AND192BITAES-CBC-BC"] = "PBEwithSHA-1and192bitAES-CBC-BC";
-            algorithms["PBEWITHSHA-1AND192BITAES-CBC-BC"] = "PBEwithSHA-1and192bitAES-CBC-BC";
-            algorithms["PBEWITHSHAAND256BITAES-CBC-BC"] = "PBEwithSHA-1and256bitAES-CBC-BC";
-            algorithms["PBEWITHSHA1AND256BITAES-CBC-BC"] = "PBEwithSHA-1and256bitAES-CBC-BC";
-            algorithms["PBEWITHSHA-1AND256BITAES-CBC-BC"] = "PBEwithSHA-1and256bitAES-CBC-BC";
-            algorithms["PBEWITHSHA256AND128BITAES-CBC-BC"] = "PBEwithSHA-256and128bitAES-CBC-BC";
-            algorithms["PBEWITHSHA-256AND128BITAES-CBC-BC"] = "PBEwithSHA-256and128bitAES-CBC-BC";
-            algorithms["PBEWITHSHA256AND192BITAES-CBC-BC"] = "PBEwithSHA-256and192bitAES-CBC-BC";
-            algorithms["PBEWITHSHA-256AND192BITAES-CBC-BC"] = "PBEwithSHA-256and192bitAES-CBC-BC";
-            algorithms["PBEWITHSHA256AND256BITAES-CBC-BC"] = "PBEwithSHA-256and256bitAES-CBC-BC";
-            algorithms["PBEWITHSHA-256AND256BITAES-CBC-BC"] = "PBEwithSHA-256and256bitAES-CBC-BC";
-            algorithms["PBEWITHSHAANDIDEA"] = "PBEwithSHA-1andIDEA-CBC";
-            algorithms["PBEWITHSHAANDIDEA-CBC"] = "PBEwithSHA-1andIDEA-CBC";
-            algorithms["PBEWITHSHAANDTWOFISH"] = "PBEwithSHA-1andTWOFISH-CBC";
-            algorithms["PBEWITHSHAANDTWOFISH-CBC"] = "PBEwithSHA-1andTWOFISH-CBC";
-            algorithms["PBEWITHHMACSHA1"] = "PBEwithHmacSHA-1";
-            algorithms["PBEWITHHMACSHA-1"] = "PBEwithHmacSHA-1";
-            algorithms[OiwObjectIdentifiers.IdSha1.Id] = "PBEwithHmacSHA-1";
-            algorithms["PBEWITHHMACSHA224"] = "PBEwithHmacSHA-224";
-            algorithms["PBEWITHHMACSHA-224"] = "PBEwithHmacSHA-224";
-            algorithms[NistObjectIdentifiers.IdSha224.Id] = "PBEwithHmacSHA-224";
-            algorithms["PBEWITHHMACSHA256"] = "PBEwithHmacSHA-256";
-            algorithms["PBEWITHHMACSHA-256"] = "PBEwithHmacSHA-256";
-            algorithms[NistObjectIdentifiers.IdSha256.Id] = "PBEwithHmacSHA-256";
-            algorithms["PBEWITHHMACRIPEMD128"] = "PBEwithHmacRipeMD128";
-            algorithms[TeleTrusTObjectIdentifiers.RipeMD128.Id] = "PBEwithHmacRipeMD128";
-            algorithms["PBEWITHHMACRIPEMD160"] = "PBEwithHmacRipeMD160";
-            algorithms[TeleTrusTObjectIdentifiers.RipeMD160.Id] = "PBEwithHmacRipeMD160";
-            algorithms["PBEWITHHMACRIPEMD256"] = "PBEwithHmacRipeMD256";
-            algorithms[TeleTrusTObjectIdentifiers.RipeMD256.Id] = "PBEwithHmacRipeMD256";
-            algorithms["PBEWITHHMACTIGER"] = "PBEwithHmacTiger";
-
-            algorithms["PBEWITHMD5AND128BITAES-CBC-OPENSSL"] = "PBEwithMD5and128bitAES-CBC-OpenSSL";
-            algorithms["PBEWITHMD5AND192BITAES-CBC-OPENSSL"] = "PBEwithMD5and192bitAES-CBC-OpenSSL";
-            algorithms["PBEWITHMD5AND256BITAES-CBC-OPENSSL"] = "PBEwithMD5and256bitAES-CBC-OpenSSL";
-
-            algorithmType["Pkcs5scheme1"] = Pkcs5S1;
-            algorithmType["Pkcs5scheme2"] = Pkcs5S2;
-            algorithmType["PBEwithMD2andDES-CBC"] = Pkcs5S1;
-            algorithmType["PBEwithMD2andRC2-CBC"] = Pkcs5S1;
-            algorithmType["PBEwithMD5andDES-CBC"] = Pkcs5S1;
-            algorithmType["PBEwithMD5andRC2-CBC"] = Pkcs5S1;
-            algorithmType["PBEwithSHA-1andDES-CBC"] = Pkcs5S1;
-            algorithmType["PBEwithSHA-1andRC2-CBC"] = Pkcs5S1;
-            algorithmType["Pkcs12"] = Pkcs12;
-            algorithmType["PBEwithSHA-1and128bitRC4"] = Pkcs12;
-            algorithmType["PBEwithSHA-1and40bitRC4"] = Pkcs12;
-            algorithmType["PBEwithSHA-1and3-keyDESEDE-CBC"] = Pkcs12;
-            algorithmType["PBEwithSHA-1and2-keyDESEDE-CBC"] = Pkcs12;
-            algorithmType["PBEwithSHA-1and128bitRC2-CBC"] = Pkcs12;
-            algorithmType["PBEwithSHA-1and40bitRC2-CBC"] = Pkcs12;
-            algorithmType["PBEwithSHA-1and128bitAES-CBC-BC"] = Pkcs12;
-            algorithmType["PBEwithSHA-1and192bitAES-CBC-BC"] = Pkcs12;
-            algorithmType["PBEwithSHA-1and256bitAES-CBC-BC"] = Pkcs12;
-            algorithmType["PBEwithSHA-256and128bitAES-CBC-BC"] = Pkcs12;
-            algorithmType["PBEwithSHA-256and192bitAES-CBC-BC"] = Pkcs12;
-            algorithmType["PBEwithSHA-256and256bitAES-CBC-BC"] = Pkcs12;
-            algorithmType["PBEwithSHA-1andIDEA-CBC"] = Pkcs12;
-            algorithmType["PBEwithSHA-1andTWOFISH-CBC"] = Pkcs12;
-            algorithmType["PBEwithHmacSHA-1"] = Pkcs12;
-            algorithmType["PBEwithHmacSHA-224"] = Pkcs12;
-            algorithmType["PBEwithHmacSHA-256"] = Pkcs12;
-            algorithmType["PBEwithHmacRipeMD128"] = Pkcs12;
-            algorithmType["PBEwithHmacRipeMD160"] = Pkcs12;
-            algorithmType["PBEwithHmacRipeMD256"] = Pkcs12;
-            algorithmType["PBEwithHmacTiger"] = Pkcs12;
-
-            algorithmType["PBEwithMD5and128bitAES-CBC-OpenSSL"] = OpenSsl;
-            algorithmType["PBEwithMD5and192bitAES-CBC-OpenSSL"] = OpenSsl;
-            algorithmType["PBEwithMD5and256bitAES-CBC-OpenSSL"] = OpenSsl;
-
-            oids["PBEwithMD2andDES-CBC"] = PkcsObjectIdentifiers.PbeWithMD2AndDesCbc;
-            oids["PBEwithMD2andRC2-CBC"] = PkcsObjectIdentifiers.PbeWithMD2AndRC2Cbc;
-            oids["PBEwithMD5andDES-CBC"] = PkcsObjectIdentifiers.PbeWithMD5AndDesCbc;
-            oids["PBEwithMD5andRC2-CBC"] = PkcsObjectIdentifiers.PbeWithMD5AndRC2Cbc;
-            oids["PBEwithSHA-1andDES-CBC"] = PkcsObjectIdentifiers.PbeWithSha1AndDesCbc;
-            oids["PBEwithSHA-1andRC2-CBC"] = PkcsObjectIdentifiers.PbeWithSha1AndRC2Cbc;
-            oids["PBEwithSHA-1and128bitRC4"] = PkcsObjectIdentifiers.PbeWithShaAnd128BitRC4;
-            oids["PBEwithSHA-1and40bitRC4"] = PkcsObjectIdentifiers.PbeWithShaAnd40BitRC4;
-            oids["PBEwithSHA-1and3-keyDESEDE-CBC"] = PkcsObjectIdentifiers.PbeWithShaAnd3KeyTripleDesCbc;
-            oids["PBEwithSHA-1and2-keyDESEDE-CBC"] = PkcsObjectIdentifiers.PbeWithShaAnd2KeyTripleDesCbc;
-            oids["PBEwithSHA-1and128bitRC2-CBC"] = PkcsObjectIdentifiers.PbeWithShaAnd128BitRC2Cbc;
-            oids["PBEwithSHA-1and40bitRC2-CBC"] = PkcsObjectIdentifiers.PbewithShaAnd40BitRC2Cbc;
-            oids["PBEwithHmacSHA-1"] = OiwObjectIdentifiers.IdSha1;
-            oids["PBEwithHmacSHA-224"] = NistObjectIdentifiers.IdSha224;
-            oids["PBEwithHmacSHA-256"] = NistObjectIdentifiers.IdSha256;
-            oids["PBEwithHmacRipeMD128"] = TeleTrusTObjectIdentifiers.RipeMD128;
-            oids["PBEwithHmacRipeMD160"] = TeleTrusTObjectIdentifiers.RipeMD160;
-            oids["PBEwithHmacRipeMD256"] = TeleTrusTObjectIdentifiers.RipeMD256;
-            oids["Pkcs5scheme2"] = PkcsObjectIdentifiers.IdPbeS2;
+            Algorithms["PBEWITHMD2ANDDES-CBC"] = "PBEwithMD2andDES-CBC";
+            Algorithms[PkcsObjectIdentifiers.PbeWithMD2AndDesCbc.Id] = "PBEwithMD2andDES-CBC";
+            Algorithms["PBEWITHMD2ANDRC2-CBC"] = "PBEwithMD2andRC2-CBC";
+            Algorithms[PkcsObjectIdentifiers.PbeWithMD2AndRC2Cbc.Id] = "PBEwithMD2andRC2-CBC";
+            Algorithms["PBEWITHMD5ANDDES-CBC"] = "PBEwithMD5andDES-CBC";
+            Algorithms[PkcsObjectIdentifiers.PbeWithMD5AndDesCbc.Id] = "PBEwithMD5andDES-CBC";
+            Algorithms["PBEWITHMD5ANDRC2-CBC"] = "PBEwithMD5andRC2-CBC";
+            Algorithms[PkcsObjectIdentifiers.PbeWithMD5AndRC2Cbc.Id] = "PBEwithMD5andRC2-CBC";
+            Algorithms["PBEWITHSHA1ANDDES"] = "PBEwithSHA-1andDES-CBC";
+            Algorithms["PBEWITHSHA-1ANDDES"] = "PBEwithSHA-1andDES-CBC";
+            Algorithms["PBEWITHSHA1ANDDES-CBC"] = "PBEwithSHA-1andDES-CBC";
+            Algorithms["PBEWITHSHA-1ANDDES-CBC"] = "PBEwithSHA-1andDES-CBC";
+            Algorithms[PkcsObjectIdentifiers.PbeWithSha1AndDesCbc.Id] = "PBEwithSHA-1andDES-CBC";
+            Algorithms["PBEWITHSHA1ANDRC2"] = "PBEwithSHA-1andRC2-CBC";
+            Algorithms["PBEWITHSHA-1ANDRC2"] = "PBEwithSHA-1andRC2-CBC";
+            Algorithms["PBEWITHSHA1ANDRC2-CBC"] = "PBEwithSHA-1andRC2-CBC";
+            Algorithms["PBEWITHSHA-1ANDRC2-CBC"] = "PBEwithSHA-1andRC2-CBC";
+            Algorithms[PkcsObjectIdentifiers.PbeWithSha1AndRC2Cbc.Id] = "PBEwithSHA-1andRC2-CBC";
+            Algorithms["PKCS12"] = "Pkcs12";
+            Algorithms[BCObjectIdentifiers.bc_pbe_sha1_pkcs12_aes128_cbc.Id] = "PBEwithSHA-1and128bitAES-CBC-BC";
+            Algorithms[BCObjectIdentifiers.bc_pbe_sha1_pkcs12_aes192_cbc.Id] = "PBEwithSHA-1and192bitAES-CBC-BC";
+            Algorithms[BCObjectIdentifiers.bc_pbe_sha1_pkcs12_aes256_cbc.Id] = "PBEwithSHA-1and256bitAES-CBC-BC";
+            Algorithms[BCObjectIdentifiers.bc_pbe_sha256_pkcs12_aes128_cbc.Id] = "PBEwithSHA-256and128bitAES-CBC-BC";
+            Algorithms[BCObjectIdentifiers.bc_pbe_sha256_pkcs12_aes192_cbc.Id] = "PBEwithSHA-256and192bitAES-CBC-BC";
+            Algorithms[BCObjectIdentifiers.bc_pbe_sha256_pkcs12_aes256_cbc.Id] = "PBEwithSHA-256and256bitAES-CBC-BC";
+            Algorithms["PBEWITHSHAAND128BITRC4"] = "PBEwithSHA-1and128bitRC4";
+            Algorithms["PBEWITHSHA1AND128BITRC4"] = "PBEwithSHA-1and128bitRC4";
+            Algorithms["PBEWITHSHA-1AND128BITRC4"] = "PBEwithSHA-1and128bitRC4";
+            Algorithms[PkcsObjectIdentifiers.PbeWithShaAnd128BitRC4.Id] = "PBEwithSHA-1and128bitRC4";
+            Algorithms["PBEWITHSHAAND40BITRC4"] = "PBEwithSHA-1and40bitRC4";
+            Algorithms["PBEWITHSHA1AND40BITRC4"] = "PBEwithSHA-1and40bitRC4";
+            Algorithms["PBEWITHSHA-1AND40BITRC4"] = "PBEwithSHA-1and40bitRC4";
+            Algorithms[PkcsObjectIdentifiers.PbeWithShaAnd40BitRC4.Id] = "PBEwithSHA-1and40bitRC4";
+            Algorithms["PBEWITHSHAAND3-KEYDESEDE-CBC"] = "PBEwithSHA-1and3-keyDESEDE-CBC";
+            Algorithms["PBEWITHSHAAND3-KEYTRIPLEDES-CBC"] = "PBEwithSHA-1and3-keyDESEDE-CBC";
+            Algorithms["PBEWITHSHA1AND3-KEYDESEDE-CBC"] = "PBEwithSHA-1and3-keyDESEDE-CBC";
+            Algorithms["PBEWITHSHA1AND3-KEYTRIPLEDES-CBC"] = "PBEwithSHA-1and3-keyDESEDE-CBC";
+            Algorithms["PBEWITHSHA-1AND3-KEYDESEDE-CBC"] = "PBEwithSHA-1and3-keyDESEDE-CBC";
+            Algorithms["PBEWITHSHA-1AND3-KEYTRIPLEDES-CBC"] = "PBEwithSHA-1and3-keyDESEDE-CBC";
+            Algorithms[PkcsObjectIdentifiers.PbeWithShaAnd3KeyTripleDesCbc.Id] = "PBEwithSHA-1and3-keyDESEDE-CBC";
+            Algorithms["PBEWITHSHAAND2-KEYDESEDE-CBC"] = "PBEwithSHA-1and2-keyDESEDE-CBC";
+            Algorithms["PBEWITHSHAAND2-KEYTRIPLEDES-CBC"] = "PBEwithSHA-1and2-keyDESEDE-CBC";
+            Algorithms["PBEWITHSHA1AND2-KEYDESEDE-CBC"] = "PBEwithSHA-1and2-keyDESEDE-CBC";
+            Algorithms["PBEWITHSHA1AND2-KEYTRIPLEDES-CBC"] = "PBEwithSHA-1and2-keyDESEDE-CBC";
+            Algorithms["PBEWITHSHA-1AND2-KEYDESEDE-CBC"] = "PBEwithSHA-1and2-keyDESEDE-CBC";
+            Algorithms["PBEWITHSHA-1AND2-KEYTRIPLEDES-CBC"] = "PBEwithSHA-1and2-keyDESEDE-CBC";
+            Algorithms[PkcsObjectIdentifiers.PbeWithShaAnd2KeyTripleDesCbc.Id] = "PBEwithSHA-1and2-keyDESEDE-CBC";
+            Algorithms["PBEWITHSHAAND128BITRC2-CBC"] = "PBEwithSHA-1and128bitRC2-CBC";
+            Algorithms["PBEWITHSHA1AND128BITRC2-CBC"] = "PBEwithSHA-1and128bitRC2-CBC";
+            Algorithms["PBEWITHSHA-1AND128BITRC2-CBC"] = "PBEwithSHA-1and128bitRC2-CBC";
+            Algorithms[PkcsObjectIdentifiers.PbeWithShaAnd128BitRC2Cbc.Id] = "PBEwithSHA-1and128bitRC2-CBC";
+            Algorithms["PBEWITHSHAAND40BITRC2-CBC"] = "PBEwithSHA-1and40bitRC2-CBC";
+            Algorithms["PBEWITHSHA1AND40BITRC2-CBC"] = "PBEwithSHA-1and40bitRC2-CBC";
+            Algorithms["PBEWITHSHA-1AND40BITRC2-CBC"] = "PBEwithSHA-1and40bitRC2-CBC";
+            Algorithms[PkcsObjectIdentifiers.PbewithShaAnd40BitRC2Cbc.Id] = "PBEwithSHA-1and40bitRC2-CBC";
+            Algorithms["PBEWITHSHAAND128BITAES-CBC-BC"] = "PBEwithSHA-1and128bitAES-CBC-BC";
+            Algorithms["PBEWITHSHA1AND128BITAES-CBC-BC"] = "PBEwithSHA-1and128bitAES-CBC-BC";
+            Algorithms["PBEWITHSHA-1AND128BITAES-CBC-BC"] = "PBEwithSHA-1and128bitAES-CBC-BC";
+            Algorithms["PBEWITHSHAAND192BITAES-CBC-BC"] = "PBEwithSHA-1and192bitAES-CBC-BC";
+            Algorithms["PBEWITHSHA1AND192BITAES-CBC-BC"] = "PBEwithSHA-1and192bitAES-CBC-BC";
+            Algorithms["PBEWITHSHA-1AND192BITAES-CBC-BC"] = "PBEwithSHA-1and192bitAES-CBC-BC";
+            Algorithms["PBEWITHSHAAND256BITAES-CBC-BC"] = "PBEwithSHA-1and256bitAES-CBC-BC";
+            Algorithms["PBEWITHSHA1AND256BITAES-CBC-BC"] = "PBEwithSHA-1and256bitAES-CBC-BC";
+            Algorithms["PBEWITHSHA-1AND256BITAES-CBC-BC"] = "PBEwithSHA-1and256bitAES-CBC-BC";
+            Algorithms["PBEWITHSHA256AND128BITAES-CBC-BC"] = "PBEwithSHA-256and128bitAES-CBC-BC";
+            Algorithms["PBEWITHSHA-256AND128BITAES-CBC-BC"] = "PBEwithSHA-256and128bitAES-CBC-BC";
+            Algorithms["PBEWITHSHA256AND192BITAES-CBC-BC"] = "PBEwithSHA-256and192bitAES-CBC-BC";
+            Algorithms["PBEWITHSHA-256AND192BITAES-CBC-BC"] = "PBEwithSHA-256and192bitAES-CBC-BC";
+            Algorithms["PBEWITHSHA256AND256BITAES-CBC-BC"] = "PBEwithSHA-256and256bitAES-CBC-BC";
+            Algorithms["PBEWITHSHA-256AND256BITAES-CBC-BC"] = "PBEwithSHA-256and256bitAES-CBC-BC";
+            Algorithms["PBEWITHSHAANDIDEA"] = "PBEwithSHA-1andIDEA-CBC";
+            Algorithms["PBEWITHSHAANDIDEA-CBC"] = "PBEwithSHA-1andIDEA-CBC";
+            Algorithms["PBEWITHSHAANDTWOFISH"] = "PBEwithSHA-1andTWOFISH-CBC";
+            Algorithms["PBEWITHSHAANDTWOFISH-CBC"] = "PBEwithSHA-1andTWOFISH-CBC";
+            Algorithms["PBEWITHHMACSHA1"] = "PBEwithHmacSHA-1";
+            Algorithms["PBEWITHHMACSHA-1"] = "PBEwithHmacSHA-1";
+            Algorithms[OiwObjectIdentifiers.IdSha1.Id] = "PBEwithHmacSHA-1";
+            Algorithms["PBEWITHHMACSHA224"] = "PBEwithHmacSHA-224";
+            Algorithms["PBEWITHHMACSHA-224"] = "PBEwithHmacSHA-224";
+            Algorithms[NistObjectIdentifiers.IdSha224.Id] = "PBEwithHmacSHA-224";
+            Algorithms["PBEWITHHMACSHA256"] = "PBEwithHmacSHA-256";
+            Algorithms["PBEWITHHMACSHA-256"] = "PBEwithHmacSHA-256";
+            Algorithms[NistObjectIdentifiers.IdSha256.Id] = "PBEwithHmacSHA-256";
+            Algorithms["PBEWITHHMACRIPEMD128"] = "PBEwithHmacRipeMD128";
+            Algorithms[TeleTrusTObjectIdentifiers.RipeMD128.Id] = "PBEwithHmacRipeMD128";
+            Algorithms["PBEWITHHMACRIPEMD160"] = "PBEwithHmacRipeMD160";
+            Algorithms[TeleTrusTObjectIdentifiers.RipeMD160.Id] = "PBEwithHmacRipeMD160";
+            Algorithms["PBEWITHHMACRIPEMD256"] = "PBEwithHmacRipeMD256";
+            Algorithms[TeleTrusTObjectIdentifiers.RipeMD256.Id] = "PBEwithHmacRipeMD256";
+            Algorithms["PBEWITHHMACTIGER"] = "PBEwithHmacTiger";
+
+            Algorithms["PBEWITHMD5AND128BITAES-CBC-OPENSSL"] = "PBEwithMD5and128bitAES-CBC-OpenSSL";
+            Algorithms["PBEWITHMD5AND192BITAES-CBC-OPENSSL"] = "PBEwithMD5and192bitAES-CBC-OpenSSL";
+            Algorithms["PBEWITHMD5AND256BITAES-CBC-OPENSSL"] = "PBEwithMD5and256bitAES-CBC-OpenSSL";
+
+            AlgorithmType["Pkcs5scheme1"] = Pkcs5S1;
+            AlgorithmType["Pkcs5scheme2"] = Pkcs5S2;
+            AlgorithmType["PBEwithMD2andDES-CBC"] = Pkcs5S1;
+            AlgorithmType["PBEwithMD2andRC2-CBC"] = Pkcs5S1;
+            AlgorithmType["PBEwithMD5andDES-CBC"] = Pkcs5S1;
+            AlgorithmType["PBEwithMD5andRC2-CBC"] = Pkcs5S1;
+            AlgorithmType["PBEwithSHA-1andDES-CBC"] = Pkcs5S1;
+            AlgorithmType["PBEwithSHA-1andRC2-CBC"] = Pkcs5S1;
+            AlgorithmType["Pkcs12"] = Pkcs12;
+            AlgorithmType["PBEwithSHA-1and128bitRC4"] = Pkcs12;
+            AlgorithmType["PBEwithSHA-1and40bitRC4"] = Pkcs12;
+            AlgorithmType["PBEwithSHA-1and3-keyDESEDE-CBC"] = Pkcs12;
+            AlgorithmType["PBEwithSHA-1and2-keyDESEDE-CBC"] = Pkcs12;
+            AlgorithmType["PBEwithSHA-1and128bitRC2-CBC"] = Pkcs12;
+            AlgorithmType["PBEwithSHA-1and40bitRC2-CBC"] = Pkcs12;
+            AlgorithmType["PBEwithSHA-1and128bitAES-CBC-BC"] = Pkcs12;
+            AlgorithmType["PBEwithSHA-1and192bitAES-CBC-BC"] = Pkcs12;
+            AlgorithmType["PBEwithSHA-1and256bitAES-CBC-BC"] = Pkcs12;
+            AlgorithmType["PBEwithSHA-256and128bitAES-CBC-BC"] = Pkcs12;
+            AlgorithmType["PBEwithSHA-256and192bitAES-CBC-BC"] = Pkcs12;
+            AlgorithmType["PBEwithSHA-256and256bitAES-CBC-BC"] = Pkcs12;
+            AlgorithmType["PBEwithSHA-1andIDEA-CBC"] = Pkcs12;
+            AlgorithmType["PBEwithSHA-1andTWOFISH-CBC"] = Pkcs12;
+            AlgorithmType["PBEwithHmacSHA-1"] = Pkcs12;
+            AlgorithmType["PBEwithHmacSHA-224"] = Pkcs12;
+            AlgorithmType["PBEwithHmacSHA-256"] = Pkcs12;
+            AlgorithmType["PBEwithHmacRipeMD128"] = Pkcs12;
+            AlgorithmType["PBEwithHmacRipeMD160"] = Pkcs12;
+            AlgorithmType["PBEwithHmacRipeMD256"] = Pkcs12;
+            AlgorithmType["PBEwithHmacTiger"] = Pkcs12;
+
+            AlgorithmType["PBEwithMD5and128bitAES-CBC-OpenSSL"] = OpenSsl;
+            AlgorithmType["PBEwithMD5and192bitAES-CBC-OpenSSL"] = OpenSsl;
+            AlgorithmType["PBEwithMD5and256bitAES-CBC-OpenSSL"] = OpenSsl;
+
+            Oids["PBEwithMD2andDES-CBC"] = PkcsObjectIdentifiers.PbeWithMD2AndDesCbc;
+            Oids["PBEwithMD2andRC2-CBC"] = PkcsObjectIdentifiers.PbeWithMD2AndRC2Cbc;
+            Oids["PBEwithMD5andDES-CBC"] = PkcsObjectIdentifiers.PbeWithMD5AndDesCbc;
+            Oids["PBEwithMD5andRC2-CBC"] = PkcsObjectIdentifiers.PbeWithMD5AndRC2Cbc;
+            Oids["PBEwithSHA-1andDES-CBC"] = PkcsObjectIdentifiers.PbeWithSha1AndDesCbc;
+            Oids["PBEwithSHA-1andRC2-CBC"] = PkcsObjectIdentifiers.PbeWithSha1AndRC2Cbc;
+            Oids["PBEwithSHA-1and128bitRC4"] = PkcsObjectIdentifiers.PbeWithShaAnd128BitRC4;
+            Oids["PBEwithSHA-1and40bitRC4"] = PkcsObjectIdentifiers.PbeWithShaAnd40BitRC4;
+            Oids["PBEwithSHA-1and3-keyDESEDE-CBC"] = PkcsObjectIdentifiers.PbeWithShaAnd3KeyTripleDesCbc;
+            Oids["PBEwithSHA-1and2-keyDESEDE-CBC"] = PkcsObjectIdentifiers.PbeWithShaAnd2KeyTripleDesCbc;
+            Oids["PBEwithSHA-1and128bitRC2-CBC"] = PkcsObjectIdentifiers.PbeWithShaAnd128BitRC2Cbc;
+            Oids["PBEwithSHA-1and40bitRC2-CBC"] = PkcsObjectIdentifiers.PbewithShaAnd40BitRC2Cbc;
+            Oids["PBEwithHmacSHA-1"] = OiwObjectIdentifiers.IdSha1;
+            Oids["PBEwithHmacSHA-224"] = NistObjectIdentifiers.IdSha224;
+            Oids["PBEwithHmacSHA-256"] = NistObjectIdentifiers.IdSha256;
+            Oids["PBEwithHmacRipeMD128"] = TeleTrusTObjectIdentifiers.RipeMD128;
+            Oids["PBEwithHmacRipeMD160"] = TeleTrusTObjectIdentifiers.RipeMD160;
+            Oids["PBEwithHmacRipeMD256"] = TeleTrusTObjectIdentifiers.RipeMD256;
+            Oids["Pkcs5scheme2"] = PkcsObjectIdentifiers.IdPbeS2;
         }
 
         static PbeParametersGenerator MakePbeGenerator(
@@ -242,60 +238,65 @@ namespace Org.BouncyCastle.Security
         /// </summary>
         /// <param name="mechanism">A string representation of the encoding.</param>
         /// <returns>A DerObjectIdentifier, null if the Oid is not available.</returns>
-        public static DerObjectIdentifier GetObjectIdentifier(
-            string mechanism)
+        public static DerObjectIdentifier GetObjectIdentifier(string mechanism)
         {
-            mechanism = (string) algorithms[Platform.ToUpperInvariant(mechanism)];
-            if (mechanism != null)
-            {
-                return (DerObjectIdentifier)oids[mechanism];
-            }
-            return null;
-        }
+            if (!Algorithms.TryGetValue(mechanism, out var algorithm))
+                return null;
 
-        public static ICollection Algorithms
-        {
-            get { return oids.Keys; }
+            return CollectionUtilities.GetValueOrNull(Oids, algorithm);
         }
 
-        public static bool IsPkcs12(
-            string algorithm)
+        //public static ICollection Algorithms
+        //{
+        //    get { return oids.Keys; }
+        //}
+
+        public static bool IsPkcs12(string algorithm)
         {
-            string mechanism = (string)algorithms[Platform.ToUpperInvariant(algorithm)];
+            if (!Algorithms.TryGetValue(algorithm, out var mechanism))
+                return false;
+            if (!AlgorithmType.TryGetValue(mechanism, out var algorithmType))
+                return false;
 
-            return mechanism != null && Pkcs12.Equals(algorithmType[mechanism]);
+            return Pkcs12.Equals(algorithmType);
         }
 
-        public static bool IsPkcs5Scheme1(
-            string algorithm)
+        public static bool IsPkcs5Scheme1(string algorithm)
         {
-            string mechanism = (string)algorithms[Platform.ToUpperInvariant(algorithm)];
+            if (!Algorithms.TryGetValue(algorithm, out var mechanism))
+                return false;
+            if (!AlgorithmType.TryGetValue(mechanism, out var algorithmType))
+                return false;
 
-            return mechanism != null && Pkcs5S1.Equals(algorithmType[mechanism]);
+            return Pkcs5S1.Equals(algorithmType);
         }
 
-        public static bool IsPkcs5Scheme2(
-            string algorithm)
+        public static bool IsPkcs5Scheme2(string algorithm)
         {
-            string mechanism = (string)algorithms[Platform.ToUpperInvariant(algorithm)];
+            if (!Algorithms.TryGetValue(algorithm, out var mechanism))
+                return false;
+            if (!AlgorithmType.TryGetValue(mechanism, out var algorithmType))
+                return false;
 
-            return mechanism != null && Pkcs5S2.Equals(algorithmType[mechanism]);
+            return Pkcs5S2.Equals(algorithmType);
         }
 
-        public static bool IsOpenSsl(
-            string algorithm)
+        public static bool IsOpenSsl(string algorithm)
         {
-            string mechanism = (string)algorithms[Platform.ToUpperInvariant(algorithm)];
+            if (!Algorithms.TryGetValue(algorithm, out var mechanism))
+                return false;
+            if (!AlgorithmType.TryGetValue(mechanism, out var algorithmType))
+                return false;
 
-            return mechanism != null && OpenSsl.Equals(algorithmType[mechanism]);
+            return OpenSsl.Equals(algorithmType);
         }
 
-        public static bool IsPbeAlgorithm(
-            string algorithm)
+        public static bool IsPbeAlgorithm(string algorithm)
         {
-            string mechanism = (string)algorithms[Platform.ToUpperInvariant(algorithm)];
+            if (!Algorithms.TryGetValue(algorithm, out var mechanism))
+                return false;
 
-            return mechanism != null && algorithmType[mechanism] != null;
+            return AlgorithmType.ContainsKey(mechanism);
         }
 
         public static Asn1Encodable GenerateAlgorithmParameters(
@@ -400,7 +401,7 @@ namespace Org.BouncyCastle.Security
             bool			wrongPkcs12Zero,
             Asn1Encodable   pbeParameters)
         {
-            string mechanism = (string)algorithms[Platform.ToUpperInvariant(algorithm)];
+            string mechanism = CollectionUtilities.GetValueOrNull(Algorithms, algorithm);
 
             byte[] keyBytes = null;
             byte[] salt = null;
@@ -457,7 +458,7 @@ namespace Org.BouncyCastle.Security
                     :	GeneratorUtilities.GetDefaultKeySize(encOid);
 
                 PbeParametersGenerator gen = MakePbeGenerator(
-                    (string)algorithmType[mechanism], digest, keyBytes, salt, iterationCount);
+                    AlgorithmType[mechanism], digest, keyBytes, salt, iterationCount);
 
                 parameters = gen.GenerateDerivedParameters(encOid.Id, keyLength);
 
@@ -477,7 +478,7 @@ namespace Org.BouncyCastle.Security
             else if (Platform.StartsWith(mechanism, "PBEwithSHA-1"))
             {
                 PbeParametersGenerator generator = MakePbeGenerator(
-                    (string) algorithmType[mechanism], new Sha1Digest(), keyBytes, salt, iterationCount);
+                    AlgorithmType[mechanism], new Sha1Digest(), keyBytes, salt, iterationCount);
 
                 if (mechanism.Equals("PBEwithSHA-1and128bitAES-CBC-BC"))
                 {
@@ -527,7 +528,7 @@ namespace Org.BouncyCastle.Security
             else if (Platform.StartsWith(mechanism, "PBEwithSHA-256"))
             {
                 PbeParametersGenerator generator = MakePbeGenerator(
-                    (string) algorithmType[mechanism], new Sha256Digest(), keyBytes, salt, iterationCount);
+                    AlgorithmType[mechanism], new Sha256Digest(), keyBytes, salt, iterationCount);
 
                 if (mechanism.Equals("PBEwithSHA-256and128bitAES-CBC-BC"))
                 {
@@ -545,7 +546,7 @@ namespace Org.BouncyCastle.Security
             else if (Platform.StartsWith(mechanism, "PBEwithMD5"))
             {
                 PbeParametersGenerator generator = MakePbeGenerator(
-                    (string)algorithmType[mechanism], new MD5Digest(), keyBytes, salt, iterationCount);
+                    AlgorithmType[mechanism], new MD5Digest(), keyBytes, salt, iterationCount);
 
                 if (mechanism.Equals("PBEwithMD5andDES-CBC"))
                 {
@@ -571,7 +572,7 @@ namespace Org.BouncyCastle.Security
             else if (Platform.StartsWith(mechanism, "PBEwithMD2"))
             {
                 PbeParametersGenerator generator = MakePbeGenerator(
-                    (string)algorithmType[mechanism], new MD2Digest(), keyBytes, salt, iterationCount);
+                    AlgorithmType[mechanism], new MD2Digest(), keyBytes, salt, iterationCount);
                 if (mechanism.Equals("PBEwithMD2andDES-CBC"))
                 {
                     parameters = generator.GenerateDerivedParameters("DES", 64, 64);
@@ -587,7 +588,7 @@ namespace Org.BouncyCastle.Security
                 IDigest digest = DigestUtilities.GetDigest(digestName);
 
                 PbeParametersGenerator generator = MakePbeGenerator(
-                    (string) algorithmType[mechanism], digest, keyBytes, salt, iterationCount);
+                    AlgorithmType[mechanism], digest, keyBytes, salt, iterationCount);
 
                 int bitLen = digest.GetDigestSize() * 8;
                 parameters = generator.GenerateDerivedMacParameters(bitLen);
@@ -619,10 +620,9 @@ namespace Org.BouncyCastle.Security
             return CreateEngine(algorithm);
         }
 
-        public static object CreateEngine(
-            string algorithm)
+        public static object CreateEngine(string algorithm)
         {
-            string mechanism = (string)algorithms[Platform.ToUpperInvariant(algorithm)];
+            string mechanism = CollectionUtilities.GetValueOrNull(Algorithms, algorithm);
 
             if (Platform.StartsWith(mechanism, "PBEwithHmac"))
             {
@@ -665,10 +665,9 @@ namespace Org.BouncyCastle.Security
             return null;
         }
 
-        public static string GetEncodingName(
-            DerObjectIdentifier oid)
+        public static string GetEncodingName(DerObjectIdentifier oid)
         {
-            return (string) algorithms[oid.Id];
+            return CollectionUtilities.GetValueOrNull(Algorithms, oid.Id);
         }
 
         private static ICipherParameters FixDesParity(string mechanism, ICipherParameters parameters)