Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
106 commits
Select commit Hold shift + click to select a range
0a6f0b4
deps: upgrade npm to 8.5.0
npm-robot Feb 11, 2022
3243701
readline: bind keystroke `ctrl`+`6` to redo
rayw000 Feb 7, 2022
182e6b9
build: improve consistency between workflows
Mesteery Feb 7, 2022
76f0f1c
test: move test-crypto-engine to addon
mhdawson Feb 2, 2022
0fff4d2
crypto: do not advertise unsupported algorithms
mscdex Feb 5, 2022
5796c3a
process: deprecate multipleResolves
benjamingr Feb 8, 2022
2b1dabf
build: revert fast-track changes
panva Feb 8, 2022
291fe63
doc: fix webstream close reject state state doc
benjamingr Feb 5, 2022
f30b5e3
tools: fix typo in prefer-primordials.js
eltociear Feb 8, 2022
ba5cb89
doc: remove unneeded ellipsis in header
Trott Feb 8, 2022
fa3a913
lib: add internal genericNodeError() function
Trott Feb 9, 2022
0de611f
doc: add joesepi to collaborators
joesepi Feb 9, 2022
c766159
repl: #41690 REPL gives wrong autocomplete on literals
meixg Feb 10, 2022
ba639d0
esm: support https remotely and http locally under flag
bmeck Nov 30, 2020
fc9d4e9
doc: edit process.config deprecation text
Trott Feb 10, 2022
aa684a7
doc: replace text with paths in toggle SVGs
mscdex Feb 10, 2022
c41e402
cluster: respect listen backlog set by workers
eladnava Jan 21, 2022
dc14bd8
test: remove lint rule for setTimeout() arguments
Trott Feb 11, 2022
b968d89
build: remove broken x32 arch support
bnoordhuis Feb 11, 2022
6076291
src: don't print interface if sin6_scope_id is 0
santigimeno Feb 11, 2022
364ec5b
src: fix query/fragment serialization in URL::SerializeURL
addaleax Jan 29, 2022
0330e2d
src: reserve string allocation space early in URL::SerializeURL
addaleax Jan 29, 2022
d91a956
src: use const reference instead of pointer in URL::SerializeURL
addaleax Jan 29, 2022
07463b3
stream: use standard for loop instead of for..of
VoltrexKeyva Feb 6, 2022
5195479
stream: refactor to use more validators
VoltrexKeyva Feb 6, 2022
3e38506
stream: avoid usage of deprecated APIs
VoltrexKeyva Feb 6, 2022
1eac0a1
debugger: remove duplicate setPauseOnException call
bavulapati Feb 11, 2022
6a7b016
doc: improve scrollbar appearance in dark mode
Aaron00101010 Feb 11, 2022
83b913c
test: improve code coverage for streams/duplexify
ErickWendel Feb 11, 2022
528c585
fs: refactor to use ES2020 syntax
xtx1130 Feb 11, 2022
77462b6
stream: revert `map` spec compliance
benjamingr Feb 11, 2022
e2a74d2
src: remove separate definitions for static constexpr members
addaleax Feb 11, 2022
3a12134
lib: move kEnumerableProperty to internal/util
Mesteery Feb 11, 2022
24b0a56
child_process: kHideConsoleWindows for spawnSync
rzhao271 Feb 11, 2022
b0e8ccb
doc: clarify `tls.Server` `'connection'` event documentation
prettydiff Feb 12, 2022
66c9565
esm: fix typo in `fetch_module`
scovetta Feb 12, 2022
dca2692
doc: emphasize security warning in vm module doc
Trott Feb 12, 2022
43a5161
doc: fix wrong indent in stream documentation
meixg Feb 12, 2022
b4db004
fs: fix writev empty array error behavior
benjamingr Feb 12, 2022
cb9dba0
doc: fix typo in readableStream.locked description
tniessen Feb 13, 2022
f80cae8
src: merge ToJsSet into ToV8Value
addaleax Feb 13, 2022
b1505a1
tls: avoid throw in onerror for bad TLSSocket obj
sigv Feb 14, 2022
8748b1e
doc: add missing `buffer` in the `stream/consumers` import example
Mesteery Feb 14, 2022
6068291
crypto: expose Web Crypto API on the global scope
aduh95 Feb 14, 2022
f5d7339
stream: add more filter tests
benjamingr Feb 11, 2022
b8cbb83
stream: add more forEach tests
benjamingr Feb 11, 2022
be5143b
fs: fix cb/sync writev empty array behavior
benjamingr Feb 11, 2022
520dcbc
test: fix intl tests on small-icu builds
aduh95 Feb 14, 2022
f4cb726
build,tools: change the quotes in YAML
Mesteery Jan 29, 2022
cd04ed1
build: extend yamllint configuration
Mesteery Jan 29, 2022
3d99811
meta: update AUTHORS and .mailmap
Trott Feb 14, 2022
06117c0
tools: update lint-md-dependencies to rollup@2.67.2
nodejs-github-bot Feb 12, 2022
4e2e2cb
build: move tool updates workflow runtime a day later
Trott Feb 15, 2022
d34ee45
doc: fix bug in `readable.unshift` code example
meixg Feb 15, 2022
1e8e8bc
build: use zoslib_include_dir provided by node-gyp
alexcfyung Feb 15, 2022
6b88595
doc: deprecate notice for process methods
yashLadha Jan 26, 2022
214d176
fs: support copy of relative links with cp and cpSync
marcosbc Feb 15, 2022
ab73bde
test: fix typographical error
Trott Feb 15, 2022
35832fe
tools: update ESLint to 8.9.0
lpinca Feb 14, 2022
90d90e3
doc: add marsonya to collaborators
marsonya Feb 15, 2022
f8e302c
test: fix names of tests marked flaky on IBM i
richardlau Feb 15, 2022
6195de5
doc: fix deprecation number
aduh95 Feb 15, 2022
06f225c
doc: capitalize valgrind
mahmoud-moursy Feb 15, 2022
09c1748
deps: update undici to 3e267ece5f
targos Feb 16, 2022
2e905a6
tools: update remark-preset-lint-node to 3.3.1
Trott Feb 16, 2022
f9bfdc3
lib: restrict usage of fetch related globals in core internals
aduh95 Feb 13, 2022
c7d590c
doc: remove extra <td>
rayw000 Feb 16, 2022
1315f1e
build: prevent concurrent CI and CQ workflow runs
targos Feb 16, 2022
68ec8d5
lib: stop installing fetch if no_browser_globals is true
RaisinTen Feb 16, 2022
0660ba3
events: set default handler value
benjamingr Feb 16, 2022
ae36276
lib: allow respondWithNewView on byob auto allocated streams
sbquinlan Feb 16, 2022
c3b0e72
lib: stop installing webcrypto if `no_browser_globals` is `true`
Mesteery Feb 17, 2022
9825ced
test: run webmessaging/broadcastchannel WPT
bnoordhuis Feb 17, 2022
2e252b3
doc: adjust a/an word usage
derekwolpert Feb 17, 2022
f51b55d
meta: use plain emojis instead of escape sequences
Mesteery Feb 17, 2022
67f1ebf
debugger: add debugger alias for exec(expr)
meixg Feb 17, 2022
69d7736
build: add action to close stale feature requests
mhdawson Feb 15, 2022
d3e6ad1
build: allow manual run of feature request action
mhdawson Feb 17, 2022
782506c
build: increase operations and test tag
mhdawson Feb 17, 2022
43c12f4
src,buffer: evaluate THROW_AND_RETURN_IF_OOB() expression only once
RaisinTen Feb 17, 2022
946ac96
crypto: rename X509_NAME_FLAGS
tniessen Feb 17, 2022
84b1e4f
crypto: check result of BIO_new in X509ToObject
tniessen Feb 17, 2022
afeed46
tools: reduce list of globals in ESLint config
Trott Feb 18, 2022
bcf53a8
test: improve vm test coverage
kuriyosh Feb 18, 2022
cfafb45
tools,lib: remove `global` and `Intl` from the list of globals
aduh95 Feb 18, 2022
47bb7dd
tools: add timers functions to the list of restricted globals
aduh95 Feb 18, 2022
ba35b6c
worker: fix typo in debug statement
aduh95 Feb 18, 2022
60bbacd
doc: use openpgp.org for keyserver examples
nschonni Feb 18, 2022
c673953
build: cancel running CI jobs when a PR is updated
targos Feb 18, 2022
fe66d2b
test: check that fetch globals are disabled by default
targos Feb 18, 2022
ec0d623
lib: add FormData global when fetch is enabled
targos Feb 18, 2022
e895e64
tools: fix bugs in prefer-primordials linter rule
aduh95 Feb 18, 2022
a95f7a0
esm: remove erroneous `context.parentURL` property passed to `load` hook
JakobJingleheimer Feb 18, 2022
d1ef43f
deps: upgrade npm to 8.5.1
npm-robot Feb 19, 2022
d900891
test: remove test-stdout-close-catch flaky designation
Trott Feb 19, 2022
c0f4289
esm: improve `fetch_module` test coverage and remove hack
aduh95 Feb 19, 2022
1b4ee6c
tools: lint deprecation codes
aduh95 Feb 19, 2022
5a807c5
fs: fix default `length` parameter for `fs.read`
wbt Feb 19, 2022
896ccc1
tools: add `console` to the list of restricted globals
aduh95 Feb 19, 2022
1e698e6
meta: update AUTHORS
nodejs-github-bot Feb 20, 2022
9c618ad
doc: make minor fixes to contributing guides
mahmoud-moursy Feb 14, 2022
fea682c
doc: fix typo in http2 endAfterHeaders description
acomanescu Feb 20, 2022
6742625
tools: enable es2022 env in ESLint config
targos Feb 20, 2022
391f4e5
perf_hooks: use arrays to store EntryBuffers
meixg Feb 20, 2022
2cdbf03
tools: update lint-md-dependencies to rollup@2.67.3
nodejs-github-bot Feb 21, 2022
972dd0a
2022-02-22, Version 17.6.0 (Current)
bengl Feb 21, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
crypto: do not advertise unsupported algorithms
Fixes: #41857

