0
0
mirror of https://github.com/nodejs/node.git synced 2024-11-30 15:30:56 +01:00
Commit Graph

110 Commits

Author SHA1 Message Date
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
cjihrig
3238232fc4
lib: rename validateSafeInteger to validateInteger
validateInteger() was renamed to validateSafeInteger() in
https://github.com/nodejs/node/pull/26572. However, this
function also works with unsafe integers. This commit restores
the old name, and adds some basic tests.

PR-URL: https://github.com/nodejs/node/pull/29184
Refs: https://github.com/nodejs/node/pull/26572
Reviewed-By: Rich Trott <rtrott@gmail.com>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Yongsheng Zhang <zyszys98@gmail.com>
Reviewed-By: Trivikram Kamat <trivikr.dev@gmail.com>
2019-08-19 11:55:22 -04:00
Zach Bjornson
91a4cb7175 lib: rename validateInteger to validateSafeInteger
PR-URL: https://github.com/nodejs/node/pull/26572
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
Reviewed-By: Ujjwal Sharma <usharma1998@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Rich Trott <rtrott@gmail.com>
2019-08-16 22:09:24 -07:00
Yaniv Friedensohn
a0e2c6d284 src: add error codes to errors thrown in C++
PR-URL: https://github.com/nodejs/node/pull/27700
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com>
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
Reviewed-By: Rich Trott <rtrott@gmail.com>
2019-08-09 15:58:58 -07:00
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
cjihrig
92ca2c208b
crypto: add null check to outputLength logic
The Hash constructor's outputLength logic checks if the options
input is an object, but doesn't check for null objects. This
commit adds that check.

PR-URL: https://github.com/nodejs/node/pull/28864
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Rich Trott <rtrott@gmail.com>
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
2019-07-29 03:33:28 -10:00
Tobias Nießen
499533f72a crypto: fix handling of malicious getters (scrypt)
It is possible to bypass parameter validation in crypto.scrypt and
crypto.scryptSync by crafting option objects with malicious getters as
demonstrated in the regression test. After bypassing validation, any
value can be passed to the C++ layer, causing an assertion to crash
the process.

Fixes: https://github.com/nodejs/node/issues/28836

PR-URL: https://github.com/nodejs/node/pull/28838
Reviewed-By: Michaël Zasso <targos@protonmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
Reviewed-By: Sam Roberts <vieuxtech@gmail.com>
Reviewed-By: Rich Trott <rtrott@gmail.com>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
2019-07-26 10:19:28 -07: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
1dc458cdd0 crypto: increase maxmem range from 32 to 53 bits
Fixes: https://github.com/nodejs/node/issues/28755

PR-URL: https://github.com/nodejs/node/pull/28799
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: Rich Trott <rtrott@gmail.com>
2019-07-23 21:17:19 -07:00
Daniel Bevenius
c6f968de71 crypto: move _impl call out of handleError funct
This commit moves the _impl function call out of the handleError
function, which now only takes in an object as its parameter.

PR-URL: https://github.com/nodejs/node/pull/28318
Reviewed-By: Yongsheng Zhang <zyszys98@gmail.com>
Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com>
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Rich Trott <rtrott@gmail.com>
Reviewed-By: Tobias Nießen <tniessen@tnie.de>
Reviewed-By: James M Snell <jasnell@gmail.com>
2019-06-24 05:36:59 +02:00
Daniel Bevenius
7edd5f3bdd crypto: move _pbkdf2 call out of handleError funct
This commit moves the _pbkdf2 function call out of the handleError
function, which now only takes in an error and a digest object as
its parameters.

PR-URL: https://github.com/nodejs/node/pull/28318
Reviewed-By: Yongsheng Zhang <zyszys98@gmail.com>
Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com>
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Rich Trott <rtrott@gmail.com>
Reviewed-By: Tobias Nießen <tniessen@tnie.de>
Reviewed-By: James M Snell <jasnell@gmail.com>
2019-06-24 05:36:55 +02:00
Daniel Bevenius
556b38ab0a crypto: move _randomBytes call out of handleError funct
This commit moves the _randomBytes function call out of the handleError
function, which now it takes in an error and a buf object as its
parameters.

