Skip to content

FF156 SubtleCrypto.deriveBits() length TypeError - #45545

Open
hamishwillee wants to merge 1 commit into
mdn:mainfrom
hamishwillee:ff156_Subtle_devivebits
Open

FF156 SubtleCrypto.deriveBits() length TypeError#45545
hamishwillee wants to merge 1 commit into
mdn:mainfrom
hamishwillee:ff156_Subtle_devivebits

Conversation

@hamishwillee

Copy link
Copy Markdown
Collaborator

FF156 added a [EnforcRange] on the IDL for the length parameter in SubtleCrypto.deriveBits().
This enforces the range on the length passed to the parameter to the type of the underlying IDL - thowing a TypeError.
As a result, some errors that would previously have been OperationErrors are now TypeErrors.

This updates the docs for the method.:

  • Fixes whole lot of arbitrary line lengthts
  • Adds the TypeError, and improves the OperationError.

Related docs work can be tracked in #45507

@hamishwillee
hamishwillee requested a review from a team as a code owner September 7, 2026 06:51
@hamishwillee
hamishwillee requested review from sideshowbarker and removed request for a team September 7, 2026 06:51
@github-actions github-actions Bot added Content:WebAPI Web API docs size/m [PR only] 51-500 LoC changed labels Sep 7, 2026
@github-actions

github-actions Bot commented Sep 7, 2026

Copy link
Copy Markdown
Contributor

Preview URLs (1 page)

Comment on lines +57 to +58
- `TypeError`
- : Raised if the _length_ parameter of the `deriveBits()` call is negative, non-finite (`NaN` or `Infinity`), or greater than 4294967295 (`2^32 - 1`).

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

This is the main change. I've put it first because it would be evaluated before everything else.

Comment on lines +60 to +64
- : Raised for reasons specific to the requested derivation algorithm.
- For HKDF and PBKDF2, raised if the [`length`](#length) parameter is `null` or is not a multiple of 8.
- For PBKDF2, also raised if the `iterations` parameter is zero.
- For ECDH and X25519, raised if the requested `length` is greater than the number of bits the algorithm can derive (256 bits for X25519; the field size of the curve for ECDH).
For X25519 only, if the derived secret is all zero.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

This is reworked around what the spec actually says. I am fairly confident of it, based on Claude interrogation.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Content:WebAPI Web API docs size/m [PR only] 51-500 LoC changed

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants