diff --git a/src/crypto/crypto_hash.cc b/src/crypto/crypto_hash.cc index 1a98b7b5b0c9ca..aaa3fee58c35b4 100644 --- a/src/crypto/crypto_hash.cc +++ b/src/crypto/crypto_hash.cc @@ -30,6 +30,7 @@ namespace node { using ncrypto::DataPointer; using ncrypto::EVPMDCtxPointer; using ncrypto::MarkPopErrorOnReturn; +using v8::ArrayBuffer; using v8::Context; using v8::FunctionCallbackInfo; using v8::FunctionTemplate; @@ -43,8 +44,11 @@ using v8::Maybe; using v8::MaybeLocal; using v8::Name; using v8::Nothing; +using v8::Null; using v8::Object; +using v8::String; using v8::Uint32; +using v8::Uint8Array; using v8::Value; namespace crypto { @@ -195,12 +199,12 @@ void Hash::GetCachedAliases(const FunctionCallbackInfo& args) { values.reserve(size); for (auto& [alias, id] : env->alias_to_md_id_map) { names.push_back(OneByteString(isolate, alias)); - values.push_back(v8::Uint32::New(isolate, id)); + values.push_back(Uint32::New(isolate, id)); } #else CHECK(env->alias_to_md_id_map.empty()); #endif - Local prototype = v8::Null(isolate); + Local prototype = Null(isolate); Local result = Object::New(isolate, prototype, names.data(), values.data(), size); args.GetReturnValue().Set(result); @@ -233,7 +237,7 @@ const EVP_MD* GetDigestImplementation(Environment* env, if (algorithm_cache.As() ->Set(isolate->GetCurrentContext(), algorithm, - v8::Int32::New(isolate, result.cache_id)) + Int32::New(isolate, result.cache_id)) .IsNothing()) { return nullptr; } @@ -333,11 +337,13 @@ void Hash::OneShotDigest(const FunctionCallbackInfo& args) { if (output_length == 0) { if (output_enc == BUFFER) { - Local ab = v8::ArrayBuffer::New(isolate, 0); - args.GetReturnValue().Set( - Buffer::New(isolate, ab, 0, 0).ToLocalChecked()); + Local u8; + if (Buffer::New(isolate, ArrayBuffer::New(isolate, 0), 0, 0) + .ToLocal(&u8)) { + args.GetReturnValue().Set(u8); + } } else { - args.GetReturnValue().Set(v8::String::Empty(isolate)); + args.GetReturnValue().Set(String::Empty(isolate)); } return; }