Skip to content

crypto: support non-byte WebCrypto lengths and cSHAKE#63988

Closed
panva wants to merge 1 commit into
nodejs:mainfrom
panva:webcrypto-non-byte-lengths
Closed

crypto: support non-byte WebCrypto lengths and cSHAKE#63988
panva wants to merge 1 commit into
nodejs:mainfrom
panva:webcrypto-non-byte-lengths

Conversation

@panva

@panva panva commented Jun 18, 2026

Copy link
Copy Markdown
Member

Add shared bit-length helpers for WebCrypto operations that accept bit sequences whose length is not byte-aligned.

Use the helpers for cSHAKE output, ECDH-derived bits, HMAC/KMAC key generation/import/derivation, and KMAC sign/verify output. Preserve the requested bit length in CryptoKey algorithm metadata while storing and exporting rounded-up byte material with unused low bits cleared.

Keep byte-multiple validation for algorithms whose specs require it.

Extend the lower-end of KMAC's key length support.

Enable cSHAKE customization and functionName parameters.

@nodejs-github-bot

Copy link
Copy Markdown
Collaborator

Review requested:

  • @nodejs/crypto

@nodejs-github-bot nodejs-github-bot added lib / src Issues and PRs related to general changes in the lib or src directory. needs-ci PRs that need a full CI run. labels Jun 18, 2026
@panva panva added crypto Issues and PRs related to the crypto subsystem. webcrypto labels Jun 18, 2026
@panva panva force-pushed the webcrypto-non-byte-lengths branch 3 times, most recently from f27f79a to b9e0073 Compare June 18, 2026 20:25
@panva panva marked this pull request as draft June 18, 2026 22:02
@panva panva changed the title crypto: support non-byte WebCrypto lengths crypto: support non-byte WebCrypto lengths and cSHAKE Jun 18, 2026
@panva panva force-pushed the webcrypto-non-byte-lengths branch from b9e0073 to ffa0349 Compare June 18, 2026 22:05
@panva panva marked this pull request as ready for review June 18, 2026 22:07
Comment thread lib/internal/crypto/util.js Outdated
@nodejs-github-bot

This comment was marked as outdated.

Add shared bit-length helpers for WebCrypto operations that accept bit
sequences whose length is not byte-aligned.

Use the helpers for cSHAKE output, ECDH-derived bits, HMAC/KMAC key
generation/import/derivation, and KMAC sign/verify output. Preserve the
requested bit length in CryptoKey algorithm metadata while storing and
exporting rounded-up byte material with unused low bits cleared.

Keep byte-multiple validation for algorithms whose specs require it.

Extend the lower-end of KMAC's key length support.

Enable cSHAKE customization and functionName parameters.

Signed-off-by: Filip Skokan <panva.ip@gmail.com>
@panva panva force-pushed the webcrypto-non-byte-lengths branch from 86c6e6d to ee1069c Compare June 19, 2026 09:00
@panva panva added the author ready PRs that have at least one approval, no pending requests for changes, and a CI started. label Jun 19, 2026
@nodejs-github-bot

This comment was marked as outdated.

@nodejs-github-bot

This comment was marked as outdated.

@nodejs-github-bot

Copy link
Copy Markdown
Collaborator

@panva panva added commit-queue Add this label to land a pull request using GitHub Actions. and removed commit-queue Add this label to land a pull request using GitHub Actions. labels Jun 20, 2026
panva added a commit that referenced this pull request Jun 20, 2026
Add shared bit-length helpers for WebCrypto operations that accept bit
sequences whose length is not byte-aligned.

Use the helpers for cSHAKE output, ECDH-derived bits, HMAC/KMAC key
generation/import/derivation, and KMAC sign/verify output. Preserve the
requested bit length in CryptoKey algorithm metadata while storing and
exporting rounded-up byte material with unused low bits cleared.

Keep byte-multiple validation for algorithms whose specs require it.

Extend the lower-end of KMAC's key length support.

Enable cSHAKE customization and functionName parameters.

Signed-off-by: Filip Skokan <panva.ip@gmail.com>
PR-URL: #63988
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Yagiz Nizipli <yagiz@nizipli.com>
@panva

panva commented Jun 20, 2026

Copy link
Copy Markdown
Member Author

Landed in 8ec37eb

@panva panva closed this Jun 20, 2026
@panva panva deleted the webcrypto-non-byte-lengths branch June 20, 2026 16:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

author ready PRs that have at least one approval, no pending requests for changes, and a CI started. crypto Issues and PRs related to the crypto subsystem. lib / src Issues and PRs related to general changes in the lib or src directory. needs-ci PRs that need a full CI run. webcrypto

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants