aboutsummaryrefslogtreecommitdiff
path: root/node_modules/browserify-aes
diff options
context:
space:
mode:
authorFlorian Dold <florian.dold@gmail.com>2017-05-03 15:35:00 +0200
committerFlorian Dold <florian.dold@gmail.com>2017-05-03 15:35:00 +0200
commitde98e0b232509d5f40c135d540a70e415272ff85 (patch)
treea79222a5b58484ab3b80d18efcaaa7ccc4769b33 /node_modules/browserify-aes
parente0c9d480a73fa629c1e4a47d3e721f1d2d345406 (diff)
downloadwallet-core-de98e0b232509d5f40c135d540a70e415272ff85.tar.xz
node_modules
Diffstat (limited to 'node_modules/browserify-aes')
-rw-r--r--node_modules/browserify-aes/.eslintrc132
-rw-r--r--node_modules/browserify-aes/.npmignore1
-rw-r--r--node_modules/browserify-aes/.travis.yml6
-rw-r--r--node_modules/browserify-aes/LICENSE21
-rw-r--r--node_modules/browserify-aes/aes.js177
-rw-r--r--node_modules/browserify-aes/authCipher.js97
-rw-r--r--node_modules/browserify-aes/browser.js11
-rw-r--r--node_modules/browserify-aes/decrypter.js137
-rw-r--r--node_modules/browserify-aes/encrypter.js122
-rw-r--r--node_modules/browserify-aes/ghash.js98
-rw-r--r--node_modules/browserify-aes/index.js7
-rw-r--r--node_modules/browserify-aes/modes.js171
-rw-r--r--node_modules/browserify-aes/modes/cbc.js17
-rw-r--r--node_modules/browserify-aes/modes/cfb.js31
-rw-r--r--node_modules/browserify-aes/modes/cfb1.js34
-rw-r--r--node_modules/browserify-aes/modes/cfb8.js15
-rw-r--r--node_modules/browserify-aes/modes/ctr.js31
-rw-r--r--node_modules/browserify-aes/modes/ecb.js6
-rw-r--r--node_modules/browserify-aes/modes/ofb.js16
-rw-r--r--node_modules/browserify-aes/package.json40
-rw-r--r--node_modules/browserify-aes/populateFixtures.js25
-rw-r--r--node_modules/browserify-aes/readme.md18
-rw-r--r--node_modules/browserify-aes/streamCipher.js25
23 files changed, 1238 insertions, 0 deletions
diff --git a/node_modules/browserify-aes/.eslintrc b/node_modules/browserify-aes/.eslintrc
new file mode 100644
index 000000000..bed248a0d
--- /dev/null
+++ b/node_modules/browserify-aes/.eslintrc
@@ -0,0 +1,132 @@
+{
+ "ecmaFeatures": {
+ "modules": true,
+ "experimentalObjectRestSpread": true
+ },
+
+ "env": {
+ "browser": false,
+ "es6": true,
+ "node": true
+ },
+
+ "plugins": [
+ "standard"
+ ],
+
+ "globals": {
+ "document": false,
+ "navigator": false,
+ "window": false
+ },
+
+ "rules": {
+ "accessor-pairs": 2,
+ "arrow-spacing": [2, { "before": true, "after": true }],
+ "block-spacing": [2, "always"],
+ "brace-style": [2, "1tbs", { "allowSingleLine": true }],
+ "comma-dangle": [2, "never"],
+ "comma-spacing": [2, { "before": false, "after": true }],
+ "comma-style": [2, "last"],
+ "constructor-super": 2,
+ "curly": [2, "multi-line"],
+ "dot-location": [2, "property"],
+ "eol-last": 2,
+ "eqeqeq": [2, "allow-null"],
+ "generator-star-spacing": [2, { "before": true, "after": true }],
+ "handle-callback-err": [2, "^(err|error)$" ],
+ "indent": [2, 2, { "SwitchCase": 1 }],
+ "key-spacing": [2, { "beforeColon": false, "afterColon": true }],
+ "new-cap": [2, { "newIsCap": true, "capIsNew": false }],
+ "new-parens": 2,
+ "no-array-constructor": 2,
+ "no-caller": 2,
+ "no-class-assign": 2,
+ "no-cond-assign": 2,
+ "no-const-assign": 2,
+ "no-control-regex": 2,
+ "no-debugger": 2,
+ "no-delete-var": 2,
+ "no-dupe-args": 2,
+ "no-dupe-class-members": 2,
+ "no-dupe-keys": 2,
+ "no-duplicate-case": 2,
+ "no-empty-character-class": 2,
+ "no-empty-label": 2,
+ "no-eval": 2,
+ "no-ex-assign": 2,
+ "no-extend-native": 2,
+ "no-extra-bind": 2,
+ "no-extra-boolean-cast": 2,
+ "no-extra-parens": [2, "functions"],
+ "no-fallthrough": 2,
+ "no-floating-decimal": 2,
+ "no-func-assign": 2,
+ "no-implied-eval": 2,
+ "no-inner-declarations": [2, "functions"],
+ "no-invalid-regexp": 2,
+ "no-irregular-whitespace": 2,
+ "no-iterator": 2,
+ "no-label-var": 2,
+ "no-labels": 2,
+ "no-lone-blocks": 2,
+ "no-mixed-spaces-and-tabs": 2,
+ "no-multi-spaces": 2,
+ "no-multi-str": 2,
+ "no-multiple-empty-lines": [2, { "max": 1 }],
+ "no-native-reassign": 2,
+ "no-negated-in-lhs": 2,
+ "no-new": 2,
+ "no-new-func": 2,
+ "no-new-object": 2,
+ "no-new-require": 2,
+ "no-new-wrappers": 2,
+ "no-obj-calls": 2,
+ "no-octal": 2,
+ "no-octal-escape": 2,
+ "no-proto": 2,
+ "no-redeclare": 2,
+ "no-regex-spaces": 2,
+ "no-return-assign": 2,
+ "no-self-compare": 2,
+ "no-sequences": 2,
+ "no-shadow-restricted-names": 2,
+ "no-spaced-func": 2,
+ "no-sparse-arrays": 2,
+ "no-this-before-super": 2,
+ "no-throw-literal": 2,
+ "no-trailing-spaces": 2,
+ "no-undef": 2,
+ "no-undef-init": 2,
+ "no-unexpected-multiline": 2,
+ "no-unneeded-ternary": [2, { "defaultAssignment": false }],
+ "no-unreachable": 2,
+ "no-unused-vars": [2, { "vars": "all", "args": "none" }],
+ "no-useless-call": 2,
+ "no-with": 2,
+ "one-var": [2, { "initialized": "never" }],
+ "operator-linebreak": [2, "after", { "overrides": { "?": "before", ":": "before" } }],
+ "padded-blocks": [2, "never"],
+ "quotes": [2, "single", "avoid-escape"],
+ "radix": 2,
+ "semi": [2, "never"],
+ "semi-spacing": [2, { "before": false, "after": true }],
+ "space-after-keywords": [2, "always"],
+ "space-before-blocks": [2, "always"],
+ "space-before-function-paren": [2, "always"],
+ "space-before-keywords": [2, "always"],
+ "space-in-parens": [2, "never"],
+ "space-infix-ops": 2,
+ "space-return-throw-case": 2,
+ "space-unary-ops": [2, { "words": true, "nonwords": false }],
+ "spaced-comment": [2, "always", { "markers": ["global", "globals", "eslint", "eslint-disable", "*package", "!", ","] }],
+ "use-isnan": 2,
+ "valid-typeof": 2,
+ "wrap-iife": [2, "any"],
+ "yoda": [2, "never"],
+
+ "standard/object-curly-even-spacing": [2, "either"],
+ "standard/array-bracket-even-spacing": [2, "either"],
+ "standard/computed-property-even-spacing": [2, "even"]
+ }
+}
diff --git a/node_modules/browserify-aes/.npmignore b/node_modules/browserify-aes/.npmignore
new file mode 100644
index 000000000..65e3ba2ed
--- /dev/null
+++ b/node_modules/browserify-aes/.npmignore
@@ -0,0 +1 @@
+test/
diff --git a/node_modules/browserify-aes/.travis.yml b/node_modules/browserify-aes/.travis.yml
new file mode 100644
index 000000000..eb83acd99
--- /dev/null
+++ b/node_modules/browserify-aes/.travis.yml
@@ -0,0 +1,6 @@
+language: node_js
+node_js:
+ - "0.11"
+ - "0.10"
+ - "0.12"
+ - "iojs"
diff --git a/node_modules/browserify-aes/LICENSE b/node_modules/browserify-aes/LICENSE
new file mode 100644
index 000000000..924b38b1e
--- /dev/null
+++ b/node_modules/browserify-aes/LICENSE
@@ -0,0 +1,21 @@
+The MIT License (MIT)
+
+Copyright (c) 2014-2015 browserify-aes contributors
+
+Permission is hereby granted, free of charge, to any person obtaining a copy
+of this software and associated documentation files (the "Software"), to deal
+in the Software without restriction, including without limitation the rights
+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+copies of the Software, and to permit persons to whom the Software is
+furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in all
+copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+SOFTWARE.
diff --git a/node_modules/browserify-aes/aes.js b/node_modules/browserify-aes/aes.js
new file mode 100644
index 000000000..4829057f1
--- /dev/null
+++ b/node_modules/browserify-aes/aes.js
@@ -0,0 +1,177 @@
+// based on the aes implimentation in triple sec
+// https://github.com/keybase/triplesec
+
+// which is in turn based on the one from crypto-js
+// https://code.google.com/p/crypto-js/
+
+var uint_max = Math.pow(2, 32)
+function fixup_uint32 (x) {
+ var ret, x_pos
+ ret = x > uint_max || x < 0 ? (x_pos = Math.abs(x) % uint_max, x < 0 ? uint_max - x_pos : x_pos) : x
+ return ret
+}
+function scrub_vec (v) {
+ for (var i = 0; i < v.length; v++) {
+ v[i] = 0
+ }
+ return false
+}
+
+function Global () {
+ this.SBOX = []
+ this.INV_SBOX = []
+ this.SUB_MIX = [[], [], [], []]
+ this.INV_SUB_MIX = [[], [], [], []]
+ this.init()
+ this.RCON = [0x00, 0x01, 0x02, 0x04, 0x08, 0x10, 0x20, 0x40, 0x80, 0x1b, 0x36]
+}
+
+Global.prototype.init = function () {
+ var d, i, sx, t, x, x2, x4, x8, xi, _i
+ d = (function () {
+ var _i, _results
+ _results = []
+ for (i = _i = 0; _i < 256; i = ++_i) {
+ if (i < 128) {
+ _results.push(i << 1)
+ } else {
+ _results.push((i << 1) ^ 0x11b)
+ }
+ }
+ return _results
+ })()
+ x = 0
+ xi = 0
+ for (i = _i = 0; _i < 256; i = ++_i) {
+ sx = xi ^ (xi << 1) ^ (xi << 2) ^ (xi << 3) ^ (xi << 4)
+ sx = (sx >>> 8) ^ (sx & 0xff) ^ 0x63
+ this.SBOX[x] = sx
+ this.INV_SBOX[sx] = x
+ x2 = d[x]
+ x4 = d[x2]
+ x8 = d[x4]
+ t = (d[sx] * 0x101) ^ (sx * 0x1010100)
+ this.SUB_MIX[0][x] = (t << 24) | (t >>> 8)
+ this.SUB_MIX[1][x] = (t << 16) | (t >>> 16)
+ this.SUB_MIX[2][x] = (t << 8) | (t >>> 24)
+ this.SUB_MIX[3][x] = t
+ t = (x8 * 0x1010101) ^ (x4 * 0x10001) ^ (x2 * 0x101) ^ (x * 0x1010100)
+ this.INV_SUB_MIX[0][sx] = (t << 24) | (t >>> 8)
+ this.INV_SUB_MIX[1][sx] = (t << 16) | (t >>> 16)
+ this.INV_SUB_MIX[2][sx] = (t << 8) | (t >>> 24)
+ this.INV_SUB_MIX[3][sx] = t
+ if (x === 0) {
+ x = xi = 1
+ } else {
+ x = x2 ^ d[d[d[x8 ^ x2]]]
+ xi ^= d[d[xi]]
+ }
+ }
+ return true
+}
+
+var G = new Global()
+
+AES.blockSize = 4 * 4
+
+AES.prototype.blockSize = AES.blockSize
+
+AES.keySize = 256 / 8
+
+AES.prototype.keySize = AES.keySize
+
+function bufferToArray (buf) {
+ var len = buf.length / 4
+ var out = new Array(len)
+ var i = -1
+ while (++i < len) {
+ out[i] = buf.readUInt32BE(i * 4)
+ }
+ return out
+}
+function AES (key) {
+ this._key = bufferToArray(key)
+ this._doReset()
+}
+
+AES.prototype._doReset = function () {
+ var invKsRow, keySize, keyWords, ksRow, ksRows, t
+ keyWords = this._key
+ keySize = keyWords.length
+ this._nRounds = keySize + 6
+ ksRows = (this._nRounds + 1) * 4
+ this._keySchedule = []
+ for (ksRow = 0; ksRow < ksRows; ksRow++) {
+ this._keySchedule[ksRow] = ksRow < keySize ? keyWords[ksRow] : (t = this._keySchedule[ksRow - 1], (ksRow % keySize) === 0 ? (t = (t << 8) | (t >>> 24), t = (G.SBOX[t >>> 24] << 24) | (G.SBOX[(t >>> 16) & 0xff] << 16) | (G.SBOX[(t >>> 8) & 0xff] << 8) | G.SBOX[t & 0xff], t ^= G.RCON[(ksRow / keySize) | 0] << 24) : keySize > 6 && ksRow % keySize === 4 ? t = (G.SBOX[t >>> 24] << 24) | (G.SBOX[(t >>> 16) & 0xff] << 16) | (G.SBOX[(t >>> 8) & 0xff] << 8) | G.SBOX[t & 0xff] : void 0, this._keySchedule[ksRow - keySize] ^ t)
+ }
+ this._invKeySchedule = []
+ for (invKsRow = 0; invKsRow < ksRows; invKsRow++) {
+ ksRow = ksRows - invKsRow
+ t = this._keySchedule[ksRow - (invKsRow % 4 ? 0 : 4)]
+ this._invKeySchedule[invKsRow] = invKsRow < 4 || ksRow <= 4 ? t : G.INV_SUB_MIX[0][G.SBOX[t >>> 24]] ^ G.INV_SUB_MIX[1][G.SBOX[(t >>> 16) & 0xff]] ^ G.INV_SUB_MIX[2][G.SBOX[(t >>> 8) & 0xff]] ^ G.INV_SUB_MIX[3][G.SBOX[t & 0xff]]
+ }
+ return true
+}
+
+AES.prototype.encryptBlock = function (M) {
+ M = bufferToArray(new Buffer(M))
+ var out = this._doCryptBlock(M, this._keySchedule, G.SUB_MIX, G.SBOX)
+ var buf = new Buffer(16)
+ buf.writeUInt32BE(out[0], 0)
+ buf.writeUInt32BE(out[1], 4)
+ buf.writeUInt32BE(out[2], 8)
+ buf.writeUInt32BE(out[3], 12)
+ return buf
+}
+
+AES.prototype.decryptBlock = function (M) {
+ M = bufferToArray(new Buffer(M))
+ var temp = [M[3], M[1]]
+ M[1] = temp[0]
+ M[3] = temp[1]
+ var out = this._doCryptBlock(M, this._invKeySchedule, G.INV_SUB_MIX, G.INV_SBOX)
+ var buf = new Buffer(16)
+ buf.writeUInt32BE(out[0], 0)
+ buf.writeUInt32BE(out[3], 4)
+ buf.writeUInt32BE(out[2], 8)
+ buf.writeUInt32BE(out[1], 12)
+ return buf
+}
+
+AES.prototype.scrub = function () {
+ scrub_vec(this._keySchedule)
+ scrub_vec(this._invKeySchedule)
+ scrub_vec(this._key)
+}
+
+AES.prototype._doCryptBlock = function (M, keySchedule, SUB_MIX, SBOX) {
+ var ksRow, s0, s1, s2, s3, t0, t1, t2, t3
+
+ s0 = M[0] ^ keySchedule[0]
+ s1 = M[1] ^ keySchedule[1]
+ s2 = M[2] ^ keySchedule[2]
+ s3 = M[3] ^ keySchedule[3]
+ ksRow = 4
+ for (var round = 1; round < this._nRounds; round++) {
+ t0 = SUB_MIX[0][s0 >>> 24] ^ SUB_MIX[1][(s1 >>> 16) & 0xff] ^ SUB_MIX[2][(s2 >>> 8) & 0xff] ^ SUB_MIX[3][s3 & 0xff] ^ keySchedule[ksRow++]
+ t1 = SUB_MIX[0][s1 >>> 24] ^ SUB_MIX[1][(s2 >>> 16) & 0xff] ^ SUB_MIX[2][(s3 >>> 8) & 0xff] ^ SUB_MIX[3][s0 & 0xff] ^ keySchedule[ksRow++]
+ t2 = SUB_MIX[0][s2 >>> 24] ^ SUB_MIX[1][(s3 >>> 16) & 0xff] ^ SUB_MIX[2][(s0 >>> 8) & 0xff] ^ SUB_MIX[3][s1 & 0xff] ^ keySchedule[ksRow++]
+ t3 = SUB_MIX[0][s3 >>> 24] ^ SUB_MIX[1][(s0 >>> 16) & 0xff] ^ SUB_MIX[2][(s1 >>> 8) & 0xff] ^ SUB_MIX[3][s2 & 0xff] ^ keySchedule[ksRow++]
+ s0 = t0
+ s1 = t1
+ s2 = t2
+ s3 = t3
+ }
+ t0 = ((SBOX[s0 >>> 24] << 24) | (SBOX[(s1 >>> 16) & 0xff] << 16) | (SBOX[(s2 >>> 8) & 0xff] << 8) | SBOX[s3 & 0xff]) ^ keySchedule[ksRow++]
+ t1 = ((SBOX[s1 >>> 24] << 24) | (SBOX[(s2 >>> 16) & 0xff] << 16) | (SBOX[(s3 >>> 8) & 0xff] << 8) | SBOX[s0 & 0xff]) ^ keySchedule[ksRow++]
+ t2 = ((SBOX[s2 >>> 24] << 24) | (SBOX[(s3 >>> 16) & 0xff] << 16) | (SBOX[(s0 >>> 8) & 0xff] << 8) | SBOX[s1 & 0xff]) ^ keySchedule[ksRow++]
+ t3 = ((SBOX[s3 >>> 24] << 24) | (SBOX[(s0 >>> 16) & 0xff] << 16) | (SBOX[(s1 >>> 8) & 0xff] << 8) | SBOX[s2 & 0xff]) ^ keySchedule[ksRow++]
+ return [
+ fixup_uint32(t0),
+ fixup_uint32(t1),
+ fixup_uint32(t2),
+ fixup_uint32(t3)
+ ]
+}
+
+exports.AES = AES
diff --git a/node_modules/browserify-aes/authCipher.js b/node_modules/browserify-aes/authCipher.js
new file mode 100644
index 000000000..1107a01a5
--- /dev/null
+++ b/node_modules/browserify-aes/authCipher.js
@@ -0,0 +1,97 @@
+var aes = require('./aes')
+var Transform = require('cipher-base')
+var inherits = require('inherits')
+var GHASH = require('./ghash')
+var xor = require('buffer-xor')
+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._finID = Buffer.concat([iv, new Buffer([0, 0, 0, 1])])
+ iv = Buffer.concat([iv, new Buffer([0, 0, 0, 2])])
+ this._cipher = new aes.AES(key)
+ this._prev = new Buffer(iv.length)
+ this._cache = new Buffer('')
+ this._secCache = new Buffer('')
+ this._decrypt = decrypt
+ this._alen = 0
+ this._len = 0
+ iv.copy(this._prev)
+ this._mode = mode
+ var h = new Buffer(4)
+ h.fill(0)
+ this._ghash = new GHASH(this._cipher.encryptBlock(h))
+ this._authTag = null
+ this._called = false
+}
+StreamCipher.prototype._update = function (chunk) {
+ if (!this._called && this._alen) {
+ var rump = 16 - (this._alen % 16)
+ if (rump < 16) {
+ rump = new Buffer(rump)
+ rump.fill(0)
+ this._ghash.update(rump)
+ }
+ }
+ this._called = true
+ var out = this._mode.encrypt(this, chunk)
+ if (this._decrypt) {
+ this._ghash.update(chunk)
+ } else {
+ this._ghash.update(out)
+ }
+ this._len += chunk.length
+ return out
+}
+StreamCipher.prototype._final = function () {
+ if (this._decrypt && !this._authTag) {
+ throw new Error('Unsupported state or unable to authenticate data')
+ }
+ var tag = xor(this._ghash.final(this._alen * 8, this._len * 8), this._cipher.encryptBlock(this._finID))
+ if (this._decrypt) {
+ if (xorTest(tag, this._authTag)) {
+ throw new Error('Unsupported state or unable to authenticate data')
+ }
+ } else {
+ this._authTag = tag
+ }
+ this._cipher.scrub()
+}
+StreamCipher.prototype.getAuthTag = function getAuthTag () {
+ if (!this._decrypt && Buffer.isBuffer(this._authTag)) {
+ return this._authTag
+ } else {
+ throw new Error('Attempting to get auth tag in unsupported state')
+ }
+}
+StreamCipher.prototype.setAuthTag = function setAuthTag (tag) {
+ if (this._decrypt) {
+ this._authTag = tag
+ } else {
+ throw new Error('Attempting to set auth tag in unsupported state')
+ }
+}
+StreamCipher.prototype.setAAD = function setAAD (buf) {
+ if (!this._called) {
+ this._ghash.update(buf)
+ this._alen += buf.length
+ } else {
+ throw new Error('Attempting to set AAD in unsupported state')
+ }
+}
+function xorTest (a, b) {
+ var out = 0
+ if (a.length !== b.length) {
+ out++
+ }
+ var len = Math.min(a.length, b.length)
+ var i = -1
+ while (++i < len) {
+ out += (a[i] ^ b[i])
+ }
+ return out
+}
diff --git a/node_modules/browserify-aes/browser.js b/node_modules/browserify-aes/browser.js
new file mode 100644
index 000000000..a058a84d1
--- /dev/null
+++ b/node_modules/browserify-aes/browser.js
@@ -0,0 +1,11 @@
+var ciphers = require('./encrypter')
+exports.createCipher = exports.Cipher = ciphers.createCipher
+exports.createCipheriv = exports.Cipheriv = ciphers.createCipheriv
+var deciphers = require('./decrypter')
+exports.createDecipher = exports.Decipher = deciphers.createDecipher
+exports.createDecipheriv = exports.Decipheriv = deciphers.createDecipheriv
+var modes = require('./modes')
+function getCiphers () {
+ return Object.keys(modes)
+}
+exports.listCiphers = exports.getCiphers = getCiphers
diff --git a/node_modules/browserify-aes/decrypter.js b/node_modules/browserify-aes/decrypter.js
new file mode 100644
index 000000000..b7b8bb02b
--- /dev/null
+++ b/node_modules/browserify-aes/decrypter.js
@@ -0,0 +1,137 @@
+var aes = require('./aes')
+var Transform = require('cipher-base')
+var inherits = require('inherits')
+var modes = require('./modes')
+var StreamCipher = require('./streamCipher')
+var AuthCipher = require('./authCipher')
+var ebtk = require('evp_bytestokey')
+
+inherits(Decipher, Transform)
+function Decipher (mode, key, iv) {
+ if (!(this instanceof Decipher)) {
+ return new Decipher(mode, key, iv)
+ }
+ Transform.call(this)
+ this._cache = new Splitter()
+ this._last = void 0
+ this._cipher = new aes.AES(key)
+ this._prev = new Buffer(iv.length)
+ iv.copy(this._prev)
+ this._mode = mode
+ this._autopadding = true
+}
+Decipher.prototype._update = function (data) {
+ this._cache.add(data)
+ var chunk
+ var thing
+ var out = []
+ while ((chunk = this._cache.get(this._autopadding))) {
+ thing = this._mode.decrypt(this, chunk)
+ out.push(thing)
+ }
+ return Buffer.concat(out)
+}
+Decipher.prototype._final = function () {
+ var chunk = this._cache.flush()
+ if (this._autopadding) {
+ return unpad(this._mode.decrypt(this, chunk))
+ } else if (chunk) {
+ throw new Error('data not multiple of block length')
+ }
+}
+Decipher.prototype.setAutoPadding = function (setTo) {
+ this._autopadding = !!setTo
+ return this
+}
+function Splitter () {
+ if (!(this instanceof Splitter)) {
+ return new Splitter()
+ }
+ this.cache = new Buffer('')
+}
+Splitter.prototype.add = function (data) {
+ this.cache = Buffer.concat([this.cache, data])
+}
+
+Splitter.prototype.get = function (autoPadding) {
+ var out
+ if (autoPadding) {
+ if (this.cache.length > 16) {
+ out = this.cache.slice(0, 16)
+ this.cache = this.cache.slice(16)
+ return out
+ }
+ } else {
+ if (this.cache.length >= 16) {
+ out = this.cache.slice(0, 16)
+ this.cache = this.cache.slice(16)
+ return out
+ }
+ }
+ return null
+}
+Splitter.prototype.flush = function () {
+ if (this.cache.length) {
+ return this.cache
+ }
+}
+function unpad (last) {
+ var padded = last[15]
+ var i = -1
+ while (++i < padded) {
+ if (last[(i + (16 - padded))] !== padded) {
+ throw new Error('unable to decrypt data')
+ }
+ }
+ if (padded === 16) {
+ return
+ }
+ return last.slice(0, 16 - padded)
+}
+
+var modelist = {
+ ECB: require('./modes/ecb'),
+ CBC: require('./modes/cbc'),
+ CFB: require('./modes/cfb'),
+ CFB8: require('./modes/cfb8'),
+ CFB1: require('./modes/cfb1'),
+ OFB: require('./modes/ofb'),
+ CTR: require('./modes/ctr'),
+ GCM: require('./modes/ctr')
+}
+
+function createDecipheriv (suite, password, iv) {
+ var config = modes[suite.toLowerCase()]
+ if (!config) {
+ throw new TypeError('invalid suite type')
+ }
+ if (typeof iv === 'string') {
+ iv = new Buffer(iv)
+ }
+ if (typeof password === 'string') {
+ password = new Buffer(password)
+ }
+ if (password.length !== config.key / 8) {
+ throw new TypeError('invalid key length ' + password.length)
+ }
+ if (iv.length !== config.iv) {
+ throw new TypeError('invalid iv length ' + iv.length)
+ }
+ if (config.type === 'stream') {
+ return new StreamCipher(modelist[config.mode], password, iv, true)
+ } else if (config.type === 'auth') {
+ return new AuthCipher(modelist[config.mode], password, iv, true)
+ }
+ return new Decipher(modelist[config.mode], password, iv)
+}
+
+function createDecipher (suite, password) {
+ var config = modes[suite.toLowerCase()]
+ if (!config) {
+ throw new TypeError('invalid suite type')
+ }
+ var keys = ebtk(password, false, config.key, config.iv)
+ return createDecipheriv(suite, keys.key, keys.iv)
+}
+exports.createDecipher = createDecipher
+exports.createDecipheriv = createDecipheriv
diff --git a/node_modules/browserify-aes/encrypter.js b/node_modules/browserify-aes/encrypter.js
new file mode 100644
index 000000000..3d3f561e3
--- /dev/null
+++ b/node_modules/browserify-aes/encrypter.js
@@ -0,0 +1,122 @@
+var aes = require('./aes')
+var Transform = require('cipher-base')
+var inherits = require('inherits')
+var modes = require('./modes')
+var ebtk = require('evp_bytestokey')
+var StreamCipher = require('./streamCipher')
+var AuthCipher = require('./authCipher')
+inherits(Cipher, Transform)
+function Cipher (mode, key, iv) {
+ if (!(this instanceof Cipher)) {
+ return new Cipher(mode, key, iv)
+ }
+ Transform.call(this)
+ this._cache = new Splitter()
+ this._cipher = new aes.AES(key)
+ this._prev = new Buffer(iv.length)
+ iv.copy(this._prev)
+ this._mode = mode
+ this._autopadding = true
+}
+Cipher.prototype._update = function (data) {
+ this._cache.add(data)
+ var chunk
+ var thing
+ var out = []
+ while ((chunk = this._cache.get())) {
+ thing = this._mode.encrypt(this, chunk)
+ out.push(thing)
+ }
+ return Buffer.concat(out)
+}
+Cipher.prototype._final = function () {
+ var chunk = this._cache.flush()
+ if (this._autopadding) {
+ chunk = this._mode.encrypt(this, chunk)
+ this._cipher.scrub()
+ return chunk
+ } else if (chunk.toString('hex') !== '10101010101010101010101010101010') {
+ this._cipher.scrub()
+ throw new Error('data not multiple of block length')
+ }
+}
+Cipher.prototype.setAutoPadding = function (setTo) {
+ this._autopadding = !!setTo
+ return this
+}
+
+function Splitter () {
+ if (!(this instanceof Splitter)) {
+ return new Splitter()
+ }
+ this.cache = new Buffer('')
+}
+Splitter.prototype.add = function (data) {
+ this.cache = Buffer.concat([this.cache, data])
+}
+
+Splitter.prototype.get = function () {
+ if (this.cache.length > 15) {
+ var out = this.cache.slice(0, 16)
+ this.cache = this.cache.slice(16)
+ return out
+ }
+ return null
+}
+Splitter.prototype.flush = function () {
+ var len = 16 - this.cache.length
+ var padBuff = new Buffer(len)
+
+ var i = -1
+ while (++i < len) {
+ padBuff.writeUInt8(len, i)
+ }
+ var out = Buffer.concat([this.cache, padBuff])
+ return out
+}
+var modelist = {
+ ECB: require('./modes/ecb'),
+ CBC: require('./modes/cbc'),
+ CFB: require('./modes/cfb'),
+ CFB8: require('./modes/cfb8'),
+ CFB1: require('./modes/cfb1'),
+ OFB: require('./modes/ofb'),
+ CTR: require('./modes/ctr'),
+ GCM: require('./modes/ctr')
+}
+
+function createCipheriv (suite, password, iv) {
+ var config = modes[suite.toLowerCase()]
+ if (!config) {
+ throw new TypeError('invalid suite type')
+ }
+ if (typeof iv === 'string') {
+ iv = new Buffer(iv)
+ }
+ if (typeof password === 'string') {
+ password = new Buffer(password)
+ }
+ if (password.length !== config.key / 8) {
+ throw new TypeError('invalid key length ' + password.length)
+ }
+ if (iv.length !== config.iv) {
+ throw new TypeError('invalid iv length ' + iv.length)
+ }
+ if (config.type === 'stream') {
+ return new StreamCipher(modelist[config.mode], password, iv)
+ } else if (config.type === 'auth') {
+ return new AuthCipher(modelist[config.mode], password, iv)
+ }
+ return new Cipher(modelist[config.mode], password, iv)
+}
+function createCipher (suite, password) {
+ var config = modes[suite.toLowerCase()]
+ if (!config) {
+ throw new TypeError('invalid suite type')
+ }
+ var keys = ebtk(password, false, config.key, config.iv)
+ return createCipheriv(suite, keys.key, keys.iv)
+}
+
+exports.createCipheriv = createCipheriv
+exports.createCipher = createCipher
diff --git a/node_modules/browserify-aes/ghash.js b/node_modules/browserify-aes/ghash.js
new file mode 100644
index 000000000..0ca143cd7
--- /dev/null
+++ b/node_modules/browserify-aes/ghash.js
@@ -0,0 +1,98 @@
+var zeros = new Buffer(16)
+zeros.fill(0)
+module.exports = GHASH
+function GHASH (key) {
+ this.h = key
+ this.state = new Buffer(16)
+ this.state.fill(0)
+ this.cache = new Buffer('')
+}
+// from http://bitwiseshiftleft.github.io/sjcl/doc/symbols/src/core_gcm.js.html
+// by Juho Vähä-Herttua
+GHASH.prototype.ghash = function (block) {
+ var i = -1
+ while (++i < block.length) {
+ this.state[i] ^= block[i]
+ }
+ this._multiply()
+}
+
+GHASH.prototype._multiply = function () {
+ var Vi = toArray(this.h)
+ var Zi = [0, 0, 0, 0]
+ var j, xi, lsb_Vi
+ var i = -1
+ while (++i < 128) {
+ xi = (this.state[~~(i / 8)] & (1 << (7 - i % 8))) !== 0
+ if (xi) {
+ // Z_i+1 = Z_i ^ V_i
+ Zi = xor(Zi, Vi)
+ }
+
+ // Store the value of LSB(V_i)
+ lsb_Vi = (Vi[3] & 1) !== 0
+
+ // V_i+1 = V_i >> 1
+ for (j = 3; j > 0; j--) {
+ Vi[j] = (Vi[j] >>> 1) | ((Vi[j - 1] & 1) << 31)
+ }
+ Vi[0] = Vi[0] >>> 1
+
+ // If LSB(V_i) is 1, V_i+1 = (V_i >> 1) ^ R
+ if (lsb_Vi) {
+ Vi[0] = Vi[0] ^ (0xe1 << 24)
+ }
+ }
+ this.state = fromArray(Zi)
+}
+GHASH.prototype.update = function (buf) {
+ this.cache = Buffer.concat([this.cache, buf])
+ var chunk
+ while (this.cache.length >= 16) {
+ chunk = this.cache.slice(0, 16)
+ this.cache = this.cache.slice(16)
+ this.ghash(chunk)
+ }
+}
+GHASH.prototype.final = function (abl, bl) {
+ if (this.cache.length) {
+ this.ghash(Buffer.concat([this.cache, zeros], 16))
+ }
+ this.ghash(fromArray([
+ 0, abl,
+ 0, bl
+ ]))
+ return this.state
+}
+
+function toArray (buf) {
+ return [
+ buf.readUInt32BE(0),
+ buf.readUInt32BE(4),
+ buf.readUInt32BE(8),
+ buf.readUInt32BE(12)
+ ]
+}
+function fromArray (out) {
+ out = out.map(fixup_uint32)
+ var buf = new Buffer(16)
+ buf.writeUInt32BE(out[0], 0)
+ buf.writeUInt32BE(out[1], 4)
+ buf.writeUInt32BE(out[2], 8)
+ buf.writeUInt32BE(out[3], 12)
+ return buf
+}
+var uint_max = Math.pow(2, 32)
+function fixup_uint32 (x) {
+ var ret, x_pos
+ ret = x > uint_max || x < 0 ? (x_pos = Math.abs(x) % uint_max, x < 0 ? uint_max - x_pos : x_pos) : x
+ return ret
+}
+function xor (a, b) {
+ return [
+ a[0] ^ b[0],
+ a[1] ^ b[1],
+ a[2] ^ b[2],
+ a[3] ^ b[3]
+ ]
+}
diff --git a/node_modules/browserify-aes/index.js b/node_modules/browserify-aes/index.js
new file mode 100644
index 000000000..58fa883ff
--- /dev/null
+++ b/node_modules/browserify-aes/index.js
@@ -0,0 +1,7 @@
+var crypto = require('crypto')
+
+exports.createCipher = exports.Cipher = crypto.createCipher
+exports.createCipheriv = exports.Cipheriv = crypto.createCipheriv
+exports.createDecipher = exports.Decipher = crypto.createDecipher
+exports.createDecipheriv = exports.Decipheriv = crypto.createDecipheriv
+exports.listCiphers = exports.getCiphers = crypto.getCiphers
diff --git a/node_modules/browserify-aes/modes.js b/node_modules/browserify-aes/modes.js
new file mode 100644
index 000000000..c070086dc
--- /dev/null
+++ b/node_modules/browserify-aes/modes.js
@@ -0,0 +1,171 @@
+exports['aes-128-ecb'] = {
+ cipher: 'AES',
+ key: 128,
+ iv: 0,
+ mode: 'ECB',
+ type: 'block'
+}
+exports['aes-192-ecb'] = {
+ cipher: 'AES',
+ key: 192,
+ iv: 0,
+ mode: 'ECB',
+ type: 'block'
+}
+exports['aes-256-ecb'] = {
+ cipher: 'AES',
+ key: 256,
+ iv: 0,
+ mode: 'ECB',
+ type: 'block'
+}
+exports['aes-128-cbc'] = {
+ cipher: 'AES',
+ key: 128,
+ iv: 16,
+ mode: 'CBC',
+ type: 'block'
+}
+exports['aes-192-cbc'] = {
+ cipher: 'AES',
+ key: 192,
+ iv: 16,
+ mode: 'CBC',
+ type: 'block'
+}
+exports['aes-256-cbc'] = {
+ cipher: 'AES',
+ key: 256,
+ iv: 16,
+ mode: 'CBC',
+ type: 'block'
+}
+exports['aes128'] = exports['aes-128-cbc']
+exports['aes192'] = exports['aes-192-cbc']
+exports['aes256'] = exports['aes-256-cbc']
+exports['aes-128-cfb'] = {
+ cipher: 'AES',
+ key: 128,
+ iv: 16,
+ mode: 'CFB',
+ type: 'stream'
+}
+exports['aes-192-cfb'] = {
+ cipher: 'AES',
+ key: 192,
+ iv: 16,
+ mode: 'CFB',
+ type: 'stream'
+}
+exports['aes-256-cfb'] = {
+ cipher: 'AES',
+ key: 256,
+ iv: 16,
+ mode: 'CFB',
+ type: 'stream'
+}
+exports['aes-128-cfb8'] = {
+ cipher: 'AES',
+ key: 128,
+ iv: 16,
+ mode: 'CFB8',
+ type: 'stream'
+}
+exports['aes-192-cfb8'] = {
+ cipher: 'AES',
+ key: 192,
+ iv: 16,
+ mode: 'CFB8',
+ type: 'stream'
+}
+exports['aes-256-cfb8'] = {
+ cipher: 'AES',
+ key: 256,
+ iv: 16,
+ mode: 'CFB8',
+ type: 'stream'
+}
+exports['aes-128-cfb1'] = {
+ cipher: 'AES',
+ key: 128,
+ iv: 16,
+ mode: 'CFB1',
+ type: 'stream'
+}
+exports['aes-192-cfb1'] = {
+ cipher: 'AES',
+ key: 192,
+ iv: 16,
+ mode: 'CFB1',
+ type: 'stream'
+}
+exports['aes-256-cfb1'] = {
+ cipher: 'AES',
+ key: 256,
+ iv: 16,
+ mode: 'CFB1',
+ type: 'stream'
+}
+exports['aes-128-ofb'] = {
+ cipher: 'AES',
+ key: 128,
+ iv: 16,
+ mode: 'OFB',
+ type: 'stream'
+}
+exports['aes-192-ofb'] = {
+ cipher: 'AES',
+ key: 192,
+ iv: 16,
+ mode: 'OFB',
+ type: 'stream'
+}
+exports['aes-256-ofb'] = {
+ cipher: 'AES',
+ key: 256,
+ iv: 16,
+ mode: 'OFB',
+ type: 'stream'
+}
+exports['aes-128-ctr'] = {
+ cipher: 'AES',
+ key: 128,
+ iv: 16,
+ mode: 'CTR',
+ type: 'stream'
+}
+exports['aes-192-ctr'] = {
+ cipher: 'AES',
+ key: 192,
+ iv: 16,
+ mode: 'CTR',
+ type: 'stream'
+}
+exports['aes-256-ctr'] = {
+ cipher: 'AES',
+ key: 256,
+ iv: 16,
+ mode: 'CTR',
+ type: 'stream'
+}
+exports['aes-128-gcm'] = {
+ cipher: 'AES',
+ key: 128,
+ iv: 12,
+ mode: 'GCM',
+ type: 'auth'
+}
+exports['aes-192-gcm'] = {
+ cipher: 'AES',
+ key: 192,
+ iv: 12,
+ mode: 'GCM',
+ type: 'auth'
+}
+exports['aes-256-gcm'] = {
+ cipher: 'AES',
+ key: 256,
+ iv: 12,
+ mode: 'GCM',
+ type: 'auth'
+}
diff --git a/node_modules/browserify-aes/modes/cbc.js b/node_modules/browserify-aes/modes/cbc.js
new file mode 100644
index 000000000..b133e4069
--- /dev/null
+++ b/node_modules/browserify-aes/modes/cbc.js
@@ -0,0 +1,17 @@
+var xor = require('buffer-xor')
+
+exports.encrypt = function (self, block) {
+ var data = xor(block, self._prev)
+
+ self._prev = self._cipher.encryptBlock(data)
+ return self._prev
+}
+
+exports.decrypt = function (self, block) {
+ var pad = self._prev
+
+ self._prev = block
+ var out = self._cipher.decryptBlock(block)
+
+ return xor(out, pad)
+}
diff --git a/node_modules/browserify-aes/modes/cfb.js b/node_modules/browserify-aes/modes/cfb.js
new file mode 100644
index 000000000..0bfe4fab8
--- /dev/null
+++ b/node_modules/browserify-aes/modes/cfb.js
@@ -0,0 +1,31 @@
+var xor = require('buffer-xor')
+
+exports.encrypt = function (self, data, decrypt) {
+ var out = new Buffer('')
+ var len
+
+ while (data.length) {
+ if (self._cache.length === 0) {
+ self._cache = self._cipher.encryptBlock(self._prev)
+ self._prev = new Buffer('')
+ }
+
+ if (self._cache.length <= data.length) {
+ len = self._cache.length
+ out = Buffer.concat([out, encryptStart(self, data.slice(0, len), decrypt)])
+ data = data.slice(len)
+ } else {
+ out = Buffer.concat([out, encryptStart(self, data, decrypt)])
+ break
+ }
+ }
+
+ return out
+}
+function encryptStart (self, data, decrypt) {
+ var len = data.length
+ var out = xor(data, self._cache)
+ self._cache = self._cache.slice(len)
+ self._prev = Buffer.concat([self._prev, decrypt ? data : out])
+ return out
+}
diff --git a/node_modules/browserify-aes/modes/cfb1.js b/node_modules/browserify-aes/modes/cfb1.js
new file mode 100644
index 000000000..335542e20
--- /dev/null
+++ b/node_modules/browserify-aes/modes/cfb1.js
@@ -0,0 +1,34 @@
+function encryptByte (self, byteParam, decrypt) {
+ var pad
+ var i = -1
+ var len = 8
+ var out = 0
+ var bit, value
+ while (++i < len) {
+ pad = self._cipher.encryptBlock(self._prev)
+ bit = (byteParam & (1 << (7 - i))) ? 0x80 : 0
+ value = pad[0] ^ bit
+ out += ((value & 0x80) >> (i % 8))
+ self._prev = shiftIn(self._prev, decrypt ? bit : value)
+ }
+ return out
+}
+exports.encrypt = function (self, chunk, decrypt) {
+ var len = chunk.length
+ var out = new Buffer(len)
+ var i = -1
+ while (++i < len) {
+ out[i] = encryptByte(self, chunk[i], decrypt)
+ }
+ return out
+}
+function shiftIn (buffer, value) {
+ var len = buffer.length
+ var i = -1
+ var out = new Buffer(buffer.length)
+ buffer = Buffer.concat([buffer, new Buffer([value])])
+ while (++i < len) {
+ out[i] = buffer[i] << 1 | buffer[i + 1] >> (7)
+ }
+ return out
+}
diff --git a/node_modules/browserify-aes/modes/cfb8.js b/node_modules/browserify-aes/modes/cfb8.js
new file mode 100644
index 000000000..c967a959f
--- /dev/null
+++ b/node_modules/browserify-aes/modes/cfb8.js
@@ -0,0 +1,15 @@
+function encryptByte (self, byteParam, decrypt) {
+ var pad = self._cipher.encryptBlock(self._prev)
+ var out = pad[0] ^ byteParam
+ self._prev = Buffer.concat([self._prev.slice(1), new Buffer([decrypt ? byteParam : out])])
+ return out
+}
+exports.encrypt = function (self, chunk, decrypt) {
+ var len = chunk.length
+ var out = new Buffer(len)
+ var i = -1
+ while (++i < len) {
+ out[i] = encryptByte(self, chunk[i], decrypt)
+ }
+ return out
+}
diff --git a/node_modules/browserify-aes/modes/ctr.js b/node_modules/browserify-aes/modes/ctr.js
new file mode 100644
index 000000000..0ef2278bf
--- /dev/null
+++ b/node_modules/browserify-aes/modes/ctr.js
@@ -0,0 +1,31 @@
+var xor = require('buffer-xor')
+
+function incr32 (iv) {
+ var len = iv.length
+ var item
+ while (len--) {
+ item = iv.readUInt8(len)
+ if (item === 255) {
+ iv.writeUInt8(0, len)
+ } else {
+ item++
+ iv.writeUInt8(item, len)
+ break
+ }
+ }
+}
+
+function getBlock (self) {
+ var out = self._cipher.encryptBlock(self._prev)
+ incr32(self._prev)
+ return out
+}
+
+exports.encrypt = function (self, chunk) {
+ while (self._cache.length < chunk.length) {
+ self._cache = Buffer.concat([self._cache, getBlock(self)])
+ }
+ var pad = self._cache.slice(0, chunk.length)
+ self._cache = self._cache.slice(chunk.length)
+ return xor(chunk, pad)
+}
diff --git a/node_modules/browserify-aes/modes/ecb.js b/node_modules/browserify-aes/modes/ecb.js
new file mode 100644
index 000000000..4dd97e7df
--- /dev/null
+++ b/node_modules/browserify-aes/modes/ecb.js
@@ -0,0 +1,6 @@
+exports.encrypt = function (self, block) {
+ return self._cipher.encryptBlock(block)
+}
+exports.decrypt = function (self, block) {
+ return self._cipher.decryptBlock(block)
+}
diff --git a/node_modules/browserify-aes/modes/ofb.js b/node_modules/browserify-aes/modes/ofb.js
new file mode 100644
index 000000000..bd875589f
--- /dev/null
+++ b/node_modules/browserify-aes/modes/ofb.js
@@ -0,0 +1,16 @@
+var xor = require('buffer-xor')
+
+function getBlock (self) {
+ self._prev = self._cipher.encryptBlock(self._prev)
+ return self._prev
+}
+
+exports.encrypt = function (self, chunk) {
+ while (self._cache.length < chunk.length) {
+ self._cache = Buffer.concat([self._cache, getBlock(self)])
+ }
+
+ var pad = self._cache.slice(0, chunk.length)
+ self._cache = self._cache.slice(chunk.length)
+ return xor(chunk, pad)
+}
diff --git a/node_modules/browserify-aes/package.json b/node_modules/browserify-aes/package.json
new file mode 100644
index 000000000..0c48faf77
--- /dev/null
+++ b/node_modules/browserify-aes/package.json
@@ -0,0 +1,40 @@
+{
+ "name": "browserify-aes",
+ "version": "1.0.6",
+ "description": "aes, for browserify",
+ "browser": "browser.js",
+ "main": "index.js",
+ "directories": {
+ "test": "test"
+ },
+ "scripts": {
+ "test": "standard && node test/index.js|tspec"
+ },
+ "repository": {
+ "type": "git",
+ "url": "git://github.com/crypto-browserify/browserify-aes.git"
+ },
+ "keywords": [
+ "aes",
+ "crypto",
+ "browserify"
+ ],
+ "author": "",
+ "license": "MIT",
+ "bugs": {
+ "url": "https://github.com/crypto-browserify/browserify-aes/issues"
+ },
+ "homepage": "https://github.com/crypto-browserify/browserify-aes",
+ "dependencies": {
+ "buffer-xor": "^1.0.2",
+ "cipher-base": "^1.0.0",
+ "create-hash": "^1.1.0",
+ "evp_bytestokey": "^1.0.0",
+ "inherits": "^2.0.1"
+ },
+ "devDependencies": {
+ "standard": "^3.7.3",
+ "tap-spec": "^1.0.0",
+ "tape": "^3.0.0"
+ }
+}
diff --git a/node_modules/browserify-aes/populateFixtures.js b/node_modules/browserify-aes/populateFixtures.js
new file mode 100644
index 000000000..ac31eb33c
--- /dev/null
+++ b/node_modules/browserify-aes/populateFixtures.js
@@ -0,0 +1,25 @@
+var modes = require('./modes')
+var fixtures = require('./test/fixtures.json')
+var crypto = require('crypto')
+var types = ['aes-128-cfb1', 'aes-192-cfb1', 'aes-256-cfb1']
+var ebtk = require('./EVP_BytesToKey')
+var fs = require('fs')
+
+fixtures.forEach(function (fixture) {
+ types.forEach(function (cipher) {
+ var suite = crypto.createCipher(cipher, new Buffer(fixture.password))
+ var buf = new Buffer('')
+ buf = Buffer.concat([buf, suite.update(new Buffer(fixture.text))])
+ buf = Buffer.concat([buf, suite.final()])
+ fixture.results.ciphers[cipher] = buf.toString('hex')
+ if (modes[cipher].mode === 'ECB') {
+ return
+ }
+ var suite2 = crypto.createCipheriv(cipher, ebtk(crypto, fixture.password, modes[cipher].key).key, new Buffer(fixture.iv, 'hex'))
+ var buf2 = new Buffer('')
+ buf2 = Buffer.concat([buf2, suite2.update(new Buffer(fixture.text))])
+ buf2 = Buffer.concat([buf2, suite2.final()])
+ fixture.results.cipherivs[cipher] = buf2.toString('hex')
+ })
+})
+fs.writeFileSync('./test/fixturesNew.json', JSON.stringify(fixtures, false, 4))
diff --git a/node_modules/browserify-aes/readme.md b/node_modules/browserify-aes/readme.md
new file mode 100644
index 000000000..1d7b08558
--- /dev/null
+++ b/node_modules/browserify-aes/readme.md
@@ -0,0 +1,18 @@
+browserify-aes
+====
+
+[![Build Status](https://travis-ci.org/crypto-browserify/browserify-aes.svg)](https://travis-ci.org/crypto-browserify/browserify-aes)
+
+Node style aes for use in the browser. Implements:
+
+ - createCipher
+ - createCipheriv
+ - createDecipher
+ - createDecipheriv
+ - getCiphers
+
+In node.js, the `crypto` implementation is used, in browsers it falls back to a pure JavaScript implementation.
+
+Much of this library has been taken from the aes implementation in [triplesec](https://github.com/keybase/triplesec), a partial derivation of [crypto-js](https://code.google.com/p/crypto-js/).
+
+`EVP_BytesToKey` is a straight up port of the same function from OpenSSL as there is literally no documenation on it beyond it using 'undocumented extensions' for longer keys.
diff --git a/node_modules/browserify-aes/streamCipher.js b/node_modules/browserify-aes/streamCipher.js
new file mode 100644
index 000000000..a55c762d5
--- /dev/null
+++ b/node_modules/browserify-aes/streamCipher.js
@@ -0,0 +1,25 @@
+var aes = require('./aes')
+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._decrypt = decrypt
+ iv.copy(this._prev)
+ this._mode = mode
+}
+StreamCipher.prototype._update = function (chunk) {
+ return this._mode.encrypt(this, chunk, this._decrypt)
+}
+StreamCipher.prototype._final = function () {
+ this._cipher.scrub()
+}