PR-URL: https://github.com/nodejs/node/pull/28318
Reviewed-By: Yongsheng Zhang <zyszys98@gmail.com>
Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com>
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Rich Trott <rtrott@gmail.com>
Reviewed-By: Tobias Nießen <tniessen@tnie.de>
Reviewed-By: James M Snell <jasnell@gmail.com>
2019-06-24 05:36:51 +02:00
Daniel Bevenius
882e8fea66 crypto: move _scrypt call out of handleError funct
This commit moves the _scrypt function call out of the handleError
function, which now only takes in an error object as its parameter.

The motivation for this is to hopefully improve readability as it was
not clear to me the first time I stepped through the code where the
actual call to _scrypt was.

PR-URL: https://github.com/nodejs/node/pull/28318
Reviewed-By: Yongsheng Zhang <zyszys98@gmail.com>
Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com>
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Rich Trott <rtrott@gmail.com>
Reviewed-By: Tobias Nießen <tniessen@tnie.de>
Reviewed-By: James M Snell <jasnell@gmail.com>
2019-06-24 05:36:40 +02:00
Alexander Avakov
f692299764 crypto: fix KeyObject handle type error message
Fix KeyObject handle type error message. Add test to cover KeyObject
ERR_INVALID_ARG_TYPE exception.

PR-URL: https://github.com/nodejs/node/pull/27904
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
Reviewed-By: Ujjwal Sharma <usharma1998@gmail.com>
Reviewed-By: Rich Trott <rtrott@gmail.com>
Reviewed-By: Trivikram Kamat <trivikr.dev@gmail.com>
2019-05-30 15:37:02 +02:00
Michaël Zasso
908292cf1f lib: enforce the use of Object from primordials
PR-URL: https://github.com/nodejs/node/pull/27146
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com>
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Gus Caplan <me@gus.host>
2019-04-12 05:38:45 +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
Tobias Nießen
2f1ed5c063 crypto: remove legacy native handles
PR-URL: https://github.com/nodejs/node/pull/27011
Reviewed-By: Michaël Zasso <targos@protonmail.com>
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
2019-04-04 16:45:41 +02:00
Filip Skokan
b2bb6c2b80
crypto: fix crash of encrypted private key export without cipher
PR-URL: https://github.com/nodejs/node/pull/27041
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
2019-04-04 15:54:04 +02:00
Ruben Bridgewater
3b044962c4
errors: add more information in case of invalid callbacks
This adds the actual callback that is passed through to the error
message in case an ERR_INVALID_CALLBACK error is thrown.

PR-URL: https://github.com/nodejs/node/pull/27048
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: Yongsheng Zhang <zyszys98@gmail.com>
2019-04-04 12:51:03 +02:00
Michaël Zasso
0817840f77 lib: force using primordials for JSON, Math and Reflect
Use the "no-restricted-globals" ESLint rule to lint for it.

PR-URL: https://github.com/nodejs/node/pull/27027
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
Reviewed-By: Gus Caplan <me@gus.host>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
2019-04-03 21:36:08 +08:00
Ruben Bridgewater
f86f5736da
benchmark,lib: change var to const
Refs: https://github.com/nodejs/node/pull/26679

PR-URL: https://github.com/nodejs/node/pull/26915
Reviewed-By: Michaël Zasso <targos@protonmail.com>
Reviewed-By: Tobias Nießen <tniessen@tnie.de>
Reviewed-By: Refael Ackermann <refack@gmail.com>
2019-03-30 13:16:39 +01:00
Brian White
7d0e50dcfe
crypto: add crypto.sign() and crypto.verify()
These methods are added primarily to allow signing and verifying
using Ed25519 and Ed448 keys, which do not support streaming of
input data. However, any key type can be used with these new
APIs, to allow better performance when only signing/verifying
a single chunk.

