deno
4a489d8f - fix(ext/crypto): validate raw key length on X25519/X448/Ed25519 importKey (#33944)

Commit
78 days ago
fix(ext/crypto): validate raw key length on X25519/X448/Ed25519 importKey (#33944) Importing a raw X25519 public key shorter than 32 bytes (e.g. an empty Uint8Array) bypassed validation and stored the bytes in the key store as-is. A subsequent deriveKey/deriveBits call then panicked in op_crypto_derive_bits_x25519 when converting the slice to [u8; 32]. Apply the same fix to X448 and Ed25519, which had the same shape. The fix: - Validate length at importKey time for raw and jwk formats so invalid keys are rejected with a DataError DOMException, matching how Chromium handles the same input. - Convert the panicking try_into expects in op_crypto_derive_bits_x25519 and op_crypto_derive_bits_x448 into a fallible Result so callers see a DOMException instead of crashing the runtime. Fixes #33032 --------- Co-authored-by: fibibot <fibibot@users.noreply.github.com>
Author
Parents
Loading