Class: Enigma::Verifier

Inherits:
Object
  • Object
show all
Defined in:
lib/enigma/verifier.rb

Overview

Verifies the password by comparing it with the stored hash.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(password_to_check:, target_salt_base64:, stored_hash_base64:) ⇒ Verifier

Returns a new instance of Verifier.



25
26
27
28
29
30
31
32
33
34
35
36
37
# File 'lib/enigma/verifier.rb', line 25

def initialize(password_to_check:, target_salt_base64:, stored_hash_base64:)
  check_args(password_to_check, target_salt_base64, stored_hash_base64, Enigma.base64_signer_key,
             Enigma.base64_salt_separator,
             Enigma.rounds, Enigma.mem_cost)

  @password_to_check = password_to_check
  @target_salt_base64 = target_salt_base64
  @stored_hash_base64 = stored_hash_base64
  @base64_signer_key = Enigma.base64_signer_key
  @base64_salt_separator = Enigma.base64_salt_separator
  @rounds = Enigma.rounds
  @mem_cost = Enigma.mem_cost
end

Instance Attribute Details

#base64_salt_separatorString (readonly)

Returns The base64-encoded salt separator.

Returns:

  • (String)

    The base64-encoded salt separator.



25
26
27
28
29
30
31
32
33
34
35
36
37
# File 'lib/enigma/verifier.rb', line 25

def initialize(password_to_check:, target_salt_base64:, stored_hash_base64:)
  check_args(password_to_check, target_salt_base64, stored_hash_base64, Enigma.base64_signer_key,
             Enigma.base64_salt_separator,
             Enigma.rounds, Enigma.mem_cost)

  @password_to_check = password_to_check
  @target_salt_base64 = target_salt_base64
  @stored_hash_base64 = stored_hash_base64
  @base64_signer_key = Enigma.base64_signer_key
  @base64_salt_separator = Enigma.base64_salt_separator
  @rounds = Enigma.rounds
  @mem_cost = Enigma.mem_cost
end

#base64_signer_keyString (readonly)

Returns The base64-encoded signer key.

Returns:

  • (String)

    The base64-encoded signer key.



25
26
27
28
29
30
31
32
33
34
35
36
37
# File 'lib/enigma/verifier.rb', line 25

def initialize(password_to_check:, target_salt_base64:, stored_hash_base64:)
  check_args(password_to_check, target_salt_base64, stored_hash_base64, Enigma.base64_signer_key,
             Enigma.base64_salt_separator,
             Enigma.rounds, Enigma.mem_cost)

  @password_to_check = password_to_check
  @target_salt_base64 = target_salt_base64
  @stored_hash_base64 = stored_hash_base64
  @base64_signer_key = Enigma.base64_signer_key
  @base64_salt_separator = Enigma.base64_salt_separator
  @rounds = Enigma.rounds
  @mem_cost = Enigma.mem_cost
end

#mem_costInteger (readonly)

Returns The memory cost used for password hashing.

Returns:

  • (Integer)

    The memory cost used for password hashing.



25
26
27
28
29
30
31
32
33
34
35
36
37
# File 'lib/enigma/verifier.rb', line 25

def initialize(password_to_check:, target_salt_base64:, stored_hash_base64:)
  check_args(password_to_check, target_salt_base64, stored_hash_base64, Enigma.base64_signer_key,
             Enigma.base64_salt_separator,
             Enigma.rounds, Enigma.mem_cost)

  @password_to_check = password_to_check
  @target_salt_base64 = target_salt_base64
  @stored_hash_base64 = stored_hash_base64
  @base64_signer_key = Enigma.base64_signer_key
  @base64_salt_separator = Enigma.base64_salt_separator
  @rounds = Enigma.rounds
  @mem_cost = Enigma.mem_cost
end

#password_to_checkString (readonly)

Returns The password to be checked.

Returns:

  • (String)

    The password to be checked.



25
26
27
28
29
30
31
32
33
34
35
36
37
# File 'lib/enigma/verifier.rb', line 25

def initialize(password_to_check:, target_salt_base64:, stored_hash_base64:)
  check_args(password_to_check, target_salt_base64, stored_hash_base64, Enigma.base64_signer_key,
             Enigma.base64_salt_separator,
             Enigma.rounds, Enigma.mem_cost)

  @password_to_check = password_to_check
  @target_salt_base64 = target_salt_base64
  @stored_hash_base64 = stored_hash_base64
  @base64_signer_key = Enigma.base64_signer_key
  @base64_salt_separator = Enigma.base64_salt_separator
  @rounds = Enigma.rounds
  @mem_cost = Enigma.mem_cost
end

#roundsInteger (readonly)

Returns The number of rounds used for password hashing.

Returns:

  • (Integer)

    The number of rounds used for password hashing.



25
26
27
28
29
30
31
32
33
34
35
36
37
# File 'lib/enigma/verifier.rb', line 25

def initialize(password_to_check:, target_salt_base64:, stored_hash_base64:)
  check_args(password_to_check, target_salt_base64, stored_hash_base64, Enigma.base64_signer_key,
             Enigma.base64_salt_separator,
             Enigma.rounds, Enigma.mem_cost)

  @password_to_check = password_to_check
  @target_salt_base64 = target_salt_base64
  @stored_hash_base64 = stored_hash_base64
  @base64_signer_key = Enigma.base64_signer_key
  @base64_salt_separator = Enigma.base64_salt_separator
  @rounds = Enigma.rounds
  @mem_cost = Enigma.mem_cost
end

#stored_hash_base64String (readonly)

Returns The base64-encoded stored hash.

Returns:

  • (String)

    The base64-encoded stored hash.



25
26
27
28
29
30
31
32
33
34
35
36
37
# File 'lib/enigma/verifier.rb', line 25

def initialize(password_to_check:, target_salt_base64:, stored_hash_base64:)
  check_args(password_to_check, target_salt_base64, stored_hash_base64, Enigma.base64_signer_key,
             Enigma.base64_salt_separator,
             Enigma.rounds, Enigma.mem_cost)

  @password_to_check = password_to_check
  @target_salt_base64 = target_salt_base64
  @stored_hash_base64 = stored_hash_base64
  @base64_signer_key = Enigma.base64_signer_key
  @base64_salt_separator = Enigma.base64_salt_separator
  @rounds = Enigma.rounds
  @mem_cost = Enigma.mem_cost
end

#target_salt_base64String (readonly)

Returns The base64-encoded user salt.

Returns:

  • (String)

    The base64-encoded user salt.



25
26
27
28
29
30
31
32
33
34
35
36
37
# File 'lib/enigma/verifier.rb', line 25

def initialize(password_to_check:, target_salt_base64:, stored_hash_base64:)
  check_args(password_to_check, target_salt_base64, stored_hash_base64, Enigma.base64_signer_key,
             Enigma.base64_salt_separator,
             Enigma.rounds, Enigma.mem_cost)

  @password_to_check = password_to_check
  @target_salt_base64 = target_salt_base64
  @stored_hash_base64 = stored_hash_base64
  @base64_signer_key = Enigma.base64_signer_key
  @base64_salt_separator = Enigma.base64_salt_separator
  @rounds = Enigma.rounds
  @mem_cost = Enigma.mem_cost
end

Instance Method Details

#verifyObject



39
40
41
# File 'lib/enigma/verifier.rb', line 39

def verify
  verify_password
end