Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
95 commits
Select commit Hold shift + click to select a range
97f3072
stream: add signal support to pipeline generators
ronag Jun 17, 2021
22a78a7
build: preserves symbols during LTO with macOS linker
jesec Aug 21, 2021
fb226ff
crypto: add rsa-pss keygen parameters
panva Aug 29, 2021
381293f
meta: update AUTHORS
nodejs-github-bot Aug 31, 2021
bef78a2
src: register external references of dtrace for snapshot
joyeecheung Aug 31, 2021
6fdf025
src: register external references of node-report for snapshot
joyeecheung Aug 31, 2021
a2c1c3e
src: register external references of BaseObject for snapshot
joyeecheung Aug 31, 2021
b4e074c
src: register missing stream wrap external references
joyeecheung Aug 31, 2021
db75711
src: register missing process methods external references
joyeecheung Aug 31, 2021
6095fb0
src: register external references of SignalWrap for snapshot
joyeecheung Aug 31, 2021
00cca48
src: register external references of TCPWrap for snapshot
joyeecheung Aug 31, 2021
7a17cbf
src: register external references of TTYWrap for snapshot
joyeecheung Aug 31, 2021
826eee3
src: register external references of PipeWrap for snapshot
joyeecheung Aug 31, 2021
b6dd2ea
doc: fix missing history version in `fs.md`
aduh95 Sep 1, 2021
29104f5
meta: consolidate AUTHORS entries for mithunsasidharan
Trott Sep 5, 2021
640353a
lib,repl: ignore non-canBeRequiredByUsers built-in
XadillaX Aug 30, 2021
73aa4e3
src: fix C4805 MSVC warning
targos Sep 5, 2021
67bbfeb
test: make tests pass on Windows with Unix EOL
targos Sep 5, 2021
0b30867
build: run AUTHORS update weekly
Trott Sep 5, 2021
99af212
tools,build: update YAML files in preparation for linting
Trott Sep 5, 2021
5a20f90
build: add YAML linting
Trott Sep 5, 2021
7bddaec
build: add YAML linting to GitHub Actions
Trott Sep 5, 2021
105c9e6
crypto: check webcrypto asymmetric key types during importKey
panva Aug 31, 2021
846e7e8
doc: fix list indentation in corepack.md
alexeyten Sep 7, 2021
fe920b6
src: make napi_create_reference accept symbol
JckXia Aug 29, 2021
98f56d1
deps: update Acorn to v8.5.0
targos Sep 6, 2021
842f936
src: use Isolate::TryGetCurrent where appropriate
addaleax Aug 31, 2021
570bef1
Revert "src: skip test_fatal/test_threads for Debug builds"
addaleax Aug 31, 2021
d426ee9
doc: fix property name 'detail' of performanceEntry
ChristianBoehlke Sep 6, 2021
edcfffe
lib: use standard property names
null8626 Sep 3, 2021
d6124d8
repl: fix top level await with surrogate characters
Mesteery Aug 29, 2021
f03bae7
tools: update remark-html to v13.0.2
targos Sep 8, 2021
6775958
deps: patch for v8 on windows
gengjiawen Sep 6, 2021
a71579b
meta: add more mailmap entries for bajtos
Trott Sep 7, 2021
fc45cbe
crypto: fix default MGF1 hash for OpenSSL 3
tniessen Sep 7, 2021
d657ae6
crypto: fix RSA-PSS default saltLength
tniessen Sep 5, 2021
9f3a015
src: add option to disable loading native addons
d3lm Sep 2, 2021
6d399e1
doc: fix CCM cipher example in MJS
tniessen Aug 30, 2021
cfcd571
src: fix -Wunreachable-code-return error
codebytere Sep 8, 2021
9655329
doc: add Ayase-252 to collaborators
Ayase-252 Sep 11, 2021
2a41530
meta: consolidate AUTHORS entry for mikemaccana
Trott Sep 9, 2021
5b5e272
test: fix internet/test-dns
Trott Sep 11, 2021
5983568
worker: avoid potential deadlock on NearHeapLimit
santigimeno Apr 25, 2021
b3843bf
deps: patch v8 for vs2019 in std17
gengjiawen Sep 10, 2021
d55804c
tools: update all dependencies of markdown linter
targos Sep 8, 2021
4367a61
test: mark test-crypto-timing-safe-equal-benchmarks flaky
richardlau Sep 10, 2021
92f182b
module: fix $ pattern replacements
guybedford Sep 8, 2021
4aa2610
test: update OpenSSL3 error messages for 3.0.0+quic
danbev Sep 13, 2021
c804d07
build: add daily/on-demand internet test workflow
Trott Sep 12, 2021
7ee3fbd
meta: update AUTHORS
nodejs-github-bot Sep 12, 2021
01b1946
build: only lint version numbers for pull requests
targos Sep 7, 2021
7376edc
module: deprecate trailing slash pattern mappings
guybedford Sep 8, 2021
ec6de11
tools: update ansi-regex in lint-md rollup
Trott Sep 14, 2021
1eca9bc
module: support pattern trailers for imports field
guybedford Sep 8, 2021
f666f5a
events: fix duplicate require which cause performance penalty
wwwzbwcom Sep 15, 2021
8aad81d
doc: add full list of subsystems
iam-frankqiu Sep 3, 2021
0df47d5
deps: upgrade npm to 7.23.0
npm-robot Sep 9, 2021
81cb14b
doc: clarify that ObjectWrap requires manual cleanup on shutdown
Flarna Sep 10, 2021
31994fb
src: register zlib external references for snapshot
joyeecheung Sep 6, 2021
bc9c2ca
http: remove CRLF variable
shfshanyue Sep 14, 2021
588257c
meta: add .mailmap entry for arcanis
Trott Sep 14, 2021
9c76c69
deps: patch V8 to 9.3.345.19
targos Sep 14, 2021
886921d
build: add paths-ignore for build-tarball workflow
Trott Sep 14, 2021
9793e7f
build: add .mailmap/AUTHORS to path-ignore for test-asan
Trott Sep 14, 2021
8d5787a
build: add .mailmap/AUTHORS to paths-ignore for test-macos
Trott Sep 14, 2021
95528b2
src: remove unnecessary comment and add a CHECK in crypto_tls.cc
RaisinTen Sep 4, 2021
effdfa9
meta: update GeoffreyBooth email address
GeoffreyBooth Sep 14, 2021
7fdb127
doc: add timeout.close
galkin Sep 8, 2021
5c67085
dns: cleanup validation
VoltrexKeyva Sep 10, 2021
b7dc651
build: run modified internet tests on GitHub Actions
Trott Sep 14, 2021
59fff92
fs: make `open` and `close` stream override optional when unused
aduh95 Sep 6, 2021
d80082f
crypto: use `validateObject`
VoltrexKeyva Aug 24, 2021
06f6e01
deps: add riscv64 into openssl Makefile and gen openssl-riscv64
luyahan Sep 10, 2021
1ced732
doc: fix CJS-ESM selector in Safari
bmeck Sep 17, 2021
51f9ad4
src: add option to disable global search paths
zcbenz Aug 13, 2021
9a67296
src: add --no-global-search-paths cli option
zcbenz Aug 16, 2021
6085280
lib: avoid creating a throw away object in `validateObject`
aduh95 Aug 19, 2021
dd50b91
lib: remove useless statement
Sep 3, 2021
8b80dcb
doc: correct parameters in fs and stream documentation
Sep 4, 2021
2488bc0
doc: clean up weird notes about reentrancy
addaleax Sep 14, 2021
98d42fa
meta: add mailmap entry for LPardue
Trott Sep 16, 2021
a8c99d9
tools: update doc generator dependencies
targos Sep 8, 2021
ec94bec
test: do not run `test-corepack-yarn-install` with no internet
aduh95 Sep 12, 2021
4993318
meta: update GeoffreyBooth email addresses in AUTHORS and .mailmap
Trott Sep 17, 2021
a07d844
doc: fix comma splice
Trott Sep 17, 2021
590ace4
tools,doc: fix misrendering of consecutive JS blocks
Trott Sep 18, 2021
a63a4bc
http: limit requests per connection
fatal10110 Sep 11, 2021
f0dec58
crypto: fix webcrypto ed(25519|448) spki/pkcs8 import
panva Sep 16, 2021
b6939a3
doc: prepare README.md for stricter linting
Trott Sep 17, 2021
6be405b
test: fix test-dgram-udp6-link-local-address on Windows
targos Sep 5, 2021
0254b4b
doc: fix markdown indentation in lists
targos Sep 18, 2021
85206b7
deps: upgrade npm to 7.24.0
npm-robot Sep 20, 2021
e4825dc
doc: changes default values for fs.read fns
rbrishabh Jul 14, 2021
4444b5c
meta: update AUTHORS
nodejs-github-bot Sep 19, 2021
aff2a0a
2021-09-22, Version 16.10.0 (Current)
BethGriggs Sep 21, 2021
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
crypto: add rsa-pss keygen parameters
PR-URL: #39927
Reviewed-By: James M Snell <[email protected]>
  • Loading branch information
