Граф коммитов

99 Коммитов

Автор SHA1 Сообщение Дата
Calvin Metcalf e5e598060e lib,src: make pseudoRandomBytes alias randomBytes
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-22 23:08:36 +01:00
cjihrig 804e7aa9ab lib: use const to define constants
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-21 16:21:31 -05:00
isaacs 3e1b1dd4a9 Remove excessive copyright/license boilerplate
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.
2015-01-12 15:30:28 -08:00
Calvin Metcalf ce56dccb99 crypto: allow creation of GCM ciphers with createCipher
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-25 18:53:35 +03:00
Ben Noordhuis 21130c7d6f lib: turn on strict mode
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-11-22 17:23:30 +01:00
Trevor Norris 1a4a189578 crypto: createDiffieHellman throw for bad args
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-10-08 15:38:46 -07:00
Fedor Indutny 6e453fad87 crypto: introduce ECDH 2014-08-29 00:27:09 +04:00
Fedor Indutny 6adf3ecebb crypto: allow padding in RSA methods
Reviewed-By: Trevor Norris <trevnorris@gmail.com>
2014-08-27 00:24:57 +04:00
seishun 42bda05af8 crypto: add RSA encryption
Reviewed-By: Fedor Indutny <fedor@indutny.com>
2014-08-11 22:00:34 +04:00
Nicholas Vavilov 5344d0c103 crypto, zlib: replace _binding with _handle
Also include whitespace fixes to appease jslint.

Signed-off-by: Trevor Norris <trev.norris@gmail.com>
2014-05-07 16:31:00 -07:00
Fedor Indutny 5d2aef17ee
crypto: move `createCredentials` to tls
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-29 12:01:43 +04:00
Timothy J Fontaine b444392a98 Merge remote-tracking branch 'upstream/v0.10'
Conflicts:
	src/node.cc
	src/node.js
	test/message/max_tick_depth_trace.out
2014-03-10 16:50:00 -07:00
Fedor Indutny f0d870501e crypto: do not lowercase cipher/hash names
`crypto.getCiphers()` and `crypto.getHashes()` should prefer lower-case
variants of names, but should not introduce them.

fix #7282
2014-03-11 01:08:43 +04:00
Brian White 31ce34887f crypto: allow setting add'l authenticated data 2014-03-04 12:42:03 +04:00
Maxwell Krohn a22a2d8656 tls: stop NodeBIO::Gets from reading off end of buffer
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-26 17:33:10 +04:00
Brian White a226be4f76 crypto: allow custom generator for DiffieHellman 2014-02-18 15:49:23 +04:00
Ben Noordhuis 74d9aa49d5 crypto: support custom pbkdf2 digest methods
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-22 15:58:07 +04:00
Fedor Indutny cdde9a386a crypto: add newline to cert and key if not present
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-22 02:42:04 +04:00
Fedor Indutny 92b6417098 crypto: introduce .setEngine(engine, [flags]) 2014-01-05 16:42:33 +04:00
Ingmar Runge e0d31ea2db crypto: support GCM authenticated encryption mode.
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-08 00:00:02 +04:00
Timothy J Fontaine fcca3585fe Merge remote-tracking branch 'upstream/v0.10'
Conflicts:
	lib/tls.js
	src/node.js
2013-12-06 21:27:18 -08:00
Kai Groner 98be8df571 crypto: Make Decipher._flush() emit errors.
When Decipher processes a stream using an incorrect key, the
DecipherFinal() method throws an unhandled exception at the end of the
stream.
2013-12-04 19:52:15 +04:00
Erik Dubbelboer bb909ad642 tls: add ECDH ciphers support
Switch test fixtures to 1024 bit keys.
2013-10-30 08:34:47 +01:00
Thom Seddon f755ecf484 src: accept passphrase when crypto signing with private key
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-29 14:19:47 +04:00
Jason Gerfen 7bf46ba4ce crypto: add SPKAC support
Implements new class 'Certificate' within crypto object for working
with SPKAC's (signed public key & challenge) natively.
2013-10-16 09:43:19 -07:00
isaacs d9b4cc323f Revert "crypto: add SPKAC support"
This reverts commit 7f66e44dc1.
2013-10-15 15:58:58 -07:00
Jason Gerfen 7f66e44dc1 crypto: add SPKAC support
Implements new class 'Certificate' within crypto object for working
with SPKAC's (signed public key & challenge) natively.
2013-10-13 10:31:20 +02:00
isaacs 22c68fdc1d src: Replace macros with util functions 2013-08-01 15:08:01 -07:00
Ben Noordhuis 0330bdf519 lib: macro-ify type checks
Increases the grep factor. Makes it easier to harmonize type checks
across the code base.
2013-07-24 21:49:35 +02:00
Nathan Rajlich 48e159faf2 crypto: throw a helpful error message for "tls" and "crypto"
When node is compiled with the --without-ssl flag.
2013-07-09 11:27:38 -07:00
isaacs adf9b67e59 Merge remote-tracking branch 'ry/v0.10' into master
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
2013-06-25 11:12:33 -07:00
Ben Noordhuis 82b3524bce crypto: fix utf8/utf-8 encoding check
Normalize the encoding in getEncoding() before using it. Fixes a
"AssertionError: Cannot change encoding" exception when the caller
mixes "utf8" and "utf-8".

