Truly independent web browser
Tests/LibWeb: Import WebCrypto getPublicKey() and supports() tests
Jelle Raaijmakers5303b4cc60b2
diff --git a/Tests/LibWeb/TestConfig.ini b/Tests/LibWeb/TestConfig.iniindex 843da51b904..7fc76fc2d6e 100644--- a/Tests/LibWeb/TestConfig.ini+++ b/Tests/LibWeb/TestConfig.ini@@ -553,6 +553,7 @@ Text/input/wpt-import/svg/idlharness.window.htmlText/input/wpt-import/trusted-types/idlharness.window.htmlText/input/wpt-import/web-animations/idlharness.window.htmlText/input/wpt-import/webaudio/idlharness.https.window.html+Text/input/wpt-import/WebCryptoAPI/modern-algos/idlharness.https.any.html; Unable to fetch the test resources PNG with CORS error.; Fails in other browsers too when loaded from file://.diff --git a/Tests/LibWeb/Text/expected/wpt-import/WebCryptoAPI/modern-algos/getPublicKey.https.any.txt b/Tests/LibWeb/Text/expected/wpt-import/WebCryptoAPI/modern-algos/getPublicKey.https.any.txtnew file mode 100644index 00000000000..31cf7a31d60--- /dev/null+++ b/Tests/LibWeb/Text/expected/wpt-import/WebCryptoAPI/modern-algos/getPublicKey.https.any.txt@@ -0,0 +1,48 @@+Harness status: OK++Found 43 tests++43 Fail+Fail getPublicKey works for ECDH+Fail getPublicKey works for ECDSA+Fail getPublicKey works for Ed25519+Fail getPublicKey works for Ed448+Fail getPublicKey works for RSA-OAEP+Fail getPublicKey works for RSA-PSS+Fail getPublicKey works for RSASSA-PKCS1-v1_5+Fail getPublicKey works for X25519+Fail getPublicKey works for X448+Fail getPublicKey works for ML-DSA-44+Fail getPublicKey works for ML-DSA-65+Fail getPublicKey works for ML-DSA-87+Fail getPublicKey works for ML-KEM-512+Fail getPublicKey works for ML-KEM-768+Fail getPublicKey works for ML-KEM-1024+Fail getPublicKey works for MLKEM768-P256+Fail getPublicKey works for MLKEM768-X25519+Fail getPublicKey works for MLKEM1024-P384+Fail Derived public key is functionally equivalent to original public key+Fail getPublicKey works with empty usages for ECDH+Fail getPublicKey works with empty usages for ECDSA+Fail getPublicKey works with empty usages for Ed25519+Fail getPublicKey works with empty usages for Ed448+Fail getPublicKey works with empty usages for RSA-OAEP+Fail getPublicKey works with empty usages for RSA-PSS+Fail getPublicKey works with empty usages for RSASSA-PKCS1-v1_5+Fail getPublicKey works with empty usages for X25519+Fail getPublicKey works with empty usages for X448+Fail getPublicKey works with empty usages for ML-DSA-44+Fail getPublicKey works with empty usages for ML-DSA-65+Fail getPublicKey works with empty usages for ML-DSA-87+Fail getPublicKey works with empty usages for ML-KEM-512+Fail getPublicKey works with empty usages for ML-KEM-768+Fail getPublicKey works with empty usages for ML-KEM-1024+Fail getPublicKey works with empty usages for MLKEM768-P256+Fail getPublicKey works with empty usages for MLKEM768-X25519+Fail getPublicKey works with empty usages for MLKEM1024-P384+Fail getPublicKey rejects with InvalidAccessError when given a public key+Fail getPublicKey rejects with NotSupportedError for AES-GCM symmetric keys+Fail getPublicKey rejects with NotSupportedError for HMAC symmetric keys+Fail getPublicKey rejects with SyntaxError for invalid usages+Fail getPublicKey rejects with SyntaxError when any usage is invalid for the algorithm+Fail getPublicKey method is available\ No newline at end of filediff --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.txtnew file mode 100644index 00000000000..51da42179ab--- /dev/null+++ b/Tests/LibWeb/Text/expected/wpt-import/WebCryptoAPI/modern-algos/idlharness.https.any.txt@@ -0,0 +1,34 @@+Harness status: OK++Found 28 tests++21 Pass+7 Fail+Pass idl_test setup+Pass idl_test validation+Pass Partial interface SubtleCrypto: original interface defined+Pass Partial interface SubtleCrypto: valid exposure set+Pass Partial interface SubtleCrypto: member names are unique+Pass Partial dictionary JsonWebKey: original dictionary defined+Pass Partial dictionary JsonWebKey: member names are unique+Pass SubtleCrypto interface: operation encapsulateKey(AlgorithmIdentifier, CryptoKey, AlgorithmIdentifier, boolean, sequence<KeyUsage>)+Pass SubtleCrypto interface: operation encapsulateBits(AlgorithmIdentifier, CryptoKey)+Pass SubtleCrypto interface: operation decapsulateKey(AlgorithmIdentifier, CryptoKey, BufferSource, AlgorithmIdentifier, boolean, sequence<KeyUsage>)+Pass SubtleCrypto interface: operation decapsulateBits(AlgorithmIdentifier, CryptoKey, BufferSource)+Fail 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: crypto.subtle must inherit property "encapsulateKey(AlgorithmIdentifier, CryptoKey, AlgorithmIdentifier, boolean, sequence<KeyUsage>)" with the proper type+Pass SubtleCrypto interface: calling encapsulateKey(AlgorithmIdentifier, CryptoKey, AlgorithmIdentifier, boolean, sequence<KeyUsage>) on crypto.subtle with too few arguments must throw TypeError+Pass SubtleCrypto interface: crypto.subtle must inherit property "encapsulateBits(AlgorithmIdentifier, CryptoKey)" with the proper type+Pass SubtleCrypto interface: calling encapsulateBits(AlgorithmIdentifier, CryptoKey) on crypto.subtle with too few arguments must throw TypeError+Pass SubtleCrypto interface: crypto.subtle must inherit property "decapsulateKey(AlgorithmIdentifier, CryptoKey, BufferSource, AlgorithmIdentifier, boolean, sequence<KeyUsage>)" with the proper type+Pass SubtleCrypto interface: calling decapsulateKey(AlgorithmIdentifier, CryptoKey, BufferSource, AlgorithmIdentifier, boolean, sequence<KeyUsage>) on crypto.subtle with too few arguments must throw TypeError+Pass SubtleCrypto interface: crypto.subtle must inherit property "decapsulateBits(AlgorithmIdentifier, CryptoKey, BufferSource)" with the proper type+Pass SubtleCrypto interface: calling decapsulateBits(AlgorithmIdentifier, CryptoKey, BufferSource) on crypto.subtle with too few arguments must throw TypeError+Fail SubtleCrypto interface: crypto.subtle must inherit property "getPublicKey(CryptoKey, sequence<KeyUsage>)" with the proper type+Fail SubtleCrypto interface: calling getPublicKey(CryptoKey, sequence<KeyUsage>) on crypto.subtle with too few arguments must throw TypeError+Pass 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: 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 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.txtnew file mode 100644index 00000000000..31e0089ae15--- /dev/null+++ b/Tests/LibWeb/Text/expected/wpt-import/WebCryptoAPI/modern-algos/supports-modern.https.any.txt@@ -0,0 +1,152 @@+Harness status: OK++Found 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)+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)+Fail supports(encapsulateKey, MLKEM768-P256)+Fail supports(encapsulateBits, MLKEM768-P256)+Fail supports(decapsulateKey, MLKEM768-P256)+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)+Fail supports(encapsulateKey, MLKEM768-X25519)+Fail supports(encapsulateBits, MLKEM768-X25519)+Fail supports(decapsulateKey, MLKEM768-X25519)+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)+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 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.txtnew file mode 100644index 00000000000..a9bf2ff35c9--- /dev/null+++ b/Tests/LibWeb/Text/expected/wpt-import/WebCryptoAPI/modern-algos/supports.https.any.txt@@ -0,0 +1,205 @@+Harness status: OK++Found 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 filediff --git a/Tests/LibWeb/Text/input/wpt-import/WebCryptoAPI/modern-algos/getPublicKey.https.any.html b/Tests/LibWeb/Text/input/wpt-import/WebCryptoAPI/modern-algos/getPublicKey.https.any.htmlnew file mode 100644index 00000000000..91772ca0bd7--- /dev/null+++ b/Tests/LibWeb/Text/input/wpt-import/WebCryptoAPI/modern-algos/getPublicKey.https.any.html@@ -0,0 +1,16 @@+<!doctype html>+<meta charset=utf-8>+<title>WebCryptoAPI: getPublicKey() method</title>+<meta name="timeout" content="long">+<script>+self.GLOBAL = {+ isWindow: function() { return true; },+ isWorker: function() { return false; },+ isShadowRealm: function() { return false; },+};+</script>+<script src="../../resources/testharness.js"></script>+<script src="../../resources/testharnessreport.js"></script>+<script src="../util/helpers.js"></script>+<div id=log></div>+<script src="../../WebCryptoAPI/modern-algos/getPublicKey.https.any.js"></script>diff --git a/Tests/LibWeb/Text/input/wpt-import/WebCryptoAPI/modern-algos/getPublicKey.https.any.js b/Tests/LibWeb/Text/input/wpt-import/WebCryptoAPI/modern-algos/getPublicKey.https.any.jsnew file mode 100644index 00000000000..e5537c900dd--- /dev/null+++ b/Tests/LibWeb/Text/input/wpt-import/WebCryptoAPI/modern-algos/getPublicKey.https.any.js@@ -0,0 +1,321 @@+// META: title=WebCryptoAPI: getPublicKey() method+// META: timeout=long+// META: script=../util/helpers.js++"use strict";++const algorithms = [+ {+ name: "ECDH",+ generateKeyParams: { name: "ECDH", namedCurve: "P-256" },+ usages: ["deriveKey", "deriveBits"],+ publicKeyUsages: []+ },+ {+ name: "ECDSA",+ generateKeyParams: { name: "ECDSA", namedCurve: "P-256" },+ usages: ["sign", "verify"],+ publicKeyUsages: ["verify"]+ },+ {+ name: "Ed25519",+ generateKeyParams: { name: "Ed25519" },+ usages: ["sign", "verify"],+ publicKeyUsages: ["verify"]+ },+ {+ name: "Ed448",+ generateKeyParams: { name: "Ed448" },+ usages: ["sign", "verify"],+ publicKeyUsages: ["verify"]+ },+ {+ name: "RSA-OAEP",+ generateKeyParams: {+ name: "RSA-OAEP",+ modulusLength: 2048,+ publicExponent: new Uint8Array([1, 0, 1]),+ hash: "SHA-256"+ },+ usages: ["encrypt", "decrypt"],+ publicKeyUsages: ["encrypt"]+ },+ {+ name: "RSA-PSS",+ generateKeyParams: {+ name: "RSA-PSS",+ modulusLength: 2048,+ publicExponent: new Uint8Array([1, 0, 1]),+ hash: "SHA-256"+ },+ usages: ["sign", "verify"],+ publicKeyUsages: ["verify"]+ },+ {+ name: "RSASSA-PKCS1-v1_5",+ generateKeyParams: {+ name: "RSASSA-PKCS1-v1_5",+ modulusLength: 2048,+ publicExponent: new Uint8Array([1, 0, 1]),+ hash: "SHA-256"+ },+ usages: ["sign", "verify"],+ publicKeyUsages: ["verify"]+ },+ {+ name: "X25519",+ generateKeyParams: { name: "X25519" },+ usages: ["deriveKey", "deriveBits"],+ publicKeyUsages: []+ },+ {+ name: "X448",+ generateKeyParams: { name: "X448" },+ usages: ["deriveKey", "deriveBits"],+ publicKeyUsages: []+ },+ {+ name: "ML-DSA-44",+ generateKeyParams: { name: "ML-DSA-44" },+ usages: ["sign", "verify"],+ publicKeyUsages: ["verify"]+ },+ {+ name: "ML-DSA-65",+ generateKeyParams: { name: "ML-DSA-65" },+ usages: ["sign", "verify"],+ publicKeyUsages: ["verify"]+ },+ {+ name: "ML-DSA-87",+ generateKeyParams: { name: "ML-DSA-87" },+ usages: ["sign", "verify"],+ publicKeyUsages: ["verify"]+ },+ {+ name: "ML-KEM-512",+ generateKeyParams: { name: "ML-KEM-512" },+ usages: ["encapsulateBits", "encapsulateKey", "decapsulateBits", "decapsulateKey"],+ publicKeyUsages: ["encapsulateBits", "encapsulateKey"]+ },+ {+ name: "ML-KEM-768",+ generateKeyParams: { name: "ML-KEM-768" },+ usages: ["encapsulateBits", "encapsulateKey", "decapsulateBits", "decapsulateKey"],+ publicKeyUsages: ["encapsulateBits", "encapsulateKey"]+ },+ {+ name: "ML-KEM-1024",+ generateKeyParams: { name: "ML-KEM-1024" },+ usages: ["encapsulateBits", "encapsulateKey", "decapsulateBits", "decapsulateKey"],+ publicKeyUsages: ["encapsulateBits", "encapsulateKey"]+ },+ {+ name: "MLKEM768-P256",+ generateKeyParams: { name: "MLKEM768-P256" },+ usages: ["encapsulateBits", "encapsulateKey", "decapsulateBits", "decapsulateKey"],+ publicKeyUsages: ["encapsulateBits", "encapsulateKey"]+ },+ {+ name: "MLKEM768-X25519",+ generateKeyParams: { name: "MLKEM768-X25519" },+ usages: ["encapsulateBits", "encapsulateKey", "decapsulateBits", "decapsulateKey"],+ publicKeyUsages: ["encapsulateBits", "encapsulateKey"]+ },+ {+ name: "MLKEM1024-P384",+ generateKeyParams: { name: "MLKEM1024-P384" },+ usages: ["encapsulateBits", "encapsulateKey", "decapsulateBits", "decapsulateKey"],+ publicKeyUsages: ["encapsulateBits", "encapsulateKey"]+ }+];++// Test basic functionality for supported algorithms+algorithms.forEach(function(algorithm) {+ promise_test(async function(t) {+ // Generate a key pair+ const keyPair = await crypto.subtle.generateKey(+ algorithm.generateKeyParams,+ false, // extractable+ algorithm.usages+ );++ assert_true(keyPair.privateKey instanceof CryptoKey, "Generated private key");+ assert_equals(keyPair.privateKey.type, "private", "Private key type");++ // Test getPublicKey with valid usages+ const publicKey = await crypto.subtle.getPublicKey(+ keyPair.privateKey,+ algorithm.publicKeyUsages+ );++ // Verify the returned public key+ assert_true(publicKey instanceof CryptoKey, "getPublicKey returns a CryptoKey");+ assert_equals(publicKey.type, "public", "Returned key is public");+ assert_equals(publicKey.algorithm.name, algorithm.name, "Algorithm name matches");+ assert_true(publicKey.extractable, "Public key is extractable");++ // Verify usages+ assert_equals(publicKey.usages.length, algorithm.publicKeyUsages.length, "Usage count matches");+ algorithm.publicKeyUsages.forEach(function(usage) {+ assert_true(publicKey.usages.includes(usage), `Has ${usage} usage`);+ });++ // Verify that the derived public key matches the original public key+ // by comparing their exported forms+ const exportFormat = algorithm.name.startsWith("MLKEM") ? "raw-public" : "spki";+ const originalExported = await crypto.subtle.exportKey(exportFormat, keyPair.publicKey);+ const derivedExported = await crypto.subtle.exportKey(exportFormat, publicKey);++ assert_array_equals(+ new Uint8Array(originalExported),+ new Uint8Array(derivedExported),+ "Exported public keys match"+ );++ }, `getPublicKey works for ${algorithm.name}`);+});++// Test functional equivalence - ensure derived public key works for crypto operations+promise_test(async function(t) {+ const keyPair = await crypto.subtle.generateKey(+ { name: "ECDSA", namedCurve: "P-256" },+ false,+ ["sign", "verify"]+ );++ const derivedPublicKey = await crypto.subtle.getPublicKey(+ keyPair.privateKey,+ ["verify"]+ );++ // Create test data+ const data = new TextEncoder().encode("test message");++ // Sign with private key+ const signature = await crypto.subtle.sign(+ { name: "ECDSA", hash: "SHA-256" },+ keyPair.privateKey,+ data+ );++ // Verify with both original and derived public keys+ const verifyOriginal = await crypto.subtle.verify(+ { name: "ECDSA", hash: "SHA-256" },+ keyPair.publicKey,+ signature,+ data+ );++ const verifyDerived = await crypto.subtle.verify(+ { name: "ECDSA", hash: "SHA-256" },+ derivedPublicKey,+ signature,+ data+ );++ assert_true(verifyOriginal, "Original public key verifies signature");+ assert_true(verifyDerived, "Derived public key verifies signature");++}, "Derived public key is functionally equivalent to original public key");++// Test with empty usages array+algorithms.forEach(function(algorithm) {+ promise_test(async function(t) {+ const keyPair = await crypto.subtle.generateKey(+ algorithm.generateKeyParams,+ false,+ algorithm.usages+ );++ // Test with empty usages array+ const publicKey = await crypto.subtle.getPublicKey(+ keyPair.privateKey,+ []+ );++ assert_true(publicKey instanceof CryptoKey, "getPublicKey returns a CryptoKey");+ assert_equals(publicKey.type, "public", "Returned key is public");+ assert_equals(publicKey.usages.length, 0, "Public key has no usages");++ }, `getPublicKey works with empty usages for ${algorithm.name}`);+});++// Test error cases++// Test with non-private key (should throw InvalidAccessError)+promise_test(async function(t) {+ const keyPair = await crypto.subtle.generateKey(+ { name: "ECDSA", namedCurve: "P-256" },+ false,+ ["sign", "verify"]+ );++ await promise_rejects_dom(t, "InvalidAccessError",+ crypto.subtle.getPublicKey(keyPair.publicKey, ["verify"]),+ "getPublicKey should reject when called with a public key"+ );+}, "getPublicKey rejects with InvalidAccessError when given a public key");++// Test with symmetric keys (should throw NotSupportedError for non-private keys)+promise_test(async function(t) {+ const aesKey = await crypto.subtle.generateKey(+ { name: "AES-GCM", length: 256 },+ false,+ ["encrypt", "decrypt"]+ );++ await promise_rejects_dom(t, "NotSupportedError",+ crypto.subtle.getPublicKey(aesKey, []),+ "getPublicKey should reject AES-GCM keys"+ );+}, "getPublicKey rejects with NotSupportedError for AES-GCM symmetric keys");++promise_test(async function(t) {+ const hmacKey = await crypto.subtle.generateKey(+ { name: "HMAC", hash: "SHA-256" },+ false,+ ["sign", "verify"]+ );++ await promise_rejects_dom(t, "NotSupportedError",+ crypto.subtle.getPublicKey(hmacKey, []),+ "getPublicKey should reject HMAC keys"+ );+}, "getPublicKey rejects with NotSupportedError for HMAC symmetric keys");++// Test with invalid usages for the algorithm+promise_test(async function(t) {+ const keyPair = await crypto.subtle.generateKey(+ { name: "ECDSA", namedCurve: "P-256" },+ false,+ ["sign", "verify"]+ );++ // Try to use "encrypt" usage with ECDSA (not supported for ECDSA public keys)+ await promise_rejects_dom(t, "SyntaxError",+ crypto.subtle.getPublicKey(keyPair.privateKey, ["encrypt"]),+ "getPublicKey should reject invalid usages for the algorithm"+ );+}, "getPublicKey rejects with SyntaxError for invalid usages");++// Test with mixed valid and invalid usages+promise_test(async function(t) {+ const keyPair = await crypto.subtle.generateKey(+ { name: "ECDSA", namedCurve: "P-256" },+ false,+ ["sign", "verify"]+ );++ // Mix valid ("verify") and invalid ("encrypt") usages+ await promise_rejects_dom(t, "SyntaxError",+ crypto.subtle.getPublicKey(keyPair.privateKey, ["verify", "encrypt"]),+ "getPublicKey should reject when any usage is invalid"+ );+}, "getPublicKey rejects with SyntaxError when any usage is invalid for the algorithm");++// Test that the method exists+test(function() {+ assert_true("getPublicKey" in crypto.subtle, "getPublicKey method exists on SubtleCrypto");+ assert_equals(typeof crypto.subtle.getPublicKey, "function", "getPublicKey is a function");+}, "getPublicKey method is available");diff --git a/Tests/LibWeb/Text/input/wpt-import/WebCryptoAPI/modern-algos/idlharness.https.any.html b/Tests/LibWeb/Text/input/wpt-import/WebCryptoAPI/modern-algos/idlharness.https.any.htmlnew file mode 100644index 00000000000..ec9a5dd80c3--- /dev/null+++ b/Tests/LibWeb/Text/input/wpt-import/WebCryptoAPI/modern-algos/idlharness.https.any.html@@ -0,0 +1,16 @@+<!doctype html>+<meta charset=utf-8>+<meta name="timeout" content="long">+<script>+self.GLOBAL = {+ isWindow: function() { return true; },+ isWorker: function() { return false; },+ isShadowRealm: function() { return false; },+};+</script>+<script src="../../resources/testharness.js"></script>+<script src="../../resources/testharnessreport.js"></script>+<script src="../../resources/WebIDLParser.js"></script>+<script src="../../resources/idlharness.js"></script>+<div id=log></div>+<script src="../../WebCryptoAPI/modern-algos/idlharness.https.any.js"></script>diff --git a/Tests/LibWeb/Text/input/wpt-import/WebCryptoAPI/modern-algos/idlharness.https.any.js b/Tests/LibWeb/Text/input/wpt-import/WebCryptoAPI/modern-algos/idlharness.https.any.jsnew file mode 100644index 00000000000..5da45f3d576--- /dev/null+++ b/Tests/LibWeb/Text/input/wpt-import/WebCryptoAPI/modern-algos/idlharness.https.any.js@@ -0,0 +1,16 @@+// META: script=/resources/WebIDLParser.js+// META: script=/resources/idlharness.js+// META: timeout=long++// https://wicg.github.io/webcrypto-modern-algos/++idl_test(+ ['webcrypto-modern-algos'],+ ['webcrypto', 'html', 'dom'],+ idl_array => {+ idl_array.add_objects({+ Crypto: ['crypto'],+ SubtleCrypto: ['crypto.subtle']+ });+ }+);diff --git a/Tests/LibWeb/Text/input/wpt-import/WebCryptoAPI/modern-algos/supports-modern.https.any.html b/Tests/LibWeb/Text/input/wpt-import/WebCryptoAPI/modern-algos/supports-modern.https.any.htmlnew file mode 100644index 00000000000..fc8873370e8--- /dev/null+++ b/Tests/LibWeb/Text/input/wpt-import/WebCryptoAPI/modern-algos/supports-modern.https.any.html@@ -0,0 +1,16 @@+<!doctype html>+<meta charset=utf-8>+<title>WebCrypto API: supports method tests for algorithms in https://wicg.github.io/webcrypto-modern-algos/</title>+<script>+self.GLOBAL = {+ isWindow: function() { return true; },+ isWorker: function() { return false; },+ isShadowRealm: function() { return false; },+};+</script>+<script src="../../resources/testharness.js"></script>+<script src="../../resources/testharnessreport.js"></script>+<script src="../util/helpers.js"></script>+<script src="util/supports.js"></script>+<div id=log></div>+<script src="../../WebCryptoAPI/modern-algos/supports-modern.https.any.js"></script>diff --git a/Tests/LibWeb/Text/input/wpt-import/WebCryptoAPI/modern-algos/supports-modern.https.any.js b/Tests/LibWeb/Text/input/wpt-import/WebCryptoAPI/modern-algos/supports-modern.https.any.jsnew file mode 100644index 00000000000..a929468ed05--- /dev/null+++ b/Tests/LibWeb/Text/input/wpt-import/WebCryptoAPI/modern-algos/supports-modern.https.any.js@@ -0,0 +1,181 @@+// META: title=WebCrypto API: supports method tests for algorithms in https://wicg.github.io/webcrypto-modern-algos/+// META: script=../util/helpers.js+// META: script=util/supports.js++'use strict';++const modernAlgorithms = {+ // Asymmetric algorithms+ 'ML-DSA-44': {+ operations: ['generateKey', 'importKey', 'sign', 'verify', 'getPublicKey'],+ },+ 'ML-DSA-65': {+ operations: ['generateKey', 'importKey', 'sign', 'verify', 'getPublicKey'],+ },+ 'ML-DSA-87': {+ operations: ['generateKey', 'importKey', 'sign', 'verify', 'getPublicKey'],+ },+ 'ML-KEM-512': {+ operations: [+ 'generateKey', 'importKey', 'encapsulateKey', 'encapsulateBits',+ 'decapsulateKey', 'decapsulateBits', 'getPublicKey'+ ],+ },+ 'ML-KEM-768': {+ operations: [+ 'generateKey', 'importKey', 'encapsulateKey', 'encapsulateBits',+ 'decapsulateKey', 'decapsulateBits', 'getPublicKey'+ ],+ },+ 'ML-KEM-1024': {+ operations: [+ 'generateKey', 'importKey', 'encapsulateKey', 'encapsulateBits',+ 'decapsulateKey', 'decapsulateBits', 'getPublicKey'+ ],+ },+ 'MLKEM768-P256': {+ operations: [+ 'generateKey', 'importKey', 'encapsulateKey', 'encapsulateBits',+ 'decapsulateKey', 'decapsulateBits', 'getPublicKey'+ ],+ },+ 'MLKEM768-X25519': {+ operations: [+ 'generateKey', 'importKey', 'encapsulateKey', 'encapsulateBits',+ 'decapsulateKey', 'decapsulateBits', 'getPublicKey'+ ],+ },+ 'MLKEM1024-P384': {+ operations: [+ 'generateKey', 'importKey', 'encapsulateKey', 'encapsulateBits',+ 'decapsulateKey', 'decapsulateBits', 'getPublicKey'+ ],+ },++ // Symmetric algorithms+ 'ChaCha20-Poly1305': {+ operations: ['generateKey', 'importKey', 'encrypt', 'decrypt'],+ encryptParams: {name: 'ChaCha20-Poly1305', iv: new Uint8Array(12)},+ },++};++const operations = [+ 'generateKey',+ 'importKey',+ 'sign',+ 'verify',+ 'encrypt',+ 'decrypt',+ 'deriveBits',+ 'digest',+ 'encapsulateKey',+ 'encapsulateBits',+ 'decapsulateKey',+ 'decapsulateBits',+ 'getPublicKey',+];++// Test that supports method exists and is a static method+testSupportsMethod();+++// Test standard WebCrypto algorithms for requested operations+runSupportsTests(modernAlgorithms, operations);++['ML-DSA-44', 'ML-DSA-65', 'ML-DSA-87'].forEach(name => {+ ['sign', 'verify'].forEach(operation => {+ test(() => {+ assert_true(+ SubtleCrypto.supports(operation, {+ name,+ context: new Uint8Array(255),+ }),+ `${name} ${operation} supports a 255-byte context`+ );+ assert_false(+ SubtleCrypto.supports(operation, {+ name,+ context: new Uint8Array(256),+ }),+ `${name} ${operation} rejects a 256-byte context`+ );+ }, `supports validates ${name} ${operation} context length`);+ });+});++const mlKemImportedKeyCases = [+ {+ description: 'a matching HMAC length',+ additionalAlgorithm: {name: 'HMAC', hash: 'SHA-256', length: 256},+ expected: true,+ },+ {+ description: 'an algorithm without raw-secret import',+ additionalAlgorithm: 'Ed25519',+ expected: false,+ },+ {+ description: 'an HMAC length shorter than the shared secret',+ additionalAlgorithm: {name: 'HMAC', hash: 'SHA-256', length: 128},+ expected: false,+ },+ {+ description: 'an HMAC length longer than the shared secret',+ additionalAlgorithm: {name: 'HMAC', hash: 'SHA-256', length: 512},+ expected: false,+ },+];++['encapsulateKey', 'decapsulateKey'].forEach(operation => {+ mlKemImportedKeyCases.forEach(({+ description,+ additionalAlgorithm,+ expected,+ }) => {+ test(() => {+ assert_equals(+ SubtleCrypto.supports(+ operation,+ 'ML-KEM-768',+ additionalAlgorithm+ ),+ expected,+ `ML-KEM-768 ${operation} with ${description}`+ );+ }, `supports ${operation} with ${description}`);+ });+});++// Test some algorithm objects with valid parameters+test(() => {+ assert_true(+ SubtleCrypto.supports('encrypt', {+ name: 'ChaCha20-Poly1305',+ iv: new Uint8Array(12),+ tagLength: 128,+ }),+ 'ChaCha20-Poly1305 encrypt with valid tagLength');+}, 'supports returns true for algorithm objects with valid parameters');++// Test some algorithm objects with invalid parameters+test(() => {+ assert_false(+ SubtleCrypto.supports('encrypt', {+ name: 'ChaCha20-Poly1305',+ iv: new Uint8Array(12),+ tagLength: 100,+ }),+ 'ChaCha20-Poly1305 encrypt with invalid tagLength');++ assert_false(+ SubtleCrypto.supports('encrypt', {+ name: 'ChaCha20-Poly1305',+ iv: new Uint8Array(10),+ tagLength: 128,+ }),+ 'ChaCha20-Poly1305 encrypt with invalid iv');+}, 'supports returns false for algorithm objects with invalid parameters');+++done();diff --git a/Tests/LibWeb/Text/input/wpt-import/WebCryptoAPI/modern-algos/supports.https.any.html b/Tests/LibWeb/Text/input/wpt-import/WebCryptoAPI/modern-algos/supports.https.any.htmlnew file mode 100644index 00000000000..7054e4efab2--- /dev/null+++ b/Tests/LibWeb/Text/input/wpt-import/WebCryptoAPI/modern-algos/supports.https.any.html@@ -0,0 +1,16 @@+<!doctype html>+<meta charset=utf-8>+<title>WebCrypto API: supports method tests</title>+<script>+self.GLOBAL = {+ isWindow: function() { return true; },+ isWorker: function() { return false; },+ isShadowRealm: function() { return false; },+};+</script>+<script src="../../resources/testharness.js"></script>+<script src="../../resources/testharnessreport.js"></script>+<script src="../util/helpers.js"></script>+<script src="util/supports.js"></script>+<div id=log></div>+<script src="../../WebCryptoAPI/modern-algos/supports.https.any.js"></script>diff --git a/Tests/LibWeb/Text/input/wpt-import/WebCryptoAPI/modern-algos/supports.https.any.js b/Tests/LibWeb/Text/input/wpt-import/WebCryptoAPI/modern-algos/supports.https.any.jsnew file mode 100644index 00000000000..a07684cbbe2--- /dev/null+++ b/Tests/LibWeb/Text/input/wpt-import/WebCryptoAPI/modern-algos/supports.https.any.js@@ -0,0 +1,752 @@+// META: title=WebCrypto API: supports method tests+// META: script=../util/helpers.js+// META: script=util/supports.js++'use strict';++const standardAlgorithms = {+ // Asymmetric algorithms+ 'RSASSA-PKCS1-v1_5': {+ operations: ['generateKey', 'importKey', 'sign', 'verify', 'getPublicKey'],+ keyGenParams: {+ name: 'RSASSA-PKCS1-v1_5',+ modulusLength: 2048,+ publicExponent: new Uint8Array([1, 0, 1]),+ hash: 'SHA-256',+ },+ importParams: { name: 'RSASSA-PKCS1-v1_5', hash: 'SHA-256' },+ signParams: { name: 'RSASSA-PKCS1-v1_5' },+ },+ 'RSA-PSS': {+ operations: ['generateKey', 'importKey', 'sign', 'verify', 'getPublicKey'],+ keyGenParams: {+ name: 'RSA-PSS',+ modulusLength: 2048,+ publicExponent: new Uint8Array([1, 0, 1]),+ hash: 'SHA-256',+ },+ importParams: { name: 'RSA-PSS', hash: 'SHA-256' },+ signParams: { name: 'RSA-PSS', saltLength: 32 },+ },+ 'RSA-OAEP': {+ operations: ['generateKey', 'importKey', 'encrypt', 'decrypt', 'getPublicKey'],+ keyGenParams: {+ name: 'RSA-OAEP',+ modulusLength: 2048,+ publicExponent: new Uint8Array([1, 0, 1]),+ hash: 'SHA-256',+ },+ importParams: { name: 'RSA-OAEP', hash: 'SHA-256' },+ encryptParams: { name: 'RSA-OAEP' },+ },+ ECDSA: {+ operations: ['generateKey', 'importKey', 'sign', 'verify', 'getPublicKey'],+ keyGenParams: { name: 'ECDSA', namedCurve: 'P-256' },+ importParams: { name: 'ECDSA', namedCurve: 'P-256' },+ signParams: { name: 'ECDSA', hash: 'SHA-256' },+ },+ ECDH: {+ operations: ['generateKey', 'importKey', 'deriveBits', 'getPublicKey'],+ keyGenParams: { name: 'ECDH', namedCurve: 'P-256' },+ importParams: { name: 'ECDH', namedCurve: 'P-256' },+ deriveBitsParamsFactory: async () => {+ const {publicKey} = await crypto.subtle.generateKey(+ {name: 'ECDH', namedCurve: 'P-256'}, false, ['deriveBits']);+ return {name: 'ECDH', public: publicKey};+ },+ },+ Ed25519: {+ operations: ['generateKey', 'importKey', 'sign', 'verify', 'getPublicKey'],+ keyGenParams: null,+ signParams: { name: 'Ed25519' },+ },+ X25519: {+ operations: ['generateKey', 'importKey', 'deriveBits', 'getPublicKey'],+ keyGenParams: null,+ deriveBitsParamsFactory: async () => {+ const {publicKey} = await crypto.subtle.generateKey(+ 'X25519', false, ['deriveBits']);+ return {name: 'X25519', public: publicKey};+ },+ },++ // Symmetric algorithms+ 'AES-CBC': {+ operations: ['generateKey', 'importKey', 'encrypt', 'decrypt'],+ keyGenParams: { name: 'AES-CBC', length: 256 },+ encryptParams: { name: 'AES-CBC', iv: new Uint8Array(16) },+ },+ 'AES-CTR': {+ operations: ['generateKey', 'importKey', 'encrypt', 'decrypt'],+ keyGenParams: { name: 'AES-CTR', length: 256 },+ encryptParams: {+ name: 'AES-CTR',+ counter: new Uint8Array(16),+ length: 128,+ },+ },+ 'AES-GCM': {+ operations: ['generateKey', 'importKey', 'encrypt', 'decrypt'],+ keyGenParams: { name: 'AES-GCM', length: 256 },+ encryptParams: { name: 'AES-GCM', iv: new Uint8Array(12) },+ },+ 'AES-KW': {+ operations: ['generateKey', 'importKey'], // wrapKey/unwrapKey not in requested operations+ keyGenParams: { name: 'AES-KW', length: 256 },+ },+ HMAC: {+ operations: ['generateKey', 'importKey', 'sign', 'verify'],+ keyGenParams: { name: 'HMAC', hash: 'SHA-256' },+ importParams: { name: 'HMAC', hash: 'SHA-256' },+ signParams: { name: 'HMAC' },+ },++ // Hash algorithms+ 'SHA-1': {+ operations: ['digest'],+ keyGenParams: null,+ },+ 'SHA-256': {+ operations: ['digest'],+ keyGenParams: null,+ },+ 'SHA-384': {+ operations: ['digest'],+ keyGenParams: null,+ },+ 'SHA-512': {+ operations: ['digest'],+ keyGenParams: null,+ },++ // Key derivation algorithms+ HKDF: {+ operations: ['importKey', 'deriveBits'],+ keyGenParams: null,+ deriveBitsParams: {+ name: 'HKDF',+ hash: 'SHA-256',+ salt: new Uint8Array(16),+ info: new Uint8Array(0),+ },+ },+ PBKDF2: {+ operations: ['importKey', 'deriveBits'],+ keyGenParams: null,+ deriveBitsParams: {+ name: 'PBKDF2',+ hash: 'SHA-256',+ salt: new Uint8Array(16),+ iterations: 100000,+ },+ },+};++const operations = [+ 'generateKey',+ 'importKey',+ 'sign',+ 'verify',+ 'encrypt',+ 'decrypt',+ 'deriveBits',+ 'digest',+ 'getPublicKey',+];++// Test that supports method exists and is a static method+testSupportsMethod();++// Test invalid operation names+test(() => {+ assert_false(+ SubtleCrypto.supports('invalidOperation', 'AES-GCM'),+ 'Invalid operation should return false'+ );+ assert_false(+ SubtleCrypto.supports('', 'AES-GCM'),+ 'Empty operation should return false'+ );+ assert_false(+ SubtleCrypto.supports('GENERATEKEY', 'AES-GCM'),+ 'Case-sensitive operation check'+ );+}, 'supports returns false for invalid operations');++// Test invalid algorithm identifiers+test(() => {+ assert_false(+ SubtleCrypto.supports('generateKey', 'InvalidAlgorithm'),+ 'Invalid algorithm should return false'+ );+ assert_false(+ SubtleCrypto.supports('generateKey', ''),+ 'Empty algorithm should return false'+ );+}, 'supports returns false for invalid algorithms');++// Test standard WebCrypto algorithms for requested operations+runSupportsTests(standardAlgorithms, operations);++// Test algorithm objects (not just strings)+test(() => {+ assert_true(+ SubtleCrypto.supports('generateKey', { name: 'AES-GCM', length: 256 }),+ 'Algorithm object should be supported'+ );+ assert_true(+ SubtleCrypto.supports('generateKey', { name: 'HMAC', hash: 'SHA-256' }),+ 'Algorithm object with parameters should be supported'+ );+}, 'supports works with algorithm objects');++// Test with algorithm objects that have invalid parameters+test(() => {+ assert_false(+ SubtleCrypto.supports('generateKey', { name: 'AES-GCM', length: 100 }),+ 'Invalid key length should return false'+ );+ assert_false(+ SubtleCrypto.supports('generateKey', {+ name: 'HMAC',+ hash: 'INVALID-HASH',+ }),+ 'Invalid hash parameter should return false'+ );+ assert_false(+ SubtleCrypto.supports(+ 'encrypt', {name: 'AES-CBC', iv: new Uint8Array(10)}),+ 'Invalid IV for AES-CBC should return false');+ assert_false(+ SubtleCrypto.supports('encrypt', {+ name: 'AES-CTR',+ counter: new Uint8Array(10),+ length: 128,+ }),+ 'Invalid IV for AES-CTR should return false');+ assert_false(+ SubtleCrypto.supports('encrypt', {+ name: 'AES-CTR',+ counter: new Uint8Array(16),+ length: 0,+ }),+ 'Invalid length=0 for AES-CTR should return false');+ assert_false(+ SubtleCrypto.supports('encrypt', {+ name: 'AES-CTR',+ counter: new Uint8Array(16),+ length: 129,+ }),+ 'Invalid length=129 for AES-CTR should return false');+ assert_false(+ SubtleCrypto.supports('encrypt', {+ name: 'AES-GCM',+ iv: new Uint8Array(16),+ tagLength: 100,+ }),+ 'Invalid tag length for AES-GCM should return false');+ assert_false(+ SubtleCrypto.supports('decrypt', {+ name: 'AES-GCM',+ iv: new Uint8Array(16),+ tagLength: 100,+ }),+ 'Invalid tag length for AES-GCM should return false');+ assert_false(+ SubtleCrypto.supports('generateKey', {name: 'ECDH', namedCurve: 'P-51'}),+ 'Invalid curve for ECDH should return false');+ assert_false(+ SubtleCrypto.supports(+ 'deriveBits', {+ name: 'HKDF',+ hash: 'SHA-25',+ salt: new Uint8Array(16),+ info: new Uint8Array(0),+ },+ 8),+ 'Invalid hash for HKDF should return false');+ assert_false(+ SubtleCrypto.supports(+ 'deriveBits', {+ name: 'HKDF',+ hash: 'SHA-256',+ salt: new Uint8Array(16),+ info: new Uint8Array(0),+ },+ 11),+ 'Invalid length for HKDF should return false');+ assert_false(+ SubtleCrypto.supports(+ 'deriveBits', {+ name: 'HKDF',+ hash: 'SHA-256',+ salt: new Uint8Array(16),+ info: new Uint8Array(0),+ }),+ 'null length for HKDF should return false');+ assert_false(+ SubtleCrypto.supports('generateKey', {+ name: 'HMAC',+ hash: 'SHA-25',+ }),+ 'Invalid hash for HMAC should return false');+ assert_false(+ SubtleCrypto.supports('generateKey', {+ name: 'HMAC',+ hash: 'SHA-256',+ length: 0,+ }),+ 'Invalid length for HMAC should return false');+ assert_false(+ SubtleCrypto.supports(+ 'deriveBits', {+ name: 'PBKDF2',+ hash: 'SHA-25',+ salt: new Uint8Array(16),+ iterations: 100000,+ },+ 8),+ 'Invalid hash for PBKDF2 should return false');+ assert_false(+ SubtleCrypto.supports(+ 'deriveBits', {+ name: 'PBKDF2',+ hash: 'SHA-256',+ salt: new Uint8Array(16),+ iterations: 100000,+ },+ 11),+ 'Invalid length for PBKDF2 should return false');+ assert_false(+ SubtleCrypto.supports(+ 'deriveBits', {+ name: 'PBKDF2',+ hash: 'SHA-256',+ salt: new Uint8Array(16),+ iterations: 100000,+ }),+ 'null length for PBKDF2 should return false');+ assert_false(+ SubtleCrypto.supports('generateKey', {+ name: 'RSASSA-PKCS1-v1_5',+ modulusLength: 2048,+ publicExponent: new Uint8Array([1, 0, 1]),+ hash: 'SHA-56',+ }),+ 'Invalid hash for RSA PKCS1 should return false');+ assert_false(+ SubtleCrypto.supports('generateKey', {+ name: 'RSA-PSS',+ modulusLength: 2048,+ publicExponent: new Uint8Array([1, 0, 1]),+ hash: 'SHA-56',+ }),+ 'Invalid hash for RSA PSS should return false');+ assert_false(+ SubtleCrypto.supports('generateKey', {+ name: 'RSA-OAEP',+ modulusLength: 2048,+ publicExponent: new Uint8Array([1, 0, 1]),+ hash: 'SHA-26',+ }),+ 'Invalid hash for RSA OAEP should return false');++}, 'supports returns false for algorithm objects with invalid parameters');++[+ ['SHA-1', 160],+ ['SHA-256', 256],+ ['SHA-384', 384],+ ['SHA-512', 512],+].forEach(([hash, hashLength]) => {+ test(() => {+ const algorithm = {+ name: 'HKDF',+ hash,+ salt: new Uint8Array(),+ info: new Uint8Array(),+ };+ const maximumLength = 255 * hashLength;++ assert_true(+ SubtleCrypto.supports('deriveBits', algorithm, maximumLength),+ `HKDF with ${hash} supports its maximum output length`+ );+ assert_false(+ SubtleCrypto.supports('deriveBits', algorithm, maximumLength + 8),+ `HKDF with ${hash} rejects output longer than its maximum`+ );+ }, `supports validates HKDF ${hash} output length`);+});++test(() => {+ assert_false(+ SubtleCrypto.supports(+ 'deriveKey',+ {+ name: 'HKDF',+ hash: 'SHA-256',+ salt: new Uint8Array(),+ info: new Uint8Array(),+ },+ {name: 'HMAC', hash: 'SHA-256', length: 65288}+ ),+ 'HKDF rejects a derived key longer than 255 hash blocks'+ );+}, 'supports validates HKDF output length for deriveKey');++test(() => {+ assert_false(+ SubtleCrypto.supports('importKey', {+ name: 'HMAC',+ hash: 'SHA-256',+ length: 0,+ }),+ 'HMAC rejects an explicitly zero-length imported key'+ );+}, 'supports validates HMAC import length');++const invalidRsaKeyGenParameters = [+ {+ description: 'a modulus shorter than 4 bits',+ modulusLength: 3,+ publicExponent: Uint8Array.of(3),+ },+ {+ description: 'a public exponent less than 3',+ modulusLength: 2048,+ publicExponent: Uint8Array.of(1),+ },+ {+ description: 'an even public exponent',+ modulusLength: 2048,+ publicExponent: Uint8Array.of(4),+ },+ {+ description: 'a public exponent equal to 2^modulusLength - 1',+ modulusLength: 2048,+ publicExponent: new Uint8Array(256).fill(0xff),+ },+];++[+ 'RSASSA-PKCS1-v1_5',+ 'RSA-PSS',+ 'RSA-OAEP',+].forEach(name => {+ invalidRsaKeyGenParameters.forEach(({description, ...parameters}) => {+ test(() => {+ assert_false(+ SubtleCrypto.supports('generateKey', {+ name,+ ...parameters,+ hash: 'SHA-256',+ }),+ `${name} rejects ${description}`+ );+ }, `supports rejects ${name} generateKey with ${description}`);+ });+});++['ECDSA', 'ECDH'].forEach(name => {+ test(() => {+ assert_false(+ SubtleCrypto.supports('importKey', {+ name,+ namedCurve: 'not-a-curve',+ }),+ `${name} rejects an unknown named curve`+ );+ }, `supports validates ${name} import namedCurve`);+});++[+ ['P-256', 256],+ ['P-384', 384],+ ['P-521', 528],+].forEach(([namedCurve, maximumLength]) => {+ promise_test(async () => {+ const {publicKey} = await crypto.subtle.generateKey(+ {name: 'ECDH', namedCurve}, false, ['deriveBits']);+ const algorithm = {name: 'ECDH', public: publicKey};++ assert_true(+ SubtleCrypto.supports('deriveBits', algorithm, maximumLength),+ `ECDH ${namedCurve} supports its maximum output length`+ );+ assert_false(+ SubtleCrypto.supports('deriveBits', algorithm, maximumLength + 1),+ `ECDH ${namedCurve} rejects output longer than its maximum`+ );+ }, `supports validates ECDH ${namedCurve} deriveBits length`);+});++promise_test(async () => {+ const {publicKey} = await crypto.subtle.generateKey(+ 'X25519', false, ['deriveBits']);+ const algorithm = {name: 'X25519', public: publicKey};++ assert_true(+ SubtleCrypto.supports('deriveBits', algorithm, 256),+ 'X25519 supports its maximum output length'+ );+ assert_false(+ SubtleCrypto.supports('deriveBits', algorithm, 257),+ 'X25519 rejects output longer than its maximum'+ );+}, 'supports validates X25519 deriveBits length');++promise_test(async () => {+ const [ecdhKeyPair, x25519KeyPair] = await Promise.all([+ crypto.subtle.generateKey(+ {name: 'ECDH', namedCurve: 'P-256'}, false, ['deriveBits']),+ crypto.subtle.generateKey('X25519', false, ['deriveBits']),+ ]);++ assert_false(+ SubtleCrypto.supports(+ 'deriveBits', {name: 'ECDH', public: ecdhKeyPair.privateKey}, 256),+ 'ECDH rejects a private public property'+ );+ assert_false(+ SubtleCrypto.supports(+ 'deriveBits', {name: 'ECDH', public: x25519KeyPair.publicKey}, 256),+ 'ECDH rejects a public property for another algorithm'+ );+}, 'supports validates the ECDH public key');++promise_test(async () => {+ const [x25519KeyPair, ecdhKeyPair] = await Promise.all([+ crypto.subtle.generateKey('X25519', false, ['deriveBits']),+ crypto.subtle.generateKey(+ {name: 'ECDH', namedCurve: 'P-256'}, false, ['deriveBits']),+ ]);++ assert_false(+ SubtleCrypto.supports(+ 'deriveBits', {name: 'X25519', public: x25519KeyPair.privateKey}, 256),+ 'X25519 rejects a private public property'+ );+ assert_false(+ SubtleCrypto.supports(+ 'deriveBits', {name: 'X25519', public: ecdhKeyPair.publicKey}, 256),+ 'X25519 rejects a public property for another algorithm'+ );+}, 'supports validates the X25519 public key');++promise_test(async () => {+ const [p256KeyPair, p521KeyPair] = await Promise.all([+ crypto.subtle.generateKey(+ {name: 'ECDH', namedCurve: 'P-256'}, false, ['deriveBits']),+ crypto.subtle.generateKey(+ {name: 'ECDH', namedCurve: 'P-521'}, false, ['deriveBits']),+ ]);+ const derivedKeyAlgorithm = {name: 'HMAC', hash: 'SHA-256'};++ assert_false(+ SubtleCrypto.supports(+ 'deriveKey',+ {name: 'ECDH', public: p256KeyPair.publicKey},+ derivedKeyAlgorithm+ ),+ 'ECDH P-256 cannot derive a 512-bit HMAC key'+ );+ assert_true(+ SubtleCrypto.supports(+ 'deriveKey',+ {name: 'ECDH', public: p521KeyPair.publicKey},+ derivedKeyAlgorithm+ ),+ 'ECDH P-521 can derive a 512-bit HMAC key'+ );+}, 'supports derives the ECDH output limit from the public curve');++// Test some specific combinations that should work+test(() => {+ // RSA algorithms+ assert_true(+ SubtleCrypto.supports('generateKey', {+ name: 'RSASSA-PKCS1-v1_5',+ modulusLength: 2048,+ publicExponent: new Uint8Array([1, 0, 1]),+ hash: 'SHA-256',+ }),+ 'RSASSA-PKCS1-v1_5 generateKey'+ );+ assert_true(+ SubtleCrypto.supports('sign', { name: 'RSASSA-PKCS1-v1_5' }),+ 'RSASSA-PKCS1-v1_5 sign'+ );+ assert_true(+ SubtleCrypto.supports('verify', { name: 'RSASSA-PKCS1-v1_5' }),+ 'RSASSA-PKCS1-v1_5 verify'+ );++ // ECDSA+ assert_true(+ SubtleCrypto.supports('generateKey', {+ name: 'ECDSA',+ namedCurve: 'P-256',+ }),+ 'ECDSA generateKey'+ );+ assert_true(+ SubtleCrypto.supports('sign', { name: 'ECDSA', hash: 'SHA-256' }),+ 'ECDSA sign'+ );+ assert_true(+ SubtleCrypto.supports('verify', { name: 'ECDSA', hash: 'SHA-256' }),+ 'ECDSA verify'+ );++ // AES-GCM+ assert_true(+ SubtleCrypto.supports('generateKey', { name: 'AES-GCM', length: 256 }),+ 'AES-GCM generateKey'+ );+ assert_true(+ SubtleCrypto.supports('encrypt', {+ name: 'AES-GCM',+ iv: new Uint8Array(12),+ }),+ 'AES-GCM encrypt'+ );+ assert_true(+ SubtleCrypto.supports('decrypt', {+ name: 'AES-GCM',+ iv: new Uint8Array(12),+ }),+ 'AES-GCM decrypt'+ );++ // HMAC+ assert_true(+ SubtleCrypto.supports('generateKey', { name: 'HMAC', hash: 'SHA-256' }),+ 'HMAC generateKey'+ );+ assert_true(SubtleCrypto.supports('sign', { name: 'HMAC' }), 'HMAC sign');+ assert_true(SubtleCrypto.supports('verify', { name: 'HMAC' }), 'HMAC verify');+}, 'Common algorithm and operation combinations work');++// Test some specific combinations that should not work+test(() => {+ // Hash algorithms don't support key operations+ assert_false(+ SubtleCrypto.supports('generateKey', 'SHA-256'),+ 'SHA-256 generateKey should fail'+ );+ assert_false(+ SubtleCrypto.supports('sign', 'SHA-256'),+ 'SHA-256 sign should fail'+ );++ // AES can't sign/verify (these require algorithm parameters due to normalization)+ assert_false(+ SubtleCrypto.supports('sign', 'AES-GCM'),+ 'AES-GCM sign should fail'+ );+ assert_false(+ SubtleCrypto.supports('verify', 'AES-GCM'),+ 'AES-GCM verify should fail'+ );++ // ECDSA can't encrypt/decrypt+ assert_false(+ SubtleCrypto.supports('encrypt', 'ECDSA'),+ 'ECDSA encrypt should fail'+ );+ assert_false(+ SubtleCrypto.supports('decrypt', 'ECDSA'),+ 'ECDSA decrypt should fail'+ );++ // HMAC can't encrypt/decrypt+ assert_false(+ SubtleCrypto.supports('encrypt', 'HMAC'),+ 'HMAC encrypt should fail'+ );+ assert_false(+ SubtleCrypto.supports('decrypt', 'HMAC'),+ 'HMAC decrypt should fail'+ );++ // Non-hash algorithms can't digest+ assert_false(+ SubtleCrypto.supports('digest', 'AES-GCM'),+ 'AES-GCM digest should fail'+ );+ assert_false(+ SubtleCrypto.supports('digest', 'ECDSA'),+ 'ECDSA digest should fail'+ );+ assert_false(+ SubtleCrypto.supports('digest', 'HMAC'),+ 'HMAC digest should fail'+ );+}, 'Invalid algorithm and operation combinations fail');++// Test supports for deriveKey op+test(() => {+ assert_true(+ SubtleCrypto.supports(+ 'deriveKey', {+ name: 'HKDF',+ hash: 'SHA-256',+ salt: new Uint8Array(16),+ info: new Uint8Array(0),+ },+ {name: 'HMAC', hash: 'SHA-256'}),++ 'deriveKey HKDF-HMAC should pass');+}, 'deriveKey tests');++promise_test(async (t) => {+ let keypair = await crypto.subtle.generateKey(+ {+ name: 'X25519',+ },+ false, ['deriveKey', 'deriveBits']);++ assert_true(+ SubtleCrypto.supports(+ 'deriveKey', {+ name: 'X25519',+ public: keypair.publicKey,+ },+ {name: 'AES-GCM', length: 256}),++ 'deriveKey X25519-AES-GCM-256 should pass');++ assert_false(+ SubtleCrypto.supports(+ 'deriveKey', {+ name: 'X25519',+ public: keypair.publicKey,+ },+ {name: 'HMAC', hash: 'SHA-256'}),++ 'deriveKey X25519-HMAC-SHA-256 should fail');+}, 'deriveKey promise tests');++// Test supports for exportKey op+test(() => {+ assert_true(SubtleCrypto.supports('exportKey', 'AES-GCM'),+ 'exportKey AES-GCM should pass');+ assert_false(SubtleCrypto.supports('exportKey', 'HKDF'),+ 'exportKey HKDF should fail');+ assert_false(SubtleCrypto.supports('exportKey', 'PBKDF2'),+ 'exportKey PBKDF2 should fail');+}, 'exportKey tests');++// Test supports for wrapKey op+test(() => {+ assert_true(SubtleCrypto.supports('wrapKey', 'AES-KW', 'AES-GCM'),+ 'wrapKey AES-KW-AES-GCM should pass');+ assert_false(SubtleCrypto.supports('wrapKey', 'AES-KW', 'HKDF'),+ 'wrapKey AES-KW-HKDF should fail');+ assert_false(SubtleCrypto.supports('wrapKey', 'AES-KW', 'PBKDF2'),+ 'wrapKey AES-KW-PBKDF2 should fail');+}, 'wrapKey tests');+++done();diff --git a/Tests/LibWeb/Text/input/wpt-import/WebCryptoAPI/modern-algos/util/supports.js b/Tests/LibWeb/Text/input/wpt-import/WebCryptoAPI/modern-algos/util/supports.jsnew file mode 100644index 00000000000..d41e38e96f9--- /dev/null+++ b/Tests/LibWeb/Text/input/wpt-import/WebCryptoAPI/modern-algos/util/supports.js@@ -0,0 +1,73 @@+'use strict';++function testSupportsMethod() {+ test(() => {+ assert_true(+ typeof SubtleCrypto.supports === 'function',+ 'SubtleCrypto.supports should be a function'+ );+ }, 'SubtleCrypto.supports method exists');+}++function runSupportsTests(algorithms, operations) {+ for (const [algorithmName, algorithmInfo] of Object.entries(algorithms)) {+ for (const operation of operations) {+ promise_test(async (t) => {+ const isSupported = algorithmInfo.operations.includes(operation);++ let algorithm;+ let lengthOrAdditionalAlgorithm;+ switch (operation) {+ case 'generateKey':+ algorithm = algorithmInfo.keyGenParams || algorithmName;+ break;+ case 'importKey':+ algorithm = algorithmInfo.importParams || algorithmName;+ break;+ case 'sign':+ case 'verify':+ algorithm = algorithmInfo.signParams || algorithmName;+ break;+ case 'encrypt':+ case 'decrypt':+ algorithm = algorithmInfo.encryptParams || algorithmName;+ break;+ case 'deriveBits':+ algorithm = algorithmInfo.deriveBitsParamsFactory ?+ await algorithmInfo.deriveBitsParamsFactory() :+ algorithmInfo.deriveBitsParams || algorithmName;+ if (algorithmName === 'PBKDF2' || algorithmName === 'HKDF') {+ lengthOrAdditionalAlgorithm = 256;+ }+ break;+ case 'digest':+ algorithm = algorithmName;+ break;+ case 'encapsulateKey':+ case 'encapsulateBits':+ case 'decapsulateKey':+ case 'decapsulateBits':+ algorithm = algorithmName;+ if (operation === 'encapsulateKey' || operation === 'decapsulateKey') {+ lengthOrAdditionalAlgorithm = { name: 'AES-GCM', length: 256 };+ }+ break;+ default:+ algorithm = algorithmName;+ }++ const result = SubtleCrypto.supports(+ operation,+ algorithm,+ lengthOrAdditionalAlgorithm+ );++ if (isSupported) {+ assert_true(result, `${algorithmName} should support ${operation}`);+ } else {+ assert_false(result, `${algorithmName} should not support ${operation}`);+ }+ }, `supports(${operation}, ${algorithmName})`);+ }+ }+}diff --git a/Tests/LibWeb/Text/input/wpt-import/interfaces/webcrypto-modern-algos.idl b/Tests/LibWeb/Text/input/wpt-import/interfaces/webcrypto-modern-algos.idlnew file mode 100644index 00000000000..00df80f74cc--- /dev/null+++ b/Tests/LibWeb/Text/input/wpt-import/interfaces/webcrypto-modern-algos.idl@@ -0,0 +1,118 @@+// GENERATED CONTENT - DO NOT EDIT+// Content was automatically extracted by Reffy into webref+// (https://github.com/w3c/webref)+// Source: Modern Algorithms in the Web Cryptography API (https://wicg.github.io/webcrypto-modern-algos/)++[SecureContext,Exposed=(Window,Worker)]+partial interface SubtleCrypto {+ Promise<EncapsulatedKey> encapsulateKey(+ AlgorithmIdentifier encapsulationAlgorithm,+ CryptoKey encapsulationKey,+ AlgorithmIdentifier sharedKeyAlgorithm,+ boolean extractable,+ sequence<KeyUsage> keyUsages+ );+ Promise<EncapsulatedBits> encapsulateBits(+ AlgorithmIdentifier encapsulationAlgorithm,+ CryptoKey encapsulationKey+ );++ Promise<CryptoKey> decapsulateKey(+ AlgorithmIdentifier decapsulationAlgorithm,+ CryptoKey decapsulationKey,+ BufferSource ciphertext,+ AlgorithmIdentifier sharedKeyAlgorithm,+ boolean extractable,+ sequence<KeyUsage> keyUsages+ );+ Promise<ArrayBuffer> decapsulateBits(+ AlgorithmIdentifier decapsulationAlgorithm,+ CryptoKey decapsulationKey,+ BufferSource ciphertext+ );++ Promise<CryptoKey> getPublicKey(+ CryptoKey key,+ sequence<KeyUsage> keyUsages+ );++ static boolean supports(DOMString operation,+ AlgorithmIdentifier algorithm,+ optional [EnforceRange] unsigned long? length = null);+ static boolean supports(DOMString operation,+ AlgorithmIdentifier algorithm,+ AlgorithmIdentifier additionalAlgorithm);+};++enum KeyFormat { "raw-public", "raw-private", "raw-seed", "raw-secret", "raw", "spki", "pkcs8", "jwk" };++enum KeyUsage { "encrypt", "decrypt", "sign", "verify", "deriveKey", "deriveBits", "wrapKey", "unwrapKey", "encapsulateKey", "encapsulateBits", "decapsulateKey", "decapsulateBits" };++dictionary EncapsulatedKey {+ CryptoKey sharedKey;+ ArrayBuffer ciphertext;+};++dictionary EncapsulatedBits {+ ArrayBuffer sharedKey;+ ArrayBuffer ciphertext;+};++partial dictionary JsonWebKey {+ // The following fields are defined in RFC 9964+ DOMString pub;+ DOMString priv;+};++dictionary ContextParams : Algorithm {+ BufferSource context;+};++dictionary AeadParams : Algorithm {+ required BufferSource iv;+ BufferSource additionalData;+ [EnforceRange] octet tagLength;+};++dictionary CShakeParams : Algorithm {+ required [EnforceRange] unsigned long outputLength;+ BufferSource functionName;+ BufferSource customization;+};++dictionary TurboShakeParams : Algorithm {+ required [EnforceRange] unsigned long outputLength;+ [EnforceRange] octet domainSeparation;+};++dictionary KangarooTwelveParams : Algorithm {+ required [EnforceRange] unsigned long outputLength;+ BufferSource customization;+};++dictionary KmacKeyGenParams : Algorithm {+ [EnforceRange] unsigned long length;+};++dictionary KmacImportParams : Algorithm {+ [EnforceRange] unsigned long length;+};++dictionary KmacKeyAlgorithm : KeyAlgorithm {+ required [EnforceRange] unsigned long length;+};++dictionary KmacParams : Algorithm {+ required [EnforceRange] unsigned long outputLength;+ BufferSource customization;+};++dictionary Argon2Params : Algorithm {+ required BufferSource nonce;+ required [EnforceRange] unsigned long parallelism;+ required [EnforceRange] unsigned long memory;+ required [EnforceRange] unsigned long passes;+ [EnforceRange] octet version;+ BufferSource secretValue;+ BufferSource associatedData;+};diff --git a/Tests/LibWeb/Text/input/wpt-import/interfaces/webcrypto.idl b/Tests/LibWeb/Text/input/wpt-import/interfaces/webcrypto.idlnew file mode 100644index 00000000000..7599a1a994a--- /dev/null+++ b/Tests/LibWeb/Text/input/wpt-import/interfaces/webcrypto.idl@@ -0,0 +1,258 @@+// GENERATED CONTENT - DO NOT EDIT+// Content was automatically extracted by Reffy into webref+// (https://github.com/w3c/webref)+// Source: Web Cryptography API Level 2 (https://w3c.github.io/webcrypto/)++partial interface mixin WindowOrWorkerGlobalScope {+ [SameObject] readonly attribute Crypto crypto;+};++[Exposed=(Window,Worker)]+interface Crypto {+ [SecureContext] readonly attribute SubtleCrypto subtle;+ ArrayBufferView getRandomValues(ArrayBufferView array);+ [SecureContext] DOMString randomUUID();+};++typedef (object or DOMString) AlgorithmIdentifier;++typedef AlgorithmIdentifier HashAlgorithmIdentifier;++dictionary Algorithm {+ required DOMString name;+};++dictionary KeyAlgorithm {+ required DOMString name;+};++enum KeyType { "public", "private", "secret" };++[SecureContext,Exposed=(Window,Worker),Serializable]+interface CryptoKey {+ readonly attribute KeyType type;+ readonly attribute boolean extractable;+ readonly attribute object algorithm;+ readonly attribute object usages;+};++[SecureContext,Exposed=(Window,Worker)]+interface SubtleCrypto {+ Promise<ArrayBuffer> encrypt(+ AlgorithmIdentifier algorithm,+ CryptoKey key,+ BufferSource data+ );+ Promise<ArrayBuffer> decrypt(+ AlgorithmIdentifier algorithm,+ CryptoKey key,+ BufferSource data+ );+ Promise<ArrayBuffer> sign(+ AlgorithmIdentifier algorithm,+ CryptoKey key,+ BufferSource data+ );+ Promise<boolean> verify(+ AlgorithmIdentifier algorithm,+ CryptoKey key,+ BufferSource signature,+ BufferSource data+ );+ Promise<ArrayBuffer> digest(+ AlgorithmIdentifier algorithm,+ BufferSource data+ );++ Promise<(CryptoKey or CryptoKeyPair)> generateKey(+ AlgorithmIdentifier algorithm,+ boolean extractable,+ sequence<KeyUsage> keyUsages+ );+ Promise<CryptoKey> deriveKey(+ AlgorithmIdentifier algorithm,+ CryptoKey baseKey,+ AlgorithmIdentifier derivedKeyType,+ boolean extractable,+ sequence<KeyUsage> keyUsages+ );+ Promise<ArrayBuffer> deriveBits(+ AlgorithmIdentifier algorithm,+ CryptoKey baseKey,+ optional [EnforceRange] unsigned long? length = null+ );++ Promise<CryptoKey> importKey(+ KeyFormat format,+ (BufferSource or JsonWebKey) keyData,+ AlgorithmIdentifier algorithm,+ boolean extractable,+ sequence<KeyUsage> keyUsages+ );+ Promise<(ArrayBuffer or JsonWebKey)> exportKey(+ KeyFormat format,+ CryptoKey key+ );++ Promise<ArrayBuffer> wrapKey(+ KeyFormat format,+ CryptoKey key,+ CryptoKey wrappingKey,+ AlgorithmIdentifier wrapAlgorithm+ );+ Promise<CryptoKey> unwrapKey(+ KeyFormat format,+ BufferSource wrappedKey,+ CryptoKey unwrappingKey,+ AlgorithmIdentifier unwrapAlgorithm,+ AlgorithmIdentifier unwrappedKeyAlgorithm,+ boolean extractable,+ sequence<KeyUsage> keyUsages+ );+};++dictionary RsaOtherPrimesInfo {+ // The following fields are defined in Section 6.3.2.7 of JSON Web Algorithms+ DOMString r;+ DOMString d;+ DOMString t;+};++dictionary JsonWebKey {+ // The following fields are defined in Section 3.1 of JSON Web Key+ DOMString kty;+ DOMString use;+ sequence<DOMString> key_ops;+ DOMString alg;++ // The following fields are defined in JSON Web Key Parameters Registration+ boolean ext;++ // The following fields are defined in Section 6 of JSON Web Algorithms+ DOMString crv;+ DOMString x;+ DOMString y;+ DOMString d;+ DOMString n;+ DOMString e;+ DOMString p;+ DOMString q;+ DOMString dp;+ DOMString dq;+ DOMString qi;+ sequence<RsaOtherPrimesInfo> oth;+ DOMString k;+};++typedef Uint8Array BigInteger;++dictionary CryptoKeyPair {+ CryptoKey publicKey;+ CryptoKey privateKey;+};++dictionary RsaKeyGenParams : Algorithm {+ required [EnforceRange] unsigned long modulusLength;+ required BigInteger publicExponent;+};++dictionary RsaHashedKeyGenParams : RsaKeyGenParams {+ required HashAlgorithmIdentifier hash;+};++dictionary RsaKeyAlgorithm : KeyAlgorithm {+ required [EnforceRange] unsigned long modulusLength;+ required BigInteger publicExponent;+};++dictionary RsaHashedKeyAlgorithm : RsaKeyAlgorithm {+ required KeyAlgorithm hash;+};++dictionary RsaHashedImportParams : Algorithm {+ required HashAlgorithmIdentifier hash;+};++dictionary RsaPssParams : Algorithm {+ required [EnforceRange] unsigned long saltLength;+};++dictionary RsaOaepParams : Algorithm {+ BufferSource label;+};++dictionary EcdsaParams : Algorithm {+ required HashAlgorithmIdentifier hash;+};++typedef DOMString NamedCurve;++dictionary EcKeyGenParams : Algorithm {+ required NamedCurve namedCurve;+};++dictionary EcKeyAlgorithm : KeyAlgorithm {+ required NamedCurve namedCurve;+};++dictionary EcKeyImportParams : Algorithm {+ required NamedCurve namedCurve;+};++dictionary EcdhKeyDeriveParams : Algorithm {+ required CryptoKey public;+};++dictionary AesCtrParams : Algorithm {+ required BufferSource counter;+ required [EnforceRange] octet length;+};++dictionary AesKeyAlgorithm : KeyAlgorithm {+ required [EnforceRange] unsigned short length;+};++dictionary AesKeyGenParams : Algorithm {+ required [EnforceRange] unsigned short length;+};++dictionary AesDerivedKeyParams : Algorithm {+ required [EnforceRange] unsigned short length;+};++dictionary AesCbcParams : Algorithm {+ required BufferSource iv;+};++dictionary AesGcmParams : Algorithm {+ required BufferSource iv;+ BufferSource additionalData;+ [EnforceRange] octet tagLength;+};++dictionary HmacImportParams : Algorithm {+ required HashAlgorithmIdentifier hash;+ [EnforceRange] unsigned long length;+};++dictionary HmacKeyAlgorithm : KeyAlgorithm {+ required KeyAlgorithm hash;+ required [EnforceRange] unsigned long length;+};++dictionary HmacKeyGenParams : Algorithm {+ required HashAlgorithmIdentifier hash;+ [EnforceRange] unsigned long length;+};++dictionary HkdfParams : Algorithm {+ required HashAlgorithmIdentifier hash;+ required BufferSource salt;+ required BufferSource info;+};++dictionary Pbkdf2Params : Algorithm {+ required BufferSource salt;+ required [EnforceRange] unsigned long iterations;+ required HashAlgorithmIdentifier hash;+};