crypto.subtle.deriveKey
different length arg in deno and browser
#16180
Labels
crypto.subtle.deriveKey
different length arg in deno and browser
#16180
Describe the bug
We were playing with https://github.com/denodrivers/postgres and at some point realized that crypto SCRAM implementation works differently in Deno and other environments (browser, cloudflare workers, etc.).
After some debugging, we narrowed the scope to the
deriveKeySignatures
function, which uses SubtleCrypto with PBKDF2 and HMAC/SHA-256. It turned out that specifying an optionallength
parameter in a single place can fix the code to work without issues across all environments:https://developer.mozilla.org/en-US/docs/Web/API/HmacKeyGenParams says that:
It looks like the issue is that Deno implementation for default
length
is wrong and differs from browser engines.This issue is probably the same as #14938
Steps to Reproduce
Code sample based on https://github.com/denodrivers/postgres/blob/8a07131efa17f4a6bcab86fd81407f149de93449/connection/scram.ts#L93
Execute this code in deno and browser:
Output in Deno:
Output in browser (Firefox 105.0.1, Chrome 105):
Expected behavior
Code in Deno and browser bundle produces the same result.
Environment
The text was updated successfully, but these errors were encountered: