@@ -5200,7 +5200,7 @@ template <PublicKeyCipher::Operation operation,
5200
5200
bool PublicKeyCipher::Cipher (Environment* env,
5201
5201
const ManagedEVPPKey& pkey,
5202
5202
int padding,
5203
- const char * oaep_hash ,
5203
+ const EVP_MD* digest ,
5204
5204
const unsigned char * data,
5205
5205
int len,
5206
5206
AllocatedBuffer* out) {
@@ -5212,9 +5212,8 @@ bool PublicKeyCipher::Cipher(Environment* env,
5212
5212
if (EVP_PKEY_CTX_set_rsa_padding (ctx.get (), padding) <= 0 )
5213
5213
return false ;
5214
5214
5215
- if (oaep_hash != nullptr ) {
5216
- if (!EVP_PKEY_CTX_md (ctx.get (), EVP_PKEY_OP_TYPE_CRYPT,
5217
- EVP_PKEY_CTRL_RSA_OAEP_MD, oaep_hash))
5215
+ if (digest != nullptr ) {
5216
+ if (!EVP_PKEY_CTX_set_rsa_oaep_md (ctx.get (), digest))
5218
5217
return false ;
5219
5218
}
5220
5219
@@ -5256,6 +5255,12 @@ void PublicKeyCipher::Cipher(const FunctionCallbackInfo<Value>& args) {
5256
5255
5257
5256
const node::Utf8Value oaep_str (env->isolate (), args[offset + 2 ]);
5258
5257
const char * oaep_hash = args[offset + 2 ]->IsString () ? *oaep_str : nullptr ;
5258
+ const EVP_MD* digest = nullptr ;
5259
+ if (oaep_hash != nullptr ) {
5260
+ digest = EVP_get_digestbyname (oaep_hash);
5261
+ if (digest == nullptr )
5262
+ return THROW_ERR_OSSL_EVP_INVALID_DIGEST (env);
5263
+ }
5259
5264
5260
5265
AllocatedBuffer out;
5261
5266
@@ -5265,7 +5270,7 @@ void PublicKeyCipher::Cipher(const FunctionCallbackInfo<Value>& args) {
5265
5270
env,
5266
5271
pkey,
5267
5272
padding,
5268
- oaep_hash ,
5273
+ digest ,
5269
5274
buf.data (),
5270
5275
buf.length (),
5271
5276
&out);
0 commit comments