summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--lib/srp/session.rb15
1 files changed, 14 insertions, 1 deletions
diff --git a/lib/srp/session.rb b/lib/srp/session.rb
index db8d428..7b0331a 100644
--- a/lib/srp/session.rb
+++ b/lib/srp/session.rb
@@ -27,12 +27,24 @@ module SRP
def authenticate(m)
if(m == calculate_m(server_secret))
- return calculate_m2
+ return @m2 = calculate_m2
+ end
+ end
+
+ def to_json(options={})
+ if @m2
+ { :M2 => @m2.to_s(16) }.to_json(options)
+ else
+ { :B => bb.to_s(16),
+# :b => @b.to_s(16), # only use for debugging
+ :salt => @user.salt.to_s(16)
+ }.to_json(options)
end
end
protected
+
# only seed b for testing purposes.
def initialize_server(aa, b = nil)
@aa = aa
@@ -80,6 +92,7 @@ module SRP
def calculate_u
sha256_int(@aa, @bb).hex
end
+
end
end