panva authored and richardlau committed Sep 10, 2021
commit fb226ff2eeb55680e86d03d625507f45ace6d328
16 changes: 16 additions & 0 deletions doc/api/crypto.md
Original file line number Diff line number Diff line change
Expand Up @@ -3375,6 +3375,10 @@ generateKey('hmac', { length: 64 }, (err, key) => {
<!-- YAML
added: v10.12.0
changes:
- version: REPLACEME
pr-url: https://github.com/nodejs/node/pull/39927
description: Add ability to define `RSASSA-PSS-params` sequence parameters
for RSA-PSS keys pairs.
- version:
- v13.9.0
- v12.17.0
Expand All @@ -3400,6 +3404,10 @@ changes:
* `options`: {Object}
* `modulusLength`: {number} Key size in bits (RSA, DSA).
* `publicExponent`: {number} Public exponent (RSA). **Default:** `0x10001`.
* `hashAlgorithm`: {string} Name of the message digest (RSA-PSS).
* `mgf1HashAlgorithm`: {string} Name of the message digest used by
MGF1 (RSA-PSS).
* `saltLength`: {number} Minimal salt length in bytes (RSA-PSS).
* `divisorLength`: {number} Size of `q` in bits (DSA).
* `namedCurve`: {string} Name of the curve to use (EC).
* `prime`: {Buffer} The prime parameter (DH).
Expand Down Expand Up @@ -3478,6 +3486,10 @@ a `Promise` for an `Object` with `publicKey` and `privateKey` properties.
<!-- YAML
added: v10.12.0
changes:
- version: REPLACEME
pr-url: https://github.com/nodejs/node/pull/39927
description: Add ability to define `RSASSA-PSS-params` sequence parameters
for RSA-PSS keys pairs.
- version:
- v13.9.0
- v12.17.0
Expand All @@ -3503,6 +3515,10 @@ changes:
* `options`: {Object}
* `modulusLength`: {number} Key size in bits (RSA, DSA).
* `publicExponent`: {number} Public exponent (RSA). **Default:** `0x10001`.
* `hashAlgorithm`: {string} Name of the message digest (RSA-PSS).
* `mgf1HashAlgorithm`: {string} Name of the message digest used by
MGF1 (RSA-PSS).
* `saltLength`: {number} Minimal salt length in bytes (RSA-PSS).
* `divisorLength`: {number} Size of `q` in bits (DSA).
* `namedCurve`: {string} Name of the curve to use (EC).
* `prime`: {Buffer} The prime parameter (DH).
Expand Down
13 changes: 13 additions & 0 deletions doc/api/deprecations.md
Original file line number Diff line number Diff line change
Expand Up @@ -2799,6 +2799,19 @@ non-number value for `hints` option, a non-nullish non-boolean value for `all`
option, or a non-nullish non-boolean value for `verbatim` option in
[`dns.lookup()`][] and [`dnsPromises.lookup()`][] is deprecated.

### DEP0154: RSA-PSS generate key pair options
<!-- YAML
changes:
- version: REPLACEME
pr-url: https://github.com/nodejs/node/pull/39927
description: Documentation-only deprecation.
-->

Type: Documentation-only (supports [`--pending-deprecation`][])

The `'hash'` and `'mgf1Hash'` options are replaced with `'hashAlgorithm'`
and `'mgf1HashAlgorithm'`.

[Legacy URL API]: url.md#url_legacy_url_api
[NIST SP 800-38D]: https://nvlpubs.nist.gov/nistpubs/Legacy/SP/nistspecialpublication800-38d.pdf
[RFC 6066]: https://tools.ietf.org/html/rfc6066#section-3
Expand Down
43 changes: 36 additions & 7 deletions lib/internal/crypto/keygen.js
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,9 @@ const {

const { isArrayBufferView } = require('internal/util/types');

const { getOptionValue } = require('internal/options');
const pendingDeprecation = getOptionValue('--pending-deprecation');

function wrapKey(key, ctor) {
if (typeof key === 'string' ||
isArrayBufferView(key) ||
Expand Down Expand Up @@ -193,21 +196,47 @@ function createJob(mode, type, options) {
...encoding);
}

const { hash, mgf1Hash, saltLength } = options;
if (hash !== undefined && typeof hash !== 'string')
throw new ERR_INVALID_ARG_VALUE('options.hash', hash);
if (mgf1Hash !== undefined && typeof mgf1Hash !== 'string')
throw new ERR_INVALID_ARG_VALUE('options.mgf1Hash', mgf1Hash);
const {
hash, mgf1Hash, hashAlgorithm, mgf1HashAlgorithm, saltLength
} = options;
if (saltLength !== undefined && (!isInt32(saltLength) || saltLength < 0))
throw new ERR_INVALID_ARG_VALUE('options.saltLength', saltLength);
if (hashAlgorithm !== undefined && typeof hashAlgorithm !== 'string')
throw new ERR_INVALID_ARG_VALUE('options.hashAlgorithm', hashAlgorithm);
if (mgf1HashAlgorithm !== undefined &&
typeof mgf1HashAlgorithm !== 'string')
throw new ERR_INVALID_ARG_VALUE('options.mgf1HashAlgorithm',
mgf1HashAlgorithm);
if (hash !== undefined) {
pendingDeprecation && process.emitWarning(
'"options.hash" is deprecated, ' +
'use "options.hashAlgorithm" instead.',
'DeprecationWarning',
'DEP0154');
if (typeof hash !== 'string' ||
(hashAlgorithm && hash !== hashAlgorithm)) {
throw new ERR_INVALID_ARG_VALUE('options.hash', hash);
}
}
if (mgf1Hash !== undefined) {
pendingDeprecation && process.emitWarning(
'"options.mgf1Hash" is deprecated, ' +
'use "options.mgf1HashAlgorithm" instead.',
'DeprecationWarning',
'DEP0154');
if (typeof mgf1Hash !== 'string' ||
(mgf1HashAlgorithm && mgf1Hash !== mgf1HashAlgorithm)) {
throw new ERR_INVALID_ARG_VALUE('options.mgf1Hash', mgf1Hash);
}
}

return new RsaKeyPairGenJob(
mode,
kKeyVariantRSA_PSS,
modulusLength,
publicExponent,
hash,
mgf1Hash,
hashAlgorithm || hash,
mgf1HashAlgorithm || mgf1Hash,
saltLength,
...encoding);
}
Expand Down
51 changes: 51 additions & 0 deletions test/parallel/test-crypto-keygen-deprecation.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
// Flags: --pending-deprecation

'use strict';

const common = require('../common');
if (!common.hasCrypto)
common.skip('missing crypto');

const DeprecationWarning = [];
DeprecationWarning.push([
'"options.hash" is deprecated, use "options.hashAlgorithm" instead.',
'DEP0154']);
DeprecationWarning.push([
'"options.mgf1Hash" is deprecated, use "options.mgf1HashAlgorithm" instead.',
'DEP0154']);

common.expectWarning({ DeprecationWarning });

const assert = require('assert');
const { generateKeyPair } = require('crypto');

{
// This test makes sure deprecated options still work as intended

generateKeyPair('rsa-pss', {
modulusLength: 512,
saltLength: 16,
hash: 'sha256',
mgf1Hash: 'sha256'
}, common.mustSucceed((publicKey, privateKey) => {
assert.strictEqual(publicKey.type, 'public');
assert.strictEqual(publicKey.asymmetricKeyType, 'rsa-pss');
assert.deepStrictEqual(publicKey.asymmetricKeyDetails, {
modulusLength: 512,
publicExponent: 65537n,
hashAlgorithm: 'sha256',
mgf1HashAlgorithm: 'sha256',
saltLength: 16
});

assert.strictEqual(privateKey.type, 'private');
assert.strictEqual(privateKey.asymmetricKeyType, 'rsa-pss');
assert.deepStrictEqual(privateKey.asymmetricKeyDetails, {
modulusLength: 512,
publicExponent: 65537n,
hashAlgorithm: 'sha256',
mgf1HashAlgorithm: 'sha256',
saltLength: 16
});
}));
}
83 changes: 68 additions & 15 deletions test/parallel/test-crypto-keygen.js
Original file line number Diff line number Diff line change
Expand Up @@ -302,8 +302,8 @@ const sec1EncExp = (cipher) => getRegExpForPEM('EC PRIVATE KEY', cipher);
generateKeyPair('rsa-pss', {
modulusLength: 512,
saltLength: 16,
hash: 'sha256',
mgf1Hash: 'sha256'
hashAlgorithm: 'sha256',
mgf1HashAlgorithm: 'sha256'
}, common.mustSucceed((publicKey, privateKey) => {
assert.strictEqual(publicKey.type, 'public');
assert.strictEqual(publicKey.asymmetricKeyType, 'rsa-pss');
Expand Down Expand Up @@ -1324,12 +1324,12 @@ const sec1EncExp = (cipher) => getRegExpForPEM('EC PRIVATE KEY', cipher);
assert.throws(() => {
generateKeyPairSync('rsa-pss', {
modulusLength: 4096,
hash: hashValue
hashAlgorithm: hashValue
});
}, {
name: 'TypeError',
code: 'ERR_INVALID_ARG_VALUE',
message: "The property 'options.hash' is invalid. " +
message: "The property 'options.hashAlgorithm' is invalid. " +
`Received ${inspect(hashValue)}`
});
}
Expand All @@ -1339,8 +1339,8 @@ const sec1EncExp = (cipher) => getRegExpForPEM('EC PRIVATE KEY', cipher);
generateKeyPair('rsa-pss', {
modulusLength: 512,
saltLength: 2147483648,
hash: 'sha256',
mgf1Hash: 'sha256'
hashAlgorithm: 'sha256',
mgf1HashAlgorithm: 'sha256'
}, common.mustNotCall());
}, {
name: 'TypeError',
Expand All @@ -1353,8 +1353,8 @@ const sec1EncExp = (cipher) => getRegExpForPEM('EC PRIVATE KEY', cipher);
generateKeyPair('rsa-pss', {
modulusLength: 512,
saltLength: -1,
hash: 'sha256',
mgf1Hash: 'sha256'
hashAlgorithm: 'sha256',
mgf1HashAlgorithm: 'sha256'
}, common.mustNotCall());
}, {
name: 'TypeError',
Expand Down Expand Up @@ -1451,8 +1451,8 @@ const sec1EncExp = (cipher) => getRegExpForPEM('EC PRIVATE KEY', cipher);
generateKeyPair('rsa-pss', {
modulusLength: 512,
saltLength: 16,
hash: 'sha256',
mgf1Hash: undefined
hashAlgorithm: 'sha256',
mgf1HashAlgorithm: undefined
});
},
{
Expand All @@ -1462,21 +1462,21 @@ const sec1EncExp = (cipher) => getRegExpForPEM('EC PRIVATE KEY', cipher);
}
);

for (const mgf1Hash of [null, 0, false, {}, []]) {
for (const mgf1HashAlgorithm of [null, 0, false, {}, []]) {
assert.throws(
() => {
generateKeyPair('rsa-pss', {
modulusLength: 512,
saltLength: 16,
hash: 'sha256',
mgf1Hash
hashAlgorithm: 'sha256',
mgf1HashAlgorithm
}, common.mustNotCall());
},
{
name: 'TypeError',
code: 'ERR_INVALID_ARG_VALUE',
message: "The property 'options.mgf1Hash' is invalid. " +
`Received ${inspect(mgf1Hash)}`
message: "The property 'options.mgf1HashAlgorithm' is invalid. " +
`Received ${inspect(mgf1HashAlgorithm)}`

}
);
Expand Down Expand Up @@ -1568,3 +1568,56 @@ if (!common.hasOpenSSL3) {
}
}
}

{
// This test makes sure deprecated and new options may be used
// simultaneously so long as they're identical values.

generateKeyPair('rsa-pss', {
modulusLength: 512,
saltLength: 16,
hash: 'sha256',
hashAlgorithm: 'sha256',
mgf1Hash: 'sha256',
mgf1HashAlgorithm: 'sha256'
}, common.mustSucceed((publicKey, privateKey) => {
assert.strictEqual(publicKey.type, 'public');
assert.strictEqual(publicKey.asymmetricKeyType, 'rsa-pss');
assert.deepStrictEqual(publicKey.asymmetricKeyDetails, {
modulusLength: 512,
publicExponent: 65537n,
hashAlgorithm: 'sha256',
mgf1HashAlgorithm: 'sha256',
saltLength: 16
});

assert.strictEqual(privateKey.type, 'private');
assert.strictEqual(privateKey.asymmetricKeyType, 'rsa-pss');
assert.deepStrictEqual(privateKey.asymmetricKeyDetails, {
modulusLength: 512,
publicExponent: 65537n,
hashAlgorithm: 'sha256',
mgf1HashAlgorithm: 'sha256',
saltLength: 16
});
}));
}

{
// This test makes sure deprecated and new options must
// be the same value.

assert.throws(() => generateKeyPair('rsa-pss', {
modulusLength: 512,
saltLength: 16,
mgf1Hash: 'sha256',
mgf1HashAlgorithm: 'sha1'
}, common.mustNotCall()), { code: 'ERR_INVALID_ARG_VALUE' });

assert.throws(() => generateKeyPair('rsa-pss', {
modulusLength: 512,
saltLength: 16,
hash: 'sha256',
hashAlgorithm: 'sha1'
}, common.mustNotCall()), { code: 'ERR_INVALID_ARG_VALUE' });
}