mirror of
https://github.com/nodejs/node.git
synced 2024-11-21 21:19:50 +01:00
7224940e54
To avoid timing out on ARM machines in the CI. PR-URL: https://github.com/nodejs/node/pull/49221 Refs: https://github.com/nodejs/node/issues/49202 Refs: https://github.com/nodejs/node/issues/41206 Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
48 lines
1.1 KiB
JavaScript
48 lines
1.1 KiB
JavaScript
'use strict';
|
|
|
|
const common = require('../common');
|
|
if (!common.hasCrypto)
|
|
common.skip('missing crypto');
|
|
|
|
const assert = require('assert');
|
|
const {
|
|
generateKeyPairSync,
|
|
} = require('crypto');
|
|
const {
|
|
assertApproximateSize,
|
|
testEncryptDecrypt,
|
|
testSignVerify,
|
|
pkcs1PubExp,
|
|
pkcs8Exp,
|
|
} = require('../common/crypto');
|
|
|
|
// To make the test faster, we will only test sync key generation once and
|
|
// with a relatively small key.
|
|
{
|
|
const ret = generateKeyPairSync('rsa', {
|
|
publicExponent: 3,
|
|
modulusLength: 512,
|
|
publicKeyEncoding: {
|
|
type: 'pkcs1',
|
|
format: 'pem'
|
|
},
|
|
privateKeyEncoding: {
|
|
type: 'pkcs8',
|
|
format: 'pem'
|
|
}
|
|
});
|
|
|
|
assert.strictEqual(Object.keys(ret).length, 2);
|
|
const { publicKey, privateKey } = ret;
|
|
|
|
assert.strictEqual(typeof publicKey, 'string');
|
|
assert.match(publicKey, pkcs1PubExp);
|
|
assertApproximateSize(publicKey, 162);
|
|
assert.strictEqual(typeof privateKey, 'string');
|
|
assert.match(privateKey, pkcs8Exp);
|
|
assertApproximateSize(privateKey, 512);
|
|
|
|
testEncryptDecrypt(publicKey, privateKey);
|
|
testSignVerify(publicKey, privateKey);
|
|
}
|