GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — crypto: fix webcrypto derive key lengths by panva · Pull Request #42542 · nodejs/node

Conversation

@panva

@panva panva commented Mar 31, 2022 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Member

This implements the get key length operation of possible deriveKey derived key's algorithms.

Specifically, for

AES Keys
image

PBKDF2 and HKDF Keys

Return null.

HMAC Keys

image

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@panva
crypto: fix webcrypto derive key lengths
740fffd
@nodejs-github-bot

nodejs-github-bot commented Mar 31, 2022

Copy link
Copy Markdown
Collaborator

Review requested:

  • @nodejs/crypto
All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@nodejs-github-bot nodejs-github-bot added crypto Issues and PRs related to the crypto subsystem. needs-ci PRs that need a full CI run. labels Mar 31, 2022
@panva panva added webcrypto Issues and PRs related to the Web Crypto API. experimental Issues and PRs related to experimental features. labels Mar 31, 2022
@panva

panva commented Mar 31, 2022 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Member Author

Prior to this code in place the following, which works in the browser

const alice = await crypto.subtle.generateKey({ name: 'ECDH', namedCurve: 'P-256' }, false, ['deriveKey']);

const bob = await crypto.subtle.generateKey({ name: 'ECDH', namedCurve: 'P-256' }, false, ['deriveKey']);

const alice_ecdh_params = { name: 'ECDH', public: bob.publicKey };
const alice_shared_key = await crypto.subtle.deriveKey(alice_ecdh_params, alice.privateKey, 'HKDF', false, ['deriveKey']);

Failed in Node.js with

TypeError [ERR_INVALID_ARG_TYPE]: The "length" argument must be of type number. Received undefined
    at __node_internal_captureLargerStackTrace (node:internal/errors:465:5)
    at new NodeError (node:internal/errors:372:5)
    at __node_internal_ (node:internal/validators:103:13)
    at Object.asyncDeriveBitsECDH (node:internal/crypto/diffiehellman:435:5)
    at SubtleCrypto.deriveKey (node:internal/crypto/webcrypto:184:10)
    at REPL10:1:83 {
  code: 'ERR_INVALID_ARG_TYPE'

Because the length passed to asyncDeriveBitsECDH was undefined rather than the expected null which indicates to give us everything that is generated.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@panva
panva requested review from jasnell and tniessen March 31, 2022 14:39
@nodejs-github-bot

nodejs-github-bot commented Mar 31, 2022

Copy link
Copy Markdown
Collaborator

CI: https://ci.nodejs.org/job/node-test-pull-request/43247/

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

Trott
Trott approved these changes Apr 1, 2022
View reviewed changes
@panva panva added the author ready PRs with CI started, the required approvals, and no outstanding review comments. label Apr 1, 2022
@VoltrexKeyva VoltrexKeyva removed the needs-ci PRs that need a full CI run. label Apr 1, 2022
@panva panva added the needs-ci PRs that need a full CI run. label Apr 2, 2022
tniessen
tniessen approved these changes Apr 2, 2022
View reviewed changes
@panva panva added the commit-queue PRs queued for automated landing through the Commit Queue. label Apr 2, 2022
@nodejs-github-bot nodejs-github-bot removed the commit-queue PRs queued for automated landing through the Commit Queue. label Apr 2, 2022
@nodejs-github-bot
nodejs-github-bot merged commit 18bd02f into nodejs:master Apr 2, 2022
@nodejs-github-bot

nodejs-github-bot commented Apr 2, 2022

Copy link
Copy Markdown
Collaborator

Landed in 18bd02f

panva reacted with hooray emoji panva reacted with heart emoji
All reactions
  • 🎉 1 reaction
  • ❤️ 1 reaction

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@panva
panva deleted the fix-webcrypto-derive-lengths branch April 2, 2022 14:54
juanarbol pushed a commit to juanarbol/node that referenced this pull request Apr 5, 2022
@panva @juanarbol
crypto: fix webcrypto derive key lengths
4e7b746
PR-URL: nodejs#42542
Reviewed-By: Rich Trott <[email protected]>
Reviewed-By: Tobias Nießen <[email protected]>
This was referenced Apr 5, 2022
V17.8.1 proposal #42612
Closed
v17.9.0 proposal #42613
Merged
juanarbol pushed a commit that referenced this pull request Apr 6, 2022
@panva @juanarbol
crypto: fix webcrypto derive key lengths
541a132
PR-URL: #42542
Reviewed-By: Rich Trott <[email protected]>
Reviewed-By: Tobias Nießen <[email protected]>
xtx1130 pushed a commit to xtx1130/node that referenced this pull request Apr 25, 2022
@panva @xtx1130
crypto: fix webcrypto derive key lengths
1f1f2cf
PR-URL: nodejs#42542
Reviewed-By: Rich Trott <[email protected]>
Reviewed-By: Tobias Nießen <[email protected]>
juanarbol pushed a commit that referenced this pull request May 31, 2022
@panva @juanarbol
crypto: fix webcrypto derive key lengths
15e0688
PR-URL: #42542
Reviewed-By: Rich Trott <[email protected]>
Reviewed-By: Tobias Nießen <[email protected]>
@juanarbol juanarbol mentioned this pull request May 31, 2022
2022-05-XX, Version 16.16.0 'Gallium' (LTS) #43268
Closed
danielleadams pushed a commit that referenced this pull request Jun 27, 2022
@panva @danielleadams
crypto: fix webcrypto derive key lengths
061d334
PR-URL: #42542
Reviewed-By: Rich Trott <[email protected]>
Reviewed-By: Tobias Nießen <[email protected]>
targos pushed a commit that referenced this pull request Jul 11, 2022
@panva @targos
crypto: fix webcrypto derive key lengths
a58ab2f
PR-URL: #42542
Reviewed-By: Rich Trott <[email protected]>
Reviewed-By: Tobias Nießen <[email protected]>
targos pushed a commit that referenced this pull request Jul 31, 2022
@panva @targos
crypto: fix webcrypto derive key lengths
c605ad1
PR-URL: #42542
Reviewed-By: Rich Trott <[email protected]>
Reviewed-By: Tobias Nießen <[email protected]>
@targos targos mentioned this pull request Aug 3, 2022
v16.17.0 release proposal #44098
Merged
@panva panva mentioned this pull request Oct 7, 2022
crypto: fix webcrypto HMAC "get key length" in deriveKey and generateKey #44917
Merged
guangwong pushed a commit to noslate-project/node that referenced this pull request Oct 10, 2022
@panva @guangwong
crypto: fix webcrypto derive key lengths
ff3267b
PR-URL: nodejs/node#42542
Reviewed-By: Rich Trott <[email protected]>
Reviewed-By: Tobias Nießen <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

@Trott Trott Trott approved these changes
@tniessen tniessen tniessen approved these changes
@jasnell jasnell Awaiting requested review from jasnell

Uh oh!

There was an error while loading. Please reload this page.

Assignees

No one assigned

Labels

author ready PRs with CI started, the required approvals, and no outstanding review comments. crypto Issues and PRs related to the crypto subsystem. experimental Issues and PRs related to experimental features. needs-ci PRs that need a full CI run. webcrypto Issues and PRs related to the Web Crypto API.

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

Uh oh!

There was an error while loading. Please reload this page.

5 participants

@panva @nodejs-github-bot @Trott @tniessen @VoltrexKeyva
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.