Skip to content

crypto: add TurboSHAKE and KangarooTwelve Web Cryptography algorithms#62183

Closed
panva wants to merge 1 commit into
nodejs:mainfrom
panva:turbo-kangaroo
Closed

crypto: add TurboSHAKE and KangarooTwelve Web Cryptography algorithms#62183
panva wants to merge 1 commit into
nodejs:mainfrom
panva:turbo-kangaroo

Conversation

@panva

@panva panva commented Mar 10, 2026

Copy link
Copy Markdown
Member

Adds RFC 9861 - KangarooTwelve and TurboSHAKE digest algorithm to Web Cryptography API per WICG/webcrypto-modern-algos#41 using adapted OpenSSL's keccak1600 implementation, to be replaced when OpenSSL supports them natively at which point we'd also make them available in stable node:crypto.

Refs: https://wicg.github.io/webcrypto-modern-algos/#kangarootwelve
Refs: https://wicg.github.io/webcrypto-modern-algos/#turboshake
Refs: https://www.rfc-editor.org/rfc/rfc9861.html
Refs: https://redirect.github.com/openssl/openssl/issues/30304

The tests for the implementation use both test vectors from the RFC as well as ones generated using PyCryptodome

@panva panva added semver-minor PRs that contain new features and should be released in the next minor version. experimental Issues and PRs related to experimental features. webcrypto labels Mar 10, 2026
@nodejs-github-bot

nodejs-github-bot commented Mar 10, 2026

Copy link
Copy Markdown
Collaborator

Review requested:

  • @nodejs/crypto
  • @nodejs/gyp
  • @nodejs/web-standards

@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 Mar 10, 2026
@panva panva force-pushed the turbo-kangaroo branch 2 times, most recently from 4afe257 to a9f6b32 Compare March 10, 2026 13:23
@panva panva changed the title crypto: Add TurboSHAKE and KangarooTwelve Web Cryptography algorithms crypto: add TurboSHAKE and KangarooTwelve Web Cryptography algorithms Mar 10, 2026
@panva panva marked this pull request as ready for review March 10, 2026 14:28
@nodejs-github-bot

This comment was marked as outdated.

@nodejs-github-bot

This comment was marked as outdated.

Comment thread src/crypto/crypto_turboshake.cc
Comment thread src/crypto/crypto_turboshake.cc
Comment thread src/crypto/crypto_turboshake.cc
@codecov

codecov Bot commented Mar 10, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 85.71429% with 62 lines in your changes missing coverage. Please review.
✅ Project coverage is 89.69%. Comparing base (1baafcc) to head (c8e9f1d).
⚠️ Report is 102 commits behind head on main.

Files with missing lines Patch % Lines
src/crypto/crypto_turboshake.cc 83.42% 33 Missing and 25 partials ⚠️
src/crypto/crypto_turboshake.h 33.33% 4 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main   #62183      +/-   ##
==========================================
- Coverage   89.71%   89.69%   -0.02%     
==========================================
  Files         676      678       +2     
  Lines      206751   207185     +434     
  Branches    39640    39731      +91     
==========================================
+ Hits       185484   185842     +358     
- Misses      13403    13441      +38     
- Partials     7864     7902      +38     
Files with missing lines Coverage Δ
lib/internal/crypto/hash.js 99.00% <100.00%> (+0.06%) ⬆️
lib/internal/crypto/util.js 95.51% <100.00%> (+0.06%) ⬆️
lib/internal/crypto/webidl.js 98.41% <100.00%> (+0.08%) ⬆️
src/node_crypto.cc 81.81% <ø> (ø)
src/crypto/crypto_turboshake.h 33.33% <33.33%> (ø)
src/crypto/crypto_turboshake.cc 83.42% <83.42%> (ø)

... and 36 files with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@nodejs-github-bot

This comment was marked as outdated.

@panva panva added the crypto Issues and PRs related to the crypto subsystem. label Mar 10, 2026
@nodejs-github-bot

This comment was marked as outdated.

@nodejs-github-bot

This comment was marked as outdated.

@nodejs-github-bot

This comment was marked as outdated.

@nodejs-github-bot

This comment was marked as outdated.

@panva panva requested a review from anonrig March 17, 2026 15:55
@panva panva added the review wanted PRs that need reviews. label Mar 18, 2026
@panva

panva commented Mar 18, 2026

Copy link
Copy Markdown
Member Author

cc @nodejs/cpp-reviewers

@addaleax addaleax 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.

Can't really review the cryptography here but the code otherwise LGTM

