summaryrefslogtreecommitdiff
path: root/lib/crypto.js
diff options
context:
space:
mode:
Diffstat (limited to 'lib/crypto.js')
-rw-r--r--lib/crypto.js16
1 files changed, 8 insertions, 8 deletions
diff --git a/lib/crypto.js b/lib/crypto.js
index f8efffda4..42564c79e 100644
--- a/lib/crypto.js
+++ b/lib/crypto.js
@@ -25,7 +25,7 @@ const DH_GENERATOR = 2;
// to break them unnecessarily.
function toBuf(str, encoding) {
encoding = encoding || 'binary';
- if (util.isString(str)) {
+ if (typeof str === 'string') {
if (encoding === 'buffer')
encoding = 'binary';
str = new Buffer(str, encoding);
@@ -92,7 +92,7 @@ Hash.prototype._flush = function(callback) {
Hash.prototype.update = function(data, encoding) {
encoding = encoding || exports.DEFAULT_ENCODING;
- if (encoding === 'buffer' && util.isString(data))
+ if (encoding === 'buffer' && typeof data === 'string')
encoding = 'binary';
this._handle.update(data, encoding);
return this;
@@ -369,7 +369,7 @@ function DiffieHellman(sizeOrKey, keyEncoding, generator, genEncoding) {
if (!(this instanceof DiffieHellman))
return new DiffieHellman(sizeOrKey, keyEncoding, generator, genEncoding);
- if (!util.isBuffer(sizeOrKey) &&
+ if (!(sizeOrKey instanceof Buffer) &&
typeof sizeOrKey !== 'number' &&
typeof sizeOrKey !== 'string')
throw new TypeError('First argument should be number, string or Buffer');
@@ -513,7 +513,7 @@ DiffieHellman.prototype.setPrivateKey = function(key, encoding) {
function ECDH(curve) {
- if (!util.isString(curve))
+ if (typeof curve !== 'string')
throw new TypeError('curve should be a string');
this._handle = new binding.ECDH(curve);
@@ -566,12 +566,12 @@ exports.pbkdf2 = function(password,
keylen,
digest,
callback) {
- if (util.isFunction(digest)) {
+ if (typeof digest === 'function') {
callback = digest;
digest = undefined;
}
- if (!util.isFunction(callback))
+ if (typeof callback !== 'function')
throw new Error('No callback provided to pbkdf2');
return pbkdf2(password, salt, iterations, keylen, digest, callback);
@@ -632,10 +632,10 @@ Certificate.prototype.exportChallenge = function(object, encoding) {
exports.setEngine = function setEngine(id, flags) {
- if (!util.isString(id))
+ if (typeof id !== 'string')
throw new TypeError('id should be a string');
- if (flags && !util.isNumber(flags))
+ if (flags && typeof flags !== 'number')
throw new TypeError('flags should be a number, if present');
flags = flags >>> 0;