crypto: declare int return type for set_field
This commit updates the set_field function pointer to return an int, and also updates the lambdas with a return statement. PR-URL: https://github.com/nodejs/node/pull/17468 Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
This commit is contained in:
parent
09e9e2bd82
commit
abc280172f
@ -5084,7 +5084,7 @@ void DiffieHellman::ComputeSecret(const FunctionCallbackInfo<Value>& args) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void DiffieHellman::SetKey(const v8::FunctionCallbackInfo<v8::Value>& args,
|
void DiffieHellman::SetKey(const v8::FunctionCallbackInfo<v8::Value>& args,
|
||||||
void (*set_field)(DH*, BIGNUM*), const char* what) {
|
int (*set_field)(DH*, BIGNUM*), const char* what) {
|
||||||
Environment* env = Environment::GetCurrent(args);
|
Environment* env = Environment::GetCurrent(args);
|
||||||
|
|
||||||
DiffieHellman* dh;
|
DiffieHellman* dh;
|
||||||
@ -5107,12 +5107,13 @@ void DiffieHellman::SetKey(const v8::FunctionCallbackInfo<v8::Value>& args,
|
|||||||
BN_bin2bn(reinterpret_cast<unsigned char*>(Buffer::Data(args[0])),
|
BN_bin2bn(reinterpret_cast<unsigned char*>(Buffer::Data(args[0])),
|
||||||
Buffer::Length(args[0]), nullptr);
|
Buffer::Length(args[0]), nullptr);
|
||||||
CHECK_NE(num, nullptr);
|
CHECK_NE(num, nullptr);
|
||||||
set_field(dh->dh, num);
|
CHECK_EQ(1, set_field(dh->dh, num));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void DiffieHellman::SetPublicKey(const FunctionCallbackInfo<Value>& args) {
|
void DiffieHellman::SetPublicKey(const FunctionCallbackInfo<Value>& 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");
|
"Public key");
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -5123,7 +5124,8 @@ void DiffieHellman::SetPrivateKey(const FunctionCallbackInfo<Value>& args) {
|
|||||||
// Node. See https://github.com/openssl/openssl/pull/4384.
|
// Node. See https://github.com/openssl/openssl/pull/4384.
|
||||||
#error "OpenSSL 1.1.0 revisions before 1.1.0g are not supported"
|
#error "OpenSSL 1.1.0 revisions before 1.1.0g are not supported"
|
||||||
#endif
|
#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");
|
"Private key");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -712,7 +712,7 @@ class DiffieHellman : public BaseObject {
|
|||||||
const BIGNUM* (*get_field)(const DH*),
|
const BIGNUM* (*get_field)(const DH*),
|
||||||
const char* err_if_null);
|
const char* err_if_null);
|
||||||
static void SetKey(const v8::FunctionCallbackInfo<v8::Value>& args,
|
static void SetKey(const v8::FunctionCallbackInfo<v8::Value>& args,
|
||||||
void (*set_field)(DH*, BIGNUM*), const char* what);
|
int (*set_field)(DH*, BIGNUM*), const char* what);
|
||||||
bool VerifyContext();
|
bool VerifyContext();
|
||||||
|
|
||||||
bool initialised_;
|
bool initialised_;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user