Skip to content

Improve ML-DSA and SLH-DSA steps for the supports() method - #76

Open
panva wants to merge 2 commits into
WICG:mainfrom
panva:supports-improvements
Open

Improve ML-DSA and SLH-DSA steps for the supports() method#76
panva wants to merge 2 commits into
WICG:mainfrom
panva:supports-improvements

Conversation

@panva

@panva panva commented Aug 7, 2026

Copy link
Copy Markdown
Collaborator

The SubtleCrypto.supports() method determines support by executing an operation's steps until it encounters unavailable key or data, key generation, a return, or an exception.

The ML-DSA sign and verify operations and the SLH-DSA sign operation currently reach an unavailable key before the 255-byte context limit can be observed. This makes supports() return true for a context that cannot be accepted with any key or message.

This PR makes those unconditional failures observable before supports() reaches its stopping point. It is the Modern Algorithms counterpart to w3c/webcrypto#558.

Changes

  • Check the 255-byte context limit before key access in ML-DSA sign and verify operations.
  • Check the 255-byte context limit before key access in the SLH-DSA sign operation.
  • Leave SLH-DSA verification unchanged because FIPS 205 returns false, rather than an error, for an oversized context.

Successful operations are unchanged.

Examples

Each of the following now returns false.

ML-DSA context

SubtleCrypto.supports("sign", {
  name: "ML-DSA-44",
  context: new Uint8Array(256),
})

No ML-DSA key or message can make a 256-byte context valid.

SLH-DSA signing context

SubtleCrypto.supports("sign", {
  name: "SLH-DSA-SHA2-128s",
  context: new Uint8Array(256),
})

No SLH-DSA key or message can make a 256-byte signing context valid. Verification remains unchanged because FIPS 205 returns false rather than an error for an oversized context.


Preview | Diff

panva added 2 commits August 7, 2026 13:12
Expose the unconditional 255-byte context limit before sign and verify reach an unavailable key.

For example, this now returns false:

    SubtleCrypto.supports("sign", {
      name: "ML-DSA-44",
      context: new Uint8Array(256),
    })

No ML-DSA key or message can make a 256-byte context valid.
Expose the unconditional 255-byte signing context limit before the operation reaches an unavailable key.

For example, this now returns false:

    SubtleCrypto.supports("sign", {
      name: "SLH-DSA-SHA2-128s",
      context: new Uint8Array(256),
    })

No SLH-DSA key or message can make a 256-byte signing context valid. Verification remains unchanged because FIPS 205 returns false rather than an error for an oversized context.
@panva
panva requested a review from twiss August 7, 2026 12:35
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.

1 participant