summaryrefslogtreecommitdiff
path: root/lib/crypto.js
AgeCommit message (Collapse)Author
2016-04-28crypto: fix error in deprecation messageRich Trott
The deprecation message for `crypto.Credentials` says to use `tls.createSecureContext` but the correct property to use is `tls.SecureContext()`. Fix the deprecation message and add a test that checks the mappings of deprecated properties and their warning messages. PR-URL: https://github.com/nodejs/node/pull/6344 Reviewed-By: James M Snell <jasnell@gmail.com>
2016-03-23crypto: fail early when loading crypto without opensslJames M Snell
Fail early in require('crypto'), require('tls'), require('https'), etc when crypto is not available (rather than depending on an internal try/catch). Add documentation for detecting when crypto is not available. PR-URL: https://github.com/nodejs/node/pull/5611 Reviewed-By: Rod Vagg <rod@vagg.org> Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
2016-03-16buffer: add .from(), .alloc() and .allocUnsafe()James M Snell
Several changes: * Soft-Deprecate Buffer() constructors * Add `Buffer.from()`, `Buffer.alloc()`, and `Buffer.allocUnsafe()` * Add `--zero-fill-buffers` command line option * Add byteOffset and length to `new Buffer(arrayBuffer)` constructor * buffer.fill('') previously had no effect, now zero-fills * Update the docs PR-URL: https://github.com/nodejs/node/pull/4682 Reviewed-By: Сковорода Никита Андреевич <chalkerx@gmail.com> Reviewed-By: Stephen Belanger <admin@stephenbelanger.com>
2016-03-05crypto: simplify Certificate class bindingsAlexander Makarenko
Replace Certificate C++ class with simple functions. Update crypto.Certificate methods accordingly. PR-URL: https://github.com/nodejs/node/pull/5382 Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
2016-03-02crypto, string_bytes: treat `buffer` str as `utf8`Fedor Indutny
Do not treat crypto inputs as `binary` strings, convert them to Buffers using `new Buffer(..., 'utf8')`, or using newly updated StringBytes APIs. PR-URL: https://github.com/nodejs/node/pull/5522 Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl> Reviewed-By: James M Snell <jasnell@gmail.com>
2016-02-25crypto: Improve control of FIPS modeStefan Budeanu
Default to FIPS off even in FIPS builds. Add JS API to check and control FIPS mode. Add command line arguments to force FIPS on/off. Respect OPENSSL_CONF variable and read the config. Add testing for new features. Fixes: https://github.com/nodejs/node/issues/3819 PR-URL: https://github.com/nodejs/node/pull/5181 Reviewed-By: Fedor Indutny <fedor@indutny.com> Reviewed-by: Michael Dawson <michael_dawson@ca.ibm.com>
2016-01-23crypto: pbkdf2 deprecate digest overload.Tom Gallacher
As per #3292, this PR introduces a deprecation notice about removing the 'default digest' overload which currently defaults to the soon to be defunct SHA1 digest. Instead it should be left up to the documentation and implementor to suggest a suitable digest function. Ref: https://github.com/nodejs/node/pull/3292 PR-URL: https://github.com/nodejs/node/pull/4047 Reviewed-By: bnoordhuis - Ben Noordhuis <info@bnoordhuis.nl> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Fedor Indutny <fedor@indutny.com> Reviewed-By: Shigeki Ohtsu <ohtsu@iij.ad.jp>
2015-11-09lib: Consistent error messages in all modulesmicnic
This commit fixes some error messages that are not consistent with some general rules which most of the error messages follow. PR-URL: https://github.com/nodejs/node/pull/3374 Reviewed-By: Roman Reiss <me@silverwind.io>
2015-09-14streams: refactor LazyTransform to internal/Brendan Ashworth
This commit refactors LazyTransform from the crypto implementation (lib/crypto.js) into an internal module (not publicy accessible) in internal/streams/lazy_transform.js. This promotes a more modular core design and removes code bloat in crypto, as LazyTransform didn't specifically have anything to do with cryptography, but rather a fast way to support two APIs on a stream. PR-URL: https://github.com/nodejs/node/pull/2566 Reviewed-By: Fedor Indutny <fedor.indutny@gmail.com>
2015-07-03util: prepend '(node) ' to deprecation messagesSakthipriyan Vairamani
Changes included in this commit are 1. Making the deprecation messages consistent. The messages will be in the following format x is deprecated. Use y instead. If there is no alternative for `x`, then the ` Use y instead.` part will not be there in the message. 2. All the internal deprecation messages are printed with the prefix `(node) `, except when the `--trace-deprecation` flag is set. Fixes: https://github.com/nodejs/io.js/issues/1883 PR-URL: https://github.com/nodejs/io.js/pull/1892 Reviewed-By: Roman Reiss <me@silverwind.io>
2015-06-15lib,test: fix whitespace issuesRoman Reiss
PR-URL: https://github.com/nodejs/io.js/pull/1971 Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
2015-06-11lib: don't use global BufferRoman Reiss
Port of https://github.com/joyent/node/pull/8603 The race condition present in the original PR didn't occur, so no workaround was needed. PR-URL: https://github.com/nodejs/io.js/pull/1794 Reviewed-By: Trevor Norris <trev.norris@gmail.com>
2015-06-08crypto: add getCurves() to get supported ECsBrian White
PR-URL: https://github.com/nodejs/io.js/pull/1914 Reviewed-By: Roman Reiss <me@silverwind.io> Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
2015-05-09lib: fix eslint stylesYosuke Furukawa
PR-URL: https://github.com/iojs/io.js/pull/1539 Fixes: https://github.com/iojs/io.js/issues/1253 Reviewed-By: Jeremiah Senkpiel <fishrock123@rocketmail.com> Reviewed-By: Trevor Norris <trev.norris@gmail.com> Reviewed-By: Roman Reiss <me@silverwind.io> Reviewed-By: Chris Dickinson <christopher.s.dickinson@gmail.com> Reviewed-By: Johan Bergström <bugs@bergstroem.nu> Reviewed-By: Fedor Indutny <fedor.indutny@gmail.com>
2015-03-24lib: add missing `new` for errors lib/*.jsMayhem
Not including `new` adds a useless frame and removes a potentially useful frame. PR-URL: https://github.com/iojs/io.js/pull/1246 Reviewed-By: Petka Antonov <petka_antonov@hotmail.com> Reviewed-By: Roman Reiss <me@silverwind.io> Reviewed-By: Brendan Ashworth <brendan.ashworth@me.com>
2015-02-02crypto: support passwords in publicEncryptCalvin Metcalf
Private keys may be used along with publicEncrypt since the private key includes the public one. This adds the ability to use encrypted private keys which previously threw an error. This commit also makes sure the user exposed functions have names. PR-URL: https://github.com/iojs/io.js/pull/626 Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
2015-01-31lib: reduce util.is*() usagecjihrig
Many of the util.is*() methods used to check data types simply compare against a single value or the result of typeof. This commit replaces calls to these methods with equivalent checks. This commit does not touch calls to the more complex methods (isRegExp(), isDate(), etc.). Fixes: https://github.com/iojs/io.js/issues/607 PR-URL: https://github.com/iojs/io.js/pull/647 Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
2015-01-28crypto: remove use of this._readableStateCalvin Metcalf
Per #445 this removes a reference to this._readableState in hash._flush. It was used to get the encoding on the readable side to pass to the writable side but omitting it just causes the stream to handle the encoding issues. PR-URL: https://github.com/iojs/io.js/pull/610 Reviewed-By: Chris Dickinson <christopher.s.dickinson@gmail.com> Reviewed-By: Fedor Indutny <fedor.indutny@gmail.com> Reviewed-By: Vladimir Kurchatkin <vladimir.kurchatkin@gmail.com>
2015-01-28crypto: implement privateEncrypt/publicDecryptFedor Indutny
PR-URL: https://github.com/iojs/io.js/pull/625 Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl> Fix iojs/io.js#477
2015-01-22lib,src: make pseudoRandomBytes alias randomBytesCalvin Metcalf
Previously pseudoRandomBytes worked similarly to randomBytes but in the event of insufficient entropy would silently return non-secure values. As of f68a116, the entropy pool blocks if there is insufficient entropy instead of giving an error so there is now no longer a case where pseudoRandomBytes would act differently than randomBytes. Docs are updated to remove pseudoRandomBytes and to clarify that randomBytes now does block instead of erring when entropy is low. PR-URL: https://github.com/iojs/io.js/pull/557 Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl> Reviewed-By: Fedor Indutny <fedor@indutny.com>
2015-01-21lib: use const to define constantscjihrig
This commit replaces a number of var statements throughout the lib code with const statements. PR-URL: https://github.com/iojs/io.js/pull/541 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-11-25crypto: allow creation of GCM ciphers with createCipherCalvin Metcalf
Sets the authenticated encryption specific methods ([set|get]AuthTag and setAAD) on the Cipher prototype not just the Cipheriv prototype. Reviewed-By: Fedor Indutny <fedor@indutny.com> PR-URL: https://github.com/joyent/node/pull/8711
2014-11-22lib: turn on strict modeBen Noordhuis
Turn on strict mode for the files in the lib/ directory. It helps catch bugs and can have a positive effect on performance. PR-URL: https://github.com/node-forward/node/pull/64 Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Fedor Indutny <fedor@indutny.com>
2014-10-08crypto: createDiffieHellman throw for bad argsTrevor Norris
Previously crypto.createDiffieHellman() would fail silently when a bad argument was passed for prime/prime_length. Now throws TypeError. Fixes: https://github.com/joyent/node/issues/8480 Signed-off-by: Trevor Norris <trev.norris@gmail.com>
2014-08-29crypto: introduce ECDHFedor Indutny
2014-08-27crypto: allow padding in RSA methodsFedor Indutny
Reviewed-By: Trevor Norris <trevnorris@gmail.com>
2014-08-11crypto: add RSA encryptionseishun
Reviewed-By: Fedor Indutny <fedor@indutny.com>
2014-05-07crypto, zlib: replace _binding with _handleNicholas Vavilov
Also include whitespace fixes to appease jslint. Signed-off-by: Trevor Norris <trev.norris@gmail.com>
2014-03-29crypto: move `createCredentials` to tlsFedor Indutny
Move `createCredentials` to `tls` module and rename it to `createSecureContext`. Make it use default values from `tls` module: `DEFAULT_CIPHERS` and `DEFAULT_ECDH_CURVE`. fix #7249
2014-03-10Merge remote-tracking branch 'upstream/v0.10'Timothy J Fontaine
Conflicts: src/node.cc src/node.js test/message/max_tick_depth_trace.out
2014-03-11crypto: do not lowercase cipher/hash namesFedor Indutny
`crypto.getCiphers()` and `crypto.getHashes()` should prefer lower-case variants of names, but should not introduce them. fix #7282
2014-03-04crypto: allow setting add'l authenticated dataBrian White
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
2014-02-18crypto: allow custom generator for DiffieHellmanBrian White
2014-01-22crypto: support custom pbkdf2 digest methodsBen Noordhuis
Make the HMAC digest method configurable. Update crypto.pbkdf2() and crypto.pbkdf2Sync() to take an extra, optional digest argument. Before this commit, SHA-1 (admittedly the most common method) was used exclusively. Fixes #6553.
2014-01-22crypto: add newline to cert and key if not presentFedor Indutny
After one of OpenSSL updates we have stopped accepting PEM private keys and certificates that doesn't end with a newline (`\n`) character. Handle this regression in `crypto.js` to make less trouble to our users. fix #6892
2014-01-05crypto: introduce .setEngine(engine, [flags])Fedor Indutny
2013-12-08crypto: support GCM authenticated encryption mode.Ingmar Runge
This adds two new member functions getAuthTag and setAuthTag that are useful for AES-GCM encryption modes. Use getAuthTag after Cipheriv.final, transmit the tag along with the data and use Decipheriv.setAuthTag to have the encrypted data verified.
2013-12-06Merge remote-tracking branch 'upstream/v0.10'Timothy J Fontaine
Conflicts: lib/tls.js src/node.js
2013-12-04crypto: Make Decipher._flush() emit errors.Kai Groner
When Decipher processes a stream using an incorrect key, the DecipherFinal() method throws an unhandled exception at the end of the stream.
2013-10-30tls: add ECDH ciphers supportErik Dubbelboer
Switch test fixtures to 1024 bit keys.
2013-10-29src: accept passphrase when crypto signing with private keyThom Seddon
Previous behaviour was to drop to an openssl prompt ("Enter PEM pass phrase:") when supplying a private key with a passphrase. This change adds a fourth, optional, paramter that will be used as the passphrase. To include this parameter in a backwards compatible way it was necessary to expose the previously undocumented (and unexposed) feature of being able to explitly setting the output encoding.
2013-10-16crypto: add SPKAC supportJason Gerfen
Implements new class 'Certificate' within crypto object for working with SPKAC's (signed public key & challenge) natively.
2013-10-15Revert "crypto: add SPKAC support"isaacs
This reverts commit 7f66e44dc1e90e7abda2a9ed02d7e8163e1f6358.
2013-10-13crypto: add SPKAC supportJason Gerfen
Implements new class 'Certificate' within crypto object for working with SPKAC's (signed public key & challenge) natively.
2013-08-01src: Replace macros with util functionsisaacs
2013-07-24lib: macro-ify type checksBen Noordhuis
Increases the grep factor. Makes it easier to harmonize type checks across the code base.
2013-07-09crypto: throw a helpful error message for "tls" and "crypto"Nathan Rajlich
When node is compiled with the --without-ssl flag.
2013-06-25Merge remote-tracking branch 'ry/v0.10' into masterisaacs
Conflicts: ChangeLog deps/uv/ChangeLog deps/uv/src/unix/stream.c deps/uv/src/version.c deps/v8/build/common.gypi deps/v8/src/frames.h deps/v8/src/runtime.cc deps/v8/test/mjsunit/debug-set-variable-value.js lib/http.js src/node_version.h