1 new sjcl.test.TestCase("CCM mode tests", function (cb) {
2 if (!sjcl.cipher.aes || !sjcl.mode.ccm) {
8 var i, kat = sjcl.test.vector.ccm, tv, iv, ct, aes, len, tlen, thiz=this, w=sjcl.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++) {
12 len = 32 * tv.key.length;
13 aes = new sjcl.cipher.aes(h.toBits(tv.key));
15 // Convert from strings
17 ad = h.toBits(tv.adata);
19 ct = h.toBits(tv.ct + tv.tag);
20 tlen = tv.tag.length * 4;
22 thiz.require(w.equal(sjcl.mode.ccm.encrypt(aes, pt, iv, ad, tlen), ct), "aes-"+len+"-ccm-encrypt #"+i);
24 thiz.require(w.equal(sjcl.mode.ccm.decrypt(aes, ct, iv, ad, tlen), pt), "aes-"+len+"-ccm-decrypt #"+i);
26 thiz.fail("aes-ccm-decrypt #"+i+" (exn "+e+")");
30 }, 0, kat.length / 100, true, cb);