Class: Klay::Key::Decrypter

Inherits:
Object
  • Object
show all
Defined in:
lib/klay/key/decrypter.rb

Overview

The Decrypter class to handle PBKDF2-SHA-256 decryption.

Defined Under Namespace

Classes: DecrypterError

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(data, password) ⇒ Decrypter

Constructor of the Klay::Key::Decrypter class for secret key decryption. Should not be used; use perform instead.

Parameters:

  • data (JSON)

    encryption data including cypherkey.

  • password (String)

    password to decrypt the key.



40
41
42
43
44
# File 'lib/klay/key/decrypter.rb', line 40

def initialize(data, password)
  data = JSON.parse(data) if data.is_a? String
  @data = data
  @password = password
end

Class Method Details

.perform(data, password) ⇒ Klay::Key

Class method perform to perform an keystore decryption.

Parameters:

  • data (JSON)

    encryption data including cypherkey.

  • password (String)

    password to decrypt the key.

Returns:



30
31
32
# File 'lib/klay/key/decrypter.rb', line 30

def self.perform(data, password)
  new(data, password).perform
end

Instance Method Details

#performKlay::Key

Method to decrypt key using password.

Returns:



49
50
51
52
53
54
# File 'lib/klay/key/decrypter.rb', line 49

def perform
  derive_key password
  check_macs
  private_key = Util.bin_to_hex decrypted_data
  Klay::Key.new priv: private_key
end