[Pkg-javascript-commits] [node-browserify-aes] 01/92: first

Bastien Roucariès rouca at moszumanska.debian.org
Sun Jun 4 09:35:14 UTC 2017


This is an automated email from the git hooks/post-receive script.

rouca pushed a commit to branch master
in repository node-browserify-aes.

commit f4f95761a0a10936c9473970627f0ac1ddfb1bb6
Author: Calvin Metcalf <cmetcalf at appgeo.com>
Date:   Wed Oct 15 17:23:26 2014 -0400

    first
---
 .jshintrc          |  36 ++++++++++
 EVP_BytesToKey.js  |  57 ++++++++++++++++
 aes.js             | 197 +++++++++++++++++++++++++++++++++++++++++++++++++++++
 decrypter.js       | 134 ++++++++++++++++++++++++++++++++++++
 encrypter.js       | 121 ++++++++++++++++++++++++++++++++
 index.js           |  17 +++++
 modes.js           |  39 +++++++++++
 package.json       |  35 ++++++++++
 readme.md          |   4 ++
 test.js            |  17 +++++
 test/fixtures.json | 158 ++++++++++++++++++++++++++++++++++++++++++
 test/index.js      | 104 ++++++++++++++++++++++++++++
 xor.js             |  13 ++++
 13 files changed, 932 insertions(+)

