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:
parent
e18950284f
commit
ec09134d8a
2 changed files with 17 additions and 2 deletions
|
@ -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"],
|
||||
);
|
||||
});
|
||||
|
|
|
@ -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",
|
||||
);
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue