GeezerVison is showing github.com — test,crypto: update WebCryptoAPI WPT · nodejs/node@aa2c7e0
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 |
|---|
@@ -31,7 +31,7 @@ Last update: | 31 | 31 | - user-timing: https://github.com/web-platform-tests/wpt/tree/df24fb604e/user-timing | 32 | 32 | - wasm/jsapi: https://github.com/web-platform-tests/wpt/tree/cde25e7e3c/wasm/jsapi | 33 | 33 | - wasm/webapi: https://github.com/web-platform-tests/wpt/tree/fd1b23eeaa/wasm/webapi | 34 | | -- WebCryptoAPI: https://github.com/web-platform-tests/wpt/tree/188993d46b/WebCryptoAPI | | 34 | +- WebCryptoAPI: https://github.com/web-platform-tests/wpt/tree/17b7ca10fd/WebCryptoAPI | 35 | 35 | - webidl/ecmascript-binding/es-exceptions: https://github.com/web-platform-tests/wpt/tree/a370aad338/webidl/ecmascript-binding/es-exceptions | 36 | 36 | - webmessaging/broadcastchannel: https://github.com/web-platform-tests/wpt/tree/e97fac4791/webmessaging/broadcastchannel | 37 | 37 |
| |
Collapse file Copy file name to clipboardExpand all lines: test/fixtures/wpt/WebCryptoAPI/generateKey/failures.js +1-1Lines changed: 1 addition & 1 deletion | Original file line number | Diff line number | Diff line change |
|---|
@@ -204,7 +204,7 @@ function run_test(algorithmNames) { | 204 | 204 | }); | 205 | 205 |
| 206 | 206 |
| 207 | | - // The last thing that should be checked is an empty usages (for secret keys). | | 207 | + // The last thing that should be checked is empty usages (disallowed for secret and private keys). | 208 | 208 | testVectors.forEach(function(vector) { | 209 | 209 | var name = vector.name; | 210 | 210 |
| |
Collapse file Copy file name to clipboardExpand all lines: test/fixtures/wpt/WebCryptoAPI/import_export/ec_importKey.https.any.js +20-5Lines changed: 20 additions & 5 deletions | Original file line number | Diff line number | Diff line change |
|---|
| 85 | 85 | }); | 86 | 86 |
| 87 | 87 | // Next, test private keys | 88 | | - allValidUsages(vector.privateUsages, []).forEach(function(usages) { | 89 | | - ['pkcs8', 'jwk'].forEach(function(format) { | 90 | | - var algorithm = {name: vector.name, namedCurve: curve}; | 91 | | - var data = keyData[curve]; | 92 | | - | | 88 | + ['pkcs8', 'jwk'].forEach(function(format) { | | 89 | + var algorithm = {name: vector.name, namedCurve: curve}; | | 90 | + var data = keyData[curve]; | | 91 | + allValidUsages(vector.privateUsages, []).forEach(function(usages) { | 93 | 92 | testFormat(format, algorithm, data, curve, usages, extractable); | 94 | 93 | }); | | 94 | + testEmptyUsages(format, algorithm, data, curve, extractable); | 95 | 95 | }); | 96 | 96 | }); | 97 | 97 |
| | 136 | 136 | }, "Good parameters: " + keySize.toString() + " bits " + parameterString(format, compressed, keyData, algorithm, extractable, usages)); | 137 | 137 | } | 138 | 138 |
| | 139 | + // Test importKey with a given key format and other parameters but with empty usages. | | 140 | + // Should fail with SyntaxError | | 141 | + function testEmptyUsages(format, algorithm, data, keySize, extractable) { | | 142 | + const keyData = data[format]; | | 143 | + const usages = []; | | 144 | + promise_test(function(test) { | | 145 | + return subtle.importKey(format, keyData, algorithm, extractable, usages). | | 146 | + then(function(key) { | | 147 | + assert_unreached("importKey succeeded but should have failed with SyntaxError"); | | 148 | + }, function(err) { | | 149 | + assert_equals(err.name, "SyntaxError", "Should throw correct error, not " + err.name + ": " + err.message); | | 150 | + }); | | 151 | + }, "Empty Usages: " + keySize.toString() + " bits " + parameterString(format, false, keyData, algorithm, extractable, usages)); | | 152 | + } | | 153 | + | 139 | 154 |
| 140 | 155 |
| 141 | 156 | // Helper methods follow: | |
Collapse file Copy file name to clipboardExpand all lines: test/fixtures/wpt/WebCryptoAPI/import_export/okp_importKey_failures.js +13Lines changed: 13 additions & 0 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -132,6 +132,19 @@ function run_test(algorithmNames) { | 132 | 132 | }); | 133 | 133 | }); | 134 | 134 |
| | 135 | + // Algorithms normalize okay, but usages bad (empty). | | 136 | + // Should fail due to SyntaxError | | 137 | + testVectors.forEach(function(vector) { | | 138 | + var name = vector.name; | | 139 | + validKeyData.filter((test) => test.format === 'pkcs8' || (test.format === 'jwk' && test.data.d)).forEach(function(test) { | | 140 | + allAlgorithmSpecifiersFor(name).forEach(function(algorithm) { | | 141 | + [true, false].forEach(function(extractable) { | | 142 | + testError(test.format, algorithm, test.data, name, [/* Empty usages */], extractable, "SyntaxError", "Empty usages"); | | 143 | + }); | | 144 | + }); | | 145 | + }); | | 146 | + }); | | 147 | + | 135 | 148 | // Algorithms normalize okay, usages ok. The length of the key must thouw a DataError exception. | 136 | 149 | testVectors.forEach(function(vector) { | 137 | 150 | var name = vector.name; | |
Collapse file Copy file name to clipboardExpand all lines: test/fixtures/wpt/WebCryptoAPI/import_export/rsa_importKey.https.any.js +19-5Lines changed: 19 additions & 5 deletions Collapse file Copy file name to clipboardExpand all lines: test/fixtures/wpt/WebCryptoAPI/import_export/symmetric_importKey.https.any.js +24-9Lines changed: 24 additions & 9 deletions | Original file line number | Diff line number | Diff line change |
|---|
| 41 | 41 | } | 42 | 42 |
| 43 | 43 | rawKeyData.forEach(function(keyData) { | 44 | | - // Generate all combinations of valid usages for testing | 45 | | - allValidUsages(vector.legalUsages, []).forEach(function(usages) { | 46 | | - // Try each legal value of the extractable parameter | 47 | | - vector.extractable.forEach(function(extractable) { | 48 | | - vector.formats.forEach(function(format) { | 49 | | - var data = keyData; | 50 | | - if (format === "jwk") { | 51 | | - data = jwkData(keyData, algorithm); | 52 | | - } | | 44 | + // Try each legal value of the extractable parameter | | 45 | + vector.extractable.forEach(function(extractable) { | | 46 | + vector.formats.forEach(function(format) { | | 47 | + var data = keyData; | | 48 | + if (format === "jwk") { | | 49 | + data = jwkData(keyData, algorithm); | | 50 | + } | | 51 | + // Generate all combinations of valid usages for testing | | 52 | + allValidUsages(vector.legalUsages, []).forEach(function(usages) { | 53 | 53 | testFormat(format, algorithm, data, keyData.length * 8, usages, extractable); | 54 | 54 | }); | | 55 | + testEmptyUsages(format, algorithm, data, keyData.length * 8, extractable); | 55 | 56 | }); | 56 | 57 | }); | 57 | 58 |
| | 90 | 91 | }, "Good parameters: " + keySize.toString() + " bits " + parameterString(format, keyData, algorithm, extractable, usages)); | 91 | 92 | } | 92 | 93 |
| | 94 | + // Test importKey with a given key format and other parameters but with empty usages. | | 95 | + // Should fail with SyntaxError | | 96 | + function testEmptyUsages(format, algorithm, keyData, keySize, extractable) { | | 97 | + const usages = []; | | 98 | + promise_test(function(test) { | | 99 | + return subtle.importKey(format, keyData, algorithm, extractable, usages). | | 100 | + then(function(key) { | | 101 | + assert_unreached("importKey succeeded but should have failed with SyntaxError"); | | 102 | + }, function(err) { | | 103 | + assert_equals(err.name, "SyntaxError", "Should throw correct error, not " + err.name + ": " + err.message); | | 104 | + }); | | 105 | + }, "Empty Usages: " + keySize.toString() + " bits " + parameterString(format, keyData, algorithm, extractable, usages)); | | 106 | + } | | 107 | + | 93 | 108 |
| 94 | 109 |
| 95 | 110 | // Helper methods follow: | |
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 |
|---|
| 84 | 84 | "path": "wasm/webapi" | 85 | 85 | }, | 86 | 86 | "WebCryptoAPI": { | 87 | | - "commit": "188993d46b95c9c0414ba2cef8751f5e19d3d498", | | 87 | + "commit": "17b7ca10fd17ab22e60d62da6bc6e7424ea52740", | 88 | 88 | "path": "WebCryptoAPI" | 89 | 89 | }, | 90 | 90 | "webidl/ecmascript-binding/es-exceptions": { | |
|