1
0
Fork 0
mirror of https://github.com/denoland/deno.git synced 2024-12-23 15:49:44 -05:00

fix(ext/crypto): correct HMAC get key length op (#16201)

fixes #16180

`HMAC`'s `get key length` `op` uses the hash function's block size, not
output size.

refs
https://github.com/cloudflare/workerd/issues/68#issuecomment-1271189657
This commit is contained in:
Filip Skokan 2022-10-15 07:23:35 +02:00 committed by GitHub
parent e7d7585065
commit 225d516466
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 5 additions and 5 deletions

View file

@ -675,7 +675,7 @@ Deno.test(async function testDeriveKey() {
const algorithm = derivedKey.algorithm as HmacKeyAlgorithm;
assertEquals(algorithm.name, "HMAC");
assertEquals(algorithm.hash.name, "SHA-256");
assertEquals(algorithm.length, 256);
assertEquals(algorithm.length, 512);
});
Deno.test(async function testAesCbcEncryptDecrypt() {

View file

@ -393,16 +393,16 @@
if (algorithm.length === undefined) {
switch (algorithm.hash.name) {
case "SHA-1":
length = 160;
length = 512;
break;
case "SHA-256":
length = 256;
length = 512;
break;
case "SHA-384":
length = 384;
length = 1024;
break;
case "SHA-512":
length = 512;
length = 1024;
break;
default:
throw new DOMException(