GeezerVison is showing github.com — test: update WPT for WebCryptoAPI to 2cb332d710 · nodejs/node@3796a73
File treeExpand file treeCollapse file tree Open diff view settings WebCryptoAPI/import_export
Expand file treeCollapse file tree Open diff view settings Collapse file Copy file name to clipboardExpand all lines: test/fixtures/wpt/README.md +1-1Lines changed: 1 addition & 1 deletion - Display the source diff
- Display the rich diff
| Original file line number | Diff line number | Diff line change |
|---|
@@ -34,7 +34,7 @@ Last update: | 34 | 34 | - wasm/jsapi: https://github.com/web-platform-tests/wpt/tree/cde25e7e3c/wasm/jsapi | 35 | 35 | - wasm/webapi: https://github.com/web-platform-tests/wpt/tree/fd1b23eeaa/wasm/webapi | 36 | 36 | - web-locks: https://github.com/web-platform-tests/wpt/tree/10a122a6bc/web-locks | 37 | | -- WebCryptoAPI: https://github.com/web-platform-tests/wpt/tree/0acea989ac/WebCryptoAPI | | 37 | +- WebCryptoAPI: https://github.com/web-platform-tests/wpt/tree/2cb332d710/WebCryptoAPI | 38 | 38 | - webidl: https://github.com/web-platform-tests/wpt/tree/63ca529a02/webidl | 39 | 39 | - webidl/ecmascript-binding/es-exceptions: https://github.com/web-platform-tests/wpt/tree/2f96fa1996/webidl/ecmascript-binding/es-exceptions | 40 | 40 | - webmessaging/broadcastchannel: https://github.com/web-platform-tests/wpt/tree/6495c91853/webmessaging/broadcastchannel | |
Collapse file Copy file name to clipboard +72Lines changed: 72 additions & 0 deletions | Original file line number | Diff line number | Diff line change |
|---|
| | 1 | +// META: title=WebCryptoAPI: raw-secret and raw-public importKey() format aliases | | 2 | +// META: timeout=long | | 3 | +// META: script=../util/helpers.js | | 4 | + | | 5 | +// For all existing symmetric algorithms in WebCrypto, "raw-secret" acts as an | | 6 | +// alias of "raw". For all existing asymmetric algorithms in WebCrypto, | | 7 | +// "raw-public" acts as an alias of "raw". | | 8 | + | | 9 | +"use strict"; | | 10 | + | | 11 | +const rawKeyData16 = crypto.getRandomValues(new Uint8Array(16)); | | 12 | +const rawKeyData32 = crypto.getRandomValues(new Uint8Array(32)); | | 13 | +const wrapAlgorithm = { name: "AES-GCM", iv: new Uint8Array(12) }; | | 14 | + | | 15 | +const symmetricAlgorithms = [ | | 16 | + { algorithm: { name: "AES-CTR", length: 128 }, keyData: rawKeyData16, usages: ["encrypt", "decrypt"] }, | | 17 | + { algorithm: { name: "AES-CBC", length: 128 }, keyData: rawKeyData16, usages: ["encrypt", "decrypt"] }, | | 18 | + { algorithm: { name: "AES-GCM", length: 128 }, keyData: rawKeyData16, usages: ["encrypt", "decrypt"] }, | | 19 | + { algorithm: { name: "AES-KW", length: 128 }, keyData: rawKeyData16, usages: ["wrapKey", "unwrapKey"] }, | | 20 | + { algorithm: { name: "HMAC", hash: "SHA-256", length: 256 }, keyData: rawKeyData32, usages: ["sign", "verify"] }, | | 21 | + { algorithm: { name: "HKDF" }, keyData: rawKeyData32, usages: ["deriveBits", "deriveKey"], extractable: false }, | | 22 | + { algorithm: { name: "PBKDF2" }, keyData: rawKeyData32, usages: ["deriveBits", "deriveKey"], extractable: false }, | | 23 | +]; | | 24 | + | | 25 | +for (const { algorithm, keyData, usages, extractable = true } of symmetricAlgorithms) { | | 26 | + promise_test(async () => { | | 27 | + const key = await crypto.subtle.importKey("raw-secret", keyData, algorithm, extractable, usages); | | 28 | + assert_goodCryptoKey(key, algorithm, extractable, usages, "secret"); | | 29 | + if (extractable) { | | 30 | + await crypto.subtle.exportKey("raw-secret", key); | | 31 | + } | | 32 | + }, `importKey/exportKey with raw-secret: ${algorithm.name}`); | | 33 | + | | 34 | + if (extractable) { | | 35 | + promise_test(async () => { | | 36 | + const wrappingKey = await crypto.subtle.generateKey({ name: "AES-GCM", length: 256 }, false, ["wrapKey", "unwrapKey"]); | | 37 | + const key = await crypto.subtle.importKey("raw-secret", keyData, algorithm, true, usages); | | 38 | + const wrapped = await crypto.subtle.wrapKey("raw-secret", key, wrappingKey, wrapAlgorithm); | | 39 | + const unwrapped = await crypto.subtle.unwrapKey("raw-secret", wrapped, wrappingKey, wrapAlgorithm, algorithm, true, usages); | | 40 | + assert_goodCryptoKey(unwrapped, algorithm, true, usages, "secret"); | | 41 | + }, `wrapKey/unwrapKey with raw-secret: ${algorithm.name}`); | | 42 | + } | | 43 | +} | | 44 | + | | 45 | +const asymmetricAlgorithms = [ | | 46 | + { algorithm: { name: "ECDSA", namedCurve: "P-256" }, usages: ["verify"] }, | | 47 | + { algorithm: { name: "ECDH", namedCurve: "P-256" }, usages: [] }, | | 48 | + { algorithm: { name: "Ed25519" }, usages: ["verify"] }, | | 49 | + { algorithm: { name: "X25519" }, usages: [] }, | | 50 | +]; | | 51 | + | | 52 | +for (const { algorithm, usages } of asymmetricAlgorithms) { | | 53 | + const generateKeyUsages = usages.length ? usages.concat("sign") : ["deriveBits"]; | | 54 | + | | 55 | + promise_test(async () => { | | 56 | + const keyPair = await crypto.subtle.generateKey(algorithm, true, generateKeyUsages); | | 57 | + const keyData = await crypto.subtle.exportKey("raw-public", keyPair.publicKey); | | 58 | + | | 59 | + const key = await crypto.subtle.importKey("raw-public", keyData, algorithm, true, usages); | | 60 | + assert_goodCryptoKey(key, algorithm, true, usages, "public"); | | 61 | + await crypto.subtle.exportKey("raw-public", key); | | 62 | + }, `importKey/exportKey with raw-public: ${algorithm.name}`); | | 63 | + | | 64 | + promise_test(async () => { | | 65 | + const keyPair = await crypto.subtle.generateKey(algorithm, true, generateKeyUsages); | | 66 | + | | 67 | + const wrappingKey = await crypto.subtle.generateKey({ name: "AES-GCM", length: 256 }, false, ["wrapKey", "unwrapKey"]); | | 68 | + const wrapped = await crypto.subtle.wrapKey("raw-public", keyPair.publicKey, wrappingKey, wrapAlgorithm); | | 69 | + const unwrapped = await crypto.subtle.unwrapKey("raw-public", wrapped, wrappingKey, wrapAlgorithm, algorithm, true, usages); | | 70 | + assert_goodCryptoKey(unwrapped, algorithm, true, usages, "public"); | | 71 | + }, `wrapKey/unwrapKey with raw-public: ${algorithm.name}`); | | 72 | +} |
Collapse file Copy file name to clipboardExpand all lines: test/fixtures/wpt/versions.json +1-1Lines changed: 1 addition & 1 deletion | Original file line number | Diff line number | Diff line change |
|---|
| 96 | 96 | "path": "web-locks" | 97 | 97 | }, | 98 | 98 | "WebCryptoAPI": { | 99 | | - "commit": "0acea989ac21842d6545d16594f1a05491c6076e", | | 99 | + "commit": "2cb332d71030ba0200610d72b94bb1badf447418", | 100 | 100 | "path": "WebCryptoAPI" | 101 | 101 | }, | 102 | 102 | "webidl": { | |
|