diff options
Diffstat (limited to 'crypto/src/ocsp')
-rw-r--r-- | crypto/src/ocsp/BasicOCSPRespGenerator.cs | 8 | ||||
-rw-r--r-- | crypto/src/ocsp/OCSPReq.cs | 1 | ||||
-rw-r--r-- | crypto/src/ocsp/OCSPReqGenerator.cs | 6 | ||||
-rw-r--r-- | crypto/src/ocsp/OCSPUtil.cs | 212 | ||||
-rw-r--r-- | crypto/src/ocsp/Req.cs | 3 | ||||
-rw-r--r-- | crypto/src/ocsp/RespData.cs | 1 | ||||
-rw-r--r-- | crypto/src/ocsp/SingleResp.cs | 2 |
7 files changed, 107 insertions, 126 deletions
diff --git a/crypto/src/ocsp/BasicOCSPRespGenerator.cs b/crypto/src/ocsp/BasicOCSPRespGenerator.cs index 0dd4e0a09..147bd7839 100644 --- a/crypto/src/ocsp/BasicOCSPRespGenerator.cs +++ b/crypto/src/ocsp/BasicOCSPRespGenerator.cs @@ -1,16 +1,16 @@ using System; -using System.Collections; +using System.Collections.Generic; using System.IO; using Org.BouncyCastle.Asn1; using Org.BouncyCastle.Asn1.Ocsp; using Org.BouncyCastle.Asn1.X509; using Org.BouncyCastle.Crypto; +using Org.BouncyCastle.Crypto.Operators; using Org.BouncyCastle.Security; using Org.BouncyCastle.Security.Certificates; using Org.BouncyCastle.Utilities; using Org.BouncyCastle.X509; -using Org.BouncyCastle.Crypto.Operators; namespace Org.BouncyCastle.Ocsp { @@ -19,7 +19,7 @@ namespace Org.BouncyCastle.Ocsp */ public class BasicOcspRespGenerator { - private readonly IList list = Platform.CreateArrayList(); + private readonly List<ResponseObject> list = new List<ResponseObject>(); private X509Extensions responseExtensions; private RespID responderID; @@ -305,7 +305,7 @@ namespace Org.BouncyCastle.Ocsp * * @return an IEnumerable containing recognised names. */ - public IEnumerable SignatureAlgNames + public IEnumerable<string> SignatureAlgNames { get { return OcspUtilities.AlgNames; } } diff --git a/crypto/src/ocsp/OCSPReq.cs b/crypto/src/ocsp/OCSPReq.cs index b1718c0c0..cb2748780 100644 --- a/crypto/src/ocsp/OCSPReq.cs +++ b/crypto/src/ocsp/OCSPReq.cs @@ -1,5 +1,4 @@ using System; -using System.Collections; using System.Collections.Generic; using System.IO; diff --git a/crypto/src/ocsp/OCSPReqGenerator.cs b/crypto/src/ocsp/OCSPReqGenerator.cs index 8032a4598..52890ae30 100644 --- a/crypto/src/ocsp/OCSPReqGenerator.cs +++ b/crypto/src/ocsp/OCSPReqGenerator.cs @@ -1,5 +1,5 @@ using System; -using System.Collections; +using System.Collections.Generic; using System.IO; using Org.BouncyCastle.Asn1; @@ -16,7 +16,7 @@ namespace Org.BouncyCastle.Ocsp { public class OcspReqGenerator { - private IList list = Platform.CreateArrayList(); + private List<RequestObject> list = new List<RequestObject>(); private GeneralName requestorName = null; private X509Extensions requestExtensions = null; @@ -235,7 +235,7 @@ namespace Org.BouncyCastle.Ocsp * * @return an IEnumerable containing recognised names. */ - public IEnumerable SignatureAlgNames + public IEnumerable<string> SignatureAlgNames { get { return OcspUtilities.AlgNames; } } diff --git a/crypto/src/ocsp/OCSPUtil.cs b/crypto/src/ocsp/OCSPUtil.cs index e990d1755..f991d2540 100644 --- a/crypto/src/ocsp/OCSPUtil.cs +++ b/crypto/src/ocsp/OCSPUtil.cs @@ -1,5 +1,4 @@ using System; -using System.Collections; using System.Collections.Generic; using Org.BouncyCastle.Asn1; @@ -10,149 +9,138 @@ using Org.BouncyCastle.Asn1.Pkcs; using Org.BouncyCastle.Asn1.TeleTrust; using Org.BouncyCastle.Asn1.X509; using Org.BouncyCastle.Asn1.X9; -using Org.BouncyCastle.Utilities; using Org.BouncyCastle.Utilities.Collections; namespace Org.BouncyCastle.Ocsp { - class OcspUtilities + internal class OcspUtilities { - private static readonly IDictionary algorithms = Platform.CreateHashtable(); - private static readonly IDictionary oids = Platform.CreateHashtable(); - private static readonly HashSet<DerObjectIdentifier> noParams = new HashSet<DerObjectIdentifier>(); + private static readonly Dictionary<string, DerObjectIdentifier> Algorithms = + new Dictionary<string, DerObjectIdentifier>(StringComparer.OrdinalIgnoreCase); + private static readonly Dictionary<DerObjectIdentifier, string> Oids = + new Dictionary<DerObjectIdentifier, string>(); + private static readonly HashSet<DerObjectIdentifier> NoParams = new HashSet<DerObjectIdentifier>(); static OcspUtilities() { - algorithms.Add("MD2WITHRSAENCRYPTION", PkcsObjectIdentifiers.MD2WithRsaEncryption); - algorithms.Add("MD2WITHRSA", PkcsObjectIdentifiers.MD2WithRsaEncryption); - algorithms.Add("MD5WITHRSAENCRYPTION", PkcsObjectIdentifiers.MD5WithRsaEncryption); - algorithms.Add("MD5WITHRSA", PkcsObjectIdentifiers.MD5WithRsaEncryption); - algorithms.Add("SHA1WITHRSAENCRYPTION", PkcsObjectIdentifiers.Sha1WithRsaEncryption); - algorithms.Add("SHA-1WITHRSAENCRYPTION", PkcsObjectIdentifiers.Sha1WithRsaEncryption); - algorithms.Add("SHA1WITHRSA", PkcsObjectIdentifiers.Sha1WithRsaEncryption); - algorithms.Add("SHA-1WITHRSA", PkcsObjectIdentifiers.Sha1WithRsaEncryption); - algorithms.Add("SHA224WITHRSAENCRYPTION", PkcsObjectIdentifiers.Sha224WithRsaEncryption); - algorithms.Add("SHA-224WITHRSAENCRYPTION", PkcsObjectIdentifiers.Sha224WithRsaEncryption); - algorithms.Add("SHA224WITHRSA", PkcsObjectIdentifiers.Sha224WithRsaEncryption); - algorithms.Add("SHA-224WITHRSA", PkcsObjectIdentifiers.Sha224WithRsaEncryption); - algorithms.Add("SHA256WITHRSAENCRYPTION", PkcsObjectIdentifiers.Sha256WithRsaEncryption); - algorithms.Add("SHA-256WITHRSAENCRYPTION", PkcsObjectIdentifiers.Sha256WithRsaEncryption); - algorithms.Add("SHA256WITHRSA", PkcsObjectIdentifiers.Sha256WithRsaEncryption); - algorithms.Add("SHA-256WITHRSA", PkcsObjectIdentifiers.Sha256WithRsaEncryption); - algorithms.Add("SHA384WITHRSAENCRYPTION", PkcsObjectIdentifiers.Sha384WithRsaEncryption); - algorithms.Add("SHA-384WITHRSAENCRYPTION", PkcsObjectIdentifiers.Sha384WithRsaEncryption); - algorithms.Add("SHA384WITHRSA", PkcsObjectIdentifiers.Sha384WithRsaEncryption); - algorithms.Add("SHA-384WITHRSA", PkcsObjectIdentifiers.Sha384WithRsaEncryption); - algorithms.Add("SHA512WITHRSAENCRYPTION", PkcsObjectIdentifiers.Sha512WithRsaEncryption); - algorithms.Add("SHA-512WITHRSAENCRYPTION", PkcsObjectIdentifiers.Sha512WithRsaEncryption); - algorithms.Add("SHA512WITHRSA", PkcsObjectIdentifiers.Sha512WithRsaEncryption); - algorithms.Add("SHA-512WITHRSA", PkcsObjectIdentifiers.Sha512WithRsaEncryption); - algorithms.Add("SHA512(224)WITHRSAENCRYPTION", PkcsObjectIdentifiers.Sha512_224WithRSAEncryption); - algorithms.Add("SHA-512(224)WITHRSAENCRYPTION", PkcsObjectIdentifiers.Sha512_224WithRSAEncryption); - algorithms.Add("SHA512(224)WITHRSA", PkcsObjectIdentifiers.Sha512_224WithRSAEncryption); - algorithms.Add("SHA-512(224)WITHRSA", PkcsObjectIdentifiers.Sha512_224WithRSAEncryption); - algorithms.Add("SHA512(256)WITHRSAENCRYPTION", PkcsObjectIdentifiers.Sha512_256WithRSAEncryption); - algorithms.Add("SHA-512(256)WITHRSAENCRYPTION", PkcsObjectIdentifiers.Sha512_256WithRSAEncryption); - algorithms.Add("SHA512(256)WITHRSA", PkcsObjectIdentifiers.Sha512_256WithRSAEncryption); - algorithms.Add("SHA-512(256)WITHRSA", PkcsObjectIdentifiers.Sha512_256WithRSAEncryption); - algorithms.Add("RIPEMD160WITHRSAENCRYPTION", TeleTrusTObjectIdentifiers.RsaSignatureWithRipeMD160); - algorithms.Add("RIPEMD160WITHRSA", TeleTrusTObjectIdentifiers.RsaSignatureWithRipeMD160); - algorithms.Add("RIPEMD128WITHRSAENCRYPTION", TeleTrusTObjectIdentifiers.RsaSignatureWithRipeMD128); - algorithms.Add("RIPEMD128WITHRSA", TeleTrusTObjectIdentifiers.RsaSignatureWithRipeMD128); - algorithms.Add("RIPEMD256WITHRSAENCRYPTION", TeleTrusTObjectIdentifiers.RsaSignatureWithRipeMD256); - algorithms.Add("RIPEMD256WITHRSA", TeleTrusTObjectIdentifiers.RsaSignatureWithRipeMD256); - algorithms.Add("SHA1WITHDSA", X9ObjectIdentifiers.IdDsaWithSha1); - algorithms.Add("DSAWITHSHA1", X9ObjectIdentifiers.IdDsaWithSha1); - algorithms.Add("SHA224WITHDSA", NistObjectIdentifiers.DsaWithSha224); - algorithms.Add("SHA256WITHDSA", NistObjectIdentifiers.DsaWithSha256); - algorithms.Add("SHA1WITHECDSA", X9ObjectIdentifiers.ECDsaWithSha1); - algorithms.Add("ECDSAWITHSHA1", X9ObjectIdentifiers.ECDsaWithSha1); - algorithms.Add("SHA224WITHECDSA", X9ObjectIdentifiers.ECDsaWithSha224); - algorithms.Add("SHA256WITHECDSA", X9ObjectIdentifiers.ECDsaWithSha256); - algorithms.Add("SHA384WITHECDSA", X9ObjectIdentifiers.ECDsaWithSha384); - algorithms.Add("SHA512WITHECDSA", X9ObjectIdentifiers.ECDsaWithSha512); - algorithms.Add("GOST3411WITHGOST3410", CryptoProObjectIdentifiers.GostR3411x94WithGostR3410x94); - algorithms.Add("GOST3411WITHGOST3410-94", CryptoProObjectIdentifiers.GostR3411x94WithGostR3410x94); + Algorithms.Add("MD2WITHRSAENCRYPTION", PkcsObjectIdentifiers.MD2WithRsaEncryption); + Algorithms.Add("MD2WITHRSA", PkcsObjectIdentifiers.MD2WithRsaEncryption); + Algorithms.Add("MD5WITHRSAENCRYPTION", PkcsObjectIdentifiers.MD5WithRsaEncryption); + Algorithms.Add("MD5WITHRSA", PkcsObjectIdentifiers.MD5WithRsaEncryption); + Algorithms.Add("SHA1WITHRSAENCRYPTION", PkcsObjectIdentifiers.Sha1WithRsaEncryption); + Algorithms.Add("SHA-1WITHRSAENCRYPTION", PkcsObjectIdentifiers.Sha1WithRsaEncryption); + Algorithms.Add("SHA1WITHRSA", PkcsObjectIdentifiers.Sha1WithRsaEncryption); + Algorithms.Add("SHA-1WITHRSA", PkcsObjectIdentifiers.Sha1WithRsaEncryption); + Algorithms.Add("SHA224WITHRSAENCRYPTION", PkcsObjectIdentifiers.Sha224WithRsaEncryption); + Algorithms.Add("SHA-224WITHRSAENCRYPTION", PkcsObjectIdentifiers.Sha224WithRsaEncryption); + Algorithms.Add("SHA224WITHRSA", PkcsObjectIdentifiers.Sha224WithRsaEncryption); + Algorithms.Add("SHA-224WITHRSA", PkcsObjectIdentifiers.Sha224WithRsaEncryption); + Algorithms.Add("SHA256WITHRSAENCRYPTION", PkcsObjectIdentifiers.Sha256WithRsaEncryption); + Algorithms.Add("SHA-256WITHRSAENCRYPTION", PkcsObjectIdentifiers.Sha256WithRsaEncryption); + Algorithms.Add("SHA256WITHRSA", PkcsObjectIdentifiers.Sha256WithRsaEncryption); + Algorithms.Add("SHA-256WITHRSA", PkcsObjectIdentifiers.Sha256WithRsaEncryption); + Algorithms.Add("SHA384WITHRSAENCRYPTION", PkcsObjectIdentifiers.Sha384WithRsaEncryption); + Algorithms.Add("SHA-384WITHRSAENCRYPTION", PkcsObjectIdentifiers.Sha384WithRsaEncryption); + Algorithms.Add("SHA384WITHRSA", PkcsObjectIdentifiers.Sha384WithRsaEncryption); + Algorithms.Add("SHA-384WITHRSA", PkcsObjectIdentifiers.Sha384WithRsaEncryption); + Algorithms.Add("SHA512WITHRSAENCRYPTION", PkcsObjectIdentifiers.Sha512WithRsaEncryption); + Algorithms.Add("SHA-512WITHRSAENCRYPTION", PkcsObjectIdentifiers.Sha512WithRsaEncryption); + Algorithms.Add("SHA512WITHRSA", PkcsObjectIdentifiers.Sha512WithRsaEncryption); + Algorithms.Add("SHA-512WITHRSA", PkcsObjectIdentifiers.Sha512WithRsaEncryption); + Algorithms.Add("SHA512(224)WITHRSAENCRYPTION", PkcsObjectIdentifiers.Sha512_224WithRSAEncryption); + Algorithms.Add("SHA-512(224)WITHRSAENCRYPTION", PkcsObjectIdentifiers.Sha512_224WithRSAEncryption); + Algorithms.Add("SHA512(224)WITHRSA", PkcsObjectIdentifiers.Sha512_224WithRSAEncryption); + Algorithms.Add("SHA-512(224)WITHRSA", PkcsObjectIdentifiers.Sha512_224WithRSAEncryption); + Algorithms.Add("SHA512(256)WITHRSAENCRYPTION", PkcsObjectIdentifiers.Sha512_256WithRSAEncryption); + Algorithms.Add("SHA-512(256)WITHRSAENCRYPTION", PkcsObjectIdentifiers.Sha512_256WithRSAEncryption); + Algorithms.Add("SHA512(256)WITHRSA", PkcsObjectIdentifiers.Sha512_256WithRSAEncryption); + Algorithms.Add("SHA-512(256)WITHRSA", PkcsObjectIdentifiers.Sha512_256WithRSAEncryption); + Algorithms.Add("RIPEMD160WITHRSAENCRYPTION", TeleTrusTObjectIdentifiers.RsaSignatureWithRipeMD160); + Algorithms.Add("RIPEMD160WITHRSA", TeleTrusTObjectIdentifiers.RsaSignatureWithRipeMD160); + Algorithms.Add("RIPEMD128WITHRSAENCRYPTION", TeleTrusTObjectIdentifiers.RsaSignatureWithRipeMD128); + Algorithms.Add("RIPEMD128WITHRSA", TeleTrusTObjectIdentifiers.RsaSignatureWithRipeMD128); + Algorithms.Add("RIPEMD256WITHRSAENCRYPTION", TeleTrusTObjectIdentifiers.RsaSignatureWithRipeMD256); + Algorithms.Add("RIPEMD256WITHRSA", TeleTrusTObjectIdentifiers.RsaSignatureWithRipeMD256); + Algorithms.Add("SHA1WITHDSA", X9ObjectIdentifiers.IdDsaWithSha1); + Algorithms.Add("DSAWITHSHA1", X9ObjectIdentifiers.IdDsaWithSha1); + Algorithms.Add("SHA224WITHDSA", NistObjectIdentifiers.DsaWithSha224); + Algorithms.Add("SHA256WITHDSA", NistObjectIdentifiers.DsaWithSha256); + Algorithms.Add("SHA1WITHECDSA", X9ObjectIdentifiers.ECDsaWithSha1); + Algorithms.Add("ECDSAWITHSHA1", X9ObjectIdentifiers.ECDsaWithSha1); + Algorithms.Add("SHA224WITHECDSA", X9ObjectIdentifiers.ECDsaWithSha224); + Algorithms.Add("SHA256WITHECDSA", X9ObjectIdentifiers.ECDsaWithSha256); + Algorithms.Add("SHA384WITHECDSA", X9ObjectIdentifiers.ECDsaWithSha384); + Algorithms.Add("SHA512WITHECDSA", X9ObjectIdentifiers.ECDsaWithSha512); + Algorithms.Add("GOST3411WITHGOST3410", CryptoProObjectIdentifiers.GostR3411x94WithGostR3410x94); + Algorithms.Add("GOST3411WITHGOST3410-94", CryptoProObjectIdentifiers.GostR3411x94WithGostR3410x94); - oids.Add(PkcsObjectIdentifiers.MD2WithRsaEncryption, "MD2WITHRSA"); - oids.Add(PkcsObjectIdentifiers.MD5WithRsaEncryption, "MD5WITHRSA"); - oids.Add(PkcsObjectIdentifiers.Sha1WithRsaEncryption, "SHA1WITHRSA"); - oids.Add(PkcsObjectIdentifiers.Sha224WithRsaEncryption, "SHA224WITHRSA"); - oids.Add(PkcsObjectIdentifiers.Sha256WithRsaEncryption, "SHA256WITHRSA"); - oids.Add(PkcsObjectIdentifiers.Sha384WithRsaEncryption, "SHA384WITHRSA"); - oids.Add(PkcsObjectIdentifiers.Sha512WithRsaEncryption, "SHA512WITHRSA"); - oids.Add(PkcsObjectIdentifiers.Sha512_224WithRSAEncryption, "SHA512(224)WITHRSA"); - oids.Add(PkcsObjectIdentifiers.Sha512_256WithRSAEncryption, "SHA512(256)WITHRSA"); - oids.Add(TeleTrusTObjectIdentifiers.RsaSignatureWithRipeMD160, "RIPEMD160WITHRSA"); - oids.Add(TeleTrusTObjectIdentifiers.RsaSignatureWithRipeMD128, "RIPEMD128WITHRSA"); - oids.Add(TeleTrusTObjectIdentifiers.RsaSignatureWithRipeMD256, "RIPEMD256WITHRSA"); - oids.Add(X9ObjectIdentifiers.IdDsaWithSha1, "SHA1WITHDSA"); - oids.Add(NistObjectIdentifiers.DsaWithSha224, "SHA224WITHDSA"); - oids.Add(NistObjectIdentifiers.DsaWithSha256, "SHA256WITHDSA"); - oids.Add(X9ObjectIdentifiers.ECDsaWithSha1, "SHA1WITHECDSA"); - oids.Add(X9ObjectIdentifiers.ECDsaWithSha224, "SHA224WITHECDSA"); - oids.Add(X9ObjectIdentifiers.ECDsaWithSha256, "SHA256WITHECDSA"); - oids.Add(X9ObjectIdentifiers.ECDsaWithSha384, "SHA384WITHECDSA"); - oids.Add(X9ObjectIdentifiers.ECDsaWithSha512, "SHA512WITHECDSA"); - oids.Add(CryptoProObjectIdentifiers.GostR3411x94WithGostR3410x94, "GOST3411WITHGOST3410"); - oids.Add(OiwObjectIdentifiers.MD5WithRsa, "MD5WITHRSA"); - oids.Add(OiwObjectIdentifiers.Sha1WithRsa, "SHA1WITHRSA"); - oids.Add(OiwObjectIdentifiers.DsaWithSha1, "SHA1WITHDSA"); + Oids.Add(PkcsObjectIdentifiers.MD2WithRsaEncryption, "MD2WITHRSA"); + Oids.Add(PkcsObjectIdentifiers.MD5WithRsaEncryption, "MD5WITHRSA"); + Oids.Add(PkcsObjectIdentifiers.Sha1WithRsaEncryption, "SHA1WITHRSA"); + Oids.Add(PkcsObjectIdentifiers.Sha224WithRsaEncryption, "SHA224WITHRSA"); + Oids.Add(PkcsObjectIdentifiers.Sha256WithRsaEncryption, "SHA256WITHRSA"); + Oids.Add(PkcsObjectIdentifiers.Sha384WithRsaEncryption, "SHA384WITHRSA"); + Oids.Add(PkcsObjectIdentifiers.Sha512WithRsaEncryption, "SHA512WITHRSA"); + Oids.Add(PkcsObjectIdentifiers.Sha512_224WithRSAEncryption, "SHA512(224)WITHRSA"); + Oids.Add(PkcsObjectIdentifiers.Sha512_256WithRSAEncryption, "SHA512(256)WITHRSA"); + Oids.Add(TeleTrusTObjectIdentifiers.RsaSignatureWithRipeMD160, "RIPEMD160WITHRSA"); + Oids.Add(TeleTrusTObjectIdentifiers.RsaSignatureWithRipeMD128, "RIPEMD128WITHRSA"); + Oids.Add(TeleTrusTObjectIdentifiers.RsaSignatureWithRipeMD256, "RIPEMD256WITHRSA"); + Oids.Add(X9ObjectIdentifiers.IdDsaWithSha1, "SHA1WITHDSA"); + Oids.Add(NistObjectIdentifiers.DsaWithSha224, "SHA224WITHDSA"); + Oids.Add(NistObjectIdentifiers.DsaWithSha256, "SHA256WITHDSA"); + Oids.Add(X9ObjectIdentifiers.ECDsaWithSha1, "SHA1WITHECDSA"); + Oids.Add(X9ObjectIdentifiers.ECDsaWithSha224, "SHA224WITHECDSA"); + Oids.Add(X9ObjectIdentifiers.ECDsaWithSha256, "SHA256WITHECDSA"); + Oids.Add(X9ObjectIdentifiers.ECDsaWithSha384, "SHA384WITHECDSA"); + Oids.Add(X9ObjectIdentifiers.ECDsaWithSha512, "SHA512WITHECDSA"); + Oids.Add(CryptoProObjectIdentifiers.GostR3411x94WithGostR3410x94, "GOST3411WITHGOST3410"); + Oids.Add(OiwObjectIdentifiers.MD5WithRsa, "MD5WITHRSA"); + Oids.Add(OiwObjectIdentifiers.Sha1WithRsa, "SHA1WITHRSA"); + Oids.Add(OiwObjectIdentifiers.DsaWithSha1, "SHA1WITHDSA"); // // According to RFC 3279, the ASN.1 encoding SHALL (id-dsa-with-sha1) or MUST (ecdsa-with-SHA*) omit the parameters field. // The parameters field SHALL be NULL for RSA based signature algorithms. // - noParams.Add(X9ObjectIdentifiers.ECDsaWithSha1); - noParams.Add(X9ObjectIdentifiers.ECDsaWithSha224); - noParams.Add(X9ObjectIdentifiers.ECDsaWithSha256); - noParams.Add(X9ObjectIdentifiers.ECDsaWithSha384); - noParams.Add(X9ObjectIdentifiers.ECDsaWithSha512); - noParams.Add(X9ObjectIdentifiers.IdDsaWithSha1); - noParams.Add(OiwObjectIdentifiers.DsaWithSha1); - noParams.Add(NistObjectIdentifiers.DsaWithSha224); - noParams.Add(NistObjectIdentifiers.DsaWithSha256); + NoParams.Add(X9ObjectIdentifiers.ECDsaWithSha1); + NoParams.Add(X9ObjectIdentifiers.ECDsaWithSha224); + NoParams.Add(X9ObjectIdentifiers.ECDsaWithSha256); + NoParams.Add(X9ObjectIdentifiers.ECDsaWithSha384); + NoParams.Add(X9ObjectIdentifiers.ECDsaWithSha512); + NoParams.Add(X9ObjectIdentifiers.IdDsaWithSha1); + NoParams.Add(OiwObjectIdentifiers.DsaWithSha1); + NoParams.Add(NistObjectIdentifiers.DsaWithSha224); + NoParams.Add(NistObjectIdentifiers.DsaWithSha256); } - internal static DerObjectIdentifier GetAlgorithmOid( - string algorithmName) + internal static DerObjectIdentifier GetAlgorithmOid(string algorithmName) { - algorithmName = Platform.ToUpperInvariant(algorithmName); - - if (algorithms.Contains(algorithmName)) - { - return (DerObjectIdentifier)algorithms[algorithmName]; - } + if (Algorithms.TryGetValue(algorithmName, out var oid)) + return oid; return new DerObjectIdentifier(algorithmName); } - - internal static string GetAlgorithmName( - DerObjectIdentifier oid) + internal static string GetAlgorithmName(DerObjectIdentifier oid) { - if (oids.Contains(oid)) - { - return (string)oids[oid]; - } + if (Oids.TryGetValue(oid, out var algorithmName)) + return algorithmName; return oid.Id; } - internal static AlgorithmIdentifier GetSigAlgID( - DerObjectIdentifier sigOid) + internal static AlgorithmIdentifier GetSigAlgID(DerObjectIdentifier sigOid) { - if (noParams.Contains(sigOid)) - { - return new AlgorithmIdentifier(sigOid); - } + if (NoParams.Contains(sigOid)) + return new AlgorithmIdentifier(sigOid); return new AlgorithmIdentifier(sigOid, DerNull.Instance); } - internal static IEnumerable AlgNames + internal static IEnumerable<string> AlgNames { - get { return new EnumerableProxy(algorithms.Keys); } + get { return CollectionUtilities.Proxy(Algorithms.Keys); } } } } diff --git a/crypto/src/ocsp/Req.cs b/crypto/src/ocsp/Req.cs index 68fd9f12a..6b94d228d 100644 --- a/crypto/src/ocsp/Req.cs +++ b/crypto/src/ocsp/Req.cs @@ -1,8 +1,5 @@ using System; -using System.Collections; -using System.IO; -using Org.BouncyCastle.Asn1; using Org.BouncyCastle.Asn1.Ocsp; using Org.BouncyCastle.Asn1.X509; using Org.BouncyCastle.X509; diff --git a/crypto/src/ocsp/RespData.cs b/crypto/src/ocsp/RespData.cs index 7ec0e4b68..00de1cd59 100644 --- a/crypto/src/ocsp/RespData.cs +++ b/crypto/src/ocsp/RespData.cs @@ -1,5 +1,4 @@ using System; -using System.Collections; using Org.BouncyCastle.Asn1; using Org.BouncyCastle.Asn1.Ocsp; diff --git a/crypto/src/ocsp/SingleResp.cs b/crypto/src/ocsp/SingleResp.cs index b8979c538..66b2ce4b1 100644 --- a/crypto/src/ocsp/SingleResp.cs +++ b/crypto/src/ocsp/SingleResp.cs @@ -1,7 +1,5 @@ using System; -using System.Collections; -using Org.BouncyCastle.Asn1; using Org.BouncyCastle.Asn1.Ocsp; using Org.BouncyCastle.Asn1.X509; using Org.BouncyCastle.Utilities.Date; |