Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

crypto: remove DiffieHellman.initialised_ #23717

Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
23 changes: 3 additions & 20 deletions src/node_crypto.cc
Expand Up @@ -3991,11 +3991,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();
}


Expand All @@ -4010,11 +4006,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();
}


Expand All @@ -4027,11 +4019,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();
}


Expand Down Expand Up @@ -4105,7 +4093,6 @@ void DiffieHellman::GenerateKeys(const FunctionCallbackInfo<Value>& 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");
Expand All @@ -4127,7 +4114,6 @@ void DiffieHellman::GetField(const FunctionCallbackInfo<Value>& 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);
Expand Down Expand Up @@ -4179,7 +4165,6 @@ void DiffieHellman::ComputeSecret(const FunctionCallbackInfo<Value>& args) {

DiffieHellman* diffieHellman;
ASSIGN_OR_RETURN_UNWRAP(&diffieHellman, args.Holder());
CHECK(diffieHellman->initialised_);

ClearErrorOnReturn clear_error_on_return;

Expand Down Expand Up @@ -4247,7 +4232,6 @@ void DiffieHellman::SetKey(const v8::FunctionCallbackInfo<Value>& args,

DiffieHellman* dh;
ASSIGN_OR_RETURN_UNWRAP(&dh, args.Holder());
CHECK(dh->initialised_);

char errmsg[64];

Expand Down Expand Up @@ -4293,7 +4277,6 @@ void DiffieHellman::VerifyErrorGetter(const FunctionCallbackInfo<Value>& args) {

DiffieHellman* diffieHellman;
ASSIGN_OR_RETURN_UNWRAP(&diffieHellman, args.Holder());
CHECK(diffieHellman->initialised_);

args.GetReturnValue().Set(diffieHellman->verifyError_);
}
Expand Down
2 changes: 0 additions & 2 deletions src/node_crypto.h
Expand Up @@ -615,7 +615,6 @@ class DiffieHellman : public BaseObject {

DiffieHellman(Environment* env, v8::Local<v8::Object> wrap)
: BaseObject(env, wrap),
initialised_(false),
verifyError_(0) {
MakeWeak();
}
Expand All @@ -633,7 +632,6 @@ class DiffieHellman : public BaseObject {
int (*set_field)(DH*, BIGNUM*), const char* what);
bool VerifyContext();

bool initialised_;
int verifyError_;
DHPointer dh_;
};
Expand Down