From 95df478b7d3f62e2893499aa7a801b0cacb19dcd Mon Sep 17 00:00:00 2001 From: Azul Date: Wed, 27 Jun 2012 15:08:41 +0200 Subject: moved to ajax workflow and integrated srp-js - not quite there yet * needs a bit of cleanup from the old workflow * are client and server using the same primes right now? * store multiple users on the server side --- lib/srp/server.rb | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) (limited to 'lib/srp/server.rb') diff --git a/lib/srp/server.rb b/lib/srp/server.rb index a1189a1..79d1b75 100644 --- a/lib/srp/server.rb +++ b/lib/srp/server.rb @@ -18,11 +18,13 @@ module SRP return @bb, u end - def authenticate(aa, client_s) + def authenticate(aa, m) u = calculate_u(aa, @bb, PRIME_N) base = (modpow(@verifier, u, PRIME_N) * aa) % PRIME_N server_s = modpow(base, @b, PRIME_N) - return client_s == server_s + if(m == calculate_m(aa, @bb, server_s)) + return calculate_m(aa, m, server_s) + end end @@ -34,8 +36,15 @@ module SRP bbhex = '%x' % [bb] hashin = '0' * (nlen - aahex.length) + aahex \ + '0' * (nlen - bbhex.length) + bbhex - sha1_hex(hashin).hex + sha256_hex(hashin).hex end + + def calculate_m(aa, bb, s) + # todo: we might want to 0fill this like for u + hashin = '%x%x%x' % [aa, bb, s] + sha256_hex(hashin).hex + end + end end -- cgit v1.2.3