js-sha3 0.5.7 → 0.8.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +106 -74
- package/LICENSE.txt +1 -1
- package/README.md +52 -36
- package/build/sha3.min.js +8 -8
- package/index.d.ts +225 -0
- package/package.json +45 -39
- package/src/sha3.js +656 -475
- package/.covignore +0 -2
- package/.npmignore +0 -3
- package/.travis.yml +0 -12
- package/bower.json +0 -9
- package/tests/index.html +0 -23
- package/tests/node-test.js +0 -60
- package/tests/test-shake.js +0 -106
- package/tests/test.js +0 -316
package/.covignore
DELETED
package/.npmignore
DELETED
package/.travis.yml
DELETED
package/bower.json
DELETED
package/tests/index.html
DELETED
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
<!doctype html>
|
|
2
|
-
<html lang="en">
|
|
3
|
-
<head>
|
|
4
|
-
<meta charset="UTF-8">
|
|
5
|
-
<title>SHA3</title>
|
|
6
|
-
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/mocha/2.1.0/mocha.min.css">
|
|
7
|
-
<script src="https://cdnjs.cloudflare.com/ajax/libs/mocha/2.1.0/mocha.min.js"></script>
|
|
8
|
-
<script src="https://cdnjs.cloudflare.com/ajax/libs/expect.js/0.2.0/expect.min.js"></script>
|
|
9
|
-
<script src="../src/sha3.js"></script>
|
|
10
|
-
</head>
|
|
11
|
-
<body>
|
|
12
|
-
<div id="mocha"></div>
|
|
13
|
-
<script>
|
|
14
|
-
mocha.setup('bdd');
|
|
15
|
-
</script>
|
|
16
|
-
<script src="test.js"></script>
|
|
17
|
-
<script src="test-shake.js"></script>
|
|
18
|
-
<script>
|
|
19
|
-
mocha.checkLeaks();
|
|
20
|
-
mocha.run();
|
|
21
|
-
</script>
|
|
22
|
-
</body>
|
|
23
|
-
</html>
|
package/tests/node-test.js
DELETED
|
@@ -1,60 +0,0 @@
|
|
|
1
|
-
expect = require('expect.js');
|
|
2
|
-
|
|
3
|
-
// Node.js env
|
|
4
|
-
var sha3 = require('../src/sha3.js');
|
|
5
|
-
keccak_512 = sha3.keccak_512;
|
|
6
|
-
keccak_384 = sha3.keccak_384;
|
|
7
|
-
keccak_256 = sha3.keccak_256;
|
|
8
|
-
keccak_224 = sha3.keccak_224;
|
|
9
|
-
sha3_512 = sha3.sha3_512;
|
|
10
|
-
sha3_384 = sha3.sha3_384;
|
|
11
|
-
sha3_256 = sha3.sha3_256;
|
|
12
|
-
sha3_224 = sha3.sha3_224;
|
|
13
|
-
shake_128 = sha3.shake_128;
|
|
14
|
-
shake_256 = sha3.shake_256;
|
|
15
|
-
require('./test.js');
|
|
16
|
-
require('./test-shake.js');
|
|
17
|
-
|
|
18
|
-
delete require.cache[require.resolve('../src/sha3.js')];
|
|
19
|
-
delete require.cache[require.resolve('./test.js')];
|
|
20
|
-
delete require.cache[require.resolve('./test-shake.js')];
|
|
21
|
-
|
|
22
|
-
// Webpack browser env
|
|
23
|
-
JS_SHA3_NO_NODE_JS = true;
|
|
24
|
-
window = global;
|
|
25
|
-
expect = require('expect.js');
|
|
26
|
-
var sha3 = require('../src/sha3.js');
|
|
27
|
-
keccak_512 = sha3.keccak_512;
|
|
28
|
-
keccak_384 = sha3.keccak_384;
|
|
29
|
-
keccak_256 = sha3.keccak_256;
|
|
30
|
-
keccak_224 = sha3.keccak_224;
|
|
31
|
-
sha3_512 = sha3.sha3_512;
|
|
32
|
-
sha3_384 = sha3.sha3_384;
|
|
33
|
-
sha3_256 = sha3.sha3_256;
|
|
34
|
-
sha3_224 = sha3.sha3_224;
|
|
35
|
-
shake_128 = sha3.shake_128;
|
|
36
|
-
shake_256 = sha3.shake_256;
|
|
37
|
-
require('./test.js');
|
|
38
|
-
require('./test-shake.js');
|
|
39
|
-
|
|
40
|
-
delete require.cache[require.resolve('../src/sha3.js')];
|
|
41
|
-
delete require.cache[require.resolve('./test.js')];
|
|
42
|
-
delete require.cache[require.resolve('./test-shake.js')];
|
|
43
|
-
sha3_512 = null;
|
|
44
|
-
sha3_384 = null;
|
|
45
|
-
sha3_256 = null;
|
|
46
|
-
sha3_224 = null;
|
|
47
|
-
keccak_512 = null;
|
|
48
|
-
keccak_384 = null;
|
|
49
|
-
keccak_256 = null;
|
|
50
|
-
keccak_224 = null;
|
|
51
|
-
shake_128 = null;
|
|
52
|
-
shake_256 = null;
|
|
53
|
-
|
|
54
|
-
// browser env
|
|
55
|
-
JS_SHA3_NO_NODE_JS = true;
|
|
56
|
-
JS_SHA3_NO_COMMON_JS = true;
|
|
57
|
-
window = global;
|
|
58
|
-
require('../src/sha3.js');
|
|
59
|
-
require('./test.js');
|
|
60
|
-
require('./test-shake.js');
|
package/tests/test-shake.js
DELETED
|
@@ -1,106 +0,0 @@
|
|
|
1
|
-
(function (shake_256, shake_128) {
|
|
2
|
-
describe('#shake_128', function () {
|
|
3
|
-
context('with 256 output', function () {
|
|
4
|
-
it('should be equal', function () {
|
|
5
|
-
expect(shake_128('', 256)).to.be('7f9c2ba4e88f827d616045507605853ed73b8093f6efbc88eb1a6eacfa66ef26');
|
|
6
|
-
expect(shake_128('The quick brown fox jumps over the lazy dog', 256)).to.be('f4202e3c5852f9182a0430fd8144f0a74b95e7417ecae17db0f8cfeed0e3e66e');
|
|
7
|
-
expect(shake_128('The quick brown fox jumps over the lazy dof', 256)).to.be('853f4538be0db9621a6cea659a06c1107b1f83f02b13d18297bd39d7411cf10c');
|
|
8
|
-
});
|
|
9
|
-
});
|
|
10
|
-
|
|
11
|
-
context('with 8 output', function () {
|
|
12
|
-
it('should be equal', function () {
|
|
13
|
-
expect(shake_128('', 8)).to.be('7f');
|
|
14
|
-
expect(shake_128('The quick brown fox jumps over the lazy dog', 8)).to.be('f4');
|
|
15
|
-
expect(shake_128('The quick brown fox jumps over the lazy dof', 8)).to.be('85');
|
|
16
|
-
});
|
|
17
|
-
});
|
|
18
|
-
|
|
19
|
-
context('with 1368 output', function () {
|
|
20
|
-
it('should be equal', function () {
|
|
21
|
-
expect(shake_128('AAA', 1368)).to.be('15e0fe495a05b74f9fd3eaa8a898a623488220dcbf9ba2f12d23d278b7cecfa4a5e4b8d0fccb0fdbc9e51cd0b4344a32a83f0ba40a514a7b86a77c854c61b836192849da9214c43c4f8bc09ec7a76af92b2fc56e4952024be65b1a47835e0bc014733b24d0e31197ca648f831caebbfd8a5b237ae6bdc9d6cc803a2c5e57dd9346eecf972bd85450f18a413dc6239982e1eb6e0c6df856385c9597d0320edb40b6fe60a74f07524015ad36');
|
|
22
|
-
expect(shake_128('AAA', 1376)).to.be('15e0fe495a05b74f9fd3eaa8a898a623488220dcbf9ba2f12d23d278b7cecfa4a5e4b8d0fccb0fdbc9e51cd0b4344a32a83f0ba40a514a7b86a77c854c61b836192849da9214c43c4f8bc09ec7a76af92b2fc56e4952024be65b1a47835e0bc014733b24d0e31197ca648f831caebbfd8a5b237ae6bdc9d6cc803a2c5e57dd9346eecf972bd85450f18a413dc6239982e1eb6e0c6df856385c9597d0320edb40b6fe60a74f07524015ad36b6');
|
|
23
|
-
});
|
|
24
|
-
});
|
|
25
|
-
|
|
26
|
-
context('with more output', function () {
|
|
27
|
-
it('should be equal', function () {
|
|
28
|
-
expect(shake_128('', 16)).to.be('7f9c');
|
|
29
|
-
expect(shake_128('', 24)).to.be('7f9c2b');
|
|
30
|
-
expect(shake_128.array('', 16)).to.eql([0x7f, 0x9c]);
|
|
31
|
-
expect(shake_128.array('', 24)).to.eql([0x7f, 0x9c, 0x2b]);
|
|
32
|
-
});
|
|
33
|
-
});
|
|
34
|
-
|
|
35
|
-
context('with 8 output ArrayBuffer', function () {
|
|
36
|
-
it('should be equal', function () {
|
|
37
|
-
expect(shake_128.buffer('', 8).toHexString()).to.be('7f');
|
|
38
|
-
expect(shake_128.buffer('The quick brown fox jumps over the lazy dog', 8).toHexString()).to.be('f4');
|
|
39
|
-
expect(shake_128.buffer('The quick brown fox jumps over the lazy dof', 8).toHexString()).to.be('85');
|
|
40
|
-
});
|
|
41
|
-
});
|
|
42
|
-
|
|
43
|
-
context('#update', function () {
|
|
44
|
-
it('should be equal', function () {
|
|
45
|
-
expect(shake_128.update('', 256).hex()).to.be('7f9c2ba4e88f827d616045507605853ed73b8093f6efbc88eb1a6eacfa66ef26');
|
|
46
|
-
expect(shake_128.update('The quick brown fox ', 256).update('jumps over the lazy dog').hex()).to.be('f4202e3c5852f9182a0430fd8144f0a74b95e7417ecae17db0f8cfeed0e3e66e');
|
|
47
|
-
});
|
|
48
|
-
});
|
|
49
|
-
});
|
|
50
|
-
|
|
51
|
-
describe('#shake_256', function () {
|
|
52
|
-
context('with 512 output', function () {
|
|
53
|
-
it('should be equal', function () {
|
|
54
|
-
expect(shake_256('', 512)).to.be('46b9dd2b0ba88d13233b3feb743eeb243fcd52ea62b81b82b50c27646ed5762fd75dc4ddd8c0f200cb05019d67b592f6fc821c49479ab48640292eacb3b7c4be');
|
|
55
|
-
});
|
|
56
|
-
});
|
|
57
|
-
context('with 8 output', function () {
|
|
58
|
-
it('should be equal', function () {
|
|
59
|
-
expect(shake_256('', 8)).to.be('46');
|
|
60
|
-
});
|
|
61
|
-
});
|
|
62
|
-
|
|
63
|
-
context('with 1112 output', function () {
|
|
64
|
-
it('should be equal', function () {
|
|
65
|
-
expect(shake_256('AAA', 1112)).to.be('419614c8b247ee5e9f4a540f7aaa5ca5b44b119f47ab7f494c05095ae5a61ab6b62c84b8b27888813ce8a4d4dab3ed7617c6bab643aa01bb1b113e6d48c3e1eeb73e96f96ffaf12e0c36b190404982b856087acfcb467535e17152e5c15a4d62a18a15d8fe434b3a7274362b0d46b627df1e011a1d037e161d5b540df7ebadab351fb730904daa9a4f40fd');
|
|
66
|
-
expect(shake_256('AAA', 1120)).to.be('419614c8b247ee5e9f4a540f7aaa5ca5b44b119f47ab7f494c05095ae5a61ab6b62c84b8b27888813ce8a4d4dab3ed7617c6bab643aa01bb1b113e6d48c3e1eeb73e96f96ffaf12e0c36b190404982b856087acfcb467535e17152e5c15a4d62a18a15d8fe434b3a7274362b0d46b627df1e011a1d037e161d5b540df7ebadab351fb730904daa9a4f40fdb5');
|
|
67
|
-
});
|
|
68
|
-
});
|
|
69
|
-
|
|
70
|
-
context('with 4100 output', function () {
|
|
71
|
-
it('should be equal', function () {
|
|
72
|
-
// https://raw.githubusercontent.com/gvanas/KeccakCodePackage/master/TestVectors/ShortMsgKAT_SHAKE256.txt
|
|
73
|
-
// Len = 0, Msg = 00
|
|
74
|
-
expect(shake_256('', 4100)).to.be('46b9dd2b0ba88d13233b3feb743eeb243fcd52ea62b81b82b50c27646ed5762fd75dc4ddd8c0f200cb05019d67b592f6fc821c49479ab48640292eacb3b7c4be141e96616fb13957692cc7edd0b45ae3dc07223c8e92937bef84bc0eab862853349ec75546f58fb7c2775c38462c5010d846c185c15111e595522a6bcd16cf86f3d122109e3b1fdd943b6aec468a2d621a7c06c6a957c62b54dafc3be87567d677231395f6147293b68ceab7a9e0c58d864e8efde4e1b9a46cbe854713672f5caaae314ed9083dab4b099f8e300f01b8650f1f4b1d8fcf3f3cb53fb8e9eb2ea203bdc970f50ae55428a91f7f53ac266b28419c3778a15fd248d339ede785fb7f5a1aaa96d313eacc890936c173cdcd0fab882c45755feb3aed96d477ff96390bf9a66d1368b208e21f7c10d04a3dbd4e360633e5db4b602601c14cea737db3dcf722632cc77851cbdde2aaf0a33a07b373445df490cc8fc1e4160ff118378f11f0477de055a81a9eda57a4a2cfb0c83929d310912f729ec6cfa36c6ac6a75837143045d791cc85eff5b21932f23861bcf23a52b5da67eaf7baae0f5fb1369db78f3ac45f8c4ac5671d85735cdddb09d2b1e34a1fc066ff4a162cb263d6541274ae2fcc865f618abe27c124cd8b074ccd516301b91875824d09958f341ef274bdab0bae316339894304e35877b0c28a9b1fd166c796b9cc258a064a8f57e27f2a');
|
|
75
|
-
|
|
76
|
-
// Len = 2040
|
|
77
|
-
// Msg = 3A3A819C48EFDE2AD914FBF00E18AB6BC4F14513AB27D0C178A188B61431E7F5623CB66B23346775D386B50E982C493ADBBFC54B9A3CD383382336A1A0B2150A15358F336D03AE18F666C7573D55C4FD181C29E6CCFDE63EA35F0ADF5885CFC0A3D84A2B2E4DD24496DB789E663170CEF74798AA1BBCD4574EA0BBA40489D764B2F83AADC66B148B4A0CD95246C127D5871C4F11418690A5DDF01246A0C80A43C70088B6183639DCFDA4125BD113A8F49EE23ED306FAAC576C3FB0C1E256671D817FC2534A52F5B439F72E424DE376F4C565CCA82307DD9EF76DA5B7C4EB7E085172E328807C02D011FFBF33785378D79DC266F6A5BE6BB0E4A92ECEEBAEB1
|
|
78
|
-
expect(shake_256([0x3A,0x3A,0x81,0x9C,0x48,0xEF,0xDE,0x2A,0xD9,0x14,0xFB,0xF0,0x0E,0x18,0xAB,0x6B,0xC4,0xF1,0x45,0x13,0xAB,0x27,0xD0,0xC1,0x78,0xA1,0x88,0xB6,0x14,0x31,0xE7,0xF5,0x62,0x3C,0xB6,0x6B,0x23,0x34,0x67,0x75,0xD3,0x86,0xB5,0x0E,0x98,0x2C,0x49,0x3A,0xDB,0xBF,0xC5,0x4B,0x9A,0x3C,0xD3,0x83,0x38,0x23,0x36,0xA1,0xA0,0xB2,0x15,0x0A,0x15,0x35,0x8F,0x33,0x6D,0x03,0xAE,0x18,0xF6,0x66,0xC7,0x57,0x3D,0x55,0xC4,0xFD,0x18,0x1C,0x29,0xE6,0xCC,0xFD,0xE6,0x3E,0xA3,0x5F,0x0A,0xDF,0x58,0x85,0xCF,0xC0,0xA3,0xD8,0x4A,0x2B,0x2E,0x4D,0xD2,0x44,0x96,0xDB,0x78,0x9E,0x66,0x31,0x70,0xCE,0xF7,0x47,0x98,0xAA,0x1B,0xBC,0xD4,0x57,0x4E,0xA0,0xBB,0xA4,0x04,0x89,0xD7,0x64,0xB2,0xF8,0x3A,0xAD,0xC6,0x6B,0x14,0x8B,0x4A,0x0C,0xD9,0x52,0x46,0xC1,0x27,0xD5,0x87,0x1C,0x4F,0x11,0x41,0x86,0x90,0xA5,0xDD,0xF0,0x12,0x46,0xA0,0xC8,0x0A,0x43,0xC7,0x00,0x88,0xB6,0x18,0x36,0x39,0xDC,0xFD,0xA4,0x12,0x5B,0xD1,0x13,0xA8,0xF4,0x9E,0xE2,0x3E,0xD3,0x06,0xFA,0xAC,0x57,0x6C,0x3F,0xB0,0xC1,0xE2,0x56,0x67,0x1D,0x81,0x7F,0xC2,0x53,0x4A,0x52,0xF5,0xB4,0x39,0xF7,0x2E,0x42,0x4D,0xE3,0x76,0xF4,0xC5,0x65,0xCC,0xA8,0x23,0x07,0xDD,0x9E,0xF7,0x6D,0xA5,0xB7,0xC4,0xEB,0x7E,0x08,0x51,0x72,0xE3,0x28,0x80,0x7C,0x02,0xD0,0x11,0xFF,0xBF,0x33,0x78,0x53,0x78,0xD7,0x9D,0xC2,0x66,0xF6,0xA5,0xBE,0x6B,0xB0,0xE4,0xA9,0x2E,0xCE,0xEB,0xAE,0xB1], 4100)).to.be('8a5199b4a7e133e264a86202720655894d48cff344a928cf8347f48379cef347dfc5bcffab99b27b1f89aa2735e23d30088ffa03b9edb02b9635470ab9f1038985d55f9ca774572dd006470ea65145469609f9fa0831bf1ffd842dc24acade27bd9816e3b5bf2876cb112232a0eb4475f1dff9f5c713d9ffd4ccb89ae5607fe35731df06317949eef646e9591cf3be53add6b7dd2b6096e2b3fb06e662ec8b2d77422daad9463cd155204acdbd38e319613f39f99b6dfb35ca9365160066db19835888c2241ff9a731a4acbb5663727aac34a401247fbaa7499e7d5ee5b69d31025e63d04c35c798bca1262d5673a9cf0930b5ad89bd485599dc184528da4790f088ebd170b635d9581632d2ff90db79665ced430089af13c9f21f6d443a818064f17aec9e9c5457001fa8dc6afbadbe3138f388d89d0e6f22f66671255b210754ed63d81dce75ce8f189b534e6d6b3539aa51e837c42df9df59c71e6171cd4902fe1bdc73fb1775b5c754a1ed4ea7f3105fc543ee0418dad256f3f6118ea77114a16c15355b42877a1db2a7df0e155ae1d8670abcec3450f4e2eec9838f895423ef63d261138baaf5d9f104cb5a957aea06c0b9b8c78b0d441796dc0350ddeabb78a33b6f1f9e68ede3d1805c7b7e2cfd54e0fad62f0d8ca67a775dc4546af9096f2edb221db42843d65327861282dc946a0ba01a11863ab2d1dfd16e3973d4');
|
|
79
|
-
});
|
|
80
|
-
});
|
|
81
|
-
|
|
82
|
-
context('with 4100 output ArrayBuffer', function () {
|
|
83
|
-
it('should be equal', function () {
|
|
84
|
-
// https://raw.githubusercontent.com/gvanas/KeccakCodePackage/master/TestVectors/ShortMsgKAT_SHAKE256.txt
|
|
85
|
-
// Len = 0, Msg = 00
|
|
86
|
-
expect(shake_256.buffer('', 4100).toHexString()).to.be('46b9dd2b0ba88d13233b3feb743eeb243fcd52ea62b81b82b50c27646ed5762fd75dc4ddd8c0f200cb05019d67b592f6fc821c49479ab48640292eacb3b7c4be141e96616fb13957692cc7edd0b45ae3dc07223c8e92937bef84bc0eab862853349ec75546f58fb7c2775c38462c5010d846c185c15111e595522a6bcd16cf86f3d122109e3b1fdd943b6aec468a2d621a7c06c6a957c62b54dafc3be87567d677231395f6147293b68ceab7a9e0c58d864e8efde4e1b9a46cbe854713672f5caaae314ed9083dab4b099f8e300f01b8650f1f4b1d8fcf3f3cb53fb8e9eb2ea203bdc970f50ae55428a91f7f53ac266b28419c3778a15fd248d339ede785fb7f5a1aaa96d313eacc890936c173cdcd0fab882c45755feb3aed96d477ff96390bf9a66d1368b208e21f7c10d04a3dbd4e360633e5db4b602601c14cea737db3dcf722632cc77851cbdde2aaf0a33a07b373445df490cc8fc1e4160ff118378f11f0477de055a81a9eda57a4a2cfb0c83929d310912f729ec6cfa36c6ac6a75837143045d791cc85eff5b21932f23861bcf23a52b5da67eaf7baae0f5fb1369db78f3ac45f8c4ac5671d85735cdddb09d2b1e34a1fc066ff4a162cb263d6541274ae2fcc865f618abe27c124cd8b074ccd516301b91875824d09958f341ef274bdab0bae316339894304e35877b0c28a9b1fd166c796b9cc258a064a8f57e27f2a');
|
|
87
|
-
|
|
88
|
-
// Len = 2040
|
|
89
|
-
// Msg = 3A3A819C48EFDE2AD914FBF00E18AB6BC4F14513AB27D0C178A188B61431E7F5623CB66B23346775D386B50E982C493ADBBFC54B9A3CD383382336A1A0B2150A15358F336D03AE18F666C7573D55C4FD181C29E6CCFDE63EA35F0ADF5885CFC0A3D84A2B2E4DD24496DB789E663170CEF74798AA1BBCD4574EA0BBA40489D764B2F83AADC66B148B4A0CD95246C127D5871C4F11418690A5DDF01246A0C80A43C70088B6183639DCFDA4125BD113A8F49EE23ED306FAAC576C3FB0C1E256671D817FC2534A52F5B439F72E424DE376F4C565CCA82307DD9EF76DA5B7C4EB7E085172E328807C02D011FFBF33785378D79DC266F6A5BE6BB0E4A92ECEEBAEB1
|
|
90
|
-
expect(shake_256.buffer([0x3A,0x3A,0x81,0x9C,0x48,0xEF,0xDE,0x2A,0xD9,0x14,0xFB,0xF0,0x0E,0x18,0xAB,0x6B,0xC4,0xF1,0x45,0x13,0xAB,0x27,0xD0,0xC1,0x78,0xA1,0x88,0xB6,0x14,0x31,0xE7,0xF5,0x62,0x3C,0xB6,0x6B,0x23,0x34,0x67,0x75,0xD3,0x86,0xB5,0x0E,0x98,0x2C,0x49,0x3A,0xDB,0xBF,0xC5,0x4B,0x9A,0x3C,0xD3,0x83,0x38,0x23,0x36,0xA1,0xA0,0xB2,0x15,0x0A,0x15,0x35,0x8F,0x33,0x6D,0x03,0xAE,0x18,0xF6,0x66,0xC7,0x57,0x3D,0x55,0xC4,0xFD,0x18,0x1C,0x29,0xE6,0xCC,0xFD,0xE6,0x3E,0xA3,0x5F,0x0A,0xDF,0x58,0x85,0xCF,0xC0,0xA3,0xD8,0x4A,0x2B,0x2E,0x4D,0xD2,0x44,0x96,0xDB,0x78,0x9E,0x66,0x31,0x70,0xCE,0xF7,0x47,0x98,0xAA,0x1B,0xBC,0xD4,0x57,0x4E,0xA0,0xBB,0xA4,0x04,0x89,0xD7,0x64,0xB2,0xF8,0x3A,0xAD,0xC6,0x6B,0x14,0x8B,0x4A,0x0C,0xD9,0x52,0x46,0xC1,0x27,0xD5,0x87,0x1C,0x4F,0x11,0x41,0x86,0x90,0xA5,0xDD,0xF0,0x12,0x46,0xA0,0xC8,0x0A,0x43,0xC7,0x00,0x88,0xB6,0x18,0x36,0x39,0xDC,0xFD,0xA4,0x12,0x5B,0xD1,0x13,0xA8,0xF4,0x9E,0xE2,0x3E,0xD3,0x06,0xFA,0xAC,0x57,0x6C,0x3F,0xB0,0xC1,0xE2,0x56,0x67,0x1D,0x81,0x7F,0xC2,0x53,0x4A,0x52,0xF5,0xB4,0x39,0xF7,0x2E,0x42,0x4D,0xE3,0x76,0xF4,0xC5,0x65,0xCC,0xA8,0x23,0x07,0xDD,0x9E,0xF7,0x6D,0xA5,0xB7,0xC4,0xEB,0x7E,0x08,0x51,0x72,0xE3,0x28,0x80,0x7C,0x02,0xD0,0x11,0xFF,0xBF,0x33,0x78,0x53,0x78,0xD7,0x9D,0xC2,0x66,0xF6,0xA5,0xBE,0x6B,0xB0,0xE4,0xA9,0x2E,0xCE,0xEB,0xAE,0xB1], 4100).toHexString()).to.be('8a5199b4a7e133e264a86202720655894d48cff344a928cf8347f48379cef347dfc5bcffab99b27b1f89aa2735e23d30088ffa03b9edb02b9635470ab9f1038985d55f9ca774572dd006470ea65145469609f9fa0831bf1ffd842dc24acade27bd9816e3b5bf2876cb112232a0eb4475f1dff9f5c713d9ffd4ccb89ae5607fe35731df06317949eef646e9591cf3be53add6b7dd2b6096e2b3fb06e662ec8b2d77422daad9463cd155204acdbd38e319613f39f99b6dfb35ca9365160066db19835888c2241ff9a731a4acbb5663727aac34a401247fbaa7499e7d5ee5b69d31025e63d04c35c798bca1262d5673a9cf0930b5ad89bd485599dc184528da4790f088ebd170b635d9581632d2ff90db79665ced430089af13c9f21f6d443a818064f17aec9e9c5457001fa8dc6afbadbe3138f388d89d0e6f22f66671255b210754ed63d81dce75ce8f189b534e6d6b3539aa51e837c42df9df59c71e6171cd4902fe1bdc73fb1775b5c754a1ed4ea7f3105fc543ee0418dad256f3f6118ea77114a16c15355b42877a1db2a7df0e155ae1d8670abcec3450f4e2eec9838f895423ef63d261138baaf5d9f104cb5a957aea06c0b9b8c78b0d441796dc0350ddeabb78a33b6f1f9e68ede3d1805c7b7e2cfd54e0fad62f0d8ca67a775dc4546af9096f2edb221db42843d65327861282dc946a0ba01a11863ab2d1dfd16e3973d4');
|
|
91
|
-
});
|
|
92
|
-
});
|
|
93
|
-
|
|
94
|
-
context('with 4100 output Array', function () {
|
|
95
|
-
it('should be equal', function () {
|
|
96
|
-
// https://raw.githubusercontent.com/gvanas/KeccakCodePackage/master/TestVectors/ShortMsgKAT_SHAKE256.txt
|
|
97
|
-
// Len = 0, Msg = 00
|
|
98
|
-
expect(shake_256.array('', 4100).toHexString()).to.be('46b9dd2b0ba88d13233b3feb743eeb243fcd52ea62b81b82b50c27646ed5762fd75dc4ddd8c0f200cb05019d67b592f6fc821c49479ab48640292eacb3b7c4be141e96616fb13957692cc7edd0b45ae3dc07223c8e92937bef84bc0eab862853349ec75546f58fb7c2775c38462c5010d846c185c15111e595522a6bcd16cf86f3d122109e3b1fdd943b6aec468a2d621a7c06c6a957c62b54dafc3be87567d677231395f6147293b68ceab7a9e0c58d864e8efde4e1b9a46cbe854713672f5caaae314ed9083dab4b099f8e300f01b8650f1f4b1d8fcf3f3cb53fb8e9eb2ea203bdc970f50ae55428a91f7f53ac266b28419c3778a15fd248d339ede785fb7f5a1aaa96d313eacc890936c173cdcd0fab882c45755feb3aed96d477ff96390bf9a66d1368b208e21f7c10d04a3dbd4e360633e5db4b602601c14cea737db3dcf722632cc77851cbdde2aaf0a33a07b373445df490cc8fc1e4160ff118378f11f0477de055a81a9eda57a4a2cfb0c83929d310912f729ec6cfa36c6ac6a75837143045d791cc85eff5b21932f23861bcf23a52b5da67eaf7baae0f5fb1369db78f3ac45f8c4ac5671d85735cdddb09d2b1e34a1fc066ff4a162cb263d6541274ae2fcc865f618abe27c124cd8b074ccd516301b91875824d09958f341ef274bdab0bae316339894304e35877b0c28a9b1fd166c796b9cc258a064a8f57e27f2a');
|
|
99
|
-
|
|
100
|
-
// Len = 2040
|
|
101
|
-
// Msg = 3A3A819C48EFDE2AD914FBF00E18AB6BC4F14513AB27D0C178A188B61431E7F5623CB66B23346775D386B50E982C493ADBBFC54B9A3CD383382336A1A0B2150A15358F336D03AE18F666C7573D55C4FD181C29E6CCFDE63EA35F0ADF5885CFC0A3D84A2B2E4DD24496DB789E663170CEF74798AA1BBCD4574EA0BBA40489D764B2F83AADC66B148B4A0CD95246C127D5871C4F11418690A5DDF01246A0C80A43C70088B6183639DCFDA4125BD113A8F49EE23ED306FAAC576C3FB0C1E256671D817FC2534A52F5B439F72E424DE376F4C565CCA82307DD9EF76DA5B7C4EB7E085172E328807C02D011FFBF33785378D79DC266F6A5BE6BB0E4A92ECEEBAEB1
|
|
102
|
-
expect(shake_256.array([0x3A,0x3A,0x81,0x9C,0x48,0xEF,0xDE,0x2A,0xD9,0x14,0xFB,0xF0,0x0E,0x18,0xAB,0x6B,0xC4,0xF1,0x45,0x13,0xAB,0x27,0xD0,0xC1,0x78,0xA1,0x88,0xB6,0x14,0x31,0xE7,0xF5,0x62,0x3C,0xB6,0x6B,0x23,0x34,0x67,0x75,0xD3,0x86,0xB5,0x0E,0x98,0x2C,0x49,0x3A,0xDB,0xBF,0xC5,0x4B,0x9A,0x3C,0xD3,0x83,0x38,0x23,0x36,0xA1,0xA0,0xB2,0x15,0x0A,0x15,0x35,0x8F,0x33,0x6D,0x03,0xAE,0x18,0xF6,0x66,0xC7,0x57,0x3D,0x55,0xC4,0xFD,0x18,0x1C,0x29,0xE6,0xCC,0xFD,0xE6,0x3E,0xA3,0x5F,0x0A,0xDF,0x58,0x85,0xCF,0xC0,0xA3,0xD8,0x4A,0x2B,0x2E,0x4D,0xD2,0x44,0x96,0xDB,0x78,0x9E,0x66,0x31,0x70,0xCE,0xF7,0x47,0x98,0xAA,0x1B,0xBC,0xD4,0x57,0x4E,0xA0,0xBB,0xA4,0x04,0x89,0xD7,0x64,0xB2,0xF8,0x3A,0xAD,0xC6,0x6B,0x14,0x8B,0x4A,0x0C,0xD9,0x52,0x46,0xC1,0x27,0xD5,0x87,0x1C,0x4F,0x11,0x41,0x86,0x90,0xA5,0xDD,0xF0,0x12,0x46,0xA0,0xC8,0x0A,0x43,0xC7,0x00,0x88,0xB6,0x18,0x36,0x39,0xDC,0xFD,0xA4,0x12,0x5B,0xD1,0x13,0xA8,0xF4,0x9E,0xE2,0x3E,0xD3,0x06,0xFA,0xAC,0x57,0x6C,0x3F,0xB0,0xC1,0xE2,0x56,0x67,0x1D,0x81,0x7F,0xC2,0x53,0x4A,0x52,0xF5,0xB4,0x39,0xF7,0x2E,0x42,0x4D,0xE3,0x76,0xF4,0xC5,0x65,0xCC,0xA8,0x23,0x07,0xDD,0x9E,0xF7,0x6D,0xA5,0xB7,0xC4,0xEB,0x7E,0x08,0x51,0x72,0xE3,0x28,0x80,0x7C,0x02,0xD0,0x11,0xFF,0xBF,0x33,0x78,0x53,0x78,0xD7,0x9D,0xC2,0x66,0xF6,0xA5,0xBE,0x6B,0xB0,0xE4,0xA9,0x2E,0xCE,0xEB,0xAE,0xB1], 4100).toHexString()).to.be('8a5199b4a7e133e264a86202720655894d48cff344a928cf8347f48379cef347dfc5bcffab99b27b1f89aa2735e23d30088ffa03b9edb02b9635470ab9f1038985d55f9ca774572dd006470ea65145469609f9fa0831bf1ffd842dc24acade27bd9816e3b5bf2876cb112232a0eb4475f1dff9f5c713d9ffd4ccb89ae5607fe35731df06317949eef646e9591cf3be53add6b7dd2b6096e2b3fb06e662ec8b2d77422daad9463cd155204acdbd38e319613f39f99b6dfb35ca9365160066db19835888c2241ff9a731a4acbb5663727aac34a401247fbaa7499e7d5ee5b69d31025e63d04c35c798bca1262d5673a9cf0930b5ad89bd485599dc184528da4790f088ebd170b635d9581632d2ff90db79665ced430089af13c9f21f6d443a818064f17aec9e9c5457001fa8dc6afbadbe3138f388d89d0e6f22f66671255b210754ed63d81dce75ce8f189b534e6d6b3539aa51e837c42df9df59c71e6171cd4902fe1bdc73fb1775b5c754a1ed4ea7f3105fc543ee0418dad256f3f6118ea77114a16c15355b42877a1db2a7df0e155ae1d8670abcec3450f4e2eec9838f895423ef63d261138baaf5d9f104cb5a957aea06c0b9b8c78b0d441796dc0350ddeabb78a33b6f1f9e68ede3d1805c7b7e2cfd54e0fad62f0d8ca67a775dc4546af9096f2edb221db42843d65327861282dc946a0ba01a11863ab2d1dfd16e3973d4');
|
|
103
|
-
});
|
|
104
|
-
});
|
|
105
|
-
});
|
|
106
|
-
})(shake_256, shake_128);
|
package/tests/test.js
DELETED
|
@@ -1,316 +0,0 @@
|
|
|
1
|
-
(function (sha3_512, sha3_384, sha3_256, sha3_224, keccak_512, keccak_384, keccak_256, keccak_224) {
|
|
2
|
-
Array.prototype.toHexString = ArrayBuffer.prototype.toHexString = function () {
|
|
3
|
-
var array = new Uint8Array(this);
|
|
4
|
-
var hex = '';
|
|
5
|
-
for (var i = 0; i < array.length; ++i) {
|
|
6
|
-
var c = array[i].toString('16');
|
|
7
|
-
hex += c.length == 1 ? '0' + c : c;
|
|
8
|
-
}
|
|
9
|
-
return hex;
|
|
10
|
-
};
|
|
11
|
-
|
|
12
|
-
function runTestCases(methods, testCases) {
|
|
13
|
-
methods.forEach(function (method) {
|
|
14
|
-
describe('#' + method.name, function () {
|
|
15
|
-
var methodTestCases = testCases[method.name];
|
|
16
|
-
for (var testCaseName in methodTestCases) {
|
|
17
|
-
(function (testCaseName) {
|
|
18
|
-
var testCase = methodTestCases[testCaseName];
|
|
19
|
-
context('when ' + testCaseName, function () {
|
|
20
|
-
for (var hash in testCase) {
|
|
21
|
-
(function (message, hash) {
|
|
22
|
-
it('should be equal', function () {
|
|
23
|
-
expect(method.call(message)).to.be(hash);
|
|
24
|
-
});
|
|
25
|
-
})(testCase[hash], hash);
|
|
26
|
-
}
|
|
27
|
-
});
|
|
28
|
-
})(testCaseName);
|
|
29
|
-
}
|
|
30
|
-
});
|
|
31
|
-
});
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
var methods = [
|
|
35
|
-
{
|
|
36
|
-
name: 'sha3_512',
|
|
37
|
-
call: sha3_512
|
|
38
|
-
},
|
|
39
|
-
{
|
|
40
|
-
name: 'sha3_384',
|
|
41
|
-
call: sha3_384
|
|
42
|
-
},
|
|
43
|
-
{
|
|
44
|
-
name: 'sha3_256',
|
|
45
|
-
call: sha3_256
|
|
46
|
-
},
|
|
47
|
-
{
|
|
48
|
-
name: 'sha3_224',
|
|
49
|
-
call: sha3_224
|
|
50
|
-
},
|
|
51
|
-
{
|
|
52
|
-
name: 'keccak_512',
|
|
53
|
-
call: keccak_512
|
|
54
|
-
},
|
|
55
|
-
{
|
|
56
|
-
name: 'keccak_384',
|
|
57
|
-
call: keccak_384
|
|
58
|
-
},
|
|
59
|
-
{
|
|
60
|
-
name: 'keccak_256',
|
|
61
|
-
call: keccak_256
|
|
62
|
-
},
|
|
63
|
-
{
|
|
64
|
-
name: 'keccak_224',
|
|
65
|
-
call: keccak_224
|
|
66
|
-
}
|
|
67
|
-
];
|
|
68
|
-
|
|
69
|
-
var testCases = {
|
|
70
|
-
sha3_512: {
|
|
71
|
-
'ascii': {
|
|
72
|
-
'a69f73cca23a9ac5c8b567dc185a756e97c982164fe25859e0d1dcc1475c80a615b2123af1f5f94c11e3e9402c3ac558f500199d95b6d3e301758586281dcd26': '',
|
|
73
|
-
'01dedd5de4ef14642445ba5f5b97c15e47b9ad931326e4b0727cd94cefc44fff23f07bf543139939b49128caf436dc1bdee54fcb24023a08d9403f9b4bf0d450': 'The quick brown fox jumps over the lazy dog',
|
|
74
|
-
'18f4f4bd419603f95538837003d9d254c26c23765565162247483f65c50303597bc9ce4d289f21d1c2f1f458828e33dc442100331b35e7eb031b5d38ba6460f8': 'The quick brown fox jumps over the lazy dog.'
|
|
75
|
-
},
|
|
76
|
-
'ascii more than 128 bytes': {
|
|
77
|
-
'4f8bcf3a60d3ee56a0bd405c3e6bb37dac44b6781c41bf76c91a5d8e621d472b7b13b8806d88914af3d97585df996363ebe17566d5dfeb6f4884a7949ba8263d': 'The MD5 message-digest algorithm is a widely used cryptographic hash function producing a 128-bit (16-byte) hash value, typically expressed in text format as a 32 digit hexadecimal number. MD5 has been utilized in a wide variety of cryptographic applications, and is also commonly used to verify data integrity.'
|
|
78
|
-
},
|
|
79
|
-
'UTF-8': {
|
|
80
|
-
'059bbe2efc50cc30e4d8ec5a96be697e2108fcbf9193e1296192eddabc13b143c0120d059399a13d0d42651efe23a6c1ce2d1efb576c5b207fa2516050505af7': '中文',
|
|
81
|
-
'35dfaf82d2ce4be79393dc90e327b4dd15b1c150d8a30f59d8d1b42ca4fc3c87f50b77da36acccf9dc76494d07fc57cfcc9470e627c38f95bce4deab311b87e0': 'aécio',
|
|
82
|
-
'33ef254289f36527c93cd203ef1973aec1eff7475c23fa842c3092b0d30965d13b0805c61d0aa92c51245c56bfe26978c35c00f26eb558a043982043ee8b178c': '𠜎'
|
|
83
|
-
},
|
|
84
|
-
'UTF-8 more than 128 bytes': {
|
|
85
|
-
'accb127bb24b0ffbb7550dc637222d2f78538a8a186c98bc5efdad685b9b396639f34148bf0b94ed470f0e9c3665dc3b4c1cb321bacd32dd317a646295e073d9': '訊息摘要演算法第五版(英語:Message-Digest Algorithm 5,縮寫為MD5),是當前電腦領域用於確保資訊傳輸完整一致而廣泛使用的雜湊演算法之一',
|
|
86
|
-
'5b70eaad083f1b86fd535b6812e02f5f2876a4bd8b43aede8d62ae71bb1743ebd919dc41be56d73ba45b67b2876ff215d0575788560e7b0c92b879f8a2fc3111': '訊息摘要演算法第五版(英語:Message-Digest Algorithm 5,縮寫為MD5),是當前電腦領域用於確保資訊傳輸完整一致而廣泛使用的雜湊演算法之一(又譯雜湊演算法、摘要演算法等),主流程式語言普遍已有MD5的實作。'
|
|
87
|
-
},
|
|
88
|
-
'special length': {
|
|
89
|
-
'bce9da5b408846edd5bec9f26c2dee9bd835215c3f2b3876197067d87bc4d1af0cd97f94fda59761a0d804fe82383be2c6c4886fbb82e005fcf899449029f221' :'012345678901234567890123456789012345678901234567890123456789012345678901',
|
|
90
|
-
'8bdcb85e6b52c29fafac0d3daf65492f2e3499e066da1a095a65eb1144849a26b2790a8b39c2a7fb747456f749391d953841a61cb13289f9806f04981c180a86' :'01234567890123456789012345678901234567890123456789012345678901234567890'
|
|
91
|
-
},
|
|
92
|
-
'Array': {
|
|
93
|
-
'a69f73cca23a9ac5c8b567dc185a756e97c982164fe25859e0d1dcc1475c80a615b2123af1f5f94c11e3e9402c3ac558f500199d95b6d3e301758586281dcd26': [],
|
|
94
|
-
'01dedd5de4ef14642445ba5f5b97c15e47b9ad931326e4b0727cd94cefc44fff23f07bf543139939b49128caf436dc1bdee54fcb24023a08d9403f9b4bf0d450': [84, 104, 101, 32, 113, 117, 105, 99, 107, 32, 98, 114, 111, 119, 110, 32, 102, 111, 120, 32, 106, 117, 109, 112, 115, 32, 111, 118, 101, 114, 32, 116, 104, 101, 32, 108, 97, 122, 121, 32, 100, 111, 103]
|
|
95
|
-
},
|
|
96
|
-
'Uint8Array': {
|
|
97
|
-
'a69f73cca23a9ac5c8b567dc185a756e97c982164fe25859e0d1dcc1475c80a615b2123af1f5f94c11e3e9402c3ac558f500199d95b6d3e301758586281dcd26': new Uint8Array([]),
|
|
98
|
-
'01dedd5de4ef14642445ba5f5b97c15e47b9ad931326e4b0727cd94cefc44fff23f07bf543139939b49128caf436dc1bdee54fcb24023a08d9403f9b4bf0d450': new Uint8Array([84, 104, 101, 32, 113, 117, 105, 99, 107, 32, 98, 114, 111, 119, 110, 32, 102, 111, 120, 32, 106, 117, 109, 112, 115, 32, 111, 118, 101, 114, 32, 116, 104, 101, 32, 108, 97, 122, 121, 32, 100, 111, 103])
|
|
99
|
-
},
|
|
100
|
-
'ArrayBuffer': {
|
|
101
|
-
'a69f73cca23a9ac5c8b567dc185a756e97c982164fe25859e0d1dcc1475c80a615b2123af1f5f94c11e3e9402c3ac558f500199d95b6d3e301758586281dcd26': new ArrayBuffer(0),
|
|
102
|
-
'01dedd5de4ef14642445ba5f5b97c15e47b9ad931326e4b0727cd94cefc44fff23f07bf543139939b49128caf436dc1bdee54fcb24023a08d9403f9b4bf0d450': new Uint8Array([84, 104, 101, 32, 113, 117, 105, 99, 107, 32, 98, 114, 111, 119, 110, 32, 102, 111, 120, 32, 106, 117, 109, 112, 115, 32, 111, 118, 101, 114, 32, 116, 104, 101, 32, 108, 97, 122, 121, 32, 100, 111, 103]).buffer
|
|
103
|
-
}
|
|
104
|
-
},
|
|
105
|
-
sha3_384: {
|
|
106
|
-
'ascii': {
|
|
107
|
-
'0c63a75b845e4f7d01107d852e4c2485c51a50aaaa94fc61995e71bbee983a2ac3713831264adb47fb6bd1e058d5f004': '',
|
|
108
|
-
'7063465e08a93bce31cd89d2e3ca8f602498696e253592ed26f07bf7e703cf328581e1471a7ba7ab119b1a9ebdf8be41': 'The quick brown fox jumps over the lazy dog',
|
|
109
|
-
'1a34d81695b622df178bc74df7124fe12fac0f64ba5250b78b99c1273d4b080168e10652894ecad5f1f4d5b965437fb9': 'The quick brown fox jumps over the lazy dog.'
|
|
110
|
-
},
|
|
111
|
-
'ascii more than 128 bytes': {
|
|
112
|
-
'ca6b121a6060bc85de05e5a8d70577838fad2481b092c8263d6f7bcbe5148740f0c7f9c4dc27061339570496956aaef6': 'The MD5 message-digest algorithm is a widely used cryptographic hash function producing a 128-bit (16-byte) hash value, typically expressed in text format as a 32 digit hexadecimal number. MD5 has been utilized in a wide variety of cryptographic applications, and is also commonly used to verify data integrity.'
|
|
113
|
-
},
|
|
114
|
-
'UTF-8': {
|
|
115
|
-
'9fb5b99e3c546f2738dcd50a14e9aef9c313800c1bf8cf76bc9b2c3a23307841364c5a2d0794702662c5796fb72f5432': '中文',
|
|
116
|
-
'70b447f1bd5ce5a4753ccf7a3697eca0315954774374bc1042aff19582ccc32d5067f7da6c2bea9d6d344e11924cbe72': 'aécio',
|
|
117
|
-
'7add8d544b0a7cf188b54b1697a046f77e49d5f292e7ffe56feeed90a500b0bf026b9b68892888a1bafb9f8cb89ed874': '𠜎'
|
|
118
|
-
},
|
|
119
|
-
'UTF-8 more than 128 bytes': {
|
|
120
|
-
'7d0f80fe5c79a04a2a37a30a440e0cc068eb78fe6c3182246ede29645c144b5d33c44607cb2c3111ba77ffc66107f1cd': '訊息摘要演算法第五版(英語:Message-Digest Algorithm 5,縮寫為MD5),是當前電腦領域用於確保資訊傳輸完整一致而廣泛使用的雜湊演算法之一',
|
|
121
|
-
'e344b95c6a961a27793eff00fa5103ef78b4180fe41c93fc60a31aff49b3b5e95a92c84fda9a6c80fa403b7df58db59f': '訊息摘要演算法第五版(英語:Message-Digest Algorithm 5,縮寫為MD5),是當前電腦領域用於確保資訊傳輸完整一致而廣泛使用的雜湊演算法之一(又譯雜湊演算法、摘要演算法等),主流程式語言普遍已有MD5的實作。'
|
|
122
|
-
}
|
|
123
|
-
},
|
|
124
|
-
sha3_256: {
|
|
125
|
-
'ascii': {
|
|
126
|
-
'a7ffc6f8bf1ed76651c14756a061d662f580ff4de43b49fa82d80a4b80f8434a': '',
|
|
127
|
-
'69070dda01975c8c120c3aada1b282394e7f032fa9cf32f4cb2259a0897dfc04': 'The quick brown fox jumps over the lazy dog',
|
|
128
|
-
'a80f839cd4f83f6c3dafc87feae470045e4eb0d366397d5c6ce34ba1739f734d': 'The quick brown fox jumps over the lazy dog.'
|
|
129
|
-
},
|
|
130
|
-
'ascii more than 128 bytes': {
|
|
131
|
-
'fa198893674a0bf9fb35980504e8cefb250aabd2311a37e5d2205f07fb023d36': 'The MD5 message-digest algorithm is a widely used cryptographic hash function producing a 128-bit (16-byte) hash value, typically expressed in text format as a 32 digit hexadecimal number. MD5 has been utilized in a wide variety of cryptographic applications, and is also commonly used to verify data integrity.'
|
|
132
|
-
},
|
|
133
|
-
'UTF-8': {
|
|
134
|
-
'ac5305da3d18be1aed44aa7c70ea548da243a59a5fd546f489348fd5718fb1a0': '中文',
|
|
135
|
-
'65c756408eb6c35a1ffa2d7e09711bdc9f0b28716b1376223844a2b4c52b6718': 'aécio',
|
|
136
|
-
'babe9afc555b0311700dfb0b5b6296d49347b3d770480baedfcdc47a4aea6e82': '𠜎'
|
|
137
|
-
},
|
|
138
|
-
'UTF-8 more than 128 bytes': {
|
|
139
|
-
'4b2f36e4320b86e6ead0ad001e47e6d9e7fcf0044cd5a5fd65490a633c0372a4': '訊息摘要演算法第五版(英語:Message-Digest Algorithm 5,縮寫為MD5),是當前電腦領域用於確保資訊傳輸完整一致而廣泛使用的雜湊演算法之一',
|
|
140
|
-
'558a7f843b1ac5e7a8bbef90357876bcce0612992d0dfa2907e95521612f507f': '訊息摘要演算法第五版(英語:Message-Digest Algorithm 5,縮寫為MD5),是當前電腦領域用於確保資訊傳輸完整一致而廣泛使用的雜湊演算法之一(又譯雜湊演算法、摘要演算法等),主流程式語言普遍已有MD5的實作。'
|
|
141
|
-
}
|
|
142
|
-
},
|
|
143
|
-
sha3_224: {
|
|
144
|
-
'ascii': {
|
|
145
|
-
'6b4e03423667dbb73b6e15454f0eb1abd4597f9a1b078e3f5b5a6bc7': '',
|
|
146
|
-
'd15dadceaa4d5d7bb3b48f446421d542e08ad8887305e28d58335795': 'The quick brown fox jumps over the lazy dog',
|
|
147
|
-
'2d0708903833afabdd232a20201176e8b58c5be8a6fe74265ac54db0': 'The quick brown fox jumps over the lazy dog.'
|
|
148
|
-
},
|
|
149
|
-
'ascii more than 128 bytes': {
|
|
150
|
-
'06885009a28e43e15bf1af718561ad211515a27b542eabc36764a0ca': 'The MD5 message-digest algorithm is a widely used cryptographic hash function producing a 128-bit (16-byte) hash value, typically expressed in text format as a 32 digit hexadecimal number. MD5 has been utilized in a wide variety of cryptographic applications, and is also commonly used to verify data integrity.'
|
|
151
|
-
},
|
|
152
|
-
'UTF-8': {
|
|
153
|
-
'106d169e10b61c2a2a05554d3e631ec94467f8316640f29545d163ee': '中文',
|
|
154
|
-
'b16bad54608dc01864a5d7510d4c19b09f3a0f39cfc4ba1e53aa952a': 'aécio',
|
|
155
|
-
'f59253c41cb87e5cd953311656716cb5b64dbafc9e8155f0dd68123c': '𠜎'
|
|
156
|
-
},
|
|
157
|
-
'UTF-8 more than 128 bytes': {
|
|
158
|
-
'135c13deb71fdf6fb77b52b720c43ddd6ce7467f9147a74248557114': '訊息摘要演算法第五版(英語:Message-Digest Algorithm 5,縮寫為MD5),是當前電腦領域用於確保資訊傳輸完整一致而廣泛使用的雜湊演算法之一',
|
|
159
|
-
'bd05581e02445c53e05aad2014f6a3819d77a9dff918b8c6bf60bd06': '訊息摘要演算法第五版(英語:Message-Digest Algorithm 5,縮寫為MD5),是當前電腦領域用於確保資訊傳輸完整一致而廣泛使用的雜湊演算法之一(又譯雜湊演算法、摘要演算法等),主流程式語言普遍已有MD5的實作。'
|
|
160
|
-
}
|
|
161
|
-
},
|
|
162
|
-
keccak_512: {
|
|
163
|
-
'ascii': {
|
|
164
|
-
'0eab42de4c3ceb9235fc91acffe746b29c29a8c366b7c60e4e67c466f36a4304c00fa9caf9d87976ba469bcbe06713b435f091ef2769fb160cdab33d3670680e': '',
|
|
165
|
-
'd135bb84d0439dbac432247ee573a23ea7d3c9deb2a968eb31d47c4fb45f1ef4422d6c531b5b9bd6f449ebcc449ea94d0a8f05f62130fda612da53c79659f609': 'The quick brown fox jumps over the lazy dog',
|
|
166
|
-
'ab7192d2b11f51c7dd744e7b3441febf397ca07bf812cceae122ca4ded6387889064f8db9230f173f6d1ab6e24b6e50f065b039f799f5592360a6558eb52d760': 'The quick brown fox jumps over the lazy dog.'
|
|
167
|
-
},
|
|
168
|
-
'ascii more than 128 bytes': {
|
|
169
|
-
'10dcbf6389980ce3594547939bbc685363d28adbd6a05bc4abd7fc62e7693a1f6e33569fed5a380bfecb56ae811d25939b95823f39bb0f16a08740629d066d43': 'The MD5 message-digest algorithm is a widely used cryptographic hash function producing a 128-bit (16-byte) hash value, typically expressed in text format as a 32 digit hexadecimal number. MD5 has been utilized in a wide variety of cryptographic applications, and is also commonly used to verify data integrity.'
|
|
170
|
-
},
|
|
171
|
-
'UTF-8': {
|
|
172
|
-
'2f6a1bd50562230229af34b0ccf46b8754b89d23ae2c5bf7840b4acfcef86f87395edc0a00b2bfef53bafebe3b79de2e3e01cbd8169ddbb08bde888dcc893524': '中文',
|
|
173
|
-
'c452ec93e83d4795fcab62a76eed0d88f2231a995ce108ac8f130246f87c4a11cb18a2c1a688a5695906a6f863e71bbe8997c6610319ab97f12d2e5bf0afe458': 'aécio',
|
|
174
|
-
'8a2d72022ce19d989dbe6a0017faccbf5dc2e22c162d1c5eb168864d32dd1a71e1b4782652c148cf6ca47b77a72c96fff682e72bdfef0566d4b7cca3c9ccc59d': '𠜎'
|
|
175
|
-
},
|
|
176
|
-
'UTF-8 more than 128 bytes': {
|
|
177
|
-
'6a67c28aa1946ca1be8382b861aac4aaf20052f495db9b6902d13adfa603eaba5d169f8896b86d461b2949283eb98e503c3f0640188ea7d6731526fc06568d37': '訊息摘要演算法第五版(英語:Message-Digest Algorithm 5,縮寫為MD5),是當前電腦領域用於確保資訊傳輸完整一致而廣泛使用的雜湊演算法之一',
|
|
178
|
-
'd04ff5b0e85e9968be2a4d4e133c15c7ccee7497198bb651599a97d11d00bca6048d329ab75aa454566cd532648fa1cb4551985d9d645de9fa43a311a9ee8e4d': '訊息摘要演算法第五版(英語:Message-Digest Algorithm 5,縮寫為MD5),是當前電腦領域用於確保資訊傳輸完整一致而廣泛使用的雜湊演算法之一(又譯雜湊演算法、摘要演算法等),主流程式語言普遍已有MD5的實作。'
|
|
179
|
-
}
|
|
180
|
-
},
|
|
181
|
-
keccak_384: {
|
|
182
|
-
'ascii': {
|
|
183
|
-
'2c23146a63a29acf99e73b88f8c24eaa7dc60aa771780ccc006afbfa8fe2479b2dd2b21362337441ac12b515911957ff': '',
|
|
184
|
-
'283990fa9d5fb731d786c5bbee94ea4db4910f18c62c03d173fc0a5e494422e8a0b3da7574dae7fa0baf005e504063b3': 'The quick brown fox jumps over the lazy dog',
|
|
185
|
-
'9ad8e17325408eddb6edee6147f13856ad819bb7532668b605a24a2d958f88bd5c169e56dc4b2f89ffd325f6006d820b': 'The quick brown fox jumps over the lazy dog.'
|
|
186
|
-
},
|
|
187
|
-
'ascii more than 128 bytes': {
|
|
188
|
-
'e7ec8976b4d96e43f50ae8ecdcf2d97a56236e6406e8dd00efd0d9abe885659db58a2f4b138a4ecfb1bd0052f6569516': 'The MD5 message-digest algorithm is a widely used cryptographic hash function producing a 128-bit (16-byte) hash value, typically expressed in text format as a 32 digit hexadecimal number. MD5 has been utilized in a wide variety of cryptographic applications, and is also commonly used to verify data integrity.'
|
|
189
|
-
},
|
|
190
|
-
'UTF-8': {
|
|
191
|
-
'743f64bb7544c6ed923be4741b738dde18b7cee384a3a09c4e01acaaac9f19222cdee137702bd3aa05dc198373d87d6c': '中文',
|
|
192
|
-
'08990555e131af8597687614309da4c5053ce866f348544da0a0c2c78c2cc79680ebb57cfbe238286e78ea133a037897': 'aécio',
|
|
193
|
-
'2a80f59abf3111f38a35a3daa25123b495f90e9736bd300e35911d19abdd8806498c581333f198ccbbf2252b57c2925d': '𠜎'
|
|
194
|
-
},
|
|
195
|
-
'UTF-8 more than 128 bytes': {
|
|
196
|
-
'a3b043a2f69e4326a05d478fa4c8aa2bd7612453d775af37665a0b96ef2207cdc74c50cdba1629796a5136fe77300b05': '訊息摘要演算法第五版(英語:Message-Digest Algorithm 5,縮寫為MD5),是當前電腦領域用於確保資訊傳輸完整一致而廣泛使用的雜湊演算法之一',
|
|
197
|
-
'66414c090cc3fe9c396d313cbaa100aefd335e851838b29382568b7f57357ada7c54b8fa8c17f859945bba88b2c2e332': '訊息摘要演算法第五版(英語:Message-Digest Algorithm 5,縮寫為MD5),是當前電腦領域用於確保資訊傳輸完整一致而廣泛使用的雜湊演算法之一(又譯雜湊演算法、摘要演算法等),主流程式語言普遍已有MD5的實作。'
|
|
198
|
-
}
|
|
199
|
-
},
|
|
200
|
-
keccak_256: {
|
|
201
|
-
'ascii': {
|
|
202
|
-
'c5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470': '',
|
|
203
|
-
'4d741b6f1eb29cb2a9b9911c82f56fa8d73b04959d3d9d222895df6c0b28aa15': 'The quick brown fox jumps over the lazy dog',
|
|
204
|
-
'578951e24efd62a3d63a86f7cd19aaa53c898fe287d2552133220370240b572d': 'The quick brown fox jumps over the lazy dog.'
|
|
205
|
-
},
|
|
206
|
-
'ascii more than 128 bytes': {
|
|
207
|
-
'af20018353ffb50d507f1555580f5272eca7fdab4f8295db4b1a9ad832c93f6d': 'The MD5 message-digest algorithm is a widely used cryptographic hash function producing a 128-bit (16-byte) hash value, typically expressed in text format as a 32 digit hexadecimal number. MD5 has been utilized in a wide variety of cryptographic applications, and is also commonly used to verify data integrity.'
|
|
208
|
-
},
|
|
209
|
-
'UTF-8': {
|
|
210
|
-
'70a2b6579047f0a977fcb5e9120a4e07067bea9abb6916fbc2d13ffb9a4e4eee': '中文',
|
|
211
|
-
'd7d569202f04daf90432810d6163112b2695d7820da979327ebd894efb0276dc': 'aécio',
|
|
212
|
-
'16a7cc7a58444cbf7e939611910ddc82e7cba65a99d3e8e08cfcda53180a2180': '𠜎'
|
|
213
|
-
},
|
|
214
|
-
'UTF-8 more than 128 bytes': {
|
|
215
|
-
'd1021d2d4c5c7e88098c40f422af68493b4b64c913cbd68220bf5e6127c37a88': '訊息摘要演算法第五版(英語:Message-Digest Algorithm 5,縮寫為MD5),是當前電腦領域用於確保資訊傳輸完整一致而廣泛使用的雜湊演算法之一',
|
|
216
|
-
'ffabf9bba2127c4928d360c9905cb4911f0ec21b9c3b89f3b242bccc68389e36': '訊息摘要演算法第五版(英語:Message-Digest Algorithm 5,縮寫為MD5),是當前電腦領域用於確保資訊傳輸完整一致而廣泛使用的雜湊演算法之一(又譯雜湊演算法、摘要演算法等),主流程式語言普遍已有MD5的實作。'
|
|
217
|
-
}
|
|
218
|
-
},
|
|
219
|
-
keccak_224: {
|
|
220
|
-
'ascii': {
|
|
221
|
-
'f71837502ba8e10837bdd8d365adb85591895602fc552b48b7390abd': '',
|
|
222
|
-
'310aee6b30c47350576ac2873fa89fd190cdc488442f3ef654cf23fe': 'The quick brown fox jumps over the lazy dog',
|
|
223
|
-
'c59d4eaeac728671c635ff645014e2afa935bebffdb5fbd207ffdeab': 'The quick brown fox jumps over the lazy dog.'
|
|
224
|
-
},
|
|
225
|
-
'ascii more than 128 bytes': {
|
|
226
|
-
'8dd58b706e3a08ec4f1f202af39295b38c355a39b23308ade7218a21': 'The MD5 message-digest algorithm is a widely used cryptographic hash function producing a 128-bit (16-byte) hash value, typically expressed in text format as a 32 digit hexadecimal number. MD5 has been utilized in a wide variety of cryptographic applications, and is also commonly used to verify data integrity.'
|
|
227
|
-
},
|
|
228
|
-
'UTF-8': {
|
|
229
|
-
'7bc2a0b6e7e0a055a61e4f731e2944b560f41ff98967dcbf4bbf77a5': '中文',
|
|
230
|
-
'66f3db76bf8cb35726cb278bac412d187c3484ab2083dc50ef5ffb55': 'aécio',
|
|
231
|
-
'3bfa94845726f4cd5cf17d19b5eacac17b3694790e13a76d5c81c7c2': '𠜎'
|
|
232
|
-
},
|
|
233
|
-
'UTF-8 more than 128 bytes': {
|
|
234
|
-
'd59eef8f394ef7d96967bb0bde578785c033f7f0a21913d6ba41ed1b': '訊息摘要演算法第五版(英語:Message-Digest Algorithm 5,縮寫為MD5),是當前電腦領域用於確保資訊傳輸完整一致而廣泛使用的雜湊演算法之一',
|
|
235
|
-
'27123a2a3860d1041d4769778c4b078732bf4300f7e1c56536ab2644': '訊息摘要演算法第五版(英語:Message-Digest Algorithm 5,縮寫為MD5),是當前電腦領域用於確保資訊傳輸完整一致而廣泛使用的雜湊演算法之一(又譯雜湊演算法、摘要演算法等),主流程式語言普遍已有MD5的實作。'
|
|
236
|
-
}
|
|
237
|
-
}
|
|
238
|
-
};
|
|
239
|
-
|
|
240
|
-
runTestCases(methods, testCases);
|
|
241
|
-
|
|
242
|
-
describe('sha3_512', function () {
|
|
243
|
-
context('#arrayBuffer', function () {
|
|
244
|
-
it('should be equal', function () {
|
|
245
|
-
expect(sha3_512.arrayBuffer('').toHexString()).to.be('a69f73cca23a9ac5c8b567dc185a756e97c982164fe25859e0d1dcc1475c80a615b2123af1f5f94c11e3e9402c3ac558f500199d95b6d3e301758586281dcd26');
|
|
246
|
-
expect(sha3_512.buffer('').toHexString()).to.be('a69f73cca23a9ac5c8b567dc185a756e97c982164fe25859e0d1dcc1475c80a615b2123af1f5f94c11e3e9402c3ac558f500199d95b6d3e301758586281dcd26');
|
|
247
|
-
});
|
|
248
|
-
});
|
|
249
|
-
|
|
250
|
-
context('#hex', function () {
|
|
251
|
-
it('should be equal', function () {
|
|
252
|
-
expect(sha3_512.hex('')).to.be('a69f73cca23a9ac5c8b567dc185a756e97c982164fe25859e0d1dcc1475c80a615b2123af1f5f94c11e3e9402c3ac558f500199d95b6d3e301758586281dcd26');
|
|
253
|
-
});
|
|
254
|
-
});
|
|
255
|
-
|
|
256
|
-
context('#update', function () {
|
|
257
|
-
it('should be equal', function () {
|
|
258
|
-
expect(sha3_512.update('').hex()).to.be('a69f73cca23a9ac5c8b567dc185a756e97c982164fe25859e0d1dcc1475c80a615b2123af1f5f94c11e3e9402c3ac558f500199d95b6d3e301758586281dcd26');
|
|
259
|
-
expect(sha3_512.update('The quick brown fox ').update('jumps over the lazy dog').hex()).to.be('01dedd5de4ef14642445ba5f5b97c15e47b9ad931326e4b0727cd94cefc44fff23f07bf543139939b49128caf436dc1bdee54fcb24023a08d9403f9b4bf0d450');
|
|
260
|
-
});
|
|
261
|
-
});
|
|
262
|
-
|
|
263
|
-
context('#create', function () {
|
|
264
|
-
it('should be equal', function () {
|
|
265
|
-
var bytes = [84, 104, 101, 32, 113, 117, 105, 99, 107, 32, 98, 114, 111, 119, 110, 32, 102, 111, 120, 32, 106, 117, 109, 112, 115, 32, 111, 118, 101, 114, 32, 116, 104, 101, 32, 108, 97, 122, 121, 32, 100, 111, 103];
|
|
266
|
-
var hash = sha3_512.create();
|
|
267
|
-
for (var i = 0; i < bytes.length; ++i) {
|
|
268
|
-
hash.update([bytes[i]]);
|
|
269
|
-
}
|
|
270
|
-
expect(hash.hex()).to.be('01dedd5de4ef14642445ba5f5b97c15e47b9ad931326e4b0727cd94cefc44fff23f07bf543139939b49128caf436dc1bdee54fcb24023a08d9403f9b4bf0d450');
|
|
271
|
-
});
|
|
272
|
-
});
|
|
273
|
-
});
|
|
274
|
-
|
|
275
|
-
describe('#keccak_512', function () {
|
|
276
|
-
context('when special length', function () {
|
|
277
|
-
it('should be equal', function () {
|
|
278
|
-
expect(keccak_512('012345678901234567890123456789012345678901234567890123456789012345678901')).to.be('90b1d032c3bf06dcc78a46fe52054bab1250600224bfc6dfbfb40a7877c55e89bb982799a2edf198568a4166f6736678b45e76b12fac813cfdf0a76714e5eae8');
|
|
279
|
-
expect(keccak_512('01234567890123456789012345678901234567890123456789012345678901234567890')).to.be('3173e7abc754a0b2909410d78986428a9183e996864af02f421d273d9fa1b4e4a5b14e2998b20767712f53a01ff8f6ae2c3e71e51e2c0f24257b03e6da09eb77');
|
|
280
|
-
});
|
|
281
|
-
});
|
|
282
|
-
|
|
283
|
-
context('when Array', function () {
|
|
284
|
-
it('should be equal', function () {
|
|
285
|
-
expect(keccak_512([])).to.be('0eab42de4c3ceb9235fc91acffe746b29c29a8c366b7c60e4e67c466f36a4304c00fa9caf9d87976ba469bcbe06713b435f091ef2769fb160cdab33d3670680e');
|
|
286
|
-
expect(keccak_512([84, 104, 101, 32, 113, 117, 105, 99, 107, 32, 98, 114, 111, 119, 110, 32, 102, 111, 120, 32, 106, 117, 109, 112, 115, 32, 111, 118, 101, 114, 32, 116, 104, 101, 32, 108, 97, 122, 121, 32, 100, 111, 103])).to.be('d135bb84d0439dbac432247ee573a23ea7d3c9deb2a968eb31d47c4fb45f1ef4422d6c531b5b9bd6f449ebcc449ea94d0a8f05f62130fda612da53c79659f609');
|
|
287
|
-
});
|
|
288
|
-
});
|
|
289
|
-
|
|
290
|
-
context('when Uint8Array', function () {
|
|
291
|
-
it('should be equal', function () {
|
|
292
|
-
expect(keccak_512(new Uint8Array([]))).to.be('0eab42de4c3ceb9235fc91acffe746b29c29a8c366b7c60e4e67c466f36a4304c00fa9caf9d87976ba469bcbe06713b435f091ef2769fb160cdab33d3670680e');
|
|
293
|
-
expect(keccak_512(new Uint8Array([84, 104, 101, 32, 113, 117, 105, 99, 107, 32, 98, 114, 111, 119, 110, 32, 102, 111, 120, 32, 106, 117, 109, 112, 115, 32, 111, 118, 101, 114, 32, 116, 104, 101, 32, 108, 97, 122, 121, 32, 100, 111, 103]))).to.be('d135bb84d0439dbac432247ee573a23ea7d3c9deb2a968eb31d47c4fb45f1ef4422d6c531b5b9bd6f449ebcc449ea94d0a8f05f62130fda612da53c79659f609');
|
|
294
|
-
});
|
|
295
|
-
});
|
|
296
|
-
|
|
297
|
-
context('when ArrayBuffer', function () {
|
|
298
|
-
it('should be equal', function () {
|
|
299
|
-
expect(keccak_512(new ArrayBuffer(0))).to.be('0eab42de4c3ceb9235fc91acffe746b29c29a8c366b7c60e4e67c466f36a4304c00fa9caf9d87976ba469bcbe06713b435f091ef2769fb160cdab33d3670680e');
|
|
300
|
-
});
|
|
301
|
-
});
|
|
302
|
-
|
|
303
|
-
context('when output ArrayBuffer', function () {
|
|
304
|
-
it('should be equal', function () {
|
|
305
|
-
expect(keccak_512.arrayBuffer('').toHexString()).to.be('0eab42de4c3ceb9235fc91acffe746b29c29a8c366b7c60e4e67c466f36a4304c00fa9caf9d87976ba469bcbe06713b435f091ef2769fb160cdab33d3670680e');
|
|
306
|
-
expect(keccak_512.buffer('').toHexString()).to.be('0eab42de4c3ceb9235fc91acffe746b29c29a8c366b7c60e4e67c466f36a4304c00fa9caf9d87976ba469bcbe06713b435f091ef2769fb160cdab33d3670680e');
|
|
307
|
-
});
|
|
308
|
-
});
|
|
309
|
-
|
|
310
|
-
context('when output Array', function () {
|
|
311
|
-
it('should be equal', function () {
|
|
312
|
-
expect(keccak_512.array('').toHexString()).to.be('0eab42de4c3ceb9235fc91acffe746b29c29a8c366b7c60e4e67c466f36a4304c00fa9caf9d87976ba469bcbe06713b435f091ef2769fb160cdab33d3670680e');
|
|
313
|
-
});
|
|
314
|
-
});
|
|
315
|
-
});
|
|
316
|
-
})(sha3_512, sha3_384, sha3_256, sha3_224, keccak_512, keccak_384, keccak_256, keccak_224);
|