class JWA::Support::ConcatKDF
Public Class Methods
new(hash)
click to toggle source
# File lib/jwa/support/concat_kdf.rb, line 4 def initialize(hash) @hash = hash @default_key_len = hash.size * 8 end
Public Instance Methods
derive_key(reps, key_data_len, z, other_info)
click to toggle source
# File lib/jwa/support/concat_kdf.rb, line 16 def derive_key(reps, key_data_len, z, other_info) key_material = '' data = z + other_info (1..reps).each do |n| concatenation = [n, data].pack('Na*') key_material += @hash.digest(concatenation) end key_material[0...key_data_len / 8] end
run(z, other_info, key_data_len = nil)
click to toggle source
# File lib/jwa/support/concat_kdf.rb, line 9 def run(z, other_info, key_data_len = nil) key_data_len ||= @default_key_len reps = (key_data_len / @default_key_len.to_f).ceil derive_key(reps, key_data_len, z, other_info) end