summaryrefslogtreecommitdiff
path: root/src/node_crypto_bio.cc
AgeCommit message (Collapse)Author
2019-06-10src: remove TLS code for unsupported OpenSSLsSam Roberts
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-05-23src: remove memory_tracker-inl.h from header filesSam Roberts
Inline headers should only be included into the .cc files that use them. PR-URL: https://github.com/nodejs/node/pull/27755 Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: Rich Trott <rtrott@gmail.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: James M Snell <jasnell@gmail.com>
2019-04-01src: remove internal includes from node_crypto.hSam Roberts
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-03-09src: apply clang-tidy various improvementgengjiawen
* rewrite to default label in method ConvertUVErrorCode * improve if condition in method PeekWritable * remove redundant cast in node_file.cc PR-URL: https://github.com/nodejs/node/pull/26470 Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Richard Lau <riclau@uk.ibm.com> Reviewed-By: Refael Ackermann <refack@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com>
2019-02-28src: remove cast for unsupported opensslSam Roberts
The cast is needed to build against OpenSSL 1.0.2, which master, 11.x, and 10.x no longer support. PR-URL: https://github.com/nodejs/node/pull/26305 Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl> Reviewed-By: Sakthipriyan Vairamani <thechargingvolcano@gmail.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
2019-02-27src: apply clang-tidy rule modernize-deprecated-headersgengjiawen
PR-URL: https://github.com/nodejs/node/pull/26159 Reviewed-By: Daniel Bevenius <daniel.bevenius@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com>
2018-08-12src: avoid possible race during NodeBIO initializationAnna Henningsen
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-12src: use smart pointers for NodeBIOAnna Henningsen
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-05-26src: add CHECK_NULL/CHECK_NOT_NULL macrosTobias Nießen
This change introduces CHECK_NULL and CHECK_NOT_NULL macros similar to their definition in v8 and replaces instances of CHECK/CHECK_EQ/CHECK_NE with these where it seems appropriate. PR-URL: https://github.com/nodejs/node/pull/20914 Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
2017-12-11crypto: remove BIO_set_shutdownDaniel Bevenius
I've not been able to find any reason for calling BIO_set_shutdown(bio, 1). This is done by default for the following versions of OpenSSL: https://github.com/openssl/openssl/blob/OpenSSL_1_1_0/ crypto/bio/bio_lib.c#L26 https://github.com/openssl/openssl/blob/OpenSSL_1_0_1/ crypto/bio/bio_lib.c#L90 https://github.com/openssl/openssl/blob/OpenSSL_1_0_2/ crypto/bio/bio_lib.c#L88 https://github.com/openssl/openssl/blob/OpenSSL_1_0_0/ crypto/bio/bio_lib.c#L90 This commit removes the call and the comment. PR-URL: https://github.com/nodejs/node/pull/17542 Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl> Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
2017-11-11crypto: make node_crypto_bio compat w/ OpenSSL 1.1David Benjamin
This is cherry-picked from PR #8491 and then tidied up. The original had an unnecessarily large diff and messed up some public/private bits. PR-URL: https://github.com/nodejs/node/pull/16130 Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl> Reviewed-By: Rod Vagg <rod@vagg.org>
2017-10-30src: do not include x.h if x-inl.h is includedJoyee Cheung
PR-URL: https://github.com/nodejs/node/pull/16548 Fixes: https://github.com/nodejs/node/issues/16519 Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl> Reviewed-By: Gireesh Punathil <gpunathi@in.ibm.com> Reviewed-By: Daniel Bevenius <daniel.bevenius@gmail.com> Reviewed-By: Gibson Fahnestock <gibfahn@gmail.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
2017-08-04http2: address initial pr feedbackJames M Snell
PR-URL: https://github.com/nodejs/node/pull/14239 Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
2017-08-04http2: introducing HTTP/2James M Snell
At long last: The initial *experimental* implementation of HTTP/2. This is an accumulation of the work that has been done in the nodejs/http2 repository, squashed down to a couple of commits. The original commit history has been preserved in the nodejs/http2 repository. This PR introduces the nghttp2 C library as a new dependency. This library provides the majority of the HTTP/2 protocol implementation, with the rest of the code here providing the mapping of the library into a usable JS API. Within src, a handful of new node_http2_*.c and node_http2_*.h files are introduced. These provide the internal mechanisms that interface with nghttp and define the `process.binding('http2')` interface. The JS API is defined within `internal/http2/*.js`. There are two APIs provided: Core and Compat. The Core API is HTTP/2 specific and is designed to be as minimal and as efficient as possible. The Compat API is intended to be as close to the existing HTTP/1 API as possible, with some exceptions. Tests, documentation and initial benchmarks are included. The `http2` module is gated by a new `--expose-http2` command line flag. When used, `require('http2')` will be exposed to users. Note that there is an existing `http2` module on npm that would be impacted by the introduction of this module, which is the main reason for gating this behind a flag. When using `require('http2')` the first time, a process warning will be emitted indicating that an experimental feature is being used. To run the benchmarks, the `h2load` tool (part of the nghttp project) is required: `./node benchmarks/http2/simple.js benchmarker=h2load`. Only two benchmarks are currently available. Additional configuration options to enable verbose debugging are provided: ``` $ ./configure --debug-http2 --debug-nghttp2 $ NODE_DEBUG=http2 ./node ``` The `--debug-http2` configuration option enables verbose debug statements from the `src/node_http2_*` files. The `--debug-nghttp2` enables the nghttp library's own verbose debug output. The `NODE_DEBUG=http2` enables JS-level debug output. The following illustrates as simple HTTP/2 server and client interaction: (The HTTP/2 client and server support both plain text and TLS connections) ```jt client = http2.connect('http://localhost:80'); const req = client.request({ ':path': '/some/path' }); req.on('data', (chunk) => { /* do something with the data */ }); req.on('end', () => { client.destroy(); }); // Plain text (non-TLS server) const server = http2.createServer(); server.on('stream', (stream, requestHeaders) => { stream.respond({ ':status': 200 }); stream.write('hello '); stream.end('world'); }); server.listen(80); ``` ```js const http2 = require('http2'); const client = http2.connect('http://localhost'); ``` Author: Anna Henningsen <anna@addaleax.net> Author: Colin Ihrig <cjihrig@gmail.com> Author: Daniel Bevenius <daniel.bevenius@gmail.com> Author: James M Snell <jasnell@gmail.com> Author: Jun Mukai Author: Kelvin Jin Author: Matteo Collina <matteo.collina@gmail.com> Author: Robert Kowalski <rok@kowalski.gd> Author: Santiago Gimeno <santiago.gimeno@gmail.com> Author: Sebastiaan Deckers <sebdeckers83@gmail.com> Author: Yosuke Furukawa <yosuke.furukawa@gmail.com> PR-URL: https://github.com/nodejs/node/pull/14239 Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
2017-06-30src: move crypto_bio/clienthello to crypto nsDaniel Bevenius
Currently, node_crypto_bio and node_crypto_clienthello are not in the crypto namespace but simply in the node namespace. Not sure if this was intentional or not, but I think it would make sense to move them to be consistent. PR-URL: https://github.com/nodejs/node/pull/13957 Reviewed-By: Refael Ackermann <refack@gmail.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl> Reviewed-By: James M Snell <jasnell@gmail.com>
2017-03-10meta: restore original copyright headerJames M Snell
A prior io.js era commit inappropriately removed the original copyright statements from the source. This restores those in any files still remaining from that edit. Ref: https://github.com/nodejs/TSC/issues/174 Ref: https://github.com/nodejs/node/pull/10599 PR-URL: https://github.com/nodejs/node/pull/10155 Note: This PR was required, reviewed-by and approved by the Node.js Foundation Legal Committee and the TSC. There is no `Approved-By:` meta data.
2016-09-22src: remove unneeded ABORT after CHECKyorkie
CHECK includes node::Abort(), so that's unneeded to call ABORT after CHECK. PR-URL: https://github.com/nodejs/node/pull/8593 Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Anna Henningsen <anna@addaleax.net>
2016-06-28src: fix runtime/int cpplint warningsBen Noordhuis
PR-URL: https://github.com/nodejs/node/pull/7462 Reviewed-By: Trevor Norris <trev.norris@gmail.com>
2016-02-11crypto: have fixed NodeBIOs return EOFAdam Langley
Prior to this change, the NodeBIO objects used to wrap fixed data had `num` equal to -1. This caused them to return -1 and set the retry flags when they ran out of data. Since the data is fixed, that's incorrect. Instead they should return zero to signal EOF. This change adds a new, static function, NodeBIO::NewFixed to create a BIO that wraps fixed data and which returns zero when exhausted. The practical impact of this is limited since most (all?) the parsing functions that these BIOs get passed to consider any return value less than one to be EOF and ignore the retry flags anyway. PR-URL: https://github.com/nodejs/node/pull/5105 Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl> Reviewed-By: Fedor Indutny <fedor@indutny.com>
2015-09-17src: Add ABORT macroEvan Lucas
Windows 8+ compiled in Release mode exits with code 0xC0000409 when abort() is called. This prevents us from being able to reliably verify an abort exit code (3) on windows. PR-URL: https://github.com/nodejs/node/pull/2776 Reviewed-By: Sakthipriyan Vairamani <thechargingvolcano@gmail.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Brian White <mscdex@mscdex.net> Reviewed-by: Trevor Norris <trev.norris@gmail.com>
2015-03-08node_crypto_bio: adjust external memory sizeFedor Indutny
Adjust V8's external memory size when allocating buffers for TLS data to ensure that V8 has enough information to trigger the GC at right time. PR-URL: https://github.com/iojs/io.js/pull/1085 Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
2015-01-12Remove excessive copyright/license boilerplateisaacs
The copyright and license notice is already in the LICENSE file. There is no justifiable reason to also require that it be included in every file, since the individual files are not individually distributed except as part of the entire package.
2014-10-23src: replace NULL with nullptrBen Noordhuis
Now that we are building with C++11 features enabled, replace use of NULL with nullptr. The benefit of using nullptr is that it can never be confused for an integral type because it does not support implicit conversions to integral types except boolean - unlike NULL, which is defined as a literal `0`.
2014-10-12src: replace assert() with CHECK()Ben Noordhuis
Mechanically replace assert() statements with UNREACHABLE(), CHECK(), or CHECK_{EQ,NE,LT,GT,LE,GE}() statements. The exceptions are src/node.h and src/node_object_wrap.h because they are public headers. PR-URL: https://github.com/node-forward/node/pull/16 Reviewed-By: Fedor Indutny <fedor@indutny.com>
2014-09-26crypto: lower RSS usage for TLSCallbacksFedor Indutny
Don't allocate any BIO buffers initially, do this on a first read from the TCP connection. Allocate different amount of data for initial read and for consequent reads: small buffer for hello+certificate, big buffer for better throughput. see #8416
2014-02-26tls: stop NodeBIO::Gets from reading off end of bufferMaxwell Krohn
NodeBIO::Gets was reading off the end of a buffer if it didn't find a "\n" before the EOF. This behavior was causing X509 certificates passed to `https.Agent` via the "ca" option to be silently discarded. It also was causing improper parsing of certs and keys passed to https.Agent, but those problems were worked around in cdde9a3. Backed out workaround in `lib/crypto.js` from ccde9a3, which now isn't needed. But keep the test introduced in that commit, which tests properly for this bug. This bug was first introduced in a58f93f Gist containing test code, bisection log, and notes: https://gist.github.com/maxtaco/9211605
2013-12-07crypto: fix moving read headFedor Indutny
Fix various possible stalls of read head (i.e. try moving it after every write head update). NOTE: This is actually backported from `bud`.
2013-12-07tls_wrap: use writev when possibleFedor Indutny
Try writing multiple chunks from NodeBIO if possible.
2013-11-08crypto: try moving read head in Peek()Fedor Indutny
Otherwise it might get stall (`Peek()` will return zero-length chunk) in following situation: 1. `Write(kBufferLength)` 2. `Read(kBufferLength)` 3. `Write(anything)` 4. `Peek()` => `len=0`
2013-10-17cpplint: disallow if one-linersFedor Indutny
2013-08-29crypto: remove NodeBIO::GetMethod()Ben Noordhuis
Remove NodeBIO::GetMethod() and replace calls to BIO_new() with calls to the new NodeBIO::New() function. This commit basically reshuffles some code in order to make it explicit that the NodeBIO BIO_METHOD is const.
2013-08-03crypto: fix another over-run in bioFedor Indutny
When doing `FreeEmpty`, `NodeBIO` skips pre-allocated `head_` buffer. However this might lead to double-freeing buffers since in `~NodeBIO()` we're starting deallocation from `head_` buffer.
2013-07-31src: lint c++ codeFedor Indutny
2013-06-26crypto: do not move half-filled write headFedor Indutny
Might cause write head running over read head, when there were no allocation and `Commit()` was called. Source of at least one test failure on windows (`simple/test-https-drain.js`).
2013-06-19crypto: change assertion to condition in bioFedor Indutny
Read head can be the same as write head, even if there's some data to read.
2013-06-16tls_wrap: embed TLS encryption into streamwrapFedor Indutny
2013-06-15crypto: ensure that read head is always non-emptyFedor Indutny
2013-06-14crypto: do not deallocate embedded bufferFedor Indutny
2013-06-14crypto: fix excessive buffer allocationFedor Indutny
Allocate buffer only if the next one isn't free.
2013-06-08crypto: free excessive memory in NodeBIOFedor Indutny
Before this commit NodeBIO never shrank, possibly consuming a lot of memory (depending on reader's haste). All buffers between write_head's child and read_head should be deallocated on read, leaving only space left in write_head and in the next buffer.
2013-04-10crypto: move write_head in bio's Reset() methodFedor Indutny
2013-04-10crypto: fix changing buffers in bioFedor Indutny
We should go to next buffer if *current* one is full, not the next one. Otherwise we may hop through buffers and written data will become interleaved, which will lead to failure.
2013-04-10crypto: fix style issues in bioFedor Indutny
Stop changing arguments, use local variables for things that change.
2013-04-05crypto: use better memory BIO implementationFedor Indutny