Update CrOS OOBE throbber to MD throbber; delete old asset
[chromium-blink-merge.git] / chrome / test / data / third_party / kraken / tests / kraken-1.1 / stanford-crypto-sha256-iterative.js
blobb8a6dab89011bcac8265fac50ac2f35572665fcb
1 /**
2 * Test SHA-256 using an ad-hoc iterative technique.
3 * This uses a string buffer which has n characters on the nth iteration.
4 * Each iteration, the buffer is hashed and the hash is converted to a string.
5 * The first two characters of the string are prepended to the buffer, then the
6 * last character of the buffer is removed. This way, neither the beginning nor
7 * the end of the buffer is fixed.
9 * The hashes from each output step are also hashed together into one final hash.
10 * This is compared against a final hash which was computed with SSL.
13 new sjcl.test.TestCase("SHA-256 iterative", function (cb) {
14 if (!sjcl.hash.sha256) {
15 this.unimplemented();
16 cb && cb();
17 return;
20 var toBeHashed = "", cumulative = new sjcl.hash.sha256(), hash, thiz=this;
21 browserUtil.cpsIterate(function (i, cbb) {
22 for (var n=100*i; n<100*(i+1); n++) {
23 hash = sjcl.hash.sha256.hash(toBeHashed);
24 hash = sjcl.codec.hex.fromBits(hash);
25 cumulative.update(hash);
26 toBeHashed = (hash.substring(0,2)+toBeHashed).substring(0,n+1);
28 cbb && cbb();
29 }, 0, 10, true, function () {
30 hash = sjcl.codec.hex.fromBits(cumulative.finalize());
31 thiz.require(hash === "f305c76d5d457ddf04f1927166f5e13429407049a5c5f29021916321fcdcd8b4");
32 cb && cb();
33 });
34 });
36 sjcl.test.run();