diff options
-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") |