mirror of
https://github.com/nodejs/node.git
synced 2024-11-21 10:59:27 +00:00
test,crypto: update WebCryptoAPI WPT
PR-URL: https://github.com/nodejs/node/pull/51533 Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com> Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com>
This commit is contained in:
parent
e57a32a03a
commit
6c342431e4
2
test/fixtures/wpt/README.md
vendored
2
test/fixtures/wpt/README.md
vendored
@ -32,7 +32,7 @@ Last update:
|
||||
- user-timing: https://github.com/web-platform-tests/wpt/tree/5ae85bf826/user-timing
|
||||
- wasm/jsapi: https://github.com/web-platform-tests/wpt/tree/cde25e7e3c/wasm/jsapi
|
||||
- wasm/webapi: https://github.com/web-platform-tests/wpt/tree/fd1b23eeaa/wasm/webapi
|
||||
- WebCryptoAPI: https://github.com/web-platform-tests/wpt/tree/d4e14d714c/WebCryptoAPI
|
||||
- WebCryptoAPI: https://github.com/web-platform-tests/wpt/tree/5e042cbc4e/WebCryptoAPI
|
||||
- webidl/ecmascript-binding/es-exceptions: https://github.com/web-platform-tests/wpt/tree/a370aad338/webidl/ecmascript-binding/es-exceptions
|
||||
- webmessaging/broadcastchannel: https://github.com/web-platform-tests/wpt/tree/e97fac4791/webmessaging/broadcastchannel
|
||||
|
||||
|
@ -60,6 +60,15 @@ function define_tests() {
|
||||
}, algorithmName + " mixed case parameters");
|
||||
|
||||
// Null length
|
||||
// "Null" is not valid per the current spec
|
||||
// - https://github.com/w3c/webcrypto/issues/322
|
||||
// - https://github.com/w3c/webcrypto/issues/329
|
||||
//
|
||||
// Proposal for a spec change:
|
||||
// - https://github.com/w3c/webcrypto/pull/345
|
||||
//
|
||||
// This test case may be replaced by these new tests:
|
||||
// - https://github.com/web-platform-tests/wpt/pull/43400
|
||||
promise_test(function(test) {
|
||||
return subtle.deriveBits({name: algorithmName, public: publicKeys[algorithmName]}, privateKeys[algorithmName], null)
|
||||
.then(function(derivation) {
|
||||
|
@ -56,6 +56,15 @@ function define_tests() {
|
||||
}, namedCurve + " mixed case parameters");
|
||||
|
||||
// Null length
|
||||
// "Null" is not valid per the current spec
|
||||
// - https://github.com/w3c/webcrypto/issues/322
|
||||
// - https://github.com/w3c/webcrypto/issues/329
|
||||
//
|
||||
// Proposal for a spec change:
|
||||
// - https://github.com/w3c/webcrypto/pull/345
|
||||
//
|
||||
// This test case may be replaced by these new tests:
|
||||
// - https://github.com/web-platform-tests/wpt/pull/43400
|
||||
promise_test(function(test) {
|
||||
return subtle.deriveBits({name: "ECDH", public: publicKeys[namedCurve]}, privateKeys[namedCurve], null)
|
||||
.then(function(derivation) {
|
||||
|
@ -140,6 +140,15 @@ function define_tests() {
|
||||
}, testName + " with missing info");
|
||||
|
||||
// length null (OperationError)
|
||||
// "Null" is not valid per the current spec
|
||||
// - https://github.com/w3c/webcrypto/issues/322
|
||||
// - https://github.com/w3c/webcrypto/issues/329
|
||||
//
|
||||
// Proposal for a spec change:
|
||||
// - https://github.com/w3c/webcrypto/pull/345
|
||||
//
|
||||
// This test case may be replaced by these new tests:
|
||||
// - https://github.com/web-platform-tests/wpt/pull/43400
|
||||
subsetTest(promise_test, function(test) {
|
||||
return subtle.deriveBits(algorithm, baseKeys[derivedKeySize], null)
|
||||
.then(function(derivation) {
|
||||
|
@ -105,6 +105,15 @@ function define_tests() {
|
||||
|
||||
// Test various error conditions for deriveBits below:
|
||||
// length null (OperationError)
|
||||
// "Null" is not valid per the current spec
|
||||
// - https://github.com/w3c/webcrypto/issues/322
|
||||
// - https://github.com/w3c/webcrypto/issues/329
|
||||
//
|
||||
// Proposal for a spec change:
|
||||
// - https://github.com/w3c/webcrypto/pull/345
|
||||
//
|
||||
// This test case may be replaced by these new tests:
|
||||
// - https://github.com/web-platform-tests/wpt/pull/43400
|
||||
subsetTest(promise_test, function(test) {
|
||||
return subtle.deriveBits({name: "PBKDF2", salt: salts[saltSize], hash: hashName, iterations: parseInt(iterations)}, baseKeys[passwordSize], null)
|
||||
.then(function(derivation) {
|
||||
|
@ -80,6 +80,9 @@
|
||||
}
|
||||
|
||||
testFormat(format, algorithm, data, curve, usages, extractable);
|
||||
if (vector.name === 'ECDH' && format === 'jwk') {
|
||||
testEcdhJwkAlg(algorithm, { ...data.jwk, alg: 'any alg works here' }, curve, usages, extractable);
|
||||
}
|
||||
});
|
||||
|
||||
});
|
||||
@ -90,11 +93,13 @@
|
||||
var data = keyData[curve];
|
||||
allValidUsages(vector.privateUsages).forEach(function(usages) {
|
||||
testFormat(format, algorithm, data, curve, usages, extractable);
|
||||
if (vector.name === 'ECDH' && format === 'jwk') {
|
||||
testEcdhJwkAlg(algorithm, { ...data.jwk, alg: 'any alg works here' }, curve, usages, extractable);
|
||||
}
|
||||
});
|
||||
testEmptyUsages(format, algorithm, data, curve, extractable);
|
||||
});
|
||||
});
|
||||
|
||||
});
|
||||
});
|
||||
|
||||
@ -151,6 +156,21 @@
|
||||
}, "Empty Usages: " + keySize.toString() + " bits " + parameterString(format, false, keyData, algorithm, extractable, usages));
|
||||
}
|
||||
|
||||
// Test ECDH importKey with a JWK format
|
||||
// Should succeed with any "alg" value
|
||||
function testEcdhJwkAlg(algorithm, keyData, keySize, usages, extractable) {
|
||||
const format = "jwk";
|
||||
promise_test(function(test) {
|
||||
return subtle.importKey(format, keyData, algorithm, extractable, usages).
|
||||
then(function(key) {
|
||||
assert_equals(key.constructor, CryptoKey, "Imported a CryptoKey object");
|
||||
assert_goodCryptoKey(key, algorithm, extractable, usages, keyData.d ? 'private' : 'public');
|
||||
}, function(err) {
|
||||
assert_unreached("Threw an unexpected error: " + err.toString());
|
||||
});
|
||||
}, "ECDH any JWK alg: " + keySize.toString() + " bits " + parameterString(format, false, keyData, algorithm, extractable, usages));
|
||||
}
|
||||
|
||||
|
||||
|
||||
// Helper methods follow:
|
||||
|
2
test/fixtures/wpt/versions.json
vendored
2
test/fixtures/wpt/versions.json
vendored
@ -88,7 +88,7 @@
|
||||
"path": "wasm/webapi"
|
||||
},
|
||||
"WebCryptoAPI": {
|
||||
"commit": "d4e14d714c5242e174ba9aec43caf5eb514d0f09",
|
||||
"commit": "5e042cbc4ecab7b2279a5fd411c6daa24ca886c6",
|
||||
"path": "WebCryptoAPI"
|
||||
},
|
||||
"webidl/ecmascript-binding/es-exceptions": {
|
||||
|
Loading…
Reference in New Issue
Block a user