From 20bf14939fbd75e3ee0206c2bf14737e2c7ac2c2 Mon Sep 17 00:00:00 2001 From: Azul Date: Thu, 28 Jun 2012 19:43:40 +0200 Subject: adopted srp algo to srp-js way of doing things. all large integers are now send as hex strings. Using sha256_str all over the place. This finally gives me successful logins. Needs a log of cleanup never the less. --- lib/srp/client.rb | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) (limited to 'lib/srp/client.rb') diff --git a/lib/srp/client.rb b/lib/srp/client.rb index 9a27174..24d0c70 100644 --- a/lib/srp/client.rb +++ b/lib/srp/client.rb @@ -10,7 +10,8 @@ module SRP def initialize(username, password) @username = username @password = password - @salt = bigrand(10).hex + @salt = "5d3055e0acd3ddcfc15".hex # bigrand(10).hex + puts "salt = %i" %@salt @multiplier = multiplier # let's cache it calculate_verifier end @@ -27,13 +28,16 @@ module SRP protected def calculate_verifier x = calculate_x(@username, @password, @salt) + puts "x = %i" % x @verifier = modpow(GENERATOR, x, PRIME_N) + puts "verifier = %i" % @verifier + @verifier end def calculate_x(username, password, salt) shex = '%x' % [salt] - spad = if shex.length.odd? then '0' else '' end - sha256_hex(spad + shex + sha256_str([username, password].join(':'))).hex + spad = "" # if shex.length.odd? then '0' else '' end + sha256_str(spad + shex + sha256_str([username, password].join(':'))).hex end def calculate_client_s(x, a, bb, u) -- cgit v1.2.3