GeezerVison is showing github.com — test,crypto: update WebCryptoAPI WPT · nodejs/node@69c1f2a
File treeExpand file treeCollapse file tree Open diff view settings 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 |
|---|
@@ -30,7 +30,7 @@ Last update: | 30 | 30 | - user-timing: https://github.com/web-platform-tests/wpt/tree/df24fb604e/user-timing | 31 | 31 | - wasm/jsapi: https://github.com/web-platform-tests/wpt/tree/d8dbe6990b/wasm/jsapi | 32 | 32 | - wasm/webapi: https://github.com/web-platform-tests/wpt/tree/fd1b23eeaa/wasm/webapi | 33 | | -- WebCryptoAPI: https://github.com/web-platform-tests/wpt/tree/edca84af42/WebCryptoAPI | | 33 | +- WebCryptoAPI: https://github.com/web-platform-tests/wpt/tree/0042d42ee6/WebCryptoAPI | 34 | 34 | - webidl/ecmascript-binding/es-exceptions: https://github.com/web-platform-tests/wpt/tree/a370aad338/webidl/ecmascript-binding/es-exceptions | 35 | 35 |
| 36 | 36 | [Web Platform Tests]: https://github.com/web-platform-tests/wpt | |
Collapse file Copy file name to clipboardExpand all lines: test/fixtures/wpt/WebCryptoAPI/derive_bits_keys/cfrg_curves_bits.js +7-1Lines changed: 7 additions & 1 deletion | Original file line number | Diff line number | Diff line change |
|---|
@@ -150,7 +150,7 @@ function define_tests() { | 150 | 150 | promise_test(function(test) { | 151 | 151 | return subtle.generateKey({name: "AES-CBC", length: 128}, true, ["encrypt", "decrypt"]) | 152 | 152 | .then(function(secretKey) { | 153 | | - subtle.deriveBits({name: algorithmName, public: secretKey}, privateKeys[algorithmName], 8 * sizes[algorithmName]) | | 153 | + return subtle.deriveBits({name: algorithmName, public: secretKey}, privateKeys[algorithmName], 8 * sizes[algorithmName]) | 154 | 154 | .then(function(derivation) { | 155 | 155 | assert_unreached("deriveBits succeeded but should have failed with InvalidAccessError"); | 156 | 156 | }, function(err) { | @@ -183,6 +183,8 @@ function define_tests() { | 183 | 183 | false, ["deriveBits", "deriveKey"]) | 184 | 184 | .then(function(key) { | 185 | 185 | privateKeys[algorithmName] = key; | | 186 | + }, function (err) { | | 187 | + privateKeys[algorithmName] = null; | 186 | 188 | }); | 187 | 189 | promises.push(operation); | 188 | 190 | }); | @@ -192,6 +194,8 @@ function define_tests() { | 192 | 194 | false, ["deriveKey"]) | 193 | 195 | .then(function(key) { | 194 | 196 | noDeriveBitsKeys[algorithmName] = key; | | 197 | + }, function (err) { | | 198 | + noDeriveBitsKeys[algorithmName] = null; | 195 | 199 | }); | 196 | 200 | promises.push(operation); | 197 | 201 | }); | @@ -201,6 +205,8 @@ function define_tests() { | 201 | 205 | false, []) | 202 | 206 | .then(function(key) { | 203 | 207 | publicKeys[algorithmName] = key; | | 208 | + }, function (err) { | | 209 | + publicKeys[algorithmName] = null; | 204 | 210 | }); | 205 | 211 | promises.push(operation); | 206 | 212 | }); | |
Collapse file Copy file name to clipboardExpand all lines: test/fixtures/wpt/WebCryptoAPI/derive_bits_keys/cfrg_curves_keys.js +7-1Lines changed: 7 additions & 1 deletion | Original file line number | Diff line number | Diff line change |
|---|
@@ -127,7 +127,7 @@ function define_tests() { | 127 | 127 | promise_test(function(test) { | 128 | 128 | return subtle.generateKey({name: "HMAC", hash: "SHA-256", length: 256}, true, ["sign", "verify"]) | 129 | 129 | .then(function(secretKey) { | 130 | | - subtle.deriveKey({name: algorithmName, public: secretKey}, privateKeys[algorithmName], {name: "AES-CBC", length: 256}, true, ["sign", "verify"]) | | 130 | + return subtle.deriveKey({name: algorithmName, public: secretKey}, privateKeys[algorithmName], {name: "AES-CBC", length: 256}, true, ["sign", "verify"]) | 131 | 131 | .then(function(key) {return crypto.subtle.exportKey("raw", key);}) | 132 | 132 | .then(function(exportedKey) { | 133 | 133 | assert_unreached("deriveKey succeeded but should have failed with InvalidAccessError"); | @@ -151,6 +151,8 @@ function define_tests() { | 151 | 151 | false, ["deriveBits", "deriveKey"]) | 152 | 152 | .then(function(key) { | 153 | 153 | privateKeys[algorithmName] = key; | | 154 | + }, function (err) { | | 155 | + privateKeys[algorithmName] = null; | 154 | 156 | }); | 155 | 157 | promises.push(operation); | 156 | 158 | }); | @@ -160,6 +162,8 @@ function define_tests() { | 160 | 162 | false, ["deriveBits"]) | 161 | 163 | .then(function(key) { | 162 | 164 | noDeriveKeyKeys[algorithmName] = key; | | 165 | + }, function (err) { | | 166 | + noDeriveKeyKeys[algorithmName] = null; | 163 | 167 | }); | 164 | 168 | promises.push(operation); | 165 | 169 | }); | @@ -169,6 +173,8 @@ function define_tests() { | 169 | 173 | false, []) | 170 | 174 | .then(function(key) { | 171 | 175 | publicKeys[algorithmName] = key; | | 176 | + }, function (err) { | | 177 | + publicKeys[algorithmName] = null; | 172 | 178 | }); | 173 | 179 | promises.push(operation); | 174 | 180 | }); | |
Collapse file Copy file name to clipboardExpand all lines: test/fixtures/wpt/WebCryptoAPI/derive_bits_keys/ecdh_bits.js +9-1Lines changed: 9 additions & 1 deletion | Original file line number | Diff line number | Diff line change |
|---|
@@ -165,7 +165,7 @@ function define_tests() { | 165 | 165 | promise_test(function(test) { | 166 | 166 | return subtle.generateKey({name: "AES-CBC", length: 128}, true, ["encrypt", "decrypt"]) | 167 | 167 | .then(function(secretKey) { | 168 | | - subtle.deriveBits({name: "ECDH", public: secretKey}, privateKeys[namedCurve], 8 * sizes[namedCurve]) | | 168 | + return subtle.deriveBits({name: "ECDH", public: secretKey}, privateKeys[namedCurve], 8 * sizes[namedCurve]) | 169 | 169 | .then(function(derivation) { | 170 | 170 | assert_unreached("deriveBits succeeded but should have failed with InvalidAccessError"); | 171 | 171 | }, function(err) { | @@ -199,6 +199,8 @@ function define_tests() { | 199 | 199 | false, ["deriveBits", "deriveKey"]) | 200 | 200 | .then(function(key) { | 201 | 201 | privateKeys[namedCurve] = key; | | 202 | + }, function (err) { | | 203 | + privateKeys[namedCurve] = null; | 202 | 204 | }); | 203 | 205 | promises.push(operation); | 204 | 206 | }); | @@ -208,6 +210,8 @@ function define_tests() { | 208 | 210 | false, ["deriveKey"]) | 209 | 211 | .then(function(key) { | 210 | 212 | noDeriveBitsKeys[namedCurve] = key; | | 213 | + }, function (err) { | | 214 | + noDeriveBitsKeys[namedCurve] = null; | 211 | 215 | }); | 212 | 216 | promises.push(operation); | 213 | 217 | }); | @@ -217,13 +221,17 @@ function define_tests() { | 217 | 221 | false, []) | 218 | 222 | .then(function(key) { | 219 | 223 | publicKeys[namedCurve] = key; | | 224 | + }, function (err) { | | 225 | + publicKeys[namedCurve] = null; | 220 | 226 | }); | 221 | 227 | promises.push(operation); | 222 | 228 | }); | 223 | 229 | Object.keys(sizes).forEach(function(namedCurve) { | 224 | 230 | var operation = subtle.generateKey({name: "ECDSA", namedCurve: namedCurve}, false, ["sign", "verify"]) | 225 | 231 | .then(function(keyPair) { | 226 | 232 | ecdsaKeyPairs[namedCurve] = keyPair; | | 233 | + }, function (err) { | | 234 | + ecdsaKeyPairs[namedCurve] = null; | 227 | 235 | }); | 228 | 236 | promises.push(operation); | 229 | 237 | }); | |
Collapse file Copy file name to clipboardExpand all lines: test/fixtures/wpt/WebCryptoAPI/derive_bits_keys/ecdh_keys.js +9-1Lines changed: 9 additions & 1 deletion | Original file line number | Diff line number | Diff line change |
|---|
@@ -143,7 +143,7 @@ function define_tests() { | 143 | 143 | promise_test(function(test) { | 144 | 144 | return subtle.generateKey({name: "HMAC", hash: "SHA-256", length: 256}, true, ["sign", "verify"]) | 145 | 145 | .then(function(secretKey) { | 146 | | - subtle.deriveKey({name: "ECDH", public: secretKey}, privateKeys[namedCurve], {name: "AES-CBC", length: 256}, true, ["sign", "verify"]) | | 146 | + return subtle.deriveKey({name: "ECDH", public: secretKey}, privateKeys[namedCurve], {name: "AES-CBC", length: 256}, true, ["sign", "verify"]) | 147 | 147 | .then(function(key) {return crypto.subtle.exportKey("raw", key);}) | 148 | 148 | .then(function(exportedKey) { | 149 | 149 | assert_unreached("deriveKey succeeded but should have failed with InvalidAccessError"); | @@ -168,6 +168,8 @@ function define_tests() { | 168 | 168 | false, ["deriveBits", "deriveKey"]) | 169 | 169 | .then(function(key) { | 170 | 170 | privateKeys[namedCurve] = key; | | 171 | + }, function (err) { | | 172 | + privateKeys[namedCurve] = null; | 171 | 173 | }); | 172 | 174 | promises.push(operation); | 173 | 175 | }); | @@ -177,6 +179,8 @@ function define_tests() { | 177 | 179 | false, ["deriveBits"]) | 178 | 180 | .then(function(key) { | 179 | 181 | noDeriveKeyKeys[namedCurve] = key; | | 182 | + }, function (err) { | | 183 | + noDeriveKeyKeys[namedCurve] = null; | 180 | 184 | }); | 181 | 185 | promises.push(operation); | 182 | 186 | }); | @@ -186,13 +190,17 @@ function define_tests() { | 186 | 190 | false, []) | 187 | 191 | .then(function(key) { | 188 | 192 | publicKeys[namedCurve] = key; | | 193 | + }, function (err) { | | 194 | + publicKeys[namedCurve] = null; | 189 | 195 | }); | 190 | 196 | promises.push(operation); | 191 | 197 | }); | 192 | 198 | Object.keys(sizes).forEach(function(namedCurve) { | 193 | 199 | var operation = subtle.generateKey({name: "ECDSA", namedCurve: namedCurve}, false, ["sign", "verify"]) | 194 | 200 | .then(function(keyPair) { | 195 | 201 | ecdsaKeyPairs[namedCurve] = keyPair; | | 202 | + }, function (err) { | | 203 | + ecdsaKeyPairs[namedCurve] = null; | 196 | 204 | }); | 197 | 205 | promises.push(operation); | 198 | 206 | }); | |
Collapse file Copy file name to clipboardExpand all lines: test/fixtures/wpt/WebCryptoAPI/util/helpers.js +25-6Lines changed: 25 additions & 6 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -110,7 +110,22 @@ function assert_goodCryptoKey(key, algorithm, extractable, usages, kind) { | 110 | 110 | assert_equals(key.extractable, extractable, "Extractability is correct"); | 111 | 111 |
| 112 | 112 | assert_equals(key.algorithm.name, registeredAlgorithmName, "Correct algorithm name"); | 113 | | - assert_equals(key.algorithm.length, algorithm.length, "Correct length"); | | 113 | + if (key.algorithm.name.toUpperCase() === "HMAC" && algorithm.length === undefined) { | | 114 | + switch (key.algorithm.hash.name.toUpperCase()) { | | 115 | + case 'SHA-1': | | 116 | + case 'SHA-256': | | 117 | + assert_equals(key.algorithm.length, 512, "Correct length"); | | 118 | + break; | | 119 | + case 'SHA-384': | | 120 | + case 'SHA-512': | | 121 | + assert_equals(key.algorithm.length, 1024, "Correct length"); | | 122 | + break; | | 123 | + default: | | 124 | + assert_unreached("Unrecognized hash"); | | 125 | + } | | 126 | + } else { | | 127 | + assert_equals(key.algorithm.length, algorithm.length, "Correct length"); | | 128 | + } | 114 | 129 | if (["HMAC", "RSASSA-PKCS1-v1_5", "RSA-PSS"].includes(registeredAlgorithmName)) { | 115 | 130 | assert_equals(key.algorithm.hash.name.toUpperCase(), algorithm.hash.toUpperCase(), "Correct hash function"); | 116 | 131 | } | @@ -166,12 +181,16 @@ function allAlgorithmSpecifiersFor(algorithmName) { | 166 | 181 | }); | 167 | 182 | } else if (algorithmName.toUpperCase() === "HMAC") { | 168 | 183 | [ | 169 | | - {name: "SHA-1", length: 160}, | 170 | | - {name: "SHA-256", length: 256}, | 171 | | - {name: "SHA-384", length: 384}, | 172 | | - {name: "SHA-512", length: 512} | | 184 | + {hash: "SHA-1", length: 160}, | | 185 | + {hash: "SHA-256", length: 256}, | | 186 | + {hash: "SHA-384", length: 384}, | | 187 | + {hash: "SHA-512", length: 512}, | | 188 | + {hash: "SHA-1"}, | | 189 | + {hash: "SHA-256"}, | | 190 | + {hash: "SHA-384"}, | | 191 | + {hash: "SHA-512"}, | 173 | 192 | ].forEach(function(hashAlgorithm) { | 174 | | - results.push({name: algorithmName, hash: hashAlgorithm.name, length: hashAlgorithm.length}); | | 193 | + results.push({name: algorithmName, ...hashAlgorithm}); | 175 | 194 | }); | 176 | 195 | } else if (algorithmName.toUpperCase().substring(0, 3) === "RSA") { | 177 | 196 | hashes.forEach(function(hashName) { | |
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 |
|---|
| 80 | 80 | "path": "wasm/webapi" | 81 | 81 | }, | 82 | 82 | "WebCryptoAPI": { | 83 | | - "commit": "edca84af42bd7e84da94e63b322fe343191842d2", | | 83 | + "commit": "0042d42ee69baf05a4ac4f5745be9c3b92c04e25", | 84 | 84 | "path": "WebCryptoAPI" | 85 | 85 | }, | 86 | 86 | "webidl/ecmascript-binding/es-exceptions": { | |
|