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 <[email protected]>

PR-URL: #40903
Reviewed-By: Anna Henningsen <[email protected]>
Reviewed-By: Tobias Nießen <[email protected]>
  • Loading branch information
RaisinTen authored and targos committed Nov 26, 2021
1 parent 1555dbd commit acbd822
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 @@ -13,7 +13,6 @@

namespace node {

using v8::ArrayBuffer;
using v8::ConstructorBehavior;
using v8::DontDelete;
using v8::FunctionCallback;
Expand Down Expand Up @@ -610,13 +609,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 acbd822

Please sign in to comment.