chore: bump node to v12.12.0 (master) (#20584)

Co-authored-by: Shelley Vohr <shelley.vohr@gmail.com>
This commit is contained in:
Electron Bot 2019-10-18 19:52:15 -04:00 committed by Shelley Vohr
parent 9f23bb581e
commit 43fa9166c9
16 changed files with 465 additions and 126 deletions

2
DEPS
View file

@ -13,7 +13,7 @@ vars = {
'chromium_version':
'c3a0220e7bde049d599a8332b9b2785b0178be74',
'node_version':
'v12.10.0',
'v12.12.0',
'nan_version':
'2ee313aaca52e2b478965ac50eb5082520380d1b',

View file

@ -25,7 +25,7 @@ fix_do_not_define_debugoptions_s_constructors_in_header.patch
src_disable_node_use_v8_platform_in_node_options.patch
build_modify_js2c_py_to_allow_injection_of_original-fs_and_custom_embedder_js.patch
refactor_allow_embedder_overriding_of_internal_fs_calls.patch
chore_add_ability_to_prevent_warn_non_context-aware_native_modules.patch
chore_prevent_warn_non_context-aware_native_modules_being_loaded.patch
chore_allow_the_node_entrypoint_to_be_a_builtin_module.patch
inherit_electron_crashpad_pipe_name_in_child_process.patch
fixme_revert_crypto_add_support_for_rsa-pss_keys.patch
@ -35,8 +35,12 @@ chore_read_nobrowserglobals_from_global_not_process.patch
chore_split_createenvironment_into_createenvironment_and.patch
chore_handle_default_configuration_not_being_set_in_the_electron_env.patch
revert_crypto_add_outputlength_option_to_crypto_createhash.patch
fix_microtasks.patch
fsevents-stop-using-fsevents-to-watch-files.patch
fsevents-regression-in-watching.patch
fix_enable_worker_threads.patch
build_bring_back_node_with_ltcg_configuration.patch
revert_tls_add_option_to_override_signature_algorithms.patch
revert_crypto_fix_openssl_return_code_handling.patch
revert_crypto_add_oaeplabel_option.patch
fix_windows_compilation_on_libuv_setsockopt.patch
fix_don_t_use_node-controlled_preparestacktrace.patch
fix_remove_uses_of_node_use_v8_platform.patch

View file

@ -882,10 +882,10 @@ index 0000000000000000000000000000000000000000..f13b471d17128468bed06e66bd03a2ea
+}
diff --git a/filenames.json b/filenames.json
new file mode 100644
index 0000000000000000000000000000000000000000..be8613d11f9f5b1c6604257edf707792f2119fcb
index 0000000000000000000000000000000000000000..bfe6555be5239c6d9cad59e8b845638d50f31ee3
--- /dev/null
+++ b/filenames.json
@@ -0,0 +1,443 @@
@@ -0,0 +1,447 @@
+// This file is automatically generated by generate_gn_filenames_json.py
+// DO NOT EDIT
+{
@ -960,7 +960,6 @@ index 0000000000000000000000000000000000000000..be8613d11f9f5b1c6604257edf707792
+ "lib/internal/bootstrap/node.js",
+ "lib/internal/bootstrap/pre_execution.js",
+ "lib/internal/per_context/primordials.js",
+ "lib/internal/per_context/setup.js",
+ "lib/internal/per_context/domexception.js",
+ "lib/async_hooks.js",
+ "lib/assert.js",
@ -1052,6 +1051,7 @@ index 0000000000000000000000000000000000000000..be8613d11f9f5b1c6604257edf707792
+ "lib/internal/fixed_queue.js",
+ "lib/internal/freelist.js",
+ "lib/internal/freeze_intrinsics.js",
+ "lib/internal/fs/dir.js",
+ "lib/internal/fs/promises.js",
+ "lib/internal/fs/read_file_context.js",
+ "lib/internal/fs/rimraf.js",
@ -1106,6 +1106,8 @@ index 0000000000000000000000000000000000000000..be8613d11f9f5b1c6604257edf707792
+ "lib/internal/repl/history.js",
+ "lib/internal/repl/utils.js",
+ "lib/internal/socket_list.js",
+ "lib/internal/source_map/source_map.js",
+ "lib/internal/source_map/source_map_cache.js",
+ "lib/internal/test/binding.js",
+ "lib/internal/timers.js",
+ "lib/internal/tls.js",
@ -1191,6 +1193,7 @@ index 0000000000000000000000000000000000000000..be8613d11f9f5b1c6604257edf707792
+ "src/node_constants.cc",
+ "src/node_contextify.cc",
+ "src/node_credentials.cc",
+ "src/node_dir.cc",
+ "src/node_domain.cc",
+ "src/node_env_var.cc",
+ "src/node_errors.cc",
@ -1272,6 +1275,7 @@ index 0000000000000000000000000000000000000000..be8613d11f9f5b1c6604257edf707792
+ "src/node_constants.h",
+ "src/node_context_data.h",
+ "src/node_contextify.h",
+ "src/node_dir.h",
+ "src/node_errors.h",
+ "src/node_file.h",
+ "src/node_http_parser_impl.h",
@ -1535,7 +1539,7 @@ index 0000000000000000000000000000000000000000..f3c5c798c0aefcb8cf9b1570a7b4817c
+ args = rebase_path(inputs + outputs, root_build_dir)
+}
diff --git a/src/node_version.h b/src/node_version.h
index 2d105483ba10533d992de3265121e6ab9edce2ed..8a8fd5f7fad4a69b65e06d67225a398385d3bbbf 100644
index a61a186edd3c92d6f0bd760a9990b5c8ed57e6fa..e4963fdfd9b93a6f50a4f1035f63e95432dd8d8e 100644
--- a/src/node_version.h
+++ b/src/node_version.h
@@ -89,7 +89,10 @@
@ -1667,10 +1671,10 @@ index 0000000000000000000000000000000000000000..3088ae4bdf814ae255c9805ebd393b2e
+
+ out_file.writelines(new_contents)
diff --git a/tools/js2c.py b/tools/js2c.py
index 0189dd762919162c8a897d291bdda3cfd600eab6..7b3e90af88b873c32f8ed51712f7dfdff3c1c706 100755
index 1346b2a87046d3472577875c887b3b44a63280ed..752344d68c3f63b4c5e491b33d4576ed48f8b74f 100755
--- a/tools/js2c.py
+++ b/tools/js2c.py
@@ -261,9 +261,17 @@ def NormalizeFileName(filename):
@@ -261,10 +261,18 @@ def NormalizeFileName(filename):
split = ['internal'] + split
else: # `lib/**/*.js` so drop the 'lib' part
split = split[1:]
@ -1678,14 +1682,14 @@ index 0189dd762919162c8a897d291bdda3cfd600eab6..7b3e90af88b873c32f8ed51712f7dfdf
if len(split):
filename = '/'.join(split)
- return os.path.splitext(filename)[0]
+
+ # Electron-specific: when driving the node build from Electron, we generate
+ # config.gypi in a separate directory and pass the absolute path to js2c.
+ # This overrides the absolute path so that the variable names in the
+ # generated C are as if it was in the root node directory.
+ if filename.endswith("/config.gypi"):
+ filename = "config.gypi"
+
+ return os.path.splitext(filename)[0]
def JS2C(source_files, target):

View file

@ -1,8 +1,11 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Samuel Attard <sattard@slack-corp.com>
Date: Wed, 22 May 2019 13:34:18 -0700
Subject: chore: add ability to prevent / warn non context-aware native modules
being loaded
Subject: chore: prevent / warn non context-aware native modules being loaded
This should be updated to take advantage of https://github.com/nodejs/node/pull/29631
once we stop warning and begin to unilaterally prevent non-context aware modules
from being loaded.
diff --git a/src/env.h b/src/env.h
index 2dd6bdb75f02e2ccb07129996d16df99c0c4ccf2..ecb845803776f5ff6e7eec712ec7a5ebea2e8d0a 100644
@ -46,17 +49,19 @@ index c51a892e1bcd3df6ea8af952c8200975c7f4ac7e..9a4a7780f4ac1bcc0855cc9e3eed904d
#include "util.h"
#if HAVE_OPENSSL
@@ -463,6 +464,13 @@ void DLOpen(const FunctionCallbackInfo<Value>& args) {
}
@@ -466,10 +466,12 @@ void DLOpen(const FunctionCallbackInfo<Value>& args) {
if (mp != nullptr) {
+ if (mp->nm_context_register_func == nullptr) {
if (mp->nm_context_register_func == nullptr) {
- if (env->options()->force_context_aware) {
+ if (env->force_context_aware()) {
dlib->Close();
- THROW_ERR_NON_CONTEXT_AWARE_DISABLED(env);
+ env->ThrowError("Loading non context-aware native modules has been disabled in this process. This means you have loaded a non context-aware native module with app.allowRendererProcessReuse set to true. See https://github.com/electron/electron/issues/18397 for more information");
return false;
+ } else if (env->warn_non_context_aware()) {
+ ProcessEmitWarningGeneric(env, "Loading non context-aware native modules in the renderer process is deprecated and will stop working at some point in the future, please see https://github.com/electron/electron/issues/18397 for more information", "Electron");
+ }
+ }
}
}
mp->nm_dso_handle = dlib->handle_;
dlib->SaveInGlobalHandleMap(mp);
} else {

View file

@ -0,0 +1,32 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Shelley Vohr <shelley.vohr@gmail.com>
Date: Thu, 17 Oct 2019 15:15:12 -0700
Subject: fix: don't use node-controlled prepareStackTrace
At the moment, Electron uses the v8 version of Error.prepareStackTrace as
defined in v7.9.74 (where https://crbug.com/v8/7848 has been fixed) and
not the one polyfilled by Node.js. As a result, we were experiencing failures
in parallel/test-buffer-constructor-outside-node-modules.js because
the polyfilled prepareStackTrace was not being run and thus code
inside that function would never be executed.
Upstreamed at https://github.com/nodejs/node/pull/30014.
diff --git a/lib/internal/util.js b/lib/internal/util.js
index 58502f3b7a7a937c896ff6d32a90a45c6912e3b3..e91362cc3a8a6c5d2462a017f177bebfd607a850 100644
--- a/lib/internal/util.js
+++ b/lib/internal/util.js
@@ -340,10 +340,10 @@ function isInsideNodeModules() {
// the perf implications should be okay.
getStructuredStack = runInNewContext(`(function() {
Error.stackTraceLimit = Infinity;
+ Error.prepareStackTrace = (err, trace) => trace;
+
return function structuredStack() {
- const e = new Error();
- overrideStackTrace.set(e, (err, trace) => trace);
- return e.stack;
+ return new Error().stack;
};
})()`, { overrideStackTrace }, { filename: 'structured-stack' });
}

View file

@ -1,29 +0,0 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Shelley Vohr <shelley.vohr@gmail.com>
Date: Thu, 3 Oct 2019 19:03:30 +0200
Subject: fix: enable worker_threads
Electron sets NODE_USE_V8_PLATFORM to false, because Electron
initializes the v8 platform itself and Node.js worker thread
initialization relies on the platform it uses having been set inside
code guarded by NODE_USE_V8_PLATFORM.
This commit fixes this problem by changing node_worker to use the three-arg
implementation of `NewIsolate` to prevent it trying to use a possibly-null ptr.
diff --git a/src/node_worker.cc b/src/node_worker.cc
index 11e44a92757e41e737087c5d08ce9931f0b0fab3..3dce5e25980ce2c6f17cda02dab9c0f8b4fab813 100644
--- a/src/node_worker.cc
+++ b/src/node_worker.cc
@@ -116,7 +116,10 @@ class WorkerThreadData {
: w_(w) {
CHECK_EQ(uv_loop_init(&loop_), 0);
- Isolate* isolate = NewIsolate(w->array_buffer_allocator_.get(), &loop_);
+ Isolate* isolate = NewIsolate(
+ w->array_buffer_allocator_.get(),
+ &loop_,
+ w->platform_);
CHECK_NOT_NULL(isolate);
{

View file

@ -1,58 +0,0 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Jeremy Apthorp <nornagon@nornagon.net>
Date: Mon, 16 Sep 2019 17:50:28 -0400
Subject: fix microtasks
backports https://github.com/nodejs/node/pull/29581 and https://github.com/nodejs/node/pull/29434
diff --git a/src/api/callback.cc b/src/api/callback.cc
index 43ccfafd9f2c85e23a9ea6277e88e4864e287905..3c518870c9c8d92f3dfcd6c270f5e023e3b69633 100644
--- a/src/api/callback.cc
+++ b/src/api/callback.cc
@@ -12,6 +12,7 @@ using v8::HandleScope;
using v8::Isolate;
using v8::Local;
using v8::MaybeLocal;
+using v8::MicrotasksScope;
using v8::NewStringType;
using v8::Object;
using v8::String;
@@ -100,7 +101,7 @@ void InternalCallbackScope::Close() {
if (!env_->can_call_into_js()) return;
if (!tick_info->has_tick_scheduled()) {
- env_->isolate()->RunMicrotasks();
+ MicrotasksScope::PerformCheckpoint(env_->isolate());
}
#if 0 // FIXME(codebytere): figure out why this check fails/causes crash
diff --git a/src/node_task_queue.cc b/src/node_task_queue.cc
index e6b4d0b8e211cdb1fef4759457c2550e28448360..918796ba77d80cf66324164a930f8068e0622ccb 100644
--- a/src/node_task_queue.cc
+++ b/src/node_task_queue.cc
@@ -21,6 +21,7 @@ using v8::kPromiseRejectWithNoHandler;
using v8::kPromiseResolveAfterResolved;
using v8::Local;
using v8::Message;
+using v8::MicrotasksScope;
using v8::Number;
using v8::Object;
using v8::Promise;
@@ -43,7 +44,7 @@ static void EnqueueMicrotask(const FunctionCallbackInfo<Value>& args) {
bool RunNextTicksNative(Environment* env) {
TickInfo* tick_info = env->tick_info();
if (!tick_info->has_tick_scheduled() && !tick_info->has_rejection_to_warn())
- env->isolate()->RunMicrotasks();
+ MicrotasksScope::PerformCheckpoint(env->isolate());
if (!tick_info->has_tick_scheduled() && !tick_info->has_rejection_to_warn())
return true;
@@ -54,7 +55,7 @@ bool RunNextTicksNative(Environment* env) {
}
static void RunMicrotasks(const FunctionCallbackInfo<Value>& args) {
- args.GetIsolate()->RunMicrotasks();
+ MicrotasksScope::PerformCheckpoint(args.GetIsolate());
}
static void SetTickCallback(const FunctionCallbackInfo<Value>& args) {

View file

@ -0,0 +1,131 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Shelley Vohr <shelley.vohr@gmail.com>
Date: Fri, 18 Oct 2019 11:20:16 -0700
Subject: fix: remove uses of NODE_USE_V8_PLATFORM
Electron makes use of HAVE_INSPECTOR but does not run with
NODE_USE_V8_PLATFORM so this prevented some Inspector code from
running properly on our end; specifically, this caused a crash in
test/parallel/test-inspector-connect-main-thread.js.
Upstreamed at https://github.com/nodejs/node/pull/30029.
diff --git a/src/env.h b/src/env.h
index 5b8465c8ba5335c8706b54dcf6e4ed46af31bcf0..d83fc3ab8d997e8044c5ee5ef12dcba3c44bb1a1 100644
--- a/src/env.h
+++ b/src/env.h
@@ -868,7 +868,7 @@ class Environment : public MemoryRetainer {
void CreateProperties();
// Should be called before InitializeInspector()
void InitializeDiagnostics();
-#if HAVE_INSPECTOR && NODE_USE_V8_PLATFORM
+#if HAVE_INSPECTOR
// If the environment is created for a worker, pass parent_handle and
// the ownership if transferred into the Environment.
int InitializeInspector(inspector::ParentInspectorHandle* parent_handle);
diff --git a/src/node.cc b/src/node.cc
index 9b43d7676e5e106318b58bfe443651cc49780068..461f736beacec67b35c89a42319f99178a1e38e9 100644
--- a/src/node.cc
+++ b/src/node.cc
@@ -224,7 +224,7 @@ MaybeLocal<Value> ExecuteBootstrapper(Environment* env,
return scope.EscapeMaybe(result);
}
-#if HAVE_INSPECTOR && NODE_USE_V8_PLATFORM
+#if HAVE_INSPECTOR
int Environment::InitializeInspector(
inspector::ParentInspectorHandle* parent_handle) {
std::string inspector_path;
@@ -258,7 +258,7 @@ int Environment::InitializeInspector(
return 0;
}
-#endif // HAVE_INSPECTOR && NODE_USE_V8_PLATFORM
+#endif // HAVE_INSPECTOR
void Environment::InitializeDiagnostics() {
isolate_->GetHeapProfiler()->AddBuildEmbedderGraphCallback(
diff --git a/src/node_main_instance.cc b/src/node_main_instance.cc
index e41e0c1fb6fe1f2ca8a8ebef8834a53d1875ac15..be53b585f0a106c6fd5675e805284291d295f205 100644
--- a/src/node_main_instance.cc
+++ b/src/node_main_instance.cc
@@ -204,7 +204,7 @@ std::unique_ptr<Environment> NodeMainInstance::CreateMainEnvironment(
// TODO(joyeecheung): when we snapshot the bootstrapped context,
// the inspector and diagnostics setup should after after deserialization.
-#if HAVE_INSPECTOR && NODE_USE_V8_PLATFORM
+#if HAVE_INSPECTOR
*exit_code = env->InitializeInspector(nullptr);
#endif
if (*exit_code != 0) {
diff --git a/src/node_worker.cc b/src/node_worker.cc
index 3dce5e25980ce2c6f17cda02dab9c0f8b4fab813..c8b2e1699f26ac9bfeb373653d35271f9b6c841f 100644
--- a/src/node_worker.cc
+++ b/src/node_worker.cc
@@ -8,7 +8,7 @@
#include "util-inl.h"
#include "async_wrap-inl.h"
-#if NODE_USE_V8_PLATFORM && HAVE_INSPECTOR
+#if HAVE_INSPECTOR
#include "inspector/worker_inspector.h" // ParentInspectorHandle
#endif
@@ -41,7 +41,7 @@ namespace worker {
namespace {
-#if NODE_USE_V8_PLATFORM && HAVE_INSPECTOR
+#if HAVE_INSPECTOR
void WaitForWorkerInspectorToStop(Environment* child) {
child->inspector_agent()->WaitForDisconnect();
child->inspector_agent()->Stop();
@@ -84,7 +84,7 @@ Worker::Worker(Environment* env,
Number::New(env->isolate(), static_cast<double>(thread_id_)))
.Check();
-#if NODE_USE_V8_PLATFORM && HAVE_INSPECTOR
+#if HAVE_INSPECTOR
inspector_parent_handle_ =
env->inspector_agent()->GetParentHandle(thread_id_, url);
#endif
@@ -195,7 +195,7 @@ void Worker::Run() {
Locker locker(isolate_);
Isolate::Scope isolate_scope(isolate_);
SealHandleScope outer_seal(isolate_);
-#if NODE_USE_V8_PLATFORM && HAVE_INSPECTOR
+#if HAVE_INSPECTOR
bool inspector_started = false;
#endif
@@ -227,7 +227,7 @@ void Worker::Run() {
env_->stop_sub_worker_contexts();
env_->RunCleanup();
RunAtExit(env_.get());
-#if NODE_USE_V8_PLATFORM && HAVE_INSPECTOR
+#if HAVE_INSPECTOR
if (inspector_started)
WaitForWorkerInspectorToStop(env_.get());
#endif
@@ -272,7 +272,7 @@ void Worker::Run() {
if (is_stopped()) return;
{
env_->InitializeDiagnostics();
-#if NODE_USE_V8_PLATFORM && HAVE_INSPECTOR
+#if HAVE_INSPECTOR
env_->InitializeInspector(inspector_parent_handle_.release());
inspector_started = true;
#endif
diff --git a/src/node_worker.h b/src/node_worker.h
index ffc4f19882cc2629252c504119649f17dd8dbaff..77f68801e7c24731c63c8cfaf00dcd422b837f29 100644
--- a/src/node_worker.h
+++ b/src/node_worker.h
@@ -65,7 +65,7 @@ class Worker : public AsyncWrap {
bool start_profiler_idle_notifier_;
uv_thread_t tid_;
-#if NODE_USE_V8_PLATFORM && HAVE_INSPECTOR
+#if HAVE_INSPECTOR
std::unique_ptr<inspector::ParentInspectorHandle> inspector_parent_handle_;
#endif

View file

@ -0,0 +1,21 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Shelley Vohr <shelley.vohr@gmail.com>
Date: Wed, 16 Oct 2019 09:07:57 -0700
Subject: fix: windows compilation on libuv setsockopt
Upstreamed in https://github.com/libuv/libuv/pull/2520.
This patch should be removed when Node.js rolls onto libuv v1.33.0.
diff --git a/deps/uv/src/win/tcp.c b/deps/uv/src/win/tcp.c
index 81e48136a3b9ef13b1b95d87a68ab3ba98f9aeb9..41f8fcbe8361dc7c7a145b38094745cb0fcfa350 100644
--- a/deps/uv/src/win/tcp.c
+++ b/deps/uv/src/win/tcp.c
@@ -556,7 +556,7 @@ int uv_tcp_close_reset(uv_tcp_t* handle, uv_close_cb close_cb) {
if (handle->flags & UV_HANDLE_SHUTTING)
return UV_EINVAL;
- if (0 != setsockopt(handle->socket, SOL_SOCKET, SO_LINGER, &l, sizeof(l)))
+ if (0 != setsockopt(handle->socket, SOL_SOCKET, SO_LINGER, (const char*)&l, sizeof(l)))
return uv_translate_sys_error(WSAGetLastError());
uv_close((uv_handle_t*) handle, close_cb);

View file

@ -9,7 +9,7 @@ index 52a8da35b671d196331b858ba46be04aecf1e0be..43ccfafd9f2c85e23a9ea6277e88e486
--- a/src/api/callback.cc
+++ b/src/api/callback.cc
@@ -103,12 +103,14 @@ void InternalCallbackScope::Close() {
env_->isolate()->RunMicrotasks();
MicrotasksScope::PerformCheckpoint(env_->isolate());
}
+#if 0 // FIXME(codebytere): figure out why this check fails/causes crash

View file

@ -51,12 +51,12 @@ index ffc7fb6fd5857b807198d4d26b7b899e63cde4a1..2a7ffbff213f23536b94664c3ecffa18
if (statCache !== null) statCache.set(filename, result);
return result;
}
@@ -205,7 +200,7 @@ const packageExportsCache = new SafeMap();
@@ -233,7 +233,7 @@ function readPackage(requestPath) {
const existing = packageJsonCache.get(jsonPath);
if (existing !== undefined) return existing;
function readPackageRaw(requestPath) {
const jsonPath = path.resolve(requestPath, 'package.json');
- const json = internalModuleReadJSON(path.toNamespacedPath(jsonPath));
+ const json = internalFsBinding.internalModuleReadJSON(path.toNamespacedPath(jsonPath));
if (json === undefined) {
packageJsonCache.set(jsonPath, false);
return false;

View file

@ -0,0 +1,28 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Shelley Vohr <shelley.vohr@gmail.com>
Date: Tue, 15 Oct 2019 11:30:27 -0700
Subject: Revert "crypto: add oaepLabel option"
This partially reverts commit 54f327b4dcb37f373bc4146686c7e4edcd9c524d.
diff --git a/src/node_crypto.cc b/src/node_crypto.cc
index be53ccc9759fcfb4cfa301e02fee6ff46b681033..2f73b3dc13a7f38b44f5f095da5dae3e24e7a629 100644
--- a/src/node_crypto.cc
+++ b/src/node_crypto.cc
@@ -5188,16 +5186,6 @@ bool PublicKeyCipher::Cipher(Environment* env,
return false;
}
- if (oaep_label_len != 0) {
- // OpenSSL takes ownership of the label, so we need to create a copy.
- void* label = OPENSSL_memdup(oaep_label, oaep_label_len);
- CHECK_NOT_NULL(label);
- if (!EVP_PKEY_CTX_set0_rsa_oaep_label(ctx.get(), label, oaep_label_len)) {
- OPENSSL_free(label);
- return false;
- }
- }
-
size_t out_len = 0;
if (EVP_PKEY_cipher(ctx.get(), nullptr, &out_len, data, len) <= 0)
return false;

View file

@ -9,7 +9,7 @@ diff --git a/doc/api/crypto.md b/doc/api/crypto.md
index 8132e2975483b8fda95fe4466910dd42f74866cd..9b7aab3009770bb7816493581d82b63b7e19f2f3 100644
--- a/doc/api/crypto.md
+++ b/doc/api/crypto.md
@@ -1785,10 +1785,6 @@ and description of each available elliptic curve.
@@ -1845,10 +1845,6 @@ and description of each available elliptic curve.
### crypto.createHash(algorithm[, options])
<!-- YAML
added: v0.1.92
@ -18,9 +18,9 @@ index 8132e2975483b8fda95fe4466910dd42f74866cd..9b7aab3009770bb7816493581d82b63b
- pr-url: https://github.com/nodejs/node/pull/28805
- description: The `outputLength` option was added for XOF hash functions.
-->
* `algorithm` {string}
* `options` {Object} [`stream.transform` options][]
@@ -1796,8 +1792,7 @@ changes:
@@ -1857,8 +1853,7 @@ changes:
Creates and returns a `Hash` object that can be used to generate hash digests
using the given `algorithm`. Optional `options` argument controls stream
@ -31,19 +31,22 @@ index 8132e2975483b8fda95fe4466910dd42f74866cd..9b7aab3009770bb7816493581d82b63b
The `algorithm` is dependent on the available algorithms supported by the
version of OpenSSL on the platform. Examples are `'sha256'`, `'sha512'`, etc.
diff --git a/lib/internal/crypto/hash.js b/lib/internal/crypto/hash.js
index 38b125e5f22c2dd5220a983d8126bef1feb5462b..a58164802124d30ac0fa2c5b472857fa018d2bfa 100644
index 3812ecfe68..7e81769eee 100644
--- a/lib/internal/crypto/hash.js
+++ b/lib/internal/crypto/hash.js
@@ -25,7 +25,7 @@ const {
@@ -24,10 +24,7 @@ const {
ERR_CRYPTO_HASH_UPDATE_FAILED,
ERR_INVALID_ARG_TYPE
} = require('internal/errors').codes;
-const { validateString, validateUint32 } = require('internal/validators');
-const {
- validateString,
- validateUint32
-} = require('internal/validators');
+const { validateString } = require('internal/validators');
const { normalizeEncoding } = require('internal/util');
const { isArrayBufferView } = require('internal/util/types');
const LazyTransform = require('internal/streams/lazy_transform');
@@ -36,11 +36,7 @@ function Hash(algorithm, options) {
const kState = Symbol('kState');
@@ -37,11 +34,7 @@ function Hash(algorithm, options) {
if (!(this instanceof Hash))
return new Hash(algorithm, options);
validateString(algorithm, 'algorithm');
@ -84,16 +87,15 @@ index cd09cdb3f2244825f6631891b94e61eeb6bc60bf..177de527c634671c571ebe4c2cfdeedc
const EVP_MD* md = EVP_get_digestbyname(hash_type);
if (md == nullptr)
return false;
@@ -4586,18 +4580,6 @@ bool Hash::HashInit(const char* hash_type, Maybe<unsigned int> xof_md_len) {
mdctx_.reset();
@@ -4738,17 +4738,6 @@ bool Hash::HashInit(const char* hash_type, Maybe<unsigned int> xof_md_len) {
return false;
}
-
- md_len_ = EVP_MD_size(md);
- if (xof_md_len.IsJust() && xof_md_len.FromJust() != md_len_) {
- // This is a little hack to cause createHash to fail when an incorrect
- // hashSize option was passed for a non-XOF hash function.
- if ((EVP_MD_meth_get_flags(md) & EVP_MD_FLAG_XOF) == 0) {
- if ((EVP_MD_flags(md) & EVP_MD_FLAG_XOF) == 0) {
- EVPerr(EVP_F_EVP_DIGESTFINALXOF, EVP_R_NOT_XOF_OR_INVALID_LENGTH);
- return false;
- }

View file

@ -0,0 +1,30 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Shelley Vohr <shelley.vohr@gmail.com>
Date: Tue, 15 Oct 2019 11:23:56 -0700
Subject: Revert "crypto: fix OpenSSL return code handling"
This reverts commit dd5d944005166fbbfd4b72b9779f398598b3481d.
diff --git a/src/node_crypto.cc b/src/node_crypto.cc
index 63dd6a186366baad660ee8e38401ba842c6ddb17..be53ccc9759fcfb4cfa301e02fee6ff46b681033 100644
--- a/src/node_crypto.cc
+++ b/src/node_crypto.cc
@@ -5184,7 +5184,7 @@ bool PublicKeyCipher::Cipher(Environment* env,
return false;
if (digest != nullptr) {
- if (EVP_PKEY_CTX_set_rsa_oaep_md(ctx.get(), digest) <= 0)
+ if (!EVP_PKEY_CTX_set_rsa_oaep_md(ctx.get(), digest))
return false;
}
@@ -5192,8 +5192,7 @@ bool PublicKeyCipher::Cipher(Environment* env,
// OpenSSL takes ownership of the label, so we need to create a copy.
void* label = OPENSSL_memdup(oaep_label, oaep_label_len);
CHECK_NOT_NULL(label);
- if (0 >= EVP_PKEY_CTX_set0_rsa_oaep_label(ctx.get(), label,
- oaep_label_len)) {
+ if (!EVP_PKEY_CTX_set0_rsa_oaep_label(ctx.get(), label, oaep_label_len)) {
OPENSSL_free(label);
return false;
}

View file

@ -0,0 +1,160 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Shelley Vohr <shelley.vohr@gmail.com>
Date: Tue, 15 Oct 2019 11:21:13 -0700
Subject: Revert "tls: add option to override signature algorithms"
This partially reverts commit 6272f82c07e913a76a316a786c9aadbc09f953ff.
diff --git a/src/node_crypto.cc b/src/node_crypto.cc
index 870456216983c2685c53580e60c44aa4dd3f7267..63dd6a186366baad660ee8e38401ba842c6ddb17 100644
--- a/src/node_crypto.cc
+++ b/src/node_crypto.cc
@@ -470,7 +470,6 @@ void SecureContext::Initialize(Environment* env, Local<Object> target) {
env->SetProtoMethod(t, "addRootCerts", AddRootCerts);
env->SetProtoMethod(t, "setCipherSuites", SetCipherSuites);
env->SetProtoMethod(t, "setCiphers", SetCiphers);
- env->SetProtoMethod(t, "setSigalgs", SetSigalgs);
env->SetProtoMethod(t, "setECDHCurve", SetECDHCurve);
env->SetProtoMethod(t, "setDHParam", SetDHParam);
env->SetProtoMethod(t, "setMaxProto", SetMaxProto);
@@ -739,23 +738,6 @@ void SecureContext::SetKey(const FunctionCallbackInfo<Value>& args) {
}
}
-void SecureContext::SetSigalgs(const FunctionCallbackInfo<Value>& args) {
- SecureContext* sc;
- ASSIGN_OR_RETURN_UNWRAP(&sc, args.Holder());
- Environment* env = sc->env();
- ClearErrorOnReturn clear_error_on_return;
-
- CHECK_EQ(args.Length(), 1);
- CHECK(args[0]->IsString());
-
- const node::Utf8Value sigalgs(env->isolate(), args[0]);
-
- int rv = SSL_CTX_set1_sigalgs_list(sc->ctx_.get(), *sigalgs);
-
- if (rv == 0) {
- return ThrowCryptoError(env, ERR_get_error());
- }
-}
#ifndef OPENSSL_NO_ENGINE
// Helpers for the smart pointer.
@@ -1748,7 +1730,6 @@ void SSLWrap<Base>::AddMethods(Environment* env, Local<FunctionTemplate> t) {
env->SetProtoMethodNoSideEffect(t, "isSessionReused", IsSessionReused);
env->SetProtoMethodNoSideEffect(t, "verifyError", VerifyError);
env->SetProtoMethodNoSideEffect(t, "getCipher", GetCipher);
- env->SetProtoMethodNoSideEffect(t, "getSharedSigalgs", GetSharedSigalgs);
env->SetProtoMethod(t, "endParser", EndParser);
env->SetProtoMethod(t, "certCbDone", CertCbDone);
env->SetProtoMethod(t, "renegotiate", Renegotiate);
@@ -2685,88 +2666,6 @@ void SSLWrap<Base>::GetCipher(const FunctionCallbackInfo<Value>& args) {
}
-template <class Base>
-void SSLWrap<Base>::GetSharedSigalgs(const FunctionCallbackInfo<Value>& args) {
- Base* w;
- ASSIGN_OR_RETURN_UNWRAP(&w, args.Holder());
- Environment* env = w->ssl_env();
- std::vector<Local<Value>> ret_arr;
-
- SSL* ssl = w->ssl_.get();
- int nsig = SSL_get_shared_sigalgs(ssl, 0, nullptr, nullptr, nullptr, nullptr,
- nullptr);
-
- for (int i = 0; i < nsig; i++) {
- int hash_nid;
- int sign_nid;
- std::string sig_with_md;
-
- SSL_get_shared_sigalgs(ssl, i, &sign_nid, &hash_nid, nullptr, nullptr,
- nullptr);
-
- switch (sign_nid) {
- case EVP_PKEY_RSA:
- sig_with_md = "RSA+";
- break;
-
- case EVP_PKEY_RSA_PSS:
- sig_with_md = "RSA-PSS+";
- break;
-
- case EVP_PKEY_DSA:
- sig_with_md = "DSA+";
- break;
-
- case EVP_PKEY_EC:
- sig_with_md = "ECDSA+";
- break;
-
- case NID_ED25519:
- sig_with_md = "Ed25519+";
- break;
-
- case NID_ED448:
- sig_with_md = "Ed448+";
- break;
-
- case NID_id_GostR3410_2001:
- sig_with_md = "gost2001+";
- break;
-
- case NID_id_GostR3410_2012_256:
- sig_with_md = "gost2012_256+";
- break;
-
- case NID_id_GostR3410_2012_512:
- sig_with_md = "gost2012_512+";
- break;
-
- default:
- const char* sn = OBJ_nid2sn(sign_nid);
-
- if (sn != nullptr) {
- sig_with_md = std::string(sn) + "+";
- } else {
- sig_with_md = "UNDEF+";
- }
- break;
- }
-
- const char* sn_hash = OBJ_nid2sn(hash_nid);
- if (sn_hash != nullptr) {
- sig_with_md += std::string(sn_hash);
- } else {
- sig_with_md += "UNDEF";
- }
-
- ret_arr.push_back(OneByteString(env->isolate(), sig_with_md.c_str()));
- }
-
- args.GetReturnValue().Set(
- Array::New(env->isolate(), ret_arr.data(), ret_arr.size()));
-}
-
-
template <class Base>
void SSLWrap<Base>::GetProtocol(const FunctionCallbackInfo<Value>& args) {
Base* w;
diff --git a/src/node_crypto.h b/src/node_crypto.h
index fb21077132dec0900118d178605c9b93cc458105..31e7da7da9daf2ecf965dc38df24272f838ba1a0 100644
--- a/src/node_crypto.h
+++ b/src/node_crypto.h
@@ -129,7 +129,6 @@ class SecureContext : public BaseObject {
static void AddRootCerts(const v8::FunctionCallbackInfo<v8::Value>& args);
static void SetCipherSuites(const v8::FunctionCallbackInfo<v8::Value>& args);
static void SetCiphers(const v8::FunctionCallbackInfo<v8::Value>& args);
- static void SetSigalgs(const v8::FunctionCallbackInfo<v8::Value>& args);
static void SetECDHCurve(const v8::FunctionCallbackInfo<v8::Value>& args);
static void SetDHParam(const v8::FunctionCallbackInfo<v8::Value>& args);
static void SetOptions(const v8::FunctionCallbackInfo<v8::Value>& args);
@@ -255,7 +254,6 @@ class SSLWrap {
static void IsSessionReused(const v8::FunctionCallbackInfo<v8::Value>& args);
static void VerifyError(const v8::FunctionCallbackInfo<v8::Value>& args);
static void GetCipher(const v8::FunctionCallbackInfo<v8::Value>& args);
- static void GetSharedSigalgs(const v8::FunctionCallbackInfo<v8::Value>& args);
static void EndParser(const v8::FunctionCallbackInfo<v8::Value>& args);
static void CertCbDone(const v8::FunctionCallbackInfo<v8::Value>& args);
static void Renegotiate(const v8::FunctionCallbackInfo<v8::Value>& args);

View file

@ -141,6 +141,7 @@
"parallel/test-tls-socket-failed-handshake-emits-error",
"parallel/test-tls-socket-allow-half-open-option",
"parallel/test-tls-ticket",
"parallel/test-tls-set-sigalgs",
"parallel/test-tls-write-error",
"parallel/test-tls-ticket-cluster",
"parallel/test-trace-events-dynamic-enable",
@ -174,9 +175,12 @@
"parallel/test-worker-message-channel",
"parallel/test-worker-message-port-transfer-duplicate",
"parallel/test-worker-message-port-transfer-target",
"parallel/test-worker-message-port",
"parallel/test-worker-invalid-workerdata",
"parallel/test-worker-ref-onexit",
"parallel/test-worker-sharedarraybuffer-from-worker-thread",
"parallel/test-worker-stdio",
"parallel/test-wrap-js-stream-exceptions",
"async-hooks/test-crypto-randomBytes",
"async-hooks/test-fseventwrap",
"async-hooks/test-fsreqcallback-readFile",
@ -273,6 +277,9 @@
"message/undefined_reference_in_new_context",
"message/unhandled_promise_trace_warnings",
"message/util_inspect_error",
"message/source_map_throw_catch",
"message/source_map_throw_first_tick",
"message/source_map_throw_set_immediate",
"message/v8_warning",
"message/vm_display_runtime_error",
"message/vm_display_syntax_error",
@ -291,6 +298,8 @@
"pseudo-tty/test-tty-wrap",
"parallel/test-cluster-master-kill",
"parallel/test-cluster-master-error",
"parallel/test-source-map",
"sequential/test-timers-block-eventloop",
"sequential/test-timers-set-interval-excludes-callback-duration"
"sequential/test-timers-set-interval-excludes-callback-duration",
"wpt/test-encoding"
]