Skip to content

Add [EnforceRange] instead of truncating lengths - #555

Merged
twiss merged 1 commit into
w3c:mainfrom
panva:enforce-range
Aug 6, 2026
Merged

Add [EnforceRange] instead of truncating lengths#555
twiss merged 1 commit into
w3c:mainfrom
panva:enforce-range

Conversation

@panva

@panva panva commented Apr 26, 2026

Copy link
Copy Markdown
Member

closes #429


Preview | Diff

closes w3c#429

Signed-off-by: Filip Skokan <panva.ip@gmail.com>

@twiss twiss left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, and sorry for the long delay!

@twiss twiss changed the title add [EnforceRange] instead of truncating lengths Add [EnforceRange] instead of truncating lengths Aug 6, 2026
@twiss
twiss merged commit 27b3faa into w3c:main Aug 6, 2026
2 checks passed
@panva
panva deleted the enforce-range branch August 6, 2026 17:07
nodejs-github-bot pushed a commit to nodejs/node that referenced this pull request Aug 8, 2026
Signed-off-by: Filip Skokan <panva.ip@gmail.com>
PR-URL: #65091
Refs: w3c/webcrypto#555
Refs: WICG/webcrypto-modern-algos#65
Reviewed-By: Aviv Keller <me@aviv.sh>
Reviewed-By: James M Snell <jasnell@gmail.com>
aduh95 pushed a commit to nodejs/node that referenced this pull request Aug 13, 2026
Signed-off-by: Filip Skokan <panva.ip@gmail.com>
PR-URL: #65091
Refs: w3c/webcrypto#555
Refs: WICG/webcrypto-modern-algos#65
Reviewed-By: Aviv Keller <me@aviv.sh>
Reviewed-By: James M Snell <jasnell@gmail.com>
@annevk

annevk commented Aug 14, 2026

Copy link
Copy Markdown
Member

Did anyone make corresponding WPT changes? I don't see them linked.

@twiss

twiss commented Aug 20, 2026

Copy link
Copy Markdown
Member

No, thanks for the reminder. I've made some here: web-platform-tests/wpt#62086

I noticed while doing so that the {Rsa,Aes,Hmac}KeyGenParams dictionaries already had [EnforceRange] specified. The dictionaries changed in this PR are read-only, and only used to indicate the algorithm properties of a key object. So, specifying [EnforceRange] on them (as well as required, which was already there?) is not really sensical, and can be removed again, I think. Lmk if you disagree, and sorry for not catching that earlier. (Edit: made #559 for this.)

So the only actually substantive change in this PR is to add [EnforceRange] to the length parameter of deriveBits. Nevertheless I've added tests for a bunch of the other cases too.

@annevk

annevk commented Aug 20, 2026

Copy link
Copy Markdown
Member

required for a return type is kinda useful for code generation (means you don't need std::optional). [EnforceRange] is probably not, indeed.

twiss added a commit to web-platform-tests/wpt that referenced this pull request Aug 20, 2026
The `[EnforceRange]` attribute of the `length` parameter of `deriveBits`
was added in w3c/webcrypto#555.

The `[EnforceRange]` attribute of the `length` and `modulusLength`
properties of the `{Aes,Hmac,Rsa}KeyGenParams` dictionaries was
already there.

This change adds tests for both.
@twiss

twiss commented Aug 20, 2026

Copy link
Copy Markdown
Member

pull Bot pushed a commit to AKJUS/servo that referenced this pull request Aug 23, 2026
The WebCrypto API specifications have updated to add [EnforceRange] to
key length parameters in WebIDL, instead of truncating lengths. We
update our implementation accordingly.

Update in the Web Cryptography API spec:
w3c/webcrypto#555

Update in the Modern Algorithms in the Web Cryptography API spec:
WICG/webcrypto-modern-algos#65

Corresponding update in WPT:
web-platform-tests/wpt#62086

Testing: Pass recently added WPT tests.

Signed-off-by: Kingsley Yung <kingsley@kkoyung.dev>
lando-worker Bot pushed a commit to mozilla-firefox/firefox that referenced this pull request Aug 25, 2026
…ge] WebIDL attribute, a=testonly

Automatic update from web-platform-tests
[WebCryptoAPI] Add tests for [EnforceRange] WebIDL attribute (#62086)

The `[EnforceRange]` attribute of the `length` parameter of `deriveBits`
was added in w3c/webcrypto#555.

The `[EnforceRange]` attribute of the `length` and `modulusLength`
properties of the `{Aes,Hmac,Rsa}KeyGenParams` dictionaries was
already there.

This change adds tests for both.
--

wpt-commits: b5af458bb2e817310239e66447c7055ce835f570
wpt-pr: 62086
aduh95 pushed a commit to nodejs/node that referenced this pull request Aug 25, 2026
Signed-off-by: Filip Skokan <panva.ip@gmail.com>
PR-URL: #65091
Refs: w3c/webcrypto#555
Refs: WICG/webcrypto-modern-algos#65
Reviewed-By: Aviv Keller <me@aviv.sh>
Reviewed-By: James M Snell <jasnell@gmail.com>
aduh95 pushed a commit to nodejs/node that referenced this pull request Aug 27, 2026
Signed-off-by: Filip Skokan <panva.ip@gmail.com>
PR-URL: #65091
Refs: w3c/webcrypto#555
Refs: WICG/webcrypto-modern-algos#65
Reviewed-By: Aviv Keller <me@aviv.sh>
Reviewed-By: James M Snell <jasnell@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Consider not truncating lengths and instead [EnforceRange]?

4 participants