annotate scripts/minifier/otr/dep/salsa20.js @ 145:9201caf7b2a8

flatpak (build_manifest): don't crash if icon is not specified
author Goffi <goffi@goffi.org>
date Mon, 24 Jun 2019 08:57:12 +0200
parents 1596660ddf72
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
12
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
1 // Salsa20 implementation
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
2 // Contributed to Cryptocat by Dmitry Chestnykh
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
3 // 21-01-2013
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
4
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
5 ;(function (root, factory) {
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
6
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
7 if (typeof define === 'function' && define.amd) {
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
8 define(factory)
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
9 } else if (typeof module !== 'undefined' && module.exports) {
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
10 module.exports = factory()
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
11 } else {
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
12 root.Salsa20 = factory()
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
13 }
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
14
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
15 }(this, function () {
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
16
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
17 function Salsa20(key, nonce) {
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
18 // Constants.
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
19 this.rounds = 20; // number of Salsa rounds
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
20 this.sigmaWords = [0x61707865, 0x3320646e, 0x79622d32, 0x6b206574];
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
21
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
22 // State.
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
23 this.keyWords = []; // key words
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
24 this.nonceWords = [0, 0]; // nonce words
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
25 this.counterWords = [0, 0]; // block counter words
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
26
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
27 // Output buffer.
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
28 this.block = []; // output block of 64 bytes
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
29 this.blockUsed = 64; // number of block bytes used
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
30
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
31 this.setKey(key);
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
32 this.setNonce(nonce);
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
33 }
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
34
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
35 // setKey sets the key to the given 32-byte array.
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
36 Salsa20.prototype.setKey = function(key) {
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
37 for (var i = 0, j = 0; i < 8; i++, j += 4) {
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
38 this.keyWords[i] = (key[j] & 0xff) |
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
39 ((key[j+1] & 0xff)<<8) |
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
40 ((key[j+2] & 0xff)<<16) |
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
41 ((key[j+3] & 0xff)<<24);
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
42 }
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
43 this._reset();
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
44 };
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
45
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
46 // setNonce sets the nonce to the given 8-byte array.
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
47 Salsa20.prototype.setNonce = function(nonce) {
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
48 this.nonceWords[0] = (nonce[0] & 0xff) |
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
49 ((nonce[1] & 0xff)<<8) |
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
50 ((nonce[2] & 0xff)<<16) |
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
51 ((nonce[3] & 0xff)<<24);
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
52 this.nonceWords[1] = (nonce[4] & 0xff) |
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
53 ((nonce[5] & 0xff)<<8) |
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
54 ((nonce[6] & 0xff)<<16) |
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
55 ((nonce[7] & 0xff)<<24);
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
56 this._reset();
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
57 };
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
58
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
59 // getBytes returns the next numberOfBytes bytes of stream.
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
60 Salsa20.prototype.getBytes = function(numberOfBytes) {
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
61 var out = new Array(numberOfBytes);
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
62 for (var i = 0; i < numberOfBytes; i++) {
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
63 if (this.blockUsed == 64) {
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
64 this._generateBlock();
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
65 this._incrementCounter();
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
66 this.blockUsed = 0;
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
67 }
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
68 out[i] = this.block[this.blockUsed];
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
69 this.blockUsed++;
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
70 }
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
71 return out;
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
72 };
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
73
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
74 Salsa20.prototype.getHexString = function(numberOfBytes) {
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
75 var hex=['0','1','2','3','4','5','6','7','8','9','a','b','c','d','e','f'];
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
76 var out = [];
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
77 var bytes = this.getBytes(numberOfBytes);
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
78 for(var i = 0; i < bytes.length; i++) {
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
79 out.push(hex[(bytes[i] >> 4) & 15]);
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
80 out.push(hex[bytes[i] & 15]);
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
81 }
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
82 return out.join('');
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
83 };
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
84
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
85 // Private methods.
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
86
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
87 Salsa20.prototype._reset = function() {
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
88 this.counterWords[0] = 0;
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
89 this.counterWords[1] = 0;
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
90 this.blockUsed = 64;
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
91 };
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
92
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
93 // _incrementCounter increments block counter.
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
94 Salsa20.prototype._incrementCounter = function() {
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
95 // Note: maximum 2^64 blocks.
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
96 this.counterWords[0] = (this.counterWords[0] + 1) & 0xffffffff;
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
97 if (this.counterWords[0] == 0) {
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
98 this.counterWords[1] = (this.counterWords[1] + 1) & 0xffffffff;
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
99 }
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
100 };
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
101
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
102 // _generateBlock generates 64 bytes from key, nonce, and counter,
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
103 // and puts the result into this.block.
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
104 Salsa20.prototype._generateBlock = function() {
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
105 var j0 = this.sigmaWords[0],
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
106 j1 = this.keyWords[0],
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
107 j2 = this.keyWords[1],
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
108 j3 = this.keyWords[2],
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
109 j4 = this.keyWords[3],
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
110 j5 = this.sigmaWords[1],
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
111 j6 = this.nonceWords[0],
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
112 j7 = this.nonceWords[1],
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
113 j8 = this.counterWords[0],
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
114 j9 = this.counterWords[1],
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
115 j10 = this.sigmaWords[2],
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
116 j11 = this.keyWords[4],
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
117 j12 = this.keyWords[5],
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
118 j13 = this.keyWords[6],
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
119 j14 = this.keyWords[7],
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
120 j15 = this.sigmaWords[3];
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
121
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
122 var x0 = j0, x1 = j1, x2 = j2, x3 = j3, x4 = j4, x5 = j5, x6 = j6, x7 = j7,
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
123 x8 = j8, x9 = j9, x10 = j10, x11 = j11, x12 = j12, x13 = j13, x14 = j14, x15 = j15;
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
124
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
125 var u;
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
126
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
127 for (var i = 0; i < this.rounds; i += 2) {
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
128 u = x0 + x12;
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
129 x4 ^= (u<<7) | (u>>>(32-7));
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
130 u = x4 + x0;
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
131 x8 ^= (u<<9) | (u>>>(32-9));
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
132 u = x8 + x4;
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
133 x12 ^= (u<<13) | (u>>>(32-13));
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
134 u = x12 + x8;
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
135 x0 ^= (u<<18) | (u>>>(32-18));
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
136
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
137 u = x5 + x1;
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
138 x9 ^= (u<<7) | (u>>>(32-7));
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
139 u = x9 + x5;
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
140 x13 ^= (u<<9) | (u>>>(32-9));
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
141 u = x13 + x9;
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
142 x1 ^= (u<<13) | (u>>>(32-13));
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
143 u = x1 + x13;
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
144 x5 ^= (u<<18) | (u>>>(32-18));
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
145
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
146 u = x10 + x6;
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
147 x14 ^= (u<<7) | (u>>>(32-7));
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
148 u = x14 + x10;
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
149 x2 ^= (u<<9) | (u>>>(32-9));
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
150 u = x2 + x14;
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
151 x6 ^= (u<<13) | (u>>>(32-13));
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
152 u = x6 + x2;
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
153 x10 ^= (u<<18) | (u>>>(32-18));
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
154
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
155 u = x15 + x11;
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
156 x3 ^= (u<<7) | (u>>>(32-7));
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
157 u = x3 + x15;
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
158 x7 ^= (u<<9) | (u>>>(32-9));
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
159 u = x7 + x3;
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
160 x11 ^= (u<<13) | (u>>>(32-13));
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
161 u = x11 + x7;
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
162 x15 ^= (u<<18) | (u>>>(32-18));
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
163
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
164 u = x0 + x3;
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
165 x1 ^= (u<<7) | (u>>>(32-7));
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
166 u = x1 + x0;
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
167 x2 ^= (u<<9) | (u>>>(32-9));
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
168 u = x2 + x1;
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
169 x3 ^= (u<<13) | (u>>>(32-13));
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
170 u = x3 + x2;
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
171 x0 ^= (u<<18) | (u>>>(32-18));
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
172
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
173 u = x5 + x4;
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
174 x6 ^= (u<<7) | (u>>>(32-7));
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
175 u = x6 + x5;
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
176 x7 ^= (u<<9) | (u>>>(32-9));
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
177 u = x7 + x6;
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
178 x4 ^= (u<<13) | (u>>>(32-13));
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
179 u = x4 + x7;
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
180 x5 ^= (u<<18) | (u>>>(32-18));
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
181
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
182 u = x10 + x9;
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
183 x11 ^= (u<<7) | (u>>>(32-7));
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
184 u = x11 + x10;
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
185 x8 ^= (u<<9) | (u>>>(32-9));
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
186 u = x8 + x11;
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
187 x9 ^= (u<<13) | (u>>>(32-13));
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
188 u = x9 + x8;
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
189 x10 ^= (u<<18) | (u>>>(32-18));
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
190
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
191 u = x15 + x14;
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
192 x12 ^= (u<<7) | (u>>>(32-7));
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
193 u = x12 + x15;
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
194 x13 ^= (u<<9) | (u>>>(32-9));
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
195 u = x13 + x12;
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
196 x14 ^= (u<<13) | (u>>>(32-13));
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
197 u = x14 + x13;
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
198 x15 ^= (u<<18) | (u>>>(32-18));
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
199 }
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
200
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
201 x0 += j0;
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
202 x1 += j1;
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
203 x2 += j2;
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
204 x3 += j3;
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
205 x4 += j4;
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
206 x5 += j5;
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
207 x6 += j6;
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
208 x7 += j7;
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
209 x8 += j8;
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
210 x9 += j9;
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
211 x10 += j10;
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
212 x11 += j11;
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
213 x12 += j12;
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
214 x13 += j13;
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
215 x14 += j14;
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
216 x15 += j15;
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
217
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
218 this.block[ 0] = ( x0 >>> 0) & 0xff; this.block[ 1] = ( x0 >>> 8) & 0xff;
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
219 this.block[ 2] = ( x0 >>> 16) & 0xff; this.block[ 3] = ( x0 >>> 24) & 0xff;
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
220 this.block[ 4] = ( x1 >>> 0) & 0xff; this.block[ 5] = ( x1 >>> 8) & 0xff;
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
221 this.block[ 6] = ( x1 >>> 16) & 0xff; this.block[ 7] = ( x1 >>> 24) & 0xff;
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
222 this.block[ 8] = ( x2 >>> 0) & 0xff; this.block[ 9] = ( x2 >>> 8) & 0xff;
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
223 this.block[10] = ( x2 >>> 16) & 0xff; this.block[11] = ( x2 >>> 24) & 0xff;
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
224 this.block[12] = ( x3 >>> 0) & 0xff; this.block[13] = ( x3 >>> 8) & 0xff;
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
225 this.block[14] = ( x3 >>> 16) & 0xff; this.block[15] = ( x3 >>> 24) & 0xff;
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
226 this.block[16] = ( x4 >>> 0) & 0xff; this.block[17] = ( x4 >>> 8) & 0xff;
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
227 this.block[18] = ( x4 >>> 16) & 0xff; this.block[19] = ( x4 >>> 24) & 0xff;
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
228 this.block[20] = ( x5 >>> 0) & 0xff; this.block[21] = ( x5 >>> 8) & 0xff;
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
229 this.block[22] = ( x5 >>> 16) & 0xff; this.block[23] = ( x5 >>> 24) & 0xff;
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
230 this.block[24] = ( x6 >>> 0) & 0xff; this.block[25] = ( x6 >>> 8) & 0xff;
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
231 this.block[26] = ( x6 >>> 16) & 0xff; this.block[27] = ( x6 >>> 24) & 0xff;
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
232 this.block[28] = ( x7 >>> 0) & 0xff; this.block[29] = ( x7 >>> 8) & 0xff;
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
233 this.block[30] = ( x7 >>> 16) & 0xff; this.block[31] = ( x7 >>> 24) & 0xff;
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
234 this.block[32] = ( x8 >>> 0) & 0xff; this.block[33] = ( x8 >>> 8) & 0xff;
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
235 this.block[34] = ( x8 >>> 16) & 0xff; this.block[35] = ( x8 >>> 24) & 0xff;
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
236 this.block[36] = ( x9 >>> 0) & 0xff; this.block[37] = ( x9 >>> 8) & 0xff;
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
237 this.block[38] = ( x9 >>> 16) & 0xff; this.block[39] = ( x9 >>> 24) & 0xff;
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
238 this.block[40] = (x10 >>> 0) & 0xff; this.block[41] = (x10 >>> 8) & 0xff;
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
239 this.block[42] = (x10 >>> 16) & 0xff; this.block[43] = (x10 >>> 24) & 0xff;
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
240 this.block[44] = (x11 >>> 0) & 0xff; this.block[45] = (x11 >>> 8) & 0xff;
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
241 this.block[46] = (x11 >>> 16) & 0xff; this.block[47] = (x11 >>> 24) & 0xff;
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
242 this.block[48] = (x12 >>> 0) & 0xff; this.block[49] = (x12 >>> 8) & 0xff;
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
243 this.block[50] = (x12 >>> 16) & 0xff; this.block[51] = (x12 >>> 24) & 0xff;
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
244 this.block[52] = (x13 >>> 0) & 0xff; this.block[53] = (x13 >>> 8) & 0xff;
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
245 this.block[54] = (x13 >>> 16) & 0xff; this.block[55] = (x13 >>> 24) & 0xff;
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
246 this.block[56] = (x14 >>> 0) & 0xff; this.block[57] = (x14 >>> 8) & 0xff;
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
247 this.block[58] = (x14 >>> 16) & 0xff; this.block[59] = (x14 >>> 24) & 0xff;
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
248 this.block[60] = (x15 >>> 0) & 0xff; this.block[61] = (x15 >>> 8) & 0xff;
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
249 this.block[62] = (x15 >>> 16) & 0xff; this.block[63] = (x15 >>> 24) & 0xff;
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
250 };
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
251
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
252 return Salsa20
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
253
1596660ddf72 Add minifier script for otr.js and its dependencies
souliane <souliane@mailoo.org>
parents:
diff changeset
254 }))