GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — crypto: derive Argon2 without worker threads · nodejs/node@abaf24b

File tree

Expand file treeCollapse file tree
Open diff view settings
Filter options
  • deps/ncrypto
    • ncrypto.cc
Expand file treeCollapse file tree
Open diff view settings
Collapse file

‎deps/ncrypto/ncrypto.cc‎

Copy file name to clipboardExpand all lines: deps/ncrypto/ncrypto.cc
+12-4Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2937,7 +2937,9 @@ DataPointer argon2(const Buffer<const char>& pass,
29372937
// per-context. It inherits no configuration, so availability is checked
29382938
// against the default context, otherwise Argon2 works in FIPS mode.
29392939
DeleteFnPtr<OSSL_LIB_CTX, OSSL_LIB_CTX_free> ctx;
2940-
if (lanes > 1) {
2940+
uint32_t threads = lanes == 0 ? 0 : 1;
2941+
if (lanes > 1 && (OSSL_get_thread_support_flags() &
2942+
OSSL_THREAD_SUPPORT_FLAG_DEFAULT_SPAWN) != 0) {
29412943
if (!KDF::Fetch(algorithm.data())) {
29422944
return {};
29432945
}
@@ -2947,8 +2949,13 @@ DataPointer argon2(const Buffer<const char>& pass,
29472949
return {};
29482950
}
29492951

2950-
if (OSSL_set_max_threads(ctx.get(), lanes) != 1) {
2951-
return {};
2952+
MarkPopErrorOnReturn mark_pop_error_on_return;
2953+
if (OSSL_set_max_threads(ctx.get(), lanes) == 1) {
2954+
threads = lanes;
2955+
} else {
2956+
// Lane count is an Argon2 input; worker threads are only an
2957+
// optimization. Compute the same lanes serially if unavailable.
2958+
ctx.reset();
29522959
}
29532960
}
29542961

@@ -2966,7 +2973,8 @@ DataPointer argon2(const Buffer<const char>& pass,
29662973
pass.len));
29672974
params.push_back(OSSL_PARAM_construct_octet_string(
29682975
OSSL_KDF_PARAM_SALT, const_cast<unsigned char*>(salt.data), salt.len));
2969-
params.push_back(OSSL_PARAM_construct_uint32(OSSL_KDF_PARAM_THREADS, &lanes));
2976+
params.push_back(
2977+
OSSL_PARAM_construct_uint32(OSSL_KDF_PARAM_THREADS, &threads));
29702978
params.push_back(
29712979
OSSL_PARAM_construct_uint32(OSSL_KDF_PARAM_ARGON2_LANES, &lanes));
29722980
params.push_back(

0 commit comments

Comments
0 (0)
You are visitor 01402792 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.