aboutsummaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorBen Noordhuis <info@bnoordhuis.nl>2018-05-30 16:14:37 +0200
committerBen Noordhuis <info@bnoordhuis.nl>2018-06-13 15:59:08 +0200
commit59ace5752a13136eee7ae07ca173bc2addda2e9f (patch)
tree765a58c17fbe5a13a3f845dbf1ca6a3054d64dff /lib
parentd669251f67b0d6e70853b18f7d9358fc98cb5ceb (diff)
downloadandroid-node-v8-59ace5752a13136eee7ae07ca173bc2addda2e9f.tar.gz
android-node-v8-59ace5752a13136eee7ae07ca173bc2addda2e9f.tar.bz2
android-node-v8-59ace5752a13136eee7ae07ca173bc2addda2e9f.zip
lib: rename checkIsArrayBufferView()
Rename it to validateArrayBufferView() to align with validateInt32() and friends. Swap the name and the value in the argument list for consistency, although any reasonable person will agree it's a crime against humanity to put the value before the name. PR-URL: https://github.com/nodejs/node/pull/20816 Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Tobias Nießen <tniessen@tnie.de>
Diffstat (limited to 'lib')
-rw-r--r--lib/internal/crypto/pbkdf2.js6
-rw-r--r--lib/internal/crypto/scrypt.js6
-rw-r--r--lib/internal/crypto/sig.js15
-rw-r--r--lib/internal/crypto/util.js4
4 files changed, 16 insertions, 15 deletions
diff --git a/lib/internal/crypto/pbkdf2.js b/lib/internal/crypto/pbkdf2.js
index 7dd51e8f72..b6b61d3585 100644
--- a/lib/internal/crypto/pbkdf2.js
+++ b/lib/internal/crypto/pbkdf2.js
@@ -11,8 +11,8 @@ const {
ERR_INVALID_CALLBACK,
} = require('internal/errors').codes;
const {
- checkIsArrayBufferView,
getDefaultEncoding,
+ validateArrayBufferView,
} = require('internal/crypto/util');
function pbkdf2(password, salt, iterations, keylen, digest, callback) {
@@ -57,8 +57,8 @@ function check(password, salt, iterations, keylen, digest, callback) {
digest = 'sha1';
}
- password = checkIsArrayBufferView('password', password);
- salt = checkIsArrayBufferView('salt', salt);
+ password = validateArrayBufferView(password, 'password');
+ salt = validateArrayBufferView(salt, 'salt');
iterations = validateInt32(iterations, 'iterations', 0, INT_MAX);
keylen = validateInt32(keylen, 'keylen', 0, INT_MAX);
diff --git a/lib/internal/crypto/scrypt.js b/lib/internal/crypto/scrypt.js
index a512af0f81..fedf7f5b10 100644
--- a/lib/internal/crypto/scrypt.js
+++ b/lib/internal/crypto/scrypt.js
@@ -10,8 +10,8 @@ const {
ERR_INVALID_CALLBACK,
} = require('internal/errors').codes;
const {
- checkIsArrayBufferView,
getDefaultEncoding,
+ validateArrayBufferView,
} = require('internal/crypto/util');
const defaults = {
@@ -74,8 +74,8 @@ function check(password, salt, keylen, options, callback) {
if (_scrypt === undefined)
throw new ERR_CRYPTO_SCRYPT_NOT_SUPPORTED();
- password = checkIsArrayBufferView('password', password);
- salt = checkIsArrayBufferView(salt, 'salt');
+ password = validateArrayBufferView(password, 'password');
+ salt = validateArrayBufferView(salt, 'salt');
keylen = validateInt32(keylen, 'keylen', 0, INT_MAX);
let { N, r, p, maxmem } = defaults;
diff --git a/lib/internal/crypto/sig.js b/lib/internal/crypto/sig.js
index fa440eb6a3..b6f8ceb501 100644
--- a/lib/internal/crypto/sig.js
+++ b/lib/internal/crypto/sig.js
@@ -14,9 +14,9 @@ const {
RSA_PKCS1_PADDING
} = process.binding('constants').crypto;
const {
- checkIsArrayBufferView,
getDefaultEncoding,
- toBuf
+ toBuf,
+ validateArrayBufferView,
} = require('internal/crypto/util');
const { Writable } = require('stream');
const { inherits } = require('util');
@@ -41,7 +41,8 @@ Sign.prototype._write = function _write(chunk, encoding, callback) {
Sign.prototype.update = function update(data, encoding) {
encoding = encoding || getDefaultEncoding();
- data = checkIsArrayBufferView('data', toBuf(data, encoding));
+ data = validateArrayBufferView(toBuf(data, encoding),
+ 'data');
this._handle.update(data);
return this;
};
@@ -77,7 +78,7 @@ Sign.prototype.sign = function sign(options, encoding) {
var pssSaltLength = getSaltLength(options);
- key = checkIsArrayBufferView('key', key);
+ key = validateArrayBufferView(key, 'key');
var ret = this._handle.sign(key, passphrase, rsaPadding, pssSaltLength);
@@ -114,10 +115,10 @@ Verify.prototype.verify = function verify(options, signature, sigEncoding) {
var pssSaltLength = getSaltLength(options);
- key = checkIsArrayBufferView('key', key);
+ key = validateArrayBufferView(key, 'key');
- signature = checkIsArrayBufferView('signature',
- toBuf(signature, sigEncoding));
+ signature = validateArrayBufferView(toBuf(signature, sigEncoding),
+ 'signature');
return this._handle.verify(key, signature, rsaPadding, pssSaltLength);
};
diff --git a/lib/internal/crypto/util.js b/lib/internal/crypto/util.js
index e2cd810a01..32c9eb7f6a 100644
--- a/lib/internal/crypto/util.js
+++ b/lib/internal/crypto/util.js
@@ -83,7 +83,7 @@ function timingSafeEqual(buf1, buf2) {
return _timingSafeEqual(buf1, buf2);
}
-function checkIsArrayBufferView(name, buffer) {
+function validateArrayBufferView(buffer, name) {
buffer = toBuf(buffer);
if (!isArrayBufferView(buffer)) {
throw new ERR_INVALID_ARG_TYPE(
@@ -96,7 +96,7 @@ function checkIsArrayBufferView(name, buffer) {
}
module.exports = {
- checkIsArrayBufferView,
+ validateArrayBufferView,
getCiphers,
getCurves,
getDefaultEncoding,