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