Fixes: https://github.com/nodejs/node/issues/26320
PR-URL: https://github.com/nodejs/node/pull/26611
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Rod Vagg <rod@vagg.org>
Reviewed-By: Sam Roberts <vieuxtech@gmail.com>
Reviewed-By: Tobias Nießen <tniessen@tnie.de>
2019-03-28 21:57:53 -04:00
Tobias Nießen
c35acc0260
crypto: allow undefined for saltLength and padding
PR-URL: https://github.com/nodejs/node/pull/26921
Reviewed-By: Sam Roberts <vieuxtech@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
2019-03-28 14:33:03 +01:00
Tobias Nießen
df1c9eb975
crypto: rename generateKeyPairEdDSA
Now that support for X25519 and X448 has been added, this function is
not used exclusively for EdDSA keys anymore.

PR-URL: https://github.com/nodejs/node/pull/26900
Refs: https://github.com/nodejs/node/pull/26774
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
Reviewed-By: Sam Roberts <vieuxtech@gmail.com>
2019-03-28 11:13:08 +01:00
Ruben Bridgewater
7bddfcc61a
lib: consolidate arrayBufferView validation
There are lots of places that validate for arrayBufferView and we
have multiple functions that do the same thing. Instead, move the
validation into `internal/validators` so all files can use that
instead.

There are more functions throughout the code that do the same but
it takes some more work to fully consolidate all of those.

PR-URL: https://github.com/nodejs/node/pull/26809
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
2019-03-27 17:05:19 +01:00
Ruben Bridgewater
751c92d972
crypto: remove obsolete encoding check
This renames the parameters for clarity and removes the check for
undefined encoding. That will always default to `utf8`.

PR-URL: https://github.com/nodejs/node/pull/26809
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
2019-03-27 17:05:18 +01:00
Ruben Bridgewater
6c913fb028
lib: remove return values from validation functions
This makes sure the validation functions do not cause any side
effects. Validation functions should ideally only validate the input
without any other effect. Since the input value must be known from
the callee, there is no reason to return the input value.

PR-URL: https://github.com/nodejs/node/pull/26809
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
2019-03-27 17:05:13 +01:00
Filip Skokan
85fda7e848
crypto: add support for x25119 and x448 KeyObjects
PR-URL: https://github.com/nodejs/node/pull/26774
Refs: https://github.com/nodejs/node/issues/26626
Reviewed-By: Tobias Nießen <tniessen@tnie.de>
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: Sam Roberts <vieuxtech@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
2019-03-25 01:40:54 +01:00
Ruben Bridgewater
bfbce289c3
lib: refactor Error.captureStackTrace() usage
When using `Errors.captureStackFrames` the error's stack property
is set again. This adds a helper function that wraps this functionality
in a simple API that does not only set the stack including the `code`
property but it also improves the performance to create the error.
The helper works for thrown errors and errors returned from wrapped
functions in case they are Node.js core errors.

PR-URL: https://github.com/nodejs/node/pull/26738
Fixes: https://github.com/nodejs/node/issues/26669
Fixes: https://github.com/nodejs/node/issues/20253
Reviewed-By: Gus Caplan <me@gus.host>
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
Reviewed-By: Michaël Zasso <targos@protonmail.com>
Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com>
2019-03-23 02:55:54 +01:00
Tobias Nießen
3a9592496c
crypto: add support for EdDSA key pair generation
PR-URL: https://github.com/nodejs/node/pull/26554
Refs: https://github.com/nodejs/node/pull/26319
Reviewed-By: Sam Roberts <vieuxtech@gmail.com>
2019-03-18 21:59:47 +01:00
Filip Skokan
f1056542f0
crypto: expose KeyObject class
PR-URL: https://github.com/nodejs/node/pull/26438
Reviewed-By: Sam Roberts <vieuxtech@gmail.com>
Reviewed-By: Tobias Nießen <tniessen@tnie.de>
2019-03-17 10:53:58 +01:00
Tobias Nießen
6f77af541e
Revert "crypto: add KeyObject.asymmetricKeySize"
This reverts commit 4895927a0a.

