Filip Skokan
8fa5954569
crypto: use EVP_MAC for HMAC on OpenSSL >=3
...
Closes: https://github.com/nodejs/node/issues/59493
Signed-off-by: Filip Skokan <panva.ip@gmail.com >
PR-URL: https://github.com/nodejs/node/pull/63942
Fixes: https://github.com/nodejs/node/issues/59493
Reviewed-By: Yagiz Nizipli <yagiz@nizipli.com >
Reviewed-By: James M Snell <jasnell@gmail.com >
2026-06-19 07:50:57 +00:00
Filip Skokan
0ed1d94aff
src: simplify OpenSSL feature gates
...
Add OPENSSL_WITH_* feature macros for crypto capabilities that vary by
OpenSSL version and use those instead of repeating version checks.
Signed-off-by: Filip Skokan <panva.ip@gmail.com >
PR-URL: https://github.com/nodejs/node/pull/63255
Refs: https://github.com/electron/electron/issues/36256
Refs: https://github.com/electron/electron/issues/41720
Refs: https://github.com/electron/electron/pull/51127
Reviewed-By: James M Snell <jasnell@gmail.com >
Reviewed-By: Yagiz Nizipli <yagiz@nizipli.com >
2026-05-17 18:18:09 +00:00
Filip Skokan
c29a34cd48
crypto: add JWK support for ML-KEM and SLH-DSA key types
...
Signed-off-by: Filip Skokan <panva.ip@gmail.com >
PR-URL: https://github.com/nodejs/node/pull/62706
Reviewed-By: Tobias Nießen <tniessen@tnie.de >
Reviewed-By: Yagiz Nizipli <yagiz@nizipli.com >
2026-04-21 17:32:23 +00:00
Filip Skokan
e0cab9dcf7
crypto: add TurboSHAKE and KangarooTwelve Web Cryptography algorithms
...
PR-URL: https://github.com/nodejs/node/pull/62183
Refs: https://wicg.github.io/webcrypto-modern-algos/#kangarootwelve
Refs: https://wicg.github.io/webcrypto-modern-algos/#turboshake
Refs: https://www.rfc-editor.org/rfc/rfc9861.html
Refs: https://redirect.github.com/openssl/openssl/issues/30304
Reviewed-By: Anna Henningsen <anna@addaleax.net >
Reviewed-By: Yagiz Nizipli <yagiz@nizipli.com >
2026-03-26 22:04:32 +01:00
Filip Skokan
14c68e3b53
crypto: add KMAC Web Cryptography algorithms
...
PR-URL: https://github.com/nodejs/node/pull/59647
Reviewed-By: Anna Henningsen <anna@addaleax.net >
Reviewed-By: James M Snell <jasnell@gmail.com >
2025-09-06 22:43:15 +00:00
Filip Skokan
f8d68d30ae
crypto: support ML-KEM, DHKEM, and RSASVE key encapsulation mechanisms
...
PR-URL: https://github.com/nodejs/node/pull/59491
Reviewed-By: Yagiz Nizipli <yagiz@nizipli.com >
Reviewed-By: Tobias Nießen <tniessen@tnie.de >
Reviewed-By: Rafael Gonzaga <rafael.nunu@hotmail.com >
2025-08-20 14:30:58 +00:00
bdcab711b8
crypto: add argon2() and argon2Sync() methods
...
Co-authored-by: Filip Skokan <panva.ip@gmail.com >
Co-authored-by: James M Snell <jasnell@gmail.com >
PR-URL: https://github.com/nodejs/node/pull/50353
Reviewed-By: Ethan Arrowood <ethan@arrowood.dev >
Reviewed-By: Filip Skokan <panva.ip@gmail.com >
Reviewed-By: Yagiz Nizipli <yagiz@nizipli.com >
2025-08-19 19:30:38 +00:00
Filip Skokan
84aaed7597
crypto: add ChaCha20-Poly1305 Web Cryptography algorithm
...
PR-URL: https://github.com/nodejs/node/pull/59365
Reviewed-By: James M Snell <jasnell@gmail.com >
Reviewed-By: Ethan Arrowood <ethan@arrowood.dev >
Reviewed-By: Yagiz Nizipli <yagiz@nizipli.com >
Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com >
2025-08-19 15:57:08 +02:00
Filip Skokan
24e28c41b5
crypto: support ML-DSA KeyObject, sign, and verify
...
PR-URL: https://github.com/nodejs/node/pull/59259
Reviewed-By: Yagiz Nizipli <yagiz@nizipli.com >
Reviewed-By: Ethan Arrowood <ethan@arrowood.dev >
Reviewed-By: James M Snell <jasnell@gmail.com >
2025-08-06 21:49:30 +00:00
Tobias Nießen
3e6e9084be
src: refactor DH groups to delete crypto_groups.h
...
Rewrite FindDiffieHellmanGroup() using OpenSSL helper functions to
obtain the required constants directly, instead of loading them from
our own crypto_groups.h and converting them to BIGNUMs.
This also removes the need for the struct modp_group, so we can delete
crypto_groups.h altogether.
PR-URL: https://github.com/nodejs/node/pull/43896
Reviewed-By: Filip Skokan <panva.ip@gmail.com >
2022-07-25 19:37:14 +01:00
Tobias Nießen
7394311a2e
src: rename crypto_ecdh.(h|cc) to crypto_ec.(h|cc)
...
PR-URL: https://github.com/nodejs/node/pull/37048
Reviewed-By: Colin Ihrig <cjihrig@gmail.com >
Reviewed-By: James M Snell <jasnell@gmail.com >
Reviewed-By: Anna Henningsen <anna@addaleax.net >
Reviewed-By: Luigi Pinca <luigipinca@gmail.com >
2021-01-25 08:11:25 -08:00
James M Snell
f5287a4b7b
crypto: introduce X509Certificate API
...
Introduces the `crypto.X509Certificate` object.
```js
const { X509Certificate } = require('crypto');
const x509 = new X509Certificate('{pem encoded cert}');
console.log(x509.subject);
```
Fixes: https://github.com/nodejs/node/issues/29181
Signed-off-by: James M Snell <jasnell@gmail.com >
PR-URL: https://github.com/nodejs/node/pull/36804
Reviewed-By: Anna Henningsen <anna@addaleax.net >
Reviewed-By: Filip Skokan <panva.ip@gmail.com >
2021-01-09 12:04:23 -08:00
James M Snell
bfc906906f
src: combine TLSWrap/SSLWrap
...
SSLWrap was needlessly defined as a template class, splitting the
TLS implementation over multiple locations. The original idea, I
surmise, was to make it possible to reuse SSLWrap for some other
purpose that never manifest. This squashes them down into a single
TLSWrap class and moves tls_wrap.h/cc into src/crypto.
Signed-off-by: James M Snell <jasnell@gmail.com >
PR-URL: https://github.com/nodejs/node/pull/35552
Reviewed-By: Alba Mendez <me@alba.sh >
2020-10-15 09:20:27 -07:00
James M Snell
dae283d96f
crypto: refactoring internals, add WebCrypto
...
Fixes: https://github.com/nodejs/node/issues/678
Refs: https://github.com/nodejs/node/issues/26854
Signed-off-by: James M Snell <jasnell@gmail.com >
PR-URL: https://github.com/nodejs/node/pull/35093
Reviewed-By: Matteo Collina <matteo.collina@gmail.com >
Reviewed-By: Anna Henningsen <anna@addaleax.net >
Reviewed-By: Michaël Zasso <targos@protonmail.com >
Reviewed-By: Rich Trott <rtrott@gmail.com >
2020-10-07 17:27:05 -07:00
James M Snell
ba77dc8597
crypto: move node_crypto files to src/crypto
...
Signed-off-by: James M Snell <jasnell@gmail.com >
PR-URL: https://github.com/nodejs/node/pull/35093
Reviewed-By: Matteo Collina <matteo.collina@gmail.com >
Reviewed-By: Anna Henningsen <anna@addaleax.net >
Reviewed-By: Michaël Zasso <targos@protonmail.com >
Reviewed-By: Rich Trott <rtrott@gmail.com >
2020-10-07 17:27:01 -07:00
Anna Henningsen
f5c7aa0c82
crypto: fix KeyObject garbage collection
...
These objects don’t hold any resources on the event loop, so they
should be weak objects that can be garbage collected when nothing
refers to them anymore.
PR-URL: https://github.com/nodejs/node/pull/35481
Reviewed-By: James M Snell <jasnell@gmail.com >
Reviewed-By: Colin Ihrig <cjihrig@gmail.com >
2020-10-03 22:46:01 +02:00
ThakurKarthik
a8556dae16
crypto: set env values in KeyObject Deserialize method
...
Fixes: https://github.com/nodejs/node/issues/35263
PR-URL: https://github.com/nodejs/node/pull/35416
Reviewed-By: Anna Henningsen <anna@addaleax.net >
Reviewed-By: Rich Trott <rtrott@gmail.com >
2020-10-03 16:55:15 +02:00
Daniel Bevenius
67ba825037
src: fix minor comment typo in KeyObjectData
...
PR-URL: https://github.com/nodejs/node/pull/34167
Reviewed-By: Anna Henningsen <anna@addaleax.net >
Reviewed-By: Richard Lau <riclau@uk.ibm.com >
Reviewed-By: Tobias Nießen <tniessen@tnie.de >
Reviewed-By: David Carlier <devnexen@gmail.com >
2020-07-06 06:39:26 +02:00
Tobias Nießen and Anna Henningsen
7b019fd3c9
crypto: allow KeyObjects in postMessage
...
This change allows sharing KeyObjects between threads via postMessage.
The receiver acquires a new KeyObject and a new KeyObjectHandle, but
refers to the same KeyObjectData:
+-------------------+
| NativeKeyObject 1 | ------------------------------------------+
+-------------------+ |
^ |
extends |
| |
+-------------------+ +-------------------+ |
| KeyObject 1 (JS) | -> | KeyObjectHandle 1 | --------------+ |
+-------------------+ +-------------------+ | |
| |
| |
| |
| |
| |
+-------------------+ | |
| NativeKeyObject 2 | ------------------------------------+ | |
+-------------------+ | | |
^ | | |
extends | | |
| | | |
+-------------------+ +-------------------+ | | |
| KeyObject 2 (JS) | -> | KeyObjectHandle 2 | --------+ | | |
+-------------------+ +-------------------+ | | | |
| | | |
| | | |
| | | |
| | | |
| | | |
+-------------------+ | | | |
| NativeKeyObject 3 | ------------------------------+ | | | |
+-------------------+ | | | | |
^ | | | | |
extends | | | | |
| v v v v v
+-------------------+ +-------------------+ +---------------+
| KeyObject 3 (JS) | -> | KeyObjectHandle 3 | -> | KeyObjectData |
+-------------------+ +-------------------+ +---------------+
Co-authored-by: Anna Henningsen <anna@addaleax.net >
PR-URL: https://github.com/nodejs/node/pull/33360
Reviewed-By: Anna Henningsen <anna@addaleax.net >
Reviewed-By: James M Snell <jasnell@gmail.com >
2020-06-22 20:50:38 +02:00
Tobias Nießen
7f185ec3c4
src: store key data in separate class
...
This separates key handles from the actual key data:
+-----------------+
| NativeKeyObject |
+-----------------+
^
extends
|
+-----------------+ +-----------------+ +---------------+
| KeyObject (JS) | -> | KeyObjectHandle | -> | KeyObjectData |
+-----------------+ +-----------------+ +---------------+
PR-URL: https://github.com/nodejs/node/pull/33360
Reviewed-By: Anna Henningsen <anna@addaleax.net >
Reviewed-By: James M Snell <jasnell@gmail.com >
2020-06-22 20:50:36 +02:00
Tobias Nießen
5489f19093
src: add NativeKeyObject base class
...
+---------------------+
| BaseObject |
+---------------------+
|
|
|
+---------------------+
| NativeKeyObject |
+---------------------+
|
|
|
+---------------------+
| KeyObject |
+---------------------+
/ \
/ \
/ \
/ \
+---------------------+ +---------------------+
| SecretKeyObject | | AsymmetricKeyObject |
+---------------------+ +---------------------+
/ \
/ \
/ \
/ \
+---------------------+ +---------------------+
| PublicKeyObject | | PrivateKeyObject |
+---------------------+ +---------------------+
PR-URL: https://github.com/nodejs/node/pull/33360
Reviewed-By: Anna Henningsen <anna@addaleax.net >
Reviewed-By: James M Snell <jasnell@gmail.com >
2020-06-22 20:50:34 +02:00
Tobias Nießen
1e27e0a4db
src: rename internal key handles to KeyObjectHandle
...
PR-URL: https://github.com/nodejs/node/pull/33360
Reviewed-By: Anna Henningsen <anna@addaleax.net >
Reviewed-By: James M Snell <jasnell@gmail.com >
2020-06-22 20:50:31 +02:00
James M Snell
56ff1ee55a
src: extract AllocatedBuffer from env.h
...
Cleanup up env.h by removing things that are not
specific to `Environment`.
PR-URL: https://github.com/nodejs/node/pull/33291
Reviewed-By: Anna Henningsen <anna@addaleax.net >
Reviewed-By: David Carlier <devnexen@gmail.com >
2020-05-30 16:20:00 -07:00
James M Snell
dd8183632d
src: add node_crypto_common and refactor
...
Two things in one on this commit:
(a) For the QUIC implementation, we need to separate out various bits
from node_crypto.cc to allow them to be reused. That's where this
commit starts.
(b) Quite a bit of the node_crypto.cc code was just messy in terms of
it's organization and lack of error handling and use of Local vs.
MaybeLocal. This cleans that up a bit and hopefully makes certain
parts a bit more manageable also.
Signed-off-by: James M Snell <jasnell@gmail.com >
PR-URL: https://github.com/nodejs/node/pull/32016
Reviewed-By: Anna Henningsen <anna@addaleax.net >
Reviewed-By: Sam Roberts <vieuxtech@gmail.com >
2020-03-02 16:27:19 -08:00
Anna Henningsen
2035e3d6cb
src: move BaseObject subclass dtors/ctors out of node_crypto.h
...
Originally landed in the QUIC repo
Move constructor and destructors for subclasses of `BaseObject`
from node_crypto.h to node_crypto.cc. This removes the need to
include base_object-inl.h when using node_crypto.h in some cases.
Original review metadata:
```
PR-URL: https://github.com/nodejs/quic/pull/220
Reviewed-By: Anna Henningsen <anna@addaleax.net >
Reviewed-By: James M Snell <jasnell@gmail.com >
```
PR-URL: https://github.com/nodejs/node/pull/31872
Reviewed-By: Sam Roberts <vieuxtech@gmail.com >
Reviewed-By: David Carlier <devnexen@gmail.com >
Reviewed-By: Colin Ihrig <cjihrig@gmail.com >
Reviewed-By: Denys Otrishko <shishugi@gmail.com >
Reviewed-By: Tobias Nießen <tniessen@tnie.de >
2020-02-24 07:55:49 -08:00
simon
341c06f088
tls: expose SSL_export_keying_material
...
Fixes: https://github.com/nodejs/node/issues/31802
PR-URL: https://github.com/nodejs/node/pull/31814
Reviewed-By: Anna Henningsen <anna@addaleax.net >
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl >
Reviewed-By: James M Snell <jasnell@gmail.com >
Reviewed-By: Tobias Nießen <tniessen@tnie.de >
2020-02-23 01:21:04 -04:00
Tobias Nießen
0e63a079e8
crypto: fix ieee-p1363 for createVerify
...
Fixes: https://github.com/nodejs/node/issues/31866
PR-URL: https://github.com/nodejs/node/pull/31876
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl >
Reviewed-By: Colin Ihrig <cjihrig@gmail.com >
Reviewed-By: James M Snell <jasnell@gmail.com >
2020-02-22 22:09:55 -04:00
Rosen Penev
4e11920251
src: don't use deprecated OpenSSL APIs
...
The extra headers are needed when deprecated APIs are disabled as ssl.h
no longer includes them implicitly.
PR-URL: https://github.com/nodejs/node/pull/30812
Reviewed-By: Sam Roberts <vieuxtech@gmail.com >
Reviewed-By: James M Snell <jasnell@gmail.com >
Reviewed-By: Rich Trott <rtrott@gmail.com >
Reviewed-By: David Carlier <devnexen@gmail.com >
Reviewed-By: Colin Ihrig <cjihrig@gmail.com >
2019-12-07 22:47:43 +01:00
Tobias Nießen
f6a4a36f09
crypto: automatically manage memory for ECDSA_SIG
...
Refs: https://github.com/nodejs/node/pull/29292
PR-URL: https://github.com/nodejs/node/pull/30641
Reviewed-By: Colin Ihrig <cjihrig@gmail.com >
Reviewed-By: David Carlier <devnexen@gmail.com >
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl >
Reviewed-By: Anna Henningsen <anna@addaleax.net >
2019-11-30 01:22:50 +01:00
Anna Henningsen
f0181d9980
src: inline SetSNICallback
...
Refs: https://github.com/nodejs/node/pull/30548#discussion_r348168855
PR-URL: https://github.com/nodejs/node/pull/30548
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl >
Reviewed-By: David Carlier <devnexen@gmail.com >
Reviewed-By: James M Snell <jasnell@gmail.com >
Reviewed-By: Tobias Nießen <tniessen@tnie.de >
2019-11-30 01:14:47 +01:00
Anna Henningsen
c5a31992b3
src: use BaseObjectPtr to store SNI context
...
Rather than relying on a link to the JS object, store a pointer to
the C++ object directly.
PR-URL: https://github.com/nodejs/node/pull/30548
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl >
Reviewed-By: David Carlier <devnexen@gmail.com >
Reviewed-By: James M Snell <jasnell@gmail.com >
Reviewed-By: Tobias Nießen <tniessen@tnie.de >
2019-11-30 01:14:46 +01:00
Anna Henningsen
ef0b65f9b0
tls: add memory tracking support to SSLWrap
...
PR-URL: https://github.com/nodejs/node/pull/30548
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl >
Reviewed-By: David Carlier <devnexen@gmail.com >
Reviewed-By: James M Snell <jasnell@gmail.com >
Reviewed-By: Tobias Nießen <tniessen@tnie.de >
2019-11-30 01:14:45 +01:00
Tobias Nießen
c63af4fea0
crypto: add support for IEEE-P1363 DSA signatures
...
PR-URL: https://github.com/nodejs/node/pull/29292
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl >
Reviewed-By: Daniel Bevenius <daniel.bevenius@gmail.com >
Reviewed-By: James M Snell <jasnell@gmail.com >
2019-11-20 12:55:47 -04:00
Ben Noordhuis
9f203f927c
crypto: add Hash.prototype.copy() method
...
Make it possible to clone the internal state of a Hash object
into a new Hash object, i.e., to fork the state of the object.
Fixes: https://github.com/nodejs/node/issues/29903
PR-URL: https://github.com/nodejs/node/pull/29910
Reviewed-By: Colin Ihrig <cjihrig@gmail.com >
Reviewed-By: Sam Roberts <vieuxtech@gmail.com >
Reviewed-By: Tobias Nießen <tniessen@tnie.de >
Reviewed-By: David Carlier <devnexen@gmail.com >
Reviewed-By: James M Snell <jasnell@gmail.com >
2019-10-16 10:00:00 -07:00
Anton Gerasimov
c2ce8d0547
tls: add option for private keys for OpenSSL engines
...
Add `privateKeyIdentifier` and `privateKeyEngine` options
to get private key from an OpenSSL engine in tls.createSecureContext().
PR-URL: https://github.com/nodejs/node/pull/28973
Reviewed-By: Rod Vagg <rod@vagg.org >
Reviewed-By: James M Snell <jasnell@gmail.com >
Reviewed-By: Sam Roberts <vieuxtech@gmail.com >
2019-09-27 15:50:56 -07:00
Anton Gerasimov
0c32ca96c8
tls: add option to override signature algorithms
...
Passes the list down to SSL_CTX_set1_sigalgs_list.
Option to get the list of shared signature algorithms
from a TLS socket added as well for testing.
Signed-off-by: Anton Gerasimov <agerasimov@twilio.com >
PR-URL: https://github.com/nodejs/node/pull/29598
Reviewed-By: Sam Roberts <vieuxtech@gmail.com >
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl >
Reviewed-By: Anna Henningsen <anna@addaleax.net >
2019-09-23 23:32:45 -07:00
Tobias Nießen
b64446648b
crypto: add oaepLabel option
...
The label acts as the "L" input to the RSA-OAEP algorithm.
PR-URL: https://github.com/nodejs/node/pull/29489
Reviewed-By: David Carlier <devnexen@gmail.com >
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl >
Reviewed-By: Minwoo Jung <minwoo@nodesource.com >
Reviewed-By: James M Snell <jasnell@gmail.com >
2019-09-13 16:58:41 +02:00
Shelley Vohr
17a697c794
crypto: don't expose openssl internals
...
PR-URL: https://github.com/nodejs/node/pull/29325
Reviewed-By: Ujjwal Sharma <usharma1998@gmail.com >
Reviewed-By: James M Snell <jasnell@gmail.com >
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl >
Reviewed-By: Tobias Nießen <tniessen@tnie.de >
2019-08-29 10:12:58 +05:30
Tobias Nießen
0c9ad34427
crypto: extend RSA-OAEP support with oaepHash
...
This adds an oaepHash option to asymmetric encryption which allows
users to specify a hash function when using OAEP padding. This
feature is required for interoperability with WebCrypto applications.
PR-URL: https://github.com/nodejs/node/pull/28335
Fixes: https://github.com/nodejs/node/issues/25756
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl >
Reviewed-By: James M Snell <jasnell@gmail.com >
Reviewed-By: Sam Roberts <vieuxtech@gmail.com >
2019-08-07 13:45:42 +02:00
Tobias Nießen
31d9b2f14f
crypto: add outputLength option to crypto.createHash
...
This change adds an outputLength option to crypto.createHash which
allows users to produce variable-length hash values using XOF hash
functons.
Fixes: https://github.com/nodejs/node/issues/28757
PR-URL: https://github.com/nodejs/node/pull/28805
Reviewed-By: Anna Henningsen <anna@addaleax.net >
Reviewed-By: Sam Roberts <vieuxtech@gmail.com >
Reviewed-By: Rich Trott <rtrott@gmail.com >
2019-07-25 23:00:41 -07:00
Tobias Nießen
fc50e6bcc8
crypto: fix crash when calling digest after piping
...
When piping data into an SHA3 hash, EVP_DigestFinal_ex is called in
hash._flush, bypassing safeguards in the JavaScript layer. Calling
hash.digest causes EVP_DigestFinal_ex to be called again, resulting
in a segmentation fault in the SHA3 implementation of OpenSSL.
A relatively easy solution is to cache the result of calling
EVP_DigestFinal_ex until the Hash object is garbage collected.
PR-URL: https://github.com/nodejs/node/pull/28251
Fixes: https://github.com/nodejs/node/issues/28245
Reviewed-By: James M Snell <jasnell@gmail.com >
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl >
2019-06-18 18:42:48 +02:00
Sam Roberts
94a7c2ab8a
src: remove TLS code for unsupported OpenSSLs
...
Versions of OpenSSL lower than 1.1.1 are no longer supported, so remove
ifdefs for previous versions.
PR-URL: https://github.com/nodejs/node/pull/28085
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl >
Reviewed-By: Anatoli Papirovski <apapirovski@mac.com >
Reviewed-By: James M Snell <jasnell@gmail.com >
Reviewed-By: Colin Ihrig <cjihrig@gmail.com >
Reviewed-By: Anna Henningsen <anna@addaleax.net >
2019-06-10 18:23:12 +02:00
Alba Mendez
53bef423f3
tls: expose keylog event on TLSSocket
...
Exposes SSL_CTX_set_keylog_callback in the form of a `keylog` event
that is emitted on clients and servers. This enables easy debugging
of TLS connections with i.e. Wireshark, which is a long-requested
feature.
PR-URL: https://github.com/nodejs/node/pull/27654
Refs: https://github.com/nodejs/node/issues/2363
Reviewed-By: Anna Henningsen <anna@addaleax.net >
Reviewed-By: James M Snell <jasnell@gmail.com >
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl >
Reviewed-By: Sam Roberts <vieuxtech@gmail.com >
Reviewed-By: Rich Trott <rtrott@gmail.com >
2019-05-15 05:32:33 +02:00
Anna Henningsen
723d5c058f
src: prefer v8::Global over node::Persistent
...
`v8::Global` is essentially a nicer variant of `node::Persistent` that,
in addition to reset-on-destroy, also implements move semantics.
This commit makes the necessary replacements, removes
`node::Persistent` and (now-)unnecessary inclusions of the
`node_persistent.h` header, and makes some of the functions that
take Persistents as arguments more generic so that they work with all
`v8::PersistentBase` flavours.
PR-URL: https://github.com/nodejs/node/pull/27287
Reviewed-By: Gus Caplan <me@gus.host >
Reviewed-By: Eugene Ostroukhov <eostroukhov@google.com >
Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com >
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl >
Reviewed-By: Colin Ihrig <cjihrig@gmail.com >
2019-04-30 00:23:33 +02:00
Tobias Nießen
969bd1eb7b
crypto: add support for RSA-PSS keys
...
This commit adds support for RSA-PSS keys, including
- KeyObjects of type rsa-pss,
- key pair generation for RSA-PSS, and
- signing and verification using RSA-PSS keys.
PR-URL: https://github.com/nodejs/node/pull/26960
Reviewed-By: Sam Roberts <vieuxtech@gmail.com >
Reviewed-By: Daniel Bevenius <daniel.bevenius@gmail.com >
2019-04-08 09:22:32 +02:00
Sam Roberts
dada2eba93
src: remove internal includes from node_crypto.h
...
Remove headers used by node_crypto.cc that were included in
node_crypto.h. The header file should only include what it uses itself.
PR-URL: https://github.com/nodejs/node/pull/26966
Reviewed-By: Anna Henningsen <anna@addaleax.net >
Reviewed-By: Colin Ihrig <cjihrig@gmail.com >
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de >
Reviewed-By: Richard Lau <riclau@uk.ibm.com >
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl >
2019-04-01 20:10:46 -07:00
Filip Skokan
7c1fc93e30
crypto: don't crash on unknown asymmetricKeyType
...
PR-URL: https://github.com/nodejs/node/pull/26786
Fixes: https://github.com/nodejs/node/issues/26775
Reviewed-By: Sam Roberts <vieuxtech@gmail.com >
Reviewed-By: Tobias Nießen <tniessen@tnie.de >
2019-04-01 12:49:17 +02:00
Sam Roberts
42dbaed460
tls: support TLSv1.3
...
This introduces TLS1.3 support and makes it the default max protocol,
but also supports CLI/NODE_OPTIONS switches to disable it if necessary.
TLS1.3 is a major update to the TLS protocol, with many security
enhancements. It should be preferred over TLS1.2 whenever possible.
TLS1.3 is different enough that even though the OpenSSL APIs are
technically API/ABI compatible, that when TLS1.3 is negotiated, the
timing of protocol records and of callbacks broke assumptions hard-coded
into the 'tls' module.
This change introduces no API incompatibilities when TLS1.2 is
negotiated. It is the intention that it be backported to current and LTS
release lines with the default maximum TLS protocol reset to 'TLSv1.2'.
This will allow users of those lines to explicitly enable TLS1.3 if they
want.
API incompatibilities between TLS1.2 and TLS1.3 are:
- Renegotiation is not supported by TLS1.3 protocol, attempts to call
`.renegotiate()` will always fail.
- Compiling against a system OpenSSL lower than 1.1.1 is no longer
supported (OpenSSL-1.1.0 used to be supported with configure flags).
- Variations of `conn.write('data'); conn.destroy()` have undefined
behaviour according to the streams API. They may or may not send the
'data', and may or may not cause a ERR_STREAM_DESTROYED error to be
emitted. This has always been true, but conditions under which the write
suceeds is slightly but observably different when TLS1.3 is negotiated
vs when TLS1.2 or below is negotiated.
- If TLS1.3 is negotiated, and a server calls `conn.end()` in its
'secureConnection' listener without any data being written, the client
will not receive session tickets (no 'session' events will be emitted,
and `conn.getSession()` will never return a resumable session).
- The return value of `conn.getSession()` API may not return a resumable
session if called right after the handshake. The effect will be that
clients using the legacy `getSession()` API will resume sessions if
TLS1.2 is negotiated, but will do full handshakes if TLS1.3 is
negotiated. See https://github.com/nodejs/node/pull/25831 for more
information.
PR-URL: https://github.com/nodejs/node/pull/26209
Reviewed-By: Anna Henningsen <anna@addaleax.net >
Reviewed-By: James M Snell <jasnell@gmail.com >
Reviewed-By: Rod Vagg <rod@vagg.org >
2019-03-20 07:48:25 -07:00
Ben Noordhuis
36101558fd
src: use EVPKeyPointer in more places
...
Rejoice, the code base is now free of manual EVP_PKEY_free() calls!
PR-URL: https://github.com/nodejs/node/pull/26632
Reviewed-By: Colin Ihrig <cjihrig@gmail.com >
Reviewed-By: Tobias Nießen <tniessen@tnie.de >
Reviewed-By: Minwoo Jung <minwoo@nodesource.com >
Reviewed-By: James M Snell <jasnell@gmail.com >
2019-03-18 08:35:20 +01:00
Sam Roberts
0f745bf9bd
tls: return correct version from getCipher()
...
OpenSSL 1.0.0 returned incorrect version information. OpenSSL 1.1.0
fixed this, but returning the correct information broke our tests, so
was considered semver-major. Because of this, the version was hard-coded
to the OpenSSL 1.0.0 (incorrect) string in 5fe81c8aff .
This is ancient history, start returning the correct cipher version.
PR-URL: https://github.com/nodejs/node/pull/26625
Reviewed-By: Daniel Bevenius <daniel.bevenius@gmail.com >
Reviewed-By: Anna Henningsen <anna@addaleax.net >
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl >
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de >
Reviewed-By: Richard Lau <riclau@uk.ibm.com >
Reviewed-By: Colin Ihrig <cjihrig@gmail.com >
2019-03-18 07:34:16 +01:00