Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

crypto: adjust minimum length in generateKey('hmac', ...) and generateKeySync('hmac', ...) #42944

Merged

Conversation

LiviaMedeiros
Copy link
Contributor

@LiviaMedeiros LiviaMedeiros commented May 2, 2022

Values in the interval [1, 8) are invalid.

Also affects generateKeySync('hmac', ...)
@nodejs-github-bot
Copy link
Collaborator

Review requested:

  • @nodejs/crypto

@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 May 2, 2022
Copy link
Member

@tniessen tniessen left a comment

Choose a reason for hiding this comment

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

LGTM. Not sure about the semver-ity though.

@LiviaMedeiros
Copy link
Contributor Author

semver-patch I guess? On that interval, this PR replaces abortion with RangeError.

Copy link
Member

@panva panva left a comment

Choose a reason for hiding this comment

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

I believe this surfaced together with Web Crypto API. I also believe the intention was to follow the way Web Crypto API works in Node.js, that is "multiples of 8", in which case, length should've been in bytes, not bits...

Since any other bit length that isn't a multiple of 8 is rounded down, this patched behaviour is IMHO correct and falls within a fix semver-ity ;)

cc @jasnell

@panva panva requested a review from jasnell May 2, 2022 17:39
@panva panva added the request-ci Add this label to start a Jenkins CI on a PR. label May 2, 2022
@tniessen
Copy link
Member

tniessen commented May 2, 2022

Ah, I didn't know this aborted before. semver-patch is fine then!

@github-actions github-actions bot removed the request-ci Add this label to start a Jenkins CI on a PR. label May 2, 2022
@nodejs-github-bot

This comment was marked as outdated.

@nodejs-github-bot
Copy link
Collaborator

@tniessen tniessen added the author ready PRs that have at least one approval, no pending requests for changes, and a CI started. label May 3, 2022
@tniessen tniessen added the commit-queue Add this label to land a pull request using GitHub Actions. label May 4, 2022
@nodejs-github-bot nodejs-github-bot removed the commit-queue Add this label to land a pull request using GitHub Actions. label May 4, 2022
@nodejs-github-bot nodejs-github-bot merged commit a5b8730 into nodejs:master May 4, 2022
@nodejs-github-bot
Copy link
Collaborator

Landed in a5b8730

RafaelGSS pushed a commit that referenced this pull request May 10, 2022
Also affects generateKeySync('hmac', ...)

PR-URL: #42944
Reviewed-By: Tobias Nießen <tniessen@tnie.de>
Reviewed-By: Filip Skokan <panva.ip@gmail.com>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
@RafaelGSS RafaelGSS mentioned this pull request May 10, 2022
juanarbol pushed a commit that referenced this pull request May 31, 2022
Also affects generateKeySync('hmac', ...)

PR-URL: #42944
Reviewed-By: Tobias Nießen <tniessen@tnie.de>
Reviewed-By: Filip Skokan <panva.ip@gmail.com>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
danielleadams pushed a commit that referenced this pull request Jun 27, 2022
Also affects generateKeySync('hmac', ...)

PR-URL: #42944
Reviewed-By: Tobias Nießen <tniessen@tnie.de>
Reviewed-By: Filip Skokan <panva.ip@gmail.com>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
targos pushed a commit that referenced this pull request Jul 12, 2022
Also affects generateKeySync('hmac', ...)

PR-URL: #42944
Reviewed-By: Tobias Nießen <tniessen@tnie.de>
Reviewed-By: Filip Skokan <panva.ip@gmail.com>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
targos pushed a commit that referenced this pull request Jul 31, 2022
Also affects generateKeySync('hmac', ...)

PR-URL: #42944
Reviewed-By: Tobias Nießen <tniessen@tnie.de>
Reviewed-By: Filip Skokan <panva.ip@gmail.com>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
guangwong pushed a commit to noslate-project/node that referenced this pull request Oct 10, 2022
Also affects generateKeySync('hmac', ...)

PR-URL: nodejs/node#42944
Reviewed-By: Tobias Nießen <tniessen@tnie.de>
Reviewed-By: Filip Skokan <panva.ip@gmail.com>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
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. needs-ci PRs that need a full CI run.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants