Sha256: 17ffe8a989de57de5c47c93b011e8763b2ec050c18f76bfe366b11cb9233e8c1

Contents?: true

Size: 494 Bytes

Versions: 1

Compression:

Stored size: 494 Bytes

Contents

module GostHmac
  class KdfTree256
    def self.generateKey(key_in, label, seed, num_R, out_len)
      n = out_len / 32
      if out_len % 32 > 0 then
        n += 1
      end
      buf = ''
      data = 0.chr * num_R + label + 0.chr + seed + (out_len / 32).chr + (out_len % 32).chr
      (0...n).each do |i|
        data[num_R-1] = (i+1).chr
        hmac = Hmac.new(key_in, 32).update(data).final
        buf += hmac
      end
      return buf[0...out_len]
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
gost_hmac-0.2.0 lib/gost_hmac/kdf_tree_256.rb