diff --git a/lib/crypto.js b/lib/crypto.js index e6b03968734..0033267ceee 100644 --- a/lib/crypto.js +++ b/lib/crypto.js @@ -340,17 +340,24 @@ Decipheriv.prototype.setAutoPadding = Cipher.prototype.setAutoPadding; exports.createSign = exports.Sign = Sign; -function Sign(algorithm) { +function Sign(algorithm, options) { if (!(this instanceof Sign)) return new Sign(algorithm); this._binding = new binding.Sign(); this._binding.init(algorithm); + + stream.Writable.call(this, options); } +util.inherits(Sign, stream.Writable); + +Sign.prototype._write = function(chunk, callback) { + this._binding.update(chunk); + callback(); +}; Sign.prototype.update = Hash.prototype.update; - Sign.prototype.sign = function(key, encoding) { encoding = encoding || exports.DEFAULT_ENCODING; var ret = this._binding.sign(toBuf(key)); @@ -364,17 +371,20 @@ Sign.prototype.sign = function(key, encoding) { exports.createVerify = exports.Verify = Verify; -function Verify(algorithm) { +function Verify(algorithm, options) { if (!(this instanceof Verify)) return new Verify(algorithm); this._binding = new binding.Verify; this._binding.init(algorithm); + + stream.Writable.call(this, options); } +util.inherits(Verify, stream.Writable); -Verify.prototype.update = Hash.prototype.update; - +Verify.prototype._write = Sign.prototype._write; +Verify.prototype.update = Sign.prototype.update; Verify.prototype.verify = function(object, signature, sigEncoding) { sigEncoding = sigEncoding || exports.DEFAULT_ENCODING;