Skip to content

Commit

Permalink
SRP group as object
Browse files Browse the repository at this point in the history
  • Loading branch information
sqs committed Apr 19, 2011
1 parent 205884d commit b7ab069
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 6 deletions.
4 changes: 2 additions & 2 deletions core/srp.js
Expand Up @@ -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) {
Expand Down
7 changes: 3 additions & 4 deletions test/srp_test.js
Expand Up @@ -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();
Expand Down

0 comments on commit b7ab069

Please sign in to comment.