Skip to content
This repository was archived by the owner on Mar 4, 2020. It is now read-only.

Commit 70a78f0

Browse files
committed
fix: BN_bn2bin_padded returns 1 on success instead of size
fixup! fix: update with BORINGSSL api for node_crypto.cc
1 parent 7294f84 commit 70a78f0

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

src/node_crypto.cc

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4221,7 +4221,7 @@ void DiffieHellman::GenerateKeys(const FunctionCallbackInfo<Value>& args) {
42214221
auto* allocator = env->isolate()->GetArrayBufferAllocator();
42224222
char* data = static_cast<char*>(allocator->AllocateUninitialized(size));
42234223
CHECK_EQ(
4224-
size,
4224+
1,
42254225
BN_bn2bin_padded(reinterpret_cast<unsigned char*>(data), size, pub_key));
42264226
args.GetReturnValue().Set(Buffer::New(env, data, size).ToLocalChecked());
42274227
}
@@ -4242,7 +4242,7 @@ void DiffieHellman::GetField(const FunctionCallbackInfo<Value>& args,
42424242
CHECK_GE(size, 0);
42434243
auto* allocator = env->isolate()->GetArrayBufferAllocator();
42444244
char* data = static_cast<char*>(allocator->AllocateUninitialized(size));
4245-
CHECK_EQ(size,
4245+
CHECK_EQ(1,
42464246
BN_bn2bin_padded(reinterpret_cast<unsigned char*>(data), size, num));
42474247
args.GetReturnValue().Set(Buffer::New(env, data, size).ToLocalChecked());
42484248
}
@@ -4588,7 +4588,7 @@ void ECDH::GetPrivateKey(const FunctionCallbackInfo<Value>& args) {
45884588
unsigned char* out =
45894589
static_cast<unsigned char*>(allocator->AllocateUninitialized(size));
45904590

4591-
if (size != BN_bn2bin_padded(out, size, b)) {
4591+
if (!BN_bn2bin_padded(out, size, b)) {
45924592
allocator->Free(out, size);
45934593
return env->ThrowError("Failed to convert ECDH private key to Buffer");
45944594
}

0 commit comments

Comments
 (0)