Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 873606b

Browse filesBrowse files
panvadanielleadams
authored andcommitted
test,crypto: update WebCryptoAPI WPT
PR-URL: #47131 Reviewed-By: Tobias Nießen <tniessen@tnie.de> Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
1 parent b04ea5a commit 873606b
Copy full SHA for 873606b

File tree

Expand file treeCollapse file tree

9 files changed

+96
-3
lines changed
Open diff view settings
Filter options
Expand file treeCollapse file tree

9 files changed

+96
-3
lines changed
Open diff view settings
Collapse file

‎test/fixtures/wpt/README.md‎

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 numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ Last update:
3131
- user-timing: https://github.com/web-platform-tests/wpt/tree/df24fb604e/user-timing
3232
- wasm/jsapi: https://github.com/web-platform-tests/wpt/tree/d8dbe6990b/wasm/jsapi
3333
- wasm/webapi: https://github.com/web-platform-tests/wpt/tree/fd1b23eeaa/wasm/webapi
34-
- WebCryptoAPI: https://github.com/web-platform-tests/wpt/tree/ee30029d47/WebCryptoAPI
34+
- WebCryptoAPI: https://github.com/web-platform-tests/wpt/tree/1406b5c0d0/WebCryptoAPI
3535
- webidl/ecmascript-binding/es-exceptions: https://github.com/web-platform-tests/wpt/tree/a370aad338/webidl/ecmascript-binding/es-exceptions
3636

3737
[Web Platform Tests]: https://github.com/web-platform-tests/wpt
Collapse file

‎test/fixtures/wpt/WebCryptoAPI/derive_bits_keys/cfrg_curves_bits.js‎

Copy file name to clipboardExpand all lines: test/fixtures/wpt/WebCryptoAPI/derive_bits_keys/cfrg_curves_bits.js
+47Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,53 @@ function define_tests() {
2323
"X448": new Uint8Array([240, 246, 197, 241, 127, 148, 244, 41, 30, 171, 113, 120, 134, 109, 55, 236, 137, 6, 221, 108, 81, 65, 67, 220, 133, 190, 124, 242, 141, 239, 243, 155, 114, 110, 15, 109, 207, 129, 14, 181, 148, 220, 169, 123, 72, 130, 189, 68, 196, 62, 167, 220, 103, 244, 154, 78])
2424
};
2525

