mirror of
https://github.com/nodejs/node.git
synced 2026-10-14 10:26:26 -04:00
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:
1 parent
b6b7f39d3a
commit
7a47cbf4c5
2 files changed
+11
-3
No files matched your search
@@ -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: {},
|
||||
|
||||
@@ -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));
|
||||
|
||||
Reference in new issue
Block a user