diff --git a/.jshintrc b/.jshintrc
new file mode 100644
index 0000000..2d7234e
--- /dev/null
+++ b/.jshintrc
@@ -0,0 +1,36 @@
+{
+  "predef": {
+    "document": true,
+    "window": true,
+    "FeldmanENV": true,
+    "google": true,
+    "MarkerClusterer": true
+  },
+  "browser" : true,
+  "node": true,
+  "boss" : true,
+  "curly": true,
+  "debug": false,
+  "devel": true,
+  "esnext": true,
+  "eqeqeq": true,
+  "evil": true,
+  "forin": false,
+  "immed": false,
+  "laxbreak": false,
+  "newcap": true,
+  "noarg": true,
+  "noempty": false,
+  "nonew": false,
+  "nomen": false,
+  "onevar": false,
+  "plusplus": false,
+  "regexp": false,
+  "undef": true,
+  "sub": true,
+  "strict": false,
+  "white": false,
+  "eqnull": true,
+  "esnext": true,
+  "unused": true
+}
\ No newline at end of file
diff --git a/EVP_BytesToKey.js b/EVP_BytesToKey.js
new file mode 100644
index 0000000..16f1ae5
--- /dev/null
+++ b/EVP_BytesToKey.js
@@ -0,0 +1,57 @@
+
+module.exports = function (crypto, password, keyLen, ivLen) {
+  keyLen = keyLen/8;
+  ivLen = ivLen || 0;
+  var ki = 0;
+  var ii = 0;
+  var key = new Buffer(keyLen);
+  var iv = new Buffer(ivLen);
+  var addmd = 0;
+  var md, md_buf;
+  var i;
+  while (true) {
+    md = crypto.createHash('md5');
+    if(addmd++ > 0) {
+       md.update(md_buf);
+    }
+    md.update(password);
+    md_buf = md.digest();
+    i = 0;
+    if(keyLen > 0) {
+      while(true) {
+        if(keyLen === 0) {
+          break;
+        }
+        if(i === md_buf.length) {
+          break;
+        }
+        key[ki++] = md_buf[i];
+        keyLen--;
+        i++;
+       }
+    }
+    if(ivLen > 0 && i !== md_buf.length) {
+      while(true) {
+        if(ivLen === 0) {
+          break;
+        }
+        if(i === md_buf.length) {
+          break;
+        }
+       iv[ii++] = md_buf[i];
+       ivLen--;
+       i++;
+     }
+   }
+   if(keyLen === 0 && ivLen === 0) {
+      break;
+    }
+  }
+  for(i=0;i<md_buf.length;i++) {
+    md_buf[i] = 0;
+  }
+  return {
+    key: key,
+    iv: iv
+  };
+};
\ No newline at end of file
diff --git a/aes.js b/aes.js
new file mode 100644
index 0000000..9c62da5
--- /dev/null
+++ b/aes.js
@@ -0,0 +1,197 @@
+var crypto = require('crypto');
+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) {
+  var i, _i, _ref;
+  for (i = _i = 0, _ref = v.length; 0 <= _ref ? _i < _ref : _i > _ref; i = 0 <= _ref ? ++_i : --_i) {
+    v[i] = 0;
+  }
+  return false;
+}
+
+function Global() {
+  var i;
+  this.SBOX = [];
+  this.INV_SBOX = [];
+  this.SUB_MIX = (function() {
+    var _i, _results;
+    _results = [];
+    for (i = _i = 0; _i < 4; i = ++_i) {
+      _results.push([]);
+    }
+    return _results;
+  })();
+  this.INV_SUB_MIX = (function() {
+    var _i, _results;
+    _results = [];
+    for (i = _i = 0; _i < 4; i = ++_i) {
+      _results.push([]);
+    }
+    return _results;
+  })();
+  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;
+
+AES.ivSize = AES.blockSize;
+
+AES.prototype.ivSize = AES.ivSize;
+
+ 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, _i, _j;
+  keyWords = this._key;
+  keySize = keyWords.length;
+  this._nRounds = keySize + 6;
+  ksRows = (this._nRounds + 1) * 4;
+  this._keySchedule = [];
+  for (ksRow = _i = 0; 0 <= ksRows ? _i < ksRows : _i > ksRows; ksRow = 0 <= ksRows ? ++_i : --_i) {
+    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._ [...]
+  }
+  this._invKeySchedule = [];
+  for (invKsRow = _j = 0; 0 <= ksRows ? _j < ksRows : _j > ksRows; invKsRow = 0 <= ksRows ? ++_j : --_j) {
+    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, round, s0, s1, s2, s3, t0, t1, t2, t3, _i, _ref;
+
+  s0 = M[0] ^ keySchedule[0];
+  s1 = M[1] ^ keySchedule[1];
+  s2 = M[2] ^ keySchedule[2];
+  s3 = M[3] ^ keySchedule[3];
+  ksRow = 4;
+  for (round = _i = 1, _ref = this._nRounds; 1 <= _ref ? _i < _ref : _i > _ref; round = 1 <= _ref ? ++_i : --_i) {
+    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;
\ No newline at end of file
diff --git a/decrypter.js b/decrypter.js
new file mode 100644
index 0000000..b64a8da
--- /dev/null
+++ b/decrypter.js
@@ -0,0 +1,134 @@
+var aes = require('./aes');
+var Transform = require('stream').Transform;
+var inherits = require('inherits');
+var duplexer = require('duplexer2');
+var modes = require('./modes');
+var ebtk = require('./EVP_BytesToKey');
+var xor = require('./xor');
+inherits(Splitter, Transform);
+function Splitter() {
+  if (!(this instanceof Splitter)) {
+    return new Splitter();
+  }
+  Transform.call(this);
+  this.cache = new Buffer('');
+}
+
+Splitter.prototype._transform = function (data, _, next) {
+  this.cache = Buffer.concat([this.cache, data]);
+  var i = 0;
+  var len = this.cache.length;
+  while (i + 15 < len) {
+    this.push(this.cache.slice(i, i + 16));
+    i += 16;
+  }
+  if (i) {
+    this.cache = this.cache.slice(i);
+  }
+  next();
+};
+
+inherits(ECB, Transform);
+function ECB(key) {
+  if (!(this instanceof ECB)) {
+    return new ECB(key);
+  }
+  Transform.call(this);
+  this._cipher = new aes.AES(key);
+  this._last = void 0;
+}
+
+ECB.prototype._transform = function (data, _, next) {
+  var last = this._last;
+  if (last) {
+    this.push(last);
+  }
+  this._last = this._cipher.decryptBlock(data);
+  next(null);
+};
+
+
+ECB.prototype._flush = function (next) {
+  this._cipher.scrub();
+  var last = this._last;
+  var padded = last[15];
+  if (padded === 16) {
+    return next();
+  }
+  var out = last.slice(0, 16 - padded);
+  this.push(out);
+  next();
+};
+inherits(CBC, Transform);
+function CBC(key, iv) {
+  if (!(this instanceof CBC)) {
+    return new CBC(key, iv);
+  }
+  Transform.call(this);
+  this._cipher = new aes.AES(key);
+  this._prev = iv;
+  this._last = void 0;
+}
+
+CBC.prototype._transform = function (data, _, next) {
+  var indata = data;
+  var out = this._cipher.decryptBlock(data);
+  if (this._last) {
+    this.push(this._last);
+  }
+  this._last = xor(out, this._prev);
+  this._prev = indata;
+  next();
+};
+CBC.prototype._flush = function (next) {
+  this._cipher.scrub();
+  var last = this._last;
+  var padded = last[15];
+  if (padded === 16) {
+    return next();
+  }
+  var out = last.slice(0, 16 - padded);
+  this.push(out);
+  next();
+};
+var modeStreams = {
+  ECB: ECB,
+  CBC: CBC
+};
+
+module.exports = function (crypto) {
+  function createDecipheriv(suite, password, iv) {
+    var config = modes[suite];
+    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);
+    }
+    var splitter = new Splitter();
+    var stream = new modeStreams[config.mode](password, iv);
+    splitter.pipe(stream);
+    return duplexer(splitter, stream);
+  }
+  function createDecipher (suite, password) {
+    var config = modes[suite];
+    if (!config) {
+      throw new TypeError('invalid suite type');
+    }
+    var keys = ebtk(crypto, password, config.key, config.iv);
+    return createDecipheriv(suite, keys.key, keys.iv);
+  }
+  return {
+    createDecipher: createDecipher,
+    createDecipheriv: createDecipheriv
+  };
+};
diff --git a/encrypter.js b/encrypter.js
new file mode 100644
index 0000000..0366a02
--- /dev/null
+++ b/encrypter.js
@@ -0,0 +1,121 @@
+var aes = require('./aes');
+var Transform = require('stream').Transform;
+var inherits = require('inherits');
+var duplexer = require('duplexer2');
+var modes = require('./modes');
+var ebtk = require('./EVP_BytesToKey');
+var xor = require('./xor');
+inherits(Splitter, Transform);
+function Splitter() {
+  if (!(this instanceof Splitter)) {
+    return new Splitter();
+  }
+  Transform.call(this);
+  this.cache = new Buffer('');
+}
+
+Splitter.prototype._transform = function (data, _, next) {
+  this.cache = Buffer.concat([this.cache, data]);
+  var i = 0;
+  var len = this.cache.length;
+  while (i + 15 < len) {
+    this.push(this.cache.slice(i, i + 16));
+    i += 16;
+  }
+  if (i) {
+    this.cache = this.cache.slice(i);
+  }
+  next();
+};
+
+Splitter.prototype._flush = function (next) {
+  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]);
+  this.push(out);
+  next();
+};
+
+inherits(ECB, Transform);
+function ECB(key) {
+  if (!(this instanceof ECB)) {
+    return new ECB(key);
+  }
+  Transform.call(this);
+  this._cipher = new aes.AES(key);
+}
+
+ECB.prototype._transform = function (data, _, next) {
+  var out = this._cipher.encryptBlock(data);
+  next(null, out);
+};
+ECB.prototype._flush = function (next) {
+  this._cipher.scrub();
+  next();
+};
+
+inherits(CBC, Transform);
+function CBC(key, iv) {
+  if (!(this instanceof CBC)) {
+    return new CBC(key, iv);
+  }
+  Transform.call(this);
+  this._cipher = new aes.AES(key);
+  this._prev = iv;
+}
+
+CBC.prototype._transform = function (data, _, next) {
+  data = xor(data, this._prev);
+  this._prev = this._cipher.encryptBlock(data);
+  next(null, this._prev);
+};
+CBC.prototype._flush = function (next) {
+  this._cipher.scrub();
+  next();
+};
+
+var modeStreams = {
+  ECB: ECB,
+  CBC: CBC
+};
+module.exports = function (crypto) {
+  function createCipheriv(suite, password, iv) {
+    var config = modes[suite];
+    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);
+    }
+    var splitter = new Splitter();
+    var stream = new modeStreams[config.mode](password, iv);
+    splitter.pipe(stream);
+    return duplexer(splitter, stream);
+  }
+  function createCipher (suite, password) {
+    var config = modes[suite];
+    if (!config) {
+      throw new TypeError('invalid suite type');
+    }
+    var keys = ebtk(crypto, password, config.key, config.iv);
+    return createCipheriv(suite, keys.key, keys.iv);
+  }
+  return {
+    createCipher: createCipher,
+    createCipheriv: createCipheriv
+  };
+};
diff --git a/index.js b/index.js
new file mode 100644
index 0000000..479804c
--- /dev/null
+++ b/index.js
@@ -0,0 +1,17 @@
+var crypto = require('crypto');
+
+exports.__browserify = function (crypto, exports) {
+  exports = exports || {};
+  var ciphers = require('./encrypter')(crypto);
+  exports.createCipher = ciphers.createCipher;
+  exports.createCipheriv = ciphers.createCipheriv;
+  var deciphers = require('./decrypter')(crypto);
+  exports.createDecipher = deciphers.createDecipher;
+  exports.createDecipheriv = deciphers.createDecipheriv;
+  var modes = require('./modes');
+  function listCiphers () {
+    return Object.keys(modes);
+  }
+  exports.listCiphers = listCiphers;
+};
+exports.__browserify(crypto, module.exports);
\ No newline at end of file
diff --git a/modes.js b/modes.js
new file mode 100644
index 0000000..0ffbeba
--- /dev/null
+++ b/modes.js
@@ -0,0 +1,39 @@
+exports['aes-128-ecb'] = {
+  cipher: 'AES',
+  key: 128,
+  iv: 0,
+  mode: 'ECB'
+};
+exports['aes-192-ecb'] = {
+  cipher: 'AES',
+  key: 192,
+  iv: 0,
+  mode: 'ECB'
+};
+exports['aes-256-ecb'] = {
+  cipher: 'AES',
+  key: 256,
+  iv: 0,
+  mode: 'ECB'
+};
+exports['aes-128-cbc'] = {
+  cipher: 'AES',
+  key: 128,
+  iv: 16,
+  mode: 'CBC'
+};
+exports['aes-192-cbc'] = {
+  cipher: 'AES',
+  key: 192,
+  iv: 16,
+  mode: 'CBC'
+};
+exports['aes-256-cbc'] = {
+  cipher: 'AES',
+  key: 256,
+  iv: 16,
+  mode: 'CBC'
+};
+exports['aes128'] = exports['aes-128-cbc'];
+exports['aes192'] = exports['aes-192-cbc'];
+exports['aes256'] = exports['aes-256-cbc'];
\ No newline at end of file
diff --git a/package.json b/package.json
new file mode 100644
index 0000000..8d544c2
--- /dev/null
+++ b/package.json
@@ -0,0 +1,35 @@
+{
+  "name": "browserify-aes",
+  "version": "0.0.0",
+  "description": "aes, for browserify",
+  "main": "index.js",
+  "directories": {
+    "test": "test"
+  },
+  "scripts": {
+    "test": "node test/index.js|tspec"
+  },
+  "repository": {
+    "type": "git",
+    "url": "git://github.com/calvinmetcalf/browserify-aes.git"
+  },
+  "keywords": [
+    "aes",
+    "crypto",
+    "browserify"
+  ],
+  "author": "",
+  "license": "MIT",
+  "bugs": {
+    "url": "https://github.com/calvinmetcalf/browserify-aes/issues"
+  },
+  "homepage": "https://github.com/calvinmetcalf/browserify-aes",
+  "dependencies": {
+    "inherits": "^2.0.1",
+    "duplexer2": "0.0.2"
+  },
+  "devDependencies": {
+    "tape": "^3.0.0",
+    "tap-spec": "^1.0.0"
+  }
+}
diff --git a/readme.md b/readme.md
new file mode 100644
index 0000000..6726be4
--- /dev/null
+++ b/readme.md
@@ -0,0 +1,4 @@
+browserify-aes
+====
+
+much of this taken from the aes implimentation in [triplesec](https://github.com/keybase/triplesec), they are just normal streams for now, no fancy stuff.
\ No newline at end of file
diff --git a/test.js b/test.js
new file mode 100644
index 0000000..9833aef
--- /dev/null
+++ b/test.js
@@ -0,0 +1,17 @@
+var createCipher = require('./index').createCipher;
+var encStream = createCipher('aes192', new Buffer('password'));
+var crypto = require('crypto');
+var decStream = crypto.createDecipher('aes192', new Buffer('password'));
+encStream.pipe(decStream).on('data', function (d) {
+  console.log(d.toString());
+});
+
+var data = [
+  "foo",
+  "abcdefghijklmnopqrstuvwxyz",
+  "You can disable automatic padding of the input data to block size. If auto_padding is false, the length of the entire input data must be a multiple of the cipher's block size or final will fail. Useful for non-standard padding, e.g. using 0x0 instead of PKCS padding. You must call this before cipher.final."
+];
+data.forEach(function (item) {
+  console.log(item);
+  encStream.write(item);
+});
\ No newline at end of file
diff --git a/test/fixtures.json b/test/fixtures.json
new file mode 100644
index 0000000..1dc28cd
--- /dev/null
+++ b/test/fixtures.json
@@ -0,0 +1,158 @@
+[
+    {
+        "text": "text",
+        "password": "password",
+        "iv": "c23dfaac5808546fb17ff807f0763ff2",
+        "results": {
+            "ciphers": {
+                "aes-128-ecb": "73e5049e015775a058cc6d69adadfb20",
+                "aes-192-ecb": "e78286b30e6c2a58dcf9a3558298bf27",
+                "aes-256-ecb": "af2e250870be1d8b85a053dca58428a9",
+                "aes-128-cbc": "ab6d044a021986b9cb2ab2d11641b23f",
+                "aes-192-cbc": "83fb920306c2d7f0c5ceb5dc7272357e",
+                "aes-256-cbc": "138839b0499e9bce8731bf0b9861b60c",
+                "aes128": "ab6d044a021986b9cb2ab2d11641b23f",
+                "aes192": "83fb920306c2d7f0c5ceb5dc7272357e",
+                "aes256": "138839b0499e9bce8731bf0b9861b60c"
+            },
+            "cipherivs": {
+                "aes-128-cbc": "f7407490d4cc14c7a0c026cbe19fb350",
+                "aes-192-cbc": "87ed62214972949ed913b612a319ee1f",
+                "aes-256-cbc": "ad3e265d8c7375c2941850fcf59337e9",
+                "aes128": "f7407490d4cc14c7a0c026cbe19fb350",
+                "aes192": "87ed62214972949ed913b612a319ee1f",
+                "aes256": "ad3e265d8c7375c2941850fcf59337e9"
+            }
+        }
+    },
+    {
+        "text": "I am by birth a Genevese, and my family is one of the most distinguished of that republic.  My ancestors had been for many years counsellors and syndics, and my father had filled several public situations with honour and reputation.  He was respected by all who knew him for his integrity and indefatigable attention to public business.  He passed his younger days perpetually occupied by the affairs of his country; a variety of circumstances had prevented his marrying earl [...]
+        "password": "password",
+        "iv": "52c1fc0fdeb71a27866886d015a6b425",
+        "results": {
+            "ciphers": {
+                "aes-128-ecb": "d379e1348c94ed429b0e3b7450067b7e3697f810ccfe699f657043d9a55ec6cc018bf5caad8e0bb113929f20e2b94dfbc31c1966aebe85f4193dbdd54d1a250c9416a0615af9325ce58bbbfcb45a247ac9a2b3a88f7216eda04fd4ccd1b6d15d9f9bc88f5f71c885aab86297bebad85b81595f58f5694eb2f688aba40b25c9fc66117e6abd0e305a2eb0369fa909c4ecd0b734507cf365dda81fba7ae8f20b6679cfc850eb7f5003e433b8758d288a0aef12c7d6bca34ef68ddfadb59bc7c28b5e6226de27c28e2e0203ce3f799a0849abd1d8ddbf12a38d66c132d8976b7e42c98254a69b83 [...]
+                "aes-192-ecb": "d715500f675edecb4d7ff2f8cb2d977041995fd2a56701025add45adc6ef298ebd05549ccb50ca6c98456c34e431c029954754d835bc74f076eadbb3917efb8eb2ac9082dafb1bcbcf0d1d39b2f22be41c7ce132206344523f651db3c006485323e3fc3229d9cdaa554b3dfd3c061a1710f0f73579d35df36ba6c50f42d775d3a7ed32dd96c72356daf30c0ea51dd0f40ea11db85f7622fb5c497af3d40c2961693f2fd775c569a8a960a30da9aa1feb912aa163a2bced5eceeb6c8d835070858cb5a07f3132146362259f84078cb0bc9a1c70d7b2b97bd22e3772c91c1138de3fd0b2691b3d [...]
+                "aes-256-ecb": "1b51469347dbcea6c5dc267e42e67fa19df5b81e50d7c7a9a180f6aa945c897e58368082a84304a4194277b22ee6a988bed15faaecd78dde0d4d16a70822af72b30b53f2708db732a073377f01a9a414c25c8ce08701a46af9a87c6a912838044dbe95092828796d97ece33b594d6079c2db32762043736877b3a662cae61f47d96e24527efddef6ddc44068facaebc7baf9a615350cebb38d6493bad6b97bb79ad8afcd2e982efb30011760b1894435fb9f8188b8124f5bd43aacd5fd60e6ebcfd5696a83b70bf97e12980567b0cafeac825b6a8f625b539c1bf64dd3baa4c8534412562e04 [...]
+                "aes-128-cbc": "17403e6b8b30dc3dfe833edaf2af3cc20493766db8adee6a6775fd66b69acdd8d42c32fef9f8cf401ca6876bf7d2b36ebced41f58f9655c434a03162547e4998551de77a34dc7184bdb49b04fa672ec07ab9d843c9c58575c2637fe236973657f97a45075cb1ff8d18c87b5044c0f62d7962c559daab347da875ed21a87f73df4f2b3586ef21c1e068b8edd8727b139fa78fb86c43f25f9eedce21462fd2abba36179c1b29ce82b7f925e81f4c4138a309aa8adaa4f0f07a3749c2da4bb05b0ad9d56920771369ba32850c311f42ea0cc90e4dd087958d7cd53f3e631b7086357cc33169e337 [...]
+                "aes-192-cbc": "9a79675d33a12c5fd5144d89752cf8591f0b595165b023800679b10ab59035b9df70f29e76e399ec30b2264178c3777c14550edad5860e1ef8f96ce3202f5208eb4316b066d911e4c89d1473cbe349a4aab7c87fb27f3e79a50925bc253aeacf61537fecf915d0b86558646d3beebb2e01eeb0a4d2d7152fef36a788c062453bd413bde5a5c5570f7b78721314699728f602e7e01397cbf8acf04c0a40df1a4a5e66ee42fba9a965bee4e2af3c92bef47dd6e330099263eba40cffc0717c37aeefa07ccbed4d3f6ce2e08c4c32146c8b072f887344a27cc92170d9ba9adc8528877b9a8909d8 [...]
+                "aes-256-cbc": "e61484b76c26d646d10783110cad453244353988d80f0fe34e9c5991b75acccc08863d2f6ea0c9c9a69362566dfbeb98fea8029681bb8698895a02ed9887a90786ba168f594552805d41a8616aaef0a5b50c259a23b803f7cd24b2ad97e5f4b745f46643074818d946dc42fa0a9d6e1da1256818be90118a643b281971bbc12260de04d3256ceb11e87917712c1bdc0512f104a00ff5d5e2bdc532ba42035787c83b64ecbdb1b860058938241efdcc43ef62be6cbae85e582d9d5e846603909d9a9bf1019909c15d4cf36ebdfb7dd4666ae84c06568e531f50e59ba9b924cca3d46f76ab1d88 [...]
+                "aes128": "17403e6b8b30dc3dfe833edaf2af3cc20493766db8adee6a6775fd66b69acdd8d42c32fef9f8cf401ca6876bf7d2b36ebced41f58f9655c434a03162547e4998551de77a34dc7184bdb49b04fa672ec07ab9d843c9c58575c2637fe236973657f97a45075cb1ff8d18c87b5044c0f62d7962c559daab347da875ed21a87f73df4f2b3586ef21c1e068b8edd8727b139fa78fb86c43f25f9eedce21462fd2abba36179c1b29ce82b7f925e81f4c4138a309aa8adaa4f0f07a3749c2da4bb05b0ad9d56920771369ba32850c311f42ea0cc90e4dd087958d7cd53f3e631b7086357cc33169e337db699 [...]
+                "aes192": "9a79675d33a12c5fd5144d89752cf8591f0b595165b023800679b10ab59035b9df70f29e76e399ec30b2264178c3777c14550edad5860e1ef8f96ce3202f5208eb4316b066d911e4c89d1473cbe349a4aab7c87fb27f3e79a50925bc253aeacf61537fecf915d0b86558646d3beebb2e01eeb0a4d2d7152fef36a788c062453bd413bde5a5c5570f7b78721314699728f602e7e01397cbf8acf04c0a40df1a4a5e66ee42fba9a965bee4e2af3c92bef47dd6e330099263eba40cffc0717c37aeefa07ccbed4d3f6ce2e08c4c32146c8b072f887344a27cc92170d9ba9adc8528877b9a8909d818ae5 [...]
+                "aes256": "e61484b76c26d646d10783110cad453244353988d80f0fe34e9c5991b75acccc08863d2f6ea0c9c9a69362566dfbeb98fea8029681bb8698895a02ed9887a90786ba168f594552805d41a8616aaef0a5b50c259a23b803f7cd24b2ad97e5f4b745f46643074818d946dc42fa0a9d6e1da1256818be90118a643b281971bbc12260de04d3256ceb11e87917712c1bdc0512f104a00ff5d5e2bdc532ba42035787c83b64ecbdb1b860058938241efdcc43ef62be6cbae85e582d9d5e846603909d9a9bf1019909c15d4cf36ebdfb7dd4666ae84c06568e531f50e59ba9b924cca3d46f76ab1d88324d0 [...]
+            },
+            "cipherivs": {
+                "aes-128-cbc": "772b4d8e20a224a6ec0392b1fc6569693accb2709509ba265ddf5aafaecc11d77016a69e70255b7d7a5ddf7ad4d87511aa12ab987115ca157f1b9d9c3583339576e81f66cd716dfe0c561bfdff14eb842f05859c69da073759c5706da8afffc951b7dfd3c689e6cb8cc32426846f375043fe519872ec27796f6ad9cd588b800206ff4115198341c321198689f5d83e5f8e60c7c6e9dfe06dc17697dc058888a1180601ae2932ff8cfa9e15546422db6b74b05fb7e79ccc143b41cb7e8b4ede73a1f11da476bf89f106e655171848ec0ccf9c94ae3e858d06acc06712d54ab8a3791a67fb61c6 [...]
+                "aes-192-cbc": "ba1d241268647886d3b9103013959edd378dccdc1f158f84ed560ca88c0c4a7863c13c914b0059d217ab32482168745225f78879c6d658653bd17277b6d9bac6cdce37dcd8dcb94b01fdebe358c33277f32d2989eb2970e434f653fc28e60dbb4fb9a14e14d5f38c30081c2e9d1a8ab145551257c448e24c91dd1adb99fc46ebcb633d4c8b3f91835bbbf9085cfb1a2f034a51c609f095c1a813fca49192e7f64cb959c664e24759f77c21c05faa90ce4c222ae6d87bf51b770c2888b7e0f059a7f06c4622e104dde2b8ffd447e6c0cff1a44cb9d54a1a16f5a90e97e4dccb5a7e135406ad06 [...]
+                "aes-256-cbc": "4bd525802cd2ed487bbfad28a81764d381b7c83291edb366c73cca3167e19760a5023fa52821dfd44d22e314583c842659aba2d23e3118756a302426699415d88d6cf7eac4ea53a01e7ba1e9251ecc62d5ded26bf4b5420b19d1e96bce7453122ace17cc0621995429436693c584cfffc66d27a0d00419b499e672b2813730cbf97d142c68ac5f52e08632c4f76c6f8b9a0140429d731e996c17e3dca3d6b07af330c4189ed6eecd338b28c989736011cd2b8704ad43e5604f3655e86cfb6a3788a508f01896cb468926cf79be1a665e435d2d54844597575292b989a81f424a4f2190bcb829 [...]
+                "aes128": "772b4d8e20a224a6ec0392b1fc6569693accb2709509ba265ddf5aafaecc11d77016a69e70255b7d7a5ddf7ad4d87511aa12ab987115ca157f1b9d9c3583339576e81f66cd716dfe0c561bfdff14eb842f05859c69da073759c5706da8afffc951b7dfd3c689e6cb8cc32426846f375043fe519872ec27796f6ad9cd588b800206ff4115198341c321198689f5d83e5f8e60c7c6e9dfe06dc17697dc058888a1180601ae2932ff8cfa9e15546422db6b74b05fb7e79ccc143b41cb7e8b4ede73a1f11da476bf89f106e655171848ec0ccf9c94ae3e858d06acc06712d54ab8a3791a67fb61c6a8562 [...]
+                "aes192": "ba1d241268647886d3b9103013959edd378dccdc1f158f84ed560ca88c0c4a7863c13c914b0059d217ab32482168745225f78879c6d658653bd17277b6d9bac6cdce37dcd8dcb94b01fdebe358c33277f32d2989eb2970e434f653fc28e60dbb4fb9a14e14d5f38c30081c2e9d1a8ab145551257c448e24c91dd1adb99fc46ebcb633d4c8b3f91835bbbf9085cfb1a2f034a51c609f095c1a813fca49192e7f64cb959c664e24759f77c21c05faa90ce4c222ae6d87bf51b770c2888b7e0f059a7f06c4622e104dde2b8ffd447e6c0cff1a44cb9d54a1a16f5a90e97e4dccb5a7e135406ad0632f61 [...]
+                "aes256": "4bd525802cd2ed487bbfad28a81764d381b7c83291edb366c73cca3167e19760a5023fa52821dfd44d22e314583c842659aba2d23e3118756a302426699415d88d6cf7eac4ea53a01e7ba1e9251ecc62d5ded26bf4b5420b19d1e96bce7453122ace17cc0621995429436693c584cfffc66d27a0d00419b499e672b2813730cbf97d142c68ac5f52e08632c4f76c6f8b9a0140429d731e996c17e3dca3d6b07af330c4189ed6eecd338b28c989736011cd2b8704ad43e5604f3655e86cfb6a3788a508f01896cb468926cf79be1a665e435d2d54844597575292b989a81f424a4f2190bcb829aadfb [...]
+            }
+        }
+    },
+    {
+        "text": "te\u00000xt",
+        "password": "pass\u00000word",
+        "iv": "7cea48c266460aaca3a48a5c2bc59a4a",
+        "results": {
+            "ciphers": {
+                "aes-128-ecb": "0263a36d5e768133ffc3c5c425ea8748",
+                "aes-192-ecb": "580d1d0fb8cd90ad16f999cda24d0eeb",
+                "aes-256-ecb": "4676a01580b9c9f4bd108fdbe49b9155",
+                "aes-128-cbc": "3141a23b60758eec9e6bda24cad914ae",
+                "aes-192-cbc": "6e5696c139c01d69773a5391310de2ff",
+                "aes-256-cbc": "185a9f2225cb2319e862aa7b4720fed5",
+                "aes128": "3141a23b60758eec9e6bda24cad914ae",
+                "aes192": "6e5696c139c01d69773a5391310de2ff",
+                "aes256": "185a9f2225cb2319e862aa7b4720fed5"
+            },
+            "cipherivs": {
+                "aes-128-cbc": "c9f85747bd44921917d9266f7d7253b3",
+                "aes-192-cbc": "6e70ebaaff28349608f56498fd959ce5",
+                "aes-256-cbc": "d6a6ee4a29a679aca37d6b3e2f0be7e8",
+                "aes128": "c9f85747bd44921917d9266f7d7253b3",
+                "aes192": "6e70ebaaff28349608f56498fd959ce5",
+                "aes256": "d6a6ee4a29a679aca37d6b3e2f0be7e8"
+            }
+        }
+    },
+    {
+        "text": "abcdefghijklmnop",
+        "password": "I am by birth a Genevese, and my family is one of the most distinguished of that republic.  My ancestors had been for many years counsellors and syndics, and my father had filled several public situations with honour and reputation.  He was respected by all who knew him for his integrity and indefatigable attention to public business.  He passed his younger days perpetually occupied by the affairs of his country; a variety of circumstances had prevented his marrying  [...]
+        "iv": "3af6efa0dc312dd60e7858460a5fc423",
+        "results": {
+            "ciphers": {
+                "aes-128-ecb": "0fc3183e19f1e9a42f2f468d469be1effd4f8c6e8298586e223da88b2d13beef",
+                "aes-192-ecb": "84bccef9fc8b8c62d0ce7af663d2ef68bce45c975754970b7e4bb0c8154d7ffd",
+                "aes-256-ecb": "70c07e30fa84a8a5a3279af564e093393ca18f36827ae78a3df3f44e56db025b",
+                "aes-128-cbc": "69260f6a155f0aa159248533425308108cfcf3322b079495337bfba733edaaf9",
+                "aes-192-cbc": "421f392130c54bbefd158ebf7a2dfbdfe4e3a60bc1d6ca7938572dcb566bf138",
+                "aes-256-cbc": "664d1b94ece9c943085d5ea4a30cbe339838f3b675dc6b6ba5f8023738d9e144",
+                "aes128": "69260f6a155f0aa159248533425308108cfcf3322b079495337bfba733edaaf9",
+                "aes192": "421f392130c54bbefd158ebf7a2dfbdfe4e3a60bc1d6ca7938572dcb566bf138",
+                "aes256": "664d1b94ece9c943085d5ea4a30cbe339838f3b675dc6b6ba5f8023738d9e144"
+            },
+            "cipherivs": {
+                "aes-128-cbc": "98e1b648e99996a2dff688b8418cd173fc2d2b809ff8659e45291ed92f7741f2",
+                "aes-192-cbc": "615eab15470e067b3cb1d34c1d0ac670371abd52c6d24b7114a04231d6846b63",
+                "aes-256-cbc": "7fce06852a9f19a946833b950d2e0f7fb89dd1889581165c350ccbe1f2360685",
+                "aes128": "98e1b648e99996a2dff688b8418cd173fc2d2b809ff8659e45291ed92f7741f2",
+                "aes192": "615eab15470e067b3cb1d34c1d0ac670371abd52c6d24b7114a04231d6846b63",
+                "aes256": "7fce06852a9f19a946833b950d2e0f7fb89dd1889581165c350ccbe1f2360685"
+            }
+        }
+    },
+    {
+        "text": "abcdefghijklmnopq",
+        "password": "(づ。◕‿‿◕。)づ",
+        "iv": "a55512ab58cefe5e8e30cb4aa4fb9e48",
+        "results": {
+            "ciphers": {
+                "aes-128-ecb": "d99f94ca395a7fd07f88e84fcd77eff9f849143bf298459fcbf0702131070d54",
+                "aes-192-ecb": "12417f16c49b25a35b5a120ae89cfcf80cef2be7295afe8e974e31e263055fc6",
+                "aes-256-ecb": "ae854bc9ecb1a89acab38b4ce2f3555af7ae4069af7ed305d665a913786f2ef5",
+                "aes-128-cbc": "3294feaaef04a0fa15bf2485301594fb1de6c201f936fc9308070ccf69f30fcd",
+                "aes-192-cbc": "555c521eb3f309be1130cb92e0601e8239bd49b20ddb868bda3c13c04ee5b082",
+                "aes-256-cbc": "161455bf919792f95ac914496f47784c590d42ed00e25414720ecc77fc094fe6",
+                "aes128": "3294feaaef04a0fa15bf2485301594fb1de6c201f936fc9308070ccf69f30fcd",
+                "aes192": "555c521eb3f309be1130cb92e0601e8239bd49b20ddb868bda3c13c04ee5b082",
+                "aes256": "161455bf919792f95ac914496f47784c590d42ed00e25414720ecc77fc094fe6"
+            },
+            "cipherivs": {
+                "aes-128-cbc": "ca7451a2b66305ea1a1793d5417b0b3c4d477abb2a42e08bbcc3ecae51cc1e1a",
+                "aes-192-cbc": "c3a33e105583fe7efd2302c6e79355108a9507ef487dff92a3eb18fef7dade5b",
+                "aes-256-cbc": "4ba2f481b6f30a74268d08ae153f39ad3dbfa4ece13ea16e8a56b0efc5df026e",
+                "aes128": "ca7451a2b66305ea1a1793d5417b0b3c4d477abb2a42e08bbcc3ecae51cc1e1a",
+                "aes192": "c3a33e105583fe7efd2302c6e79355108a9507ef487dff92a3eb18fef7dade5b",
+                "aes256": "4ba2f481b6f30a74268d08ae153f39ad3dbfa4ece13ea16e8a56b0efc5df026e"
+            }
+        }
+    },
+    {
+        "text": "abcdefghijklmno",
+        "password": "Ѱζ༼ᴼل͜ᴼ༽ᶘѰ",
+        "iv": "9d5c638078f9b110d03d9fc5f082eaae",
+        "results": {
+            "ciphers": {
+                "aes-128-ecb": "9454756f6b6405bd675ca68e1b428bc6",
+                "aes-192-ecb": "b0e46cff0b4f9879c2076306db07799b",
+                "aes-256-ecb": "99daedaf9bcca861e35253316be4ab57",
+                "aes-128-cbc": "aa1822f4394c2121014d77544682395c",
+                "aes-192-cbc": "7d937c3182ce33b51f9f7d34482042de",
+                "aes-256-cbc": "8f25a9f28db8f672adc91354652306cc",
+                "aes128": "aa1822f4394c2121014d77544682395c",
+                "aes192": "7d937c3182ce33b51f9f7d34482042de",
+                "aes256": "8f25a9f28db8f672adc91354652306cc"
+            },
+            "cipherivs": {
+                "aes-128-cbc": "af45c639b04747b2eaf310b52c51dfeb",
+                "aes-192-cbc": "c767360bcd75d774a4b89719fc2589b5",
+                "aes-256-cbc": "8bfb71ae015f795c20c41d403b2ba973",
+                "aes128": "af45c639b04747b2eaf310b52c51dfeb",
+                "aes192": "c767360bcd75d774a4b89719fc2589b5",
+                "aes256": "8bfb71ae015f795c20c41d403b2ba973"
+            }
+        }
+    }
+]
\ No newline at end of file
diff --git a/test/index.js b/test/index.js
new file mode 100644
index 0000000..3b06a37
--- /dev/null
+++ b/test/index.js
@@ -0,0 +1,104 @@
+var test = require('tape');
+var fixtures = require('./fixtures.json');
+var _crypto = require('crypto');
+var crypto = require('../');
+var modes = require('../modes');
+var types = Object.keys(modes);
+var ebtk = require('../EVP_BytesToKey');
+function decriptNoPadding(cipher, password, thing, code) {
+  var suite = _crypto.createDecipher(cipher, password);
+  var buf = new Buffer('');
+  suite.on('data', function (d) {
+    buf = Buffer.concat([buf, d]);
+  });
+  suite.on('error', function (e) {
+    console.log(e);
+  });
+  suite.on("finish", function () {
+    console.log(code, buf.toString('hex'));
+  });
+  suite.setAutoPadding(false);
+  suite.write(thing, 'hex');
+  suite.end();
+}
+fixtures.forEach(function (fixture) {
+  //var ciphers = fixture.results.ciphers = {};
+  types.forEach(function (cipher) {
+    test(cipher, function (t) {
+      t.plan(1);
+      var suite = crypto.createCipher(cipher, new Buffer(fixture.password));
+      var buf = new Buffer('');
+      suite.on('data', function (d) {
+        buf = Buffer.concat([buf, d]);
+      });
+      suite.on('error', function (e) {
+        console.log(e);
+      });
+      suite.on("end", function () {
+        // console.log(fixture.text);
+        // decriptNoPadding(cipher, new Buffer(fixture.password), buf.toString('hex'), 'a');
+        // decriptNoPadding(cipher, new Buffer(fixture.password), fixture.results.ciphers[cipher], 'b');
+        t.equals(buf.toString('hex'), fixture.results.ciphers[cipher]);
+      });
+      suite.write(new Buffer(fixture.text));
+      suite.end();
+    });
+    test(cipher + '-derypt', function (t) {
+      t.plan(1);
+      var suite = crypto.createDecipher(cipher, new Buffer(fixture.password));
+      var buf = new Buffer('');
+      suite.on('data', function (d) {
+        buf = Buffer.concat([buf, d]);
+      });
+      suite.on('error', function (e) {
+        console.log(e);
+      });
+      suite.on("end", function () {
+        // console.log(fixture.text);
+        // decriptNoPadding(cipher, new Buffer(fixture.password), buf.toString('hex'), 'a');
+        // decriptNoPadding(cipher, new Buffer(fixture.password), fixture.results.ciphers[cipher], 'b');
+        t.equals(buf.toString('utf8'), fixture.text);
+      });
+      suite.write(new Buffer(fixture.results.ciphers[cipher], 'hex'));
+      suite.end();
+    });
+    //var cipherivs = fixture.results.cipherivs = {};
+    types.forEach(function (cipher) {
+      if (modes[cipher].mode === 'ECB') {
+        return;
+      }
+      test(cipher + '-iv', function (t) {
+        t.plan(1);
+        var suite = crypto.createCipheriv(cipher, ebtk(_crypto, fixture.password, modes[cipher].key).key, new Buffer(fixture.iv, 'hex'));
+        var buf = new Buffer('');
+        suite.on('data', function (d) {
+          buf = Buffer.concat([buf, d]);
+        });
+        suite.on('error', function (e) {
+          console.log(e);
+        });
+        suite.on("end", function () {
+          t.equals(buf.toString('hex'), fixture.results.cipherivs[cipher]);
+        });
+        suite.write(new Buffer(fixture.text));
+        suite.end();
+      });
+      test(cipher + '-iv-decrypt', function (t) {
+        t.plan(1);
+        var suite = crypto.createDecipheriv(cipher, ebtk(_crypto, fixture.password, modes[cipher].key).key, new Buffer(fixture.iv, 'hex'));
+        var buf = new Buffer('');
+        suite.on('data', function (d) {
+          buf = Buffer.concat([buf, d]);
+        });
+        suite.on('error', function (e) {
+          console.log(e);
+        });
+        suite.on("end", function () {
+            t.equals(buf.toString('utf8'), fixture.text);
+        });
+        suite.write(new Buffer(fixture.results.cipherivs[cipher], 'hex'));
+        suite.end();
+      });
+    });
+  });
+});
diff --git a/xor.js b/xor.js
new file mode 100644
index 0000000..b78a2c2
--- /dev/null
+++ b/xor.js
@@ -0,0 +1,13 @@
+module.exports = xor;
+function xor(a, b) {
+  if (a.length !== b.length) {
+    throw new TypeError('must be same length');
+  }
+  var len = a.length;
+  var out = new Buffer(len);
+  var i = -1;
+  while (++i < len) {
+    out.writeUInt8(a[i] ^ b[i], i);
+  }
+  return out;
+}
\ No newline at end of file

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-javascript/node-browserify-aes.git



More information about the Pkg-javascript-commits mailing list