diff options
author | Azul <azul@riseup.net> | 2012-10-03 16:59:46 +0200 |
---|---|---|
committer | Azul <azul@riseup.net> | 2012-10-03 16:59:46 +0200 |
commit | 4f57d8010a90fe1221c351f695d15d29a9cdc37f (patch) | |
tree | fd85a1db7a2d851a8227e566a406a62a2713e472 /lib/srp/client.rb | |
parent | 9683634eb18843151d318b483a5fb237508f4755 (diff) |
calculate verifiers and multiplier just like in py srpfeature-py_srp_compat
Some other parts are still missing. Main issue was using hashes of hex representation rather that hashes of byte arrays
Diffstat (limited to 'lib/srp/client.rb')
-rw-r--r-- | lib/srp/client.rb | 16 |
1 files changed, 8 insertions, 8 deletions
diff --git a/lib/srp/client.rb b/lib/srp/client.rb index 484d12b..37f37d7 100644 --- a/lib/srp/client.rb +++ b/lib/srp/client.rb @@ -7,10 +7,10 @@ module SRP attr_reader :salt, :verifier - def initialize(username, password) + def initialize(username, password, salt = nil) @username = username @password = password - @salt = "5d3055e0acd3ddcfc15".hex # bigrand(10).hex + @salt = salt.hex || bigrand(4).hex @multiplier = multiplier # let's cache it calculate_verifier end @@ -27,15 +27,15 @@ module SRP protected def calculate_verifier - x = calculate_x(@username, @password, @salt) - @verifier = modpow(GENERATOR, x, PRIME_N) + x = calculate_x + @verifier = modpow(GENERATOR, x, BIG_PRIME_N) @verifier end - def calculate_x(username, password, salt) - shex = '%x' % [salt] - spad = "" # if shex.length.odd? then '0' else '' end - sha256_str(spad + shex + sha256_str([username, password].join(':'))).hex + def calculate_x + shex = '%x' % [@salt] + inner = sha256_str([@username, @password].join(':')) + sha256_str([shex].pack('H*') + [inner].pack('H*')).hex end def calculate_client_s(x, a, bb, u) |