Skip to content

Commit

Permalink
fixup! crypto: add RSA-PSS params to asymmetricKeyDetails
Browse files Browse the repository at this point in the history
  • Loading branch information
panva committed Aug 29, 2021
1 parent 98d2e56 commit 9319f2f
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 9 deletions.
17 changes: 12 additions & 5 deletions doc/api/crypto.md
Original file line number Diff line number Diff line change
Expand Up @@ -1908,14 +1908,20 @@ const {
### `keyObject.asymmetricKeyDetails`
<!-- YAML
added: v15.7.0
changes:
- version: REPLACEME
pr-url: https://github.com/nodejs/node/pull/39851
description: Expose `RSASSA-PSS-params` sequence parameters
for RSA-PSS keys.
-->

* {Object}
* `modulusLength`: {number} Key size in bits (RSA, DSA).
* `publicExponent`: {bigint} Public exponent (RSA).
* `modulusLength`: {number} Key size in bits (RSA, RSA-PSS, DSA).
* `publicExponent`: {bigint} Public exponent (RSA, RSA-PSS).
* `hashAlgorithm`: {string} Name of the message digest (RSA-PSS).
* `mgf1Hash`: {string} Name of the message digest used by MGF1 (RSA-PSS).
* `saltLength`: {number} Salt length in bytes (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 (EC).

Expand All @@ -1925,7 +1931,8 @@ through this property can be used to uniquely identify a key or to compromise
the security of the key.

For RSA-PSS keys, if the key material contains a `RSASSA-PSS-params` sequence,
the `hashAlgorithm`, `mgf1Hash`, and `saltLength` properties will be set.
the `hashAlgorithm`, `mgf1HashAlgorithm`, and `saltLength` properties will be
set.

Other key details might be exposed via this API using additional attributes.

Expand Down
2 changes: 1 addition & 1 deletion src/crypto/crypto_rsa.cc
Original file line number Diff line number Diff line change
Expand Up @@ -599,7 +599,7 @@ Maybe<bool> GetRsaKeyDetail(
if (target
->Set(
env->context(),
env->mgf1_hash_string(),
env->mgf1_hash_algorithm_string(),
OneByteString(env->isolate(), OBJ_nid2ln(mgf1_hash_nid)))
.IsNothing()) {
return Nothing<bool>();
Expand Down
2 changes: 1 addition & 1 deletion src/env.h
Original file line number Diff line number Diff line change
Expand Up @@ -317,7 +317,7 @@ constexpr size_t kFsStatsBufferLength =
V(message_port_string, "messagePort") \
V(message_string, "message") \
V(messageerror_string, "messageerror") \
V(mgf1_hash_string, "mgf1Hash") \
V(mgf1_hash_algorithm_string, "mgf1HashAlgorithm") \
V(minttl_string, "minttl") \
V(module_string, "module") \
V(modulus_string, "modulus") \
Expand Down
4 changes: 2 additions & 2 deletions test/parallel/test-crypto-key-objects.js
Original file line number Diff line number Diff line change
Expand Up @@ -652,7 +652,7 @@ const privateDsa = fixtures.readKey('dsa_private_encrypted_1025.pem',
modulusLength: 2048,
publicExponent: 65537n,
hashAlgorithm: 'sha1',
mgf1Hash: 'sha1',
mgf1HashAlgorithm: 'sha1',
saltLength: 20
};

Expand Down Expand Up @@ -727,7 +727,7 @@ const privateDsa = fixtures.readKey('dsa_private_encrypted_1025.pem',
modulusLength: 2048,
publicExponent: 65537n,
hashAlgorithm: 'sha512',
mgf1Hash: 'sha256',
mgf1HashAlgorithm: 'sha256',
saltLength: 20
};

Expand Down

0 comments on commit 9319f2f

Please sign in to comment.