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: add RSA-PSS params to asymmetricKeyDetails #39851

Closed
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
17 changes: 12 additions & 5 deletions doc/api/crypto.md
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).
panva marked this conversation as resolved.
Show resolved Hide resolved
* `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
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
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
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