Truly independent web browser
LibWeb: Expect "sig" as the use of a KMAC JWK
Shannon Booth7334c954d48a
diff --git a/Libraries/LibWeb/Crypto/CryptoAlgorithms.cpp b/Libraries/LibWeb/Crypto/CryptoAlgorithms.cppindex 9d363f48199..faef8246ba4 100644--- a/Libraries/LibWeb/Crypto/CryptoAlgorithms.cpp+++ b/Libraries/LibWeb/Crypto/CryptoAlgorithms.cpp@@ -10484,8 +10484,8 @@ WebIDL::ExceptionOr<GC::Ref<CryptoKey>> KMAC::import_key(JS::Realm& realm, Algorreturn WebIDL::DataError::create("Invalid alg field for KMAC256"_utf16);}- // 6. If usages is non-empty and the use field of jwk is present and is not "sign", then throw a DataError.- if (!usages.is_empty() && jwk.use.has_value() && *jwk.use != "sign"sv)+ // 6. If usages is non-empty and the use field of jwk is present and is not "sig", then throw a DataError.+ if (!usages.is_empty() && jwk.use.has_value() && *jwk.use != "sig"sv)return WebIDL::DataError::create("Invalid use in JsonWebKey"_utf16);// 7. If the key_ops field of jwk is present, and is invalid according to the requirements of JSON Web Key [JWK]diff --git a/Tests/LibWeb/Text/expected/Crypto/SubtleCrypto-KMAC-jwk-use.txt b/Tests/LibWeb/Text/expected/Crypto/SubtleCrypto-KMAC-jwk-use.txtnew file mode 100644index 00000000000..2c835fe653c--- /dev/null+++ b/Tests/LibWeb/Text/expected/Crypto/SubtleCrypto-KMAC-jwk-use.txt@@ -0,0 +1,2 @@+use "sig": ok+use "sign": DataErrordiff --git a/Tests/LibWeb/Text/input/Crypto/SubtleCrypto-KMAC-jwk-use.html b/Tests/LibWeb/Text/input/Crypto/SubtleCrypto-KMAC-jwk-use.htmlnew file mode 100644index 00000000000..888814abadd--- /dev/null+++ b/Tests/LibWeb/Text/input/Crypto/SubtleCrypto-KMAC-jwk-use.html@@ -0,0 +1,19 @@+<!doctype html>+<script src="../include.js"></script>+<script>+ promiseTest(async () => {+ async function check(label, promise) {+ try {+ await promise;+ println(`${label}: ok`);+ } catch (error) {+ println(`${label}: ${error.name}`);+ }+ }++ const jwk = use => ({ kty: "oct", k: "AAAAAAAAAAAAAAAAAAAAAA", alg: "K128", use });++ await check('use "sig"', crypto.subtle.importKey("jwk", jwk("sig"), "KMAC128", false, ["sign"]));+ await check('use "sign"', crypto.subtle.importKey("jwk", jwk("sign"), "KMAC128", false, ["sign"]));+ });+</script>