diff options
| author | Azul <azul@riseup.net> | 2012-10-16 17:06:35 +0200 | 
|---|---|---|
| committer | Azul <azul@riseup.net> | 2012-10-16 17:06:35 +0200 | 
| commit | aeab3e93f45d2d8882d93ec20531aafd3cd9df45 (patch) | |
| tree | ce4cc58ed8028875fdae945310dab16bd8c827d5 /src | |
| parent | 5e7d79423cbc8b4cb48e2619f871bc223fd5ccdd (diff) | |
not caching x,V,salt to avoid conflicts
Diffstat (limited to 'src')
| -rw-r--r-- | src/srp_session.js | 26 | 
1 files changed, 8 insertions, 18 deletions
diff --git a/src/srp_session.js b/src/srp_session.js index 7554e4a..cbb95d8 100644 --- a/src/srp_session.js +++ b/src/srp_session.js @@ -22,15 +22,12 @@ SRP.prototype.Session = function(login, password) {    var authenticated = false;    var I = login || document.getElementById("srp_username").value;    var pass = password || document.getElementById("srp_password").value; -  var x, V; -  var salt;    // *** Accessor methods ***    // allows setting the random number A for testing -  this.calculateAndSetA = function(_a) -  { +  this.calculateAndSetA = function(_a) {      a = new BigInteger(_a, 16);      A = g.modPow(a, N);      Astr = A.toString(16); @@ -42,40 +39,33 @@ SRP.prototype.Session = function(login, password) {    }    // Returns the user's identity -  this.getI = function() -  { +  this.getI = function() {      return I;    };    // some 16 byte random number    this.getSalt = function() { -    salt = salt || new BigInteger(64, rng).toString(16); -    return salt +    return new BigInteger(64, rng).toString(16);    }    // Returns the BigInteger, g -  this.getg = function() -  { +  this.getg = function() {      return g;    };    // Returns the BigInteger, N -  this.getN = function() -  { +  this.getN = function() {      return N;    };    // Calculates the X value and return it as a BigInteger -  this.calcX = function(salt) -  { -    x = x || new BigInteger(SHA256(hex2a(salt + SHA256(I + ":" + pass))), 16); -    return x; +  this.calcX = function(salt) { +    return new BigInteger(SHA256(hex2a(salt + SHA256(I + ":" + pass))), 16);    };    this.getV = function(salt)    { -    V = V || this.getg().modPow(this.calcX(salt), this.getN()); -    return V; +    return this.getg().modPow(this.calcX(salt), this.getN());    }    // Calculate S, M, and M2  | 
