summaryrefslogtreecommitdiff
path: root/extensions/crypto/key.rs
diff options
context:
space:
mode:
Diffstat (limited to 'extensions/crypto/key.rs')
-rw-r--r--extensions/crypto/key.rs12
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 {