diff options
Diffstat (limited to 'lib')
-rw-r--r-- | lib/srp.rb | 2 | ||||
-rw-r--r-- | lib/srp/authentication.rb (renamed from lib/srp/server.rb) | 12 |
2 files changed, 5 insertions, 9 deletions
@@ -9,5 +9,5 @@ $:.unshift File.dirname(__FILE__) module SRP autoload :Client, 'srp/client' - autoload :Server, 'srp/server' + autoload :Authentication, 'srp/authentication' end diff --git a/lib/srp/server.rb b/lib/srp/authentication.rb index 30f5088..1f36dd7 100644 --- a/lib/srp/server.rb +++ b/lib/srp/authentication.rb @@ -1,27 +1,23 @@ require File.expand_path(File.dirname(__FILE__) + '/util') module SRP - class Server + module Authentication include Util - def initialize(salt, verifier) - @salt = salt - @verifier = verifier - end def initialize_auth(aa) @aa = aa @b = bigrand(32).hex # B = g^b + k v (mod N) - @bb = (modpow(GENERATOR, @b, PRIME_N) + multiplier * @verifier) % PRIME_N + @bb = (modpow(GENERATOR, @b, PRIME_N) + multiplier * verifier) % PRIME_N u = calculate_u(@aa, @bb, PRIME_N) return @bb, u end def authenticate(m) u = calculate_u(@aa, @bb, PRIME_N) - base = (modpow(@verifier, u, PRIME_N) * @aa) % PRIME_N + base = (modpow(verifier, u, PRIME_N) * @aa) % PRIME_N server_s = modpow(base, @b, PRIME_N) if(m == calculate_m(@aa, @bb, server_s)) return calculate_m(@aa, m, server_s) @@ -40,8 +36,8 @@ module SRP + '0' * (nlen - bbhex.length) + bbhex sha256_str(hashin).hex end - end + end |