Ben Noordhuis
9ed4646df0
crypto: fix length argument to snprintf()
...
Introduced in commit d3d6cd3eca ("src: improve SSL version extraction
logic".)
PR-URL: https://github.com/nodejs/node/pull/23622
Reviewed-By: Anna Henningsen <anna@addaleax.net >
Reviewed-By: Santiago Gimeno <santiago.gimeno@gmail.com >
Reviewed-By: James M Snell <jasnell@gmail.com >
Reviewed-By: Hitesh Kanwathirtha <digitalinfinity@gmail.com >
Reviewed-By: Richard Lau <riclau@uk.ibm.com >
Reviewed-By: Colin Ihrig <cjihrig@gmail.com >
Reviewed-By: Refael Ackermann <refack@gmail.com >
2018-10-12 20:04:54 -07:00
Gireesh Punathil
d3d6cd3eca
src: improve SSL version extraction logic
...
The openssl version as defined in ssl libraries is complex.
The current logic to extract the major.minor.patch format
uses C semantics to loop through the text and search for
specific patterns. Use C++ string to tidy it up.
PR-URL: https://github.com/nodejs/node/pull/23050
Reviewed-By: Anna Henningsen <anna@addaleax.net >
Reviewed-By: Tobias Nießen <tniessen@tnie.de >
Reviewed-By: Colin Ihrig <cjihrig@gmail.com >
Reviewed-By: Richard Lau <riclau@uk.ibm.com >
Reviewed-By: Refael Ackermann <refack@gmail.com >
Reviewed-By: Sakthipriyan Vairamani <thechargingvolcano@gmail.com >
Reviewed-By: James M Snell <jasnell@gmail.com >
Reviewed-By: Luigi Pinca <luigipinca@gmail.com >
Reviewed-By: Michael Dawson <michael_dawson@ca.ibm.com >
2018-10-11 21:25:52 -07:00
Vitaly Dyatlov
3f08c004c5
src: revert removal of SecureContext _external getter
...
This `_external` getter is essential for some libs to work:
uWebSockets as an example.
PR-URL: https://github.com/nodejs/node/pull/21711
Reviewed-By: Anna Henningsen <anna@addaleax.net >
Reviewed-By: James M Snell <jasnell@gmail.com >
2018-10-11 21:04:55 -07:00
Brandon Smith
13340d47fc
benchmark,doc,lib,src,test,tools: fix typos
...
PR-URL: https://github.com/nodejs/node/pull/23302
Reviewed-By: Gireesh Punathil <gpunathi@in.ibm.com >
Reviewed-By: Colin Ihrig <cjihrig@gmail.com >
Reviewed-By: Rich Trott <rtrott@gmail.com >
Reviewed-By: Vse Mozhet Byt <vsemozhetbyt@gmail.com >
Reviewed-By: Trivikram Kamat <trivikr.dev@gmail.com >
Reviewed-By: James M Snell <jasnell@gmail.com >
Reviewed-By: Sakthipriyan Vairamani <thechargingvolcano@gmail.com >
2018-10-09 16:53:12 +03:00
cjihrig
78b4369f09
src: remove unneeded variables in node_crypto.cc
...
PR-URL: https://github.com/nodejs/node/pull/23297
Reviewed-By: Anna Henningsen <anna@addaleax.net >
Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com >
Reviewed-By: Refael Ackermann <refack@gmail.com >
Reviewed-By: Gabriel Schulhof <gabriel.schulhof@intel.com >
Reviewed-By: Trivikram Kamat <trivikr.dev@gmail.com >
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de >
Reviewed-By: James M Snell <jasnell@gmail.com >
2018-10-09 08:33:15 -04:00
cjihrig
43a1bc30c1
src: fix ToObject() usage in node_crypto.cc
...
PR-URL: https://github.com/nodejs/node/pull/23298
Reviewed-By: Anna Henningsen <anna@addaleax.net >
Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com >
Reviewed-By: Refael Ackermann <refack@gmail.com >
Reviewed-By: James M Snell <jasnell@gmail.com >
2018-10-08 17:42:21 -04:00
Daniel Bevenius
8d218a9bb9
crypto: replace goto SSL_CTX_use_certificate_chain
...
This commit removes the goto statements in SSL_CTX_use_certificate_chain
by using a unique_ptr.
PR-URL: https://github.com/nodejs/node/pull/23113
Reviewed-By: Anna Henningsen <anna@addaleax.net >
Reviewed-By: James M Snell <jasnell@gmail.com >
2018-10-08 05:48:20 +02:00
Daniel Bevenius
a8c145807e
crypto: add virtual dtor to KeyPairGenerationConfig
...
Currently the KeyPairGenerationConfigs class has a virtual function
but no virtual destructor which means that if delete is called on a
KeyPairGenerationConfig pointer to a derived instance, the derived
destructor will not get called.
The following warning is currently being printed when
compiling:
warning: delete called on 'node::crypto::KeyPairGenerationConfig' that
is abstract but has non-virtual destructor [-Wdelete-non-virtual-dtor]
delete __ptr;
This commit adds a virtual destructor.
PR-URL: https://github.com/nodejs/node/pull/23215
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl >
Reviewed-By: Colin Ihrig <cjihrig@gmail.com >
Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com >
Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com >
Reviewed-By: Anna Henningsen <anna@addaleax.net >
Reviewed-By: James M Snell <jasnell@gmail.com >
2018-10-05 05:11:18 +02:00
Anna Henningsen
cc31d8b2d4
src: remove public API for option variables
...
PR-URL: https://github.com/nodejs/node/pull/23069
Reviewed-By: Gus Caplan <me@gus.host >
Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com >
Reviewed-By: James M Snell <jasnell@gmail.com >
Reviewed-By: Shingo Inoue <leko.noor@gmail.com >
Reviewed-By: Refael Ackermann <refack@gmail.com >
2018-10-03 14:08:06 -07:00
Tobias Nießen
ad07e44b37
crypto: make PEM parsing RFC7468-compliant
...
PR-URL: https://github.com/nodejs/node/pull/23164
Fixes: https://github.com/nodejs/node/issues/13612
Fixes: https://github.com/nodejs/node/issues/22815
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl >
Reviewed-By: James M Snell <jasnell@gmail.com >
2018-10-02 12:16:46 +02:00
Tobias Nießen
0a1c65079a
crypto: add support for PEM-level encryption
...
This adds support for PEM-level encryption as defined in RFC 1421.
PEM-level encryption is intentionally unsupported for PKCS#8 private
keys since PKCS#8 defines a newer encryption format.
PR-URL: https://github.com/nodejs/node/pull/23151
Refs: https://github.com/nodejs/node/pull/22660
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl >
Reviewed-By: James M Snell <jasnell@gmail.com >
2018-10-02 11:32:16 +02:00
Daniel Bevenius
8316c6f047
crypto: remove unnecessary calls to TLS_method()
...
PR-URL: https://github.com/nodejs/node/pull/23077
Reviewed-By: Tobias Nießen <tniessen@tnie.de >
Reviewed-By: James M Snell <jasnell@gmail.com >
2018-09-28 09:32:24 +02:00
Jeremy Apthorp
7dae8729aa
crypto: enable auto cert chaining for BoringSSL
...
OpenSSL enables this feature by default, but BoringSSL doesn't. This
change makes it so that when building node with BoringSSL, the
behaviour matches OpenSSL's.
PR-URL: https://github.com/nodejs/node/pull/22110
Reviewed-By: Tobias Nießen <tniessen@tnie.de >
Reviewed-By: Ujjwal Sharma <usharma1998@gmail.com >
Reviewed-By: James M Snell <jasnell@gmail.com >
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl >
2018-09-27 19:35:50 +02:00
Tobias Nießen
b7bdde013a
crypto: deduplicate cipher initialization code
...
CipherBase::Init and CipherBase::InitIv contain a lot of duplicate
code, this commit moves that into a separate function.
PR-URL: https://github.com/nodejs/node/pull/23011
Reviewed-By: Anna Henningsen <anna@addaleax.net >
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl >
Reviewed-By: James M Snell <jasnell@gmail.com >
Reviewed-By: Ujjwal Sharma <usharma1998@gmail.com >
2018-09-26 05:27:02 +02:00
Tobias Nießen
3eb2adbb8e
crypto: remove unnecessary usage of goto
...
The control flow can easily be refactored to use break instead of
goto.
PR-URL: https://github.com/nodejs/node/pull/23018
Reviewed-By: Anna Henningsen <anna@addaleax.net >
Reviewed-By: Michaël Zasso <targos@protonmail.com >
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl >
Reviewed-By: Colin Ihrig <cjihrig@gmail.com >
Reviewed-By: James M Snell <jasnell@gmail.com >
Reviewed-By: Luigi Pinca <luigipinca@gmail.com >
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de >
2018-09-25 05:33:58 +02:00
Andreas Haas
7dde560beb
src: replace deprecated uses of FunctionTemplate::GetFunction
...
PR-URL: https://github.com/nodejs/node/pull/22993
Reviewed-By: Michaël Zasso <targos@protonmail.com >
Reviewed-By: Colin Ihrig <cjihrig@gmail.com >
Reviewed-By: Ujjwal Sharma <usharma1998@gmail.com >
Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com >
Reviewed-By: Eugene Ostroukhov <eostroukhov@google.com >
Reviewed-By: Anna Henningsen <anna@addaleax.net >
Reviewed-By: James M Snell <jasnell@gmail.com >
2018-09-24 05:44:28 +02:00
Tobias Nießen
058c5b81cd
crypto: do not allow multiple calls to setAuthTag
...
Calling setAuthTag multiple times can result in hard to detect bugs
since to the user, it is unclear which invocation actually affected
OpenSSL.
PR-URL: https://github.com/nodejs/node/pull/22931
Reviewed-By: Anna Henningsen <anna@addaleax.net >
Reviewed-By: James M Snell <jasnell@gmail.com >
Reviewed-By: Ujjwal Sharma <usharma1998@gmail.com >
2018-09-21 11:40:35 +02:00
Tobias Nießen
8c502f54ce
crypto: add API for key pair generation
...
This adds support for RSA, DSA and EC key pair generation with a
variety of possible output formats etc.
PR-URL: https://github.com/nodejs/node/pull/22660
Fixes: https://github.com/nodejs/node/issues/15116
Reviewed-By: Matteo Collina <matteo.collina@gmail.com >
Reviewed-By: Anna Henningsen <anna@addaleax.net >
Reviewed-By: James M Snell <jasnell@gmail.com >
Reviewed-By: Ujjwal Sharma <usharma1998@gmail.com >
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl >
2018-09-20 14:31:14 +02:00
Tobias Nießen
a9e7369b11
crypto: fix edge case in authenticated encryption
...
Restricting the authentication tag length and calling update or
setAAD before setAuthTag caused an incorrect authentication tag to
be passed to OpenSSL: The auth_tag_len_ field was already set, so
the implementation assumed that the tag itself was known as well.
PR-URL: https://github.com/nodejs/node/pull/22828
Reviewed-By: Daniel Bevenius <daniel.bevenius@gmail.com >
2018-09-18 12:55:07 +02:00
Tobias Nießen
711445b419
crypto: fix public key encryption internals
...
Coincidentally, the old version works as well since the padding
parameter is never null, but it is semantically incorrect.
PR-URL: https://github.com/nodejs/node/pull/22780
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de >
Reviewed-By: Luigi Pinca <luigipinca@gmail.com >
Reviewed-By: Colin Ihrig <cjihrig@gmail.com >
Reviewed-By: James M Snell <jasnell@gmail.com >
Reviewed-By: Anna Henningsen <anna@addaleax.net >
2018-09-12 22:33:35 +02:00
Ujjwal Sharma and Michaël Zasso
f464ac3c74
src: remove calls to deprecated v8 functions (IntegerValue)
...
Remove all calls to deprecated v8 functions (here:
Value::IntegerValue) inside the code (src directory only).
Co-authored-by: Michaël Zasso <targos@protonmail.com >
PR-URL: https://github.com/nodejs/node/pull/22129
Reviewed-By: Anna Henningsen <anna@addaleax.net >
2018-09-05 13:42:38 +02:00
Michaël Zasso
594a84d8f2
src: remove calls to deprecated V8 functions (Int32Value)
...
Remove all calls to deprecated V8 functions (here: Value::Int32Value)
inside the code.
PR-URL: https://github.com/nodejs/node/pull/22662
Reviewed-By: Anna Henningsen <anna@addaleax.net >
Reviewed-By: Minwoo Jung <minwoo@nodesource.com >
Reviewed-By: James M Snell <jasnell@gmail.com >
Reviewed-By: Ujjwal Sharma <usharma1998@gmail.com >
2018-09-05 12:59:25 +02:00
Ujjwal Sharma
37cd10a116
src: remove calls to deprecated v8 functions (Uint32Value)
...
Remove all calls to deprecated v8 functions (here:
Value::Uint32Value) inside the code (src directory only).
PR-URL: https://github.com/nodejs/node/pull/22143
Reviewed-By: Anna Henningsen <anna@addaleax.net >
Reviewed-By: Denys Otrishko <shishugi@gmail.com >
2018-09-02 16:32:15 +02:00
Ujjwal Sharma and Michaël Zasso
a55c57b8c4
src: rework (mostly internal) functions to use Maybes
...
Rework all affected functions to use Maybes, thus improving error
handling substantially in internal functions, API functions as well as
utilities.
Co-authored-by: Michaël Zasso <targos@protonmail.com >
PR-URL: https://github.com/nodejs/node/pull/21935
Reviewed-By: James M Snell <jasnell@gmail.com >
Reviewed-By: Anna Henningsen <anna@addaleax.net >
2018-09-02 14:25:16 +02:00
Tobias Nießen
b4026099c3
crypto: improve setAuthTag
...
This is an attempt to make the behavior of setAuthTag match the
documentation: In GCM mode, it can be called at any time before
invoking final, even after the last call to update.
Fixes: https://github.com/nodejs/node/issues/22421
PR-URL: https://github.com/nodejs/node/pull/22538
Reviewed-By: Anna Henningsen <anna@addaleax.net >
2018-09-02 13:56:25 +02:00
Ujjwal Sharma
59e5a39d30
src: remove calls to deprecated v8 functions (BooleanValue)
...
Remove all calls to deprecated v8 functions (here:
Value::BooleanValue) inside the code (src directory only).
PR-URL: https://github.com/nodejs/node/pull/22075
Reviewed-By: Anna Henningsen <anna@addaleax.net >
Reviewed-By: James M Snell <jasnell@gmail.com >
2018-09-01 20:37:08 +02:00
Tobias Nießen
83f319cb3b
crypto: deduplicate public key parsing
...
PR-URL: https://github.com/nodejs/node/pull/22553
Reviewed-By: Anna Henningsen <anna@addaleax.net >
2018-08-31 19:05:35 +02:00
Daniel Bevenius
bf5cc3bf1a
crypto: move process.binding('crypto') to internal
...
This commit makes the crypto builtin an internal builtin, and
changes usage of the builtin from using process.binding('crypto')
to use internalBinding instead.
Refs: https://github.com/nodejs/node/issues/22160
PR-URL: https://github.com/nodejs/node/pull/22426
Reviewed-By: James M Snell <jasnell@gmail.com >
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de >
Reviewed-By: Trivikram Kamat <trivikr.dev@gmail.com >
Reviewed-By: Anna Henningsen <anna@addaleax.net >
2018-08-24 00:49:29 +02:00
Anna Henningsen
29a71bae40
src: refactor options parsing
...
This is a major refactor of our Node’s parser. See `node_options.cc`
for how it is used, and `node_options-inl.h` for the bulk
of its implementation.
Unfortunately, the implementation has come to have some
complexity, in order to meet the following goals:
- Make it easy to *use* for defining or changing options.
- Keep it (mostly) backwards-compatible.
- No tests were harmed as part of this commit.
- Be as consistent as possible.
- In particular, options can now generally accept arguments
through both `--foo=bar` notation and `--foo bar` notation.
We were previously very inconsistent on this point.
- Separate into different levels of scope, namely
per-process (global), per-Isolate and per-Environment
(+ debug options).
- Allow programmatic accessibility in the future.
- This includes a possible expansion for `--help` output.
This commit also leaves a number of `TODO` comments, mostly for
improving consistency even more (possibly with having to modify
tests), improving embedder support, as well as removing pieces of
exposed configuration variables that should never have become
part of the public API but unfortunately are at this point.
PR-URL: https://github.com/nodejs/node/pull/22392
Reviewed-By: Matteo Collina <matteo.collina@gmail.com >
Reviewed-By: Refael Ackermann <refack@gmail.com >
Reviewed-By: James M Snell <jasnell@gmail.com >
Reviewed-By: Gus Caplan <me@gus.host >
2018-08-22 23:37:19 +02:00
Anna Henningsen
40ae307071
src: avoid possible race during NodeBIO initialization
...
PR-URL: https://github.com/nodejs/node/pull/21984
Reviewed-By: Anatoli Papirovski <apapirovski@mac.com >
Reviewed-By: James M Snell <jasnell@gmail.com >
2018-08-12 03:58:49 -07:00
Anna Henningsen
987dc07111
src: use smart pointers for NodeBIO
...
PR-URL: https://github.com/nodejs/node/pull/21984
Reviewed-By: Anatoli Papirovski <apapirovski@mac.com >
Reviewed-By: James M Snell <jasnell@gmail.com >
2018-08-12 03:58:37 -07:00
Jon Moss
640dc7a474
crypto: remove unused SSLWrap handle methods
...
One was not used at all, and the other was only used in a test, which I
converted to use the more standard `ShutdownWrap` API.
PR-URL: https://github.com/nodejs/node/pull/22216
Reviewed-By: Anna Henningsen <anna@addaleax.net >
Reviewed-By: Tobias Nießen <tniessen@tnie.de >
Reviewed-By: James M Snell <jasnell@gmail.com >
Reviewed-By: Colin Ihrig <cjihrig@gmail.com >
2018-08-11 20:22:10 -04:00
Tobias Nießen
4253e5583b
tls: preallocate SSL cipher array
...
PR-URL: https://github.com/nodejs/node/pull/22136
Reviewed-By: Anna Henningsen <anna@addaleax.net >
Reviewed-By: Colin Ihrig <cjihrig@gmail.com >
Reviewed-By: Matteo Collina <matteo.collina@gmail.com >
2018-08-09 16:07:50 +02:00
Tobias Nießen
77ac9628b3
crypto: simplify state failure handling
...
It is more intuitive to return true/false instead of undefined/false
and also simplifies handling in the JS layer.
PR-URL: https://github.com/nodejs/node/pull/22131
Reviewed-By: Jon Moss <me@jonathanmoss.me >
Reviewed-By: Luigi Pinca <luigipinca@gmail.com >
Reviewed-By: Ujjwal Sharma <usharma1998@gmail.com >
2018-08-08 12:05:23 -07:00
Tobias Nießen
7e29453d2f
crypto: simplify Hmac::HmacUpdate
...
This makes HmacUpdate slightly simpler and introduces a CHECK instead
of ignoring invalid input types.
PR-URL: https://github.com/nodejs/node/pull/22132
Reviewed-By: Jon Moss <me@jonathanmoss.me >
Reviewed-By: Luigi Pinca <luigipinca@gmail.com >
Reviewed-By: Ujjwal Sharma <usharma1998@gmail.com >
Reviewed-By: Colin Ihrig <cjihrig@gmail.com >
2018-08-08 12:03:06 -07:00
Ujjwal Sharma
35ec9b247e
src: remove calls to deprecated v8 functions (NewFromUtf8)
...
Remove all calls to deprecated v8 functions (here: String::NewFromUtf8) inside
the code (src directory only).
PR-URL: https://github.com/nodejs/node/pull/21926
Reviewed-By: Anna Henningsen <anna@addaleax.net >
Reviewed-By: Tobias Nießen <tniessen@tnie.de >
Reviewed-By: Anatoli Papirovski <apapirovski@mac.com >
Reviewed-By: James M Snell <jasnell@gmail.com >
2018-07-29 16:59:31 +02:00
Tobias Nießen
b3f459e6cf
crypto: add support for OCB mode for AEAD
...
PR-URL: https://github.com/nodejs/node/pull/21447
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl >
Reviewed-By: James M Snell <jasnell@gmail.com >
2018-07-18 13:10:10 +02:00
Anna Henningsen
57e301539b
src: enable more detailed memory tracking
...
This will enable more detailed heap snapshots based on
a newer V8 API.
This commit itself is not tied to that API and could
be backported.
PR-URL: https://github.com/nodejs/node/pull/21742
Reviewed-By: James M Snell <jasnell@gmail.com >
2018-07-13 19:53:15 +02:00
Tobias Nießen
85b0f1649d
crypto: handle OpenSSL error queue in CipherBase
...
This handles all errors produced by OpenSSL within the CipherBase
class. API functions ensure that they do not add any new errors to the
error queue. Also adds a couple of CHECKs and throws under certain
conditions.
PR-URL: https://github.com/nodejs/node/pull/21288
Fixes: https://github.com/nodejs/node/issues/21281
Refs: https://github.com/nodejs/node/pull/21287
Reviewed-By: Ujjwal Sharma <usharma1998@gmail.com >
2018-07-12 16:02:01 +02:00
Brian White
a15ea5d7ca
tls: throw error on bad ciphers option
...
PR-URL: https://github.com/nodejs/node/pull/21557
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl >
Reviewed-By: Matteo Collina <matteo.collina@gmail.com >
Reviewed-By: Colin Ihrig <cjihrig@gmail.com >
Reviewed-By: James M Snell <jasnell@gmail.com >
Reviewed-By: Tiancheng "Timothy" Gu <timothygu99@gmail.com >
2018-07-03 16:30:30 -04:00
Timothy Gu
65f617314d
src: start annotating native code side effect
...
PR-URL: https://github.com/nodejs/node/pull/21458
Refs: https://github.com/nodejs/node/issues/20977
Reviewed-By: Anna Henningsen <anna@addaleax.net >
Reviewed-By: Gus Caplan <me@gus.host >
Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com >
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl >
Reviewed-By: Colin Ihrig <cjihrig@gmail.com >
Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com >
Reviewed-By: James M Snell <jasnell@gmail.com >
2018-06-25 23:15:35 -04:00
Ben Noordhuis
19fe5299d3
crypto: fix UB in computing max message size
...
Before this commit it computed `(1<<(8*(15-iv_len)))-1` for `iv_len>=11`
and that reduces to `(1<<32)-1` for `iv_len==11`. Left-shifting past
the sign bit and overflowing a signed integral type are both undefined
behaviors.
This commit switches to fixed values and restricts the `iv_len==11`
case to `INT_MAX`, as was already the case for all `iv_len<=10`.
PR-URL: https://github.com/nodejs/node/pull/21462
Reviewed-By: Colin Ihrig <cjihrig@gmail.com >
Reviewed-By: James M Snell <jasnell@gmail.com >
Reviewed-By: Tobias Nießen <tniessen@tnie.de >
2018-06-25 23:45:14 +02:00
Timothy Gu
6396574cde
crypto: remove outdated comment
...
PR-URL: https://github.com/nodejs/node/pull/21511
Fixes: https://github.com/nodejs/node/issues/21488
Reviewed-By: Michaël Zasso <targos@protonmail.com >
Reviewed-By: Colin Ihrig <cjihrig@gmail.com >
2018-06-24 18:02:10 -04:00
Tobias Nießen
a703df9785
crypto: fix behavior of createCipher in wrap mode
...
The old implementation silently failed in EVP_CipherInit_ex in
EVP_CIPH_WRAP_MODE, this commit should fix that.
PR-URL: https://github.com/nodejs/node/pull/21287
Reviewed-By: Ujjwal Sharma <usharma1998@gmail.com >
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl >
Reviewed-By: James M Snell <jasnell@gmail.com >
2018-06-15 17:58:52 +02:00
Ben Noordhuis
078bb0f0a0
crypto: refactor randomBytes()
...
Use the scrypt() infrastructure to reimplement randomBytes() and
randomFill() in a simpler manner.
PR-URL: https://github.com/nodejs/node/pull/20816
Reviewed-By: Anna Henningsen <anna@addaleax.net >
Reviewed-By: Colin Ihrig <cjihrig@gmail.com >
Reviewed-By: James M Snell <jasnell@gmail.com >
Reviewed-By: Tobias Nießen <tniessen@tnie.de >
2018-06-13 15:58:59 +02:00
Ben Noordhuis
c188cc5338
crypto: refactor pbkdf2() and pbkdf2Sync() methods
...
Use the scrypt() infrastructure to reimplement pbkdf2() in a simpler
manner.
PR-URL: https://github.com/nodejs/node/pull/20816
Reviewed-By: Anna Henningsen <anna@addaleax.net >
Reviewed-By: Colin Ihrig <cjihrig@gmail.com >
Reviewed-By: James M Snell <jasnell@gmail.com >
Reviewed-By: Tobias Nießen <tniessen@tnie.de >
2018-06-13 15:58:56 +02:00
Ben Noordhuis
371103dae8
crypto: add scrypt() and scryptSync() methods
...
Scrypt is a password-based key derivation function that is designed to
be expensive both computationally and memory-wise in order to make
brute-force attacks unrewarding.
OpenSSL has had support for the scrypt algorithm since v1.1.0. Add a
Node.js API modeled after `crypto.pbkdf2()` and `crypto.pbkdf2Sync()`.
Changes:
* Introduce helpers for copying buffers, collecting openssl errors, etc.
* Add new infrastructure for offloading crypto to a worker thread.
* Add a `AsyncWrap` JS class to simplify pbkdf2(), randomBytes() and
scrypt().
Fixes: https://github.com/nodejs/node/issues/8417
PR-URL: https://github.com/nodejs/node/pull/20816
Reviewed-By: Anna Henningsen <anna@addaleax.net >
Reviewed-By: Colin Ihrig <cjihrig@gmail.com >
Reviewed-By: James M Snell <jasnell@gmail.com >
Reviewed-By: Tobias Nießen <tniessen@tnie.de >
2018-06-13 15:58:45 +02:00
Ben Noordhuis
a76f029818
lib,src: remove openssl feature conditionals
...
Remove compile-time and run-time conditionals for features that
OpenSSL 1.0.0 and 1.0.1 didn't support: ALPN, OCSP and/or SNI.
They are no longer necessary since our baseline is OpenSSL 1.0.2.
PR-URL: https://github.com/nodejs/node/pull/21094
Reviewed-By: Anna Henningsen <anna@addaleax.net >
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de >
Reviewed-By: James M Snell <jasnell@gmail.com >
Reviewed-By: Tobias Nießen <tniessen@tnie.de >
Reviewed-By: Trivikram Kamat <trivikr.dev@gmail.com >
Reviewed-By: Colin Ihrig <cjihrig@gmail.com >
2018-06-08 00:53:37 +02:00
Daniel Bevenius
cbc3dd997e
src, tools: add check for left leaning pointers
...
This commit adds a rule to cpplint to check that pointers in the code
base lean to the left and not right, and also fixes the violations
reported.
PR-URL: https://github.com/nodejs/node/pull/21010
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl >
Reviewed-By: Anna Henningsen <anna@addaleax.net >
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de >
Reviewed-By: James M Snell <jasnell@gmail.com >
2018-06-07 05:46:51 +02:00
Tobias Nießen
faf449ca04
crypto: throw in setAuthTag on invalid length
...
The current implementation performs limited checks only and silently
ignores superfluous bytes of the authentication tag. This change makes
setAuthTag throw when
- the user-specified authTagLength does not match the actual tag length,
especially when the authentication tag is longer than 16 bytes, and
when
- the mode is GCM, no authTagLength option has been specified and the
tag length is not a valid GCM tag length.
This change makes the conditional assignment in SetAuthTag unnecessary,
which is replaced with a CHECK.
Refs: https://github.com/nodejs/node/pull/17825
PR-URL: https://github.com/nodejs/node/pull/20040
Reviewed-By: Daniel Bevenius <daniel.bevenius@gmail.com >
Reviewed-By: Yihong Wang <yh.wang@ibm.com >
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl >
Reviewed-By: James M Snell <jasnell@gmail.com >
2018-06-01 09:52:27 +02:00