diff --git a/src/node_crypto.cc b/src/node_crypto.cc index 72fd05c2ecd5a5..b833b7415d51ff 100644 --- a/src/node_crypto.cc +++ b/src/node_crypto.cc @@ -5115,7 +5115,7 @@ void DiffieHellman::ComputeSecret(const FunctionCallbackInfo& args) { } void DiffieHellman::SetKey(const v8::FunctionCallbackInfo& args, - void (*set_field)(DH*, BIGNUM*), const char* what) { + int (*set_field)(DH*, BIGNUM*), const char* what) { Environment* env = Environment::GetCurrent(args); DiffieHellman* dh; @@ -5138,12 +5138,13 @@ void DiffieHellman::SetKey(const v8::FunctionCallbackInfo& args, BN_bin2bn(reinterpret_cast(Buffer::Data(args[0])), Buffer::Length(args[0]), nullptr); CHECK_NE(num, nullptr); - set_field(dh->dh, num); + CHECK_EQ(1, set_field(dh->dh, num)); } void DiffieHellman::SetPublicKey(const FunctionCallbackInfo& args) { - SetKey(args, [](DH* dh, BIGNUM* num) { DH_set0_key(dh, num, nullptr); }, + SetKey(args, + [](DH* dh, BIGNUM* num) { return DH_set0_key(dh, num, nullptr); }, "Public key"); } @@ -5154,7 +5155,8 @@ void DiffieHellman::SetPrivateKey(const FunctionCallbackInfo& args) { // Node. See https://github.com/openssl/openssl/pull/4384. #error "OpenSSL 1.1.0 revisions before 1.1.0g are not supported" #endif - SetKey(args, [](DH* dh, BIGNUM* num) { DH_set0_key(dh, nullptr, num); }, + SetKey(args, + [](DH* dh, BIGNUM* num) { return DH_set0_key(dh, nullptr, num); }, "Private key"); } diff --git a/src/node_crypto.h b/src/node_crypto.h index 836144bf8be1a2..7d8c9032c65285 100644 --- a/src/node_crypto.h +++ b/src/node_crypto.h @@ -712,7 +712,7 @@ class DiffieHellman : public BaseObject { const BIGNUM* (*get_field)(const DH*), const char* err_if_null); static void SetKey(const v8::FunctionCallbackInfo& args, - void (*set_field)(DH*, BIGNUM*), const char* what); + int (*set_field)(DH*, BIGNUM*), const char* what); bool VerifyContext(); bool initialised_;