diff --git a/test/fixtures/wpt/README.md b/test/fixtures/wpt/README.md index c98284f664a0af..10cedb4149edde 100644 --- a/test/fixtures/wpt/README.md +++ b/test/fixtures/wpt/README.md @@ -34,7 +34,7 @@ Last update: - wasm/jsapi: https://github.com/web-platform-tests/wpt/tree/288c467d35/wasm/jsapi - wasm/webapi: https://github.com/web-platform-tests/wpt/tree/fd1b23eeaa/wasm/webapi - web-locks: https://github.com/web-platform-tests/wpt/tree/10a122a6bc/web-locks -- WebCryptoAPI: https://github.com/web-platform-tests/wpt/tree/8b5cd267b4/WebCryptoAPI +- WebCryptoAPI: https://github.com/web-platform-tests/wpt/tree/97bbc7247a/WebCryptoAPI - webidl: https://github.com/web-platform-tests/wpt/tree/63ca529a02/webidl - webidl/ecmascript-binding/es-exceptions: https://github.com/web-platform-tests/wpt/tree/2f96fa1996/webidl/ecmascript-binding/es-exceptions - webmessaging/broadcastchannel: https://github.com/web-platform-tests/wpt/tree/6495c91853/webmessaging/broadcastchannel diff --git a/test/fixtures/wpt/WebCryptoAPI/import_export/ML-KEM_importKey.js b/test/fixtures/wpt/WebCryptoAPI/import_export/ML-KEM_importKey.js index ad2f75048556e4..d9257ac6982505 100644 --- a/test/fixtures/wpt/WebCryptoAPI/import_export/ML-KEM_importKey.js +++ b/test/fixtures/wpt/WebCryptoAPI/import_export/ML-KEM_importKey.js @@ -3,14 +3,14 @@ var subtle = crypto.subtle; function runTests(algorithmName) { var algorithm = { name: algorithmName }; var data = keyData[algorithmName]; - // var jwkData = {jwk: {kty: data.jwk.kty, alg: data.jwk.alg, pub: data.jwk.pub}}; - - // TODO: add JWK when its definition is done in IETF JOSE WG + var jwkData = { + jwk: { kty: data.jwk.kty, alg: data.jwk.alg, pub: data.jwk.pub }, + }; [true, false].forEach(function (extractable) { // Test public keys first allValidUsages(data.publicUsages, true).forEach(function (usages) { - ['spki', /*'jwk',*/ 'raw-public'].forEach(function (format) { + ['spki', 'jwk', 'raw-public'].forEach(function (format) { if (format === 'jwk') { // Not all fields used for public keys testFormat( @@ -36,7 +36,7 @@ function runTests(algorithmName) { // Next, test private keys allValidUsages(data.privateUsages).forEach(function (usages) { - ['pkcs8', /*'jwk',*/ 'raw-seed'].forEach(function (format) { + ['pkcs8', 'jwk', 'raw-seed'].forEach(function (format) { testFormat(format, algorithm, data, algorithmName, usages, extractable); }); }); diff --git a/test/fixtures/wpt/WebCryptoAPI/import_export/ML-KEM_importKey_fixtures.js b/test/fixtures/wpt/WebCryptoAPI/import_export/ML-KEM_importKey_fixtures.js index 1c25d37614e92e..f3a5f6687dc5e1 100644 --- a/test/fixtures/wpt/WebCryptoAPI/import_export/ML-KEM_importKey_fixtures.js +++ b/test/fixtures/wpt/WebCryptoAPI/import_export/ML-KEM_importKey_fixtures.js @@ -23,6 +23,12 @@ var keyData = { 80, 130, 235, 161, 49, 141, 160, 11, 40, 152, 18, 142, 30, 56, 252, 129, 211, ]), + jwk: { + priv: 'pSbBpIR6aK1T1uMf57eY5GCMQRdTgwjN9cB64vRehm12PK3LGUu9kBYlozVOlblQguuhMY2gCyiYEo4eOPyB0w', + kty: 'AKP', + alg: 'ML-KEM-512', + pub: 'NmgRwWK5Bbwb-FQJRnK_kDCVThmIH7wdYMRUaaUaIFQoZJQK5bJh0zEtyFpBboqtcZLG7tibd5wJQpNDnnkvmHZjC3QZl2iOLolHnjQPe7FuOPGP_EqSF0kziAZ7cHQ2UPgJVcVhQWYsqhdjAkEsTqyrUvOlclGMjxSOdNF0e9qVxWZRjvFzTudlmfKGdPsO9gmnKRYsHqbDm4mdVJOlRhpeZIUUwPRF3KrIUBul5CpUPVuUdPrM1Ola15ISYJU_mDI0ECKpElWtiAmRcOWxoiGd3tGWwPyorGqmJCabuEI7ZaqjIQoygXlWanvIxEVI75d2aroa4ZM1dgMJAiWM_Pcet7EEieafA7pdP1EQ6utJs9oYDXsngBZaOXiqc_hnm3KzKQUZIkiPA9BQgxN53RMG51ZC2HVHwoC7iaVQsDi4u9iFRZCplXWPZXQMcSpH_sBy4cEVDgW-AZweDpIW9rICT9xOHwwwmvWtNMmXmDZ0-vNN14kHGdBOP4N0-YIj1nwdkwIHskKfAnlDVcrA0Rx-EFixxcQiXDq-xeBc-gY6UdR6LDQeifp7BRwqTicqBYOCdYHJpIN2pweK70puM3Iy_kHIPhIazCBnJvOKl3YlYRsPR8BU12W3LJS4kOUfvXiNqIKrqXxFv7BxURULIfvN7myEBrc9OpivU_IfiOOy-5jA8RRxLGsWnppqQdINFuqvYtEn31obk2CVnESA7hnOERuM7EOdU-M8MsN0QSlmZJxAN3VavFBl6uOq8FJJvfydUvEWc3vPrnB2g_KmXuwtprObdlO9_1JWp2UnenFpOClD7QnMKtaiBmWOGZZV6dmIWrtY9_RZ01Gn_LORv8JoWQhAb2tMrRVtF9M1Jjx0jIO5jlSx9MgVzYte18YCMTCPY-J5Zuo3Q6o-LdLInnUq6cVugdQMjhJ_8SuXmsBYIHXN9FMKttWI6YKcLVYjHstsXiEP0kOx4fd4kZaKH-S3vCIl9CA5BiUXjxK108ooEpY9lTxH_yGCQRnEkve0HwWwHfvagpKsDDWzRIh4xAHRsY9_xcPO-JlXbUZ6_HA', + }, }, 'ML-KEM-768': { privateUsages: ['decapsulateBits', 'decapsulateKey'], @@ -47,6 +53,12 @@ var keyData = { 201, 9, 240, 170, 192, 86, 52, 228, 122, 16, 73, 139, 30, 11, 224, 117, 143, 2, 124, 21, 63, 91, 210, 94, 160, 123, 99, 189, 172, 61, 235, 191, ]), + jwk: { + priv: 'psgdZMYwUKSP1wJsaqLna2-PAg63_ZwRW9VLyHBZ8zfJCfCqwFY05HoQSYseC-B1jwJ8FT9b0l6ge2O9rD3rvw', + kty: 'AKP', + alg: 'ML-KEM-768', + pub: '7lhoaxGSnpU0O6dvndAgrKiCDLwlHeMBR4ZatDw5lYwtPCIEI9CbmfqjX7kTAcoJsEKh-oityrERRVegtAmShCZFdzGGVjRh3Yh594KhKZfGPYyUnTq8eBETGfl0Gldu8BBimWuzEGhghoOHYPa0ygEfUQZh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ow1NgEx_e6MRkc_PIsekgytkAhsPSYc0t_AuEy5xyqN_m_JMbLJCwaFVtoPVoKPNRzFtM1YrNSrtAOg0MLMna5eJN9CotPh0MywwxzKfyvFnEr-FKMr9UgOExqrZWY1gFeDot5S9rJhErLrZWAI8cn2tUuOGMg1LozqOxJIOyHsAERJ4W7jJQ5dWosbzdsiSeXAauX4fB_VWbAxmxNhreT1mJAF5Owx1OLJGYTFsmKqSI4HsGvlVpwQcClh8ZIBmWiLwUstOO401BGBsh2lbyWUmRGQCgSymgMP6IuQ7hAnWAp7CyO92VWNfXMV3ynevpq4a8MzDsgXnFisMWx_7w1vsdnSvNfo8E', + }, }, 'ML-KEM-1024': { privateUsages: ['decapsulateBits', 'decapsulateKey'], @@ -72,5 +84,11 @@ var keyData = { 251, 65, 39, 3, 101, 145, 174, 21, 195, 144, 234, 14, 158, 32, 49, 57, 142, 113, ]), + jwk: { + priv: 'mHWy5rWG9IGnfaYItV_O0ohw230GdnpTJvQ5zTJiOy7oQhGRzPyiuXR08hyEwftBJwNlka4Vw5DqDp4gMTmOcQ', + kty: 'AKP', + alg: 'ML-KEM-1024', + pub: 'IUe4I2Yu3_Ix1zZYFhRrTaBXm9KI8sZbdfbBXtsk8yV5ZBa0HYip0qHDrSEniEVDDngDv9Nhibg-OKdEgFy2NEaVa4WbHQxsVrUO11sV5LZ3H4Ww7CNG_3Ye-4h-vRw0B8eYJSLFGouhMRs8Q4q0ZhVp1wI8fIOoM-cXxypf6Kw_hLZD2TCkA3dN8hxk_tC5o5aZ8bFw7UyFJhgjmcEvzaYV6VqzokdodPty1jWOmguRXmydfvE1RjUHodUFOIhSzwuH3BgYlVk2Xcp3IPyyjnSNLBwLKEg4LlANCUvENPY6EJNgp-toE9wqk9ao_0t5HPpaqDAU0frBe9MhAHuvH3DHWlukxSRy7rmqC2tra9XCbTxp9_QRrCEs8Aa956fFmjN_z_EAGEdS7QqIxfi414ECFAWcTpGmC4y-VHSUC3UUGjJW1eNHzLOrk6g0dg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EYgRUkzVgYxtFn6WyhQqhDeXGry4lUJrMGUWmmr5yGvbW8u1GFS7LITjODYvms1kKtRpEdNCIJICwlyQwhn_eVsYc-OWMG71iNeqELTgRj1olWgJpXenFMe0K8ctyMnSNY6LQOd-tTtUx8cQnKmxA5ThtrhYtS8JS0iDmUUcikf8aJxxZs7hh9HQp9jttI4PsBo8dKdMRHJQLEW1cY8nGG21C1nRzKKeet8hNA2va3T-xznbdzkEJ1FNae1fMWhZUO1pRAGUfB_ARPnAeNRRFn-XmLCwtKtRy_GrpHsmhlVZdvioJVZGoB9JusQamo7PhciUmTbpx69rc55nF7EKjOyHFaH3O5GCmulSLJK0fKpTG2d0KWlKDK13IK4PMvVpd0kegv-VSyF3as7QwEuVQrdJJOHZi5MZMsF4vISwgGdcN5JBdFdCXAvgmOqlpR0Li6HCUoD0GXs7KPZwCADLk1lynACrq_HodeXadFvpORW0ok07UF58Swb-SbdatO2dQjfwWB0dC2a9JINjSS6WGfrIKrOriqP-5wjVKdo5w1493fQtp3aXqOEio', + }, }, }; diff --git a/test/fixtures/wpt/WebCryptoAPI/serialization/aes-cbc.https.any.js b/test/fixtures/wpt/WebCryptoAPI/serialization/aes-cbc.https.any.js new file mode 100644 index 00000000000000..840566639cd799 --- /dev/null +++ b/test/fixtures/wpt/WebCryptoAPI/serialization/aes-cbc.https.any.js @@ -0,0 +1,11 @@ +// META: title=WebCryptoAPI: CryptoKey serialization +// META: script=../util/helpers.js +// META: script=serialization.js +run_test([ + { + name: 'AES-CBC', + resultType: 'CryptoKey', + usages: ['encrypt', 'decrypt', 'wrapKey', 'unwrapKey'], + exportFormat: 'raw' + }, +]); diff --git a/test/fixtures/wpt/WebCryptoAPI/serialization/aes-ctr.https.any.js b/test/fixtures/wpt/WebCryptoAPI/serialization/aes-ctr.https.any.js new file mode 100644 index 00000000000000..3b3fb6822043f3 --- /dev/null +++ b/test/fixtures/wpt/WebCryptoAPI/serialization/aes-ctr.https.any.js @@ -0,0 +1,11 @@ +// META: title=WebCryptoAPI: CryptoKey serialization +// META: script=../util/helpers.js +// META: script=serialization.js +run_test([ + { + name: 'AES-CTR', + resultType: 'CryptoKey', + usages: ['encrypt', 'decrypt', 'wrapKey', 'unwrapKey'], + exportFormat: 'raw' + }, +]); diff --git a/test/fixtures/wpt/WebCryptoAPI/serialization/aes-gcm.https.any.js b/test/fixtures/wpt/WebCryptoAPI/serialization/aes-gcm.https.any.js new file mode 100644 index 00000000000000..b54eba677b965b --- /dev/null +++ b/test/fixtures/wpt/WebCryptoAPI/serialization/aes-gcm.https.any.js @@ -0,0 +1,11 @@ +// META: title=WebCryptoAPI: CryptoKey serialization +// META: script=../util/helpers.js +// META: script=serialization.js +run_test([ + { + name: 'AES-GCM', + resultType: 'CryptoKey', + usages: ['encrypt', 'decrypt', 'wrapKey', 'unwrapKey'], + exportFormat: 'raw' + }, +]); diff --git a/test/fixtures/wpt/WebCryptoAPI/serialization/aes-kw.https.any.js b/test/fixtures/wpt/WebCryptoAPI/serialization/aes-kw.https.any.js new file mode 100644 index 00000000000000..9948dce9b395e7 --- /dev/null +++ b/test/fixtures/wpt/WebCryptoAPI/serialization/aes-kw.https.any.js @@ -0,0 +1,11 @@ +// META: title=WebCryptoAPI: CryptoKey serialization +// META: script=../util/helpers.js +// META: script=serialization.js +run_test([ + { + name: 'AES-KW', + resultType: 'CryptoKey', + usages: ['wrapKey', 'unwrapKey'], + exportFormat: 'raw' + }, +]); diff --git a/test/fixtures/wpt/WebCryptoAPI/serialization/aes-ocb.tentative.https.any.js b/test/fixtures/wpt/WebCryptoAPI/serialization/aes-ocb.tentative.https.any.js new file mode 100644 index 00000000000000..33b814410c3ff4 --- /dev/null +++ b/test/fixtures/wpt/WebCryptoAPI/serialization/aes-ocb.tentative.https.any.js @@ -0,0 +1,11 @@ +// META: title=WebCryptoAPI: CryptoKey serialization +// META: script=../util/helpers.js +// META: script=serialization.js +run_test([ + { + name: 'AES-OCB', + resultType: 'CryptoKey', + usages: ['encrypt', 'decrypt', 'wrapKey', 'unwrapKey'], + exportFormat: 'raw-secret' + }, +]); diff --git a/test/fixtures/wpt/WebCryptoAPI/serialization/chacha20-poly1305.tentative.https.any.js b/test/fixtures/wpt/WebCryptoAPI/serialization/chacha20-poly1305.tentative.https.any.js new file mode 100644 index 00000000000000..aaaa24a0b662bc --- /dev/null +++ b/test/fixtures/wpt/WebCryptoAPI/serialization/chacha20-poly1305.tentative.https.any.js @@ -0,0 +1,11 @@ +// META: title=WebCryptoAPI: CryptoKey serialization +// META: script=../util/helpers.js +// META: script=serialization.js +run_test([ + { + name: 'ChaCha20-Poly1305', + resultType: 'CryptoKey', + usages: ['encrypt', 'decrypt', 'wrapKey', 'unwrapKey'], + exportFormat: 'raw-secret' + }, +]); diff --git a/test/fixtures/wpt/WebCryptoAPI/serialization/ecdh.https.any.js b/test/fixtures/wpt/WebCryptoAPI/serialization/ecdh.https.any.js new file mode 100644 index 00000000000000..17df8a87ba6ffb --- /dev/null +++ b/test/fixtures/wpt/WebCryptoAPI/serialization/ecdh.https.any.js @@ -0,0 +1,12 @@ +// META: title=WebCryptoAPI: CryptoKey serialization +// META: script=../util/helpers.js +// META: script=serialization.js +run_test([ + { + name: 'ECDH', + resultType: 'CryptoKeyPair', + usages: ['deriveKey', 'deriveBits'], + publicFormat: 'raw', + privateFormat: 'pkcs8' + }, +]); diff --git a/test/fixtures/wpt/WebCryptoAPI/serialization/ecdsa.https.any.js b/test/fixtures/wpt/WebCryptoAPI/serialization/ecdsa.https.any.js new file mode 100644 index 00000000000000..679dc066f53193 --- /dev/null +++ b/test/fixtures/wpt/WebCryptoAPI/serialization/ecdsa.https.any.js @@ -0,0 +1,12 @@ +// META: title=WebCryptoAPI: CryptoKey serialization +// META: script=../util/helpers.js +// META: script=serialization.js +run_test([ + { + name: 'ECDSA', + resultType: 'CryptoKeyPair', + usages: ['sign', 'verify'], + publicFormat: 'raw', + privateFormat: 'pkcs8' + }, +]); diff --git a/test/fixtures/wpt/WebCryptoAPI/serialization/ed25519.https.any.js b/test/fixtures/wpt/WebCryptoAPI/serialization/ed25519.https.any.js new file mode 100644 index 00000000000000..831e91725b6bae --- /dev/null +++ b/test/fixtures/wpt/WebCryptoAPI/serialization/ed25519.https.any.js @@ -0,0 +1,12 @@ +// META: title=WebCryptoAPI: CryptoKey serialization +// META: script=../util/helpers.js +// META: script=serialization.js +run_test([ + { + name: 'Ed25519', + resultType: 'CryptoKeyPair', + usages: ['sign', 'verify'], + publicFormat: 'raw', + privateFormat: 'pkcs8' + }, +]); diff --git a/test/fixtures/wpt/WebCryptoAPI/serialization/ed448.tentative.https.any.js b/test/fixtures/wpt/WebCryptoAPI/serialization/ed448.tentative.https.any.js new file mode 100644 index 00000000000000..4abe56285689b8 --- /dev/null +++ b/test/fixtures/wpt/WebCryptoAPI/serialization/ed448.tentative.https.any.js @@ -0,0 +1,12 @@ +// META: title=WebCryptoAPI: CryptoKey serialization +// META: script=../util/helpers.js +// META: script=serialization.js +run_test([ + { + name: 'Ed448', + resultType: 'CryptoKeyPair', + usages: ['sign', 'verify'], + publicFormat: 'raw', + privateFormat: 'pkcs8' + }, +]); diff --git a/test/fixtures/wpt/WebCryptoAPI/serialization/hmac.https.any.js b/test/fixtures/wpt/WebCryptoAPI/serialization/hmac.https.any.js new file mode 100644 index 00000000000000..99efea6bcaa996 --- /dev/null +++ b/test/fixtures/wpt/WebCryptoAPI/serialization/hmac.https.any.js @@ -0,0 +1,11 @@ +// META: title=WebCryptoAPI: CryptoKey serialization +// META: script=../util/helpers.js +// META: script=serialization.js +run_test([ + { + name: 'HMAC', + resultType: 'CryptoKey', + usages: ['sign', 'verify'], + exportFormat: 'raw' + }, +]); diff --git a/test/fixtures/wpt/WebCryptoAPI/serialization/kmac.tentative.https.any.js b/test/fixtures/wpt/WebCryptoAPI/serialization/kmac.tentative.https.any.js new file mode 100644 index 00000000000000..645d16bec776fb --- /dev/null +++ b/test/fixtures/wpt/WebCryptoAPI/serialization/kmac.tentative.https.any.js @@ -0,0 +1,17 @@ +// META: title=WebCryptoAPI: CryptoKey serialization +// META: script=../util/helpers.js +// META: script=serialization.js +run_test([ + { + name: 'KMAC128', + resultType: 'CryptoKey', + usages: ['sign', 'verify'], + exportFormat: 'raw-secret' + }, + { + name: 'KMAC256', + resultType: 'CryptoKey', + usages: ['sign', 'verify'], + exportFormat: 'raw-secret' + }, +]); diff --git a/test/fixtures/wpt/WebCryptoAPI/serialization/mldsa.tentative.https.any.js b/test/fixtures/wpt/WebCryptoAPI/serialization/mldsa.tentative.https.any.js new file mode 100644 index 00000000000000..3f61248b3d9e49 --- /dev/null +++ b/test/fixtures/wpt/WebCryptoAPI/serialization/mldsa.tentative.https.any.js @@ -0,0 +1,27 @@ +// META: title=WebCryptoAPI: CryptoKey serialization +// META: script=../util/helpers.js +// META: script=serialization.js + +run_test([ + { + name: 'ML-DSA-44', + resultType: 'CryptoKeyPair', + usages: ['sign', 'verify'], + publicFormat: 'raw-public', + privateFormat: 'raw-seed' + }, + { + name: 'ML-DSA-65', + resultType: 'CryptoKeyPair', + usages: ['sign', 'verify'], + publicFormat: 'raw-public', + privateFormat: 'raw-seed' + }, + { + name: 'ML-DSA-87', + resultType: 'CryptoKeyPair', + usages: ['sign', 'verify'], + publicFormat: 'raw-public', + privateFormat: 'raw-seed' + }, +]); diff --git a/test/fixtures/wpt/WebCryptoAPI/serialization/mlkem.tentative.https.any.js b/test/fixtures/wpt/WebCryptoAPI/serialization/mlkem.tentative.https.any.js new file mode 100644 index 00000000000000..62a210f0cda218 --- /dev/null +++ b/test/fixtures/wpt/WebCryptoAPI/serialization/mlkem.tentative.https.any.js @@ -0,0 +1,32 @@ +// META: title=WebCryptoAPI: CryptoKey serialization +// META: script=../util/helpers.js +// META: script=serialization.js +run_test([ + { + name: 'ML-KEM-512', + resultType: 'CryptoKeyPair', + usages: [ + 'decapsulateBits', 'decapsulateKey', 'encapsulateBits', 'encapsulateKey' + ], + publicFormat: 'raw-public', + privateFormat: 'raw-seed' + }, + { + name: 'ML-KEM-768', + resultType: 'CryptoKeyPair', + usages: [ + 'decapsulateBits', 'decapsulateKey', 'encapsulateBits', 'encapsulateKey' + ], + publicFormat: 'raw-public', + privateFormat: 'raw-seed' + }, + { + name: 'ML-KEM-1024', + resultType: 'CryptoKeyPair', + usages: [ + 'decapsulateBits', 'decapsulateKey', 'encapsulateBits', 'encapsulateKey' + ], + publicFormat: 'raw-public', + privateFormat: 'raw-seed' + }, +]); diff --git a/test/fixtures/wpt/WebCryptoAPI/serialization/rsa-oaep.https.any.js b/test/fixtures/wpt/WebCryptoAPI/serialization/rsa-oaep.https.any.js new file mode 100644 index 00000000000000..42469307155d50 --- /dev/null +++ b/test/fixtures/wpt/WebCryptoAPI/serialization/rsa-oaep.https.any.js @@ -0,0 +1,12 @@ +// META: title=WebCryptoAPI: CryptoKey serialization +// META: script=../util/helpers.js +// META: script=serialization.js +run_test([ + { + name: 'RSA-OAEP', + resultType: 'CryptoKeyPair', + usages: ['encrypt', 'decrypt', 'wrapKey', 'unwrapKey'], + publicFormat: 'spki', + privateFormat: 'pkcs8' + }, +]); diff --git a/test/fixtures/wpt/WebCryptoAPI/serialization/rsa-pss.https.any.js b/test/fixtures/wpt/WebCryptoAPI/serialization/rsa-pss.https.any.js new file mode 100644 index 00000000000000..a1255b7638bc37 --- /dev/null +++ b/test/fixtures/wpt/WebCryptoAPI/serialization/rsa-pss.https.any.js @@ -0,0 +1,12 @@ +// META: title=WebCryptoAPI: CryptoKey serialization +// META: script=../util/helpers.js +// META: script=serialization.js +run_test([ + { + name: 'RSA-PSS', + resultType: 'CryptoKeyPair', + usages: ['sign', 'verify'], + publicFormat: 'spki', + privateFormat: 'pkcs8' + }, +]); diff --git a/test/fixtures/wpt/WebCryptoAPI/serialization/rsassa-pkcs1-v1_5.https.any.js b/test/fixtures/wpt/WebCryptoAPI/serialization/rsassa-pkcs1-v1_5.https.any.js new file mode 100644 index 00000000000000..051eb87e07856e --- /dev/null +++ b/test/fixtures/wpt/WebCryptoAPI/serialization/rsassa-pkcs1-v1_5.https.any.js @@ -0,0 +1,12 @@ +// META: title=WebCryptoAPI: CryptoKey serialization +// META: script=../util/helpers.js +// META: script=serialization.js +run_test([ + { + name: 'RSASSA-PKCS1-v1_5', + resultType: 'CryptoKeyPair', + usages: ['sign', 'verify'], + publicFormat: 'spki', + privateFormat: 'pkcs8' + }, +]); diff --git a/test/fixtures/wpt/WebCryptoAPI/serialization/serialization.js b/test/fixtures/wpt/WebCryptoAPI/serialization/serialization.js new file mode 100644 index 00000000000000..a9444032503268 --- /dev/null +++ b/test/fixtures/wpt/WebCryptoAPI/serialization/serialization.js @@ -0,0 +1,55 @@ +function run_test(vectors) { + function testCryptoKeySerialization( + generateKeyAlgorithm, generateKeyUsages, exportFormat) { + promise_test(async t => { + var cryptoKey = await crypto.subtle.generateKey( + generateKeyAlgorithm, true, generateKeyUsages); + const keyExported = + await crypto.subtle.exportKey(exportFormat, cryptoKey); + + const {key} = structuredClone({key: cryptoKey}); + const newKeyExported = + await crypto.subtle.exportKey(exportFormat, key); + assert_true(equalBuffers(keyExported, newKeyExported)); + }, 'serialization test ' + objectToString(generateKeyAlgorithm)); + }; + + function testCryptoKeyPairSerialization( + generateKeyAlgorithm, generateKeyUsages, publicExportFormat, + privateExportFormat) { + promise_test(async t => { + var keyPair = await crypto.subtle.generateKey( + generateKeyAlgorithm, true, generateKeyUsages); + const publicKeyExported = + await crypto.subtle.exportKey(publicExportFormat, keyPair.publicKey); + const privateKeyExported = await crypto.subtle.exportKey( + privateExportFormat, keyPair.privateKey); + + const {publicKey, privateKey} = structuredClone( + {publicKey: keyPair.publicKey, privateKey: keyPair.privateKey}); + const newPublicKeyExported = + await crypto.subtle.exportKey(publicExportFormat, publicKey); + assert_true(equalBuffers(publicKeyExported, newPublicKeyExported)); + const newPrivateKeyExported = await crypto.subtle.exportKey( + privateExportFormat, privateKey); + assert_true(equalBuffers(privateKeyExported, newPrivateKeyExported)); + }, 'serialization test ' + objectToString(generateKeyAlgorithm)); + }; + + vectors.forEach(function(vector) { + if (vector.resultType === 'CryptoKey') { + allAlgorithmSpecifiersFor(vector.name) + .forEach(function(generateKeyAlgorithm) { + testCryptoKeySerialization( + generateKeyAlgorithm, vector.usages, vector.exportFormat); + }); + } else { + allAlgorithmSpecifiersFor(vector.name) + .forEach(function(generateKeyAlgorithm) { + testCryptoKeyPairSerialization( + generateKeyAlgorithm, vector.usages, vector.publicFormat, + vector.privateFormat); + }); + } + }); +} diff --git a/test/fixtures/wpt/WebCryptoAPI/serialization/x25519.https.any.js b/test/fixtures/wpt/WebCryptoAPI/serialization/x25519.https.any.js new file mode 100644 index 00000000000000..618bf29ebfe206 --- /dev/null +++ b/test/fixtures/wpt/WebCryptoAPI/serialization/x25519.https.any.js @@ -0,0 +1,12 @@ +// META: title=WebCryptoAPI: CryptoKey serialization +// META: script=../util/helpers.js +// META: script=serialization.js +run_test([ + { + name: 'X25519', + resultType: 'CryptoKeyPair', + usages: ['deriveKey', 'deriveBits'], + publicFormat: 'raw', + privateFormat: 'pkcs8' + }, +]); diff --git a/test/fixtures/wpt/WebCryptoAPI/serialization/x448.tentative.https.any.js b/test/fixtures/wpt/WebCryptoAPI/serialization/x448.tentative.https.any.js new file mode 100644 index 00000000000000..cafc00144a3ce7 --- /dev/null +++ b/test/fixtures/wpt/WebCryptoAPI/serialization/x448.tentative.https.any.js @@ -0,0 +1,12 @@ +// META: title=WebCryptoAPI: CryptoKey serialization +// META: script=../util/helpers.js +// META: script=serialization.js +run_test([ + { + name: 'X448', + resultType: 'CryptoKeyPair', + usages: ['deriveKey', 'deriveBits'], + publicFormat: 'raw', + privateFormat: 'pkcs8' + }, +]); diff --git a/test/fixtures/wpt/versions.json b/test/fixtures/wpt/versions.json index 5a461bda392613..470592c842b925 100644 --- a/test/fixtures/wpt/versions.json +++ b/test/fixtures/wpt/versions.json @@ -96,7 +96,7 @@ "path": "web-locks" }, "WebCryptoAPI": { - "commit": "8b5cd267b480d75bce41aa306bebbd07ce414fa5", + "commit": "97bbc7247a16231f4744a47a1d9b3d29633d5292", "path": "WebCryptoAPI" }, "webidl": { diff --git a/test/wpt/status/WebCryptoAPI.cjs b/test/wpt/status/WebCryptoAPI.cjs index 4b01978511548f..c31831a6ea6a12 100644 --- a/test/wpt/status/WebCryptoAPI.cjs +++ b/test/wpt/status/WebCryptoAPI.cjs @@ -36,6 +36,8 @@ if (!hasOpenSSL(3, 0)) { 'generateKey/successes_kmac.tentative.https.any.js', 'import_export/AES-OCB_importKey.tentative.https.any.js', 'import_export/KMAC_importKey.tentative.https.any.js', + 'serialization/aes-ocb.tentative.https.any.js', + 'serialization/kmac.tentative.https.any.js', 'sign_verify/kmac.tentative.https.any.js'); } @@ -55,6 +57,8 @@ if (!hasOpenSSL(3, 5) && !process.features.openssl_is_boringssl) { 'generateKey/successes_ML-KEM.tentative.https.any.js', 'import_export/ML-DSA_importKey.tentative.https.any.js', 'import_export/ML-KEM_importKey.tentative.https.any.js', + 'serialization/mldsa.tentative.https.any.js', + 'serialization/mlkem.tentative.https.any.js', 'sign_verify/mldsa.tentative.https.any.js'); skipSubtests( @@ -75,6 +79,8 @@ if (process.features.openssl_is_boringssl) { 'import_export/okp_importKey_failures_Ed448.tentative.https.any.js', 'import_export/okp_importKey_failures_X448.tentative.https.any.js', 'import_export/okp_importKey_X448.tentative.https.any.js', + 'serialization/ed448.tentative.https.any.js', + 'serialization/x448.tentative.https.any.js', 'sign_verify/eddsa_curve448.tentative.https.any.js'); skipSubtests( @@ -83,6 +89,7 @@ if (process.features.openssl_is_boringssl) { ['generateKey/failures_ML-KEM.tentative.https.any.js', /ml-kem-512/i], ['generateKey/successes_ML-KEM.tentative.https.any.js', /ml-kem-512/i], ['import_export/ML-KEM_importKey.tentative.https.any.js', /ml-kem-512/i], + ['serialization/mlkem.tentative.https.any.js', /ml-kem-512/i], ['supports-modern.tentative.https.any.js', /ml-kem-512/i]); }