summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorAzul <azul@leap.se>2012-07-26 10:51:42 +0200
committerAzul <azul@leap.se>2012-07-26 10:51:42 +0200
commit7de7a78668a83eaab58597ce655ba613d4b477fb (patch)
tree0de1e7bb7af165eb8d165dc4ba296acb7850fdc0 /lib
parent1481331f3827711c16a3bcfb0ae0c6e4afd788d9 (diff)
turned server class into authentication module - test green, example broken
The example seems to be broken due to changes in srp-js
Diffstat (limited to 'lib')
-rw-r--r--lib/srp.rb2
-rw-r--r--lib/srp/authentication.rb (renamed from lib/srp/server.rb)12
2 files changed, 5 insertions, 9 deletions
diff --git a/lib/srp.rb b/lib/srp.rb
index 999f9b6..a008b82 100644
--- a/lib/srp.rb
+++ b/lib/srp.rb
@@ -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