diff options
author | Divy Srivastava <dj.srivastava23@gmail.com> | 2021-07-08 00:04:02 +0530 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-07-07 20:34:02 +0200 |
commit | 5bcbbb75e9df029299647bf5c84f58b7317a5c1d (patch) | |
tree | 702fbca21a3132b1e73906701f3afcbe3431444b /extensions/crypto/key.rs | |
parent | 48e7c871d9798161e99a30ff738ca94b92aed7a3 (diff) |
refactor(extensions/crypto): use key::CryptoHash with digest (#11309)
Diffstat (limited to 'extensions/crypto/key.rs')
-rw-r--r-- | extensions/crypto/key.rs | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/extensions/crypto/key.rs b/extensions/crypto/key.rs index d5801635e..cb44812fd 100644 --- a/extensions/crypto/key.rs +++ b/extensions/crypto/key.rs @@ -1,6 +1,7 @@ // Copyright 2018-2021 the Deno authors. All rights reserved. MIT license. use ring::agreement::Algorithm as RingAlgorithm; +use ring::digest; use ring::hmac::Algorithm as HmacAlgorithm; use ring::signature::EcdsaSigningAlgorithm; use serde::Deserialize; @@ -67,6 +68,17 @@ impl From<CryptoHash> for HmacAlgorithm { } } +impl From<CryptoHash> for &'static digest::Algorithm { + fn from(hash: CryptoHash) -> &'static digest::Algorithm { + match hash { + CryptoHash::Sha1 => &digest::SHA1_FOR_LEGACY_USE_ONLY, + CryptoHash::Sha256 => &digest::SHA256, + CryptoHash::Sha384 => &digest::SHA384, + CryptoHash::Sha512 => &digest::SHA512, + } + } +} + #[derive(Serialize, Deserialize, Copy, Clone, Debug, PartialEq)] #[serde(rename_all = "camelCase")] pub enum KeyUsage { |