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: deprecate digest == null in PBKDF2 #22861

Conversation

tniessen
Copy link
Member

@tniessen tniessen commented Sep 14, 2018

I assume that permitting digest === null was unintentional when digest === undefined was deprecated since their behavior was equivalent. The sha1 default for digest === null has somehow made it through refactoring of the PBKDF2 module multiple times, even though digest === undefined has been EOL for some time now.

This change deprecates setting digest to null so we can fix the behavior in Node.js 12 or so.

Checklist
  • make -j4 test (UNIX), or vcbuild test (Windows) passes
  • tests and/or benchmarks are included
  • documentation is changed or added
  • commit message follows commit guidelines

@tniessen tniessen added the semver-major PRs that contain breaking changes and should be released in the next major version. label Sep 14, 2018
@tniessen tniessen added this to the 11.0.0 milestone Sep 14, 2018
@nodejs-github-bot nodejs-github-bot added the crypto Issues and PRs related to the crypto subsystem. label Sep 14, 2018
@tniessen
Copy link
Member Author

cc @nodejs/tsc @nodejs/security-wg @nodejs/crypto

-->

Type: End-of-Life
Type: Runtime

Use of the [`crypto.pbkdf2()`][] API without specifying a digest was deprecated
in Node.js 6.0 because the method defaulted to using the non-recommended
`'SHA1'` digest. Previously, a deprecation warning was printed. Starting in
Node.js 8.0.0, calling `crypto.pbkdf2()` or `crypto.pbkdf2Sync()` with an
Copy link
Contributor

Choose a reason for hiding this comment

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

an -> a

@@ -55,6 +55,11 @@ function check(password, salt, iterations, keylen, digest, callback) {
if (typeof digest !== 'string') {
if (digest !== null)
throw new ERR_INVALID_ARG_TYPE('digest', ['string', 'null'], digest);
if (process.noDeprecation !== true) {
process.emitWarning(
Copy link
Member

Choose a reason for hiding this comment

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

If I'm not wrong this is emitted every time check() is called, is this wanted?

Copy link
Member Author

Choose a reason for hiding this comment

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

check is called once per crypto.pbkdf2 / crypto.pbkdf2Sync call. Would you prefer to only warn once throughout the whole execution?

Copy link
Member

Choose a reason for hiding this comment

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

Yes, I think it's better. As is it may create too much noise.

@tniessen tniessen added the deprecations Issues and PRs related to deprecations. label Sep 17, 2018
@tniessen
Copy link
Member Author

tniessen commented Sep 17, 2018

@lpinca I rewrote it to use the deprecate function, that should take care of it. PTAL.

CI: https://ci.nodejs.org/job/node-test-pull-request/17234/
Resumed in https://ci.nodejs.org/job/node-test-pull-request/17244/
Resumed in https://ci.nodejs.org/job/node-test-pull-request/17266/

I assume that permitting digest === null was unintentional when
digest === undefined was deprecated since their behavior was
equivalent. The sha1 default for digest === null has somehow made it
through refactoring of the PBKDF2 module multiple times, even though
digest === undefined has been EOL for some time now.

This change deprecates setting digest to null so we can fix the
behavior in Node.js 12 or so.
@tniessen tniessen force-pushed the crypto-fix-pbkdf2-behavior-for-digest-null branch from 3aef5e5 to 6bcfb6f Compare September 18, 2018 14:14
@tniessen
Copy link
Member Author

tniessen commented Sep 18, 2018

@tniessen
Copy link
Member Author

tniessen commented Sep 19, 2018

Landed in 19ad6b8, thanks for reviewing.

@tniessen tniessen closed this Sep 19, 2018
tniessen added a commit that referenced this pull request Sep 19, 2018
I assume that permitting digest === null was unintentional when
digest === undefined was deprecated since their behavior was
equivalent. The sha1 default for digest === null has somehow made it
through refactoring of the PBKDF2 module multiple times, even though
digest === undefined has been EOL for some time now.

This change deprecates setting digest to null so we can fix the
behavior in Node.js 12 or so.

PR-URL: #22861
Reviewed-By: Anna Henningsen <[email protected]>
Reviewed-By: Luigi Pinca <[email protected]>
Reviewed-By: James M Snell <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
crypto Issues and PRs related to the crypto subsystem. deprecations Issues and PRs related to deprecations. semver-major PRs that contain breaking changes and should be released in the next major version.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants