mirror of
https://github.com/nodejs/node.git
synced 2025-08-15 13:48:44 +02:00
test: prepare test-crypto-rsa-dsa for newer OpenSSL
Update `parallel/test-crypto-rsa-dsa` to prepare for updating `deps/openssl` to later versions of OpenSSL which support implicit rejections with `RSA_PKCS1_PADDING`. PR-URL: https://github.com/nodejs/node/pull/58100 Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: Yagiz Nizipli <yagiz@nizipli.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Filip Skokan <panva.ip@gmail.com> Reviewed-By: Michaël Zasso <targos@protonmail.com>
This commit is contained in:
parent
0259df9faf
commit
cb531b0616
1 changed files with 25 additions and 7 deletions
|
@ -9,7 +9,7 @@ const crypto = require('crypto');
|
||||||
const constants = crypto.constants;
|
const constants = crypto.constants;
|
||||||
|
|
||||||
const fixtures = require('../common/fixtures');
|
const fixtures = require('../common/fixtures');
|
||||||
const { hasOpenSSL3 } = require('../common/crypto');
|
const { hasOpenSSL, hasOpenSSL3 } = require('../common/crypto');
|
||||||
|
|
||||||
// Test certificates
|
// Test certificates
|
||||||
const certPem = fixtures.readKey('rsa_cert.crt');
|
const certPem = fixtures.readKey('rsa_cert.crt');
|
||||||
|
@ -225,6 +225,23 @@ function test_rsa(padding, encryptOaepHash, decryptOaepHash) {
|
||||||
|
|
||||||
if (padding === constants.RSA_PKCS1_PADDING) {
|
if (padding === constants.RSA_PKCS1_PADDING) {
|
||||||
if (!process.config.variables.node_shared_openssl) {
|
if (!process.config.variables.node_shared_openssl) {
|
||||||
|
// TODO(richardlau) remove check and else branch after deps/openssl
|
||||||
|
// is upgraded.
|
||||||
|
if (hasOpenSSL(3, 2)) {
|
||||||
|
let decryptedBuffer = crypto.privateDecrypt({
|
||||||
|
key: rsaKeyPem,
|
||||||
|
padding: padding,
|
||||||
|
oaepHash: decryptOaepHash
|
||||||
|
}, encryptedBuffer);
|
||||||
|
assert.deepStrictEqual(decryptedBuffer, input);
|
||||||
|
|
||||||
|
decryptedBuffer = crypto.privateDecrypt({
|
||||||
|
key: rsaPkcs8KeyPem,
|
||||||
|
padding: padding,
|
||||||
|
oaepHash: decryptOaepHash
|
||||||
|
}, encryptedBuffer);
|
||||||
|
assert.deepStrictEqual(decryptedBuffer, input);
|
||||||
|
} else {
|
||||||
assert.throws(() => {
|
assert.throws(() => {
|
||||||
crypto.privateDecrypt({
|
crypto.privateDecrypt({
|
||||||
key: rsaKeyPem,
|
key: rsaKeyPem,
|
||||||
|
@ -239,6 +256,7 @@ function test_rsa(padding, encryptOaepHash, decryptOaepHash) {
|
||||||
oaepHash: decryptOaepHash
|
oaepHash: decryptOaepHash
|
||||||
}, encryptedBuffer);
|
}, encryptedBuffer);
|
||||||
}, { code: 'ERR_INVALID_ARG_VALUE' });
|
}, { code: 'ERR_INVALID_ARG_VALUE' });
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
// The version of a linked against OpenSSL. May
|
// The version of a linked against OpenSSL. May
|
||||||
// or may not support implicit rejection. Figuring
|
// or may not support implicit rejection. Figuring
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue