Class: Reth::Keystore::PBKDF2
- Inherits:
-
Object
- Object
- Reth::Keystore::PBKDF2
- Defined in:
- lib/reth/keystore.rb
Instance Attribute Summary collapse
-
#name ⇒ Object
readonly
Returns the value of attribute name.
Instance Method Summary collapse
- #eval(pw) ⇒ Object
-
#initialize(params = nil) ⇒ PBKDF2
constructor
A new instance of PBKDF2.
- #mkparams ⇒ Object
Constructor Details
#initialize(params = nil) ⇒ PBKDF2
Returns a new instance of PBKDF2.
12 13 14 15 |
# File 'lib/reth/keystore.rb', line 12 def initialize(params=nil) @name = 'pbkdf2' @params = params || mkparams end |
Instance Attribute Details
#name ⇒ Object (readonly)
Returns the value of attribute name.
10 11 12 |
# File 'lib/reth/keystore.rb', line 10 def name @name end |
Instance Method Details
#eval(pw) ⇒ Object
17 18 19 20 21 22 23 24 25 |
# File 'lib/reth/keystore.rb', line 17 def eval(pw) OpenSSL::PKCS5.pbkdf2_hmac( pw, Utils.decode_hex(params[:salt]), params[:c], params[:dklen], 'SHA256' ) end |
#mkparams ⇒ Object
27 28 29 30 31 32 |
# File 'lib/reth/keystore.rb', line 27 def mkparams { prf: 'hmac-sha256', dklen: 32, c: 262144, salt: Utils.encode_hex(SecureRandom.random_bytes(16)) } end |