Wed, 31 Dec 2014 06:09:35 +0100
Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.
michael@0 | 1 | var sjcl = { |
michael@0 | 2 | hash: {}, |
michael@0 | 3 | }; |
michael@0 | 4 | sjcl.bitArray = { |
michael@0 | 5 | concat: function (a, b) { |
michael@0 | 6 | var c = a[a.length - 1], |
michael@0 | 7 | d = sjcl.bitArray.getPartial(c); |
michael@0 | 8 | return d === 32 ? a.concat(b) : sjcl.bitArray.P(b, d, c | 0, a.slice(0, a.length - 1)) |
michael@0 | 9 | }, |
michael@0 | 10 | getPartial: function (a) { |
michael@0 | 11 | return Math.round(a / 0x10000000000) || 32 |
michael@0 | 12 | } |
michael@0 | 13 | }; |
michael@0 | 14 | sjcl.hash.sha256 = function (a) { |
michael@0 | 15 | this.a[0] || this.w(); |
michael@0 | 16 | this.reset() |
michael@0 | 17 | }; |
michael@0 | 18 | sjcl.hash.sha256.prototype = { |
michael@0 | 19 | reset: function () { |
michael@0 | 20 | this.n = this.N.slice(0); |
michael@0 | 21 | this.i = []; |
michael@0 | 22 | }, |
michael@0 | 23 | update: function (a) { |
michael@0 | 24 | var b, c = this.i = sjcl.bitArray.concat(this.i, a); |
michael@0 | 25 | return this |
michael@0 | 26 | }, |
michael@0 | 27 | finalize: function () { |
michael@0 | 28 | var a, b = this.i, |
michael@0 | 29 | c = this.n; |
michael@0 | 30 | this.C(b.splice(0, 16)); |
michael@0 | 31 | return c |
michael@0 | 32 | }, |
michael@0 | 33 | N: [], |
michael@0 | 34 | a: [], |
michael@0 | 35 | w: function () { |
michael@0 | 36 | function a(e) { |
michael@0 | 37 | return (e - Math.floor(e)) * 0x100000000 | 0 |
michael@0 | 38 | } |
michael@0 | 39 | var b = 0, |
michael@0 | 40 | c = 2, |
michael@0 | 41 | d; |
michael@0 | 42 | a: for (; b < 64; c++) { |
michael@0 | 43 | if (b < 8) |
michael@0 | 44 | this.N[b] = a(Math.pow(c, 0.5)); |
michael@0 | 45 | b++ |
michael@0 | 46 | } |
michael@0 | 47 | }, |
michael@0 | 48 | C: function (a) { |
michael@0 | 49 | var b, c, d = a.slice(0), |
michael@0 | 50 | e = this.n, |
michael@0 | 51 | h = e[1], |
michael@0 | 52 | i = e[2], |
michael@0 | 53 | k = e[3], |
michael@0 | 54 | n = e[7]; |
michael@0 | 55 | for (a = 0; a < 64; a++) { |
michael@0 | 56 | b = d[a + 1 & 15]; |
michael@0 | 57 | g = b + (h & i ^ k & (h ^ i)) + (h >>> 2 ^ h >>> 13 ^ h >>> 22 ^ h << 30 ^ h << 19 ^ h << 10) | 0 |
michael@0 | 58 | } |
michael@0 | 59 | e[0] = e[0] + g | 0; |
michael@0 | 60 | } |
michael@0 | 61 | }; |
michael@0 | 62 | var ax1 = [-1862726214, -1544935945, -1650904951, -1523200565, 1783959997, -1422527763, -1915825893, 67249414]; |
michael@0 | 63 | var ax2 = ax1; |
michael@0 | 64 | for (var aix = 0; aix < 200; aix++) ax1 = (new sjcl.hash.sha256(undefined)).update(ax1, undefined).finalize(); |
michael@0 | 65 | eval("for (var aix = 0; aix < 200; aix++) ax2 = (new sjcl.hash.sha256(undefined)).update(ax2, undefined).finalize();" + |
michael@0 | 66 | "assertEq(ax2.toString(), ax1.toString());"); |