diff --git a/src/node_crypto.cc b/src/node_crypto.cc index 490ec0df28936a..421db555d21973 100644 --- a/src/node_crypto.cc +++ b/src/node_crypto.cc @@ -3974,11 +3974,7 @@ bool DiffieHellman::Init(int primeLength, int g) { dh_.reset(DH_new()); if (!DH_generate_parameters_ex(dh_.get(), primeLength, g, 0)) return false; - bool result = VerifyContext(); - if (!result) - return false; - initialised_ = true; - return true; + return VerifyContext(); } @@ -3993,11 +3989,7 @@ bool DiffieHellman::Init(const char* p, int p_len, int g) { BN_free(bn_g); return false; } - bool result = VerifyContext(); - if (!result) - return false; - initialised_ = true; - return true; + return VerifyContext(); } @@ -4010,11 +4002,7 @@ bool DiffieHellman::Init(const char* p, int p_len, const char* g, int g_len) { BN_free(bn_g); return false; } - bool result = VerifyContext(); - if (!result) - return false; - initialised_ = true; - return true; + return VerifyContext(); } @@ -4088,7 +4076,6 @@ void DiffieHellman::GenerateKeys(const FunctionCallbackInfo& args) { DiffieHellman* diffieHellman; ASSIGN_OR_RETURN_UNWRAP(&diffieHellman, args.Holder()); - CHECK(diffieHellman->initialised_); if (!DH_generate_key(diffieHellman->dh_.get())) { return ThrowCryptoError(env, ERR_get_error(), "Key generation failed"); @@ -4110,7 +4097,6 @@ void DiffieHellman::GetField(const FunctionCallbackInfo& args, DiffieHellman* dh; ASSIGN_OR_RETURN_UNWRAP(&dh, args.Holder()); - CHECK(dh->initialised_); const BIGNUM* num = get_field(dh->dh_.get()); if (num == nullptr) return env->ThrowError(err_if_null); @@ -4162,7 +4148,6 @@ void DiffieHellman::ComputeSecret(const FunctionCallbackInfo& args) { DiffieHellman* diffieHellman; ASSIGN_OR_RETURN_UNWRAP(&diffieHellman, args.Holder()); - CHECK(diffieHellman->initialised_); ClearErrorOnReturn clear_error_on_return; @@ -4230,7 +4215,6 @@ void DiffieHellman::SetKey(const v8::FunctionCallbackInfo& args, DiffieHellman* dh; ASSIGN_OR_RETURN_UNWRAP(&dh, args.Holder()); - CHECK(dh->initialised_); char errmsg[64]; @@ -4276,7 +4260,6 @@ void DiffieHellman::VerifyErrorGetter(const FunctionCallbackInfo& args) { DiffieHellman* diffieHellman; ASSIGN_OR_RETURN_UNWRAP(&diffieHellman, args.Holder()); - CHECK(diffieHellman->initialised_); args.GetReturnValue().Set(diffieHellman->verifyError_); } diff --git a/src/node_crypto.h b/src/node_crypto.h index 9603fcf3b2edb4..6fcf737f6c43c3 100644 --- a/src/node_crypto.h +++ b/src/node_crypto.h @@ -614,7 +614,6 @@ class DiffieHellman : public BaseObject { DiffieHellman(Environment* env, v8::Local wrap) : BaseObject(env, wrap), - initialised_(false), verifyError_(0) { MakeWeak(); } @@ -632,7 +631,6 @@ class DiffieHellman : public BaseObject { int (*set_field)(DH*, BIGNUM*), const char* what); bool VerifyContext(); - bool initialised_; int verifyError_; DHPointer dh_; };