Skip to content

Commit

Permalink
crypto: fix OpenSSL return code handling
Browse files Browse the repository at this point in the history
PR-URL: #29489
Reviewed-By: David Carlier <devnexen@gmail.com>
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: Minwoo Jung <minwoo@nodesource.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
  • Loading branch information
tniessen authored and BridgeAR committed Sep 25, 2019
1 parent 54f327b commit dd5d944
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions src/node_crypto.cc
Original file line number Diff line number Diff line change
Expand Up @@ -5215,15 +5215,16 @@ bool PublicKeyCipher::Cipher(Environment* env,
return false;

if (digest != nullptr) {
if (!EVP_PKEY_CTX_set_rsa_oaep_md(ctx.get(), digest))
if (EVP_PKEY_CTX_set_rsa_oaep_md(ctx.get(), digest) <= 0)
return false;
}

if (oaep_label_len != 0) {
// OpenSSL takes ownership of the label, so we need to create a copy.
void* label = OPENSSL_memdup(oaep_label, oaep_label_len);
CHECK_NOT_NULL(label);
if (!EVP_PKEY_CTX_set0_rsa_oaep_label(ctx.get(), label, oaep_label_len)) {
if (0 >= EVP_PKEY_CTX_set0_rsa_oaep_label(ctx.get(), label,
oaep_label_len)) {
OPENSSL_free(label);
return false;
}
Expand Down

0 comments on commit dd5d944

Please sign in to comment.