initial commit for GitHub
This commit is contained in:
15
test/hmac_test.js
Normal file
15
test/hmac_test.js
Normal file
@@ -0,0 +1,15 @@
|
||||
new sjcl.test.TestCase("HMAC official test vectors", function (cb) {
|
||||
if (!sjcl.misc.hmac || !sjcl.hash.sha256) {
|
||||
this.unimplemented();
|
||||
cb && cb();
|
||||
return;
|
||||
}
|
||||
|
||||
var i, kat = sjcl.test.vector.hmac, tv, h=sjcl.codec.hex, out;
|
||||
for (i=0; i<kat.length; i++) {
|
||||
tv = kat[i];
|
||||
out = h.fromBits((new sjcl.misc.hmac(h.toBits(tv.key))).mac(h.toBits(tv.data)));
|
||||
this.require (out.substr(0,tv.mac.length) == tv.mac, "hmac #"+i);
|
||||
}
|
||||
cb && cb();
|
||||
});
|
||||
Reference in New Issue
Block a user