crypto: normalize RsaHashedKeyParams publicExponent

Fixes: https://github.com/nodejs/node/issues/59535
PR-URL: https://github.com/nodejs/node/pull/59538
Fixes: https://github.com/nodejs/node/issues/59534
Reviewed-By: Tobias Nießen <tniessen@tnie.de>
Reviewed-By: Yagiz Nizipli <yagiz@nizipli.com>
Reviewed-By: Rafael Gonzaga <rafael.nunu@hotmail.com>
This commit is contained in:
Filip Skokan authored and Node.js GitHub Bot committed 2025-08-21 14:14:56 +00:00
1 parent b6b7f39d3a
commit 7a47cbf4c5
2 files changed
+11 -3

No files matched your search

+3 -1
View File
@@ -397,7 +397,9 @@ const kSupportedAlgorithms = createSupportedAlgorithms(kAlgorithmDefinitions);
const simpleAlgorithmDictionaries = {
AeadParams: { iv: 'BufferSource', additionalData: 'BufferSource' },
RsaHashedKeyGenParams: { hash: 'HashAlgorithmIdentifier' },
// publicExponent is not strictly a BufferSource but it is a Uint8Array that we normalize
// this way
RsaHashedKeyGenParams: { hash: 'HashAlgorithmIdentifier', publicExponent: 'BufferSource' },
EcKeyGenParams: {},
HmacKeyGenParams: { hash: 'HashAlgorithmIdentifier' },
RsaPssParams: {},
+8 -2
View File
@@ -311,14 +311,20 @@ if (hasOpenSSL(3, 5)) {
assert.deepStrictEqual(privateKey.usages, privateUsages);
assert.strictEqual(publicKey.algorithm.name, name);
assert.strictEqual(publicKey.algorithm.modulusLength, modulusLength);
assert.deepStrictEqual(publicKey.algorithm.publicExponent, publicExponent);
assert(publicKey.algorithm.publicExponent instanceof Uint8Array);
assert.notStrictEqual(publicKey.algorithm.publicExponent, publicExponent);
assert(!Buffer.isBuffer(publicKey.algorithm.publicExponent));
assert.deepStrictEqual(publicKey.algorithm.publicExponent, new Uint8Array(publicExponent));
assert.strictEqual(
KeyObject.from(publicKey).asymmetricKeyDetails.publicExponent,
bigIntArrayToUnsignedBigInt(publicExponent));
assert.strictEqual(publicKey.algorithm.hash.name, hash);
assert.strictEqual(privateKey.algorithm.name, name);
assert.strictEqual(privateKey.algorithm.modulusLength, modulusLength);
assert.deepStrictEqual(privateKey.algorithm.publicExponent, publicExponent);
assert(privateKey.algorithm.publicExponent instanceof Uint8Array);
assert.notStrictEqual(privateKey.algorithm.publicExponent, publicExponent);
assert(!Buffer.isBuffer(privateKey.algorithm.publicExponent));
assert.deepStrictEqual(privateKey.algorithm.publicExponent, new Uint8Array(publicExponent));
assert.strictEqual(
KeyObject.from(privateKey).asymmetricKeyDetails.publicExponent,
bigIntArrayToUnsignedBigInt(publicExponent));