aboutsummaryrefslogtreecommitdiff
path: root/node_modules/hash.js
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/hash.js
parente0c9d480a73fa629c1e4a47d3e721f1d2d345406 (diff)
downloadwallet-core-de98e0b232509d5f40c135d540a70e415272ff85.tar.xz
node_modules
Diffstat (limited to 'node_modules/hash.js')
-rw-r--r--node_modules/hash.js/.npmignore2
-rw-r--r--node_modules/hash.js/.travis.yml7
-rw-r--r--node_modules/hash.js/README.md28
-rw-r--r--node_modules/hash.js/lib/hash.js15
-rw-r--r--node_modules/hash.js/lib/hash/common.js91
-rw-r--r--node_modules/hash.js/lib/hash/hmac.js48
-rw-r--r--node_modules/hash.js/lib/hash/ripemd.js144
-rw-r--r--node_modules/hash.js/lib/hash/sha.js564
-rw-r--r--node_modules/hash.js/lib/hash/utils.js257
-rw-r--r--node_modules/hash.js/package.json31
-rw-r--r--node_modules/hash.js/test/hash-test.js119
-rw-r--r--node_modules/hash.js/test/hmac-test.js59
12 files changed, 1365 insertions, 0 deletions
diff --git a/node_modules/hash.js/.npmignore b/node_modules/hash.js/.npmignore
new file mode 100644
index 000000000..1ca957177
--- /dev/null
+++ b/node_modules/hash.js/.npmignore
@@ -0,0 +1,2 @@
+node_modules/
+npm-debug.log
diff --git a/node_modules/hash.js/.travis.yml b/node_modules/hash.js/.travis.yml
new file mode 100644
index 000000000..92a990f67
--- /dev/null
+++ b/node_modules/hash.js/.travis.yml
@@ -0,0 +1,7 @@
+language: node_js
+node_js:
+ - "0.10"
+ - "0.11"
+branches:
+ only:
+ - master
diff --git a/node_modules/hash.js/README.md b/node_modules/hash.js/README.md
new file mode 100644
index 000000000..63107cbe3
--- /dev/null
+++ b/node_modules/hash.js/README.md
@@ -0,0 +1,28 @@
+# hash.js [![Build Status](https://secure.travis-ci.org/indutny/hash.js.png)](http://travis-ci.org/indutny/hash.js)
+
+Just a bike-shed.
+
+#### LICENSE
+
+This software is licensed under the MIT License.
+
+Copyright Fedor Indutny, 2014.
+
+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/hash.js/lib/hash.js b/node_modules/hash.js/lib/hash.js
new file mode 100644
index 000000000..f59b67301
--- /dev/null
+++ b/node_modules/hash.js/lib/hash.js
@@ -0,0 +1,15 @@
+var hash = exports;
+
+hash.utils = require('./hash/utils');
+hash.common = require('./hash/common');
+hash.sha = require('./hash/sha');
+hash.ripemd = require('./hash/ripemd');
+hash.hmac = require('./hash/hmac');
+
+// Proxy hash functions to the main object
+hash.sha1 = hash.sha.sha1;
+hash.sha256 = hash.sha.sha256;
+hash.sha224 = hash.sha.sha224;
+hash.sha384 = hash.sha.sha384;
+hash.sha512 = hash.sha.sha512;
+hash.ripemd160 = hash.ripemd.ripemd160;
diff --git a/node_modules/hash.js/lib/hash/common.js b/node_modules/hash.js/lib/hash/common.js
new file mode 100644
index 000000000..a052c55fe
--- /dev/null
+++ b/node_modules/hash.js/lib/hash/common.js
@@ -0,0 +1,91 @@
+var hash = require('../hash');
+var utils = hash.utils;
+var assert = utils.assert;
+
+function BlockHash() {
+ this.pending = null;
+ this.pendingTotal = 0;
+ this.blockSize = this.constructor.blockSize;
+ this.outSize = this.constructor.outSize;
+ this.hmacStrength = this.constructor.hmacStrength;
+ this.padLength = this.constructor.padLength / 8;
+ this.endian = 'big';
+
+ this._delta8 = this.blockSize / 8;
+ this._delta32 = this.blockSize / 32;
+}
+exports.BlockHash = BlockHash;
+
+BlockHash.prototype.update = function update(msg, enc) {
+ // Convert message to array, pad it, and join into 32bit blocks
+ msg = utils.toArray(msg, enc);
+ if (!this.pending)
+ this.pending = msg;
+ else
+ this.pending = this.pending.concat(msg);
+ this.pendingTotal += msg.length;
+
+ // Enough data, try updating
+ if (this.pending.length >= this._delta8) {
+ msg = this.pending;
+
+ // Process pending data in blocks
+ var r = msg.length % this._delta8;
+ this.pending = msg.slice(msg.length - r, msg.length);
+ if (this.pending.length === 0)
+ this.pending = null;
+
+ msg = utils.join32(msg, 0, msg.length - r, this.endian);
+ for (var i = 0; i < msg.length; i += this._delta32)
+ this._update(msg, i, i + this._delta32);
+ }
+
+ return this;
+};
+
+BlockHash.prototype.digest = function digest(enc) {
+ this.update(this._pad());
+ assert(this.pending === null);
+
+ return this._digest(enc);
+};
+
+BlockHash.prototype._pad = function pad() {
+ var len = this.pendingTotal;
+ var bytes = this._delta8;
+ var k = bytes - ((len + this.padLength) % bytes);
+ var res = new Array(k + this.padLength);
+ res[0] = 0x80;
+ for (var i = 1; i < k; i++)
+ res[i] = 0;
+
+ // Append length
+ len <<= 3;
+ if (this.endian === 'big') {
+ for (var t = 8; t < this.padLength; t++)
+ res[i++] = 0;
+
+ res[i++] = 0;
+ res[i++] = 0;
+ res[i++] = 0;
+ res[i++] = 0;
+ res[i++] = (len >>> 24) & 0xff;
+ res[i++] = (len >>> 16) & 0xff;
+ res[i++] = (len >>> 8) & 0xff;
+ res[i++] = len & 0xff;
+ } else {
+ res[i++] = len & 0xff;
+ res[i++] = (len >>> 8) & 0xff;
+ res[i++] = (len >>> 16) & 0xff;
+ res[i++] = (len >>> 24) & 0xff;
+ res[i++] = 0;
+ res[i++] = 0;
+ res[i++] = 0;
+ res[i++] = 0;
+
+ for (var t = 8; t < this.padLength; t++)
+ res[i++] = 0;
+ }
+
+ return res;
+};
diff --git a/node_modules/hash.js/lib/hash/hmac.js b/node_modules/hash.js/lib/hash/hmac.js
new file mode 100644
index 000000000..3a3da9728
--- /dev/null
+++ b/node_modules/hash.js/lib/hash/hmac.js
@@ -0,0 +1,48 @@
+var hmac = exports;
+
+var hash = require('../hash');
+var utils = hash.utils;
+var assert = utils.assert;
+
+function Hmac(hash, key, enc) {
+ if (!(this instanceof Hmac))
+ return new Hmac(hash, key, enc);
+ this.Hash = hash;
+ this.blockSize = hash.blockSize / 8;
+ this.outSize = hash.outSize / 8;
+ this.inner = null;
+ this.outer = null;
+
+ this._init(utils.toArray(key, enc));
+}
+module.exports = Hmac;
+
+Hmac.prototype._init = function init(key) {
+ // Shorten key, if needed
+ if (key.length > this.blockSize)
+ key = new this.Hash().update(key).digest();
+ assert(key.length <= this.blockSize);
+
+ // Add padding to key
+ for (var i = key.length; i < this.blockSize; i++)
+ key.push(0);
+
+ for (var i = 0; i < key.length; i++)
+ key[i] ^= 0x36;
+ this.inner = new this.Hash().update(key);
+
+ // 0x36 ^ 0x5c = 0x6a
+ for (var i = 0; i < key.length; i++)
+ key[i] ^= 0x6a;
+ this.outer = new this.Hash().update(key);
+};
+
+Hmac.prototype.update = function update(msg, enc) {
+ this.inner.update(msg, enc);
+ return this;
+};
+
+Hmac.prototype.digest = function digest(enc) {
+ this.outer.update(this.inner.digest());
+ return this.outer.digest(enc);
+};
diff --git a/node_modules/hash.js/lib/hash/ripemd.js b/node_modules/hash.js/lib/hash/ripemd.js
new file mode 100644
index 000000000..cd55bfc7f
--- /dev/null
+++ b/node_modules/hash.js/lib/hash/ripemd.js
@@ -0,0 +1,144 @@
+var hash = require('../hash');
+var utils = hash.utils;
+
+var rotl32 = utils.rotl32;
+var sum32 = utils.sum32;
+var sum32_3 = utils.sum32_3;
+var sum32_4 = utils.sum32_4;
+var BlockHash = hash.common.BlockHash;
+
+function RIPEMD160() {
+ if (!(this instanceof RIPEMD160))
+ return new RIPEMD160();
+
+ BlockHash.call(this);
+
+ this.h = [ 0x67452301, 0xefcdab89, 0x98badcfe, 0x10325476, 0xc3d2e1f0 ];
+ this.endian = 'little';
+}
+utils.inherits(RIPEMD160, BlockHash);
+exports.ripemd160 = RIPEMD160;
+
+RIPEMD160.blockSize = 512;
+RIPEMD160.outSize = 160;
+RIPEMD160.hmacStrength = 192;
+RIPEMD160.padLength = 64;
+
+RIPEMD160.prototype._update = function update(msg, start) {
+ var A = this.h[0];
+ var B = this.h[1];
+ var C = this.h[2];
+ var D = this.h[3];
+ var E = this.h[4];
+ var Ah = A;
+ var Bh = B;
+ var Ch = C;
+ var Dh = D;
+ var Eh = E;
+ for (var j = 0; j < 80; j++) {
+ var T = sum32(
+ rotl32(
+ sum32_4(A, f(j, B, C, D), msg[r[j] + start], K(j)),
+ s[j]),
+ E);
+ A = E;
+ E = D;
+ D = rotl32(C, 10);
+ C = B;
+ B = T;
+ T = sum32(
+ rotl32(
+ sum32_4(Ah, f(79 - j, Bh, Ch, Dh), msg[rh[j] + start], Kh(j)),
+ sh[j]),
+ Eh);
+ Ah = Eh;
+ Eh = Dh;
+ Dh = rotl32(Ch, 10);
+ Ch = Bh;
+ Bh = T;
+ }
+ T = sum32_3(this.h[1], C, Dh);
+ this.h[1] = sum32_3(this.h[2], D, Eh);
+ this.h[2] = sum32_3(this.h[3], E, Ah);
+ this.h[3] = sum32_3(this.h[4], A, Bh);
+ this.h[4] = sum32_3(this.h[0], B, Ch);
+ this.h[0] = T;
+};
+
+RIPEMD160.prototype._digest = function digest(enc) {
+ if (enc === 'hex')
+ return utils.toHex32(this.h, 'little');
+ else
+ return utils.split32(this.h, 'little');
+};
+
+function f(j, x, y, z) {
+ if (j <= 15)
+ return x ^ y ^ z;
+ else if (j <= 31)
+ return (x & y) | ((~x) & z);
+ else if (j <= 47)
+ return (x | (~y)) ^ z;
+ else if (j <= 63)
+ return (x & z) | (y & (~z));
+ else
+ return x ^ (y | (~z));
+}
+
+function K(j) {
+ if (j <= 15)
+ return 0x00000000;
+ else if (j <= 31)
+ return 0x5a827999;
+ else if (j <= 47)
+ return 0x6ed9eba1;
+ else if (j <= 63)
+ return 0x8f1bbcdc;
+ else
+ return 0xa953fd4e;
+}
+
+function Kh(j) {
+ if (j <= 15)
+ return 0x50a28be6;
+ else if (j <= 31)
+ return 0x5c4dd124;
+ else if (j <= 47)
+ return 0x6d703ef3;
+ else if (j <= 63)
+ return 0x7a6d76e9;
+ else
+ return 0x00000000;
+}
+
+var r = [
+ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15,
+ 7, 4, 13, 1, 10, 6, 15, 3, 12, 0, 9, 5, 2, 14, 11, 8,
+ 3, 10, 14, 4, 9, 15, 8, 1, 2, 7, 0, 6, 13, 11, 5, 12,
+ 1, 9, 11, 10, 0, 8, 12, 4, 13, 3, 7, 15, 14, 5, 6, 2,
+ 4, 0, 5, 9, 7, 12, 2, 10, 14, 1, 3, 8, 11, 6, 15, 13
+];
+
+var rh = [
+ 5, 14, 7, 0, 9, 2, 11, 4, 13, 6, 15, 8, 1, 10, 3, 12,
+ 6, 11, 3, 7, 0, 13, 5, 10, 14, 15, 8, 12, 4, 9, 1, 2,
+ 15, 5, 1, 3, 7, 14, 6, 9, 11, 8, 12, 2, 10, 0, 4, 13,
+ 8, 6, 4, 1, 3, 11, 15, 0, 5, 12, 2, 13, 9, 7, 10, 14,
+ 12, 15, 10, 4, 1, 5, 8, 7, 6, 2, 13, 14, 0, 3, 9, 11
+];
+
+var s = [
+ 11, 14, 15, 12, 5, 8, 7, 9, 11, 13, 14, 15, 6, 7, 9, 8,
+ 7, 6, 8, 13, 11, 9, 7, 15, 7, 12, 15, 9, 11, 7, 13, 12,
+ 11, 13, 6, 7, 14, 9, 13, 15, 14, 8, 13, 6, 5, 12, 7, 5,
+ 11, 12, 14, 15, 14, 15, 9, 8, 9, 14, 5, 6, 8, 6, 5, 12,
+ 9, 15, 5, 11, 6, 8, 13, 12, 5, 12, 13, 14, 11, 8, 5, 6
+];
+
+var sh = [
+ 8, 9, 9, 11, 13, 15, 15, 5, 7, 7, 8, 11, 14, 14, 12, 6,
+ 9, 13, 15, 7, 12, 8, 9, 11, 7, 7, 12, 7, 6, 15, 13, 11,
+ 9, 7, 15, 11, 8, 6, 6, 14, 12, 13, 5, 14, 13, 13, 7, 5,
+ 15, 5, 8, 11, 14, 14, 6, 14, 6, 9, 12, 9, 12, 5, 15, 8,
+ 8, 5, 12, 9, 12, 5, 14, 6, 8, 13, 6, 5, 15, 13, 11, 11
+];
diff --git a/node_modules/hash.js/lib/hash/sha.js b/node_modules/hash.js/lib/hash/sha.js
new file mode 100644
index 000000000..a7837aad0
--- /dev/null
+++ b/node_modules/hash.js/lib/hash/sha.js
@@ -0,0 +1,564 @@
+var hash = require('../hash');
+var utils = hash.utils;
+var assert = utils.assert;
+
+var rotr32 = utils.rotr32;
+var rotl32 = utils.rotl32;
+var sum32 = utils.sum32;
+var sum32_4 = utils.sum32_4;
+var sum32_5 = utils.sum32_5;
+var rotr64_hi = utils.rotr64_hi;
+var rotr64_lo = utils.rotr64_lo;
+var shr64_hi = utils.shr64_hi;
+var shr64_lo = utils.shr64_lo;
+var sum64 = utils.sum64;
+var sum64_hi = utils.sum64_hi;
+var sum64_lo = utils.sum64_lo;
+var sum64_4_hi = utils.sum64_4_hi;
+var sum64_4_lo = utils.sum64_4_lo;
+var sum64_5_hi = utils.sum64_5_hi;
+var sum64_5_lo = utils.sum64_5_lo;
+var BlockHash = hash.common.BlockHash;
+
+var sha256_K = [
+ 0x428a2f98, 0x71374491, 0xb5c0fbcf, 0xe9b5dba5,
+ 0x3956c25b, 0x59f111f1, 0x923f82a4, 0xab1c5ed5,
+ 0xd807aa98, 0x12835b01, 0x243185be, 0x550c7dc3,
+ 0x72be5d74, 0x80deb1fe, 0x9bdc06a7, 0xc19bf174,
+ 0xe49b69c1, 0xefbe4786, 0x0fc19dc6, 0x240ca1cc,
+ 0x2de92c6f, 0x4a7484aa, 0x5cb0a9dc, 0x76f988da,
+ 0x983e5152, 0xa831c66d, 0xb00327c8, 0xbf597fc7,
+ 0xc6e00bf3, 0xd5a79147, 0x06ca6351, 0x14292967,
+ 0x27b70a85, 0x2e1b2138, 0x4d2c6dfc, 0x53380d13,
+ 0x650a7354, 0x766a0abb, 0x81c2c92e, 0x92722c85,
+ 0xa2bfe8a1, 0xa81a664b, 0xc24b8b70, 0xc76c51a3,
+ 0xd192e819, 0xd6990624, 0xf40e3585, 0x106aa070,
+ 0x19a4c116, 0x1e376c08, 0x2748774c, 0x34b0bcb5,
+ 0x391c0cb3, 0x4ed8aa4a, 0x5b9cca4f, 0x682e6ff3,
+ 0x748f82ee, 0x78a5636f, 0x84c87814, 0x8cc70208,
+ 0x90befffa, 0xa4506ceb, 0xbef9a3f7, 0xc67178f2
+];
+
+var sha512_K = [
+ 0x428a2f98, 0xd728ae22, 0x71374491, 0x23ef65cd,
+ 0xb5c0fbcf, 0xec4d3b2f, 0xe9b5dba5, 0x8189dbbc,
+ 0x3956c25b, 0xf348b538, 0x59f111f1, 0xb605d019,
+ 0x923f82a4, 0xaf194f9b, 0xab1c5ed5, 0xda6d8118,
+ 0xd807aa98, 0xa3030242, 0x12835b01, 0x45706fbe,
+ 0x243185be, 0x4ee4b28c, 0x550c7dc3, 0xd5ffb4e2,
+ 0x72be5d74, 0xf27b896f, 0x80deb1fe, 0x3b1696b1,
+ 0x9bdc06a7, 0x25c71235, 0xc19bf174, 0xcf692694,
+ 0xe49b69c1, 0x9ef14ad2, 0xefbe4786, 0x384f25e3,
+ 0x0fc19dc6, 0x8b8cd5b5, 0x240ca1cc, 0x77ac9c65,
+ 0x2de92c6f, 0x592b0275, 0x4a7484aa, 0x6ea6e483,
+ 0x5cb0a9dc, 0xbd41fbd4, 0x76f988da, 0x831153b5,
+ 0x983e5152, 0xee66dfab, 0xa831c66d, 0x2db43210,
+ 0xb00327c8, 0x98fb213f, 0xbf597fc7, 0xbeef0ee4,
+ 0xc6e00bf3, 0x3da88fc2, 0xd5a79147, 0x930aa725,
+ 0x06ca6351, 0xe003826f, 0x14292967, 0x0a0e6e70,
+ 0x27b70a85, 0x46d22ffc, 0x2e1b2138, 0x5c26c926,
+ 0x4d2c6dfc, 0x5ac42aed, 0x53380d13, 0x9d95b3df,
+ 0x650a7354, 0x8baf63de, 0x766a0abb, 0x3c77b2a8,
+ 0x81c2c92e, 0x47edaee6, 0x92722c85, 0x1482353b,
+ 0xa2bfe8a1, 0x4cf10364, 0xa81a664b, 0xbc423001,
+ 0xc24b8b70, 0xd0f89791, 0xc76c51a3, 0x0654be30,
+ 0xd192e819, 0xd6ef5218, 0xd6990624, 0x5565a910,
+ 0xf40e3585, 0x5771202a, 0x106aa070, 0x32bbd1b8,
+ 0x19a4c116, 0xb8d2d0c8, 0x1e376c08, 0x5141ab53,
+ 0x2748774c, 0xdf8eeb99, 0x34b0bcb5, 0xe19b48a8,
+ 0x391c0cb3, 0xc5c95a63, 0x4ed8aa4a, 0xe3418acb,
+ 0x5b9cca4f, 0x7763e373, 0x682e6ff3, 0xd6b2b8a3,
+ 0x748f82ee, 0x5defb2fc, 0x78a5636f, 0x43172f60,
+ 0x84c87814, 0xa1f0ab72, 0x8cc70208, 0x1a6439ec,
+ 0x90befffa, 0x23631e28, 0xa4506ceb, 0xde82bde9,
+ 0xbef9a3f7, 0xb2c67915, 0xc67178f2, 0xe372532b,
+ 0xca273ece, 0xea26619c, 0xd186b8c7, 0x21c0c207,
+ 0xeada7dd6, 0xcde0eb1e, 0xf57d4f7f, 0xee6ed178,
+ 0x06f067aa, 0x72176fba, 0x0a637dc5, 0xa2c898a6,
+ 0x113f9804, 0xbef90dae, 0x1b710b35, 0x131c471b,
+ 0x28db77f5, 0x23047d84, 0x32caab7b, 0x40c72493,
+ 0x3c9ebe0a, 0x15c9bebc, 0x431d67c4, 0x9c100d4c,
+ 0x4cc5d4be, 0xcb3e42b6, 0x597f299c, 0xfc657e2a,
+ 0x5fcb6fab, 0x3ad6faec, 0x6c44198c, 0x4a475817
+];
+
+var sha1_K = [
+ 0x5A827999, 0x6ED9EBA1,
+ 0x8F1BBCDC, 0xCA62C1D6
+];
+
+function SHA256() {
+ if (!(this instanceof SHA256))
+ return new SHA256();
+
+ BlockHash.call(this);
+ this.h = [ 0x6a09e667, 0xbb67ae85, 0x3c6ef372, 0xa54ff53a,
+ 0x510e527f, 0x9b05688c, 0x1f83d9ab, 0x5be0cd19 ];
+ this.k = sha256_K;
+ this.W = new Array(64);
+}
+utils.inherits(SHA256, BlockHash);
+exports.sha256 = SHA256;
+
+SHA256.blockSize = 512;
+SHA256.outSize = 256;
+SHA256.hmacStrength = 192;
+SHA256.padLength = 64;
+
+SHA256.prototype._update = function _update(msg, start) {
+ var W = this.W;
+
+ for (var i = 0; i < 16; i++)
+ W[i] = msg[start + i];
+ for (; i < W.length; i++)
+ W[i] = sum32_4(g1_256(W[i - 2]), W[i - 7], g0_256(W[i - 15]), W[i - 16]);
+
+ var a = this.h[0];
+ var b = this.h[1];
+ var c = this.h[2];
+ var d = this.h[3];
+ var e = this.h[4];
+ var f = this.h[5];
+ var g = this.h[6];
+ var h = this.h[7];
+
+ assert(this.k.length === W.length);
+ for (var i = 0; i < W.length; i++) {
+ var T1 = sum32_5(h, s1_256(e), ch32(e, f, g), this.k[i], W[i]);
+ var T2 = sum32(s0_256(a), maj32(a, b, c));
+ h = g;
+ g = f;
+ f = e;
+ e = sum32(d, T1);
+ d = c;
+ c = b;
+ b = a;
+ a = sum32(T1, T2);
+ }
+
+ this.h[0] = sum32(this.h[0], a);
+ this.h[1] = sum32(this.h[1], b);
+ this.h[2] = sum32(this.h[2], c);
+ this.h[3] = sum32(this.h[3], d);
+ this.h[4] = sum32(this.h[4], e);
+ this.h[5] = sum32(this.h[5], f);
+ this.h[6] = sum32(this.h[6], g);
+ this.h[7] = sum32(this.h[7], h);
+};
+
+SHA256.prototype._digest = function digest(enc) {
+ if (enc === 'hex')
+ return utils.toHex32(this.h, 'big');
+ else
+ return utils.split32(this.h, 'big');
+};
+
+function SHA224() {
+ if (!(this instanceof SHA224))
+ return new SHA224();
+
+ SHA256.call(this);
+ this.h = [ 0xc1059ed8, 0x367cd507, 0x3070dd17, 0xf70e5939,
+ 0xffc00b31, 0x68581511, 0x64f98fa7, 0xbefa4fa4 ];
+}
+utils.inherits(SHA224, SHA256);
+exports.sha224 = SHA224;
+
+SHA224.blockSize = 512;
+SHA224.outSize = 224;
+SHA224.hmacStrength = 192;
+SHA224.padLength = 64;
+
+SHA224.prototype._digest = function digest(enc) {
+ // Just truncate output
+ if (enc === 'hex')
+ return utils.toHex32(this.h.slice(0, 7), 'big');
+ else
+ return utils.split32(this.h.slice(0, 7), 'big');
+};
+
+function SHA512() {
+ if (!(this instanceof SHA512))
+ return new SHA512();
+
+ BlockHash.call(this);
+ this.h = [ 0x6a09e667, 0xf3bcc908,
+ 0xbb67ae85, 0x84caa73b,
+ 0x3c6ef372, 0xfe94f82b,
+ 0xa54ff53a, 0x5f1d36f1,
+ 0x510e527f, 0xade682d1,
+ 0x9b05688c, 0x2b3e6c1f,
+ 0x1f83d9ab, 0xfb41bd6b,
+ 0x5be0cd19, 0x137e2179 ];
+ this.k = sha512_K;
+ this.W = new Array(160);
+}
+utils.inherits(SHA512, BlockHash);
+exports.sha512 = SHA512;
+
+SHA512.blockSize = 1024;
+SHA512.outSize = 512;
+SHA512.hmacStrength = 192;
+SHA512.padLength = 128;
+
+SHA512.prototype._prepareBlock = function _prepareBlock(msg, start) {
+ var W = this.W;
+
+ // 32 x 32bit words
+ for (var i = 0; i < 32; i++)
+ W[i] = msg[start + i];
+ for (; i < W.length; i += 2) {
+ var c0_hi = g1_512_hi(W[i - 4], W[i - 3]); // i - 2
+ var c0_lo = g1_512_lo(W[i - 4], W[i - 3]);
+ var c1_hi = W[i - 14]; // i - 7
+ var c1_lo = W[i - 13];
+ var c2_hi = g0_512_hi(W[i - 30], W[i - 29]); // i - 15
+ var c2_lo = g0_512_lo(W[i - 30], W[i - 29]);
+ var c3_hi = W[i - 32]; // i - 16
+ var c3_lo = W[i - 31];
+
+ W[i] = sum64_4_hi(c0_hi, c0_lo,
+ c1_hi, c1_lo,
+ c2_hi, c2_lo,
+ c3_hi, c3_lo);
+ W[i + 1] = sum64_4_lo(c0_hi, c0_lo,
+ c1_hi, c1_lo,
+ c2_hi, c2_lo,
+ c3_hi, c3_lo);
+ }
+};
+
+SHA512.prototype._update = function _update(msg, start) {
+ this._prepareBlock(msg, start);
+
+ var W = this.W;
+
+ var ah = this.h[0];
+ var al = this.h[1];
+ var bh = this.h[2];
+ var bl = this.h[3];
+ var ch = this.h[4];
+ var cl = this.h[5];
+ var dh = this.h[6];
+ var dl = this.h[7];
+ var eh = this.h[8];
+ var el = this.h[9];
+ var fh = this.h[10];
+ var fl = this.h[11];
+ var gh = this.h[12];
+ var gl = this.h[13];
+ var hh = this.h[14];
+ var hl = this.h[15];
+
+ assert(this.k.length === W.length);
+ for (var i = 0; i < W.length; i += 2) {
+ var c0_hi = hh;
+ var c0_lo = hl;
+ var c1_hi = s1_512_hi(eh, el);
+ var c1_lo = s1_512_lo(eh, el);
+ var c2_hi = ch64_hi(eh, el, fh, fl, gh, gl);
+ var c2_lo = ch64_lo(eh, el, fh, fl, gh, gl);
+ var c3_hi = this.k[i];
+ var c3_lo = this.k[i + 1];
+ var c4_hi = W[i];
+ var c4_lo = W[i + 1];
+
+ var T1_hi = sum64_5_hi(c0_hi, c0_lo,
+ c1_hi, c1_lo,
+ c2_hi, c2_lo,
+ c3_hi, c3_lo,
+ c4_hi, c4_lo);
+ var T1_lo = sum64_5_lo(c0_hi, c0_lo,
+ c1_hi, c1_lo,
+ c2_hi, c2_lo,
+ c3_hi, c3_lo,
+ c4_hi, c4_lo);
+
+ var c0_hi = s0_512_hi(ah, al);
+ var c0_lo = s0_512_lo(ah, al);
+ var c1_hi = maj64_hi(ah, al, bh, bl, ch, cl);
+ var c1_lo = maj64_lo(ah, al, bh, bl, ch, cl);
+
+ var T2_hi = sum64_hi(c0_hi, c0_lo, c1_hi, c1_lo);
+ var T2_lo = sum64_lo(c0_hi, c0_lo, c1_hi, c1_lo);
+
+ hh = gh;
+ hl = gl;
+
+ gh = fh;
+ gl = fl;
+
+ fh = eh;
+ fl = el;
+
+ eh = sum64_hi(dh, dl, T1_hi, T1_lo);
+ el = sum64_lo(dl, dl, T1_hi, T1_lo);
+
+ dh = ch;
+ dl = cl;
+
+ ch = bh;
+ cl = bl;
+
+ bh = ah;
+ bl = al;
+
+ ah = sum64_hi(T1_hi, T1_lo, T2_hi, T2_lo);
+ al = sum64_lo(T1_hi, T1_lo, T2_hi, T2_lo);
+ }
+
+ sum64(this.h, 0, ah, al);
+ sum64(this.h, 2, bh, bl);
+ sum64(this.h, 4, ch, cl);
+ sum64(this.h, 6, dh, dl);
+ sum64(this.h, 8, eh, el);
+ sum64(this.h, 10, fh, fl);
+ sum64(this.h, 12, gh, gl);
+ sum64(this.h, 14, hh, hl);
+};
+
+SHA512.prototype._digest = function digest(enc) {
+ if (enc === 'hex')
+ return utils.toHex32(this.h, 'big');
+ else
+ return utils.split32(this.h, 'big');
+};
+
+function SHA384() {
+ if (!(this instanceof SHA384))
+ return new SHA384();
+
+ SHA512.call(this);
+ this.h = [ 0xcbbb9d5d, 0xc1059ed8,
+ 0x629a292a, 0x367cd507,
+ 0x9159015a, 0x3070dd17,
+ 0x152fecd8, 0xf70e5939,
+ 0x67332667, 0xffc00b31,
+ 0x8eb44a87, 0x68581511,
+ 0xdb0c2e0d, 0x64f98fa7,
+ 0x47b5481d, 0xbefa4fa4 ];
+}
+utils.inherits(SHA384, SHA512);
+exports.sha384 = SHA384;
+
+SHA384.blockSize = 1024;
+SHA384.outSize = 384;
+SHA384.hmacStrength = 192;
+SHA384.padLength = 128;
+
+SHA384.prototype._digest = function digest(enc) {
+ if (enc === 'hex')
+ return utils.toHex32(this.h.slice(0, 12), 'big');
+ else
+ return utils.split32(this.h.slice(0, 12), 'big');
+};
+
+function SHA1() {
+ if (!(this instanceof SHA1))
+ return new SHA1();
+
+ BlockHash.call(this);
+ this.h = [ 0x67452301, 0xefcdab89, 0x98badcfe,
+ 0x10325476, 0xc3d2e1f0 ];
+ this.W = new Array(80);
+}
+
+utils.inherits(SHA1, BlockHash);
+exports.sha1 = SHA1;
+
+SHA1.blockSize = 512;
+SHA1.outSize = 160;
+SHA1.hmacStrength = 80;
+SHA1.padLength = 64;
+
+SHA1.prototype._update = function _update(msg, start) {
+ var W = this.W;
+
+ for (var i = 0; i < 16; i++)
+ W[i] = msg[start + i];
+
+ for(; i < W.length; i++)
+ W[i] = rotl32(W[i - 3] ^ W[i - 8] ^ W[i - 14] ^ W[i - 16], 1);
+
+ var a = this.h[0];
+ var b = this.h[1];
+ var c = this.h[2];
+ var d = this.h[3];
+ var e = this.h[4];
+
+ for (var i = 0; i < W.length; i++) {
+ var s = ~~(i / 20);
+ var t = sum32_5(rotl32(a, 5), ft_1(s, b, c, d), e, W[i], sha1_K[s]);
+ e = d;
+ d = c;
+ c = rotl32(b, 30);
+ b = a;
+ a = t;
+ }
+
+ this.h[0] = sum32(this.h[0], a);
+ this.h[1] = sum32(this.h[1], b);
+ this.h[2] = sum32(this.h[2], c);
+ this.h[3] = sum32(this.h[3], d);
+ this.h[4] = sum32(this.h[4], e);
+};
+
+SHA1.prototype._digest = function digest(enc) {
+ if (enc === 'hex')
+ return utils.toHex32(this.h, 'big');
+ else
+ return utils.split32(this.h, 'big');
+};
+
+function ch32(x, y, z) {
+ return (x & y) ^ ((~x) & z);
+}
+
+function maj32(x, y, z) {
+ return (x & y) ^ (x & z) ^ (y & z);
+}
+
+function p32(x, y, z) {
+ return x ^ y ^ z;
+}
+
+function s0_256(x) {
+ return rotr32(x, 2) ^ rotr32(x, 13) ^ rotr32(x, 22);
+}
+
+function s1_256(x) {
+ return rotr32(x, 6) ^ rotr32(x, 11) ^ rotr32(x, 25);
+}
+
+function g0_256(x) {
+ return rotr32(x, 7) ^ rotr32(x, 18) ^ (x >>> 3);
+}
+
+function g1_256(x) {
+ return rotr32(x, 17) ^ rotr32(x, 19) ^ (x >>> 10);
+}
+
+function ft_1(s, x, y, z) {
+ if (s === 0)
+ return ch32(x, y, z);
+ if (s === 1 || s === 3)
+ return p32(x, y, z);
+ if (s === 2)
+ return maj32(x, y, z);
+}
+
+function ch64_hi(xh, xl, yh, yl, zh, zl) {
+ var r = (xh & yh) ^ ((~xh) & zh);
+ if (r < 0)
+ r += 0x100000000;
+ return r;
+}
+
+function ch64_lo(xh, xl, yh, yl, zh, zl) {
+ var r = (xl & yl) ^ ((~xl) & zl);
+ if (r < 0)
+ r += 0x100000000;
+ return r;
+}
+
+function maj64_hi(xh, xl, yh, yl, zh, zl) {
+ var r = (xh & yh) ^ (xh & zh) ^ (yh & zh);
+ if (r < 0)
+ r += 0x100000000;
+ return r;
+}
+
+function maj64_lo(xh, xl, yh, yl, zh, zl) {
+ var r = (xl & yl) ^ (xl & zl) ^ (yl & zl);
+ if (r < 0)
+ r += 0x100000000;
+ return r;
+}
+
+function s0_512_hi(xh, xl) {
+ var c0_hi = rotr64_hi(xh, xl, 28);
+ var c1_hi = rotr64_hi(xl, xh, 2); // 34
+ var c2_hi = rotr64_hi(xl, xh, 7); // 39
+
+ var r = c0_hi ^ c1_hi ^ c2_hi;
+ if (r < 0)
+ r += 0x100000000;
+ return r;
+}
+
+function s0_512_lo(xh, xl) {
+ var c0_lo = rotr64_lo(xh, xl, 28);
+ var c1_lo = rotr64_lo(xl, xh, 2); // 34
+ var c2_lo = rotr64_lo(xl, xh, 7); // 39
+
+ var r = c0_lo ^ c1_lo ^ c2_lo;
+ if (r < 0)
+ r += 0x100000000;
+ return r;
+}
+
+function s1_512_hi(xh, xl) {
+ var c0_hi = rotr64_hi(xh, xl, 14);
+ var c1_hi = rotr64_hi(xh, xl, 18);
+ var c2_hi = rotr64_hi(xl, xh, 9); // 41
+
+ var r = c0_hi ^ c1_hi ^ c2_hi;
+ if (r < 0)
+ r += 0x100000000;
+ return r;
+}
+
+function s1_512_lo(xh, xl) {
+ var c0_lo = rotr64_lo(xh, xl, 14);
+ var c1_lo = rotr64_lo(xh, xl, 18);
+ var c2_lo = rotr64_lo(xl, xh, 9); // 41
+
+ var r = c0_lo ^ c1_lo ^ c2_lo;
+ if (r < 0)
+ r += 0x100000000;
+ return r;
+}
+
+function g0_512_hi(xh, xl) {
+ var c0_hi = rotr64_hi(xh, xl, 1);
+ var c1_hi = rotr64_hi(xh, xl, 8);
+ var c2_hi = shr64_hi(xh, xl, 7);
+
+ var r = c0_hi ^ c1_hi ^ c2_hi;
+ if (r < 0)
+ r += 0x100000000;
+ return r;
+}
+
+function g0_512_lo(xh, xl) {
+ var c0_lo = rotr64_lo(xh, xl, 1);
+ var c1_lo = rotr64_lo(xh, xl, 8);
+ var c2_lo = shr64_lo(xh, xl, 7);
+
+ var r = c0_lo ^ c1_lo ^ c2_lo;
+ if (r < 0)
+ r += 0x100000000;
+ return r;
+}
+
+function g1_512_hi(xh, xl) {
+ var c0_hi = rotr64_hi(xh, xl, 19);
+ var c1_hi = rotr64_hi(xl, xh, 29); // 61
+ var c2_hi = shr64_hi(xh, xl, 6);
+
+ var r = c0_hi ^ c1_hi ^ c2_hi;
+ if (r < 0)
+ r += 0x100000000;
+ return r;
+}
+
+function g1_512_lo(xh, xl) {
+ var c0_lo = rotr64_lo(xh, xl, 19);
+ var c1_lo = rotr64_lo(xl, xh, 29); // 61
+ var c2_lo = shr64_lo(xh, xl, 6);
+
+ var r = c0_lo ^ c1_lo ^ c2_lo;
+ if (r < 0)
+ r += 0x100000000;
+ return r;
+}
diff --git a/node_modules/hash.js/lib/hash/utils.js b/node_modules/hash.js/lib/hash/utils.js
new file mode 100644
index 000000000..00ed5fb43
--- /dev/null
+++ b/node_modules/hash.js/lib/hash/utils.js
@@ -0,0 +1,257 @@
+var utils = exports;
+var inherits = require('inherits');
+
+function toArray(msg, enc) {
+ if (Array.isArray(msg))
+ return msg.slice();
+ if (!msg)
+ return [];
+ var res = [];
+ if (typeof msg === 'string') {
+ if (!enc) {
+ for (var i = 0; i < msg.length; i++) {
+ var c = msg.charCodeAt(i);
+ var hi = c >> 8;
+ var lo = c & 0xff;
+ if (hi)
+ res.push(hi, lo);
+ else
+ res.push(lo);
+ }
+ } else if (enc === 'hex') {
+ msg = msg.replace(/[^a-z0-9]+/ig, '');
+ if (msg.length % 2 !== 0)
+ msg = '0' + msg;
+ for (var i = 0; i < msg.length; i += 2)
+ res.push(parseInt(msg[i] + msg[i + 1], 16));
+ }
+ } else {
+ for (var i = 0; i < msg.length; i++)
+ res[i] = msg[i] | 0;
+ }
+ return res;
+}
+utils.toArray = toArray;
+
+function toHex(msg) {
+ var res = '';
+ for (var i = 0; i < msg.length; i++)
+ res += zero2(msg[i].toString(16));
+ return res;
+}
+utils.toHex = toHex;
+
+function htonl(w) {
+ var res = (w >>> 24) |
+ ((w >>> 8) & 0xff00) |
+ ((w << 8) & 0xff0000) |
+ ((w & 0xff) << 24);
+ return res >>> 0;
+}
+utils.htonl = htonl;
+
+function toHex32(msg, endian) {
+ var res = '';
+ for (var i = 0; i < msg.length; i++) {
+ var w = msg[i];
+ if (endian === 'little')
+ w = htonl(w);
+ res += zero8(w.toString(16));
+ }
+ return res;
+}
+utils.toHex32 = toHex32;
+
+function zero2(word) {
+ if (word.length === 1)
+ return '0' + word;
+ else
+ return word;
+}
+utils.zero2 = zero2;
+
+function zero8(word) {
+ if (word.length === 7)
+ return '0' + word;
+ else if (word.length === 6)
+ return '00' + word;
+ else if (word.length === 5)
+ return '000' + word;
+ else if (word.length === 4)
+ return '0000' + word;
+ else if (word.length === 3)
+ return '00000' + word;
+ else if (word.length === 2)
+ return '000000' + word;
+ else if (word.length === 1)
+ return '0000000' + word;
+ else
+ return word;
+}
+utils.zero8 = zero8;
+
+function join32(msg, start, end, endian) {
+ var len = end - start;
+ assert(len % 4 === 0);
+ var res = new Array(len / 4);
+ for (var i = 0, k = start; i < res.length; i++, k += 4) {
+ var w;
+ if (endian === 'big')
+ w = (msg[k] << 24) | (msg[k + 1] << 16) | (msg[k + 2] << 8) | msg[k + 3];
+ else
+ w = (msg[k + 3] << 24) | (msg[k + 2] << 16) | (msg[k + 1] << 8) | msg[k];
+ res[i] = w >>> 0;
+ }
+ return res;
+}
+utils.join32 = join32;
+
+function split32(msg, endian) {
+ var res = new Array(msg.length * 4);
+ for (var i = 0, k = 0; i < msg.length; i++, k += 4) {
+ var m = msg[i];
+ if (endian === 'big') {
+ res[k] = m >>> 24;
+ res[k + 1] = (m >>> 16) & 0xff;
+ res[k + 2] = (m >>> 8) & 0xff;
+ res[k + 3] = m & 0xff;
+ } else {
+ res[k + 3] = m >>> 24;
+ res[k + 2] = (m >>> 16) & 0xff;
+ res[k + 1] = (m >>> 8) & 0xff;
+ res[k] = m & 0xff;
+ }
+ }
+ return res;
+}
+utils.split32 = split32;
+
+function rotr32(w, b) {
+ return (w >>> b) | (w << (32 - b));
+}
+utils.rotr32 = rotr32;
+
+function rotl32(w, b) {
+ return (w << b) | (w >>> (32 - b));
+}
+utils.rotl32 = rotl32;
+
+function sum32(a, b) {
+ return (a + b) >>> 0;
+}
+utils.sum32 = sum32;
+
+function sum32_3(a, b, c) {
+ return (a + b + c) >>> 0;
+}
+utils.sum32_3 = sum32_3;
+
+function sum32_4(a, b, c, d) {
+ return (a + b + c + d) >>> 0;
+}
+utils.sum32_4 = sum32_4;
+
+function sum32_5(a, b, c, d, e) {
+ return (a + b + c + d + e) >>> 0;
+}
+utils.sum32_5 = sum32_5;
+
+function assert(cond, msg) {
+ if (!cond)
+ throw new Error(msg || 'Assertion failed');
+}
+utils.assert = assert;
+
+utils.inherits = inherits;
+
+function sum64(buf, pos, ah, al) {
+ var bh = buf[pos];
+ var bl = buf[pos + 1];
+
+ var lo = (al + bl) >>> 0;
+ var hi = (lo < al ? 1 : 0) + ah + bh;
+ buf[pos] = hi >>> 0;
+ buf[pos + 1] = lo;
+}
+exports.sum64 = sum64;
+
+function sum64_hi(ah, al, bh, bl) {
+ var lo = (al + bl) >>> 0;
+ var hi = (lo < al ? 1 : 0) + ah + bh;
+ return hi >>> 0;
+};
+exports.sum64_hi = sum64_hi;
+
+function sum64_lo(ah, al, bh, bl) {
+ var lo = al + bl;
+ return lo >>> 0;
+};
+exports.sum64_lo = sum64_lo;
+
+function sum64_4_hi(ah, al, bh, bl, ch, cl, dh, dl) {
+ var carry = 0;
+ var lo = al;
+ lo = (lo + bl) >>> 0;
+ carry += lo < al ? 1 : 0;
+ lo = (lo + cl) >>> 0;
+ carry += lo < cl ? 1 : 0;
+ lo = (lo + dl) >>> 0;
+ carry += lo < dl ? 1 : 0;
+
+ var hi = ah + bh + ch + dh + carry;
+ return hi >>> 0;
+};
+exports.sum64_4_hi = sum64_4_hi;
+
+function sum64_4_lo(ah, al, bh, bl, ch, cl, dh, dl) {
+ var lo = al + bl + cl + dl;
+ return lo >>> 0;
+};
+exports.sum64_4_lo = sum64_4_lo;
+
+function sum64_5_hi(ah, al, bh, bl, ch, cl, dh, dl, eh, el) {
+ var carry = 0;
+ var lo = al;
+ lo = (lo + bl) >>> 0;
+ carry += lo < al ? 1 : 0;
+ lo = (lo + cl) >>> 0;
+ carry += lo < cl ? 1 : 0;
+ lo = (lo + dl) >>> 0;
+ carry += lo < dl ? 1 : 0;
+ lo = (lo + el) >>> 0;
+ carry += lo < el ? 1 : 0;
+
+ var hi = ah + bh + ch + dh + eh + carry;
+ return hi >>> 0;
+};
+exports.sum64_5_hi = sum64_5_hi;
+
+function sum64_5_lo(ah, al, bh, bl, ch, cl, dh, dl, eh, el) {
+ var lo = al + bl + cl + dl + el;
+
+ return lo >>> 0;
+};
+exports.sum64_5_lo = sum64_5_lo;
+
+function rotr64_hi(ah, al, num) {
+ var r = (al << (32 - num)) | (ah >>> num);
+ return r >>> 0;
+};
+exports.rotr64_hi = rotr64_hi;
+
+function rotr64_lo(ah, al, num) {
+ var r = (ah << (32 - num)) | (al >>> num);
+ return r >>> 0;
+};
+exports.rotr64_lo = rotr64_lo;
+
+function shr64_hi(ah, al, num) {
+ return ah >>> num;
+};
+exports.shr64_hi = shr64_hi;
+
+function shr64_lo(ah, al, num) {
+ var r = (ah << (32 - num)) | (al >>> num);
+ return r >>> 0;
+};
+exports.shr64_lo = shr64_lo;
diff --git a/node_modules/hash.js/package.json b/node_modules/hash.js/package.json
new file mode 100644
index 000000000..04f7b6565
--- /dev/null
+++ b/node_modules/hash.js/package.json
@@ -0,0 +1,31 @@
+{
+ "name": "hash.js",
+ "version": "1.0.3",
+ "description": "Various hash functions that could be run by both browser and node",
+ "main": "lib/hash.js",
+ "scripts": {
+ "test": "mocha --reporter=spec test/*-test.js"
+ },
+ "repository": {
+ "type": "git",
+ "url": "git@github.com:indutny/hash.js"
+ },
+ "keywords": [
+ "hash",
+ "sha256",
+ "sha224",
+ "hmac"
+ ],
+ "author": "Fedor Indutny <fedor@indutny.com>",
+ "license": "MIT",
+ "bugs": {
+ "url": "https://github.com/indutny/hash.js/issues"
+ },
+ "homepage": "https://github.com/indutny/hash.js",
+ "dependencies": {
+ "inherits": "^2.0.1"
+ },
+ "devDependencies": {
+ "mocha": "^1.18.2"
+ }
+}
diff --git a/node_modules/hash.js/test/hash-test.js b/node_modules/hash.js/test/hash-test.js
new file mode 100644
index 000000000..97347a27f
--- /dev/null
+++ b/node_modules/hash.js/test/hash-test.js
@@ -0,0 +1,119 @@
+var assert = require('assert');
+var hash = require('../');
+
+describe('Hash', function() {
+ function test(fn, cases) {
+ for (var i = 0; i < cases.length; i++) {
+ var msg = cases[i][0];
+ var res = cases[i][1];
+ var enc = cases[i][2];
+
+ var dgst = fn().update(msg, enc).digest('hex');
+ assert.equal(dgst, res);
+
+ // Split message
+ var dgst = fn().update(msg.slice(0, 2), enc)
+ .update(msg.slice(2), enc)
+ .digest('hex');
+ assert.equal(dgst, res);
+ }
+ }
+
+ it('should support sha256', function() {
+ assert.equal(hash.sha256.blockSize, 512);
+ assert.equal(hash.sha256.outSize, 256);
+
+ test(hash.sha256, [
+ [ 'abc',
+ 'ba7816bf8f01cfea414140de5dae2223b00361a396177a9cb410ff61f20015ad' ],
+ [ 'abcdbcdecdefdefgefghfghighijhijkijkljklmklmnlmnomnopnopq',
+ '248d6a61d20638b8e5c026930c3e6039a33ce45964ff2167f6ecedd419db06c1' ],
+ [ 'deadbeef',
+ '5f78c33274e43fa9de5659265c1d917e25c03722dcb0b8d27db8d5feaa813953',
+ 'hex' ],
+ ]);
+ });
+
+ it('should support sha224', function() {
+ assert.equal(hash.sha224.blockSize, 512);
+ assert.equal(hash.sha224.outSize, 224);
+
+ test(hash.sha224, [
+ [ 'abc',
+ '23097d223405d8228642a477bda255b32aadbce4bda0b3f7e36c9da7' ],
+ [ 'abcdbcdecdefdefgefghfghighijhijkijkljklmklmnlmnomnopnopq',
+ '75388b16512776cc5dba5da1fd890150b0c6455cb4f58b1952522525' ],
+ [ 'deadbeef',
+ '55b9eee5f60cc362ddc07676f620372611e22272f60fdbec94f243f8',
+ 'hex' ],
+ ]);
+ });
+
+ it('should support ripemd160', function() {
+ assert.equal(hash.ripemd160.blockSize, 512);
+ assert.equal(hash.ripemd160.outSize, 160);
+
+ test(hash.ripemd160, [
+ [ '', '9c1185a5c5e9fc54612808977ee8f548b2258d31'],
+ [ 'abc',
+ '8eb208f7e05d987a9b044a8e98c6b087f15a0bfc' ],
+ [ 'message digest',
+ '5d0689ef49d2fae572b881b123a85ffa21595f36' ],
+ [ 'abcdbcdecdefdefgefghfghighijhijkijkljklmklmnlmnomnopnopq',
+ '12a053384a9c0c88e405a06c27dcf49ada62eb2b' ],
+ [ 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789',
+ 'b0e20b6e3116640286ed3a87a5713079b21f5189' ],
+ ]);
+ });
+
+ it('should support sha1', function() {
+ assert.equal(hash.sha1.blockSize, 512);
+ assert.equal(hash.sha1.outSize, 160);
+
+ test(hash.sha1, [
+ [ '',
+ 'da39a3ee5e6b4b0d3255bfef95601890afd80709' ],
+ [ 'abc',
+ 'a9993e364706816aba3e25717850c26c9cd0d89d' ],
+ [ 'abcdbcdecdefdefgefghfghighijhijkijkljklmklmnlmnomnopnopq',
+ '84983e441c3bd26ebaae4aa1f95129e5e54670f1' ],
+ [ 'deadbeef',
+ 'd78f8bb992a56a597f6c7a1fb918bb78271367eb',
+ 'hex' ],
+ ]);
+ });
+
+ it('should support sha512', function() {
+ assert.equal(hash.sha512.blockSize, 1024);
+ assert.equal(hash.sha512.outSize, 512);
+
+ test(hash.sha512, [
+ [ 'abc',
+ 'ddaf35a193617abacc417349ae20413112e6fa4e89a97ea20a9eeee64b55d39a' +
+ '2192992a274fc1a836ba3c23a3feebbd454d4423643ce80e2a9ac94fa54ca49f'
+ ],
+ [ 'abcdefghbcdefghicdefghijdefghijkefghijklfghijklmghijklmn' +
+ 'hijklmnoijklmnopjklmnopqklmnopqrlmnopqrsmnopqrstnopqrstu',
+ '8e959b75dae313da8cf4f72814fc143f8f7779c6eb9f7fa17299aeadb6889018' +
+ '501d289e4900f7e4331b99dec4b5433ac7d329eeb6dd26545e96e55b874be909'
+ ]
+ ]);
+ });
+
+ it('should support sha384', function() {
+ assert.equal(hash.sha384.blockSize, 1024);
+ assert.equal(hash.sha384.outSize, 384);
+
+ test(hash.sha384, [
+ [ 'abc',
+ 'cb00753f45a35e8bb5a03d699ac65007272c32ab0eded1631a8b605a43ff5bed' +
+ '8086072ba1e7cc2358baeca134c825a7'
+ ],
+ [ 'abcdefghbcdefghicdefghijdefghijkefghijklfghijklmghijklmn' +
+ 'hijklmnoijklmnopjklmnopqklmnopqrlmnopqrsmnopqrstnopqrstu',
+ '09330c33f71147e83d192fc782cd1b4753111b173b3b05d22fa08086e3b0f712' +
+ 'fcc7c71a557e2db966c3e9fa91746039'
+ ]
+ ]);
+ });
+});
diff --git a/node_modules/hash.js/test/hmac-test.js b/node_modules/hash.js/test/hmac-test.js
new file mode 100644
index 000000000..0a9647eec
--- /dev/null
+++ b/node_modules/hash.js/test/hmac-test.js
@@ -0,0 +1,59 @@
+var assert = require('assert');
+var hash = require('../');
+var utils = hash.utils;
+
+describe('Hmac', function() {
+ describe('mixed test vector', function() {
+ test({
+ name: 'nist 1',
+ key: '00010203 04050607 08090A0B 0C0D0E0F' +
+ '10111213 14151617 18191A1B 1C1D1E1F 20212223 24252627' +
+ '28292A2B 2C2D2E2F 30313233 34353637 38393A3B 3C3D3E3F',
+ msg: 'Sample message for keylen=blocklen',
+ res: '8bb9a1db9806f20df7f77b82138c7914d174d59e13dc4d0169c9057b133e1d62'
+ });
+ test({
+ name: 'nist 2',
+ key: '00010203 04050607' +
+ '08090A0B 0C0D0E0F 10111213 14151617 18191A1B 1C1D1E1F',
+ msg: 'Sample message for keylen<blocklen',
+ res: 'a28cf43130ee696a98f14a37678b56bcfcbdd9e5cf69717fecf5480f0ebdf790'
+ });
+ test({
+ name: 'nist 3',
+ key: '00010203' +
+ '04050607 08090A0B 0C0D0E0F 10111213 14151617 18191A1B' +
+ '1C1D1E1F 20212223 24252627 28292A2B 2C2D2E2F 30313233' +
+ '34353637 38393A3B 3C3D3E3F 40414243 44454647 48494A4B' +
+ '4C4D4E4F 50515253 54555657 58595A5B 5C5D5E5F 60616263',
+ msg: 'Sample message for keylen=blocklen',
+ res: 'bdccb6c72ddeadb500ae768386cb38cc41c63dbb0878ddb9c7a38a431b78378d'
+ });
+ test({
+ name: 'nist 4',
+ key: '00' +
+ '01020304 05060708 090A0B0C 0D0E0F10 11121314 15161718' +
+ '191A1B1C 1D1E1F20 21222324 25262728 292A2B2C 2D2E2F30',
+ msg: 'Sample message for keylen<blocklen, with truncated tag',
+ res: '27a8b157839efeac98df070b331d593618ddb985d403c0c786d23b5d132e57c7'
+ });
+ test({
+ name: 'regression 1',
+ key: '48f38d0c6a344959cc94502b7b5e8dffb6a5f41795d9066fc9a649557167ee2f',
+ msg: '1d495eef7761b65dccd0a983d2d7204fea28b5c81f1758046e062eb043755ea1',
+ msgEnc: 'hex',
+ res: 'cf5ad5984f9e43917aa9087380dac46e410ddc8a7731859c84e9d0f31bd43655'
+ });
+
+ function test(opt) {
+ it('should not fail at ' + opt.name, function() {
+ var h = hash.hmac(hash.sha256, opt.key, 'hex');
+ assert.equal(h.update(opt.msg, opt.msgEnc).digest('hex'), opt.res);
+ var h = hash.hmac(hash.sha256, opt.key, 'hex');
+ assert.equal(h.update(opt.msg.slice(0, 10), opt.msgEnc)
+ .update(opt.msg.slice(10), opt.msgEnc)
+ .digest('hex'), opt.res);
+ });
+ }
+ });
+});