Browse Source

crypto: Streaming interface for Sign and Verify

v0.9.4-release
isaacs 12 years ago
parent
commit
dd3ebb8cf6
  1. 20
      lib/crypto.js

20
lib/crypto.js

@ -340,16 +340,23 @@ 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.update = Hash.prototype.update;
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;
@ -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);
}
Verify.prototype.update = Hash.prototype.update;
util.inherits(Verify, stream.Writable);
Verify.prototype._write = Sign.prototype._write;
Verify.prototype.update = Sign.prototype.update;
Verify.prototype.verify = function(object, signature, sigEncoding) {
sigEncoding = sigEncoding || exports.DEFAULT_ENCODING;

Loading…
Cancel
Save