diff options
Diffstat (limited to 'node_modules/browserify-aes/streamCipher.js')
-rw-r--r-- | node_modules/browserify-aes/streamCipher.js | 20 |
1 files changed, 11 insertions, 9 deletions
diff --git a/node_modules/browserify-aes/streamCipher.js b/node_modules/browserify-aes/streamCipher.js index a55c762d5..1877fa090 100644 --- a/node_modules/browserify-aes/streamCipher.js +++ b/node_modules/browserify-aes/streamCipher.js @@ -1,25 +1,27 @@ var aes = require('./aes') +var Buffer = require('safe-buffer').Buffer var Transform = require('cipher-base') var inherits = require('inherits') -inherits(StreamCipher, Transform) -module.exports = StreamCipher function StreamCipher (mode, key, iv, decrypt) { - if (!(this instanceof StreamCipher)) { - return new StreamCipher(mode, key, iv) - } Transform.call(this) + this._cipher = new aes.AES(key) - this._prev = new Buffer(iv.length) - this._cache = new Buffer('') - this._secCache = new Buffer('') + this._prev = Buffer.from(iv) + this._cache = Buffer.allocUnsafe(0) + this._secCache = Buffer.allocUnsafe(0) this._decrypt = decrypt - iv.copy(this._prev) this._mode = mode } + +inherits(StreamCipher, Transform) + StreamCipher.prototype._update = function (chunk) { return this._mode.encrypt(this, chunk, this._decrypt) } + StreamCipher.prototype._final = function () { this._cipher.scrub() } + +module.exports = StreamCipher |