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>
51 lines
1.1 KiB
JavaScript
51 lines
1.1 KiB
JavaScript
'use strict';
|
|
|
|
const common = require('../common');
|
|
if (!common.hasCrypto)
|
|
common.skip('missing crypto');
|
|
|
|
const assert = require('assert');
|
|
const {
|
|
generateKeyPair,
|
|
} = require('crypto');
|
|
const {
|
|
assertApproximateSize,
|
|
testEncryptDecrypt,
|
|
testSignVerify,
|
|
} = require('../common/crypto');
|
|
|
|
// Test async RSA key generation with an encrypted private key, but encoded as DER.
|
|
{
|
|
generateKeyPair('rsa', {
|
|
publicExponent: 0x10001,
|
|
modulusLength: 512,
|
|
publicKeyEncoding: {
|
|
type: 'pkcs1',
|
|
format: 'der'
|
|
},
|
|
privateKeyEncoding: {
|
|
type: 'pkcs8',
|
|
format: 'der'
|
|
}
|
|
}, common.mustSucceed((publicKeyDER, privateKeyDER) => {
|
|
assert(Buffer.isBuffer(publicKeyDER));
|
|
assertApproximateSize(publicKeyDER, 74);
|
|
|
|
assert(Buffer.isBuffer(privateKeyDER));
|
|
|
|
const publicKey = {
|
|
key: publicKeyDER,
|
|
type: 'pkcs1',
|
|
format: 'der',
|
|
};
|
|
const privateKey = {
|
|
key: privateKeyDER,
|
|
format: 'der',
|
|
type: 'pkcs8',
|
|
passphrase: 'secret'
|
|
};
|
|
testEncryptDecrypt(publicKey, privateKey);
|
|
testSignVerify(publicKey, privateKey);
|
|
}));
|
|
}
|