PR-URL: #41864
Reviewed-By: Tobias Nießen <tniessen@tnie.de>
Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Filip Skokan <panva.ip@gmail.com>
  • Loading branch information
mscdex authored and bengl committed Feb 21, 2022
commit 0fff4d2314924147807a486d23d83d613974f594
13 changes: 12 additions & 1 deletion src/crypto/crypto_cipher.cc
Original file line number Diff line number Diff line change
Expand Up @@ -235,8 +235,19 @@ void CipherBase::GetSSLCiphers(const FunctionCallbackInfo<Value>& args) {

void CipherBase::GetCiphers(const FunctionCallbackInfo<Value>& args) {
Environment* env = Environment::GetCurrent(args);
MarkPopErrorOnReturn mark_pop_error_on_return;
CipherPushContext ctx(env);
EVP_CIPHER_do_all_sorted(array_push_back<EVP_CIPHER>, &ctx);
EVP_CIPHER_do_all_sorted(
#if OPENSSL_VERSION_MAJOR >= 3
array_push_back<EVP_CIPHER,
EVP_CIPHER_fetch,
EVP_CIPHER_free,
EVP_get_cipherbyname,
EVP_CIPHER_get0_name>,
#else
array_push_back<EVP_CIPHER>,
#endif
&ctx);
args.GetReturnValue().Set(ctx.ToJSArray());
}

Expand Down
13 changes: 12 additions & 1 deletion src/crypto/crypto_hash.cc
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,19 @@ void Hash::MemoryInfo(MemoryTracker* tracker) const {

void Hash::GetHashes(const FunctionCallbackInfo<Value>& args) {
Environment* env = Environment::GetCurrent(args);
MarkPopErrorOnReturn mark_pop_error_on_return;
CipherPushContext ctx(env);
EVP_MD_do_all_sorted(array_push_back<EVP_MD>, &ctx);
EVP_MD_do_all_sorted(
#if OPENSSL_VERSION_MAJOR >= 3
array_push_back<EVP_MD,
EVP_MD_fetch,
EVP_MD_free,
EVP_get_digestbyname,
EVP_MD_get0_name>,
#else
array_push_back<EVP_MD>,
#endif
&ctx);
args.GetReturnValue().Set(ctx.ToJSArray());
}

Expand Down
40 changes: 39 additions & 1 deletion src/crypto/crypto_util.h
Original file line number Diff line number Diff line change
Expand Up @@ -616,13 +616,51 @@ class CipherPushContext {
Environment* env_;
};

#if OPENSSL_VERSION_MAJOR >= 3
template <class TypeName,
TypeName* fetch_type(OSSL_LIB_CTX*, const char*, const char*),
void free_type(TypeName*),
const TypeName* getbyname(const char*),
const char* getname(const TypeName*)>
void array_push_back(const TypeName* evp_ref,
const char* from,
const char* to,
void* arg) {
if (!from)
return;

const TypeName* real_instance = getbyname(from);
if (!real_instance)
return;

const char* real_name = getname(real_instance);
if (!real_name)
return;

// EVP_*_fetch() does not support alias names, so we need to pass it the
// real/original algorithm name.
// We use EVP_*_fetch() as a filter here because it will only return an
// instance if the algorithm is supported by the public OpenSSL APIs (some
// algorithms are used internally by OpenSSL and are also passed to this
// callback).
TypeName* fetched = fetch_type(nullptr, real_name, nullptr);
if (!fetched)
return;

free_type(fetched);
static_cast<CipherPushContext*>(arg)->push_back(from);
}
#else
template <class TypeName>
void array_push_back(const TypeName* md,
void array_push_back(const TypeName* evp_ref,
const char* from,
const char* to,
void* arg) {
if (!from)
return;
static_cast<CipherPushContext*>(arg)->push_back(from);
}
#endif

inline bool IsAnyByteSource(v8::Local<v8::Value> arg) {
return arg->IsArrayBufferView() ||
Expand Down
16 changes: 16 additions & 0 deletions test/parallel/test-crypto.js
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,19 @@ function validateList(list) {
const cryptoCiphers = crypto.getCiphers();
assert(crypto.getCiphers().includes('aes-128-cbc'));
validateList(cryptoCiphers);
// Make sure all of the ciphers are supported by OpenSSL
for (const algo of cryptoCiphers) {
const { ivLength, keyLength, mode } = crypto.getCipherInfo(algo);
let options;
if (mode === 'ccm')
options = { authTagLength: 8 };
else if (mode === 'ocb' || algo === 'chacha20-poly1305')
options = { authTagLength: 16 };
crypto.createCipheriv(algo,
crypto.randomBytes(keyLength),
crypto.randomBytes(ivLength || 0),
options);
}

// Assume that we have at least AES256-SHA.
const tlsCiphers = tls.getCiphers();
Expand All @@ -140,6 +153,9 @@ assert(!crypto.getHashes().includes('SHA256'));
assert(crypto.getHashes().includes('RSA-SHA1'));
assert(!crypto.getHashes().includes('rsa-sha1'));
validateList(crypto.getHashes());
// Make sure all of the hashes are supported by OpenSSL
for (const algo of crypto.getHashes())
crypto.createHash(algo);

// Assume that we have at least secp384r1.
assert.notStrictEqual(crypto.getCurves().length, 0);
Expand Down