2011-04-19 10:43:21 +02:00
|
|
|
new sjcl.test.TestCase("SRP known-answer (RFC 5054) tests", function (cb) {
|
|
|
|
if (!sjcl.keyexchange.srp) {
|
|
|
|
this.unimplemented();
|
|
|
|
cb && cb();
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2011-04-20 01:26:44 +02:00
|
|
|
var i, kat = sjcl.test.vector.srp, tv, group, v, x;
|
2011-04-19 10:43:21 +02:00
|
|
|
|
|
|
|
for (i=0; i<kat.length; i++) {
|
|
|
|
tv = kat[i];
|
2011-04-20 01:26:44 +02:00
|
|
|
group = sjcl.keyexchange.srp.knownGroup(tv.known_group_size);
|
2011-04-19 14:14:28 +02:00
|
|
|
tv.s = sjcl.codec.hex.toBits(tv.s);
|
|
|
|
x = sjcl.keyexchange.srp.makeX(tv.I, tv.P, tv.s);
|
|
|
|
this.require(sjcl.codec.hex.fromBits(x).toUpperCase() === tv.x, "srpx #"+i);
|
|
|
|
|
2011-04-20 01:26:44 +02:00
|
|
|
v = sjcl.keyexchange.srp.makeVerifier(tv.I, tv.P, tv.s, group);
|
2011-04-19 14:14:28 +02:00
|
|
|
this.require(v.equals(new sjcl.bn(tv.v)), "srpv #"+i);
|
2011-04-19 10:43:21 +02:00
|
|
|
}
|
|
|
|
cb && cb();
|
|
|
|
});
|