mirror of
https://github.com/denoland/deno.git
synced 2025-03-03 09:31:22 -05:00
fix(ext/crypto): key generation based on AES key length (#12146)
This commit is contained in:
parent
3aa8591595
commit
b033a7a6d4
1 changed files with 2 additions and 1 deletions
|
@ -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")
|
||||
|
|
Loading…
Add table
Reference in a new issue