From acbd8220a7e5d758ed340ff59c6fdf5987b233e2 Mon Sep 17 00:00:00 2001 From: Darshan Sen Date: Thu, 25 Nov 2021 05:44:49 +0530 Subject: [PATCH] src,crypto: use `ByteSource::ToBuffer()` in `crypto_dh` MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Darshan Sen PR-URL: https://github.com/nodejs/node/pull/40903 Reviewed-By: Anna Henningsen Reviewed-By: Tobias Nießen --- src/crypto/crypto_dh.cc | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) diff --git a/src/crypto/crypto_dh.cc b/src/crypto/crypto_dh.cc index 72f6a114ddfbc2..8a2c559d783eda 100644 --- a/src/crypto/crypto_dh.cc +++ b/src/crypto/crypto_dh.cc @@ -13,7 +13,6 @@ namespace node { -using v8::ArrayBuffer; using v8::ConstructorBehavior; using v8::DontDelete; using v8::FunctionCallback; @@ -610,13 +609,8 @@ void DiffieHellman::Stateless(const FunctionCallbackInfo& args) { ManagedEVPPKey our_key = our_key_object->Data()->GetAsymmetricKey(); ManagedEVPPKey their_key = their_key_object->Data()->GetAsymmetricKey(); - Local out; - { - Local ab = StatelessDiffieHellmanThreadsafe(our_key, their_key) - .ToArrayBuffer(env); - out = Buffer::New(env, ab, 0, ab->ByteLength()) - .FromMaybe(Local()); - } + Local out = StatelessDiffieHellmanThreadsafe(our_key, their_key) + .ToBuffer(env).FromMaybe(Local()); if (Buffer::Length(out) == 0) return ThrowCryptoError(env, ERR_get_error(), "diffieHellman failed");