Add EcdsaSha512P384 and EcdsaSha512P521
Keep them hidden behind a feature flag for now per request from joshlf.
Change-Id: I6bd53dde7fc8c84441867cc0155b45ed9431eefd
diff --git a/Cargo.toml b/Cargo.toml
index 4654cdc..ef35ae1 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -31,3 +31,4 @@
insecure = []
kdf = []
rand-bytes = []
+experimental-sha512-ec = []
diff --git a/src/public/ec/mod.rs b/src/public/ec/mod.rs
index 9de9ee5..3b8f120 100644
--- a/src/public/ec/mod.rs
+++ b/src/public/ec/mod.rs
@@ -337,6 +337,8 @@
use std::marker::PhantomData;
use boringssl;
+ #[cfg(feature = "experimental-sha512-ec")]
+ use hash::Sha512;
use hash::{inner::Digest, Hasher, Sha256, Sha384};
use public::{
ec::{EcPrivKey, EcPubKey, PCurve, P256, P384, P521},
@@ -362,6 +364,12 @@
impl EcdsaHash<P521> for Sha256 {}
impl EcdsaHash<P521> for Sha384 {}
+ #[cfg(feature = "experimental-sha512-ec")]
+ impl EcdsaHash<P384> for Sha512 {}
+
+ #[cfg(feature = "experimental-sha512-ec")]
+ impl EcdsaHash<P521> for Sha512 {}
+
// The maximum length of an ECDSA signature over P-521. Since this isn't
// exposed in the API, we can increase later if we add support for curves
// with larger signatures.
@@ -504,6 +512,19 @@
EcdsaSignature::<_, Sha384>::from_bytes,
EcdsaSignature::bytes,
);
+ #[cfg(feature = "experimental-sha512-ec")]
+ {
+ test_signature_smoke(
+ &p384,
+ EcdsaSignature::<_, Sha512>::from_bytes,
+ EcdsaSignature::bytes,
+ );
+ test_signature_smoke(
+ &p521,
+ EcdsaSignature::<_, Sha512>::from_bytes,
+ EcdsaSignature::bytes,
+ );
+ }
}
#[test]