Skip to content

Commit acbd822

Browse files
RaisinTentargos
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 1555dbd commit acbd822

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
@@ -13,7 +13,6 @@
1313

1414
namespace node {
1515

16-
using v8::ArrayBuffer;
1716
using v8::ConstructorBehavior;
1817
using v8::DontDelete;
1918
using v8::FunctionCallback;
@@ -610,13 +609,8 @@ void DiffieHellman::Stateless(const FunctionCallbackInfo<Value>& args) {
610609
ManagedEVPPKey our_key = our_key_object->Data()->GetAsymmetricKey();
611610
ManagedEVPPKey their_key = their_key_object->Data()->GetAsymmetricKey();
612611

613-
Local<Value> out;
614-
{
615-
Local<ArrayBuffer> ab = StatelessDiffieHellmanThreadsafe(our_key, their_key)
616-
.ToArrayBuffer(env);
617-
out = Buffer::New(env, ab, 0, ab->ByteLength())
618-
.FromMaybe(Local<Uint8Array>());
619-
}
612+
Local<Value> out = StatelessDiffieHellmanThreadsafe(our_key, their_key)
613+
.ToBuffer(env).FromMaybe(Local<Uint8Array>());
620614

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

0 commit comments

Comments
 (0)