0
0
mirror of https://github.com/nodejs/node.git synced 2024-11-30 07:27:22 +01:00

crypto: Pass options to ctor calls

This commit is contained in:
isaacs 2013-03-29 09:39:51 -07:00
parent 1d17ced200
commit 7af075ee30

View File

@ -59,7 +59,7 @@ var StringDecoder = require('string_decoder').StringDecoder;
function Credentials(secureProtocol, flags, context) {
if (!(this instanceof Credentials)) {
return new Credentials(secureProtocol);
return new Credentials(secureProtocol, flags, context);
}
if (!crypto) {
@ -171,7 +171,7 @@ util.inherits(LazyTransform, stream.Transform);
exports.createHash = exports.Hash = Hash;
function Hash(algorithm, options) {
if (!(this instanceof Hash))
return new Hash(algorithm);
return new Hash(algorithm, options);
this._binding = new binding.Hash(algorithm);
LazyTransform.call(this, options);
}
@ -209,7 +209,7 @@ exports.createHmac = exports.Hmac = Hmac;
function Hmac(hmac, key, options) {
if (!(this instanceof Hmac))
return new Hmac(hmac, key);
return new Hmac(hmac, key, options);
this._binding = new binding.Hmac();
this._binding.init(hmac, toBuf(key));
LazyTransform.call(this, options);
@ -233,7 +233,7 @@ function getDecoder(decoder, encoding) {
exports.createCipher = exports.Cipher = Cipher;
function Cipher(cipher, password, options) {
if (!(this instanceof Cipher))
return new Cipher(cipher, password);
return new Cipher(cipher, password, options);
this._binding = new binding.Cipher;
this._binding.init(cipher, toBuf(password));
@ -293,7 +293,7 @@ Cipher.prototype.setAutoPadding = function(ap) {
exports.createCipheriv = exports.Cipheriv = Cipheriv;
function Cipheriv(cipher, key, iv, options) {
if (!(this instanceof Cipheriv))
return new Cipheriv(cipher, key, iv);
return new Cipheriv(cipher, key, iv, options);
this._binding = new binding.Cipher();
this._binding.initiv(cipher, toBuf(key), toBuf(iv));
this._decoder = null;
@ -314,7 +314,7 @@ Cipheriv.prototype.setAutoPadding = Cipher.prototype.setAutoPadding;
exports.createDecipher = exports.Decipher = Decipher;
function Decipher(cipher, password, options) {
if (!(this instanceof Decipher))
return new Decipher(cipher, password);
return new Decipher(cipher, password, options);
this._binding = new binding.Decipher;
this._binding.init(cipher, toBuf(password));
@ -337,7 +337,7 @@ Decipher.prototype.setAutoPadding = Cipher.prototype.setAutoPadding;
exports.createDecipheriv = exports.Decipheriv = Decipheriv;
function Decipheriv(cipher, key, iv, options) {
if (!(this instanceof Decipheriv))
return new Decipheriv(cipher, key, iv);
return new Decipheriv(cipher, key, iv, options);
this._binding = new binding.Decipher;
this._binding.initiv(cipher, toBuf(key), toBuf(iv));
@ -360,7 +360,7 @@ Decipheriv.prototype.setAutoPadding = Cipher.prototype.setAutoPadding;
exports.createSign = exports.Sign = Sign;
function Sign(algorithm, options) {
if (!(this instanceof Sign))
return new Sign(algorithm);
return new Sign(algorithm, options);
this._binding = new binding.Sign();
this._binding.init(algorithm);
@ -391,7 +391,7 @@ Sign.prototype.sign = function(key, encoding) {
exports.createVerify = exports.Verify = Verify;
function Verify(algorithm, options) {
if (!(this instanceof Verify))
return new Verify(algorithm);
return new Verify(algorithm, options);
this._binding = new binding.Verify;
this._binding.init(algorithm);