- add sources.
[platform/framework/web/crosswalk.git] / src / chrome / test / data / third_party / kraken / tests / kraken-1.1 / stanford-crypto-aes.js
1 new sjcl.test.TestCase("AES official known-answer tests", function (cb) {
2   if (!sjcl.cipher.aes) {
3     this.unimplemented();
4     cb && cb();
5     return;
6   }
7   
8   var i, kat = sjcl.test.vector.aes, tv, len, aes;
9
10   //XXX add more vectors instead of looping
11   for (var index = 0; index < 8; index++) {
12       for (i=0; i<kat.length; i++) {
13         tv = kat[i];
14         len = 32 * tv.key.length;
15         aes = new sjcl.cipher.aes(tv.key);
16         this.require(sjcl.bitArray.equal(aes.encrypt(tv.pt), tv.ct), "encrypt "+len+" #"+i);
17         this.require(sjcl.bitArray.equal(aes.decrypt(tv.ct), tv.pt), "decrypt "+len+" #"+i);
18       }
19   }
20   cb && cb();
21 });
22
23 sjcl.test.run();