1
0
Fork 0
mirror of https://github.com/denoland/deno.git synced 2025-01-11 08:33:43 -05:00

fix(ext/crypto): fix HMAC jwk import "use" check (#16465)

This commit is contained in:
Filip Skokan 2022-10-28 16:20:38 +02:00 committed by GitHub
parent e18950284f
commit ec09134d8a
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 17 additions and 2 deletions

View file

@ -1965,3 +1965,18 @@ Deno.test(async function testECspkiRoundTrip() {
const spki = await crypto.subtle.exportKey("spki", publicKey);
await crypto.subtle.importKey("spki", spki, alg, true, []);
});
Deno.test(async function testHmacJwkImport() {
await crypto.subtle.importKey(
"jwk",
{
kty: "oct",
use: "sig",
alg: "HS256",
k: "hJtXIZ2uSN5kbQfbtTNWbpdmhkV8FJG-Onbc6mxCcYg",
},
{ name: "HMAC", hash: "SHA-256" },
false,
["sign", "verify"],
);
});

View file

@ -2880,10 +2880,10 @@
// 7.
if (
keyUsages.length > 0 && jwk.use !== undefined && jwk.use !== "sign"
keyUsages.length > 0 && jwk.use !== undefined && jwk.use !== "sig"
) {
throw new DOMException(
"'use' property of JsonWebKey must be 'sign'",
"'use' property of JsonWebKey must be 'sig'",
"DataError",
);
}