Fixes #5655.
2013-06-11 13:07:24 +02:00
isaacs 61c9f78c63 Merge remote-tracking branch 'ry/v0.10' into master
Conflicts:
	AUTHORS
	ChangeLog
	deps/uv/ChangeLog
	deps/uv/config-unix.mk
	deps/uv/src/unix/stream.c
	deps/uv/src/version.c
	deps/uv/uv.gyp
	src/node.cc
	src/node_buffer.cc
	src/node_crypto.cc
	src/node_version.h
	src/stream_wrap.cc
	src/stream_wrap.h
2013-05-17 14:04:54 -07:00
isaacs a241deb19a crypto: Pass encodings for Hmac digest 2013-05-14 13:51:43 -07:00
isaacs 430dc39e87 crypto: use StringBytes::Encode 2013-05-14 13:51:43 -07:00
isaacs a1eacdf12a crypto: Pass strings to binding layer directly 2013-05-14 13:51:43 -07:00
Ben Noordhuis af1ed99ce2 Merge remote-tracking branch 'origin/v0.10'
Conflicts:
	AUTHORS
	ChangeLog
	deps/uv/ChangeLog
	deps/uv/src/version.c
	lib/http.js
	src/node_crypto.cc
	src/node_os.cc
	src/node_version.h
	test/simple/helper-debugger-repl.js
2013-04-29 14:08:51 +02:00
isaacs 4bf1d1007f crypto: LazyTransform on properties, not methods
It needs to apply the Transform class when the _readableState,
_writableState, or _transformState properties are accessed,
otherwise things like setEncoding and on('data') don't work
properly.

Also, the methods wrappers are no longer needed, since they're only
problematic because they access the undefined properties.
2013-04-21 09:33:10 -04:00
Fedor Indutny 259839fe75 Merge branch 'v0.10'
Conflicts:
	ChangeLog
	deps/uv/src/version.c
	src/node.h
	src/node_crypto.cc
	src/node_crypto_bio.cc
	src/node_crypto_bio.h
	src/node_object_wrap.h
	src/node_version.h
2013-04-12 11:30:11 -04:00
Andreas Madsen fed8cff1d0 crypto: fix constructor call in crypto streams
When using some stream method on a lazy crypto stream, the transform
constructor wasn't called. This caused the internal state object to
be undefined.
2013-04-08 14:45:42 +04:00
isaacs 2c9a38d059 Merge remote-tracking branch 'ry/v0.10'
Conflicts:
	AUTHORS
	ChangeLog
	deps/v8/src/json-parser.h
	lib/crypto.js
	src/node_version.h
2013-04-05 09:02:48 -07:00
isaacs 7af075ee30 crypto: Pass options to ctor calls 2013-03-29 09:39:51 -07:00
Ben Noordhuis 1a65154d72 Merge remote-tracking branch 'origin/v0.10'
Conflicts:
	deps/v8/src/objects-inl.h
	deps/v8/src/objects.h
	src/node_crypto.cc
2013-03-26 00:27:23 +01:00
Ben Noordhuis cfd0dca9ae crypto: make getCiphers() return non-SSL ciphers
Commit f53441a added crypto.getCiphers() as a function that returns the
names of SSL ciphers.

Commit 14a6c4e then added crypto.getHashes(), which returns the names of
digest algorithms, but that creates a subtle inconsistency: the return
values of crypto.getHashes() are valid arguments to crypto.createHash()
but that is not true for crypto.getCiphers() - the returned values are
only valid for SSL/TLS functions.

Rectify that by adding tls.getCiphers() and making crypto.getCiphers()
return proper cipher names.
2013-03-25 18:42:07 +01:00
isaacs 2f88272ba2 Merge remote-tracking branch 'ry/v0.10' into master
Conflicts:
	src/node.cc
	src/node_version.h
2013-03-21 10:52:01 -07:00
Fedor Indutny 855caa82aa crypto: initialize transform lazily 2013-03-20 16:49:08 -07:00
Fedor Indutny 83d17e509f crypto: merge Cipher and Decipher 2013-03-13 00:23:29 +04:00
isaacs 426b4c6258 stream: _write takes an encoding argument
This vastly reduces the overhead of decodeStrings:false streams,
such as net and http.
2013-03-05 14:27:15 -08:00
isaacs cd68d86c32 stream: Remove output function from _transform
Just use stream.push(outputChunk) instead.
2013-03-05 14:27:15 -08:00
Ben Noordhuis 4231dab39f crypto: fix base64 padding regression
Commit 9901b69c introduces a small regression where the trailing base64
padding is no longer written out when Cipher#final is called. Rectify
that.

Fixes #4837.
2013-02-25 15:21:52 +01:00