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