diff options
author | Divy Srivastava <dj.srivastava23@gmail.com> | 2021-08-05 01:19:27 +0530 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-08-04 21:49:27 +0200 |
commit | 87de8e82a157ecbcc596b0226b8a6fc0e81a8b1b (patch) | |
tree | 1b11766af8fce76db2cf2110bee4307f3681a0d5 /extensions/crypto/lib.rs | |
parent | 2ac031d6fd3cb9b98ffb1801033d96675291f577 (diff) |
feat(extensions/crypto): implement verify() for HMAC (#11387)
Diffstat (limited to 'extensions/crypto/lib.rs')
-rw-r--r-- | extensions/crypto/lib.rs | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/extensions/crypto/lib.rs b/extensions/crypto/lib.rs index 09f237fa6..d1908120d 100644 --- a/extensions/crypto/lib.rs +++ b/extensions/crypto/lib.rs @@ -505,6 +505,11 @@ pub async fn op_crypto_verify_key( .verify(padding, &hashed, &*args.signature) .is_ok() } + Algorithm::Hmac => { + let hash: HmacAlgorithm = args.hash.ok_or_else(not_supported)?.into(); + let key = HmacKey::new(hash, &*args.key.data); + ring::hmac::verify(&key, data, &*args.signature).is_ok() + } _ => return Err(type_error("Unsupported algorithm".to_string())), }; |