Skip to content

Instantly share code, notes, and snippets.

@isaacs
Last active December 15, 2015 14:09
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save isaacs/5271988 to your computer and use it in GitHub Desktop.
Save isaacs/5271988 to your computer and use it in GitHub Desktop.
From 7af075ee30485e6f2d295d3ad32923dd5ecb7536 Mon Sep 17 00:00:00 2001
From: isaacs <i@izs.me>
Date: Fri, 29 Mar 2013 09:39:51 -0700
Subject: [PATCH] crypto: Pass options to ctor calls
---
lib/crypto.js | 18 +++++++++---------
1 files changed, 9 insertions(+), 9 deletions(-)
diff --git a/lib/crypto.js b/lib/crypto.js
index 94c9569..f716ce0 100644
--- a/lib/crypto.js
+++ b/lib/crypto.js
@@ -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);
--
1.7.5.4
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment