From da8f6025900740684bc81e9a7c22f6a83ed48d79 Mon Sep 17 00:00:00 2001 From: Azul Date: Sat, 4 Aug 2012 16:41:01 +0200 Subject: started implementing a restful signup --- lib/srp.js | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) (limited to 'lib/srp.js') 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 -- cgit v1.2.3