feat: Created a mini nodeJS server with NewMan for testing without PostMan GUI.

This will mimic a run in a CD/CI environment or docker container.
This commit is contained in:
Simon Priet
2021-09-08 14:01:19 +02:00
parent 5fbd7c88fa
commit e69a613a37
5610 changed files with 740417 additions and 3 deletions

86
node_modules/js-sha512/CHANGELOG.md generated vendored Normal file
View File

@@ -0,0 +1,86 @@
# Change Log
## v0.8.0 / 2018-08-05
### Added
- TypeScript definitions.
- clone method.
### Changed
- throw error if update after finalize
## v0.7.1 / 2017-12-21
### Fixed
- incorrect result when first bit is 1 of bytes.
## v0.7.0 / 2017-11-19
### Added
- support HMAC. #8
## v0.6.0 / 2017-10-31
### Fixed
- incorrect result when file size >= 512M.
## v0.5.0 / 2017-10-07
### Added
- support for web worker. #5
### Changed
- throw error if input type is incorrect.
## v0.4.0 / 2017-07-08
### Added
- Streaming support(update).
- support for ArrayBuffer input/output.
- support for byte array input/output.
## v0.3.0 / 2017-01-23
### Added
- AMD support.
### Fixed
- ArrayBuffer dosen't work in Webpack.
## v0.2.2 / 2015-02-09
### Improved
- performance.
## v0.2.1 / 2015-02-08
### Added
- test cases.
### Removed
- ascii parameter.
### Improved
- performance.
## v0.2.0 / 2015-02-02
### Added
- test cases.
### Improved
- performance.
## v0.1.3 / 2015-01-26
### Added
- test cases.
### Improved
- performance.
## v0.1.2 / 2015-01-07
### Added
- bower package.
- travis.
- coveralls.
### Fixed
- JSHint warnings.
## v0.1.1 / 2014-07-27
### Fixed
- accents bug.
## v0.1.0 / 2014-01-05
### Added
- initial release.

20
node_modules/js-sha512/LICENSE.txt generated vendored Normal file
View File

@@ -0,0 +1,20 @@
Copyright 2014-2018 Chen, Yi-Cyuan
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.

125
node_modules/js-sha512/README.md generated vendored Normal file
View File

