Class: SRP::Client

Inherits:
Object
  • Object
show all
Includes:
Util
Defined in:
lib/srp/client.rb

Constant Summary

Constants included from Util

Util::BIG_PRIME_N, Util::GENERATOR, Util::PRIME_N

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Util

#bigrand, #hn_xor_hg, #modpow, #multiplier, #sha256_hex, #sha256_int, #sha256_str

Constructor Details

#initialize(username, options) ⇒ Client

Returns a new instance of Client.



8
9
10
11
12
13
14
15
16
17
18
# File 'lib/srp/client.rb', line 8

def initialize(username, options)
  @username = username
  if options[:password]
    @password = options[:password]
    @salt = options[:salt] || bigrand(4).hex
    calculate_verifier
  else
    @verifier = options[:verifier]
    @salt = options[:salt]
  end
end

Instance Attribute Details

#saltObject (readonly)

Returns the value of attribute salt.



6
7
8
# File 'lib/srp/client.rb', line 6

def salt
  @salt
end

#usernameObject (readonly)

Returns the value of attribute username.



6
7
8
# File 'lib/srp/client.rb', line 6

def username
  @username
end

#verifierObject (readonly)

Returns the value of attribute verifier.



6
7
8
# File 'lib/srp/client.rb', line 6

def verifier
  @verifier
end

Instance Method Details

#authenticate(server) ⇒ Object



20
21
22
23
24
# File 'lib/srp/client.rb', line 20

def authenticate(server)
  @session = SRP::Session.new(self)
  @session.handshake(server)
  @session.validate(server)
end

#private_keyObject



26
27
28
# File 'lib/srp/client.rb', line 26

def private_key
  @private_key ||= calculate_private_key
end