module JWA::Algorithms::KeyManagement::Pbes2
Public Class Methods
new(password, salt, iterations)
click to toggle source
# File lib/jwa/algorithms/key_management/pbes2.rb, line 5 def initialize(password, salt, iterations) salt = "#{self.class.alg_name}\x00#{salt}" @key = kdf.run(password, salt, iterations, self.class.key_length) end
Public Instance Methods
decrypt(ciphertext)
click to toggle source
# File lib/jwa/algorithms/key_management/pbes2.rb, line 15 def decrypt(ciphertext) self.class.kw_class.new(@key).decrypt(ciphertext) end
encrypt(plaintext)
click to toggle source
# File lib/jwa/algorithms/key_management/pbes2.rb, line 11 def encrypt(plaintext) self.class.kw_class.new(@key).encrypt(plaintext) end
Private Instance Methods
kdf()
click to toggle source
# File lib/jwa/algorithms/key_management/pbes2.rb, line 21 def kdf @_kdf ||= Support::PBKDF2.new(OpenSSL::Digest::SHA256.new) end