- From: Anne van Kesteren <notifications@github.com>
- Date: Tue, 18 Nov 2025 05:09:12 -0800
- To: whatwg/fetch <fetch@noreply.github.com>
- Cc: Subscribed <subscribed@noreply.github.com>
- Message-ID: <whatwg/fetch/pull/1867/review/3477717826@github.com>
@annevk commented on this pull request. > +<p>To <dfn export>verify `<code>Unencoded-Digest</code>` assertions</dfn>, given a +<a>byte sequence</a> <var>bytes</var> and a <a for=/>header list</a> <var>list</var>, run these +steps: ```suggestion <p>To <dfn export>verify `<code>Unencoded-Digest</code>` assertions</dfn>, given a <a>byte sequence</a> <var>bytes</var> and a <a for=/>header list</a> <var>list</var>: ``` > +algorithms, and whose values are <a data-lt="structured field byte sequence">byte sequences</a> +represent a digest of the response produced via the specified algorithm. [[!UNENCODED-DIGEST]] + + +<div algorithm> +<p>To <dfn export>verify `<code>Unencoded-Digest</code>` assertions</dfn>, given a +<a>byte sequence</a> <var>bytes</var> and a <a for=/>header list</a> <var>list</var>, run these +steps: + +<ol> + <li><p>Let <var>header</var> be the result of + <a for="header list" lt="get a structured field value">getting</a> the + `<a http-header><code>Unencoded-Digest</code></a>` header as a "<code>dictionary</code>" from + <var>list</var>. + + <li><p>If <var>header</var> is null, then return <b>verified</b>. I think we should restructure this to return a boolean. `<b>return value</b>` is not part of Infra and it's not necessarily that much clearer. I suppose we could return an enum instead, but we don't really have enums with only two values. (Maybe we should and maybe we should refactor everything away from booleans after mostly refactoring away from flags, but that would require a bit of investigation as to what that would look like.) > +<h3 id=unencoded-digest-header>`<code>Unencoded-Digest</code>` header</h3> + +<p>The `<a http-header><code>Unencoded-Digest</code></a>` header field represents a server's +assertions about the integrity of a response's content. It is a <a>structured header</a> whose value +must be a <a data-lt="structured field dictionary">dictionary</a> whose keys specify hashing +algorithms, and whose values are <a data-lt="structured field byte sequence">byte sequences</a> +represent a digest of the response produced via the specified algorithm. [[!UNENCODED-DIGEST]] + + +<div algorithm> +<p>To <dfn export>verify `<code>Unencoded-Digest</code>` assertions</dfn>, given a +<a>byte sequence</a> <var>bytes</var> and a <a for=/>header list</a> <var>list</var>, run these +steps: + +<ol> + <li><p>Let <var>header</var> be the result of Shouldn't this be called _value_? > + +<div algorithm> +<p>To <dfn export>verify `<code>Unencoded-Digest</code>` assertions</dfn>, given a +<a>byte sequence</a> <var>bytes</var> and a <a for=/>header list</a> <var>list</var>, run these +steps: + +<ol> + <li><p>Let <var>header</var> be the result of + <a for="header list" lt="get a structured field value">getting</a> the + `<a http-header><code>Unencoded-Digest</code></a>` header as a "<code>dictionary</code>" from + <var>list</var>. + + <li><p>If <var>header</var> is null, then return <b>verified</b>. + + <li> + <p><a for="list">For each</a> <var>alg</var> → <var>digest</var> of <var>header</var>: algorithm* > + + <li> + <p><a for="list">For each</a> <var>alg</var> → <var>digest</var> of <var>header</var>: + + <ol> + <li> + <p>Switch on <var>alg</var>: + + <dl class=switch> + <dt>"<code>sha-256</code>" + <dd> + <ol> + <li><p>Let <var>body digest</var> be the result of executing the SHA-256 algorithm on + <var>bytes</var>. [[!FIPS-180-4]] + + <li><p>If <var>body digest</var> matches <var>digest</var>, <a for="iteration">continue</a>. bodyDigest What does "matches" mean here? Can we say "is"? Also, perhaps we should pass algorithm and bytes to SRI so it can have the dependencies on SHA? Perhaps this entire algorithm can be in SRI and we only have the processing model hooks in fetch? Hmm. > + <p>If <var>request</var>'s <a for=request>integrity metadata</a> is not the empty string, or if + <var>internalResponse</var>'s <a for="response">header list</a> <a for="header list">contains</a> + `<a http-header><code>Unencoded-Digest</code></a>`, then: This means we enforce it for opaque responses. Is that what we want? What about requests that didn't care about integrity enforcement? -- Reply to this email directly or view it on GitHub: https://github.com/whatwg/fetch/pull/1867#pullrequestreview-3477717826 You are receiving this because you are subscribed to this thread. Message ID: <whatwg/fetch/pull/1867/review/3477717826@github.com>
Received on Tuesday, 18 November 2025 13:09:16 UTC