aboutsummaryrefslogtreecommitdiff
path: root/node_modules/browserify-aes/streamCipher.js
diff options
context:
space:
mode:
authorFlorian Dold <florian.dold@gmail.com>2017-12-10 21:51:33 +0100
committerFlorian Dold <florian.dold@gmail.com>2017-12-10 21:51:33 +0100
commit0469abd4a9c9270a1fdc962969e36e63699af8b4 (patch)
treef9864d4a4148621378958794cbbfdc2393733283 /node_modules/browserify-aes/streamCipher.js
parent6947e79bbc258f7bc96af424ddb71a511f0c15a3 (diff)
upgrade dependencies
Diffstat (limited to 'node_modules/browserify-aes/streamCipher.js')
-rw-r--r--node_modules/browserify-aes/streamCipher.js20
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