mirror of
https://github.com/nodejs/node.git
synced 2025-04-28 13:40:37 +00:00

Since `common/crypto` already exists, it makes sense to keep crypto-related utilities there. The only exception being common.hasCrypto which is needed up front to determine if tests should be skipped. Eliminate the redundant check in hasFipsCrypto and just use crypto.getFips() directly where needed. PR-URL: https://github.com/nodejs/node/pull/56714 Reviewed-By: Yagiz Nizipli <yagiz@nizipli.com> Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
41 lines
1.3 KiB
JavaScript
41 lines
1.3 KiB
JavaScript
'use strict';
|
|
|
|
const common = require('../common');
|
|
if (!common.hasCrypto)
|
|
common.skip('missing crypto');
|
|
|
|
const assert = require('assert');
|
|
const {
|
|
generateKeyPair,
|
|
} = require('crypto');
|
|
const { hasOpenSSL3 } = require('../common/crypto');
|
|
|
|
// This tests check that generateKeyPair returns correct bit length in
|
|
// KeyObject's asymmetricKeyDetails.
|
|
// https://github.com/nodejs/node/issues/46102#issuecomment-1372153541
|
|
{
|
|
generateKeyPair('rsa', {
|
|
modulusLength: 513,
|
|
}, common.mustSucceed((publicKey, privateKey) => {
|
|
assert.strictEqual(privateKey.asymmetricKeyDetails.modulusLength, 513);
|
|
assert.strictEqual(publicKey.asymmetricKeyDetails.modulusLength, 513);
|
|
}));
|
|
|
|
generateKeyPair('rsa-pss', {
|
|
modulusLength: 513,
|
|
}, common.mustSucceed((publicKey, privateKey) => {
|
|
assert.strictEqual(privateKey.asymmetricKeyDetails.modulusLength, 513);
|
|
assert.strictEqual(publicKey.asymmetricKeyDetails.modulusLength, 513);
|
|
}));
|
|
|
|
if (hasOpenSSL3) {
|
|
generateKeyPair('dsa', {
|
|
modulusLength: 2049,
|
|
divisorLength: 256,
|
|
}, common.mustSucceed((publicKey, privateKey) => {
|
|
assert.strictEqual(privateKey.asymmetricKeyDetails.modulusLength, 2049);
|
|
assert.strictEqual(publicKey.asymmetricKeyDetails.modulusLength, 2049);
|
|
}));
|
|
}
|
|
}
|