Skip to content

Commit 807536c

Browse files
RaisinTendanielleadams
authored andcommitted
src,crypto: use ByteSource::ToBuffer() in crypto_dh
Signed-off-by: Darshan Sen <[email protected]> PR-URL: #40903 Reviewed-By: Anna Henningsen <[email protected]> Reviewed-By: Tobias Nießen <[email protected]>
1 parent 370bfda commit 807536c

File tree

1 file changed

+2
-8
lines changed

1 file changed

+2
-8
lines changed

src/crypto/crypto_dh.cc

+2-8
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@
1111

1212
namespace node {
1313

14-
using v8::ArrayBuffer;
1514
using v8::ConstructorBehavior;
1615
using v8::DontDelete;
1716
using v8::FunctionCallback;
@@ -604,13 +603,8 @@ void DiffieHellman::Stateless(const FunctionCallbackInfo<Value>& args) {
604603
ManagedEVPPKey our_key = our_key_object->Data()->GetAsymmetricKey();
605604
ManagedEVPPKey their_key = their_key_object->Data()->GetAsymmetricKey();
606605

607-
Local<Value> out;
608-
{
609-
Local<ArrayBuffer> ab = StatelessDiffieHellmanThreadsafe(our_key, their_key)
610-
.ToArrayBuffer(env);
611-
out = Buffer::New(env, ab, 0, ab->ByteLength())
612-
.FromMaybe(Local<Uint8Array>());
613-
}
606+
Local<Value> out = StatelessDiffieHellmanThreadsafe(our_key, their_key)
607+
.ToBuffer(env).FromMaybe(Local<Uint8Array>());
614608

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

0 commit comments

Comments
 (0)