PR-URL: https://github.com/nodejs/node/pull/26636
Fixes: https://github.com/nodejs/node/issues/26631
Reviewed-By: Ujjwal Sharma <usharma1998@gmail.com>
Reviewed-By: Rich Trott <rtrott@gmail.com>
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
2019-03-15 17:01:56 +01:00
Tobias Nießen
3afa5d7ba8
crypto: improve error handling in parseKeyEncoding
This change only affects KeyObject.export().

PR-URL: https://github.com/nodejs/node/pull/26455
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
Reviewed-By: Rich Trott <rtrott@gmail.com>
Reviewed-By: Michaël Zasso <targos@protonmail.com>
2019-03-09 12:00:23 +01:00
Patrick Gansterer
4895927a0a
crypto: add KeyObject.asymmetricKeySize
Expose the size of asymetric keys of crypto key object from the
crypto module added in v11.6.0.

PR-URL: https://github.com/nodejs/node/pull/26387
Refs: https://github.com/nodejs/node/pull/24234
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
2019-03-07 00:24:07 +01:00
Tobias Nießen
fe7162915e
crypto: allow deriving public from private keys
This change allows passing private key objects to
crypto.createPublicKey, resulting in a key object that represents a
valid public key for the given private key. The returned public key
object can be used and exported safely without revealing information
about the private key.

PR-URL: https://github.com/nodejs/node/pull/26278
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: Sam Roberts <vieuxtech@gmail.com>
2019-03-05 16:32:19 +01:00
Tobias Nießen
b8018f407b
crypto: move DEP0113 to End-of-Life
PR-URL: https://github.com/nodejs/node/pull/26249
Reviewed-By: Sam Roberts <vieuxtech@gmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Rich Trott <rtrott@gmail.com>
2019-03-02 10:58:12 +01:00
Amit Zur
e0a3d74135
crypto: include 'Buffer' in error output of Hash.update method
Fixes: https://github.com/nodejs/node/issues/25487

PR-URL: https://github.com/nodejs/node/pull/25533
Reviewed-By: Sakthipriyan Vairamani <thechargingvolcano@gmail.com>
Reviewed-By: Sam Roberts <vieuxtech@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com>
2019-02-09 17:21:41 +01:00
Rich Trott
62942e9ad7 lib: replace 'assert' with 'internal/assert' for many built-ins
Replace large 'assert' module with tiny 'internal/assert' module for
many built-in uses.

PR-URL: https://github.com/nodejs/node/pull/25956
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
Reviewed-By: Minwoo Jung <minwoo@nodesource.com>
2019-02-08 00:01:12 -08:00
Anna Henningsen
270ffb0fa7
src,lib: remove dead process.binding() code
There are no non-internal builtin modules left, so this
should be safe to remove to a large degree.

PR-URL: https://github.com/nodejs/node/pull/25829
Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Anto Aravinth <anto.aravinth.cse@gmail.com>
Reviewed-By: Gus Caplan <me@gus.host>
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
2019-02-03 20:41:53 +01:00
Tobias Nießen
9315daaf02
crypto: fix key handle extraction
PR-URL: https://github.com/nodejs/node/pull/25562
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
2019-01-18 14:55:29 +01:00
Tobias Nießen
ae2d1f0e05
crypto: always accept private keys as public keys
Some APIs already accept private keys instead of public keys. This
changes all relevant crypto APIs to do so.

PR-URL: https://github.com/nodejs/node/pull/25217
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>
2019-01-08 00:20:09 +01:00
Tobias Nießen
7afdfaec08 crypto: fix key object wrapping in sync keygen
PR-URL: https://github.com/nodejs/node/pull/25326
Fixes: https://github.com/nodejs/node/issues/25322
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Sam Roberts <vieuxtech@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
2019-01-07 07:33:35 +01:00
Tobias Nießen
823d86c47c crypto: add key object API
This commit makes multiple important changes:

