@@ -9,7 +9,7 @@ const crypto = require('crypto');
|
9 | 9 | const constants = crypto.constants; |
10 | 10 | |
11 | 11 | const fixtures = require('../common/fixtures'); |
12 | | -const { hasOpenSSL3 } = require('../common/crypto'); |
| 12 | +const { hasOpenSSL, hasOpenSSL3 } = require('../common/crypto'); |
13 | 13 | |
14 | 14 | // Test certificates |
15 | 15 | const certPem = fixtures.readKey('rsa_cert.crt'); |
@@ -225,20 +225,38 @@ function test_rsa(padding, encryptOaepHash, decryptOaepHash) {
|
225 | 225 | |
226 | 226 | if (padding === constants.RSA_PKCS1_PADDING) { |
227 | 227 | if (!process.config.variables.node_shared_openssl) { |
228 | | -assert.throws(() => { |
229 | | -crypto.privateDecrypt({ |
| 228 | +// TODO(richardlau) remove check and else branch after deps/openssl |
| 229 | +// is upgraded. |
| 230 | +if (hasOpenSSL(3, 2)) { |
| 231 | +let decryptedBuffer = crypto.privateDecrypt({ |
230 | 232 | key: rsaKeyPem, |
231 | 233 | padding: padding, |
232 | 234 | oaepHash: decryptOaepHash |
233 | 235 | }, encryptedBuffer); |
234 | | -}, { code: 'ERR_INVALID_ARG_VALUE' }); |
235 | | - assert.throws(() => { |
236 | | -crypto.privateDecrypt({ |
| 236 | + assert.deepStrictEqual(decryptedBuffer, input); |
| 237 | + |
| 238 | +decryptedBuffer = crypto.privateDecrypt({ |
237 | 239 | key: rsaPkcs8KeyPem, |
238 | 240 | padding: padding, |
239 | 241 | oaepHash: decryptOaepHash |
240 | 242 | }, encryptedBuffer); |
241 | | -}, { code: 'ERR_INVALID_ARG_VALUE' }); |
| 243 | +assert.deepStrictEqual(decryptedBuffer, input); |
| 244 | +} else { |
| 245 | +assert.throws(() => { |
| 246 | +crypto.privateDecrypt({ |
| 247 | +key: rsaKeyPem, |
| 248 | +padding: padding, |
| 249 | +oaepHash: decryptOaepHash |
| 250 | +}, encryptedBuffer); |
| 251 | +}, { code: 'ERR_INVALID_ARG_VALUE' }); |
| 252 | +assert.throws(() => { |
| 253 | +crypto.privateDecrypt({ |
| 254 | +key: rsaPkcs8KeyPem, |
| 255 | +padding: padding, |
| 256 | +oaepHash: decryptOaepHash |
| 257 | +}, encryptedBuffer); |
| 258 | +}, { code: 'ERR_INVALID_ARG_VALUE' }); |
| 259 | +} |
242 | 260 | } else { |
243 | 261 | // The version of a linked against OpenSSL. May |
244 | 262 | // or may not support implicit rejection. Figuring |
|