summaryrefslogtreecommitdiffstats
path: root/node_modules/browserify-aes/streamCipher.js
diff options
context:
space:
mode:
Diffstat (limited to 'node_modules/browserify-aes/streamCipher.js')
-rw-r--r--node_modules/browserify-aes/streamCipher.js27
1 files changed, 27 insertions, 0 deletions
diff --git a/node_modules/browserify-aes/streamCipher.js b/node_modules/browserify-aes/streamCipher.js
new file mode 100644
index 0000000..1877fa0
--- /dev/null
+++ b/node_modules/browserify-aes/streamCipher.js
@@ -0,0 +1,27 @@
+var aes = require('./aes')
+var Buffer = require('safe-buffer').Buffer
+var Transform = require('cipher-base')
+var inherits = require('inherits')
+
+function StreamCipher (mode, key, iv, decrypt) {
+ Transform.call(this)
+
+ this._cipher = new aes.AES(key)
+ this._prev = Buffer.from(iv)
+ this._cache = Buffer.allocUnsafe(0)
+ this._secCache = Buffer.allocUnsafe(0)
+ this._decrypt = decrypt
+ 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