Skip to content

Commit 2045920

Browse files
mikewestmoz-wptsync-bot
authored andcommitted
Bug 1956062 [wpt PR 51556] - [SRI Message Signatures] Accept unknown parameters., a=testonly
Automatic update from web-platform-tests [SRI Message Signatures] Accept unknown parameters. After discussion in WICG/signature-based-sri#38, the specification has shifted to accept unknown parameters for forward compat[1]. Our implementation should do the same. [1]: WICG/signature-based-sri@65bbd5b Bug: 405793111 Change-Id: Ieff7f56eeb76048b73978714fca9d3635a89e81e Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/6382317 Reviewed-by: Joe DeBlasio <jdeblasio@chromium.org> Commit-Queue: Mike West <mkwst@chromium.org> Cr-Commit-Position: refs/heads/main@{#1436906} -- wpt-commits: a40853676ebb1e890ca33c5db2c1ebc468c51935 wpt-pr: 51556
1 parent 3e03c75 commit 2045920

File tree

1 file changed

+73
-0
lines changed

1 file changed

+73
-0
lines changed
Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
// META: script=helper.js
2+
3+
// The following tests validate the behavior of unknown signature parameters.
4+
// They'll all be rooted in the following response, generated using the steps at
5+
// https://wicg.github.io/signature-based-sri/#examples, relying on the test
6+
// key from https://www.rfc-editor.org/rfc/rfc9421.html#name-example-ed25519-test-key:
7+
//
8+
// ```
9+
// NOTE: '\' line wrapping per RFC 8792
10+
//
11+
// HTTP/1.1 200 OK
12+
// Date: Tue, 20 Apr 2021 02:07:56 GMT
13+
// Content-Type: application/json
14+
// Unencoded-Digest: sha-256=:X48E9qOokqqrvdts8nOJRJN3OWDUoyWxBf7kbu9DBPE=:
15+
// Content-Length: 18
16+
// Signature-Input: signature=("unencoded-digest";sf "@status"); \
17+
// keyid="JrQLj5P/89iXES9+vFgrIy29clF9CC/oPPsw3c5D0bs="; \
18+
// tag="sri"
19+
// Signature: signature=:oVQ+s/OqXLAVdfvgZ3HaPiyzkpNXZSit9l6e1FB/gOOL3t8FOrIRDV \
20+
// CkcIEcJjd3MA1mROn39/WQShTmnKmlDg==:
21+
//
22+
//
23+
// {"hello": "world"}
24+
// ```
25+
26+
// Metadata from the response above:
27+
const kRequestsWithValidSignature = [
28+
// ```
29+
// "unencoded-digest";sf: sha-256=:PZJ+9CdAAIacg7wfUe4t/RkDQJVKM0mCZ2K7qiRhHFc=:
30+
// "@signature-params": ("unencoded-digest";sf "@status");keyid="JrQLj5P/89iXES9+vFgrIy29clF9CC/oPPsw3c5D0bs=";tag="sri";unknown=1
31+
// ```
32+
{
33+
body: "window.hello = `world`;",
34+
digest: "sha-256=:PZJ+9CdAAIacg7wfUe4t/RkDQJVKM0mCZ2K7qiRhHFc=:",
35+
signature: `signature=:eZ2DGIHUsTNMxFReOMkbOrTmn+CqDckCZ5/635x1Apl2ws0nA+qZcHqZFMdjBvcGw0WElh3zYD0ynkQ+cHiWCA==:`,
36+
signatureInput: `signature=("unencoded-digest";sf);keyid="${kValidKeys['rfc']}";tag="sri";unknown=1`
37+
},
38+
// ```
39+
// "unencoded-digest";sf: sha-256=:PZJ+9CdAAIacg7wfUe4t/RkDQJVKM0mCZ2K7qiRhHFc=:
40+
// "@signature-params": ("unencoded-digest";sf "@status");unknown=1;keyid="JrQLj5P/89iXES9+vFgrIy29clF9CC/oPPsw3c5D0bs=";tag="sri"
41+
// ```
42+
{
43+
body: "window.hello = `world`;",
44+
digest: "sha-256=:PZJ+9CdAAIacg7wfUe4t/RkDQJVKM0mCZ2K7qiRhHFc=:",
45+
signature: `signature=:YXQH8lkKBcGOMNSFbS56j3d5nK3j15HbFPIdsljzQVGFFd93T6FmXb2cLsoINYQbnMUOQBSROIzFZpgUQTBTBA==:`,
46+
signatureInput: `signature=("unencoded-digest";sf);unknown=1;keyid="${kValidKeys['rfc']}";tag="sri"`
47+
},
48+
];
49+
50+
// Valid signatures depend upon integrity checks.
51+
//
52+
// We're testing our handling of malformed and multiple keys generally in
53+
// the broader `client-initiated.*` tests. Here we'll just focus on ensuring
54+
// that responses with unknown parameters load at all (no integrity check),
55+
// load when integrity checks match, and fail when integrity checks mismatch.
56+
for (const request of kRequestsWithValidSignature) {
57+
// fetch():
58+
generate_fetch_test(request, {}, EXPECT_LOADED,
59+
`Valid signature (${request.signature}), no integrity check: loads.`);
60+
generate_fetch_test(request, {integrity:`ed25519-${kValidKeys['rfc']}`}, EXPECT_LOADED,
61+
`Valid signature (${request.signature}), matching integrity check: loads.`);
62+
63+
generate_fetch_test(request, {integrity:`ed25519-${kInvalidKey}`}, EXPECT_BLOCKED,
64+
`Valid signature (${request.signature}), mismatched integrity check: blocked.`);
65+
66+
// <script>:
67+
generate_script_test(request, "", EXPECT_LOADED,
68+
`Valid signature (${request.signature}), no integrity check: loads.`);
69+
generate_script_test(request, `ed25519-${kValidKeys['rfc']}`, EXPECT_LOADED,
70+
`Valid signature (${request.signature}), matching integrity check: loads.`);
71+
generate_script_test(request, `ed25519-${kInvalidKey}`, EXPECT_BLOCKED,
72+
`Valid signature (${request.signature}), mismatched integrity check: blocked.`);
73+
}

0 commit comments

Comments
 (0)