diff options
Diffstat (limited to 'node_modules/sha.js')
-rw-r--r-- | node_modules/sha.js/.travis.yml | 17 | ||||
-rw-r--r-- | node_modules/sha.js/LICENSE | 49 | ||||
-rw-r--r-- | node_modules/sha.js/README.md | 44 | ||||
-rwxr-xr-x | node_modules/sha.js/bin.js | 41 | ||||
-rw-r--r-- | node_modules/sha.js/hash.js | 81 | ||||
-rw-r--r-- | node_modules/sha.js/index.js | 15 | ||||
-rw-r--r-- | node_modules/sha.js/package.json | 66 | ||||
-rw-r--r-- | node_modules/sha.js/sha.js | 94 | ||||
-rw-r--r-- | node_modules/sha.js/sha1.js | 99 | ||||
-rw-r--r-- | node_modules/sha.js/sha224.js | 53 | ||||
-rw-r--r-- | node_modules/sha.js/sha256.js | 135 | ||||
-rw-r--r-- | node_modules/sha.js/sha384.js | 57 | ||||
-rw-r--r-- | node_modules/sha.js/sha512.js | 260 | ||||
-rw-r--r-- | node_modules/sha.js/test/hash.js | 75 | ||||
-rw-r--r-- | node_modules/sha.js/test/test.js | 100 | ||||
-rw-r--r-- | node_modules/sha.js/test/vectors.js | 72 |
16 files changed, 0 insertions, 1258 deletions
diff --git a/node_modules/sha.js/.travis.yml b/node_modules/sha.js/.travis.yml deleted file mode 100644 index 0b606eb..0000000 --- a/node_modules/sha.js/.travis.yml +++ /dev/null @@ -1,17 +0,0 @@ -sudo: false -os: - - linux -language: node_js -node_js: - - "4" - - "5" - - "6" - - "7" -env: - matrix: - - TEST_SUITE=unit -matrix: - include: - - node_js: "7" - env: TEST_SUITE=lint -script: npm run $TEST_SUITE diff --git a/node_modules/sha.js/LICENSE b/node_modules/sha.js/LICENSE deleted file mode 100644 index 11888c1..0000000 --- a/node_modules/sha.js/LICENSE +++ /dev/null @@ -1,49 +0,0 @@ -Copyright (c) 2013-2018 sha.js 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. - - -Copyright (c) 1998 - 2009, Paul Johnston & Contributors -All rights reserved. - -Redistribution and use in source and binary forms, with or without -modification, are permitted provided that the following conditions are met: - -Redistributions of source code must retain the above copyright notice, this -list of conditions and the following disclaimer. - -Redistributions in binary form must reproduce the above copyright notice, this -list of conditions and the following disclaimer in the documentation and/or -other materials provided with the distribution. - -Neither the name of the author nor the names of its contributors may be used to -endorse or promote products derived from this software without specific prior -written permission. - -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND -ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED -WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR -ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES -(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; -LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON -ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - diff --git a/node_modules/sha.js/README.md b/node_modules/sha.js/README.md deleted file mode 100644 index 1cc3db5..0000000 --- a/node_modules/sha.js/README.md +++ /dev/null @@ -1,44 +0,0 @@ -# sha.js -[](https://www.npmjs.org/package/sha.js) -[](https://travis-ci.org/crypto-browserify/sha.js) -[](https://david-dm.org/crypto-browserify/sha.js#info=dependencies) - -[](https://github.com/feross/standard) - -Node style `SHA` on pure JavaScript. - -```js -var shajs = require('sha.js') - -console.log(shajs('sha256').update('42').digest('hex')) -// => 73475cb40a568e8da8a045ced110137e159f890ac4da883b6b17dc651b3a8049 -console.log(new shajs.sha256().update('42').digest('hex')) -// => 73475cb40a568e8da8a045ced110137e159f890ac4da883b6b17dc651b3a8049 - -var sha256stream = shajs('sha256') -sha256stream.end('42') -console.log(sha256stream.read().toString('hex')) -// => 73475cb40a568e8da8a045ced110137e159f890ac4da883b6b17dc651b3a8049 -``` - -## supported hashes -`sha.js` currently implements: - - - SHA (SHA-0) -- **legacy, do not use in new systems** - - SHA-1 -- **legacy, do not use in new systems** - - SHA-224 - - SHA-256 - - SHA-384 - - SHA-512 - - -## Not an actual stream -Note, this doesn't actually implement a stream, but wrapping this in a stream is trivial. -It does update incrementally, so you can hash things larger than RAM, as it uses a constant amount of memory (except when using base64 or utf8 encoding, see code comments). - - -## Acknowledgements -This work is derived from Paul Johnston's [A JavaScript implementation of the Secure Hash Algorithm](http://pajhome.org.uk/crypt/md5/sha1.html). - - -## LICENSE [MIT](LICENSE) diff --git a/node_modules/sha.js/bin.js b/node_modules/sha.js/bin.js deleted file mode 100755 index 5a7ac83..0000000 --- a/node_modules/sha.js/bin.js +++ /dev/null @@ -1,41 +0,0 @@ -#! /usr/bin/env node - -var createHash = require('./browserify') -var argv = process.argv.slice(2) - -function pipe (algorithm, s) { - var start = Date.now() - var hash = createHash(algorithm || 'sha1') - - s.on('data', function (data) { - hash.update(data) - }) - - s.on('end', function () { - if (process.env.DEBUG) { - return console.log(hash.digest('hex'), Date.now() - start) - } - - console.log(hash.digest('hex')) - }) -} - -function usage () { - console.error('sha.js [algorithm=sha1] [filename] # hash filename with algorithm') - console.error('input | sha.js [algorithm=sha1] # hash stdin with algorithm') - console.error('sha.js --help # display this message') -} - -if (!process.stdin.isTTY) { - pipe(argv[0], process.stdin) -} else if (argv.length) { - if (/--help|-h/.test(argv[0])) { - usage() - } else { - var filename = argv.pop() - var algorithm = argv.pop() - pipe(algorithm, require('fs').createReadStream(filename)) - } -} else { - usage() -} diff --git a/node_modules/sha.js/hash.js b/node_modules/sha.js/hash.js deleted file mode 100644 index 013537a..0000000 --- a/node_modules/sha.js/hash.js +++ /dev/null @@ -1,81 +0,0 @@ -var Buffer = require('safe-buffer').Buffer - -// prototype class for hash functions -function Hash (blockSize, finalSize) { - this._block = Buffer.alloc(blockSize) - this._finalSize = finalSize - this._blockSize = blockSize - this._len = 0 -} - -Hash.prototype.update = function (data, enc) { - if (typeof data === 'string') { - enc = enc || 'utf8' - data = Buffer.from(data, enc) - } - - var block = this._block - var blockSize = this._blockSize - var length = data.length - var accum = this._len - - for (var offset = 0; offset < length;) { - var assigned = accum % blockSize - var remainder = Math.min(length - offset, blockSize - assigned) - - for (var i = 0; i < remainder; i++) { - block[assigned + i] = data[offset + i] - } - - accum += remainder - offset += remainder - - if ((accum % blockSize) === 0) { - this._update(block) - } - } - - this._len += length - return this -} - -Hash.prototype.digest = function (enc) { - var rem = this._len % this._blockSize - - this._block[rem] = 0x80 - - // zero (rem + 1) trailing bits, where (rem + 1) is the smallest - // non-negative solution to the equation (length + 1 + (rem + 1)) === finalSize mod blockSize - this._block.fill(0, rem + 1) - - if (rem >= this._finalSize) { - this._update(this._block) - this._block.fill(0) - } - - var bits = this._len * 8 - - // uint32 - if (bits <= 0xffffffff) { - this._block.writeUInt32BE(bits, this._blockSize - 4) - - // uint64 - } else { - var lowBits = (bits & 0xffffffff) >>> 0 - var highBits = (bits - lowBits) / 0x100000000 - - this._block.writeUInt32BE(highBits, this._blockSize - 8) - this._block.writeUInt32BE(lowBits, this._blockSize - 4) - } - - this._update(this._block) - var hash = this._hash() - - return enc ? hash.toString(enc) : hash -} - -Hash.prototype._update = function () { - throw new Error('_update must be implemented by subclass') -} - -module.exports = Hash diff --git a/node_modules/sha.js/index.js b/node_modules/sha.js/index.js deleted file mode 100644 index 87cdf49..0000000 --- a/node_modules/sha.js/index.js +++ /dev/null @@ -1,15 +0,0 @@ -var exports = module.exports = function SHA (algorithm) { - algorithm = algorithm.toLowerCase() - - var Algorithm = exports[algorithm] - if (!Algorithm) throw new Error(algorithm + ' is not supported (we accept pull requests)') - - return new Algorithm() -} - -exports.sha = require('./sha') -exports.sha1 = require('./sha1') -exports.sha224 = require('./sha224') -exports.sha256 = require('./sha256') -exports.sha384 = require('./sha384') -exports.sha512 = require('./sha512') diff --git a/node_modules/sha.js/package.json b/node_modules/sha.js/package.json deleted file mode 100644 index bf5ecc5..0000000 --- a/node_modules/sha.js/package.json +++ /dev/null @@ -1,66 +0,0 @@ -{ - "_from": "sha.js@^2.4.0", - "_id": "sha.js@2.4.11", - "_inBundle": false, - "_integrity": "sha512-QMEp5B7cftE7APOjk5Y6xgrbWu+WkLVQwk8JNjZ8nKRciZaByEW6MubieAiToS7+dwvrjGhH8jRXz3MVd0AYqQ==", - "_location": "/sha.js", - "_phantomChildren": {}, - "_requested": { - "type": "range", - "registry": true, - "raw": "sha.js@^2.4.0", - "name": "sha.js", - "escapedName": "sha.js", - "rawSpec": "^2.4.0", - "saveSpec": null, - "fetchSpec": "^2.4.0" - }, - "_requiredBy": [ - "/create-hash", - "/create-hmac", - "/pbkdf2" - ], - "_resolved": "https://registry.npmjs.org/sha.js/-/sha.js-2.4.11.tgz", - "_shasum": "37a5cf0b81ecbc6943de109ba2960d1b26584ae7", - "_spec": "sha.js@^2.4.0", - "_where": "/home/pruss/Dev/3-minute-website/node_modules/create-hash", - "author": { - "name": "Dominic Tarr", - "email": "dominic.tarr@gmail.com", - "url": "dominictarr.com" - }, - "bin": { - "sha.js": "bin.js" - }, - "bugs": { - "url": "https://github.com/crypto-browserify/sha.js/issues" - }, - "bundleDependencies": false, - "dependencies": { - "inherits": "^2.0.1", - "safe-buffer": "^5.0.1" - }, - "deprecated": false, - "description": "Streamable SHA hashes in pure javascript", - "devDependencies": { - "buffer": "~2.3.2", - "hash-test-vectors": "^1.3.1", - "standard": "^10.0.2", - "tape": "~2.3.2", - "typedarray": "0.0.6" - }, - "homepage": "https://github.com/crypto-browserify/sha.js", - "license": "(MIT AND BSD-3-Clause)", - "name": "sha.js", - "repository": { - "type": "git", - "url": "git://github.com/crypto-browserify/sha.js.git" - }, - "scripts": { - "lint": "standard", - "prepublish": "npm ls && npm run unit", - "test": "npm run lint && npm run unit", - "unit": "set -e; for t in test/*.js; do node $t; done;" - }, - "version": "2.4.11" -} diff --git a/node_modules/sha.js/sha.js b/node_modules/sha.js/sha.js deleted file mode 100644 index 50c4fa8..0000000 --- a/node_modules/sha.js/sha.js +++ /dev/null @@ -1,94 +0,0 @@ -/* - * A JavaScript implementation of the Secure Hash Algorithm, SHA-0, as defined - * in FIPS PUB 180-1 - * This source code is derived from sha1.js of the same repository. - * The difference between SHA-0 and SHA-1 is just a bitwise rotate left - * operation was added. - */ - -var inherits = require('inherits') -var Hash = require('./hash') -var Buffer = require('safe-buffer').Buffer - -var K = [ - 0x5a827999, 0x6ed9eba1, 0x8f1bbcdc | 0, 0xca62c1d6 | 0 -] - -var W = new Array(80) - -function Sha () { - this.init() - this._w = W - - Hash.call(this, 64, 56) -} - -inherits(Sha, Hash) - -Sha.prototype.init = function () { - this._a = 0x67452301 - this._b = 0xefcdab89 - this._c = 0x98badcfe - this._d = 0x10325476 - this._e = 0xc3d2e1f0 - - return this -} - -function rotl5 (num) { - return (num << 5) | (num >>> 27) -} - -function rotl30 (num) { - return (num << 30) | (num >>> 2) -} - -function ft (s, b, c, d) { - if (s === 0) return (b & c) | ((~b) & d) - if (s === 2) return (b & c) | (b & d) | (c & d) - return b ^ c ^ d -} - -Sha.prototype._update = function (M) { - var W = this._w - - var a = this._a | 0 - var b = this._b | 0 - var c = this._c | 0 - var d = this._d | 0 - var e = this._e | 0 - - for (var i = 0; i < 16; ++i) W[i] = M.readInt32BE(i * 4) - for (; i < 80; ++i) W[i] = W[i - 3] ^ W[i - 8] ^ W[i - 14] ^ W[i - 16] - - for (var j = 0; j < 80; ++j) { - var s = ~~(j / 20) - var t = (rotl5(a) + ft(s, b, c, d) + e + W[j] + K[s]) | 0 - - e = d - d = c - c = rotl30(b) - b = a - a = t - } - - this._a = (a + this._a) | 0 - this._b = (b + this._b) | 0 - this._c = (c + this._c) | 0 - this._d = (d + this._d) | 0 - this._e = (e + this._e) | 0 -} - -Sha.prototype._hash = function () { - var H = Buffer.allocUnsafe(20) - - H.writeInt32BE(this._a | 0, 0) - H.writeInt32BE(this._b | 0, 4) - H.writeInt32BE(this._c | 0, 8) - H.writeInt32BE(this._d | 0, 12) - H.writeInt32BE(this._e | 0, 16) - - return H -} - -module.exports = Sha diff --git a/node_modules/sha.js/sha1.js b/node_modules/sha.js/sha1.js deleted file mode 100644 index cabd747..0000000 --- a/node_modules/sha.js/sha1.js +++ /dev/null @@ -1,99 +0,0 @@ -/* - * A JavaScript implementation of the Secure Hash Algorithm, SHA-1, as defined - * in FIPS PUB 180-1 - * Version 2.1a Copyright Paul Johnston 2000 - 2002. - * Other contributors: Greg Holt, Andrew Kepert, Ydnar, Lostinet - * Distributed under the BSD License - * See http://pajhome.org.uk/crypt/md5 for details. - */ - -var inherits = require('inherits') -var Hash = require('./hash') -var Buffer = require('safe-buffer').Buffer - -var K = [ - 0x5a827999, 0x6ed9eba1, 0x8f1bbcdc | 0, 0xca62c1d6 | 0 -] - -var W = new Array(80) - -function Sha1 () { - this.init() - this._w = W - - Hash.call(this, 64, 56) -} - -inherits(Sha1, Hash) - -Sha1.prototype.init = function () { - this._a = 0x67452301 - this._b = 0xefcdab89 - this._c = 0x98badcfe - this._d = 0x10325476 - this._e = 0xc3d2e1f0 - - return this -} - -function rotl1 (num) { - return (num << 1) | (num >>> 31) -} - -function rotl5 (num) { - return (num << 5) | (num >>> 27) -} - -function rotl30 (num) { - return (num << 30) | (num >>> 2) -} - -function ft (s, b, c, d) { - if (s === 0) return (b & c) | ((~b) & d) - if (s === 2) return (b & c) | (b & d) | (c & d) - return b ^ c ^ d -} - -Sha1.prototype._update = function (M) { - var W = this._w - - var a = this._a | 0 - var b = this._b | 0 - var c = this._c | 0 - var d = this._d | 0 - var e = this._e | 0 - - for (var i = 0; i < 16; ++i) W[i] = M.readInt32BE(i * 4) - for (; i < 80; ++i) W[i] = rotl1(W[i - 3] ^ W[i - 8] ^ W[i - 14] ^ W[i - 16]) - - for (var j = 0; j < 80; ++j) { - var s = ~~(j / 20) - var t = (rotl5(a) + ft(s, b, c, d) + e + W[j] + K[s]) | 0 - - e = d - d = c - c = rotl30(b) - b = a - a = t - } - - this._a = (a + this._a) | 0 - this._b = (b + this._b) | 0 - this._c = (c + this._c) | 0 - this._d = (d + this._d) | 0 - this._e = (e + this._e) | 0 -} - -Sha1.prototype._hash = function () { - var H = Buffer.allocUnsafe(20) - - H.writeInt32BE(this._a | 0, 0) - H.writeInt32BE(this._b | 0, 4) - H.writeInt32BE(this._c | 0, 8) - H.writeInt32BE(this._d | 0, 12) - H.writeInt32BE(this._e | 0, 16) - - return H -} - -module.exports = Sha1 diff --git a/node_modules/sha.js/sha224.js b/node_modules/sha.js/sha224.js deleted file mode 100644 index 35541e5..0000000 --- a/node_modules/sha.js/sha224.js +++ /dev/null @@ -1,53 +0,0 @@ -/** - * A JavaScript implementation of the Secure Hash Algorithm, SHA-256, as defined - * in FIPS 180-2 - * Version 2.2-beta Copyright Angel Marin, Paul Johnston 2000 - 2009. - * Other contributors: Greg Holt, Andrew Kepert, Ydnar, Lostinet - * - */ - -var inherits = require('inherits') -var Sha256 = require('./sha256') -var Hash = require('./hash') -var Buffer = require('safe-buffer').Buffer - -var W = new Array(64) - -function Sha224 () { - this.init() - - this._w = W // new Array(64) - - Hash.call(this, 64, 56) -} - -inherits(Sha224, Sha256) - -Sha224.prototype.init = function () { - this._a = 0xc1059ed8 - this._b = 0x367cd507 - this._c = 0x3070dd17 - this._d = 0xf70e5939 - this._e = 0xffc00b31 - this._f = 0x68581511 - this._g = 0x64f98fa7 - this._h = 0xbefa4fa4 - - return this -} - -Sha224.prototype._hash = function () { - var H = Buffer.allocUnsafe(28) - - H.writeInt32BE(this._a, 0) - H.writeInt32BE(this._b, 4) - H.writeInt32BE(this._c, 8) - H.writeInt32BE(this._d, 12) - H.writeInt32BE(this._e, 16) - H.writeInt32BE(this._f, 20) - H.writeInt32BE(this._g, 24) - - return H -} - -module.exports = Sha224 diff --git a/node_modules/sha.js/sha256.js b/node_modules/sha.js/sha256.js deleted file mode 100644 index 342e48a..0000000 --- a/node_modules/sha.js/sha256.js +++ /dev/null @@ -1,135 +0,0 @@ -/** - * A JavaScript implementation of the Secure Hash Algorithm, SHA-256, as defined - * in FIPS 180-2 - * Version 2.2-beta Copyright Angel Marin, Paul Johnston 2000 - 2009. - * Other contributors: Greg Holt, Andrew Kepert, Ydnar, Lostinet - * - */ - -var inherits = require('inherits') -var Hash = require('./hash') -var Buffer = require('safe-buffer').Buffer - -var 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 W = new Array(64) - -function Sha256 () { - this.init() - - this._w = W // new Array(64) - - Hash.call(this, 64, 56) -} - -inherits(Sha256, Hash) - -Sha256.prototype.init = function () { - this._a = 0x6a09e667 - this._b = 0xbb67ae85 - this._c = 0x3c6ef372 - this._d = 0xa54ff53a - this._e = 0x510e527f - this._f = 0x9b05688c - this._g = 0x1f83d9ab - this._h = 0x5be0cd19 - - return this -} - -function ch (x, y, z) { - return z ^ (x & (y ^ z)) -} - -function maj (x, y, z) { - return (x & y) | (z & (x | y)) -} - -function sigma0 (x) { - return (x >>> 2 | x << 30) ^ (x >>> 13 | x << 19) ^ (x >>> 22 | x << 10) -} - -function sigma1 (x) { - return (x >>> 6 | x << 26) ^ (x >>> 11 | x << 21) ^ (x >>> 25 | x << 7) -} - -function gamma0 (x) { - return (x >>> 7 | x << 25) ^ (x >>> 18 | x << 14) ^ (x >>> 3) -} - -function gamma1 (x) { - return (x >>> 17 | x << 15) ^ (x >>> 19 | x << 13) ^ (x >>> 10) -} - -Sha256.prototype._update = function (M) { - var W = this._w - - var a = this._a | 0 - var b = this._b | 0 - var c = this._c | 0 - var d = this._d | 0 - var e = this._e | 0 - var f = this._f | 0 - var g = this._g | 0 - var h = this._h | 0 - - for (var i = 0; i < 16; ++i) W[i] = M.readInt32BE(i * 4) - for (; i < 64; ++i) W[i] = (gamma1(W[i - 2]) + W[i - 7] + gamma0(W[i - 15]) + W[i - 16]) | 0 - - for (var j = 0; j < 64; ++j) { - var T1 = (h + sigma1(e) + ch(e, f, g) + K[j] + W[j]) | 0 - var T2 = (sigma0(a) + maj(a, b, c)) | 0 - - h = g - g = f - f = e - e = (d + T1) | 0 - d = c - c = b - b = a - a = (T1 + T2) | 0 - } - - this._a = (a + this._a) | 0 - this._b = (b + this._b) | 0 - this._c = (c + this._c) | 0 - this._d = (d + this._d) | 0 - this._e = (e + this._e) | 0 - this._f = (f + this._f) | 0 - this._g = (g + this._g) | 0 - this._h = (h + this._h) | 0 -} - -Sha256.prototype._hash = function () { - var H = Buffer.allocUnsafe(32) - - H.writeInt32BE(this._a, 0) - H.writeInt32BE(this._b, 4) - H.writeInt32BE(this._c, 8) - H.writeInt32BE(this._d, 12) - H.writeInt32BE(this._e, 16) - H.writeInt32BE(this._f, 20) - H.writeInt32BE(this._g, 24) - H.writeInt32BE(this._h, 28) - - return H -} - -module.exports = Sha256 diff --git a/node_modules/sha.js/sha384.js b/node_modules/sha.js/sha384.js deleted file mode 100644 index afc85e5..0000000 --- a/node_modules/sha.js/sha384.js +++ /dev/null @@ -1,57 +0,0 @@ -var inherits = require('inherits') -var SHA512 = require('./sha512') -var Hash = require('./hash') -var Buffer = require('safe-buffer').Buffer - -var W = new Array(160) - -function Sha384 () { - this.init() - this._w = W - - Hash.call(this, 128, 112) -} - -inherits(Sha384, SHA512) - -Sha384.prototype.init = function () { - this._ah = 0xcbbb9d5d - this._bh = 0x629a292a - this._ch = 0x9159015a - this._dh = 0x152fecd8 - this._eh = 0x67332667 - this._fh = 0x8eb44a87 - this._gh = 0xdb0c2e0d - this._hh = 0x47b5481d - - this._al = 0xc1059ed8 - this._bl = 0x367cd507 - this._cl = 0x3070dd17 - this._dl = 0xf70e5939 - this._el = 0xffc00b31 - this._fl = 0x68581511 - this._gl = 0x64f98fa7 - this._hl = 0xbefa4fa4 - - return this -} - -Sha384.prototype._hash = function () { - var H = Buffer.allocUnsafe(48) - - function writeInt64BE (h, l, offset) { - H.writeInt32BE(h, offset) - H.writeInt32BE(l, offset + 4) - } - - writeInt64BE(this._ah, this._al, 0) - writeInt64BE(this._bh, this._bl, 8) - writeInt64BE(this._ch, this._cl, 16) - writeInt64BE(this._dh, this._dl, 24) - writeInt64BE(this._eh, this._el, 32) - writeInt64BE(this._fh, this._fl, 40) - - return H -} - -module.exports = Sha384 diff --git a/node_modules/sha.js/sha512.js b/node_modules/sha.js/sha512.js deleted file mode 100644 index fb28f2f..0000000 --- a/node_modules/sha.js/sha512.js +++ /dev/null @@ -1,260 +0,0 @@ -var inherits = require('inherits') -var Hash = require('./hash') -var Buffer = require('safe-buffer').Buffer - -var 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 W = new Array(160) - -function Sha512 () { - this.init() - this._w = W - - Hash.call(this, 128, 112) -} - -inherits(Sha512, Hash) - -Sha512.prototype.init = function () { - this._ah = 0x6a09e667 - this._bh = 0xbb67ae85 - this._ch = 0x3c6ef372 - this._dh = 0xa54ff53a - this._eh = 0x510e527f - this._fh = 0x9b05688c - this._gh = 0x1f83d9ab - this._hh = 0x5be0cd19 - - this._al = 0xf3bcc908 - this._bl = 0x84caa73b - this._cl = 0xfe94f82b - this._dl = 0x5f1d36f1 - this._el = 0xade682d1 - this._fl = 0x2b3e6c1f - this._gl = 0xfb41bd6b - this._hl = 0x137e2179 - - return this -} - -function Ch (x, y, z) { - return z ^ (x & (y ^ z)) -} - -function maj (x, y, z) { - return (x & y) | (z & (x | y)) -} - -function sigma0 (x, xl) { - return (x >>> 28 | xl << 4) ^ (xl >>> 2 | x << 30) ^ (xl >>> 7 | x << 25) -} - -function sigma1 (x, xl) { - return (x >>> 14 | xl << 18) ^ (x >>> 18 | xl << 14) ^ (xl >>> 9 | x << 23) -} - -function Gamma0 (x, xl) { - return (x >>> 1 | xl << 31) ^ (x >>> 8 | xl << 24) ^ (x >>> 7) -} - -function Gamma0l (x, xl) { - return (x >>> 1 | xl << 31) ^ (x >>> 8 | xl << 24) ^ (x >>> 7 | xl << 25) -} - -function Gamma1 (x, xl) { - return (x >>> 19 | xl << 13) ^ (xl >>> 29 | x << 3) ^ (x >>> 6) -} - -function Gamma1l (x, xl) { - return (x >>> 19 | xl << 13) ^ (xl >>> 29 | x << 3) ^ (x >>> 6 | xl << 26) -} - -function getCarry (a, b) { - return (a >>> 0) < (b >>> 0) ? 1 : 0 -} - -Sha512.prototype._update = function (M) { - var W = this._w - - var ah = this._ah | 0 - var bh = this._bh | 0 - var ch = this._ch | 0 - var dh = this._dh | 0 - var eh = this._eh | 0 - var fh = this._fh | 0 - var gh = this._gh | 0 - var hh = this._hh | 0 - - var al = this._al | 0 - var bl = this._bl | 0 - var cl = this._cl | 0 - var dl = this._dl | 0 - var el = this._el | 0 - var fl = this._fl | 0 - var gl = this._gl | 0 - var hl = this._hl | 0 - - for (var i = 0; i < 32; i += 2) { - W[i] = M.readInt32BE(i * 4) - W[i + 1] = M.readInt32BE(i * 4 + 4) - } - for (; i < 160; i += 2) { - var xh = W[i - 15 * 2] - var xl = W[i - 15 * 2 + 1] - var gamma0 = Gamma0(xh, xl) - var gamma0l = Gamma0l(xl, xh) - - xh = W[i - 2 * 2] - xl = W[i - 2 * 2 + 1] - var gamma1 = Gamma1(xh, xl) - var gamma1l = Gamma1l(xl, xh) - - // W[i] = gamma0 + W[i - 7] + gamma1 + W[i - 16] - var Wi7h = W[i - 7 * 2] - var Wi7l = W[i - 7 * 2 + 1] - - var Wi16h = W[i - 16 * 2] - var Wi16l = W[i - 16 * 2 + 1] - - var Wil = (gamma0l + Wi7l) | 0 - var Wih = (gamma0 + Wi7h + getCarry(Wil, gamma0l)) | 0 - Wil = (Wil + gamma1l) | 0 - Wih = (Wih + gamma1 + getCarry(Wil, gamma1l)) | 0 - Wil = (Wil + Wi16l) | 0 - Wih = (Wih + Wi16h + getCarry(Wil, Wi16l)) | 0 - - W[i] = Wih - W[i + 1] = Wil - } - - for (var j = 0; j < 160; j += 2) { - Wih = W[j] - Wil = W[j + 1] - - var majh = maj(ah, bh, ch) - var majl = maj(al, bl, cl) - - var sigma0h = sigma0(ah, al) - var sigma0l = sigma0(al, ah) - var sigma1h = sigma1(eh, el) - var sigma1l = sigma1(el, eh) - - // t1 = h + sigma1 + ch + K[j] + W[j] - var Kih = K[j] - var Kil = K[j + 1] - - var chh = Ch(eh, fh, gh) - var chl = Ch(el, fl, gl) - - var t1l = (hl + sigma1l) | 0 - var t1h = (hh + sigma1h + getCarry(t1l, hl)) | 0 - t1l = (t1l + chl) | 0 - t1h = (t1h + chh + getCarry(t1l, chl)) | 0 - t1l = (t1l + Kil) | 0 - t1h = (t1h + Kih + getCarry(t1l, Kil)) | 0 - t1l = (t1l + Wil) | 0 - t1h = (t1h + Wih + getCarry(t1l, Wil)) | 0 - - // t2 = sigma0 + maj - var t2l = (sigma0l + majl) | 0 - var t2h = (sigma0h + majh + getCarry(t2l, sigma0l)) | 0 - - hh = gh - hl = gl - gh = fh - gl = fl - fh = eh - fl = el - el = (dl + t1l) | 0 - eh = (dh + t1h + getCarry(el, dl)) | 0 - dh = ch - dl = cl - ch = bh - cl = bl - bh = ah - bl = al - al = (t1l + t2l) | 0 - ah = (t1h + t2h + getCarry(al, t1l)) | 0 - } - - this._al = (this._al + al) | 0 - this._bl = (this._bl + bl) | 0 - this._cl = (this._cl + cl) | 0 - this._dl = (this._dl + dl) | 0 - this._el = (this._el + el) | 0 - this._fl = (this._fl + fl) | 0 - this._gl = (this._gl + gl) | 0 - this._hl = (this._hl + hl) | 0 - - this._ah = (this._ah + ah + getCarry(this._al, al)) | 0 - this._bh = (this._bh + bh + getCarry(this._bl, bl)) | 0 - this._ch = (this._ch + ch + getCarry(this._cl, cl)) | 0 - this._dh = (this._dh + dh + getCarry(this._dl, dl)) | 0 - this._eh = (this._eh + eh + getCarry(this._el, el)) | 0 - this._fh = (this._fh + fh + getCarry(this._fl, fl)) | 0 - this._gh = (this._gh + gh + getCarry(this._gl, gl)) | 0 - this._hh = (this._hh + hh + getCarry(this._hl, hl)) | 0 -} - -Sha512.prototype._hash = function () { - var H = Buffer.allocUnsafe(64) - - function writeInt64BE (h, l, offset) { - H.writeInt32BE(h, offset) - H.writeInt32BE(l, offset + 4) - } - - writeInt64BE(this._ah, this._al, 0) - writeInt64BE(this._bh, this._bl, 8) - writeInt64BE(this._ch, this._cl, 16) - writeInt64BE(this._dh, this._dl, 24) - writeInt64BE(this._eh, this._el, 32) - writeInt64BE(this._fh, this._fl, 40) - writeInt64BE(this._gh, this._gl, 48) - writeInt64BE(this._hh, this._hl, 56) - - return H -} - -module.exports = Sha512 diff --git a/node_modules/sha.js/test/hash.js b/node_modules/sha.js/test/hash.js deleted file mode 100644 index 5fa000d..0000000 --- a/node_modules/sha.js/test/hash.js +++ /dev/null @@ -1,75 +0,0 @@ -var tape = require('tape') -var Hash = require('../hash') -var hex = '0A1B2C3D4E5F6G7H' - -function equal (t, a, b) { - t.equal(a.length, b.length) - t.equal(a.toString('hex'), b.toString('hex')) -} - -var hexBuf = Buffer.from('0A1B2C3D4E5F6G7H', 'utf8') -var count16 = { - strings: ['0A1B2C3D4E5F6G7H'], - buffers: [ - hexBuf, - Buffer.from('80000000000000000000000000000080', 'hex') - ] -} - -var empty = { - strings: [''], - buffers: [ - Buffer.from('80000000000000000000000000000000', 'hex') - ] -} - -var multi = { - strings: ['abcd', 'efhijk', 'lmnopq'], - buffers: [ - Buffer.from('abcdefhijklmnopq', 'ascii'), - Buffer.from('80000000000000000000000000000080', 'hex') - ] -} - -var long = { - strings: [hex + hex], - buffers: [ - hexBuf, - hexBuf, - Buffer.from('80000000000000000000000000000100', 'hex') - ] -} - -function makeTest (name, data) { - tape(name, function (t) { - var h = new Hash(16, 8) - var hash = Buffer.alloc(20) - var n = 2 - var expected = data.buffers.slice() - // t.plan(expected.length + 1) - - h._update = function (block) { - var e = expected.shift() - equal(t, block, e) - - if (n < 0) { - throw new Error('expecting only 2 calls to _update') - } - } - h._hash = function () { - return hash - } - - data.strings.forEach(function (string) { - h.update(string, 'ascii') - }) - - equal(t, h.digest(), hash) - t.end() - }) -} - -makeTest('Hash#update 1 in 1', count16) -makeTest('empty Hash#update', empty) -makeTest('Hash#update 1 in 3', multi) -makeTest('Hash#update 2 in 1', long) diff --git a/node_modules/sha.js/test/test.js b/node_modules/sha.js/test/test.js deleted file mode 100644 index dac8580..0000000 --- a/node_modules/sha.js/test/test.js +++ /dev/null @@ -1,100 +0,0 @@ -var crypto = require('crypto') -var tape = require('tape') -var Sha1 = require('../').sha1 - -var inputs = [ - ['', 'ascii'], - ['abc', 'ascii'], - ['123', 'ascii'], - ['123456789abcdef123456789abcdef123456789abcdef123456789abcdef', 'ascii'], - ['123456789abcdef123456789abcdef123456789abcdef123456789abc', 'ascii'], - ['123456789abcdef123456789abcdef123456789abcdef123456789ab', 'ascii'], - ['0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcde', 'ascii'], - ['0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef', 'ascii'], - ['foobarbaz', 'ascii'] -] - -tape("hash is the same as node's crypto", function (t) { - inputs.forEach(function (v) { - var a = new Sha1().update(v[0], v[1]).digest('hex') - var e = crypto.createHash('sha1').update(v[0], v[1]).digest('hex') - console.log(a, '==', e) - t.equal(a, e) - }) - - t.end() -}) - -tape('call update multiple times', function (t) { - inputs.forEach(function (v) { - var hash = new Sha1() - var _hash = crypto.createHash('sha1') - - for (var i = 0; i < v[0].length; i = (i + 1) * 2) { - var s = v[0].substring(i, (i + 1) * 2) - hash.update(s, v[1]) - _hash.update(s, v[1]) - } - - var a = hash.digest('hex') - var e = _hash.digest('hex') - console.log(a, '==', e) - t.equal(a, e) - }) - t.end() -}) - -tape('call update twice', function (t) { - var _hash = crypto.createHash('sha1') - var hash = new Sha1() - - _hash.update('foo', 'ascii') - hash.update('foo', 'ascii') - - _hash.update('bar', 'ascii') - hash.update('bar', 'ascii') - - _hash.update('baz', 'ascii') - hash.update('baz', 'ascii') - - var a = hash.digest('hex') - var e = _hash.digest('hex') - - t.equal(a, e) - t.end() -}) - -tape('hex encoding', function (t) { - inputs.forEach(function (v) { - var hash = new Sha1() - var _hash = crypto.createHash('sha1') - - for (var i = 0; i < v[0].length; i = (i + 1) * 2) { - var s = v[0].substring(i, (i + 1) * 2) - hash.update(Buffer.from(s, 'ascii').toString('hex'), 'hex') - _hash.update(Buffer.from(s, 'ascii').toString('hex'), 'hex') - } - var a = hash.digest('hex') - var e = _hash.digest('hex') - - console.log(a, '==', e) - t.equal(a, e) - }) - - t.end() -}) - -tape('call digest for more than MAX_UINT32 bits of data', function (t) { - var _hash = crypto.createHash('sha1') - var hash = new Sha1() - var bigData = Buffer.alloc(0x1ffffffff / 8) - - hash.update(bigData) - _hash.update(bigData) - - var a = hash.digest('hex') - var e = _hash.digest('hex') - - t.equal(a, e) - t.end() -}) diff --git a/node_modules/sha.js/test/vectors.js b/node_modules/sha.js/test/vectors.js deleted file mode 100644 index 48a646e..0000000 --- a/node_modules/sha.js/test/vectors.js +++ /dev/null @@ -1,72 +0,0 @@ -var tape = require('tape') -var vectors = require('hash-test-vectors') -// var from = require('bops/typedarray/from') -var Buffer = require('safe-buffer').Buffer - -var createHash = require('../') - -function makeTest (alg, i, verbose) { - var v = vectors[i] - - tape(alg + ': NIST vector ' + i, function (t) { - if (verbose) { - console.log(v) - console.log('VECTOR', i) - console.log('INPUT', v.input) - console.log(Buffer.from(v.input, 'base64').toString('hex')) - } - - var buf = Buffer.from(v.input, 'base64') - t.equal(createHash(alg).update(buf).digest('hex'), v[alg]) - - i = ~~(buf.length / 2) - var buf1 = buf.slice(0, i) - var buf2 = buf.slice(i, buf.length) - - console.log(buf1.length, buf2.length, buf.length) - console.log(createHash(alg)._block.length) - - t.equal( - createHash(alg) - .update(buf1) - .update(buf2) - .digest('hex'), - v[alg] - ) - - var j, buf3 - - i = ~~(buf.length / 3) - j = ~~(buf.length * 2 / 3) - buf1 = buf.slice(0, i) - buf2 = buf.slice(i, j) - buf3 = buf.slice(j, buf.length) - - t.equal( - createHash(alg) - .update(buf1) - .update(buf2) - .update(buf3) - .digest('hex'), - v[alg] - ) - - setTimeout(function () { - // avoid "too much recursion" errors in tape in firefox - t.end() - }) - }) -} - -if (process.argv[2]) { - makeTest(process.argv[2], parseInt(process.argv[3], 10), true) -} else { - vectors.forEach(function (v, i) { - makeTest('sha', i) - makeTest('sha1', i) - makeTest('sha224', i) - makeTest('sha256', i) - makeTest('sha384', i) - makeTest('sha512', i) - }) -} |