diff options
author | Daniel Bevenius <daniel.bevenius@gmail.com> | 2018-08-21 08:54:02 +0200 |
---|---|---|
committer | Anna Henningsen <anna@addaleax.net> | 2018-08-24 00:49:29 +0200 |
commit | bf5cc3bf1add7eea1d7d4c2c0de2092582ea1541 (patch) | |
tree | 555b689fe4381f7ee3ad3af6a9f03c6e1919d3da /lib | |
parent | d8ef9811a726c84c4b6803436235642d87ec47ea (diff) | |
download | android-node-v8-bf5cc3bf1add7eea1d7d4c2c0de2092582ea1541.tar.gz android-node-v8-bf5cc3bf1add7eea1d7d4c2c0de2092582ea1541.tar.bz2 android-node-v8-bf5cc3bf1add7eea1d7d4c2c0de2092582ea1541.zip |
crypto: move process.binding('crypto') to internal
This commit makes the crypto builtin an internal builtin, and
changes usage of the builtin from using process.binding('crypto')
to use internalBinding instead.
Refs: https://github.com/nodejs/node/issues/22160
PR-URL: https://github.com/nodejs/node/pull/22426
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
Reviewed-By: Trivikram Kamat <trivikr.dev@gmail.com>
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Diffstat (limited to 'lib')
-rw-r--r-- | lib/_tls_common.js | 4 | ||||
-rw-r--r-- | lib/_tls_wrap.js | 5 | ||||
-rw-r--r-- | lib/crypto.js | 6 | ||||
-rw-r--r-- | lib/internal/bootstrap/node.js | 3 | ||||
-rw-r--r-- | lib/internal/crypto/certificate.js | 3 | ||||
-rw-r--r-- | lib/internal/crypto/cipher.js | 3 | ||||
-rw-r--r-- | lib/internal/crypto/pbkdf2.js | 3 | ||||
-rw-r--r-- | lib/internal/crypto/random.js | 3 | ||||
-rw-r--r-- | lib/internal/crypto/scrypt.js | 3 | ||||
-rw-r--r-- | lib/internal/crypto/sig.js | 6 | ||||
-rw-r--r-- | lib/internal/crypto/util.js | 3 | ||||
-rw-r--r-- | lib/tls.js | 3 |
12 files changed, 24 insertions, 21 deletions
diff --git a/lib/_tls_common.js b/lib/_tls_common.js index de96fa687d..1f56c46dd8 100644 --- a/lib/_tls_common.js +++ b/lib/_tls_common.js @@ -34,8 +34,8 @@ const { SSL_OP_CIPHER_SERVER_PREFERENCE } = process.binding('constants').crypto; // Lazily loaded var crypto = null; -const { SecureContext: NativeSecureContext } = process.binding('crypto'); - +const { internalBinding } = require('internal/bootstrap/loaders'); +const { SecureContext: NativeSecureContext } = internalBinding('crypto'); function SecureContext(secureProtocol, secureOptions, context) { if (!(this instanceof SecureContext)) { return new SecureContext(secureProtocol, secureOptions, context); diff --git a/lib/_tls_wrap.js b/lib/_tls_wrap.js index 3f2a2cc52d..15604f466d 100644 --- a/lib/_tls_wrap.js +++ b/lib/_tls_wrap.js @@ -36,9 +36,8 @@ const tls_wrap = process.binding('tls_wrap'); const { TCP, constants: TCPConstants } = process.binding('tcp_wrap'); const { Pipe, constants: PipeConstants } = process.binding('pipe_wrap'); const { owner_symbol } = require('internal/async_hooks').symbols; -const { - SecureContext: NativeSecureContext -} = process.binding('crypto'); +const { internalBinding } = require('internal/bootstrap/loaders'); +const { SecureContext: NativeSecureContext } = internalBinding('crypto'); const { ERR_INVALID_ARG_TYPE, ERR_MULTIPLE_CALLBACK, diff --git a/lib/crypto.js b/lib/crypto.js index fa9412bc85..bced9f040a 100644 --- a/lib/crypto.js +++ b/lib/crypto.js @@ -30,6 +30,7 @@ const { } = require('internal/util'); assertCrypto(); +const { internalBinding } = require('internal/bootstrap/loaders'); const { ERR_CRYPTO_FIPS_FORCED, ERR_CRYPTO_FIPS_UNAVAILABLE @@ -39,10 +40,7 @@ const { fipsMode, fipsForced } = process.binding('config'); -const { - getFipsCrypto, - setFipsCrypto, -} = process.binding('crypto'); +const { getFipsCrypto, setFipsCrypto } = internalBinding('crypto'); const { randomBytes, randomFill, diff --git a/lib/internal/bootstrap/node.js b/lib/internal/bootstrap/node.js index e087a10844..6a4e4860b3 100644 --- a/lib/internal/bootstrap/node.js +++ b/lib/internal/bootstrap/node.js @@ -350,7 +350,8 @@ 'http_parser', 'v8', 'stream_wrap', - 'signal_wrap']); + 'signal_wrap', + 'crypto']); process.binding = function binding(name) { return internalBindingWhitelist.has(name) ? internalBinding(name) : diff --git a/lib/internal/crypto/certificate.js b/lib/internal/crypto/certificate.js index 35325874ba..d96965224d 100644 --- a/lib/internal/crypto/certificate.js +++ b/lib/internal/crypto/certificate.js @@ -1,10 +1,11 @@ 'use strict'; +const { internalBinding } = require('internal/bootstrap/loaders'); const { certExportChallenge, certExportPublicKey, certVerifySpkac -} = process.binding('crypto'); +} = internalBinding('crypto'); const { ERR_INVALID_ARG_TYPE } = require('internal/errors').codes; const { isArrayBufferView } = require('internal/util/types'); diff --git a/lib/internal/crypto/cipher.js b/lib/internal/crypto/cipher.js index 1828b69b14..73a6c6ab49 100644 --- a/lib/internal/crypto/cipher.js +++ b/lib/internal/crypto/cipher.js @@ -19,13 +19,14 @@ const { const { isArrayBufferView } = require('internal/util/types'); +const { internalBinding } = require('internal/bootstrap/loaders'); const { CipherBase, privateDecrypt: _privateDecrypt, privateEncrypt: _privateEncrypt, publicDecrypt: _publicDecrypt, publicEncrypt: _publicEncrypt -} = process.binding('crypto'); +} = internalBinding('crypto'); const assert = require('assert'); const LazyTransform = require('internal/streams/lazy_transform'); diff --git a/lib/internal/crypto/pbkdf2.js b/lib/internal/crypto/pbkdf2.js index b6b61d3585..24498c73a6 100644 --- a/lib/internal/crypto/pbkdf2.js +++ b/lib/internal/crypto/pbkdf2.js @@ -2,7 +2,8 @@ const { AsyncWrap, Providers } = process.binding('async_wrap'); const { Buffer } = require('buffer'); -const { INT_MAX, pbkdf2: _pbkdf2 } = process.binding('crypto'); +const { internalBinding } = require('internal/bootstrap/loaders'); +const { INT_MAX, pbkdf2: _pbkdf2 } = internalBinding('crypto'); const { validateInt32 } = require('internal/validators'); const { ERR_CRYPTO_INVALID_DIGEST, diff --git a/lib/internal/crypto/random.js b/lib/internal/crypto/random.js index ea73c85ec5..2d462bd756 100644 --- a/lib/internal/crypto/random.js +++ b/lib/internal/crypto/random.js @@ -2,7 +2,8 @@ const { AsyncWrap, Providers } = process.binding('async_wrap'); const { Buffer, kMaxLength } = require('buffer'); -const { randomBytes: _randomBytes } = process.binding('crypto'); +const { internalBinding } = require('internal/bootstrap/loaders'); +const { randomBytes: _randomBytes } = internalBinding('crypto'); const { ERR_INVALID_ARG_TYPE, ERR_INVALID_CALLBACK, diff --git a/lib/internal/crypto/scrypt.js b/lib/internal/crypto/scrypt.js index edfe522be4..f68a77aa86 100644 --- a/lib/internal/crypto/scrypt.js +++ b/lib/internal/crypto/scrypt.js @@ -2,7 +2,8 @@ const { AsyncWrap, Providers } = process.binding('async_wrap'); const { Buffer } = require('buffer'); -const { INT_MAX, scrypt: _scrypt } = process.binding('crypto'); +const { internalBinding } = require('internal/bootstrap/loaders'); +const { INT_MAX, scrypt: _scrypt } = internalBinding('crypto'); const { validateInt32 } = require('internal/validators'); const { ERR_CRYPTO_SCRYPT_INVALID_PARAMETER, diff --git a/lib/internal/crypto/sig.js b/lib/internal/crypto/sig.js index ebd852402e..fd2db9016f 100644 --- a/lib/internal/crypto/sig.js +++ b/lib/internal/crypto/sig.js @@ -5,10 +5,8 @@ const { ERR_INVALID_OPT_VALUE } = require('internal/errors').codes; const { validateString } = require('internal/validators'); -const { - Sign: _Sign, - Verify: _Verify -} = process.binding('crypto'); +const { internalBinding } = require('internal/bootstrap/loaders'); +const { Sign: _Sign, Verify: _Verify } = internalBinding('crypto'); const { RSA_PSS_SALTLEN_AUTO, RSA_PKCS1_PADDING diff --git a/lib/internal/crypto/util.js b/lib/internal/crypto/util.js index 9283e80df4..19d18be5b0 100644 --- a/lib/internal/crypto/util.js +++ b/lib/internal/crypto/util.js @@ -1,12 +1,13 @@ 'use strict'; +const { internalBinding } = require('internal/bootstrap/loaders'); const { getCiphers: _getCiphers, getCurves: _getCurves, getHashes: _getHashes, setEngine: _setEngine, timingSafeEqual: _timingSafeEqual -} = process.binding('crypto'); +} = internalBinding('crypto'); const { ENGINE_METHOD_ALL diff --git a/lib/tls.js b/lib/tls.js index c6568fc7ed..d58906b286 100644 --- a/lib/tls.js +++ b/lib/tls.js @@ -29,7 +29,8 @@ const { isUint8Array } = require('internal/util/types'); const net = require('net'); const url = require('url'); -const binding = process.binding('crypto'); +const { internalBinding } = require('internal/bootstrap/loaders'); +const binding = internalBinding('crypto'); const { Buffer } = require('buffer'); const EventEmitter = require('events'); const { URL } = require('internal/url'); |