summaryrefslogtreecommitdiff
path: root/lib/srp.js
diff options
context:
space:
mode:
Diffstat (limited to 'lib/srp.js')
-rw-r--r--lib/srp.js12
1 files changed, 8 insertions, 4 deletions
diff --git a/lib/srp.js b/lib/srp.js
index a5a2c14..8cb0c03 100644
--- a/lib/srp.js
+++ b/lib/srp.js
@@ -22,6 +22,8 @@ function SRP(remote)
var authenticated = false;
var I = document.getElementById("srp_username").value;
var p = document.getElementById("srp_password").value;
+ var V;
+ var salt;
remote = remote || plainXHR();
// *** Accessor methods ***
@@ -43,8 +45,9 @@ function SRP(remote)
};
// some 16 byte random number
- this.salt = function() {
- return new BigInteger(64, rng).toString(16);
+ this.getSalt = function() {
+ salt = salt || new BigInteger(64, rng).toString(16);
+ return salt
}
// Returns the BigInteger, g
@@ -65,9 +68,10 @@ function SRP(remote)
return new BigInteger(SHA256(s + SHA256(I + ":" + p)), 16);
};
- this.calcV = function(salt)
+ this.getV = function(salt)
{
- return this.getg().modPow(this.calcX(salt), this.getN());
+ V = V || this.getg().modPow(this.calcX(salt), this.getN());
+ return V;
}
// Check whether or not a variable is defined