diff options
author | Azul <azul@leap.se> | 2012-07-20 14:21:22 +0200 |
---|---|---|
committer | Azul <azul@leap.se> | 2012-07-20 14:21:22 +0200 |
commit | 8fa0825e28828a4bd1c28b5e467578498ba54b43 (patch) | |
tree | f8620ca7da0f632c94ec2e4c687863bdf72b2fbf /lib | |
parent | fcb9e65af31569db33c198217df816971f2f20cd (diff) |
calcV to calculate verifier, do not use srp_url or srp_server anymore
We can easily overwrite the corresponding functions
Diffstat (limited to 'lib')
-rw-r--r-- | lib/srp.js | 29 | ||||
-rw-r--r-- | lib/srp_register.js | 3 |
2 files changed, 15 insertions, 17 deletions
@@ -18,8 +18,6 @@ function SRP() var K = null; var M = null; var M2 = null; - var url = document.getElementById("srp_url").value; - var server = document.getElementById("srp_server").value; var that = this; var authenticated = false; var I = document.getElementById("srp_username").value; @@ -50,11 +48,12 @@ function SRP() return xhr; }; - // Returns the base URL + // Returns the base URL - overwrite to use a different one this.geturl = function() { - return url; + return ""; }; + // Returns the BigInteger, g this.getg = function() { @@ -73,15 +72,15 @@ function SRP() return new BigInteger(SHA256(s + SHA256(I + ":" + p)), 16); }; - // Translates the django path to PHP and ASP.NET paths + this.calcV = function(salt) + { + return this.getg().modPow(this.calcX(salt), this.getN()); + } + + // Overwrite this if you want to change the paths this.paths = function(str) { - // For now, str will be the django path - // This function will translate for other backends. - if(server == "django") - { - return str; - } + return str; }; // Check whether or not a variable is defined @@ -174,7 +173,7 @@ function SRP() // Start the login process by identifying the user this.identify = function() { - var handshake_url = url + that.paths("handshake/"); + var handshake_url = that.geturl() + that.paths("handshake/"); var params = "I="+I+"&A="+Astr; that.ajaxRequest(handshake_url, params, receive_salts); }; @@ -194,7 +193,7 @@ function SRP() else if(!response.a) { calculations(response.s, response.B, p); - that.ajaxRequest(url+that.paths("authenticate/"), "M="+M, confirm_authentication); + that.ajaxRequest(that.geturl()+that.paths("authenticate/"), "M="+M, confirm_authentication); } // If there is an algorithm specified, start the login process else { @@ -263,7 +262,7 @@ function SRP() hashfun = MD5; //alert(hashfun(dsalt+p)); calculations(s, ephemeral, hashfun(dsalt+p)); - that.ajaxRequest(url+that.paths("upgrade/authenticate/"), "M="+M, confirm_upgrade); + that.ajaxRequest(that.geturl()+that.paths("upgrade/authenticate/"), "M="+M, confirm_upgrade); }; window.setTimeout(do_upgrade,10); }; @@ -292,7 +291,7 @@ function SRP() if(response.M == M2) { K = SHA256(S.toString(16)); - var auth_url = url + that.paths("upgrade/verifier/"); + var auth_url = that.geturl() + that.paths("upgrade/verifier/"); that.ajaxRequest(auth_url, "p="+encrypt(p)+"&l="+p.length, confirm_verifier); } else diff --git a/lib/srp_register.js b/lib/srp_register.js index 3966d79..1666476 100644 --- a/lib/srp_register.js +++ b/lib/srp_register.js @@ -17,8 +17,7 @@ function SRP_REGISTER() if(response.salt) { var s = response.salt; - var x = that.calcX(s); - var v = that.getg().modPow(x, that.getN()); + var v = that.calcV(s); that.register_send_verifier(v.toString(16)); } else if(response.error) |