26+
var kSmallOrderPoint = {
27+
"X25519": [
28+
{ order: "0", vector : new Uint8Array([48, 42, 48, 5, 6, 3, 43, 101, 110, 3, 33, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]) },
29+
{ order: "1", vector : new Uint8Array([48, 42, 48, 5, 6, 3, 43, 101, 110, 3, 33, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]) },
30+
{ order: "8", vector : new Uint8Array([48, 42, 48, 5, 6, 3, 43, 101, 110, 3, 33, 0, 224, 235, 122, 124, 59, 65, 184, 174, 22, 86, 227, 250, 241, 159, 196, 106, 218, 9, 141, 235, 156, 50, 177, 253, 134, 98, 5, 22, 95, 73, 184, 0]) },
31+
{ order: "p-1 (order 2)", vector : new Uint8Array([48, 42, 48, 5, 6, 3, 43, 101, 110, 3, 33, 0, 236, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 127]) },
32+
{ order: "p (=0, order 4)", vector : new Uint8Array([48, 42, 48, 5, 6, 3, 43, 101, 110, 3, 33, 0, 237, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 127]) },
33+
{ order: "p+1 (=1, order 1)", vector : new Uint8Array([48, 42, 48, 5, 6, 3, 43, 101, 110, 3, 33, 0, 238, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 127]) },
34+
],
35+
"X448": [
36+
{ order: "0", vector : new Uint8Array([48, 66, 48, 5, 6, 3, 43, 101, 111, 3, 57, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]) },
37+
{ order: "1", vector : new Uint8Array([48, 66, 48, 5, 6, 3, 43, 101, 111, 3, 57, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]) },
38+
{ order: "p-1 (order 2)", vector : new Uint8Array([48, 66, 48, 5, 6, 3, 43, 101, 111, 3, 57, 0, 254, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 254, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255]) },
39+
{ order: "p (=0, order 4)", vector : new Uint8Array([48, 66, 48, 5, 6, 3, 43, 101, 111, 3, 57, 0, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 254, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255]) },
40+
{ order: "p+1 (=1, order 1)", vector : new Uint8Array([48, 66, 48, 5, 6, 3, 43, 101, 111, 3, 57, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255]) },
41+
]
42+
};
43+
44+
// Verify the derive functions perform checks against the all-zero value results,
45+
// ensuring small-order points are rejected.
46+
// https://www.rfc-editor.org/rfc/rfc7748#section-6.1
47+
// TODO: The spec states that the check must be done on use, but there is discussion about doing it on import.
48+
// https://github.com/WICG/webcrypto-secure-curves/pull/13
49+
Object.keys(kSmallOrderPoint).forEach(function(algorithmName) {
50+
kSmallOrderPoint[algorithmName].forEach(function(test) {
51+
promise_test(async() => {
52+
let derived;
53+
let privateKey = await subtle.importKey("pkcs8", pkcs8[algorithmName],
54+
{name: algorithmName},
55+
false, ["deriveBits", "deriveKey"]);
56+
let publicKey = await subtle.importKey("spki", test.vector,
57+
{name: algorithmName},
58+
false, [])
59+
try {
60+
derived = await subtle.deriveKey({name: algorithmName, public: publicKey}, privateKey,
61+
{name: "HMAC", hash: "SHA-256", length: 256}, true,
62+
["sign", "verify"]);
63+
} catch (err) {
64+
assert_false(privateKey === undefined, "Private key should be valid.");
65+
assert_false(publicKey === undefined, "Public key should be valid.");
66+
assert_equals(err.name, "OperationError", "Should throw correct error, not " + err.name + ": " + err.message + ".");
67+
}
68+
assert_equals(derived, undefined, "Operation succeeded, but should not have.");
69+
}, algorithmName + " key derivation checks for all-zero value result with a key of order " + test.order);
70+
});
71+
});
72+
2673
return importKeys(pkcs8, spki, sizes)
2774
.then(function(results) {
2875
publicKeys = results.publicKeys;
Collapse file

‎test/fixtures/wpt/WebCryptoAPI/derive_bits_keys/cfrg_curves_keys.js‎

Copy file name to clipboardExpand all lines: test/fixtures/wpt/WebCryptoAPI/derive_bits_keys/cfrg_curves_keys.js
+14Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,20 @@ function define_tests() {
2323
"X448": new Uint8Array([240, 246, 197, 241, 127, 148, 244, 41, 30, 171, 113, 120, 134, 109, 55, 236, 137, 6, 221, 108, 81, 65, 67, 220, 133, 190, 124, 242, 141, 239, 243, 155, 114, 110, 15, 109, 207, 129, 14, 181, 148, 220, 169, 123, 72, 130, 189, 68, 196, 62, 167, 220, 103, 244, 154, 78])
2424
};
2525

26+
// Ensure the keys generated by each algorithm are valid for key derivation.
27+
Object.keys(sizes).forEach(function(algorithmName) {
28+
promise_test(async() => {
29+
let derived;
30+
try {
31+
let key = await subtle.generateKey({name: algorithmName}, true, ["deriveKey", "deriveBits"]);
32+
derived = await subtle.deriveKey({name: algorithmName, public: key.publicKey}, key.privateKey, {name: "HMAC", hash: "SHA-256", length: 256}, true, ["sign", "verify"]);
33+
} catch (err) {
34+
assert_unreached("Threw an unexpected error: " + err.toString() + " -");
35+
}
36+
assert_false (derived === undefined, "Key derivation failed.");
37+
}, "Key derivation using a " + algorithmName + " generated keys.");
38+
});
39+
2640
return importKeys(pkcs8, spki, sizes)
2741
.then(function(results) {
2842
publicKeys = results.publicKeys;
Collapse file

‎test/fixtures/wpt/WebCryptoAPI/import_export/okp_importKey_failures.js‎

Copy file name to clipboardExpand all lines: test/fixtures/wpt/WebCryptoAPI/import_export/okp_importKey_failures.js
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ function run_test(algorithmNames) {
9999
}
100100

101101
function validUsages(usages, format, data) {
102-
if (format === 'spki') return usages.publicUsages
102+
if (format === 'spki' || format === 'raw') return usages.publicUsages
103103
if (format === 'pkcs8') return usages.privateUsages
104104
if (format === 'jwk') {
105105
if (data === undefined)
Collapse file

‎test/fixtures/wpt/WebCryptoAPI/import_export/okp_importKey_failures_Ed25519.https.any.js‎

Copy file name to clipboardExpand all lines: test/fixtures/wpt/WebCryptoAPI/import_export/okp_importKey_failures_Ed25519.https.any.js
+8Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,10 @@ var validKeyData = [
1515
format: "pkcs8",
1616
data: new Uint8Array([48, 46, 2, 1, 0, 48, 5, 6, 3, 43, 101, 112, 4, 34, 4, 32, 243, 200, 244, 196, 141, 248, 120, 20, 110, 140, 211, 191, 109, 244, 229, 14, 56, 155, 167, 7, 78, 21, 194, 53, 45, 205, 93, 48, 141, 76, 168, 31])
1717
},
18+
{
19+
format: "raw",
20+
data: new Uint8Array([216, 225, 137, 99, 216, 9, 212, 135, 217, 84, 154, 204, 174, 198, 116, 46, 126, 235, 162, 77, 138, 13, 59, 20, 183, 227, 202, 234, 6, 137, 61, 204])
21+
},
1822
{
1923
format: "jwk",
2024
data: {
@@ -44,6 +48,10 @@ var badKeyLengthData = [
4448
format: "pkcs8",
4549
data: new Uint8Array([48, 46, 2, 1, 0, 48, 5, 6, 3, 43, 101, 112, 4, 34, 4, 32, 243, 200, 244, 196, 141, 248, 120, 20, 110, 140, 211, 191, 109, 244, 229, 14, 56, 155, 167, 7, 78, 21, 194, 53, 45, 205, 93, 48, 141, 76, 168])
4650
},
51+
{
52+
format: "raw",
53+
data: new Uint8Array([216, 225, 137, 99, 216, 9, 212, 135, 217, 84, 154, 204, 174, 198, 116, 46, 126, 235, 162, 77, 138, 13, 59, 20, 183, 227, 202, 234, 6, 137, 61])
54+
},
4755
{
4856
format: "jwk",
4957
data: {
Collapse file

‎test/fixtures/wpt/WebCryptoAPI/import_export/okp_importKey_failures_Ed448.https.any.js‎

Copy file name to clipboardExpand all lines: test/fixtures/wpt/WebCryptoAPI/import_export/okp_importKey_failures_Ed448.https.any.js
+8Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,10 @@ var validKeyData = [
1515
format: "pkcs8",
1616
data: new Uint8Array([48, 71, 2, 1, 0, 48, 5, 6, 3, 43, 101, 113, 4, 59, 4, 57, 14, 255, 3, 69, 140, 40, 224, 23, 156, 82, 29, 227, 18, 201, 105, 183, 131, 67, 72, 236, 171, 153, 26, 96, 227, 178, 233, 167, 158, 76, 217, 228, 128, 239, 41, 23, 18, 210, 200, 61, 4, 114, 114, 213, 201, 244, 40, 102, 79, 105, 109, 38, 112, 69, 143, 29, 46]),
1717
},
18+
{
19+
format: "raw",
20+
data: new Uint8Array([171, 75, 184, 133, 253, 125, 44, 90, 242, 78, 131, 113, 12, 255, 160, 199, 74, 87, 226, 116, 128, 29, 178, 5, 123, 11, 220, 94, 160, 50, 182, 254, 107, 199, 139, 128, 69, 54, 90, 235, 38, 232, 110, 31, 20, 253, 52, 157, 7, 196, 132, 149, 245, 164, 106, 90, 128]),
21+
},
1822
{
1923
format: "jwk",
2024
data: {
@@ -44,6 +48,10 @@ var badKeyLengthData = [
4448
format: "pkcs8",
4549
data: new Uint8Array([48, 71, 2, 1, 0, 48, 5, 6, 3, 43, 101, 113, 4, 59, 4, 57, 14, 255, 3, 69, 140, 40, 224, 23, 156, 82, 29, 227, 18, 201, 105, 183, 131, 67, 72, 236, 171, 153, 26, 96, 227, 178, 233, 167, 158, 76, 217, 228, 128, 239, 41, 23, 18, 210, 200, 61, 4, 114, 114, 213, 201, 244, 40, 102, 79, 105, 109, 38, 112, 69, 143, 29]),
4650
},
51+
{
52+
format: "raw",
53+
data: new Uint8Array([171, 75, 184, 133, 253, 125, 44, 90, 242, 78, 131, 113, 12, 255, 160, 199, 74, 87, 226, 116, 128, 29, 178, 5, 123, 11, 220, 94, 160, 50, 182, 254, 107, 199, 139, 128, 69, 54, 90, 235, 38, 232, 110, 31, 20, 253, 52, 157, 7, 196, 132, 149, 245, 164, 106, 90]),
54+
},
4755
{
4856
format: "jwk",
4957
data: {
Collapse file

‎test/fixtures/wpt/WebCryptoAPI/import_export/okp_importKey_failures_X25519.https.any.js‎

Copy file name to clipboardExpand all lines: test/fixtures/wpt/WebCryptoAPI/import_export/okp_importKey_failures_X25519.https.any.js
+8Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,10 @@ var validKeyData = [
1515
format: "pkcs8",
1616
data: new Uint8Array([48, 46, 2, 1, 0, 48, 5, 6, 3, 43, 101, 110, 4, 34, 4, 32, 200, 131, 142, 118, 208, 87, 223, 183, 216, 201, 90, 105, 225, 56, 22, 10, 221, 99, 115, 253, 113, 164, 210, 118, 187, 86, 227, 168, 27, 100, 255, 97]),
1717
},
18+
{
19+
format: "raw",
20+
data: new Uint8Array([28, 242, 177, 230, 2, 46, 197, 55, 55, 30, 215, 245, 62, 84, 250, 17, 84, 216, 62, 152, 235, 100, 234, 81, 250, 229, 179, 48, 124, 254, 151, 6]),
21+
},
1822
{
1923
format: "jwk",
2024
data: {
@@ -44,6 +48,10 @@ var badKeyLengthData = [
4448
format: "pkcs8",
4549
data: new Uint8Array([48, 46, 2, 1, 0, 48, 5, 6, 3, 43, 101, 110, 4, 34, 4, 32, 200, 131, 142, 118, 208, 87, 223, 183, 216, 201, 90, 105, 225, 56, 22, 10, 221, 99, 115, 253, 113, 164, 210, 118, 187, 86, 227, 168, 27, 100, 255]),
4650
},
51+
{
52+
format: "raw",
53+
data: new Uint8Array([28, 242, 177, 230, 2, 46, 197, 55, 55, 30, 215, 245, 62, 84, 250, 17, 84, 216, 62, 152, 235, 100, 234, 81, 250, 229, 179, 48, 124, 254, 151]),
54+
},
4755
{
4856
format: "jwk",
4957
data: {
Collapse file

‎test/fixtures/wpt/WebCryptoAPI/import_export/okp_importKey_failures_X448.https.any.js‎

Copy file name to clipboardExpand all lines: test/fixtures/wpt/WebCryptoAPI/import_export/okp_importKey_failures_X448.https.any.js
+8Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,10 @@ var validKeyData = [
1515
format: "pkcs8",
1616
data: new Uint8Array([48, 70, 2, 1, 0, 48, 5, 6, 3, 43, 101, 111, 4, 58, 4, 56, 88, 199, 210, 154, 62, 181, 25, 178, 157, 0, 207, 177, 145, 187, 100, 252, 109, 138, 66, 216, 241, 113, 118, 39, 43, 137, 242, 39, 45, 24, 25, 41, 92, 101, 37, 192, 130, 150, 113, 176, 82, 239, 7, 39, 83, 15, 24, 142, 49, 208, 204, 83, 191, 38, 146, 158]),
1717
},
18+
{
19+
format: "raw",
20+
data: new Uint8Array([182, 4, 161, 209, 165, 205, 29, 148, 38, 213, 97, 239, 99, 10, 158, 177, 108, 190, 105, 213, 185, 202, 97, 94, 220, 83, 99, 62, 251, 82, 234, 49, 230, 230, 160, 161, 219, 172, 198, 231, 108, 188, 230, 72, 45, 126, 75, 163, 213, 93, 158, 128, 39, 101, 206, 111]),
21+
},
1822
{
1923
format: "jwk",
2024
data: {
@@ -44,6 +48,10 @@ var badKeyLengthData = [
4448
format: "pkcs8",
4549
data: new Uint8Array([48, 70, 2, 1, 0, 48, 5, 6, 3, 43, 101, 111, 4, 58, 4, 56, 88, 199, 210, 154, 62, 181, 25, 178, 157, 0, 207, 177, 145, 187, 100, 252, 109, 138, 66, 216, 241, 113, 118, 39, 43, 137, 242, 39, 45, 24, 25, 41, 92, 101, 37, 192, 130, 150, 113, 176, 82, 239, 7, 39, 83, 15, 24, 142, 49, 208, 204, 83, 191, 38, 146]),
4650
},
51+
{
52+
format: "raw",
53+
data: new Uint8Array([182, 4, 161, 209, 165, 205, 29, 148, 38, 213, 97, 239, 99, 10, 158, 177, 108, 190, 105, 213, 185, 202, 97, 94, 220, 83, 99, 62, 251, 82, 234, 49, 230, 230, 160, 161, 219, 172, 198, 231, 108, 188, 230, 72, 45, 126, 75, 163, 213, 93, 158, 128, 39, 101, 206]),
54+
},
4755
{
4856
format: "jwk",
4957
data: {
Collapse file

‎test/fixtures/wpt/versions.json‎

Copy file name to clipboardExpand all lines: test/fixtures/wpt/versions.json
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@
8484
"path": "wasm/webapi"
8585
},
8686
"WebCryptoAPI": {
87-
"commit": "ee30029d47cf9f7cf8f71fe851b4c29903edf851",
87+
"commit": "1406b5c0d07b5e8dd08e328c451e42c23f3b96c8",
8888
"path": "WebCryptoAPI"
8989
},
9090
"webidl/ecmascript-binding/es-exceptions": {

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.