diff options
author | Divy Srivastava <dj.srivastava23@gmail.com> | 2021-10-06 14:54:41 +0530 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-10-06 11:24:41 +0200 |
commit | b033a7a6d4ac6f1d3e20b5d113cca2fd85cacfc3 (patch) | |
tree | 2ec2a5b49581c6e37813c13c059ac18698cb0618 /ext/crypto/lib.rs | |
parent | 3aa859159561bb318a474baa347ced4362deece8 (diff) |
fix(ext/crypto): key generation based on AES key length (#12146)
Diffstat (limited to 'ext/crypto/lib.rs')
-rw-r--r-- | ext/crypto/lib.rs | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/ext/crypto/lib.rs b/ext/crypto/lib.rs index 2db629c94..948ef53a1 100644 --- a/ext/crypto/lib.rs +++ b/ext/crypto/lib.rs @@ -222,7 +222,8 @@ pub async fn op_crypto_generate_key( | Algorithm::AesGcm | Algorithm::AesKw => { let length = args.length.ok_or_else(not_supported)?; - let mut key_data = vec![0u8; length]; + // Caller must guarantee divisibility by 8 + let mut key_data = vec![0u8; length / 8]; let rng = RingRand::SystemRandom::new(); rng.fill(&mut key_data).map_err(|_| { custom_error("DOMExceptionOperationError", "Key generation failed") |