Skip to content
This repository has been archived by the owner on Aug 26, 2022. It is now read-only.

Commit

Permalink
Use some syntactic sugar that Ruby provides.
Browse files Browse the repository at this point in the history
  • Loading branch information
grempe committed May 15, 2016
1 parent 9069f21 commit b64d06d
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 5 deletions.
4 changes: 2 additions & 2 deletions lib/sirp/client.rb
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,13 @@ def process_challenge(username, password, xsalt, xbb)
bb = xbb.to_i(16)

# SRP-6a safety check
return false if (bb % @N) == 0
return false if (bb % @N).zero?

x = calc_x(username, password, xsalt, hash)
u = calc_u(@A, xbb, @N, hash)

# SRP-6a safety check
return false if u == 0
return false if u.zero?

# calculate session key
@S = num_to_hex(calc_client_S(bb, @a, @k, x, u, @N, @g))
Expand Down
2 changes: 1 addition & 1 deletion lib/sirp/sirp.rb
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ def H(hash_klass, n, *a)

hashin = a.map do |s|
next unless s
shex = (s.class == String) ? s : num_to_hex(s)
shex = s.is_a?(String) ? s : num_to_hex(s)
if shex.length > nlen
raise 'Bit width does not match - client uses different prime'
end
Expand Down
5 changes: 3 additions & 2 deletions lib/sirp/verifier.rb
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,8 @@ def generate_userauth(username, password)
# Parameters should be given in hex.
def get_challenge_and_proof(username, xverifier, xsalt, xaa)
# SRP-6a safety check
return false if (xaa.to_i(16) % @N) == 0
return false if (xaa.to_i(16) % @N).zero?

generate_B(xverifier)

{
Expand All @@ -45,7 +46,7 @@ def verify_session(proof, client_M)
u = calc_u(@A, @B, @N, hash)

# SRP-6a safety check
return false if u == 0
return false if u.zero?

# calculate session key
@S = num_to_hex(calc_server_S(@A.to_i(16), @b, v, u, @N))
Expand Down

0 comments on commit b64d06d

Please sign in to comment.