From cb8e9f7b3dec1963e0d985b1b2541b260a132762 Mon Sep 17 00:00:00 2001 From: Azul Date: Mon, 15 Oct 2012 12:54:24 +0200 Subject: expecting the salt to be send with key salt --- src/srp.js | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) (limited to 'src/srp.js') diff --git a/src/srp.js b/src/srp.js index 972b211..b348e69 100644 --- a/src/srp.js +++ b/src/srp.js @@ -19,9 +19,14 @@ function SRP(remote, session) // B = 0 will make the algorithm always succeed // -> refuse such a server answer if(response.B === 0) { - srp.error("Server send random number 0 - this is not allowed"); - } else { - session.calculations(response.s, response.B); + srp.error("Server send random number 0 - could not login."); + } + else if(! response.salt || response.salt === 0) { + srp.error("Server failed to send salt - could not login."); + } + else + { + session.calculations(response.salt, response.B); remote.authenticate(session, confirm_authentication); } } -- cgit v1.2.3 From d21474a0290edab1c765741d484335d83f50be75 Mon Sep 17 00:00:00 2001 From: Azul Date: Tue, 16 Oct 2012 17:24:12 +0200 Subject: use M2 as the key for the server auth --- src/srp.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/srp.js') diff --git a/src/srp.js b/src/srp.js index b348e69..e66c2fa 100644 --- a/src/srp.js +++ b/src/srp.js @@ -35,7 +35,7 @@ function SRP(remote, session) // If an error occurs, raise it as an alert. function confirm_authentication(response) { - if (session.validate(response.M)) + if (session.validate(response.M2)) srp.success(); else srp.error("Server key does not match"); -- cgit v1.2.3 From 5a0ceeb1ca0055719a9b8977a799362163955766 Mon Sep 17 00:00:00 2001 From: Azul Date: Wed, 17 Oct 2012 12:06:37 +0200 Subject: hand success and error messages to identify by default also cleaned up some other parts that were not needed anymore --- src/srp.js | 16 +++++----------- 1 file changed, 5 insertions(+), 11 deletions(-) (limited to 'src/srp.js') diff --git a/src/srp.js b/src/srp.js index e66c2fa..c986443 100644 --- a/src/srp.js +++ b/src/srp.js @@ -9,8 +9,10 @@ function SRP(remote, session) this.session = session; // Start the login process by identifying the user - this.identify = function() + this.identify = function(success, error) { + srp.success = success; + srp.error = error; remote.handshake(session, receive_salts); // Receive login salts from the server, start calculations @@ -64,18 +66,10 @@ function SRP(remote, session) }; // This function is called when authentication is successful. - // Developers can set this to other functions in specific implementations - // and change the functionality. + // It's a dummy. Please hand the real thing to the call to identify. this.success = function() { - var forward_url = document.getElementById("srp_forward").value; - if(forward_url.charAt(0) != "#") - window.location = forward_url; - else - { - window.location = forward_url; - alert("Login successful."); - } + alert("Login successful."); }; }; -- cgit v1.2.3 From 8c1cc0f4903b1b6eabffe6681744ea02a870af7f Mon Sep 17 00:00:00 2001 From: Azul Date: Fri, 19 Oct 2012 17:49:53 +0200 Subject: added success and error callbacks to register --- src/srp.js | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) (limited to 'src/srp.js') diff --git a/src/srp.js b/src/srp.js index c986443..7060598 100644 --- a/src/srp.js +++ b/src/srp.js @@ -11,8 +11,7 @@ function SRP(remote, session) // Start the login process by identifying the user this.identify = function(success, error) { - srp.success = success; - srp.error = error; + store_callbacks(success, error); remote.handshake(session, receive_salts); // Receive login salts from the server, start calculations @@ -45,8 +44,9 @@ function SRP(remote, session) }; // Initiate the registration process - this.register = function() + this.register = function(success, error) { + store_callbacks(success, error); remote.register(session, srp.registered_user); }; @@ -71,5 +71,14 @@ function SRP(remote, session) { alert("Login successful."); }; + + function store_callbacks(success, error) { + if (typeof success == "function") { + srp.success = success; + } + if (typeof error == "function") { + srp.error = error; + } + } }; -- cgit v1.2.3 From 23350b54ec2723e1b2e333626567c9fe9d1e2644 Mon Sep 17 00:00:00 2001 From: Azul Date: Fri, 19 Oct 2012 18:01:04 +0200 Subject: don't expect create to return an ok * it returns the user * it will return errors if sth. goes wrong. --- src/srp.js | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'src/srp.js') diff --git a/src/srp.js b/src/srp.js index 7060598..6d1e8c1 100644 --- a/src/srp.js +++ b/src/srp.js @@ -53,8 +53,10 @@ function SRP(remote, session) // The user has been registered successfully, now login this.registered_user = function(response) { - if(response.ok) - { + if(response.errors) { + srp.error(response.errors) + } + else { srp.identify(); } }; -- cgit v1.2.3