diff options
author | Peter Dettman <peter.dettman@bouncycastle.org> | 2022-06-28 11:01:05 +0700 |
---|---|---|
committer | Peter Dettman <peter.dettman@bouncycastle.org> | 2022-06-28 11:01:05 +0700 |
commit | 18c67ac1339c9ca4f3604f5e5d44da0263b9ad21 (patch) | |
tree | 32fe34fa1251ddb8c5529d9a39a31a68641dd257 /crypto/src/cms/CMSEnvelopedHelper.cs | |
parent | Generics migration in Bcpg, Bzip2, Cmp (diff) | |
download | BouncyCastle.NET-ed25519-18c67ac1339c9ca4f3604f5e5d44da0263b9ad21.tar.xz |
Generics migration in Cms
Diffstat (limited to 'crypto/src/cms/CMSEnvelopedHelper.cs')
-rw-r--r-- | crypto/src/cms/CMSEnvelopedHelper.cs | 36 |
1 files changed, 16 insertions, 20 deletions
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) |