File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1010module Argon2
1111 # Front-end API for the Argon2 module.
1212 class Password
13+ # Expose constants for the options supported and default used for passwords.
14+ DEFAULT_T_COST = 2
15+ DEFAULT_M_COST = 16
16+ DEFAULT_P_COST = 1
17+ MIN_T_COST = 1
18+ MAX_T_COST = 750
19+ MIN_M_COST = 1
20+ MAX_M_COST = 31
21+ MIN_P_COST = 1
22+ MAX_P_COST = 8
23+
1324 def initialize ( options = { } )
14- @t_cost = options [ :t_cost ] || 2
15- raise ArgonHashFail , "Invalid t_cost" if @t_cost < 1 || @t_cost > 750
25+ @t_cost = options [ :t_cost ] || DEFAULT_T_COST
26+ raise ArgonHashFail , "Invalid t_cost" if @t_cost < MIN_T_COST || @t_cost > MAX_T_COST
1627
17- @m_cost = options [ :m_cost ] || 16
18- raise ArgonHashFail , "Invalid m_cost" if @m_cost < 1 || @m_cost > 31
28+ @m_cost = options [ :m_cost ] || DEFAULT_M_COST
29+ raise ArgonHashFail , "Invalid m_cost" if @m_cost < MIN_M_COST || @m_cost > MAX_M_COST
1930
20- @p_cost = options [ :p_cost ] || 1
21- raise ArgonHashFail , "Invalid p_cost" if @p_cost < 1 || @p_cost > 8
31+ @p_cost = options [ :p_cost ] || DEFAULT_P_COST
32+ raise ArgonHashFail , "Invalid p_cost" if @p_cost < MIN_P_COST || @p_cost > MAX_P_COST
2233
2334 @salt_do_not_supply = options [ :salt_do_not_supply ]
2435 @secret = options [ :secret ]
You can’t perform that action at this time.
0 commit comments