Class: Argon2::Profiles

Inherits:
Object
  • Object
show all
Defined in:
lib/argon2/profiles.rb

Overview

Contains named profiles of different common cost parameter sets

Constant Summary collapse

RFC_9106_HIGH_MEMORY =

datatracker.ietf.org/doc/html/rfc9106#name-argon2-algorithm FIRST RECOMMENDED option per RFC 9106.

{
  t_cost: 1,
  m_cost: 21, # 2 GiB
  p_cost: 4
}.freeze
RFC_9106_LOW_MEMORY =

SECOND RECOMMENDED option per RFC 9106.

{
  t_cost: 3,
  m_cost: 16, # 64 MiB
  p_cost: 4
}.freeze
PRE_RFC_9106 =

The default values ruby-argon2 had before using RFC 9106 recommendations

{
  t_cost: 2,
  m_cost: 16, # 64 MiB
  p_cost: 1
}.freeze
UNSAFE_CHEAPEST =

Only use for fast testing. Insecure otherwise!

{
  t_cost: 1,
  m_cost: 3, # 8 KiB
  p_cost: 1
}.freeze

Class Method Summary collapse

Class Method Details

.[](name) ⇒ Object

Raises:

  • (NotImplementedError)


6
7
8
9
10
11
# File 'lib/argon2/profiles.rb', line 6

def self.[](name)
  name = name.upcase.to_sym
  raise NotImplementedError unless const_defined?(name)

  const_get(name)
end

.to_aObject



13
14
15
# File 'lib/argon2/profiles.rb', line 13

def self.to_a
  constants.map(&:downcase)
end

.to_hObject



17
18
19
# File 'lib/argon2/profiles.rb', line 17

def self.to_h
  to_a.reduce({}) { |h, name| h.update(name => self[name]) }
end