diff options
author | Peter Dettman <peter.dettman@bouncycastle.org> | 2024-01-28 19:55:10 +0700 |
---|---|---|
committer | Peter Dettman <peter.dettman@bouncycastle.org> | 2024-01-28 19:55:10 +0700 |
commit | 6e9092a3b00c4586c1efaa37b8b8fd30375f0a24 (patch) | |
tree | 9284148eda4c699d98524e8546b4be92a6d3dfa4 | |
parent | Tolerate missing assembly attributes (diff) | |
download | BouncyCastle.NET-ed25519-6e9092a3b00c4586c1efaa37b8b8fd30375f0a24.tar.xz |
Add noParams entries for Ed25519, Ed448
- see https://github.com/bcgit/bc-csharp/pull/485
-rw-r--r-- | crypto/src/crypto/operators/Asn1Signature.cs | 15 | ||||
-rw-r--r-- | crypto/src/pkcs/Pkcs10CertificationRequest.cs | 67 |
2 files changed, 52 insertions, 30 deletions
diff --git a/crypto/src/crypto/operators/Asn1Signature.cs b/crypto/src/crypto/operators/Asn1Signature.cs index 5f493f0c7..cec99dccf 100644 --- a/crypto/src/crypto/operators/Asn1Signature.cs +++ b/crypto/src/crypto/operators/Asn1Signature.cs @@ -101,7 +101,6 @@ namespace Org.BouncyCastle.Crypto.Operators m_algorithms.Add("GOST3411-2012-512WITHECGOST3410-2012-512", RosstandartObjectIdentifiers.id_tc26_signwithdigest_gost_3410_12_512); m_algorithms.Add("Ed25519", EdECObjectIdentifiers.id_Ed25519); m_algorithms.Add("Ed448", EdECObjectIdentifiers.id_Ed448); - // TODO Ed25519ctx, Ed25519ph, Ed448ph m_algorithms.Add("SHA256WITHSM2", GMObjectIdentifiers.sm2sign_with_sha256); m_algorithms.Add("SM3WITHSM2", GMObjectIdentifiers.sm2sign_with_sm3); @@ -128,10 +127,16 @@ namespace Org.BouncyCastle.Crypto.Operators noParams.Add(CryptoProObjectIdentifiers.GostR3411x94WithGostR3410x94); noParams.Add(CryptoProObjectIdentifiers.GostR3411x94WithGostR3410x2001); - // - // explicit params - // - AlgorithmIdentifier sha1AlgId = new AlgorithmIdentifier(OiwObjectIdentifiers.IdSha1, DerNull.Instance); + // + // RFC 8410 + // + noParams.Add(EdECObjectIdentifiers.id_Ed25519); + noParams.Add(EdECObjectIdentifiers.id_Ed448); + + // + // explicit params + // + AlgorithmIdentifier sha1AlgId = new AlgorithmIdentifier(OiwObjectIdentifiers.IdSha1, DerNull.Instance); m_exParams.Add("SHA1WITHRSAANDMGF1", CreatePssParams(sha1AlgId, 20)); AlgorithmIdentifier sha224AlgId = new AlgorithmIdentifier(NistObjectIdentifiers.IdSha224, DerNull.Instance); diff --git a/crypto/src/pkcs/Pkcs10CertificationRequest.cs b/crypto/src/pkcs/Pkcs10CertificationRequest.cs index c3e21f8ed..0534e0b25 100644 --- a/crypto/src/pkcs/Pkcs10CertificationRequest.cs +++ b/crypto/src/pkcs/Pkcs10CertificationRequest.cs @@ -4,9 +4,11 @@ using System.IO; using Org.BouncyCastle.Asn1; using Org.BouncyCastle.Asn1.CryptoPro; +using Org.BouncyCastle.Asn1.EdEC; using Org.BouncyCastle.Asn1.Nist; using Org.BouncyCastle.Asn1.Oiw; using Org.BouncyCastle.Asn1.Pkcs; +using Org.BouncyCastle.Asn1.Rosstandart; using Org.BouncyCastle.Asn1.TeleTrust; using Org.BouncyCastle.Asn1.X509; using Org.BouncyCastle.Asn1.X9; @@ -52,8 +54,8 @@ namespace Org.BouncyCastle.Pkcs new Dictionary<string, Asn1Encodable>(StringComparer.OrdinalIgnoreCase); internal static readonly Dictionary<DerObjectIdentifier, string> m_keyAlgorithms = new Dictionary<DerObjectIdentifier, string>(); - internal static readonly Dictionary<DerObjectIdentifier, string> m_oids = - new Dictionary<DerObjectIdentifier, string>(); + //internal static readonly Dictionary<DerObjectIdentifier, string> m_oids = + // new Dictionary<DerObjectIdentifier, string>(); internal static readonly HashSet<DerObjectIdentifier> m_noParams = new HashSet<DerObjectIdentifier>(); static Pkcs10CertificationRequest() @@ -120,33 +122,42 @@ namespace Org.BouncyCastle.Pkcs m_algorithms.Add("GOST3411WITHECGOST3410", CryptoProObjectIdentifiers.GostR3411x94WithGostR3410x2001); m_algorithms.Add("GOST3411WITHECGOST3410-2001", CryptoProObjectIdentifiers.GostR3411x94WithGostR3410x2001); m_algorithms.Add("GOST3411WITHGOST3410-2001", CryptoProObjectIdentifiers.GostR3411x94WithGostR3410x2001); + m_algorithms.Add("GOST3411-2012-256WITHECGOST3410", RosstandartObjectIdentifiers.id_tc26_signwithdigest_gost_3410_12_256); + m_algorithms.Add("GOST3411-2012-256WITHECGOST3410-2012-256", RosstandartObjectIdentifiers.id_tc26_signwithdigest_gost_3410_12_256); + m_algorithms.Add("GOST3411-2012-512WITHECGOST3410", RosstandartObjectIdentifiers.id_tc26_signwithdigest_gost_3410_12_512); + m_algorithms.Add("GOST3411-2012-512WITHECGOST3410-2012-512", RosstandartObjectIdentifiers.id_tc26_signwithdigest_gost_3410_12_512); + m_algorithms.Add("Ed25519", EdECObjectIdentifiers.id_Ed25519); + m_algorithms.Add("Ed448", EdECObjectIdentifiers.id_Ed448); // // reverse mappings // - m_oids.Add(PkcsObjectIdentifiers.Sha1WithRsaEncryption, "SHA1WITHRSA"); - m_oids.Add(PkcsObjectIdentifiers.Sha224WithRsaEncryption, "SHA224WITHRSA"); - m_oids.Add(PkcsObjectIdentifiers.Sha256WithRsaEncryption, "SHA256WITHRSA"); - m_oids.Add(PkcsObjectIdentifiers.Sha384WithRsaEncryption, "SHA384WITHRSA"); - m_oids.Add(PkcsObjectIdentifiers.Sha512WithRsaEncryption, "SHA512WITHRSA"); - m_oids.Add(PkcsObjectIdentifiers.Sha512_224WithRSAEncryption, "SHA512(224)WITHRSA"); - m_oids.Add(PkcsObjectIdentifiers.Sha512_256WithRSAEncryption, "SHA512(256)WITHRSA"); - m_oids.Add(CryptoProObjectIdentifiers.GostR3411x94WithGostR3410x94, "GOST3411WITHGOST3410"); - m_oids.Add(CryptoProObjectIdentifiers.GostR3411x94WithGostR3410x2001, "GOST3411WITHECGOST3410"); - - m_oids.Add(PkcsObjectIdentifiers.MD5WithRsaEncryption, "MD5WITHRSA"); - m_oids.Add(PkcsObjectIdentifiers.MD2WithRsaEncryption, "MD2WITHRSA"); - m_oids.Add(X9ObjectIdentifiers.IdDsaWithSha1, "SHA1WITHDSA"); - m_oids.Add(X9ObjectIdentifiers.ECDsaWithSha1, "SHA1WITHECDSA"); - m_oids.Add(X9ObjectIdentifiers.ECDsaWithSha224, "SHA224WITHECDSA"); - m_oids.Add(X9ObjectIdentifiers.ECDsaWithSha256, "SHA256WITHECDSA"); - m_oids.Add(X9ObjectIdentifiers.ECDsaWithSha384, "SHA384WITHECDSA"); - m_oids.Add(X9ObjectIdentifiers.ECDsaWithSha512, "SHA512WITHECDSA"); - m_oids.Add(OiwObjectIdentifiers.MD5WithRsa, "MD5WITHRSA"); - m_oids.Add(OiwObjectIdentifiers.Sha1WithRsa, "SHA1WITHRSA"); - m_oids.Add(OiwObjectIdentifiers.DsaWithSha1, "SHA1WITHDSA"); - m_oids.Add(NistObjectIdentifiers.DsaWithSha224, "SHA224WITHDSA"); - m_oids.Add(NistObjectIdentifiers.DsaWithSha256, "SHA256WITHDSA"); + //m_oids.Add(PkcsObjectIdentifiers.Sha1WithRsaEncryption, "SHA1WITHRSA"); + //m_oids.Add(PkcsObjectIdentifiers.Sha224WithRsaEncryption, "SHA224WITHRSA"); + //m_oids.Add(PkcsObjectIdentifiers.Sha256WithRsaEncryption, "SHA256WITHRSA"); + //m_oids.Add(PkcsObjectIdentifiers.Sha384WithRsaEncryption, "SHA384WITHRSA"); + //m_oids.Add(PkcsObjectIdentifiers.Sha512WithRsaEncryption, "SHA512WITHRSA"); + //m_oids.Add(PkcsObjectIdentifiers.Sha512_224WithRSAEncryption, "SHA512(224)WITHRSA"); + //m_oids.Add(PkcsObjectIdentifiers.Sha512_256WithRSAEncryption, "SHA512(256)WITHRSA"); + //m_oids.Add(CryptoProObjectIdentifiers.GostR3411x94WithGostR3410x94, "GOST3411WITHGOST3410"); + //m_oids.Add(CryptoProObjectIdentifiers.GostR3411x94WithGostR3410x2001, "GOST3411WITHECGOST3410"); + + //m_oids.Add(PkcsObjectIdentifiers.MD5WithRsaEncryption, "MD5WITHRSA"); + //m_oids.Add(PkcsObjectIdentifiers.MD2WithRsaEncryption, "MD2WITHRSA"); + //m_oids.Add(X9ObjectIdentifiers.IdDsaWithSha1, "SHA1WITHDSA"); + //m_oids.Add(X9ObjectIdentifiers.ECDsaWithSha1, "SHA1WITHECDSA"); + //m_oids.Add(X9ObjectIdentifiers.ECDsaWithSha224, "SHA224WITHECDSA"); + //m_oids.Add(X9ObjectIdentifiers.ECDsaWithSha256, "SHA256WITHECDSA"); + //m_oids.Add(X9ObjectIdentifiers.ECDsaWithSha384, "SHA384WITHECDSA"); + //m_oids.Add(X9ObjectIdentifiers.ECDsaWithSha512, "SHA512WITHECDSA"); + //m_oids.Add(OiwObjectIdentifiers.MD5WithRsa, "MD5WITHRSA"); + //m_oids.Add(OiwObjectIdentifiers.Sha1WithRsa, "SHA1WITHRSA"); + //m_oids.Add(OiwObjectIdentifiers.DsaWithSha1, "SHA1WITHDSA"); + //m_oids.Add(NistObjectIdentifiers.DsaWithSha224, "SHA224WITHDSA"); + //m_oids.Add(NistObjectIdentifiers.DsaWithSha256, "SHA256WITHDSA"); + + //m_oids.Add(EdECObjectIdentifiers.id_Ed25519, "Ed25519"); + //m_oids.Add(EdECObjectIdentifiers.id_Ed448, "Ed448"); // // key types @@ -175,6 +186,12 @@ namespace Org.BouncyCastle.Pkcs m_noParams.Add(CryptoProObjectIdentifiers.GostR3411x94WithGostR3410x2001); // + // RFC 8410 + // + m_noParams.Add(EdECObjectIdentifiers.id_Ed25519); + m_noParams.Add(EdECObjectIdentifiers.id_Ed448); + + // // explicit params // AlgorithmIdentifier sha1AlgId = new AlgorithmIdentifier(OiwObjectIdentifiers.IdSha1, DerNull.Instance); |