@@ -9,7 +9,7 @@ const crypto = require('crypto');
99const constants = crypto . constants ;
1010
1111const fixtures = require ( '../common/fixtures' ) ;
12- const { hasOpenSSL3 } = require ( '../common/crypto' ) ;
12+ const { hasOpenSSL , hasOpenSSL3 } = require ( '../common/crypto' ) ;
1313
1414// Test certificates
1515const certPem = fixtures . readKey ( 'rsa_cert.crt' ) ;
@@ -225,20 +225,38 @@ function test_rsa(padding, encryptOaepHash, decryptOaepHash) {
225225
226226 if ( padding === constants . RSA_PKCS1_PADDING ) {
227227 if ( ! process . config . variables . node_shared_openssl ) {
228- assert . throws ( ( ) => {
229- crypto . privateDecrypt ( {
230- key : rsaKeyPem ,
231- padding : padding ,
232- oaepHash : decryptOaepHash
233- } , encryptedBuffer ) ;
234- } , { code : 'ERR_INVALID_ARG_VALUE' } ) ;
235- assert . throws ( ( ) => {
236- crypto . privateDecrypt ( {
237- key : rsaPkcs8KeyPem ,
238- padding : padding ,
239- oaepHash : decryptOaepHash
240- } , encryptedBuffer ) ;
241- } , { code : 'ERR_INVALID_ARG_VALUE' } ) ;
228+ // TODO(richardlau) remove check and else branch after deps/openssl
229+ // is upgraded.
230+ if ( hasOpenSSL ( 3 , 2 ) ) {
231+ let decryptedBuffer = crypto . privateDecrypt ( {
232+ key : rsaKeyPem ,
233+ padding : padding ,
234+ oaepHash : decryptOaepHash
235+ } , encryptedBuffer ) ;
236+ assert . deepStrictEqual ( decryptedBuffer , input ) ;
237+
238+ decryptedBuffer = crypto . privateDecrypt ( {
239+ key : rsaPkcs8KeyPem ,
240+ padding : padding ,
241+ oaepHash : decryptOaepHash
242+ } , encryptedBuffer ) ;
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+ }
242260 } else {
243261 // The version of a linked against OpenSSL. May
244262 // or may not support implicit rejection. Figuring
0 commit comments