Skip to content

Commit

Permalink
src,crypto: use ByteSource::ToBuffer() in crypto_dh
Browse files Browse the repository at this point in the history
Signed-off-by: Darshan Sen <darshan.sen@postman.com>

PR-URL: #40903
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Tobias Nießen <tniessen@tnie.de>
  • Loading branch information
RaisinTen authored and danielleadams committed Feb 1, 2022
1 parent 370bfda commit 807536c
Showing 1 changed file with 2 additions and 8 deletions.
10 changes: 2 additions & 8 deletions src/crypto/crypto_dh.cc
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@

namespace node {

using v8::ArrayBuffer;
using v8::ConstructorBehavior;
using v8::DontDelete;
using v8::FunctionCallback;
Expand Down Expand Up @@ -604,13 +603,8 @@ void DiffieHellman::Stateless(const FunctionCallbackInfo<Value>& args) {
ManagedEVPPKey our_key = our_key_object->Data()->GetAsymmetricKey();
ManagedEVPPKey their_key = their_key_object->Data()->GetAsymmetricKey();

Local<Value> out;
{
Local<ArrayBuffer> ab = StatelessDiffieHellmanThreadsafe(our_key, their_key)
.ToArrayBuffer(env);
out = Buffer::New(env, ab, 0, ab->ByteLength())
.FromMaybe(Local<Uint8Array>());
}
Local<Value> out = StatelessDiffieHellmanThreadsafe(our_key, their_key)
.ToBuffer(env).FromMaybe(Local<Uint8Array>());

if (Buffer::Length(out) == 0)
return ThrowCryptoError(env, ERR_get_error(), "diffieHellman failed");
Expand Down

0 comments on commit 807536c

Please sign in to comment.