1. A new key object API is introduced. The KeyObject class itself is
   not exposed to users, instead, several new APIs can be used to
   construct key objects: createSecretKey, createPrivateKey and
   createPublicKey. The new API also allows to convert between
   different key formats, and even though the API itself is not
   compatible to the WebCrypto standard in any way, it makes
   interoperability much simpler.

2. Key objects can be used instead of the raw key material in all
   relevant crypto APIs.

3. The handling of asymmetric keys has been unified and greatly
   improved. Node.js now fully supports both PEM-encoded and
   DER-encoded public and private keys.

4. Conversions between buffers and strings have been moved to native
   code for sensitive data such as symmetric keys due to security
   considerations such as zeroing temporary buffers.

5. For compatibility with older versions of the crypto API, this
   change allows to specify Buffers and strings as the "passphrase"
   option when reading or writing an encoded key. Note that this
   can result in unexpected behavior if the password contains a
   null byte.

PR-URL: https://github.com/nodejs/node/pull/24234
Reviewed-By: Refael Ackermann <refack@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
2018-12-24 14:50:16 +01:00
ZYSzys
a35bd62ae1 lib: refactor argument validation using validateString
PR-URL: https://github.com/nodejs/node/pull/24960
Refs: https://github.com/nodejs/node/pull/22101
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: Richard Lau <riclau@uk.ibm.com>
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
2018-12-13 17:22:43 -08:00
Ruben Bridgewater
59257543c3
lib: use ES6 class inheritance style
PR-URL: https://github.com/nodejs/node/pull/24755
Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
2018-12-05 16:55:00 +01:00
Ruben Bridgewater
dcc82b37b6
lib: remove inherits() usage
This switches all `util.inherits()` calls to use
`Object.setPrototypeOf()` instead. In fact, `util.inherits()` is
mainly a small wrapper around exactly this function while adding
the `_super` property on the object as well.

Refs: #24395

PR-URL: https://github.com/nodejs/node/pull/24755
Refs: https://github.com/nodejs/node/issues/24395
Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
2018-12-05 16:53:58 +01:00
yosuke ota
519923fbf9 crypto: convert to arrow function
Changed function expression to arrow function.

PR-URL: https://github.com/nodejs/node/pull/24597
Reviewed-By: Ron Korving <ron@ronkorving.nl>
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Gireesh Punathil <gpunathi@in.ibm.com>
2018-11-26 17:42:38 +05:30
Michaël Zasso
e83d7e8d88
crypto: put legacy _handle accessors on prototypes
Creating deprecated accessors each time an object is created is very
time consuming.

Refs: https://github.com/nodejs/node/pull/22747
Fixes: https://github.com/nodejs/node/issues/24266

PR-URL: https://github.com/nodejs/node/pull/24269
Reviewed-By: Tobias Nießen <tniessen@tnie.de>
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
2018-11-11 20:01:31 +01:00
Anna Henningsen
87b808f761
src,lib: move natives and constants to internalBinding()
Refs: https://github.com/nodejs/node/issues/22160

PR-URL: https://github.com/nodejs/node/pull/23663
Reviewed-By: Trivikram Kamat <trivikr.dev@gmail.com>
Reviewed-By: Weijia Wang <starkwang@126.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Sakthipriyan Vairamani <thechargingvolcano@gmail.com>
Reviewed-By: Denys Otrishko <shishugi@gmail.com>
Reviewed-By: Refael Ackermann <refack@gmail.com>
2018-10-21 03:17:12 +02:00
Gus Caplan
e7f710c1d4 bootstrapper: move internalBinding to NativeModule
internalBinding is used so often that it should just automatically be
available for usage in internals.

PR-URL: https://github.com/nodejs/node/pull/23025
Refs: https://github.com/nodejs/node/commit/2a9eb31
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Michaël Zasso <targos@protonmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com>
Reviewed-By: Refael Ackermann <refack@gmail.com>
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
Reviewed-By: Sakthipriyan Vairamani <thechargingvolcano@gmail.com>
Reviewed-By: Trivikram Kamat <trivikr.dev@gmail.com>
2018-10-04 11:55:34 +02:00