SRP group as object
This commit is contained in:
parent
945d6c4996
commit
57da29902f
@ -8,13 +8,13 @@
|
|||||||
* @class SRP
|
* @class SRP
|
||||||
*/
|
*/
|
||||||
sjcl.keyexchange.srp = {
|
sjcl.keyexchange.srp = {
|
||||||
makeVerifier: function(I, P, s, N, g) {
|
makeVerifier: function(I, P, s, group) {
|
||||||
var x;
|
var x;
|
||||||
// From RFC 5054:
|
// From RFC 5054:
|
||||||
// v = g^x mod N
|
// v = g^x mod N
|
||||||
x = this.makeX(I, P, s);
|
x = this.makeX(I, P, s);
|
||||||
x = sjcl.bn.fromBits(x);
|
x = sjcl.bn.fromBits(x);
|
||||||
return g.powermod(x, N);
|
return group.g.powermod(x, group.N);
|
||||||
},
|
},
|
||||||
|
|
||||||
makeX: function(I, P, s) {
|
makeX: function(I, P, s) {
|
||||||
|
@ -5,17 +5,16 @@ new sjcl.test.TestCase("SRP known-answer (RFC 5054) tests", function (cb) {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
var i, kat = sjcl.test.vector.srp, tv, N, g, v, x;
|
var i, kat = sjcl.test.vector.srp, tv, group, v, x;
|
||||||
|
|
||||||
for (i=0; i<kat.length; i++) {
|
for (i=0; i<kat.length; i++) {
|
||||||
tv = kat[i];
|
tv = kat[i];
|
||||||
N = sjcl.keyexchange.srp.knownGroup(tv.known_group_size).N;
|
group = sjcl.keyexchange.srp.knownGroup(tv.known_group_size);
|
||||||
g = sjcl.keyexchange.srp.knownGroup(tv.known_group_size).g;
|
|
||||||
tv.s = sjcl.codec.hex.toBits(tv.s);
|
tv.s = sjcl.codec.hex.toBits(tv.s);
|
||||||
x = sjcl.keyexchange.srp.makeX(tv.I, tv.P, 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);
|
this.require(sjcl.codec.hex.fromBits(x).toUpperCase() === tv.x, "srpx #"+i);
|
||||||
|
|
||||||
v = sjcl.keyexchange.srp.makeVerifier(tv.I, tv.P, tv.s, N, g);
|
v = sjcl.keyexchange.srp.makeVerifier(tv.I, tv.P, tv.s, group);
|
||||||
this.require(v.equals(new sjcl.bn(tv.v)), "srpv #"+i);
|
this.require(v.equals(new sjcl.bn(tv.v)), "srpv #"+i);
|
||||||
}
|
}
|
||||||
cb && cb();
|
cb && cb();
|
||||||
|
Loading…
Reference in New Issue
Block a user