Comment thread src/crypto/crypto_turboshake.cc
// Absorb complete blocks from input
while (offset + rate <= input_len) {
for (size_t i = 0; i < lane_count; i++) {
A[i / 5][i % 5] ^= LoadLE64(input + offset + i * 8);

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.

Is using LE part of the algorithm specification? Because Node.js does support BE platforms

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

It does need to produce the same digests regardless of the platforms's endianness. And it does, i had earlier failures in jenkins on those platforms and handled that.

Comment thread src/crypto/crypto_turboshake.cc
@panva panva added the author ready PRs that have at least one approval, no pending requests for changes, and a CI started. label Mar 20, 2026
@aduh95 aduh95 added dont-land-on-v24.x PRs that should not land on the v24.x-staging branch and should not be released in v24.x. and removed backport-open-v24.x Indicate that the PR has an open backport lts-watch-v24.x PRs that may need to be released in v24.x labels Apr 7, 2026
@panva panva added dont-land-on-v22.x PRs that should not land on the v22.x-staging branch and should not be released in v22.x. backport-open-v24.x Indicate that the PR has an open backport dont-land-on-v25.x and removed dont-land-on-v24.x PRs that should not land on the v24.x-staging branch and should not be released in v24.x. labels May 25, 2026
sxa added a commit to sxa/node that referenced this pull request Jun 22, 2026
Notable changes:

* crypto: update root certificates to NSS 3.123.1 (Node.js GitHub Bot) nodejs#63527
* (SEMVER-MINOR) buffer: increase Buffer.poolSize default to 64 KiB (Matteo Collina) nodejs#63597
* (SEMVER-MINOR) crypto: align key argument names in docs and error messages (Filip Skokan) nodejs#62527
* (SEMVER-MINOR) crypto: accept key data in crypto.diffieHellman() and cleanup DH jobs (Filip Skokan) nodejs#62527
* (SEMVER-MINOR) crypto: unify asymmetric key import through KeyObjectHandle::Init (Filip Skokan) nodejs#62499
* (SEMVER-MINOR) crypto: add TurboSHAKE and KangarooTwelve Web Cryptography algorithms (Filip Skokan) nodejs#62183
* (SEMVER-MINOR) http: add writeInformation to send arbitrary 1xx status codes (Tim Perry) nodejs#63155
* (SEMVER-MINOR) inspector: expose precise coverage start to JS runtime (sangwook) nodejs#63079
* (SEMVER-MINOR) lib: cleanup stateless diffiehellman key handling (Filip Skokan) nodejs#62645

PR-URL: nodejs#64062

Signed-off-by: Stewart X Addison <sxa@ibm.com>
sxa added a commit that referenced this pull request Jun 22, 2026
    Notable changes:

    * crypto: update root certificates to NSS 3.123.1 (Node.js GitHub Bot) #63527
    * (SEMVER-MINOR) buffer: increase Buffer.poolSize default to 64 KiB (Matteo Collina) #63597
    * (SEMVER-MINOR) crypto: align key argument names in docs and error messages (Filip Skokan) #62527
    * (SEMVER-MINOR) crypto: accept key data in crypto.diffieHellman() and cleanup DH jobs (Filip Skokan) #62527
    * (SEMVER-MINOR) crypto: unify asymmetric key import through KeyObjectHandle::Init (Filip Skokan) #62499
    * (SEMVER-MINOR) crypto: add TurboSHAKE and KangarooTwelve Web Cryptography algorithms (Filip Skokan) #62183
    * (SEMVER-MINOR) http: add writeInformation to send arbitrary 1xx status codes (Tim Perry) #63155
    * (SEMVER-MINOR) inspector: expose precise coverage start to JS runtime (sangwook) #63079
    * (SEMVER-MINOR) lib: cleanup stateless diffiehellman key handling (Filip Skokan) #62645

    PR-URL: #64062

    Signed-off-by: Stewart X Addison <sxa@ibm.com>
sxa added a commit that referenced this pull request Jun 22, 2026
Notable changes:

* crypto: update root certificates to NSS 3.123.1 (Node.js GitHub Bot) #63527
* (SEMVER-MINOR) buffer: increase Buffer.poolSize default to 64 KiB (Matteo Collina) #63597
* (SEMVER-MINOR) crypto: align key argument names in docs and error messages (Filip Skokan) #62527
* (SEMVER-MINOR) crypto: accept key data in crypto.diffieHellman() and cleanup DH jobs (Filip Skokan) #62527
* (SEMVER-MINOR) crypto: unify asymmetric key import through KeyObjectHandle::Init (Filip Skokan) #62499
* (SEMVER-MINOR) crypto: add TurboSHAKE and KangarooTwelve Web Cryptography algorithms (Filip Skokan) #62183
* (SEMVER-MINOR) http: add writeInformation to send arbitrary 1xx status codes (Tim Perry) #63155
* (SEMVER-MINOR) inspector: expose precise coverage start to JS runtime (sangwook) #63079
* (SEMVER-MINOR) lib: cleanup stateless diffiehellman key handling (Filip Skokan) #62645

PR-URL: #64062
sxa added a commit to sxa/node that referenced this pull request Jun 22, 2026
Notable changes:

buffer:
  * (SEMVER-MINOR) increase Buffer.poolSize default to 64 KiB (Matteo Collina) nodejs#63597
crypto:
  * update root certificates to NSS 3.123.1 (Node.js GitHub Bot) nodejs#63527
  * (SEMVER-MINOR)  align key argument names in docs and error messages (Filip Skokan) nodejs#62527
  * (SEMVER-MINOR)  accept key data in crypto.diffieHellman() and cleanup DH jobs (Filip Skokan) nodejs#62527
  * (SEMVER-MINOR)  add TurboSHAKE and KangarooTwelve Web Cryptography algorithms (Filip Skokan) nodejs#62183
http:
  * http: avoid stream listeners on idle agent sockets (Matteo Collina) nodejs#64004
  * (SEMVER-MINOR) add writeInformation to send arbitrary 1xx status codes (Tim Perry) nodejs#63155
inspector:
  * (SEMVER-MINOR) expose precise coverage start to JS runtime (sangwook) nodejs#63079
stream:
  * stream: Revert noop pause/resume on destroyed streams" (Stewart X Addison) nodejs#63834

PR-URL: nodejs#64062
sxa added a commit that referenced this pull request Jun 22, 2026
Notable changes:

buffer:
  * (SEMVER-MINOR) increase Buffer.poolSize default to 64 KiB (Matteo Collina) #63597
crypto:
  * update root certificates to NSS 3.123.1 (Node.js GitHub Bot) #63527
  * (SEMVER-MINOR)  align key argument names in docs and error messages (Filip Skokan) #62527
  * (SEMVER-MINOR)  accept key data in crypto.diffieHellman() and cleanup DH jobs (Filip Skokan) #62527
  * (SEMVER-MINOR)  add TurboSHAKE and KangarooTwelve Web Cryptography algorithms (Filip Skokan) #62183
http:
  * http: avoid stream listeners on idle agent sockets (Matteo Collina) #64004
  * (SEMVER-MINOR) add writeInformation to send arbitrary 1xx status codes (Tim Perry) #63155
inspector:
  * (SEMVER-MINOR) expose precise coverage start to JS runtime (sangwook) #63079
stream:
  * stream: Revert noop pause/resume on destroyed streams" (Stewart X Addison) #63834

PR-URL: #64062
sxa added a commit that referenced this pull request Jun 22, 2026
Notable changes:

buffer:
  * (SEMVER-MINOR) increase Buffer.poolSize default to 64 KiB (Matteo Collina) #63597
crypto:
  * update root certificates to NSS 3.123.1 (Node.js GitHub Bot) #63527
  * (SEMVER-MINOR)  align key argument names in docs and error messages (Filip Skokan) #62527
  * (SEMVER-MINOR)  accept key data in crypto.diffieHellman() and cleanup DH jobs (Filip Skokan) #62527
  * (SEMVER-MINOR)  add TurboSHAKE and KangarooTwelve Web Cryptography algorithms (Filip Skokan) #62183
http:
  * http: avoid stream listeners on idle agent sockets (Matteo Collina) #64004
  * (SEMVER-MINOR) add writeInformation to send arbitrary 1xx status codes (Tim Perry) #63155
inspector:
  * (SEMVER-MINOR) expose precise coverage start to JS runtime (sangwook) #63079
stream:
  * stream: Revert noop pause/resume on destroyed streams" (Stewart X Addison) #63834

PR-URL: #64062
sxa added a commit to sxa/node that referenced this pull request Jun 22, 2026
Notable changes:

buffer:
  * (SEMVER-MINOR) increase Buffer.poolSize default to 64 KiB (Matteo Collina) nodejs#63597
crypto:
  * update root certificates to NSS 3.123.1 (Node.js GitHub Bot) nodejs#63527
  * (SEMVER-MINOR)  align key argument names in docs and error messages (Filip Skokan) nodejs#62527
  * (SEMVER-MINOR)  accept key data in crypto.diffieHellman() and cleanup DH jobs (Filip Skokan) nodejs#62527
  * (SEMVER-MINOR)  add TurboSHAKE and KangarooTwelve Web Cryptography algorithms (Filip Skokan) nodejs#62183
http:
  * http: avoid stream listeners on idle agent sockets (Matteo Collina) nodejs#64004
  * (SEMVER-MINOR) add writeInformation to send arbitrary 1xx status codes (Tim Perry) nodejs#63155
inspector:
  * (SEMVER-MINOR) expose precise coverage start to JS runtime (sangwook) nodejs#63079
stream:
  * stream: Revert noop pause/resume on destroyed streams" (Stewart X Addison) nodejs#63834

PR-URL: nodejs#64062
sxa added a commit to sxa/node that referenced this pull request Jun 22, 2026
Notable changes:

buffer:
  * (SEMVER-MINOR) increase Buffer.poolSize default to 64 KiB (Matteo Collina) nodejs#63597
crypto:
  * update root certificates to NSS 3.123.1 (Node.js GitHub Bot) nodejs#63527
  * (SEMVER-MINOR)  align key argument names in docs and error messages (Filip Skokan) nodejs#62527
  * (SEMVER-MINOR)  accept key data in crypto.diffieHellman() and cleanup DH jobs (Filip Skokan) nodejs#62527
  * (SEMVER-MINOR)  add TurboSHAKE and KangarooTwelve Web Cryptography algorithms (Filip Skokan) nodejs#62183
http:
  * http: avoid stream listeners on idle agent sockets (Matteo Collina) nodejs#64004
  * (SEMVER-MINOR) add writeInformation to send arbitrary 1xx status codes (Tim Perry) nodejs#63155
inspector:
  * (SEMVER-MINOR) expose precise coverage start to JS runtime (sangwook) nodejs#63079
stream:
  * stream: Revert noop pause/resume on destroyed streams" (Stewart X Addison) nodejs#63834

PR-URL: nodejs#64062
sxa added a commit to sxa/node that referenced this pull request Jun 23, 2026
Notable changes:

buffer:
  * (SEMVER-MINOR) increase Buffer.poolSize default to 64 KiB (Matteo Collina) nodejs#63597
crypto:
  * update root certificates to NSS 3.123.1 (Node.js GitHub Bot) nodejs#63527
  * (SEMVER-MINOR)  align key argument names in docs and error messages (Filip Skokan) nodejs#62527
  * (SEMVER-MINOR)  accept key data in crypto.diffieHellman() and cleanup DH jobs (Filip Skokan) nodejs#62527
  * (SEMVER-MINOR)  add TurboSHAKE and KangarooTwelve Web Cryptography algorithms (Filip Skokan) nodejs#62183
http:
  * http: avoid stream listeners on idle agent sockets (Matteo Collina) nodejs#64004
  * (SEMVER-MINOR) add writeInformation to send arbitrary 1xx status codes (Tim Perry) nodejs#63155
inspector:
  * (SEMVER-MINOR) expose precise coverage start to JS runtime (sangwook) nodejs#63079
stream:
  * stream: Revert noop pause/resume on destroyed streams" (Stewart X Addison) nodejs#63834

PR-URL: nodejs#64062
@panva panva added backported-to-v24.x PRs backported to the v24.x-staging branch. and removed backport-open-v24.x Indicate that the PR has an open backport labels Jun 23, 2026
richardlau pushed a commit that referenced this pull request Jun 23, 2026
Notable changes:

buffer:
  * (SEMVER-MINOR) increase Buffer.poolSize default to 64 KiB (Matteo Collina) #63597
crypto:
  * update root certificates to NSS 3.123.1 (Node.js GitHub Bot) #63527
  * (SEMVER-MINOR)  align key argument names in docs and error messages (Filip Skokan) #62527
  * (SEMVER-MINOR)  accept key data in crypto.diffieHellman() and cleanup DH jobs (Filip Skokan) #62527
  * (SEMVER-MINOR)  add TurboSHAKE and KangarooTwelve Web Cryptography algorithms (Filip Skokan) #62183
http:
  * http: avoid stream listeners on idle agent sockets (Matteo Collina) #64004
  * (SEMVER-MINOR) add writeInformation to send arbitrary 1xx status codes (Tim Perry) #63155
inspector:
  * (SEMVER-MINOR) expose precise coverage start to JS runtime (sangwook) #63079
stream:
  * stream: Revert noop pause/resume on destroyed streams" (Stewart X Addison) #63834

PR-URL: #64062
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. backported-to-v24.x PRs backported to the v24.x-staging branch. crypto Issues and PRs related to the crypto subsystem. dont-land-on-v22.x PRs that should not land on the v22.x-staging branch and should not be released in v22.x. experimental Issues and PRs related to experimental features. lib / src Issues and PRs related to general changes in the lib or src directory. needs-ci PRs that need a full CI run. semver-minor PRs that contain new features and should be released in the next minor version. webcrypto

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants