Skip to content

Commit

Permalink
refactor
Browse files Browse the repository at this point in the history
  • Loading branch information
jshawl committed Feb 6, 2024
1 parent ea2210e commit 2862d4b
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions lib/minisign/key_pair.rb
Original file line number Diff line number Diff line change
Expand Up @@ -13,16 +13,18 @@ def initialize(password = nil)
@checksum = blake2b256(key_data)
@keynum_sk = "#{key_id}#{signing_key.to_bytes}#{signing_key.verify_key.to_bytes}#{@checksum}"

@kdf_opslimit = [0, 0, 0, 2, 0, 0, 0, 0].pack('C*')
@kdf_memlimit = [0, 0, 0, 64, 0, 0, 0, 0].pack('C*')
kdf_opslimit_bytes = [0, 0, 0, 2, 0, 0, 0, 0]
kdf_memlimit_bytes = [0, 0, 0, 64, 0, 0, 0, 0]
@kdf_opslimit = kdf_opslimit_bytes.pack('C*')
@kdf_memlimit = kdf_memlimit_bytes.pack('C*')
@kdf_salt = SecureRandom.bytes(32)
if password
p @kdf_opslimit.unpack('N*').sum
kdf_output = derive_key(
password,
@kdf_salt,
[0, 0, 0, 2, 0, 0, 0, 0].pack("V*").unpack('N*').sum,
[0, 0, 0, 64, 0, 0, 0, 0].pack("V*").unpack('N*').sum
kdf_opslimit_bytes.pack("V*").unpack('N*').sum,
kdf_memlimit_bytes.pack("V*").unpack('N*').sum
)
p "kdf_output #{kdf_output}"
@keynum_sk = xor(kdf_output, @keynum_sk.bytes).pack("C*")
Expand Down

0 comments on commit 2862d4b

Please sign in to comment.