diff options
author | Divy Srivastava <dj.srivastava23@gmail.com> | 2021-09-12 02:19:53 +0530 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-09-11 16:49:53 -0400 |
commit | 40c63d1255642b8d70d7b5ce5b85a50f6af8a00d (patch) | |
tree | abdfe6e1df461b3d8106fc3c75a7c879cd9381a2 /ext/crypto/key.rs | |
parent | d236f432b86de55c6006778b0c68fe60b6419069 (diff) |
feat(ext/crypto): verify ECDSA signatures (#11739)
Diffstat (limited to 'ext/crypto/key.rs')
-rw-r--r-- | ext/crypto/key.rs | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/ext/crypto/key.rs b/ext/crypto/key.rs index d2420bfe9..663217887 100644 --- a/ext/crypto/key.rs +++ b/ext/crypto/key.rs @@ -4,6 +4,7 @@ use ring::agreement::Algorithm as RingAlgorithm; use ring::digest; use ring::hmac::Algorithm as HmacAlgorithm; use ring::signature::EcdsaSigningAlgorithm; +use ring::signature::EcdsaVerificationAlgorithm; use serde::Deserialize; use serde::Serialize; @@ -57,6 +58,15 @@ impl From<CryptoNamedCurve> for &EcdsaSigningAlgorithm { } } +impl From<CryptoNamedCurve> for &EcdsaVerificationAlgorithm { + fn from(curve: CryptoNamedCurve) -> &'static EcdsaVerificationAlgorithm { + match curve { + CryptoNamedCurve::P256 => &ring::signature::ECDSA_P256_SHA256_FIXED, + CryptoNamedCurve::P384 => &ring::signature::ECDSA_P384_SHA384_FIXED, + } + } +} + impl From<CryptoHash> for HmacAlgorithm { fn from(hash: CryptoHash) -> HmacAlgorithm { match hash { |