@@ -26,10 +26,10 @@ index 9cbe99596b1b8c148ac076acf8a9623d6989d505..93d85d46dc6b3b30795b88ffa8070253
2626 void* ret;
2727 if (zero_fill_field_ || per_process::cli_options->zero_fill_all_buffers)
2828diff --git a/src/crypto/crypto_util.cc b/src/crypto/crypto_util.cc
29- index 840fe824617b951d4f4421155c5e1ce79c28525e..b1ae378993723d7a0a71bfe36fc5be94a899082a 100644
29+ index 51973d7cb15f0650f3e94a7b8c9811c550ee9b0f..1ab08092e8b8ad8a989eaa18f8e573b5948d295f 100644
3030--- a/src/crypto/crypto_util.cc
3131+++ b/src/crypto/crypto_util.cc
32- @@ -332 ,10 +332 ,35 @@ ByteSource& ByteSource::operator=(ByteSource&& other) noexcept {
32+ @@ -326 ,10 +326 ,35 @@ ByteSource& ByteSource::operator=(ByteSource&& other) noexcept {
3333 return *this;
3434 }
3535
@@ -66,7 +66,7 @@ index 840fe824617b951d4f4421155c5e1ce79c28525e..b1ae378993723d7a0a71bfe36fc5be94
6666 std::unique_ptr<BackingStore> ptr = ArrayBuffer::NewBackingStore(
6767 allocated_data_,
6868 size(),
69- @@ -347 ,10 +372 ,11 @@ std::unique_ptr<BackingStore> ByteSource::ReleaseToBackingStore() {
69+ @@ -341 ,10 +366 ,11 @@ std::unique_ptr<BackingStore> ByteSource::ReleaseToBackingStore() {
7070 data_ = nullptr;
7171 size_ = 0;
7272 return ptr;
@@ -79,10 +79,10 @@ index 840fe824617b951d4f4421155c5e1ce79c28525e..b1ae378993723d7a0a71bfe36fc5be94
7979 return ArrayBuffer::New(env->isolate(), std::move(store));
8080 }
8181
82- @@ -680 ,6 +706 ,16 @@ CryptoJobMode GetCryptoJobMode(v8::Local<v8::Value> args) {
83- }
84-
85- namespace {
82+ @@ -658 ,6 +684 ,16 @@ namespace {
83+ // in which case this has the same semantics as
84+ // using OPENSSL_malloc. However, if the secure heap is
85+ // initialized, SecureBuffer will automatically use it.
8686+ #if defined(V8_ENABLE_SANDBOX)
8787+ // When V8 sandboxed pointers are enabled, the secure heap cannot be used as
8888+ // all ArrayBuffers must be allocated inside the V8 memory cage.
@@ -93,17 +93,18 @@ index 840fe824617b951d4f4421155c5e1ce79c28525e..b1ae378993723d7a0a71bfe36fc5be94
9393+ args.GetReturnValue().Set(Uint8Array::New(buffer, 0, len));
9494+ }
9595+ #else
96- // SecureBuffer uses openssl to allocate a Uint8Array using
97- // OPENSSL_secure_malloc. Because we do not yet actually
98- // make use of secure heap, this has the same semantics as
99- @@ -707 ,6 +743 ,7 @@ void SecureBuffer(const FunctionCallbackInfo<Value>& args) {
96+ void SecureBuffer(const FunctionCallbackInfo<Value>& args) {
97+ CHECK(args[0]->IsUint32());
98+ Environment* env = Environment::GetCurrent(args);
99+ @@ -679 ,6 +715 ,7 @@ void SecureBuffer(const FunctionCallbackInfo<Value>& args) {
100100 Local<ArrayBuffer> buffer = ArrayBuffer::New(env->isolate(), store);
101101 args.GetReturnValue().Set(Uint8Array::New(buffer, 0, len));
102102 }
103103+ #endif // defined(V8_ENABLE_SANDBOX)
104104
105105 void SecureHeapUsed(const FunctionCallbackInfo<Value>& args) {
106106 #ifndef OPENSSL_IS_BORINGSSL
107+
107108diff --git a/src/crypto/crypto_util.h b/src/crypto/crypto_util.h
108109index f26422ee106ab7a816750ee717cb18ea454b5b62..5e5798e7e55dbb2df93ef4a8ab6f40aeb85616b4 100644
109110--- a/src/crypto/crypto_util.h
0 commit comments