Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 5 additions & 6 deletions src/node_crypto.cc
Original file line number Diff line number Diff line change
Expand Up @@ -3150,8 +3150,7 @@ static ManagedEVPPKey GetPrivateKeyFromJs(

static ManagedEVPPKey GetPublicOrPrivateKeyFromJs(
const FunctionCallbackInfo<Value>& args,
unsigned int* offset,
bool allow_key_object) {
unsigned int* offset) {
if (args[*offset]->IsString() || Buffer::HasInstance(args[*offset])) {
Environment* env = Environment::GetCurrent(args);
ByteSource data = ByteSource::FromStringOrBuffer(env, args[(*offset)++]);
Expand Down Expand Up @@ -3199,7 +3198,7 @@ static ManagedEVPPKey GetPublicOrPrivateKeyFromJs(
ThrowCryptoError(env, ERR_get_error(), "Failed to read asymmetric key");
return ManagedEVPPKey(pkey.release());
} else {
CHECK(args[*offset]->IsObject() && allow_key_object);
CHECK(args[*offset]->IsObject());
KeyObject* key = Unwrap<KeyObject>(args[*offset].As<Object>());
CHECK(key);
CHECK_NE(key->GetKeyType(), kKeyTypeSecret);
Expand Down Expand Up @@ -3409,7 +3408,7 @@ void KeyObject::Init(const FunctionCallbackInfo<Value>& args) {
CHECK_EQ(args.Length(), 3);

offset = 0;
pkey = GetPublicOrPrivateKeyFromJs(args, &offset, true);
pkey = GetPublicOrPrivateKeyFromJs(args, &offset);
if (!pkey)
return;
key->InitPublic(pkey);
Expand Down Expand Up @@ -4676,7 +4675,7 @@ void Verify::VerifyFinal(const FunctionCallbackInfo<Value>& args) {
ASSIGN_OR_RETURN_UNWRAP(&verify, args.Holder());

unsigned int offset = 0;
ManagedEVPPKey pkey = GetPublicOrPrivateKeyFromJs(args, &offset, true);
ManagedEVPPKey pkey = GetPublicOrPrivateKeyFromJs(args, &offset);
if (!pkey)
return;

Expand Down Expand Up @@ -4739,7 +4738,7 @@ void PublicKeyCipher::Cipher(const FunctionCallbackInfo<Value>& args) {
Environment* env = Environment::GetCurrent(args);

unsigned int offset = 0;
ManagedEVPPKey pkey = GetPublicOrPrivateKeyFromJs(args, &offset, true);
ManagedEVPPKey pkey = GetPublicOrPrivateKeyFromJs(args, &offset);
if (!pkey)
return;

Expand Down