summaryrefslogtreecommitdiff
path: root/src/node_crypto_bio.cc
Commit message (Collapse)AuthorAgeFilesLines
* src: avoid possible race during NodeBIO initializationAnna Henningsen2018-08-121-0/+2
| | | | | | PR-URL: https://github.com/nodejs/node/pull/21984 Reviewed-By: Anatoli Papirovski <apapirovski@mac.com> Reviewed-By: James M Snell <jasnell@gmail.com>
* src: use smart pointers for NodeBIOAnna Henningsen2018-08-121-15/+11
| | | | | | PR-URL: https://github.com/nodejs/node/pull/21984 Reviewed-By: Anatoli Papirovski <apapirovski@mac.com> Reviewed-By: James M Snell <jasnell@gmail.com>
* src: add CHECK_NULL/CHECK_NOT_NULL macrosTobias Nießen2018-05-261-1/+1
| | | | | | | | | | | | | 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>
* crypto: remove BIO_set_shutdownDaniel Bevenius2017-12-111-2/+0
| | | | | | | | | | | | | | | | | | | | | | | | 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>
* crypto: make node_crypto_bio compat w/ OpenSSL 1.1David Benjamin2017-11-111-27/+64
| | | | | | | | | 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>
* src: do not include x.h if x-inl.h is includedJoyee Cheung2017-10-301-1/+0
| | | | | | | | | | 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>
* http2: address initial pr feedbackJames M Snell2017-08-041-0/+1
| | | | | | | 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>
* http2: introducing HTTP/2James M Snell2017-08-041-1/+0
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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>
* src: move crypto_bio/clienthello to crypto nsDaniel Bevenius2017-06-301-0/+2
| | | | | | | | | | | | | 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>
* meta: restore original copyright headerJames M Snell2017-03-101-0/+21
| | | | | | | | | | | | | | | 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.
* src: remove unneeded ABORT after CHECKyorkie2016-09-221-1/+0
| | | | | | | | | | 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>
* src: fix runtime/int cpplint warningsBen Noordhuis2016-06-281-2/+3
| | | | | PR-URL: https://github.com/nodejs/node/pull/7462 Reviewed-By: Trevor Norris <trev.norris@gmail.com>
* crypto: have fixed NodeBIOs return EOFAdam Langley2016-02-111-0/+16
| | | | | | | | | | | | | | | | | | 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>
* src: Add ABORT macroEvan Lucas2015-09-171-1/+1
| | | | | | | | | | | | 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>
* node_crypto_bio: adjust external memory sizeFedor Indutny2015-03-081-1/+6
| | | | | | | | 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>
* Remove excessive copyright/license boilerplateisaacs2015-01-121-21/+0
| | | | | | | 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.
* src: replace NULL with nullptrBen Noordhuis2014-10-231-16/+16
| | | | | | | | | | 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`.
* src: replace assert() with CHECK()Ben Noordhuis2014-10-121-15/+17
| | | | | | | | | | | 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>
* crypto: lower RSS usage for TLSCallbacksFedor Indutny2014-09-261-28/+47
| | | | | | | | | 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
* tls: stop NodeBIO::Gets from reading off end of bufferMaxwell Krohn2014-02-261-2/+2
| | | | | | | | | | | | | | | | | | | | 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
* crypto: fix moving read headFedor Indutny2013-12-071-11/+16
| | | | | | | Fix various possible stalls of read head (i.e. try moving it after every write head update). NOTE: This is actually backported from `bud`.
* tls_wrap: use writev when possibleFedor Indutny2013-12-071-0/+27
| | | | Try writing multiple chunks from NodeBIO if possible.
* crypto: try moving read head in Peek()Fedor Indutny2013-11-081-10/+24
| | | | | | | | | | 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`
* cpplint: disallow if one-linersFedor Indutny2013-10-171-3/+6
|
* crypto: remove NodeBIO::GetMethod()Ben Noordhuis2013-08-291-1/+8
| | | | | | | | 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.
* crypto: fix another over-run in bioFedor Indutny2013-08-031-3/+6
| | | | | | 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.
* src: lint c++ codeFedor Indutny2013-07-311-44/+44
|
* crypto: do not move half-filled write headFedor Indutny2013-06-261-1/+3
| | | | | | 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`).
* crypto: change assertion to condition in bioFedor Indutny2013-06-191-2/+1
| | | | | Read head can be the same as write head, even if there's some data to read.
* tls_wrap: embed TLS encryption into streamwrapFedor Indutny2013-06-161-0/+29
|
* crypto: ensure that read head is always non-emptyFedor Indutny2013-06-151-1/+3
|
* crypto: do not deallocate embedded bufferFedor Indutny2013-06-141-0/+5
|
* crypto: fix excessive buffer allocationFedor Indutny2013-06-141-5/+13
| | | | Allocate buffer only if the next one isn't free.
* crypto: free excessive memory in NodeBIOFedor Indutny2013-06-081-0/+24
| | | | | | | | | 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.
* crypto: move write_head in bio's Reset() methodFedor Indutny2013-04-101-0/+1
|
* crypto: fix changing buffers in bioFedor Indutny2013-04-101-1/+1
| | | | | | 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.
* crypto: fix style issues in bioFedor Indutny2013-04-101-28/+36
| | | | Stop changing arguments, use local variables for things that change.
* crypto: use better memory BIO implementationFedor Indutny2013-04-051-0/+312