Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(286)

Side by Side Diff: chrome/test/data/third_party/kraken/tests/kraken-1.1/stanford-crypto-ccm.js

Issue 11348021: Automate Kraken benchmark with Chrome Remote Control. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
(Empty)
1 new sjcl.test.TestCase("CCM mode tests", function (cb) {
2 if (!sjcl.cipher.aes || !sjcl.mode.ccm) {
3 this.unimplemented();
4 cb && cb();
5 return;
6 }
7
8 var i, kat = sjcl.test.vector.ccm, tv, iv, ct, aes, len, tlen, thiz=this, w=sj cl.bitArray, pt, h=sjcl.codec.hex, ad;
9 browserUtil.cpsIterate(function (j, cbb) {
10 for (i=100*j; i<kat.length && i<100*(j+1); i++) {
11 tv = kat[i];
12 len = 32 * tv.key.length;
13 aes = new sjcl.cipher.aes(h.toBits(tv.key));
14
15 // Convert from strings
16 iv = h.toBits(tv.iv);
17 ad = h.toBits(tv.adata);
18 pt = h.toBits(tv.pt);
19 ct = h.toBits(tv.ct + tv.tag);
20 tlen = tv.tag.length * 4;
21
22 thiz.require(w.equal(sjcl.mode.ccm.encrypt(aes, pt, iv, ad, tlen), ct), "a es-"+len+"-ccm-encrypt #"+i);
23 try {
24 thiz.require(w.equal(sjcl.mode.ccm.decrypt(aes, ct, iv, ad, tlen), pt), "aes-"+len+"-ccm-decrypt #"+i);
25 } catch (e) {
26 thiz.fail("aes-ccm-decrypt #"+i+" (exn "+e+")");
27 }
28 }
29 cbb();
30 }, 0, kat.length / 100, true, cb);
31 });
32
33 sjcl.test.run();
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698