mirror of
https://github.com/nodejs/node.git
synced 2025-05-20 08:49:49 +00:00

This patch changes GetRsaKeyDetail to work in older supported versions of OpenSSL. Refs: https://github.com/openssl/openssl/pull/10217 PR-URL: https://github.com/nodejs/node/pull/36877 Refs: https://github.com/nodejs/node/pull/36188 Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Filip Skokan <panva.ip@gmail.com> Reviewed-By: Richard Lau <rlau@redhat.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
41 lines
927 B
JavaScript
41 lines
927 B
JavaScript
'use strict';
|
|
|
|
const common = require('../common');
|
|
|
|
if (!common.hasCrypto)
|
|
common.skip('missing crypto');
|
|
|
|
const {
|
|
createPrivateKey,
|
|
createPublicKey,
|
|
webcrypto: {
|
|
subtle
|
|
}
|
|
} = require('crypto');
|
|
|
|
const fixtures = require('../common/fixtures');
|
|
|
|
{
|
|
const rsaPssKeyWithoutParams = fixtures.readKey('rsa_pss_private_2048.pem');
|
|
|
|
const pkcs8 = createPrivateKey(rsaPssKeyWithoutParams).export({
|
|
type: 'pkcs8',
|
|
format: 'der'
|
|
});
|
|
const spki = createPublicKey(rsaPssKeyWithoutParams).export({
|
|
type: 'spki',
|
|
format: 'der'
|
|
});
|
|
|
|
const hashes = ['SHA-1', 'SHA-256', 'SHA-384', 'SHA-512'];
|
|
|
|
const tasks = [];
|
|
for (const hash of hashes) {
|
|
const algorithm = { name: 'RSA-PSS', hash };
|
|
tasks.push(subtle.importKey('pkcs8', pkcs8, algorithm, true, ['sign']));
|
|
tasks.push(subtle.importKey('spki', spki, algorithm, true, ['verify']));
|
|
}
|
|
|
|
Promise.all(tasks).then(common.mustCall());
|
|
}
|