@@ -0,0 +1,125 @@
# js-sha512
[![Build Status](https://travis-ci.org/emn178/js-sha512.svg?branch=master)](https://travis-ci.org/emn178/js-sha512)
[![Coverage Status](https://coveralls.io/repos/emn178/js-sha512/badge.svg?branch=master)](https://coveralls.io/r/emn178/js-sha512?branch=master)
[![CDNJS](https://img.shields.io/cdnjs/v/js-sha512.svg)](https://cdnjs.com/libraries/js-sha512/)
[![NPM](https://nodei.co/npm/js-sha512.png?stars&downloads)](https://nodei.co/npm/js-sha512/)
A simple SHA-512, SHA-384, SHA-512/224, SHA-512/256 hash functions for JavaScript supports UTF-8 encoding.
## Notice
* v0.8.0+ will throw an error if try to update hash after finalize.
## Demo
[SHA512 Online](http://emn178.github.io/online-tools/sha512.html)
[SHA384 Online](http://emn178.github.io/online-tools/sha384.html)
[SHA512/256 Online](http://emn178.github.io/online-tools/sha512_256.html)
[SHA512/224 Online](http://emn178.github.io/online-tools/sha512_224.html)
## Download
[Compress](https://raw.github.com/emn178/js-sha512/master/build/sha512.min.js)
[Uncompress](https://raw.github.com/emn178/js-sha512/master/src/sha512.js)
## Installation
You can also install js-sha512 by using Bower.
bower install js-sha512
For node.js, you can use this command to install:
npm install js-sha512
## Usage
You could use like this:
```JavaScript
sha512('Message to hash');
sha384('Message to hash');
sha512_256('Message to hash');
sha512_224('Message to hash');
// Support ArrayBuffer output
var arrayBuffer = sha512.arrayBuffer('Message to hash');
// Support Array output
var bytes = sha512.digest('Message to hash');
var bytes = sha512.array('Message to hash');
// update hash
var hash = sha512.update('Message to hash');
hash.update('Message2 to hash');
hash.hex();
// or to use create
var hash = sha512.create();
hash.update('Message to hash');
hash.hex();
// clone
var hash = sha512.update('Message to hash');
var hash2 = hash.clone();
hash2.hex();
hash.update('Message2 to hash');
hash.hex();
// HMAC
sha512.hmac('key', 'Message to hash');
sha384.hmac('key', 'Message to hash');
var hash = sha512.hmac.create('key');
hash.update('Message to hash');
hash.hex();
var hash2 = sha512.hmac.update('key', 'Message to hash');
hash2.update('Message2 to hash');
hash2.array();
```
If you use node.js, you should require the module first:
```JavaScript
var sha512 = require('js-sha512');
```
or
```JavaScript
var sha512 = require('js-sha512').sha512;
var sha384 = require('js-sha512').sha384;
var sha512_256 = require('js-sha512').sha512_256;
var sha512_224 = require('js-sha512').sha512_224;
```
It supports AMD:
```JavaScript
require(['your/path/sha512.js'], function(sha512) {
// ...
});
```
## Example
```JavaScript
sha512(''); // cf83e1357eefb8bdf1542850d66d8007d620e4050b5715dc83f4a921d36ce9ce47d0d13c5d85f2b0ff8318d2877eec2f63b931bd47417a81a538327af927da3e
sha512('The quick brown fox jumps over the lazy dog'); // 07e547d9586f6a73f73fbac0435ed76951218fb7d0c8d788a309d785436bbb642e93a252a954f23912547d1e8a3b5ed6e1bfd7097821233fa0538f3db854fee6
sha512('The quick brown fox jumps over the lazy dog.'); // 91ea1245f20d46ae9a037a989f54f1f790f0a47607eeb8a14d12890cea77a1bbc6c7ed9cf205e67b7f2b8fd4c7dfd3a7a8617e45f3c463d481c7e586c39ac1ed
sha384(''); // 38b060a751ac96384cd9327eb1b1e36a21fdb71114be07434c0cc7bf63f6e1da274edebfe76f65fbd51ad2f14898b95b
sha384('The quick brown fox jumps over the lazy dog'); // ca737f1014a48f4c0b6dd43cb177b0afd9e5169367544c494011e3317dbf9a509cb1e5dc1e85a941bbee3d7f2afbc9b1
sha384('The quick brown fox jumps over the lazy dog.'); // ed892481d8272ca6df370bf706e4d7bc1b5739fa2177aae6c50e946678718fc67a7af2819a021c2fc34e91bdb63409d7
sha512_256(''); // c672b8d1ef56ed28ab87c3622c5114069bdd3ad7b8f9737498d0c01ecef0967a
sha512_256('The quick brown fox jumps over the lazy dog'); // dd9d67b371519c339ed8dbd25af90e976a1eeefd4ad3d889005e532fc5bef04d
sha512_256('The quick brown fox jumps over the lazy dog.'); // 1546741840f8a492b959d9b8b2344b9b0eb51b004bba35c0aebaac86d45264c3
sha512_224(''); // 6ed0dd02806fa89e25de060c19d3ac86cabb87d6a0ddd05c333b84f4
sha512_224('The quick brown fox jumps over the lazy dog'); // 944cd2847fb54558d4775db0485a50003111c8e5daa63fe722c6aa37
sha512_224('The quick brown fox jumps over the lazy dog.'); // 6d6a9279495ec4061769752e7ff9c68b6b0b3c5a281b7917ce0572de
// It also supports UTF-8 encoding
sha512('中文'); // 8b88efc2ebbcbdad5ac2d65af05bec57bda25e71fd5fb25bbd892057a2755fbd05d8d8491cb2946febd5b0f124ffdfbaecf7e34946353c4f1b5ab29545895468
sha384('中文'); // 93422ceb8291a69b22f02dc1114c39a287493ad525dcebc77e4019a44eaee2633a85d0f29cd298ee6799048c33a4be0c
sha512_256('中文'); // b6dab29c16ec35ab34a5d92ff135b58de96741dda78b1009a2181cf8b45d2f72
sha512_224('中文'); // 0f46a0ae7f226517dd66ece0ce1efa29ffb7ced05ac4566fdcaed188
// Different output
sha512(''); // cf83e1357eefb8bdf1542850d66d8007d620e4050b5715dc83f4a921d36ce9ce47d0d13c5d85f2b0ff8318d2877eec2f63b931bd47417a81a538327af927da3e
sha512.hex(''); // cf83e1357eefb8bdf1542850d66d8007d620e4050b5715dc83f4a921d36ce9ce47d0d13c5d85f2b0ff8318d2877eec2f63b931bd47417a81a538327af927da3e
sha512.array(''); // [207, 131, 225, 53, 126, 239, 184, 189, 241, 84, 40, 80, 214, 109, 128, 7, 214, 32, 228, 5, 11, 87, 21, 220, 131, 244, 169, 33, 211, 108, 233, 206, 71, 208, 209, 60, 93, 133, 242, 176, 255, 131, 24, 210, 135, 126, 236, 47, 99, 185, 49, 189, 71, 65, 122, 129, 165, 56, 50, 122, 249, 39, 218, 62]
sha512.digest(''); // [207, 131, 225, 53, 126, 239, 184, 189, 241, 84, 40, 80, 214, 109, 128, 7, 214, 32, 228, 5, 11, 87, 21, 220, 131, 244, 169, 33, 211, 108, 233, 206, 71, 208, 209, 60, 93, 133, 242, 176, 255, 131, 24, 210, 135, 126, 236, 47, 99, 185, 49, 189, 71, 65, 122, 129, 165, 56, 50, 122, 249, 39, 218, 62]
sha512.arrayBuffer(''); // ArrayBuffer
```
## License
The project is released under the [MIT license](http://www.opensource.org/licenses/MIT).
## Contact
The project's website is located at https://github.com/emn178/js-sha512
Author: Chen, Yi-Cyuan (emn178@gmail.com)

9
node_modules/js-sha512/build/sha512.min.js generated vendored Normal file

File diff suppressed because one or more lines are too long

151
node_modules/js-sha512/index.d.ts generated vendored Normal file
View File

@@ -0,0 +1,151 @@
type Message = string | number[] | ArrayBuffer | Uint8Array;
interface Hasher {
/**
* Update hash
*
* @param message The message you want to hash.
*/
update(message: Message): Hasher;
/**
* Return hash in hex string.
*/
hex(): string;
/**
* Return hash in hex string.
*/
toString(): string;
/**
* Return hash in ArrayBuffer.
*/
arrayBuffer(): ArrayBuffer;
/**
* Return hash in integer array.
*/
digest(): number[];
/**
* Return hash in integer array.
*/
array(): number[];
}
interface Hmac {
/**
* Computes a Hash-based message authentication code (HMAC) using a secret key
*
* @param secretKey The Secret Key
* @param message The message you want to hash.
*/
(secretKey: string, message: Message): string;
/**
* Create a hash object using a secret key.
*
* @param secretKey The Secret Key
*/
create(secretKey: string): Hasher;
/**
* Create a hash object and hash message using a secret key
*
* @param secretKey The Secret Key
* @param message The message you want to hash.
*/
update(secretKey: string, message: Message): Hasher;
/**
* Return hash in hex string.
*
* @param secretKey The Secret Key
* @param message The message you want to hash.
*/
hex(secretKey: string, message: Message): string;
/**
* Return hash in ArrayBuffer.
*
* @param secretKey The Secret Key
* @param message The message you want to hash.
*/
arrayBuffer(secretKey: string, message: Message): ArrayBuffer;
/**
* Return hash in integer array.
*
* @param secretKey The Secret Key
* @param message The message you want to hash.
*/
digest(secretKey: string, message: Message): number[];
/**
* Return hash in integer array.
*
* @param secretKey The Secret Key
* @param message The message you want to hash.
*/
array(secretKey: string, message: Message): number[];
}
interface Hash {
/**
* Hash and return hex string.
*
* @param message The message you want to hash.
*/
(message: Message): string;
/**
* Hash and return hex string.
*
* @param message The message you want to hash.
*/
hex(message: Message): string;
/**
* Hash and return ArrayBuffer.
*
* @param message The message you want to hash.
*/
arrayBuffer(message: Message): ArrayBuffer;
/**
* Hash and return integer array.
*
* @param message The message you want to hash.
*/
digest(message: Message): number[];
/**
* Hash and return integer array.
*
* @param message The message you want to hash.
*/
array(message: Message): number[];
/**
* Create a hash object.
*/
create(): Hasher;
/**
* Create a hash object and hash message.
*
* @param message The message you want to hash.
*/
update(message: Message): Hasher;
/**
* HMAC interface
*/
hmac: Hmac;
}
export var sha512: Hash;
export var sha384: Hash;
export var sha512_256: Hash;
export var sha512_224: Hash;

47
node_modules/js-sha512/package.json generated vendored Normal file
View File

@@ -0,0 +1,47 @@
{
"name": "js-sha512",
"version": "0.8.0",
"description": "This is a simple SHA-512, SHA-384, SHA-512/224, SHA-512/256 hash functions for JavaScript supports UTF-8 encoding.",
"main": "src/sha512.js",
"devDependencies": {
"expect.js": "~0.3.1",
"mocha": "~5.2.0",
"nyc": "^11.3.0",
"requirejs": "^2.1.22",
"uglify-js": "^3.1.9",
"webworker-threads": "^0.7.11"
},
"scripts": {
"test": "nyc mocha tests/node-test.js --exit",
"report": "nyc --reporter=html --reporter=text mocha tests/node-test.js --exit",
"coveralls": "nyc report --reporter=text-lcov | coveralls",
"build": "uglifyjs src/sha512.js -c -m eval --comments -o build/sha512.min.js"
},
"repository": {
"type": "git",
"url": "https://github.com/emn178/js-sha512.git"
},
"keywords": [
"sha",
"sha2",
"sha384",
"sha512",
"sha512/224",
"sha512/256",
"hash",
"encryption",
"cryptography",
"HMAC"
],
"license": "MIT",
"author": "Chen, Yi-Cyuan <emn178@gmail.com>",
"homepage": "https://github.com/emn178/js-sha512",
"bugs": {
"url": "https://github.com/emn178/js-sha512/issues"
},
"nyc": {
"exclude": [
"tests"
]
}
}

927
node_modules/js-sha512/src/sha512.js generated vendored Normal file
View File

@@ -0,0 +1,927 @@
/*
* [js-sha512]{@link https://github.com/emn178/js-sha512}
*
* @version 0.8.0
* @author Chen, Yi-Cyuan [emn178@gmail.com]
* @copyright Chen, Yi-Cyuan 2014-2018
* @license MIT
*/
/*jslint bitwise: true */
(function () {
'use strict';
var INPUT_ERROR = 'input is invalid type';
var FINALIZE_ERROR = 'finalize already called';
var WINDOW = typeof window === 'object';
var root = WINDOW ? window : {};
if (root.JS_SHA512_NO_WINDOW) {
WINDOW = false;
}
var WEB_WORKER = !WINDOW && typeof self === 'object';
var NODE_JS = !root.JS_SHA512_NO_NODE_JS && typeof process === 'object' && process.versions && process.versions.node;
if (NODE_JS) {
root = global;
} else if (WEB_WORKER) {
root = self;
}
var COMMON_JS = !root.JS_SHA512_NO_COMMON_JS && typeof module === 'object' && module.exports;
var AMD = typeof define === 'function' && define.amd;
var ARRAY_BUFFER = !root.JS_SHA512_NO_ARRAY_BUFFER && typeof ArrayBuffer !== 'undefined';
var HEX_CHARS = '0123456789abcdef'.split('');
var EXTRA = [-2147483648, 8388608, 32768, 128];
var SHIFT = [24, 16, 8, 0];
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 OUTPUT_TYPES = ['hex', 'array', 'digest', 'arrayBuffer'];
var blocks = [];
if (root.JS_SHA512_NO_NODE_JS || !Array.isArray) {
Array.isArray = function (obj) {
return Object.prototype.toString.call(obj) === '[object Array]';
};
}
if (ARRAY_BUFFER && (root.JS_SHA512_NO_ARRAY_BUFFER_IS_VIEW || !ArrayBuffer.isView)) {
ArrayBuffer.isView = function (obj) {
return typeof obj === 'object' && obj.buffer && obj.buffer.constructor === ArrayBuffer;
};
}
var createOutputMethod = function (outputType, bits) {
return function (message) {
return new Sha512(bits, true).update(message)[outputType]();
};
};
var createMethod = function (bits) {
var method = createOutputMethod('hex', bits);
method.create = function () {
return new Sha512(bits);
};
method.update = function (message) {
return method.create().update(message);
};
for (var i = 0; i < OUTPUT_TYPES.length; ++i) {
var type = OUTPUT_TYPES[i];
method[type] = createOutputMethod(type, bits);
}
return method;
};
var createHmacOutputMethod = function (outputType, bits) {
return function (key, message) {
return new HmacSha512(key, bits, true).update(message)[outputType]();
};
};
var createHmacMethod = function (bits) {
var method = createHmacOutputMethod('hex', bits);
method.create = function (key) {
return new HmacSha512(key, bits);
};
method.update = function (key, message) {
return method.create(key).update(message);
};
for (var i = 0; i < OUTPUT_TYPES.length; ++i) {
var type = OUTPUT_TYPES[i];
method[type] = createHmacOutputMethod(type, bits);
}
return method;
};
function Sha512(bits, sharedMemory) {
if (sharedMemory) {
blocks[0] = blocks[1] = blocks[2] = blocks[3] = blocks[4] =
blocks[5] = blocks[6] = blocks[7] = blocks[8] =
blocks[9] = blocks[10] = blocks[11] = blocks[12] =
blocks[13] = blocks[14] = blocks[15] = blocks[16] =
blocks[17] = blocks[18] = blocks[19] = blocks[20] =
blocks[21] = blocks[22] = blocks[23] = blocks[24] =
blocks[25] = blocks[26] = blocks[27] = blocks[28] =
blocks[29] = blocks[30] = blocks[31] = blocks[32] = 0;
this.blocks = blocks;
} else {
this.blocks = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0];
}
if (bits == 384) {
this.h0h = 0xCBBB9D5D;
this.h0l = 0xC1059ED8;
this.h1h = 0x629A292A;
this.h1l = 0x367CD507;
this.h2h = 0x9159015A;
this.h2l = 0x3070DD17;
this.h3h = 0x152FECD8;
this.h3l = 0xF70E5939;
this.h4h = 0x67332667;
this.h4l = 0xFFC00B31;
this.h5h = 0x8EB44A87;
this.h5l = 0x68581511;
this.h6h = 0xDB0C2E0D;
this.h6l = 0x64F98FA7;
this.h7h = 0x47B5481D;
this.h7l = 0xBEFA4FA4;
} else if (bits == 256) {
this.h0h = 0x22312194;
this.h0l = 0xFC2BF72C;
this.h1h = 0x9F555FA3;
this.h1l = 0xC84C64C2;
this.h2h = 0x2393B86B;
this.h2l = 0x6F53B151;
this.h3h = 0x96387719;
this.h3l = 0x5940EABD;
this.h4h = 0x96283EE2;
this.h4l = 0xA88EFFE3;
this.h5h = 0xBE5E1E25;
this.h5l = 0x53863992;
this.h6h = 0x2B0199FC;
this.h6l = 0x2C85B8AA;
this.h7h = 0x0EB72DDC;
this.h7l = 0x81C52CA2;
} else if (bits == 224) {
this.h0h = 0x8C3D37C8;
this.h0l = 0x19544DA2;
this.h1h = 0x73E19966;
this.h1l = 0x89DCD4D6;
this.h2h = 0x1DFAB7AE;
this.h2l = 0x32FF9C82;
this.h3h = 0x679DD514;
this.h3l = 0x582F9FCF;
this.h4h = 0x0F6D2B69;
this.h4l = 0x7BD44DA8;
this.h5h = 0x77E36F73;
this.h5l = 0x04C48942;
this.h6h = 0x3F9D85A8;
this.h6l = 0x6A1D36C8;
this.h7h = 0x1112E6AD;
this.h7l = 0x91D692A1;
} else { // 512
this.h0h = 0x6A09E667;
this.h0l = 0xF3BCC908;
this.h1h = 0xBB67AE85;
this.h1l = 0x84CAA73B;
this.h2h = 0x3C6EF372;
this.h2l = 0xFE94F82B;
this.h3h = 0xA54FF53A;
this.h3l = 0x5F1D36F1;
this.h4h = 0x510E527F;
this.h4l = 0xADE682D1;
this.h5h = 0x9B05688C;
this.h5l = 0x2B3E6C1F;
this.h6h = 0x1F83D9AB;
this.h6l = 0xFB41BD6B;
this.h7h = 0x5BE0CD19;
this.h7l = 0x137E2179;
}
this.bits = bits;
this.block = this.start = this.bytes = this.hBytes = 0;
this.finalized = this.hashed = false;
}
Sha512.prototype.update = function (message) {
if (this.finalized) {
throw new Error(FINALIZE_ERROR);
}
var notString, type = typeof message;
if (type !== 'string') {
if (type === 'object') {
if (message === null) {
throw new Error(INPUT_ERROR);
} else if (ARRAY_BUFFER && message.constructor === ArrayBuffer) {
message = new Uint8Array(message);
} else if (!Array.isArray(message)) {
if (!ARRAY_BUFFER || !ArrayBuffer.isView(message)) {
throw new Error(INPUT_ERROR);
}
}
} else {
throw new Error(INPUT_ERROR);
}
notString = true;
}
var code, index = 0, i, length = message.length, blocks = this.blocks;
while (index < length) {
if (this.hashed) {
this.hashed = false;
blocks[0] = this.block;
blocks[1] = blocks[2] = blocks[3] = blocks[4] =
blocks[5] = blocks[6] = blocks[7] = blocks[8] =
blocks[9] = blocks[10] = blocks[11] = blocks[12] =
blocks[13] = blocks[14] = blocks[15] = blocks[16] =
blocks[17] = blocks[18] = blocks[19] = blocks[20] =
blocks[21] = blocks[22] = blocks[23] = blocks[24] =
blocks[25] = blocks[26] = blocks[27] = blocks[28] =
blocks[29] = blocks[30] = blocks[31] = blocks[32] = 0;
}
if(notString) {
for (i = this.start; index < length && i < 128; ++index) {
blocks[i >> 2] |= message[index] << SHIFT[i++ & 3];
}
} else {
for (i = this.start; index < length && i < 128; ++index) {
code = message.charCodeAt(index);
if (code < 0x80) {
blocks[i >> 2] |= code << SHIFT[i++ & 3];
} else if (code < 0x800) {
blocks[i >> 2] |= (0xc0 | (code >> 6)) << SHIFT[i++ & 3];
blocks[i >> 2] |= (0x80 | (code & 0x3f)) << SHIFT[i++ & 3];
} else if (code < 0xd800 || code >= 0xe000) {
blocks[i >> 2] |= (0xe0 | (code >> 12)) << SHIFT[i++ & 3];
blocks[i >> 2] |= (0x80 | ((code >> 6) & 0x3f)) << SHIFT[i++ & 3];
blocks[i >> 2] |= (0x80 | (code & 0x3f)) << SHIFT[i++ & 3];
} else {
code = 0x10000 + (((code & 0x3ff) << 10) | (message.charCodeAt(++index) & 0x3ff));
blocks[i >> 2] |= (0xf0 | (code >> 18)) << SHIFT[i++ & 3];
blocks[i >> 2] |= (0x80 | ((code >> 12) & 0x3f)) << SHIFT[i++ & 3];
blocks[i >> 2] |= (0x80 | ((code >> 6) & 0x3f)) << SHIFT[i++ & 3];
blocks[i >> 2] |= (0x80 | (code & 0x3f)) << SHIFT[i++ & 3];
}
}
}
this.lastByteIndex = i;
this.bytes += i - this.start;
if (i >= 128) {
this.block = blocks[32];
this.start = i - 128;
this.hash();
this.hashed = true;
} else {
this.start = i;
}
}
if (this.bytes > 4294967295) {
this.hBytes += this.bytes / 4294967296 << 0;
this.bytes = this.bytes % 4294967296;
}
return this;
};
Sha512.prototype.finalize = function () {
if (this.finalized) {
return;
}
this.finalized = true;
var blocks = this.blocks, i = this.lastByteIndex;
blocks[32] = this.block;
blocks[i >> 2] |= EXTRA[i & 3];
this.block = blocks[32];
if (i >= 112) {
if (!this.hashed) {
this.hash();
}
blocks[0] = this.block;
blocks[1] = blocks[2] = blocks[3] = blocks[4] =
blocks[5] = blocks[6] = blocks[7] = blocks[8] =
blocks[9] = blocks[10] = blocks[11] = blocks[12] =
blocks[13] = blocks[14] = blocks[15] = blocks[16] =
blocks[17] = blocks[18] = blocks[19] = blocks[20] =
blocks[21] = blocks[22] = blocks[23] = blocks[24] =
blocks[25] = blocks[26] = blocks[27] = blocks[28] =
blocks[29] = blocks[30] = blocks[31] = blocks[32] = 0;
}
blocks[30] = this.hBytes << 3 | this.bytes >>> 29;
blocks[31] = this.bytes << 3;
this.hash();
};
Sha512.prototype.hash = function () {
var h0h = this.h0h, h0l = this.h0l, h1h = this.h1h, h1l = this.h1l,
h2h = this.h2h, h2l = this.h2l, h3h = this.h3h, h3l = this.h3l,
h4h = this.h4h, h4l = this.h4l, h5h = this.h5h, h5l = this.h5l,
h6h = this.h6h, h6l = this.h6l, h7h = this.h7h, h7l = this.h7l,
blocks = this.blocks, j, s0h, s0l, s1h, s1l, c1, c2, c3, c4,
abh, abl, dah, dal, cdh, cdl, bch, bcl,
majh, majl, t1h, t1l, t2h, t2l, chh, chl;
for (j = 32; j < 160; j += 2) {
t1h = blocks[j - 30];
t1l = blocks[j - 29];
s0h = ((t1h >>> 1) | (t1l << 31)) ^ ((t1h >>> 8) | (t1l << 24)) ^ (t1h >>> 7);
s0l = ((t1l >>> 1) | (t1h << 31)) ^ ((t1l >>> 8) | (t1h << 24)) ^ ((t1l >>> 7) | t1h << 25);
t1h = blocks[j - 4];
t1l = blocks[j - 3];
s1h = ((t1h >>> 19) | (t1l << 13)) ^ ((t1l >>> 29) | (t1h << 3)) ^ (t1h >>> 6);
s1l = ((t1l >>> 19) | (t1h << 13)) ^ ((t1h >>> 29) | (t1l << 3)) ^ ((t1l >>> 6) | t1h << 26);
t1h = blocks[j - 32];
t1l = blocks[j - 31];
t2h = blocks[j - 14];
t2l = blocks[j - 13];
c1 = (t2l & 0xFFFF) + (t1l & 0xFFFF) + (s0l & 0xFFFF) + (s1l & 0xFFFF);
c2 = (t2l >>> 16) + (t1l >>> 16) + (s0l >>> 16) + (s1l >>> 16) + (c1 >>> 16);
c3 = (t2h & 0xFFFF) + (t1h & 0xFFFF) + (s0h & 0xFFFF) + (s1h & 0xFFFF) + (c2 >>> 16);
c4 = (t2h >>> 16) + (t1h >>> 16) + (s0h >>> 16) + (s1h >>> 16) + (c3 >>> 16);
blocks[j] = (c4 << 16) | (c3 & 0xFFFF);
blocks[j + 1] = (c2 << 16) | (c1 & 0xFFFF);
}
var ah = h0h, al = h0l, bh = h1h, bl = h1l, ch = h2h, cl = h2l, dh = h3h, dl = h3l, eh = h4h, el = h4l, fh = h5h, fl = h5l, gh = h6h, gl = h6l, hh = h7h, hl = h7l;
bch = bh & ch;
bcl = bl & cl;
for (j = 0; j < 160; j += 8) {
s0h = ((ah >>> 28) | (al << 4)) ^ ((al >>> 2) | (ah << 30)) ^ ((al >>> 7) | (ah << 25));
s0l = ((al >>> 28) | (ah << 4)) ^ ((ah >>> 2) | (al << 30)) ^ ((ah >>> 7) | (al << 25));
s1h = ((eh >>> 14) | (el << 18)) ^ ((eh >>> 18) | (el << 14)) ^ ((el >>> 9) | (eh << 23));
s1l = ((el >>> 14) | (eh << 18)) ^ ((el >>> 18) | (eh << 14)) ^ ((eh >>> 9) | (el << 23));
abh = ah & bh;
abl = al & bl;
majh = abh ^ (ah & ch) ^ bch;
majl = abl ^ (al & cl) ^ bcl;
chh = (eh & fh) ^ (~eh & gh);
chl = (el & fl) ^ (~el & gl);
t1h = blocks[j];
t1l = blocks[j + 1];
t2h = K[j];
t2l = K[j + 1];
c1 = (t2l & 0xFFFF) + (t1l & 0xFFFF) + (chl & 0xFFFF) + (s1l & 0xFFFF) + (hl & 0xFFFF);
c2 = (t2l >>> 16) + (t1l >>> 16) + (chl >>> 16) + (s1l >>> 16) + (hl >>> 16) + (c1 >>> 16);
c3 = (t2h & 0xFFFF) + (t1h & 0xFFFF) + (chh & 0xFFFF) + (s1h & 0xFFFF) + (hh & 0xFFFF) + (c2 >>> 16);
c4 = (t2h >>> 16) + (t1h >>> 16) + (chh >>> 16) + (s1h >>> 16) + (hh >>> 16) + (c3 >>> 16);
t1h = (c4 << 16) | (c3 & 0xFFFF);
t1l = (c2 << 16) | (c1 & 0xFFFF);
c1 = (majl & 0xFFFF) + (s0l & 0xFFFF);
c2 = (majl >>> 16) + (s0l >>> 16) + (c1 >>> 16);
c3 = (majh & 0xFFFF) + (s0h & 0xFFFF) + (c2 >>> 16);
c4 = (majh >>> 16) + (s0h >>> 16) + (c3 >>> 16);
t2h = (c4 << 16) | (c3 & 0xFFFF);
t2l = (c2 << 16) | (c1 & 0xFFFF);
c1 = (dl & 0xFFFF) + (t1l & 0xFFFF);
c2 = (dl >>> 16) + (t1l >>> 16) + (c1 >>> 16);
c3 = (dh & 0xFFFF) + (t1h & 0xFFFF) + (c2 >>> 16);
c4 = (dh >>> 16) + (t1h >>> 16) + (c3 >>> 16);
hh = (c4 << 16) | (c3 & 0xFFFF);
hl = (c2 << 16) | (c1 & 0xFFFF);
c1 = (t2l & 0xFFFF) + (t1l & 0xFFFF);
c2 = (t2l >>> 16) + (t1l >>> 16) + (c1 >>> 16);
c3 = (t2h & 0xFFFF) + (t1h & 0xFFFF) + (c2 >>> 16);
c4 = (t2h >>> 16) + (t1h >>> 16) + (c3 >>> 16);
dh = (c4 << 16) | (c3 & 0xFFFF);
dl = (c2 << 16) | (c1 & 0xFFFF);
s0h = ((dh >>> 28) | (dl << 4)) ^ ((dl >>> 2) | (dh << 30)) ^ ((dl >>> 7) | (dh << 25));
s0l = ((dl >>> 28) | (dh << 4)) ^ ((dh >>> 2) | (dl << 30)) ^ ((dh >>> 7) | (dl << 25));
s1h = ((hh >>> 14) | (hl << 18)) ^ ((hh >>> 18) | (hl << 14)) ^ ((hl >>> 9) | (hh << 23));
s1l = ((hl >>> 14) | (hh << 18)) ^ ((hl >>> 18) | (hh << 14)) ^ ((hh >>> 9) | (hl << 23));
dah = dh & ah;
dal = dl & al;
majh = dah ^ (dh & bh) ^ abh;
majl = dal ^ (dl & bl) ^ abl;
chh = (hh & eh) ^ (~hh & fh);
chl = (hl & el) ^ (~hl & fl);
t1h = blocks[j + 2];
t1l = blocks[j + 3];
t2h = K[j + 2];
t2l = K[j + 3];
c1 = (t2l & 0xFFFF) + (t1l & 0xFFFF) + (chl & 0xFFFF) + (s1l & 0xFFFF) + (gl & 0xFFFF);
c2 = (t2l >>> 16) + (t1l >>> 16) + (chl >>> 16) + (s1l >>> 16) + (gl >>> 16) + (c1 >>> 16);
c3 = (t2h & 0xFFFF) + (t1h & 0xFFFF) + (chh & 0xFFFF) + (s1h & 0xFFFF) + (gh & 0xFFFF) + (c2 >>> 16);
c4 = (t2h >>> 16) + (t1h >>> 16) + (chh >>> 16) + (s1h >>> 16) + (gh >>> 16) + (c3 >>> 16);
t1h = (c4 << 16) | (c3 & 0xFFFF);
t1l = (c2 << 16) | (c1 & 0xFFFF);
c1 = (majl & 0xFFFF) + (s0l & 0xFFFF);
c2 = (majl >>> 16) + (s0l >>> 16) + (c1 >>> 16);
c3 = (majh & 0xFFFF) + (s0h & 0xFFFF) + (c2 >>> 16);
c4 = (majh >>> 16) + (s0h >>> 16) + (c3 >>> 16);
t2h = (c4 << 16) | (c3 & 0xFFFF);
t2l = (c2 << 16) | (c1 & 0xFFFF);
c1 = (cl & 0xFFFF) + (t1l & 0xFFFF);
c2 = (cl >>> 16) + (t1l >>> 16) + (c1 >>> 16);
c3 = (ch & 0xFFFF) + (t1h & 0xFFFF) + (c2 >>> 16);
c4 = (ch >>> 16) + (t1h >>> 16) + (c3 >>> 16);
gh = (c4 << 16) | (c3 & 0xFFFF);
gl = (c2 << 16) | (c1 & 0xFFFF);
c1 = (t2l & 0xFFFF) + (t1l & 0xFFFF);
c2 = (t2l >>> 16) + (t1l >>> 16) + (c1 >>> 16);
c3 = (t2h & 0xFFFF) + (t1h & 0xFFFF) + (c2 >>> 16);
c4 = (t2h >>> 16) + (t1h >>> 16) + (c3 >>> 16);
ch = (c4 << 16) | (c3 & 0xFFFF);
cl = (c2 << 16) | (c1 & 0xFFFF);
s0h = ((ch >>> 28) | (cl << 4)) ^ ((cl >>> 2) | (ch << 30)) ^ ((cl >>> 7) | (ch << 25));
s0l = ((cl >>> 28) | (ch << 4)) ^ ((ch >>> 2) | (cl << 30)) ^ ((ch >>> 7) | (cl << 25));
s1h = ((gh >>> 14) | (gl << 18)) ^ ((gh >>> 18) | (gl << 14)) ^ ((gl >>> 9) | (gh << 23));
s1l = ((gl >>> 14) | (gh << 18)) ^ ((gl >>> 18) | (gh << 14)) ^ ((gh >>> 9) | (gl << 23));
cdh = ch & dh;
cdl = cl & dl;
majh = cdh ^ (ch & ah) ^ dah;
majl = cdl ^ (cl & al) ^ dal;
chh = (gh & hh) ^ (~gh & eh);
chl = (gl & hl) ^ (~gl & el);
t1h = blocks[j + 4];
t1l = blocks[j + 5];
t2h = K[j + 4];
t2l = K[j + 5];
c1 = (t2l & 0xFFFF) + (t1l & 0xFFFF) + (chl & 0xFFFF) + (s1l & 0xFFFF) + (fl & 0xFFFF);
c2 = (t2l >>> 16) + (t1l >>> 16) + (chl >>> 16) + (s1l >>> 16) + (fl >>> 16) + (c1 >>> 16);
c3 = (t2h & 0xFFFF) + (t1h & 0xFFFF) + (chh & 0xFFFF) + (s1h & 0xFFFF) + (fh & 0xFFFF) + (c2 >>> 16);
c4 = (t2h >>> 16) + (t1h >>> 16) + (chh >>> 16) + (s1h >>> 16) + (fh >>> 16) + (c3 >>> 16);
t1h = (c4 << 16) | (c3 & 0xFFFF);
t1l = (c2 << 16) | (c1 & 0xFFFF);
c1 = (majl & 0xFFFF) + (s0l & 0xFFFF);
c2 = (majl >>> 16) + (s0l >>> 16) + (c1 >>> 16);
c3 = (majh & 0xFFFF) + (s0h & 0xFFFF) + (c2 >>> 16);
c4 = (majh >>> 16) + (s0h >>> 16) + (c3 >>> 16);
t2h = (c4 << 16) | (c3 & 0xFFFF);
t2l = (c2 << 16) | (c1 & 0xFFFF);
c1 = (bl & 0xFFFF) + (t1l & 0xFFFF);
c2 = (bl >>> 16) + (t1l >>> 16) + (c1 >>> 16);
c3 = (bh & 0xFFFF) + (t1h & 0xFFFF) + (c2 >>> 16);
c4 = (bh >>> 16) + (t1h >>> 16) + (c3 >>> 16);
fh = (c4 << 16) | (c3 & 0xFFFF);
fl = (c2 << 16) | (c1 & 0xFFFF);
c1 = (t2l & 0xFFFF) + (t1l & 0xFFFF);
c2 = (t2l >>> 16) + (t1l >>> 16) + (c1 >>> 16);
c3 = (t2h & 0xFFFF) + (t1h & 0xFFFF) + (c2 >>> 16);
c4 = (t2h >>> 16) + (t1h >>> 16) + (c3 >>> 16);
bh = (c4 << 16) | (c3 & 0xFFFF);
bl = (c2 << 16) | (c1 & 0xFFFF);
s0h = ((bh >>> 28) | (bl << 4)) ^ ((bl >>> 2) | (bh << 30)) ^ ((bl >>> 7) | (bh << 25));
s0l = ((bl >>> 28) | (bh << 4)) ^ ((bh >>> 2) | (bl << 30)) ^ ((bh >>> 7) | (bl << 25));
s1h = ((fh >>> 14) | (fl << 18)) ^ ((fh >>> 18) | (fl << 14)) ^ ((fl >>> 9) | (fh << 23));
s1l = ((fl >>> 14) | (fh << 18)) ^ ((fl >>> 18) | (fh << 14)) ^ ((fh >>> 9) | (fl << 23));
bch = bh & ch;
bcl = bl & cl;
majh = bch ^ (bh & dh) ^ cdh;
majl = bcl ^ (bl & dl) ^ cdl;
chh = (fh & gh) ^ (~fh & hh);
chl = (fl & gl) ^ (~fl & hl);
t1h = blocks[j + 6];
t1l = blocks[j + 7];
t2h = K[j + 6];
t2l = K[j + 7];
c1 = (t2l & 0xFFFF) + (t1l & 0xFFFF) + (chl & 0xFFFF) + (s1l & 0xFFFF) + (el & 0xFFFF);
c2 = (t2l >>> 16) + (t1l >>> 16) + (chl >>> 16) + (s1l >>> 16) + (el >>> 16) + (c1 >>> 16);
c3 = (t2h & 0xFFFF) + (t1h & 0xFFFF) + (chh & 0xFFFF) + (s1h & 0xFFFF) + (eh & 0xFFFF) + (c2 >>> 16);
c4 = (t2h >>> 16) + (t1h >>> 16) + (chh >>> 16) + (s1h >>> 16) + (eh >>> 16) + (c3 >>> 16);
t1h = (c4 << 16) | (c3 & 0xFFFF);
t1l = (c2 << 16) | (c1 & 0xFFFF);
c1 = (majl & 0xFFFF) + (s0l & 0xFFFF);
c2 = (majl >>> 16) + (s0l >>> 16) + (c1 >>> 16);
c3 = (majh & 0xFFFF) + (s0h & 0xFFFF) + (c2 >>> 16);
c4 = (majh >>> 16) + (s0h >>> 16) + (c3 >>> 16);
t2h = (c4 << 16) | (c3 & 0xFFFF);
t2l = (c2 << 16) | (c1 & 0xFFFF);
c1 = (al & 0xFFFF) + (t1l & 0xFFFF);
c2 = (al >>> 16) + (t1l >>> 16) + (c1 >>> 16);
c3 = (ah & 0xFFFF) + (t1h & 0xFFFF) + (c2 >>> 16);
c4 = (ah >>> 16) + (t1h >>> 16) + (c3 >>> 16);
eh = (c4 << 16) | (c3 & 0xFFFF);
el = (c2 << 16) | (c1 & 0xFFFF);
c1 = (t2l & 0xFFFF) + (t1l & 0xFFFF);
c2 = (t2l >>> 16) + (t1l >>> 16) + (c1 >>> 16);
c3 = (t2h & 0xFFFF) + (t1h & 0xFFFF) + (c2 >>> 16);
c4 = (t2h >>> 16) + (t1h >>> 16) + (c3 >>> 16);
ah = (c4 << 16) | (c3 & 0xFFFF);
al = (c2 << 16) | (c1 & 0xFFFF);
}
c1 = (h0l & 0xFFFF) + (al & 0xFFFF);
c2 = (h0l >>> 16) + (al >>> 16) + (c1 >>> 16);
c3 = (h0h & 0xFFFF) + (ah & 0xFFFF) + (c2 >>> 16);
c4 = (h0h >>> 16) + (ah >>> 16) + (c3 >>> 16);
this.h0h = (c4 << 16) | (c3 & 0xFFFF);
this.h0l = (c2 << 16) | (c1 & 0xFFFF);
c1 = (h1l & 0xFFFF) + (bl & 0xFFFF);
c2 = (h1l >>> 16) + (bl >>> 16) + (c1 >>> 16);
c3 = (h1h & 0xFFFF) + (bh & 0xFFFF) + (c2 >>> 16);
c4 = (h1h >>> 16) + (bh >>> 16) + (c3 >>> 16);
this.h1h = (c4 << 16) | (c3 & 0xFFFF);
this.h1l = (c2 << 16) | (c1 & 0xFFFF);
c1 = (h2l & 0xFFFF) + (cl & 0xFFFF);
c2 = (h2l >>> 16) + (cl >>> 16) + (c1 >>> 16);
c3 = (h2h & 0xFFFF) + (ch & 0xFFFF) + (c2 >>> 16);
c4 = (h2h >>> 16) + (ch >>> 16) + (c3 >>> 16);
this.h2h = (c4 << 16) | (c3 & 0xFFFF);
this.h2l = (c2 << 16) | (c1 & 0xFFFF);
c1 = (h3l & 0xFFFF) + (dl & 0xFFFF);
c2 = (h3l >>> 16) + (dl >>> 16) + (c1 >>> 16);
c3 = (h3h & 0xFFFF) + (dh & 0xFFFF) + (c2 >>> 16);
c4 = (h3h >>> 16) + (dh >>> 16) + (c3 >>> 16);
this.h3h = (c4 << 16) | (c3 & 0xFFFF);
this.h3l = (c2 << 16) | (c1 & 0xFFFF);
c1 = (h4l & 0xFFFF) + (el & 0xFFFF);
c2 = (h4l >>> 16) + (el >>> 16) + (c1 >>> 16);
c3 = (h4h & 0xFFFF) + (eh & 0xFFFF) + (c2 >>> 16);
c4 = (h4h >>> 16) + (eh >>> 16) + (c3 >>> 16);
this.h4h = (c4 << 16) | (c3 & 0xFFFF);
this.h4l = (c2 << 16) | (c1 & 0xFFFF);
c1 = (h5l & 0xFFFF) + (fl & 0xFFFF);
c2 = (h5l >>> 16) + (fl >>> 16) + (c1 >>> 16);
c3 = (h5h & 0xFFFF) + (fh & 0xFFFF) + (c2 >>> 16);
c4 = (h5h >>> 16) + (fh >>> 16) + (c3 >>> 16);
this.h5h = (c4 << 16) | (c3 & 0xFFFF);
this.h5l = (c2 << 16) | (c1 & 0xFFFF);
c1 = (h6l & 0xFFFF) + (gl & 0xFFFF);
c2 = (h6l >>> 16) + (gl >>> 16) + (c1 >>> 16);
c3 = (h6h & 0xFFFF) + (gh & 0xFFFF) + (c2 >>> 16);
c4 = (h6h >>> 16) + (gh >>> 16) + (c3 >>> 16);
this.h6h = (c4 << 16) | (c3 & 0xFFFF);
this.h6l = (c2 << 16) | (c1 & 0xFFFF);
c1 = (h7l & 0xFFFF) + (hl & 0xFFFF);
c2 = (h7l >>> 16) + (hl >>> 16) + (c1 >>> 16);
c3 = (h7h & 0xFFFF) + (hh & 0xFFFF) + (c2 >>> 16);
c4 = (h7h >>> 16) + (hh >>> 16) + (c3 >>> 16);
this.h7h = (c4 << 16) | (c3 & 0xFFFF);
this.h7l = (c2 << 16) | (c1 & 0xFFFF);
};
Sha512.prototype.hex = function () {
this.finalize();
var h0h = this.h0h, h0l = this.h0l, h1h = this.h1h, h1l = this.h1l,
h2h = this.h2h, h2l = this.h2l, h3h = this.h3h, h3l = this.h3l,
h4h = this.h4h, h4l = this.h4l, h5h = this.h5h, h5l = this.h5l,
h6h = this.h6h, h6l = this.h6l, h7h = this.h7h, h7l = this.h7l,
bits = this.bits;
var hex = HEX_CHARS[(h0h >> 28) & 0x0F] + HEX_CHARS[(h0h >> 24) & 0x0F] +
HEX_CHARS[(h0h >> 20) & 0x0F] + HEX_CHARS[(h0h >> 16) & 0x0F] +
HEX_CHARS[(h0h >> 12) & 0x0F] + HEX_CHARS[(h0h >> 8) & 0x0F] +
HEX_CHARS[(h0h >> 4) & 0x0F] + HEX_CHARS[h0h & 0x0F] +
HEX_CHARS[(h0l >> 28) & 0x0F] + HEX_CHARS[(h0l >> 24) & 0x0F] +
HEX_CHARS[(h0l >> 20) & 0x0F] + HEX_CHARS[(h0l >> 16) & 0x0F] +
HEX_CHARS[(h0l >> 12) & 0x0F] + HEX_CHARS[(h0l >> 8) & 0x0F] +
HEX_CHARS[(h0l >> 4) & 0x0F] + HEX_CHARS[h0l & 0x0F] +
HEX_CHARS[(h1h >> 28) & 0x0F] + HEX_CHARS[(h1h >> 24) & 0x0F] +
HEX_CHARS[(h1h >> 20) & 0x0F] + HEX_CHARS[(h1h >> 16) & 0x0F] +
HEX_CHARS[(h1h >> 12) & 0x0F] + HEX_CHARS[(h1h >> 8) & 0x0F] +
HEX_CHARS[(h1h >> 4) & 0x0F] + HEX_CHARS[h1h & 0x0F] +
HEX_CHARS[(h1l >> 28) & 0x0F] + HEX_CHARS[(h1l >> 24) & 0x0F] +
HEX_CHARS[(h1l >> 20) & 0x0F] + HEX_CHARS[(h1l >> 16) & 0x0F] +
HEX_CHARS[(h1l >> 12) & 0x0F] + HEX_CHARS[(h1l >> 8) & 0x0F] +
HEX_CHARS[(h1l >> 4) & 0x0F] + HEX_CHARS[h1l & 0x0F] +
HEX_CHARS[(h2h >> 28) & 0x0F] + HEX_CHARS[(h2h >> 24) & 0x0F] +
HEX_CHARS[(h2h >> 20) & 0x0F] + HEX_CHARS[(h2h >> 16) & 0x0F] +
HEX_CHARS[(h2h >> 12) & 0x0F] + HEX_CHARS[(h2h >> 8) & 0x0F] +
HEX_CHARS[(h2h >> 4) & 0x0F] + HEX_CHARS[h2h & 0x0F] +
HEX_CHARS[(h2l >> 28) & 0x0F] + HEX_CHARS[(h2l >> 24) & 0x0F] +
HEX_CHARS[(h2l >> 20) & 0x0F] + HEX_CHARS[(h2l >> 16) & 0x0F] +
HEX_CHARS[(h2l >> 12) & 0x0F] + HEX_CHARS[(h2l >> 8) & 0x0F] +
HEX_CHARS[(h2l >> 4) & 0x0F] + HEX_CHARS[h2l & 0x0F] +
HEX_CHARS[(h3h >> 28) & 0x0F] + HEX_CHARS[(h3h >> 24) & 0x0F] +
HEX_CHARS[(h3h >> 20) & 0x0F] + HEX_CHARS[(h3h >> 16) & 0x0F] +
HEX_CHARS[(h3h >> 12) & 0x0F] + HEX_CHARS[(h3h >> 8) & 0x0F] +
HEX_CHARS[(h3h >> 4) & 0x0F] + HEX_CHARS[h3h & 0x0F];
if (bits >= 256) {
hex += HEX_CHARS[(h3l >> 28) & 0x0F] + HEX_CHARS[(h3l >> 24) & 0x0F] +
HEX_CHARS[(h3l >> 20) & 0x0F] + HEX_CHARS[(h3l >> 16) & 0x0F] +
HEX_CHARS[(h3l >> 12) & 0x0F] + HEX_CHARS[(h3l >> 8) & 0x0F] +
HEX_CHARS[(h3l >> 4) & 0x0F] + HEX_CHARS[h3l & 0x0F];
}
if (bits >= 384) {
hex += HEX_CHARS[(h4h >> 28) & 0x0F] + HEX_CHARS[(h4h >> 24) & 0x0F] +
HEX_CHARS[(h4h >> 20) & 0x0F] + HEX_CHARS[(h4h >> 16) & 0x0F] +
HEX_CHARS[(h4h >> 12) & 0x0F] + HEX_CHARS[(h4h >> 8) & 0x0F] +
HEX_CHARS[(h4h >> 4) & 0x0F] + HEX_CHARS[h4h & 0x0F] +
HEX_CHARS[(h4l >> 28) & 0x0F] + HEX_CHARS[(h4l >> 24) & 0x0F] +
HEX_CHARS[(h4l >> 20) & 0x0F] + HEX_CHARS[(h4l >> 16) & 0x0F] +
HEX_CHARS[(h4l >> 12) & 0x0F] + HEX_CHARS[(h4l >> 8) & 0x0F] +
HEX_CHARS[(h4l >> 4) & 0x0F] + HEX_CHARS[h4l & 0x0F] +
HEX_CHARS[(h5h >> 28) & 0x0F] + HEX_CHARS[(h5h >> 24) & 0x0F] +
HEX_CHARS[(h5h >> 20) & 0x0F] + HEX_CHARS[(h5h >> 16) & 0x0F] +
HEX_CHARS[(h5h >> 12) & 0x0F] + HEX_CHARS[(h5h >> 8) & 0x0F] +
HEX_CHARS[(h5h >> 4) & 0x0F] + HEX_CHARS[h5h & 0x0F] +
HEX_CHARS[(h5l >> 28) & 0x0F] + HEX_CHARS[(h5l >> 24) & 0x0F] +
HEX_CHARS[(h5l >> 20) & 0x0F] + HEX_CHARS[(h5l >> 16) & 0x0F] +
HEX_CHARS[(h5l >> 12) & 0x0F] + HEX_CHARS[(h5l >> 8) & 0x0F] +
HEX_CHARS[(h5l >> 4) & 0x0F] + HEX_CHARS[h5l & 0x0F];
}
if (bits == 512) {
hex += HEX_CHARS[(h6h >> 28) & 0x0F] + HEX_CHARS[(h6h >> 24) & 0x0F] +
HEX_CHARS[(h6h >> 20) & 0x0F] + HEX_CHARS[(h6h >> 16) & 0x0F] +
HEX_CHARS[(h6h >> 12) & 0x0F] + HEX_CHARS[(h6h >> 8) & 0x0F] +
HEX_CHARS[(h6h >> 4) & 0x0F] + HEX_CHARS[h6h & 0x0F] +
HEX_CHARS[(h6l >> 28) & 0x0F] + HEX_CHARS[(h6l >> 24) & 0x0F] +
HEX_CHARS[(h6l >> 20) & 0x0F] + HEX_CHARS[(h6l >> 16) & 0x0F] +
HEX_CHARS[(h6l >> 12) & 0x0F] + HEX_CHARS[(h6l >> 8) & 0x0F] +
HEX_CHARS[(h6l >> 4) & 0x0F] + HEX_CHARS[h6l & 0x0F] +
HEX_CHARS[(h7h >> 28) & 0x0F] + HEX_CHARS[(h7h >> 24) & 0x0F] +
HEX_CHARS[(h7h >> 20) & 0x0F] + HEX_CHARS[(h7h >> 16) & 0x0F] +
HEX_CHARS[(h7h >> 12) & 0x0F] + HEX_CHARS[(h7h >> 8) & 0x0F] +
HEX_CHARS[(h7h >> 4) & 0x0F] + HEX_CHARS[h7h & 0x0F] +
HEX_CHARS[(h7l >> 28) & 0x0F] + HEX_CHARS[(h7l >> 24) & 0x0F] +
HEX_CHARS[(h7l >> 20) & 0x0F] + HEX_CHARS[(h7l >> 16) & 0x0F] +
HEX_CHARS[(h7l >> 12) & 0x0F] + HEX_CHARS[(h7l >> 8) & 0x0F] +
HEX_CHARS[(h7l >> 4) & 0x0F] + HEX_CHARS[h7l & 0x0F];
}
return hex;
};
Sha512.prototype.toString = Sha512.prototype.hex;
Sha512.prototype.digest = function () {
this.finalize();
var h0h = this.h0h, h0l = this.h0l, h1h = this.h1h, h1l = this.h1l,
h2h = this.h2h, h2l = this.h2l, h3h = this.h3h, h3l = this.h3l,
h4h = this.h4h, h4l = this.h4l, h5h = this.h5h, h5l = this.h5l,
h6h = this.h6h, h6l = this.h6l, h7h = this.h7h, h7l = this.h7l,
bits = this.bits;
var arr = [
(h0h >> 24) & 0xFF, (h0h >> 16) & 0xFF, (h0h >> 8) & 0xFF, h0h & 0xFF,
(h0l >> 24) & 0xFF, (h0l >> 16) & 0xFF, (h0l >> 8) & 0xFF, h0l & 0xFF,
(h1h >> 24) & 0xFF, (h1h >> 16) & 0xFF, (h1h >> 8) & 0xFF, h1h & 0xFF,
(h1l >> 24) & 0xFF, (h1l >> 16) & 0xFF, (h1l >> 8) & 0xFF, h1l & 0xFF,
(h2h >> 24) & 0xFF, (h2h >> 16) & 0xFF, (h2h >> 8) & 0xFF, h2h & 0xFF,
(h2l >> 24) & 0xFF, (h2l >> 16) & 0xFF, (h2l >> 8) & 0xFF, h2l & 0xFF,
(h3h >> 24) & 0xFF, (h3h >> 16) & 0xFF, (h3h >> 8) & 0xFF, h3h & 0xFF
];
if (bits >= 256) {
arr.push((h3l >> 24) & 0xFF, (h3l >> 16) & 0xFF, (h3l >> 8) & 0xFF, h3l & 0xFF);
}
if (bits >= 384) {
arr.push(
(h4h >> 24) & 0xFF, (h4h >> 16) & 0xFF, (h4h >> 8) & 0xFF, h4h & 0xFF,
(h4l >> 24) & 0xFF, (h4l >> 16) & 0xFF, (h4l >> 8) & 0xFF, h4l & 0xFF,
(h5h >> 24) & 0xFF, (h5h >> 16) & 0xFF, (h5h >> 8) & 0xFF, h5h & 0xFF,
(h5l >> 24) & 0xFF, (h5l >> 16) & 0xFF, (h5l >> 8) & 0xFF, h5l & 0xFF
);
}
if (bits == 512) {
arr.push(
(h6h >> 24) & 0xFF, (h6h >> 16) & 0xFF, (h6h >> 8) & 0xFF, h6h & 0xFF,
(h6l >> 24) & 0xFF, (h6l >> 16) & 0xFF, (h6l >> 8) & 0xFF, h6l & 0xFF,
(h7h >> 24) & 0xFF, (h7h >> 16) & 0xFF, (h7h >> 8) & 0xFF, h7h & 0xFF,
(h7l >> 24) & 0xFF, (h7l >> 16) & 0xFF, (h7l >> 8) & 0xFF, h7l & 0xFF
);
}
return arr;
};
Sha512.prototype.array = Sha512.prototype.digest;
Sha512.prototype.arrayBuffer = function () {
this.finalize();
var bits = this.bits;
var buffer = new ArrayBuffer(bits / 8);
var dataView = new DataView(buffer);
dataView.setUint32(0, this.h0h);
dataView.setUint32(4, this.h0l);
dataView.setUint32(8, this.h1h);
dataView.setUint32(12, this.h1l);
dataView.setUint32(16, this.h2h);
dataView.setUint32(20, this.h2l);
dataView.setUint32(24, this.h3h);
if (bits >= 256) {
dataView.setUint32(28, this.h3l);
}
if (bits >= 384) {
dataView.setUint32(32, this.h4h);
dataView.setUint32(36, this.h4l);
dataView.setUint32(40, this.h5h);
dataView.setUint32(44, this.h5l);
}
if (bits == 512) {
dataView.setUint32(48, this.h6h);
dataView.setUint32(52, this.h6l);
dataView.setUint32(56, this.h7h);
dataView.setUint32(60, this.h7l);
}
return buffer;
};
Sha512.prototype.clone = function () {
var hash = new Sha512(this.bits, false);
this.copyTo(hash);
return hash;
};
Sha512.prototype.copyTo = function (hash) {
var i = 0, attrs = [
'h0h', 'h0l', 'h1h', 'h1l', 'h2h', 'h2l', 'h3h', 'h3l', 'h4h', 'h4l', 'h5h', 'h5l', 'h6h', 'h6l', 'h7h', 'h7l',
'start', 'bytes', 'hBytes', 'finalized', 'hashed', 'lastByteIndex'
];
for (i = 0; i < attrs.length; ++i) {
hash[attrs[i]] = this[attrs[i]];
}
for (i = 0; i < this.blocks.length; ++i) {
hash.blocks[i] = this.blocks[i];
}
};
function HmacSha512(key, bits, sharedMemory) {
var notString, type = typeof key;
if (type !== 'string') {
if (type === 'object') {
if (key === null) {
throw new Error(INPUT_ERROR);
} else if (ARRAY_BUFFER && key.constructor === ArrayBuffer) {
key = new Uint8Array(key);
} else if (!Array.isArray(key)) {
if (!ARRAY_BUFFER || !ArrayBuffer.isView(key)) {
throw new Error(INPUT_ERROR);
}
}
} else {
throw new Error(INPUT_ERROR);
}
notString = true;
}
var length = key.length;
if (!notString) {
var bytes = [], length = key.length, index = 0, code;
for (var i = 0; i < length; ++i) {
code = key.charCodeAt(i);
if (code < 0x80) {
bytes[index++] = code;
} else if (code < 0x800) {
bytes[index++] = (0xc0 | (code >> 6));
bytes[index++] = (0x80 | (code & 0x3f));
} else if (code < 0xd800 || code >= 0xe000) {
bytes[index++] = (0xe0 | (code >> 12));
bytes[index++] = (0x80 | ((code >> 6) & 0x3f));
bytes[index++] = (0x80 | (code & 0x3f));
} else {
code = 0x10000 + (((code & 0x3ff) << 10) | (key.charCodeAt(++i) & 0x3ff));
bytes[index++] = (0xf0 | (code >> 18));
bytes[index++] = (0x80 | ((code >> 12) & 0x3f));
bytes[index++] = (0x80 | ((code >> 6) & 0x3f));
bytes[index++] = (0x80 | (code & 0x3f));
}
}
key = bytes;
}
if (key.length > 128) {
key = (new Sha512(bits, true)).update(key).array();
}
var oKeyPad = [], iKeyPad = [];
for (var i = 0; i < 128; ++i) {
var b = key[i] || 0;
oKeyPad[i] = 0x5c ^ b;
iKeyPad[i] = 0x36 ^ b;
}
Sha512.call(this, bits, sharedMemory);
this.update(iKeyPad);
this.oKeyPad = oKeyPad;
this.inner = true;
this.sharedMemory = sharedMemory;
}
HmacSha512.prototype = new Sha512();
HmacSha512.prototype.finalize = function () {
Sha512.prototype.finalize.call(this);
if (this.inner) {
this.inner = false;
var innerHash = this.array();
Sha512.call(this, this.bits, this.sharedMemory);
this.update(this.oKeyPad);
this.update(innerHash);
Sha512.prototype.finalize.call(this);
}
};
HmacSha512.prototype.clone = function () {
var hash = new HmacSha512([], this.bits, false);
this.copyTo(hash);
hash.inner = this.inner;
for (var i = 0; i < this.oKeyPad.length; ++i) {
hash.oKeyPad[i] = this.oKeyPad[i];
}
return hash;
};
var exports = createMethod(512);
exports.sha512 = exports;
exports.sha384 = createMethod(384);
exports.sha512_256 = createMethod(256);
exports.sha512_224 = createMethod(224);
exports.sha512.hmac = createHmacMethod(512);
exports.sha384.hmac = createHmacMethod(384);
exports.sha512_256.hmac = createHmacMethod(256);
exports.sha512_224.hmac = createHmacMethod(224);
if (COMMON_JS) {
module.exports = exports;
} else {
root.sha512 = exports.sha512;
root.sha384 = exports.sha384;
root.sha512_256 = exports.sha512_256;
root.sha512_224 = exports.sha512_224;
if (AMD) {
define(function () {
return exports;
});
}
}
})();