mirror of
https://github.com/nodejs/node.git
synced 2024-11-24 20:29:23 +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>
56 lines
1.6 KiB
JavaScript
56 lines
1.6 KiB
JavaScript
'use strict';
|
|
|
|
const common = require('../common');
|
|
if (!common.hasCrypto)
|
|
common.skip('missing crypto');
|
|
|
|
const assert = require('assert');
|
|
const {
|
|
generateKeyPair,
|
|
} = require('crypto');
|
|
const {
|
|
testEncryptDecrypt,
|
|
testSignVerify,
|
|
} = require('../common/crypto');
|
|
|
|
// Tests key objects are returned when key encodings are not specified.
|
|
{
|
|
// If no publicKeyEncoding is specified, a key object should be returned.
|
|
generateKeyPair('rsa', {
|
|
modulusLength: 1024,
|
|
privateKeyEncoding: {
|
|
type: 'pkcs1',
|
|
format: 'pem'
|
|
}
|
|
}, common.mustSucceed((publicKey, privateKey) => {
|
|
assert.strictEqual(typeof publicKey, 'object');
|
|
assert.strictEqual(publicKey.type, 'public');
|
|
assert.strictEqual(publicKey.asymmetricKeyType, 'rsa');
|
|
|
|
// The private key should still be a string.
|
|
assert.strictEqual(typeof privateKey, 'string');
|
|
|
|
testEncryptDecrypt(publicKey, privateKey);
|
|
testSignVerify(publicKey, privateKey);
|
|
}));
|
|
|
|
// If no privateKeyEncoding is specified, a key object should be returned.
|
|
generateKeyPair('rsa', {
|
|
modulusLength: 1024,
|
|
publicKeyEncoding: {
|
|
type: 'pkcs1',
|
|
format: 'pem'
|
|
}
|
|
}, common.mustSucceed((publicKey, privateKey) => {
|
|
// The public key should still be a string.
|
|
assert.strictEqual(typeof publicKey, 'string');
|
|
|
|
assert.strictEqual(typeof privateKey, 'object');
|
|
assert.strictEqual(privateKey.type, 'private');
|
|
assert.strictEqual(privateKey.asymmetricKeyType, 'rsa');
|
|
|
|
testEncryptDecrypt(publicKey, privateKey);
|
|
testSignVerify(publicKey, privateKey);
|
|
}));
|
|
}
|