Truly independent web browser
LibWeb: Implement SubtleCrypto.supports()
Jelle Raaijmakersfc2694be678e
diff --git a/Libraries/LibWeb/Crypto/CryptoAlgorithms.cpp b/Libraries/LibWeb/Crypto/CryptoAlgorithms.cppindex 4922ca0f0d7..2ef48e4e1eb 100644--- a/Libraries/LibWeb/Crypto/CryptoAlgorithms.cpp+++ b/Libraries/LibWeb/Crypto/CryptoAlgorithms.cpp@@ -9852,6 +9852,13 @@ WebIDL::ExceptionOr<ByteBuffer> MLKEM::decapsulate(JS::Realm&, AlgorithmParams creturn shared_key;}+// https://wicg.github.io/webcrypto-modern-algos/#ml-kem-operations-get-shared-key-length+WebIDL::ExceptionOr<u32> MLKEM::get_shared_key_length(AlgorithmParams const&) const+{+ // 1. Return 256.+ return 256;+}+// https://wicg.github.io/webcrypto-modern-algos/#argon2-operations-import-keyWebIDL::ExceptionOr<GC::Ref<CryptoKey>> Argon2::import_key(JS::Realm&, AlgorithmParams const& params, KeyFormat format, CryptoKey::ImportKeyData key_data, bool extractable, Vector<KeyUsage> const& usages){diff --git a/Libraries/LibWeb/Crypto/CryptoAlgorithms.h b/Libraries/LibWeb/Crypto/CryptoAlgorithms.hindex f7e01b23c93..8eec3f9d85f 100644--- a/Libraries/LibWeb/Crypto/CryptoAlgorithms.h+++ b/Libraries/LibWeb/Crypto/CryptoAlgorithms.h@@ -356,6 +356,11 @@ public:return WebIDL::NotSupportedError::create("getKeyLength is not supported"_utf16);}+ virtual WebIDL::ExceptionOr<u32> get_shared_key_length(AlgorithmParams const&) const+ {+ return WebIDL::NotSupportedError::create("getSharedKeyLength is not supported"_utf16);+ }+virtual WebIDL::ExceptionOr<ByteBuffer> wrap_key(JS::Realm&, AlgorithmParams const&, GC::Ref<CryptoKey>, ByteBuffer const&){return WebIDL::NotSupportedError::create("wrapKey is not supported"_utf16);@@ -709,6 +714,7 @@ public:virtual WebIDL::ExceptionOr<ExportKeyResult> export_key(JS::Realm& realm, KeyFormat, GC::Ref<CryptoKey>) override;virtual WebIDL::ExceptionOr<EncapsulatedBits> encapsulate(JS::Realm& realm, AlgorithmParams const&, GC::Ref<CryptoKey>) override;virtual WebIDL::ExceptionOr<ByteBuffer> decapsulate(JS::Realm& realm, AlgorithmParams const&, GC::Ref<CryptoKey>, ByteBuffer const&) override;+ virtual WebIDL::ExceptionOr<u32> get_shared_key_length(AlgorithmParams const&) const override;virtual Optional<ReadonlySpan<KeyUsage>> public_key_usages() const override;diff --git a/Libraries/LibWeb/Crypto/SubtleCrypto.cpp b/Libraries/LibWeb/Crypto/SubtleCrypto.cppindex 42bb6f219a7..62b28c70e4b 100644--- a/Libraries/LibWeb/Crypto/SubtleCrypto.cpp+++ b/Libraries/LibWeb/Crypto/SubtleCrypto.cpp@@ -91,9 +91,13 @@ WebIDL::ExceptionOr<NormalizedAlgorithmAndParameter> normalize_an_algorithm(JS::// If alg is an object:// 1. Let registeredAlgorithms be the associative container stored at the op key of supportedAlgorithms.- // NOTE: There should always be a container at the op key.auto const& internal_object = supported_algorithms();auto maybe_registered_algorithms = internal_object.get(operation);++ // NB: supports() can normalize with op set to "deriveKey", for which there is no container and thus no registered+ // algorithm.+ if (!maybe_registered_algorithms.has_value())+ return WebIDL::NotSupportedError::create(Utf16String::formatted("Operation '{}' is not supported", operation));auto registered_algorithms = maybe_registered_algorithms.value();// 2. Let initialAlg be the result of converting the ECMAScript object represented by alg to@@ -1645,6 +1649,227 @@ GC::Ref<WebIDL::Promise> SubtleCrypto::get_public_key(JS::Realm& realm, GC::Ref<return promise;}+// https://wicg.github.io/webcrypto-modern-algos/#dfn-determine-support-from-operation-steps+static bool determine_support_from_operation_steps(JS::Realm& realm, StringView op, NormalizedAlgorithmAndParameter& normalized_algorithm, Optional<u32> length)+{+ auto& methods = *normalized_algorithm.methods;+ auto const& parameter = *normalized_algorithm.parameter;++ // 1. If the specified operation or normalized algorithm (or one of its parameter values) is expected to fail (for+ // any key and/or data) for an implementation-specific reason (e.g. known nonconformance to the specification),+ // return false.+ // NB: The validate_*_parameters() methods of the algorithms also reject parameters that we do not support.++ // 2. If op is "generateKey" or "importKey", let usages be the empty list.+ // NB: An empty list of usages never makes a step of these operations throw.++ // 3. For each of the steps of the operation specified by op of the algorithm specified by normalizedAlgorithm:+ // -> If the step says to throw an error: Return false.+ // -> If the step says to generate a key: Return true.+ // -> If the step relies on an unavailable parameter, such as key, plaintext or ciphertext: Return true.+ // -> If the step says to return a value: Return true.+ // -> Otherwise: Execute the step.+ // NB: The validate_*_parameters() methods of an algorithm perform the steps of its operations that come before the+ // first step that relies on an unavailable parameter, generates a key or returns a value. The operations that+ // have no such method rely on an unavailable parameter in their first steps. The get key length operation+ // relies on its parameters only, so we perform it in full.+ auto result = [&] -> WebIDL::ExceptionOr<void> {+ if (op == "encrypt"sv)+ return methods.validate_encrypt_parameters(parameter);+ if (op == "decrypt"sv)+ return methods.validate_decrypt_parameters(parameter);+ if (op == "sign"sv)+ return methods.validate_sign_parameters(parameter);+ if (op == "verify"sv)+ return methods.validate_verify_parameters(parameter);+ if (op == "digest"sv)+ return methods.validate_digest_parameters(parameter);+ if (op == "generateKey"sv)+ return methods.validate_generate_key_parameters(parameter);+ if (op == "importKey"sv)+ return methods.validate_import_key_parameters(parameter);+ if (op == "deriveBits"sv)+ return methods.validate_derive_bits_parameters(parameter, length);+ if (op == "get key length"sv)+ TRY(methods.get_key_length(realm, parameter));+ return {};+ }();+ return !result.is_error();+}++// https://wicg.github.io/webcrypto-modern-algos/#dfn-check-support-for-algorithm+static bool check_support_for_an_algorithm(JS::Realm& realm, String op, AlgorithmIdentifier const& alg, Optional<u32> length)+{+ // 1. If op is "encapsulateKey" or "encapsulateBits", set op to "encapsulate".+ if (op.is_one_of("encapsulateKey"sv, "encapsulateBits"sv))+ op = "encapsulate"_string;++ // 2. If op is "decapsulateKey" or "decapsulateBits", set op to "decapsulate".+ if (op.is_one_of("decapsulateKey"sv, "decapsulateBits"sv))+ op = "decapsulate"_string;++ // 3. If op is "getPublicKey":+ if (op == "getPublicKey"sv) {+ // 1. Let normalizedAlgorithm be the result of normalizing an algorithm, with alg set to alg and op set to+ // "exportKey".+ auto normalized_algorithm = normalize_an_algorithm(realm, alg, "exportKey"_string);++ // 2. If an error occurred, return false.+ if (normalized_algorithm.is_error())+ return false;++ // 3. If the cryptographic algorithm identified by normalizedAlgorithm does not support deriving a public key+ // from a private key, then return false.+ // 4. Otherwise, return true.+ return normalized_algorithm.value().methods->public_key_usages().has_value();+ }++ // 4. Let normalizedAlgorithm be the result of normalizing an algorithm, with alg set to alg and op set to op.+ auto normalized_algorithm = normalize_an_algorithm(realm, alg, op);++ // 5. If an error occurred:+ if (normalized_algorithm.is_error()) {+ // 1. If op is "wrapKey", return the result of checking support for an algorithm with op set to "encrypt" and+ // alg set to alg.+ if (op == "wrapKey"sv)+ return check_support_for_an_algorithm(realm, "encrypt"_string, alg, {});++ // 2. If op is "unwrapKey", return the result of checking support for an algorithm with op set to "decrypt" and+ // alg set to alg.+ if (op == "unwrapKey"sv)+ return check_support_for_an_algorithm(realm, "decrypt"_string, alg, {});++ // 3. Otherwise, return false.+ return false;+ }++ // 6. Return the result of determining support from operation steps, with op set to op, normalizedAlgorithm set to+ // normalizedAlgorithm, and length set to length.+ return determine_support_from_operation_steps(realm, op, normalized_algorithm.value(), length);+}++static bool is_a_supported_operation(Utf16String const& operation)+{+ return operation.is_one_of("encrypt"sv, "decrypt"sv, "sign"sv, "verify"sv, "digest"sv, "generateKey"sv,+ "deriveKey"sv, "deriveBits"sv, "importKey"sv, "exportKey"sv, "wrapKey"sv, "unwrapKey"sv, "encapsulateKey"sv,+ "encapsulateBits"sv, "decapsulateKey"sv, "decapsulateBits"sv, "getPublicKey"sv);+}++// https://wicg.github.io/webcrypto-modern-algos/#dfn-SubtleCrypto-method-supports+bool SubtleCrypto::supports(JS::Realm& realm, Utf16String const& operation, AlgorithmIdentifier const& algorithm, Optional<u32> length)+{+ // 1. If operation is not one of "encrypt", "decrypt", "sign", "verify", "digest", "generateKey", "deriveKey",+ // "deriveBits", "importKey", "exportKey", "wrapKey", "unwrapKey", "encapsulateKey", "encapsulateBits",+ // "decapsulateKey", "decapsulateBits" or "getPublicKey", return false.+ if (!is_a_supported_operation(operation))+ return false;++ // 2. Return the result of checking support for an algorithm, with op set to operation, alg set to algorithm, and+ // length set to length.+ return check_support_for_an_algorithm(realm, operation.to_utf8(), algorithm, length);+}++// https://wicg.github.io/webcrypto-modern-algos/#dfn-SubtleCrypto-method-supports-additionalAlgorithm+bool SubtleCrypto::supports(JS::Realm& realm, Utf16String const& operation, AlgorithmIdentifier const& algorithm, AlgorithmIdentifier const& additional_algorithm)+{+ // 1. If operation is not one of "encrypt", "decrypt", "sign", "verify", "digest", "generateKey", "deriveKey",+ // "deriveBits", "importKey", "exportKey", "wrapKey", "unwrapKey", "encapsulateKey", "encapsulateBits",+ // "decapsulateKey", "decapsulateBits" or "getPublicKey", return false.+ if (!is_a_supported_operation(operation))+ return false;++ auto op = operation.to_utf8();++ // 2. If operation is "deriveKey" or "unwrapKey":+ if (op.is_one_of("deriveKey"sv, "unwrapKey"sv)) {+ // 1. If the result of checking support for an algorithm with op set to "importKey" and alg set to+ // additionalAlgorithm is false, return false.+ if (!check_support_for_an_algorithm(realm, "importKey"_string, additional_algorithm, {}))+ return false;+ }++ // 3. If operation is "wrapKey":+ if (op == "wrapKey"sv) {+ // 1. If the result of checking support for an algorithm with op set to "exportKey" and alg set to+ // additionalAlgorithm is false, return false.+ if (!check_support_for_an_algorithm(realm, "exportKey"_string, additional_algorithm, {}))+ return false;+ }++ // 4. If operation is "encapsulateKey" or "decapsulateKey":+ if (op.is_one_of("encapsulateKey"sv, "decapsulateKey"sv)) {+ // 1. Let normalizedAlgorithm be the result of normalizing an algorithm, with alg set to algorithm and op set+ // to "get shared key length".+ auto normalized_algorithm = normalize_an_algorithm(realm, algorithm, "get shared key length"_string);++ // 2. If an error occurred, return false.+ if (normalized_algorithm.is_error())+ return false;++ // 3. Let sharedKeyLength be the result of performing the get shared key length algorithm specified by+ // normalizedAlgorithm using algorithm.+ auto shared_key_length = normalized_algorithm.value().methods->get_shared_key_length(*normalized_algorithm.value().parameter);+ if (shared_key_length.is_error())+ return false;++ // 4. Let normalizedAdditionalAlgorithm be the result of normalizing an algorithm, with alg set to+ // additionalAlgorithm and op set to "importKey".+ auto normalized_additional_algorithm = normalize_an_algorithm(realm, additional_algorithm, "importKey"_string);++ // 5. If an error occurred, return false.+ if (normalized_additional_algorithm.is_error())+ return false;++ // 6. If the result of determining support from operation steps with op set to "importKey" and+ // normalizedAlgorithm set to normalizedAdditionalAlgorithm, and length set to null is false, return false.+ if (!determine_support_from_operation_steps(realm, "importKey"sv, normalized_additional_algorithm.value(), {}))+ return false;++ // 7. If the import key operation specified by normalizedAdditionalAlgorithm would throw an error for every value+ // of keyData that is a byte sequence whose length in bits is sharedKeyLength when format is "raw-secret",+ // return false.+ // NB: Whether importing secret key data fails depends on its length only, so importing zeroes of that length+ // tells whether every such keyData fails.+ auto key_data = MUST(ByteBuffer::create_zeroed(ceil_div(shared_key_length.value(), 8u)));+ auto const& import_algorithm = normalized_additional_algorithm.value();+ if (import_algorithm.methods->import_key(realm, *import_algorithm.parameter, KeyFormat::RawSecret, move(key_data), false, {}).is_error())+ return false;+ }++ // 5. Let length be null.+ Optional<u32> length;++ // 6. If operation is "deriveKey":+ if (op == "deriveKey"sv) {+ // 1. If the result of checking support for an algorithm with op set to "get key length" and alg set to+ // additionalAlgorithm is false, return false.+ if (!check_support_for_an_algorithm(realm, "get key length"_string, additional_algorithm, {}))+ return false;++ // 2. Let normalizedAdditionalAlgorithm be the result of normalizing an algorithm, with alg set to+ // additionalAlgorithm and op set to "get key length".+ // NB: Normalizing can run author code, so this second normalization can fail even though the first succeeded.+ auto normalized_additional_algorithm = normalize_an_algorithm(realm, additional_algorithm, "get key length"_string);+ if (normalized_additional_algorithm.is_error())+ return false;++ // 3. Let length be the result of performing the get key length algorithm specified by additionalAlgorithm+ // using normalizedAdditionalAlgorithm.+ auto& normalized_length_algorithm = normalized_additional_algorithm.value();+ auto key_length = normalized_length_algorithm.methods->get_key_length(realm, *normalized_length_algorithm.parameter);+ if (key_length.is_error())+ return false;+ length = key_length.release_value();++ // 4. Set operation to "deriveBits".+ op = "deriveBits"_string;+ }++ // 7. Return the result of checking support for an algorithm, with op set to operation, alg set to algorithm, and+ // length set to length.+ return check_support_for_an_algorithm(realm, move(op), algorithm, length);+}+SupportedAlgorithmsMap& supported_algorithms_internal(){static NeverDestroyed<SupportedAlgorithmsMap> supported_algorithms;@@ -1676,7 +1901,8 @@ SupportedAlgorithmsMap const& supported_algorithms()"exportKey"_string,"get key length"_string,"encapsulate"_string,- "decapsulate"_string+ "decapsulate"_string,+ "get shared key length"_string};for (auto& operation : supported_operations) {@@ -1826,6 +2052,7 @@ SupportedAlgorithmsMap const& supported_algorithms()define_an_algorithm<MLKEM>("exportKey"_string, name);define_an_algorithm<MLKEM>("encapsulate"_string, name);define_an_algorithm<MLKEM>("decapsulate"_string, name);+ define_an_algorithm<MLKEM>("get shared key length"_string, name);}// https://wicg.github.io/webcrypto-modern-algos/#argon2-registrationdiff --git a/Libraries/LibWeb/Crypto/SubtleCrypto.h b/Libraries/LibWeb/Crypto/SubtleCrypto.hindex 3644b2d4abd..d28167e5837 100644--- a/Libraries/LibWeb/Crypto/SubtleCrypto.h+++ b/Libraries/LibWeb/Crypto/SubtleCrypto.h@@ -52,6 +52,9 @@ public:GC::Ref<WebIDL::Promise> get_public_key(JS::Realm&, GC::Ref<CryptoKey> key, Vector<KeyUsage> key_usages);+ static bool supports(JS::Realm&, Utf16String const& operation, AlgorithmIdentifier const& algorithm, Optional<u32> length);+ static bool supports(JS::Realm&, Utf16String const& operation, AlgorithmIdentifier const& algorithm, AlgorithmIdentifier const& additional_algorithm);+private:SubtleCrypto();};diff --git a/Libraries/LibWeb/Crypto/SubtleCrypto.idl b/Libraries/LibWeb/Crypto/SubtleCrypto.idlindex 190dfef3924..cdc6ea4e427 100644--- a/Libraries/LibWeb/Crypto/SubtleCrypto.idl+++ b/Libraries/LibWeb/Crypto/SubtleCrypto.idl@@ -84,4 +84,6 @@ interface SubtleCrypto {[NeedsCallerRealm] Promise<CryptoKey> decapsulateKey(AlgorithmIdentifier decapsulationAlgorithm, CryptoKey decapsulationKey, BufferSource ciphertext, AlgorithmIdentifier sharedKeyAlgorithm, boolean extractable, sequence<KeyUsage> keyUsages);[NeedsCallerRealm] Promise<ArrayBuffer> decapsulateBits(AlgorithmIdentifier decapsulationAlgorithm, CryptoKey decapsulationKey, BufferSource ciphertext);[NeedsCallerRealm] Promise<CryptoKey> getPublicKey(CryptoKey key, sequence<KeyUsage> keyUsages);+ [NeedsCallerRealm] static boolean supports(DOMString operation, AlgorithmIdentifier algorithm, optional [EnforceRange] unsigned long? length = null);+ [NeedsCallerRealm] static boolean supports(DOMString operation, AlgorithmIdentifier algorithm, AlgorithmIdentifier additionalAlgorithm);};diff --git a/Meta/Linters/check_libweb_realm_mentions.py b/Meta/Linters/check_libweb_realm_mentions.pyindex 9e282c98327..78a40312ed3 100755--- a/Meta/Linters/check_libweb_realm_mentions.py+++ b/Meta/Linters/check_libweb_realm_mentions.py@@ -40,7 +40,12 @@ ALLOWED_REALM_MENTIONS = {"Clipboard": (4, 16, "clipboard item/data callbacks still materialize JS values in caller-selected realms"),"ContentSecurityPolicy": (4, 10, "CSP violation/report objects and callbacks still materialize JS-facing values"),"CookieStore": (2, 19, "cookie-store async callbacks and promise/value materialization still thread realms"),- "Crypto": (8, 371, "WebCrypto algorithms still use realms for buffer/key/promise materialization"),+ "Crypto": (+ 8,+ 377,+ "WebCrypto algorithms still use realms for buffer/key/promise materialization and for normalizing algorithm "+ "dictionaries, which SubtleCrypto.supports() does in the caller realm",+ ),"DOM": (10, 33, "DOM abort plumbing and node helpers still have callback/materialization realm use"),"Fetch": (20,diff --git a/Tests/LibWeb/Text/expected/Crypto/SubtleCrypto-supports-implementation-limits.txt b/Tests/LibWeb/Text/expected/Crypto/SubtleCrypto-supports-implementation-limits.txtnew file mode 100644index 00000000000..c8e8f28f217--- /dev/null+++ b/Tests/LibWeb/Text/expected/Crypto/SubtleCrypto-supports-implementation-limits.txt@@ -0,0 +1,30 @@+cSHAKE128: supports true, digest ok+cSHAKE128 with customization: supports false, digest OperationError+cSHAKE256 with function name: supports false, digest OperationError+cSHAKE128 with partial byte output length: supports false, digest OperationError+HMAC SHA-256: supports true, generateKey ok+HMAC SHA3-256: supports false, generateKey NotSupportedError+HMAC SHA3-256 with length: supports true, generateKey ok+RSA-OAEP 512-bit modulus: supports true, generateKey ok+RSA-OAEP 511-bit modulus: supports false, generateKey OperationError+RSA-PSS 512-bit modulus: supports true, generateKey ok+RSA-PSS 511-bit modulus: supports false, generateKey OperationError+RSASSA-PKCS1-v1_5 512-bit modulus: supports true, generateKey ok+RSASSA-PKCS1-v1_5 511-bit modulus: supports false, generateKey OperationError+ECDSA SHA-256: supports true, sign ok+ECDSA SHA3-256: supports false, sign NotSupportedError+PBKDF2 SHA-256: supports true, deriveBits ok+PBKDF2 SHA3-256: supports false, deriveBits NotSupportedError+KMAC128 output length 256: supports true, sign ok+KMAC128 output length 1: supports false, sign OperationError+KMAC128 512-byte customization: supports true, sign ok+KMAC128 513-byte customization: supports false, sign OperationError+KMAC128 import length 8: supports true, importKey ok+KMAC128 import length 1: supports false, importKey NotSupportedError+KMAC128 import length 4104: supports false, importKey NotSupportedError+AES-GCM 12-byte IV: supports true, encrypt ok+AES-GCM empty IV: supports false, encrypt OperationError+AES-OCB 12-byte IV: supports true, encrypt ok+AES-OCB empty IV: supports false, encrypt OperationError+Argon2id 8-byte nonce: supports true, deriveBits ok+Argon2id 7-byte nonce: supports false, deriveBits OperationErrordiff --git a/Tests/LibWeb/Text/expected/wpt-import/WebCryptoAPI/modern-algos/idlharness.https.any.txt b/Tests/LibWeb/Text/expected/wpt-import/WebCryptoAPI/modern-algos/idlharness.https.any.txtindex 550f51f16c5..fa531342711 100644--- a/Tests/LibWeb/Text/expected/wpt-import/WebCryptoAPI/modern-algos/idlharness.https.any.txt+++ b/Tests/LibWeb/Text/expected/wpt-import/WebCryptoAPI/modern-algos/idlharness.https.any.txt@@ -2,8 +2,7 @@ Harness status: OKFound 28 tests-24 Pass-4 Fail+28 PassPass idl_test setupPass idl_test validationPass Partial interface SubtleCrypto: original interface defined@@ -16,8 +15,8 @@ Pass SubtleCrypto interface: operation encapsulateBits(AlgorithmIdentifier, CrypPass SubtleCrypto interface: operation decapsulateKey(AlgorithmIdentifier, CryptoKey, BufferSource, AlgorithmIdentifier, boolean, sequence<KeyUsage>)Pass SubtleCrypto interface: operation decapsulateBits(AlgorithmIdentifier, CryptoKey, BufferSource)Pass SubtleCrypto interface: operation getPublicKey(CryptoKey, sequence<KeyUsage>)-Fail SubtleCrypto interface: operation supports(DOMString, AlgorithmIdentifier, optional unsigned long?)-Fail SubtleCrypto interface: operation supports(DOMString, AlgorithmIdentifier, AlgorithmIdentifier)+Pass SubtleCrypto interface: operation supports(DOMString, AlgorithmIdentifier, optional unsigned long?)+Pass SubtleCrypto interface: operation supports(DOMString, AlgorithmIdentifier, AlgorithmIdentifier)Pass SubtleCrypto interface: crypto.subtle must inherit property "encapsulateKey(AlgorithmIdentifier, CryptoKey, AlgorithmIdentifier, boolean, sequence<KeyUsage>)" with the proper typePass SubtleCrypto interface: calling encapsulateKey(AlgorithmIdentifier, CryptoKey, AlgorithmIdentifier, boolean, sequence<KeyUsage>) on crypto.subtle with too few arguments must throw TypeErrorPass SubtleCrypto interface: crypto.subtle must inherit property "encapsulateBits(AlgorithmIdentifier, CryptoKey)" with the proper type@@ -29,6 +28,6 @@ Pass SubtleCrypto interface: calling decapsulateBits(AlgorithmIdentifier, CryptoPass SubtleCrypto interface: crypto.subtle must inherit property "getPublicKey(CryptoKey, sequence<KeyUsage>)" with the proper typePass SubtleCrypto interface: calling getPublicKey(CryptoKey, sequence<KeyUsage>) on crypto.subtle with too few arguments must throw TypeErrorPass SubtleCrypto interface: crypto.subtle must inherit property "supports(DOMString, AlgorithmIdentifier, optional unsigned long?)" with the proper type-Fail SubtleCrypto interface: calling supports(DOMString, AlgorithmIdentifier, optional unsigned long?) on crypto.subtle with too few arguments must throw TypeError+Pass SubtleCrypto interface: calling supports(DOMString, AlgorithmIdentifier, optional unsigned long?) on crypto.subtle with too few arguments must throw TypeErrorPass SubtleCrypto interface: crypto.subtle must inherit property "supports(DOMString, AlgorithmIdentifier, AlgorithmIdentifier)" with the proper type-Fail SubtleCrypto interface: calling supports(DOMString, AlgorithmIdentifier, AlgorithmIdentifier) on crypto.subtle with too few arguments must throw TypeError\ No newline at end of file+Pass SubtleCrypto interface: calling supports(DOMString, AlgorithmIdentifier, AlgorithmIdentifier) on crypto.subtle with too few arguments must throw TypeError\ No newline at end of filediff --git a/Tests/LibWeb/Text/expected/wpt-import/WebCryptoAPI/modern-algos/supports-modern.https.any.txt b/Tests/LibWeb/Text/expected/wpt-import/WebCryptoAPI/modern-algos/supports-modern.https.any.txtindex 31e0089ae15..9cc83f182f0 100644--- a/Tests/LibWeb/Text/expected/wpt-import/WebCryptoAPI/modern-algos/supports-modern.https.any.txt+++ b/Tests/LibWeb/Text/expected/wpt-import/WebCryptoAPI/modern-algos/supports-modern.https.any.txt@@ -2,94 +2,95 @@ Harness status: OKFound 147 tests-147 Fail-Fail SubtleCrypto.supports method exists-Fail supports(generateKey, ML-DSA-44)-Fail supports(importKey, ML-DSA-44)-Fail supports(sign, ML-DSA-44)-Fail supports(verify, ML-DSA-44)-Fail supports(encrypt, ML-DSA-44)-Fail supports(decrypt, ML-DSA-44)-Fail supports(deriveBits, ML-DSA-44)-Fail supports(digest, ML-DSA-44)-Fail supports(encapsulateKey, ML-DSA-44)-Fail supports(encapsulateBits, ML-DSA-44)-Fail supports(decapsulateKey, ML-DSA-44)-Fail supports(decapsulateBits, ML-DSA-44)-Fail supports(getPublicKey, ML-DSA-44)-Fail supports(generateKey, ML-DSA-65)-Fail supports(importKey, ML-DSA-65)-Fail supports(sign, ML-DSA-65)-Fail supports(verify, ML-DSA-65)-Fail supports(encrypt, ML-DSA-65)-Fail supports(decrypt, ML-DSA-65)-Fail supports(deriveBits, ML-DSA-65)-Fail supports(digest, ML-DSA-65)-Fail supports(encapsulateKey, ML-DSA-65)-Fail supports(encapsulateBits, ML-DSA-65)-Fail supports(decapsulateKey, ML-DSA-65)-Fail supports(decapsulateBits, ML-DSA-65)-Fail supports(getPublicKey, ML-DSA-65)-Fail supports(generateKey, ML-DSA-87)-Fail supports(importKey, ML-DSA-87)-Fail supports(sign, ML-DSA-87)-Fail supports(verify, ML-DSA-87)-Fail supports(encrypt, ML-DSA-87)-Fail supports(decrypt, ML-DSA-87)-Fail supports(deriveBits, ML-DSA-87)-Fail supports(digest, ML-DSA-87)-Fail supports(encapsulateKey, ML-DSA-87)-Fail supports(encapsulateBits, ML-DSA-87)-Fail supports(decapsulateKey, ML-DSA-87)-Fail supports(decapsulateBits, ML-DSA-87)-Fail supports(getPublicKey, ML-DSA-87)-Fail supports(generateKey, ML-KEM-512)-Fail supports(importKey, ML-KEM-512)-Fail supports(sign, ML-KEM-512)-Fail supports(verify, ML-KEM-512)-Fail supports(encrypt, ML-KEM-512)-Fail supports(decrypt, ML-KEM-512)-Fail supports(deriveBits, ML-KEM-512)-Fail supports(digest, ML-KEM-512)-Fail supports(encapsulateKey, ML-KEM-512)-Fail supports(encapsulateBits, ML-KEM-512)-Fail supports(decapsulateKey, ML-KEM-512)-Fail supports(decapsulateBits, ML-KEM-512)-Fail supports(getPublicKey, ML-KEM-512)-Fail supports(generateKey, ML-KEM-768)-Fail supports(importKey, ML-KEM-768)-Fail supports(sign, ML-KEM-768)-Fail supports(verify, ML-KEM-768)-Fail supports(encrypt, ML-KEM-768)-Fail supports(decrypt, ML-KEM-768)-Fail supports(deriveBits, ML-KEM-768)-Fail supports(digest, ML-KEM-768)-Fail supports(encapsulateKey, ML-KEM-768)-Fail supports(encapsulateBits, ML-KEM-768)-Fail supports(decapsulateKey, ML-KEM-768)-Fail supports(decapsulateBits, ML-KEM-768)-Fail supports(getPublicKey, ML-KEM-768)-Fail supports(generateKey, ML-KEM-1024)-Fail supports(importKey, ML-KEM-1024)-Fail supports(sign, ML-KEM-1024)-Fail supports(verify, ML-KEM-1024)-Fail supports(encrypt, ML-KEM-1024)-Fail supports(decrypt, ML-KEM-1024)-Fail supports(deriveBits, ML-KEM-1024)-Fail supports(digest, ML-KEM-1024)-Fail supports(encapsulateKey, ML-KEM-1024)-Fail supports(encapsulateBits, ML-KEM-1024)-Fail supports(decapsulateKey, ML-KEM-1024)-Fail supports(decapsulateBits, ML-KEM-1024)-Fail supports(getPublicKey, ML-KEM-1024)+126 Pass+21 Fail+Pass SubtleCrypto.supports method exists+Pass supports(generateKey, ML-DSA-44)+Pass supports(importKey, ML-DSA-44)+Pass supports(sign, ML-DSA-44)+Pass supports(verify, ML-DSA-44)+Pass supports(encrypt, ML-DSA-44)+Pass supports(decrypt, ML-DSA-44)+Pass supports(deriveBits, ML-DSA-44)+Pass supports(digest, ML-DSA-44)+Pass supports(encapsulateKey, ML-DSA-44)+Pass supports(encapsulateBits, ML-DSA-44)+Pass supports(decapsulateKey, ML-DSA-44)+Pass supports(decapsulateBits, ML-DSA-44)+Pass supports(getPublicKey, ML-DSA-44)+Pass supports(generateKey, ML-DSA-65)+Pass supports(importKey, ML-DSA-65)+Pass supports(sign, ML-DSA-65)+Pass supports(verify, ML-DSA-65)+Pass supports(encrypt, ML-DSA-65)+Pass supports(decrypt, ML-DSA-65)+Pass supports(deriveBits, ML-DSA-65)+Pass supports(digest, ML-DSA-65)+Pass supports(encapsulateKey, ML-DSA-65)+Pass supports(encapsulateBits, ML-DSA-65)+Pass supports(decapsulateKey, ML-DSA-65)+Pass supports(decapsulateBits, ML-DSA-65)+Pass supports(getPublicKey, ML-DSA-65)+Pass supports(generateKey, ML-DSA-87)+Pass supports(importKey, ML-DSA-87)+Pass supports(sign, ML-DSA-87)+Pass supports(verify, ML-DSA-87)+Pass supports(encrypt, ML-DSA-87)+Pass supports(decrypt, ML-DSA-87)+Pass supports(deriveBits, ML-DSA-87)+Pass supports(digest, ML-DSA-87)+Pass supports(encapsulateKey, ML-DSA-87)+Pass supports(encapsulateBits, ML-DSA-87)+Pass supports(decapsulateKey, ML-DSA-87)+Pass supports(decapsulateBits, ML-DSA-87)+Pass supports(getPublicKey, ML-DSA-87)+Pass supports(generateKey, ML-KEM-512)+Pass supports(importKey, ML-KEM-512)+Pass supports(sign, ML-KEM-512)+Pass supports(verify, ML-KEM-512)+Pass supports(encrypt, ML-KEM-512)+Pass supports(decrypt, ML-KEM-512)+Pass supports(deriveBits, ML-KEM-512)+Pass supports(digest, ML-KEM-512)+Pass supports(encapsulateKey, ML-KEM-512)+Pass supports(encapsulateBits, ML-KEM-512)+Pass supports(decapsulateKey, ML-KEM-512)+Pass supports(decapsulateBits, ML-KEM-512)+Pass supports(getPublicKey, ML-KEM-512)+Pass supports(generateKey, ML-KEM-768)+Pass supports(importKey, ML-KEM-768)+Pass supports(sign, ML-KEM-768)+Pass supports(verify, ML-KEM-768)+Pass supports(encrypt, ML-KEM-768)+Pass supports(decrypt, ML-KEM-768)+Pass supports(deriveBits, ML-KEM-768)+Pass supports(digest, ML-KEM-768)+Pass supports(encapsulateKey, ML-KEM-768)+Pass supports(encapsulateBits, ML-KEM-768)+Pass supports(decapsulateKey, ML-KEM-768)+Pass supports(decapsulateBits, ML-KEM-768)+Pass supports(getPublicKey, ML-KEM-768)+Pass supports(generateKey, ML-KEM-1024)+Pass supports(importKey, ML-KEM-1024)+Pass supports(sign, ML-KEM-1024)+Pass supports(verify, ML-KEM-1024)+Pass supports(encrypt, ML-KEM-1024)+Pass supports(decrypt, ML-KEM-1024)+Pass supports(deriveBits, ML-KEM-1024)+Pass supports(digest, ML-KEM-1024)+Pass supports(encapsulateKey, ML-KEM-1024)+Pass supports(encapsulateBits, ML-KEM-1024)+Pass supports(decapsulateKey, ML-KEM-1024)+Pass supports(decapsulateBits, ML-KEM-1024)+Pass supports(getPublicKey, ML-KEM-1024)Fail supports(generateKey, MLKEM768-P256)Fail supports(importKey, MLKEM768-P256)-Fail supports(sign, MLKEM768-P256)-Fail supports(verify, MLKEM768-P256)-Fail supports(encrypt, MLKEM768-P256)-Fail supports(decrypt, MLKEM768-P256)-Fail supports(deriveBits, MLKEM768-P256)-Fail supports(digest, MLKEM768-P256)+Pass supports(sign, MLKEM768-P256)+Pass supports(verify, MLKEM768-P256)+Pass supports(encrypt, MLKEM768-P256)+Pass supports(decrypt, MLKEM768-P256)+Pass supports(deriveBits, MLKEM768-P256)+Pass supports(digest, MLKEM768-P256)Fail supports(encapsulateKey, MLKEM768-P256)Fail supports(encapsulateBits, MLKEM768-P256)Fail supports(decapsulateKey, MLKEM768-P256)@@ -97,12 +98,12 @@ Fail supports(decapsulateBits, MLKEM768-P256)Fail supports(getPublicKey, MLKEM768-P256)Fail supports(generateKey, MLKEM768-X25519)Fail supports(importKey, MLKEM768-X25519)-Fail supports(sign, MLKEM768-X25519)-Fail supports(verify, MLKEM768-X25519)-Fail supports(encrypt, MLKEM768-X25519)-Fail supports(decrypt, MLKEM768-X25519)-Fail supports(deriveBits, MLKEM768-X25519)-Fail supports(digest, MLKEM768-X25519)+Pass supports(sign, MLKEM768-X25519)+Pass supports(verify, MLKEM768-X25519)+Pass supports(encrypt, MLKEM768-X25519)+Pass supports(decrypt, MLKEM768-X25519)+Pass supports(deriveBits, MLKEM768-X25519)+Pass supports(digest, MLKEM768-X25519)Fail supports(encapsulateKey, MLKEM768-X25519)Fail supports(encapsulateBits, MLKEM768-X25519)Fail supports(decapsulateKey, MLKEM768-X25519)@@ -110,43 +111,43 @@ Fail supports(decapsulateBits, MLKEM768-X25519)Fail supports(getPublicKey, MLKEM768-X25519)Fail supports(generateKey, MLKEM1024-P384)Fail supports(importKey, MLKEM1024-P384)-Fail supports(sign, MLKEM1024-P384)-Fail supports(verify, MLKEM1024-P384)-Fail supports(encrypt, MLKEM1024-P384)-Fail supports(decrypt, MLKEM1024-P384)-Fail supports(deriveBits, MLKEM1024-P384)-Fail supports(digest, MLKEM1024-P384)+Pass supports(sign, MLKEM1024-P384)+Pass supports(verify, MLKEM1024-P384)+Pass supports(encrypt, MLKEM1024-P384)+Pass supports(decrypt, MLKEM1024-P384)+Pass supports(deriveBits, MLKEM1024-P384)+Pass supports(digest, MLKEM1024-P384)Fail supports(encapsulateKey, MLKEM1024-P384)Fail supports(encapsulateBits, MLKEM1024-P384)Fail supports(decapsulateKey, MLKEM1024-P384)Fail supports(decapsulateBits, MLKEM1024-P384)Fail supports(getPublicKey, MLKEM1024-P384)-Fail supports(generateKey, ChaCha20-Poly1305)-Fail supports(importKey, ChaCha20-Poly1305)-Fail supports(sign, ChaCha20-Poly1305)-Fail supports(verify, ChaCha20-Poly1305)-Fail supports(encrypt, ChaCha20-Poly1305)-Fail supports(decrypt, ChaCha20-Poly1305)-Fail supports(deriveBits, ChaCha20-Poly1305)-Fail supports(digest, ChaCha20-Poly1305)-Fail supports(encapsulateKey, ChaCha20-Poly1305)-Fail supports(encapsulateBits, ChaCha20-Poly1305)-Fail supports(decapsulateKey, ChaCha20-Poly1305)-Fail supports(decapsulateBits, ChaCha20-Poly1305)-Fail supports(getPublicKey, ChaCha20-Poly1305)-Fail supports validates ML-DSA-44 sign context length-Fail supports validates ML-DSA-44 verify context length-Fail supports validates ML-DSA-65 sign context length-Fail supports validates ML-DSA-65 verify context length-Fail supports validates ML-DSA-87 sign context length-Fail supports validates ML-DSA-87 verify context length-Fail supports encapsulateKey with a matching HMAC length-Fail supports encapsulateKey with an algorithm without raw-secret import-Fail supports encapsulateKey with an HMAC length shorter than the shared secret-Fail supports encapsulateKey with an HMAC length longer than the shared secret-Fail supports decapsulateKey with a matching HMAC length-Fail supports decapsulateKey with an algorithm without raw-secret import-Fail supports decapsulateKey with an HMAC length shorter than the shared secret-Fail supports decapsulateKey with an HMAC length longer than the shared secret-Fail supports returns true for algorithm objects with valid parameters-Fail supports returns false for algorithm objects with invalid parameters\ No newline at end of file+Pass supports(generateKey, ChaCha20-Poly1305)+Pass supports(importKey, ChaCha20-Poly1305)+Pass supports(sign, ChaCha20-Poly1305)+Pass supports(verify, ChaCha20-Poly1305)+Pass supports(encrypt, ChaCha20-Poly1305)+Pass supports(decrypt, ChaCha20-Poly1305)+Pass supports(deriveBits, ChaCha20-Poly1305)+Pass supports(digest, ChaCha20-Poly1305)+Pass supports(encapsulateKey, ChaCha20-Poly1305)+Pass supports(encapsulateBits, ChaCha20-Poly1305)+Pass supports(decapsulateKey, ChaCha20-Poly1305)+Pass supports(decapsulateBits, ChaCha20-Poly1305)+Pass supports(getPublicKey, ChaCha20-Poly1305)+Pass supports validates ML-DSA-44 sign context length+Pass supports validates ML-DSA-44 verify context length+Pass supports validates ML-DSA-65 sign context length+Pass supports validates ML-DSA-65 verify context length+Pass supports validates ML-DSA-87 sign context length+Pass supports validates ML-DSA-87 verify context length+Pass supports encapsulateKey with a matching HMAC length+Pass supports encapsulateKey with an algorithm without raw-secret import+Pass supports encapsulateKey with an HMAC length shorter than the shared secret+Pass supports encapsulateKey with an HMAC length longer than the shared secret+Pass supports decapsulateKey with a matching HMAC length+Pass supports decapsulateKey with an algorithm without raw-secret import+Pass supports decapsulateKey with an HMAC length shorter than the shared secret+Pass supports decapsulateKey with an HMAC length longer than the shared secret+Pass supports returns true for algorithm objects with valid parameters+Pass supports returns false for algorithm objects with invalid parameters\ No newline at end of filediff --git a/Tests/LibWeb/Text/expected/wpt-import/WebCryptoAPI/modern-algos/supports.https.any.txt b/Tests/LibWeb/Text/expected/wpt-import/WebCryptoAPI/modern-algos/supports.https.any.txtindex a9bf2ff35c9..236da491db8 100644--- a/Tests/LibWeb/Text/expected/wpt-import/WebCryptoAPI/modern-algos/supports.https.any.txt+++ b/Tests/LibWeb/Text/expected/wpt-import/WebCryptoAPI/modern-algos/supports.https.any.txt@@ -2,204 +2,204 @@ Harness status: OKFound 200 tests-200 Fail-Fail SubtleCrypto.supports method exists-Fail supports returns false for invalid operations-Fail supports returns false for invalid algorithms-Fail supports(generateKey, RSASSA-PKCS1-v1_5)-Fail supports(importKey, RSASSA-PKCS1-v1_5)-Fail supports(sign, RSASSA-PKCS1-v1_5)-Fail supports(verify, RSASSA-PKCS1-v1_5)-Fail supports(encrypt, RSASSA-PKCS1-v1_5)-Fail supports(decrypt, RSASSA-PKCS1-v1_5)-Fail supports(deriveBits, RSASSA-PKCS1-v1_5)-Fail supports(digest, RSASSA-PKCS1-v1_5)-Fail supports(getPublicKey, RSASSA-PKCS1-v1_5)-Fail supports(generateKey, RSA-PSS)-Fail supports(importKey, RSA-PSS)-Fail supports(sign, RSA-PSS)-Fail supports(verify, RSA-PSS)-Fail supports(encrypt, RSA-PSS)-Fail supports(decrypt, RSA-PSS)-Fail supports(deriveBits, RSA-PSS)-Fail supports(digest, RSA-PSS)-Fail supports(getPublicKey, RSA-PSS)-Fail supports(generateKey, RSA-OAEP)-Fail supports(importKey, RSA-OAEP)-Fail supports(sign, RSA-OAEP)-Fail supports(verify, RSA-OAEP)-Fail supports(encrypt, RSA-OAEP)-Fail supports(decrypt, RSA-OAEP)-Fail supports(deriveBits, RSA-OAEP)-Fail supports(digest, RSA-OAEP)-Fail supports(getPublicKey, RSA-OAEP)-Fail supports(generateKey, ECDSA)-Fail supports(importKey, ECDSA)-Fail supports(sign, ECDSA)-Fail supports(verify, ECDSA)-Fail supports(encrypt, ECDSA)-Fail supports(decrypt, ECDSA)-Fail supports(deriveBits, ECDSA)-Fail supports(digest, ECDSA)-Fail supports(getPublicKey, ECDSA)-Fail supports(generateKey, ECDH)-Fail supports(importKey, ECDH)-Fail supports(sign, ECDH)-Fail supports(verify, ECDH)-Fail supports(encrypt, ECDH)-Fail supports(decrypt, ECDH)-Fail supports(deriveBits, ECDH)-Fail supports(digest, ECDH)-Fail supports(getPublicKey, ECDH)-Fail supports(generateKey, Ed25519)-Fail supports(importKey, Ed25519)-Fail supports(sign, Ed25519)-Fail supports(verify, Ed25519)-Fail supports(encrypt, Ed25519)-Fail supports(decrypt, Ed25519)-Fail supports(deriveBits, Ed25519)-Fail supports(digest, Ed25519)-Fail supports(getPublicKey, Ed25519)-Fail supports(generateKey, X25519)-Fail supports(importKey, X25519)-Fail supports(sign, X25519)-Fail supports(verify, X25519)-Fail supports(encrypt, X25519)-Fail supports(decrypt, X25519)-Fail supports(deriveBits, X25519)-Fail supports(digest, X25519)-Fail supports(getPublicKey, X25519)-Fail supports(generateKey, AES-CBC)-Fail supports(importKey, AES-CBC)-Fail supports(sign, AES-CBC)-Fail supports(verify, AES-CBC)-Fail supports(encrypt, AES-CBC)-Fail supports(decrypt, AES-CBC)-Fail supports(deriveBits, AES-CBC)-Fail supports(digest, AES-CBC)-Fail supports(getPublicKey, AES-CBC)-Fail supports(generateKey, AES-CTR)-Fail supports(importKey, AES-CTR)-Fail supports(sign, AES-CTR)-Fail supports(verify, AES-CTR)-Fail supports(encrypt, AES-CTR)-Fail supports(decrypt, AES-CTR)-Fail supports(deriveBits, AES-CTR)-Fail supports(digest, AES-CTR)-Fail supports(getPublicKey, AES-CTR)-Fail supports(generateKey, AES-GCM)-Fail supports(importKey, AES-GCM)-Fail supports(sign, AES-GCM)-Fail supports(verify, AES-GCM)-Fail supports(encrypt, AES-GCM)-Fail supports(decrypt, AES-GCM)-Fail supports(deriveBits, AES-GCM)-Fail supports(digest, AES-GCM)-Fail supports(getPublicKey, AES-GCM)-Fail supports(generateKey, AES-KW)-Fail supports(importKey, AES-KW)-Fail supports(sign, AES-KW)-Fail supports(verify, AES-KW)-Fail supports(encrypt, AES-KW)-Fail supports(decrypt, AES-KW)-Fail supports(deriveBits, AES-KW)-Fail supports(digest, AES-KW)-Fail supports(getPublicKey, AES-KW)-Fail supports(generateKey, HMAC)-Fail supports(importKey, HMAC)-Fail supports(sign, HMAC)-Fail supports(verify, HMAC)-Fail supports(encrypt, HMAC)-Fail supports(decrypt, HMAC)-Fail supports(deriveBits, HMAC)-Fail supports(digest, HMAC)-Fail supports(getPublicKey, HMAC)-Fail supports(generateKey, SHA-1)-Fail supports(importKey, SHA-1)-Fail supports(sign, SHA-1)-Fail supports(verify, SHA-1)-Fail supports(encrypt, SHA-1)-Fail supports(decrypt, SHA-1)-Fail supports(deriveBits, SHA-1)-Fail supports(digest, SHA-1)-Fail supports(getPublicKey, SHA-1)-Fail supports(generateKey, SHA-256)-Fail supports(importKey, SHA-256)-Fail supports(sign, SHA-256)-Fail supports(verify, SHA-256)-Fail supports(encrypt, SHA-256)-Fail supports(decrypt, SHA-256)-Fail supports(deriveBits, SHA-256)-Fail supports(digest, SHA-256)-Fail supports(getPublicKey, SHA-256)-Fail supports(generateKey, SHA-384)-Fail supports(importKey, SHA-384)-Fail supports(sign, SHA-384)-Fail supports(verify, SHA-384)-Fail supports(encrypt, SHA-384)-Fail supports(decrypt, SHA-384)-Fail supports(deriveBits, SHA-384)-Fail supports(digest, SHA-384)-Fail supports(getPublicKey, SHA-384)-Fail supports(generateKey, SHA-512)-Fail supports(importKey, SHA-512)-Fail supports(sign, SHA-512)-Fail supports(verify, SHA-512)-Fail supports(encrypt, SHA-512)-Fail supports(decrypt, SHA-512)-Fail supports(deriveBits, SHA-512)-Fail supports(digest, SHA-512)-Fail supports(getPublicKey, SHA-512)-Fail supports(generateKey, HKDF)-Fail supports(importKey, HKDF)-Fail supports(sign, HKDF)-Fail supports(verify, HKDF)-Fail supports(encrypt, HKDF)-Fail supports(decrypt, HKDF)-Fail supports(deriveBits, HKDF)-Fail supports(digest, HKDF)-Fail supports(getPublicKey, HKDF)-Fail supports(generateKey, PBKDF2)-Fail supports(importKey, PBKDF2)-Fail supports(sign, PBKDF2)-Fail supports(verify, PBKDF2)-Fail supports(encrypt, PBKDF2)-Fail supports(decrypt, PBKDF2)-Fail supports(deriveBits, PBKDF2)-Fail supports(digest, PBKDF2)-Fail supports(getPublicKey, PBKDF2)-Fail supports works with algorithm objects-Fail supports returns false for algorithm objects with invalid parameters-Fail supports validates HKDF SHA-1 output length-Fail supports validates HKDF SHA-256 output length-Fail supports validates HKDF SHA-384 output length-Fail supports validates HKDF SHA-512 output length-Fail supports validates HKDF output length for deriveKey-Fail supports validates HMAC import length-Fail supports rejects RSASSA-PKCS1-v1_5 generateKey with a modulus shorter than 4 bits-Fail supports rejects RSASSA-PKCS1-v1_5 generateKey with a public exponent less than 3-Fail supports rejects RSASSA-PKCS1-v1_5 generateKey with an even public exponent-Fail supports rejects RSASSA-PKCS1-v1_5 generateKey with a public exponent equal to 2^modulusLength - 1-Fail supports rejects RSA-PSS generateKey with a modulus shorter than 4 bits-Fail supports rejects RSA-PSS generateKey with a public exponent less than 3-Fail supports rejects RSA-PSS generateKey with an even public exponent-Fail supports rejects RSA-PSS generateKey with a public exponent equal to 2^modulusLength - 1-Fail supports rejects RSA-OAEP generateKey with a modulus shorter than 4 bits-Fail supports rejects RSA-OAEP generateKey with a public exponent less than 3-Fail supports rejects RSA-OAEP generateKey with an even public exponent-Fail supports rejects RSA-OAEP generateKey with a public exponent equal to 2^modulusLength - 1-Fail supports validates ECDSA import namedCurve-Fail supports validates ECDH import namedCurve-Fail supports validates ECDH P-256 deriveBits length-Fail supports validates ECDH P-384 deriveBits length-Fail supports validates ECDH P-521 deriveBits length-Fail supports validates X25519 deriveBits length-Fail supports validates the ECDH public key-Fail supports validates the X25519 public key-Fail supports derives the ECDH output limit from the public curve-Fail Common algorithm and operation combinations work-Fail Invalid algorithm and operation combinations fail-Fail deriveKey tests-Fail deriveKey promise tests-Fail exportKey tests-Fail wrapKey tests\ No newline at end of file+200 Pass+Pass SubtleCrypto.supports method exists+Pass supports returns false for invalid operations+Pass supports returns false for invalid algorithms+Pass supports(generateKey, RSASSA-PKCS1-v1_5)+Pass supports(importKey, RSASSA-PKCS1-v1_5)+Pass supports(sign, RSASSA-PKCS1-v1_5)+Pass supports(verify, RSASSA-PKCS1-v1_5)+Pass supports(encrypt, RSASSA-PKCS1-v1_5)+Pass supports(decrypt, RSASSA-PKCS1-v1_5)+Pass supports(deriveBits, RSASSA-PKCS1-v1_5)+Pass supports(digest, RSASSA-PKCS1-v1_5)+Pass supports(getPublicKey, RSASSA-PKCS1-v1_5)+Pass supports(generateKey, RSA-PSS)+Pass supports(importKey, RSA-PSS)+Pass supports(sign, RSA-PSS)+Pass supports(verify, RSA-PSS)+Pass supports(encrypt, RSA-PSS)+Pass supports(decrypt, RSA-PSS)+Pass supports(deriveBits, RSA-PSS)+Pass supports(digest, RSA-PSS)+Pass supports(getPublicKey, RSA-PSS)+Pass supports(generateKey, RSA-OAEP)+Pass supports(importKey, RSA-OAEP)+Pass supports(sign, RSA-OAEP)+Pass supports(verify, RSA-OAEP)+Pass supports(encrypt, RSA-OAEP)+Pass supports(decrypt, RSA-OAEP)+Pass supports(deriveBits, RSA-OAEP)+Pass supports(digest, RSA-OAEP)+Pass supports(getPublicKey, RSA-OAEP)+Pass supports(generateKey, ECDSA)+Pass supports(importKey, ECDSA)+Pass supports(sign, ECDSA)+Pass supports(verify, ECDSA)+Pass supports(encrypt, ECDSA)+Pass supports(decrypt, ECDSA)+Pass supports(deriveBits, ECDSA)+Pass supports(digest, ECDSA)+Pass supports(getPublicKey, ECDSA)+Pass supports(generateKey, ECDH)+Pass supports(importKey, ECDH)+Pass supports(sign, ECDH)+Pass supports(verify, ECDH)+Pass supports(encrypt, ECDH)+Pass supports(decrypt, ECDH)+Pass supports(deriveBits, ECDH)+Pass supports(digest, ECDH)+Pass supports(getPublicKey, ECDH)+Pass supports(generateKey, Ed25519)+Pass supports(importKey, Ed25519)+Pass supports(sign, Ed25519)+Pass supports(verify, Ed25519)+Pass supports(encrypt, Ed25519)+Pass supports(decrypt, Ed25519)+Pass supports(deriveBits, Ed25519)+Pass supports(digest, Ed25519)+Pass supports(getPublicKey, Ed25519)+Pass supports(generateKey, X25519)+Pass supports(importKey, X25519)+Pass supports(sign, X25519)+Pass supports(verify, X25519)+Pass supports(encrypt, X25519)+Pass supports(decrypt, X25519)+Pass supports(deriveBits, X25519)+Pass supports(digest, X25519)+Pass supports(getPublicKey, X25519)+Pass supports(generateKey, AES-CBC)+Pass supports(importKey, AES-CBC)+Pass supports(sign, AES-CBC)+Pass supports(verify, AES-CBC)+Pass supports(encrypt, AES-CBC)+Pass supports(decrypt, AES-CBC)+Pass supports(deriveBits, AES-CBC)+Pass supports(digest, AES-CBC)+Pass supports(getPublicKey, AES-CBC)+Pass supports(generateKey, AES-CTR)+Pass supports(importKey, AES-CTR)+Pass supports(sign, AES-CTR)+Pass supports(verify, AES-CTR)+Pass supports(encrypt, AES-CTR)+Pass supports(decrypt, AES-CTR)+Pass supports(deriveBits, AES-CTR)+Pass supports(digest, AES-CTR)+Pass supports(getPublicKey, AES-CTR)+Pass supports(generateKey, AES-GCM)+Pass supports(importKey, AES-GCM)+Pass supports(sign, AES-GCM)+Pass supports(verify, AES-GCM)+Pass supports(encrypt, AES-GCM)+Pass supports(decrypt, AES-GCM)+Pass supports(deriveBits, AES-GCM)+Pass supports(digest, AES-GCM)+Pass supports(getPublicKey, AES-GCM)+Pass supports(generateKey, AES-KW)+Pass supports(importKey, AES-KW)+Pass supports(sign, AES-KW)+Pass supports(verify, AES-KW)+Pass supports(encrypt, AES-KW)+Pass supports(decrypt, AES-KW)+Pass supports(deriveBits, AES-KW)+Pass supports(digest, AES-KW)+Pass supports(getPublicKey, AES-KW)+Pass supports(generateKey, HMAC)+Pass supports(importKey, HMAC)+Pass supports(sign, HMAC)+Pass supports(verify, HMAC)+Pass supports(encrypt, HMAC)+Pass supports(decrypt, HMAC)+Pass supports(deriveBits, HMAC)+Pass supports(digest, HMAC)+Pass supports(getPublicKey, HMAC)+Pass supports(generateKey, SHA-1)+Pass supports(importKey, SHA-1)+Pass supports(sign, SHA-1)+Pass supports(verify, SHA-1)+Pass supports(encrypt, SHA-1)+Pass supports(decrypt, SHA-1)+Pass supports(deriveBits, SHA-1)+Pass supports(digest, SHA-1)+Pass supports(getPublicKey, SHA-1)+Pass supports(generateKey, SHA-256)+Pass supports(importKey, SHA-256)+Pass supports(sign, SHA-256)+Pass supports(verify, SHA-256)+Pass supports(encrypt, SHA-256)+Pass supports(decrypt, SHA-256)+Pass supports(deriveBits, SHA-256)+Pass supports(digest, SHA-256)+Pass supports(getPublicKey, SHA-256)+Pass supports(generateKey, SHA-384)+Pass supports(importKey, SHA-384)+Pass supports(sign, SHA-384)+Pass supports(verify, SHA-384)+Pass supports(encrypt, SHA-384)+Pass supports(decrypt, SHA-384)+Pass supports(deriveBits, SHA-384)+Pass supports(digest, SHA-384)+Pass supports(getPublicKey, SHA-384)+Pass supports(generateKey, SHA-512)+Pass supports(importKey, SHA-512)+Pass supports(sign, SHA-512)+Pass supports(verify, SHA-512)+Pass supports(encrypt, SHA-512)+Pass supports(decrypt, SHA-512)+Pass supports(deriveBits, SHA-512)+Pass supports(digest, SHA-512)+Pass supports(getPublicKey, SHA-512)+Pass supports(generateKey, HKDF)+Pass supports(importKey, HKDF)+Pass supports(sign, HKDF)+Pass supports(verify, HKDF)+Pass supports(encrypt, HKDF)+Pass supports(decrypt, HKDF)+Pass supports(deriveBits, HKDF)+Pass supports(digest, HKDF)+Pass supports(getPublicKey, HKDF)+Pass supports(generateKey, PBKDF2)+Pass supports(importKey, PBKDF2)+Pass supports(sign, PBKDF2)+Pass supports(verify, PBKDF2)+Pass supports(encrypt, PBKDF2)+Pass supports(decrypt, PBKDF2)+Pass supports(deriveBits, PBKDF2)+Pass supports(digest, PBKDF2)+Pass supports(getPublicKey, PBKDF2)+Pass supports works with algorithm objects+Pass supports returns false for algorithm objects with invalid parameters+Pass supports validates HKDF SHA-1 output length+Pass supports validates HKDF SHA-256 output length+Pass supports validates HKDF SHA-384 output length+Pass supports validates HKDF SHA-512 output length+Pass supports validates HKDF output length for deriveKey+Pass supports validates HMAC import length+Pass supports rejects RSASSA-PKCS1-v1_5 generateKey with a modulus shorter than 4 bits+Pass supports rejects RSASSA-PKCS1-v1_5 generateKey with a public exponent less than 3+Pass supports rejects RSASSA-PKCS1-v1_5 generateKey with an even public exponent+Pass supports rejects RSASSA-PKCS1-v1_5 generateKey with a public exponent equal to 2^modulusLength - 1+Pass supports rejects RSA-PSS generateKey with a modulus shorter than 4 bits+Pass supports rejects RSA-PSS generateKey with a public exponent less than 3+Pass supports rejects RSA-PSS generateKey with an even public exponent+Pass supports rejects RSA-PSS generateKey with a public exponent equal to 2^modulusLength - 1+Pass supports rejects RSA-OAEP generateKey with a modulus shorter than 4 bits+Pass supports rejects RSA-OAEP generateKey with a public exponent less than 3+Pass supports rejects RSA-OAEP generateKey with an even public exponent+Pass supports rejects RSA-OAEP generateKey with a public exponent equal to 2^modulusLength - 1+Pass supports validates ECDSA import namedCurve+Pass supports validates ECDH import namedCurve+Pass supports validates ECDH P-256 deriveBits length+Pass supports validates ECDH P-384 deriveBits length+Pass supports validates ECDH P-521 deriveBits length+Pass supports validates X25519 deriveBits length+Pass supports validates the ECDH public key+Pass supports validates the X25519 public key+Pass supports derives the ECDH output limit from the public curve+Pass Common algorithm and operation combinations work+Pass Invalid algorithm and operation combinations fail+Pass deriveKey tests+Pass deriveKey promise tests+Pass exportKey tests+Pass wrapKey tests\ No newline at end of filediff --git a/Tests/LibWeb/Text/input/Crypto/SubtleCrypto-supports-implementation-limits.html b/Tests/LibWeb/Text/input/Crypto/SubtleCrypto-supports-implementation-limits.htmlnew file mode 100644index 00000000000..50df7057d8f--- /dev/null+++ b/Tests/LibWeb/Text/input/Crypto/SubtleCrypto-supports-implementation-limits.html@@ -0,0 +1,73 @@+<!doctype html>+<script src="../include.js"></script>+<script>+ promiseTest(async () => {+ const subtle = crypto.subtle;+ const data = new Uint8Array([1, 2, 3]);++ async function check(label, operation, algorithm, length, run) {+ const supported = length === undefined ? SubtleCrypto.supports(operation, algorithm) : SubtleCrypto.supports(operation, algorithm, length);+ let outcome;+ try {+ await run(algorithm);+ outcome = "ok";+ } catch (error) {+ outcome = error.name;+ }+ println(`${label}: supports ${supported}, ${operation} ${outcome}`);+ }++ const digest = algorithm => subtle.digest(algorithm, data);+ await check("cSHAKE128", "digest", { name: "cSHAKE128", outputLength: 256 }, undefined, digest);+ await check("cSHAKE128 with customization", "digest", { name: "cSHAKE128", outputLength: 256, customization: new Uint8Array([1]) }, undefined, digest);+ await check("cSHAKE256 with function name", "digest", { name: "cSHAKE256", outputLength: 256, functionName: new Uint8Array([1]) }, undefined, digest);+ await check("cSHAKE128 with partial byte output length", "digest", { name: "cSHAKE128", outputLength: 12 }, undefined, digest);++ const generateKey = algorithm => subtle.generateKey(algorithm, false, ["sign"]);+ await check("HMAC SHA-256", "generateKey", { name: "HMAC", hash: "SHA-256" }, undefined, generateKey);+ await check("HMAC SHA3-256", "generateKey", { name: "HMAC", hash: "SHA3-256" }, undefined, generateKey);+ await check("HMAC SHA3-256 with length", "generateKey", { name: "HMAC", hash: "SHA3-256", length: 256 }, undefined, generateKey);++ for (const name of ["RSA-OAEP", "RSA-PSS", "RSASSA-PKCS1-v1_5"]) {+ const usages = name === "RSA-OAEP" ? ["decrypt"] : ["sign"];+ const generateRsaKey = algorithm => subtle.generateKey(algorithm, false, usages);+ for (const modulusLength of [512, 511]) {+ const algorithm = { name, modulusLength, publicExponent: new Uint8Array([1, 0, 1]), hash: "SHA-256" };+ await check(`${name} ${modulusLength}-bit modulus`, "generateKey", algorithm, undefined, generateRsaKey);+ }+ }++ const ecdsaKeys = await subtle.generateKey({ name: "ECDSA", namedCurve: "P-256" }, false, ["sign"]);+ const ecdsaSign = algorithm => subtle.sign(algorithm, ecdsaKeys.privateKey, data);+ await check("ECDSA SHA-256", "sign", { name: "ECDSA", hash: "SHA-256" }, undefined, ecdsaSign);+ await check("ECDSA SHA3-256", "sign", { name: "ECDSA", hash: "SHA3-256" }, undefined, ecdsaSign);++ const pbkdf2Key = await subtle.importKey("raw", new Uint8Array(16), "PBKDF2", false, ["deriveBits"]);+ const pbkdf2 = algorithm => subtle.deriveBits(algorithm, pbkdf2Key, 256);+ await check("PBKDF2 SHA-256", "deriveBits", { name: "PBKDF2", hash: "SHA-256", salt: new Uint8Array(8), iterations: 1 }, 256, pbkdf2);+ await check("PBKDF2 SHA3-256", "deriveBits", { name: "PBKDF2", hash: "SHA3-256", salt: new Uint8Array(8), iterations: 1 }, 256, pbkdf2);++ const kmacKey = await subtle.generateKey({ name: "KMAC128" }, false, ["sign"]);+ const kmacSign = algorithm => subtle.sign(algorithm, kmacKey, data);+ await check("KMAC128 output length 256", "sign", { name: "KMAC128", outputLength: 256 }, undefined, kmacSign);+ await check("KMAC128 output length 1", "sign", { name: "KMAC128", outputLength: 1 }, undefined, kmacSign);+ await check("KMAC128 512-byte customization", "sign", { name: "KMAC128", outputLength: 256, customization: new Uint8Array(512) }, undefined, kmacSign);+ await check("KMAC128 513-byte customization", "sign", { name: "KMAC128", outputLength: 256, customization: new Uint8Array(513) }, undefined, kmacSign);+ const kmacImport = algorithm => subtle.importKey("raw-secret", new Uint8Array(Math.ceil(algorithm.length / 8)), algorithm, false, ["sign"]);+ await check("KMAC128 import length 8", "importKey", { name: "KMAC128", length: 8 }, undefined, kmacImport);+ await check("KMAC128 import length 1", "importKey", { name: "KMAC128", length: 1 }, undefined, kmacImport);+ await check("KMAC128 import length 4104", "importKey", { name: "KMAC128", length: 4104 }, undefined, kmacImport);++ for (const name of ["AES-GCM", "AES-OCB"]) {+ const key = await subtle.generateKey({ name, length: 128 }, false, ["encrypt"]);+ const encrypt = algorithm => subtle.encrypt(algorithm, key, data);+ await check(`${name} 12-byte IV`, "encrypt", { name, iv: new Uint8Array(12) }, undefined, encrypt);+ await check(`${name} empty IV`, "encrypt", { name, iv: new Uint8Array(0) }, undefined, encrypt);+ }++ const argon2Key = await subtle.importKey("raw-secret", new Uint8Array(16), "Argon2id", false, ["deriveBits"]);+ const argon2 = algorithm => subtle.deriveBits(algorithm, argon2Key, 256);+ await check("Argon2id 8-byte nonce", "deriveBits", { name: "Argon2id", nonce: new Uint8Array(8), parallelism: 1, memory: 8, passes: 1 }, 256, argon2);+ await check("Argon2id 7-byte nonce", "deriveBits", { name: "Argon2id", nonce: new Uint8Array(7), parallelism: 1, memory: 8, passes: 1 }, 256, argon2);+ });+</script>