Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/nodejs/node.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorDarshan Sen <raisinten@gmail.com>2022-05-04 23:33:09 +0300
committerRafaelGSS <rafael.nunu@hotmail.com>2022-05-10 15:13:17 +0300
commit8cfc18e4dba5b3a97f37f8c3be4d720e98100ada (patch)
treeb18e09bb5a9d2e96cf775f5234ac90d7ca415b3c /src
parent19c060fd84c1285ea483779a67cd391d7ae8d29b (diff)
src,crypto: remove uses of AllocatedBuffer from crypto_rsa.cc
Refs: https://github.com/nodejs/node/pull/39941 Signed-off-by: Darshan Sen <raisinten@gmail.com> PR-URL: https://github.com/nodejs/node/pull/42852 Reviewed-By: Anna Henningsen <anna@addaleax.net>
Diffstat (limited to 'src')
-rw-r--r--src/crypto/crypto_rsa.cc24
1 files changed, 15 insertions, 9 deletions
diff --git a/src/crypto/crypto_rsa.cc b/src/crypto/crypto_rsa.cc
index ae4550e9fde..62d54db8a3d 100644
--- a/src/crypto/crypto_rsa.cc
+++ b/src/crypto/crypto_rsa.cc
@@ -15,6 +15,8 @@
namespace node {
+using v8::ArrayBuffer;
+using v8::BackingStore;
using v8::FunctionCallbackInfo;
using v8::Int32;
using v8::Just;
@@ -555,17 +557,21 @@ Maybe<bool> GetRsaKeyDetail(
return Nothing<bool>();
}
- int len = BN_num_bytes(e);
- AllocatedBuffer public_exponent = AllocatedBuffer::AllocateManaged(env, len);
- unsigned char* data =
- reinterpret_cast<unsigned char*>(public_exponent.data());
- CHECK_EQ(BN_bn2binpad(e, data, len), len);
+ std::unique_ptr<BackingStore> public_exponent;
+ {
+ NoArrayBufferZeroFillScope no_zero_fill_scope(env->isolate_data());
+ public_exponent =
+ ArrayBuffer::NewBackingStore(env->isolate(), BN_num_bytes(e));
+ }
+ CHECK_EQ(BN_bn2binpad(e,
+ static_cast<unsigned char*>(public_exponent->Data()),
+ public_exponent->ByteLength()),
+ static_cast<int>(public_exponent->ByteLength()));
if (target
- ->Set(
- env->context(),
- env->public_exponent_string(),
- public_exponent.ToArrayBuffer())
+ ->Set(env->context(),
+ env->public_exponent_string(),
+ ArrayBuffer::New(env->isolate(), std::move(public_exponent)))
.IsNothing()) {
return Nothing<bool>();
}