Class: UniversaTools::KeyRing::KeyRecord

Inherits:
Struct
  • Object
show all
Defined in:
lib/universa_tools/keyring.rb

Overview

The record class that hold key, tag and associated information inside the ring

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#dataObject

Returns the value of attribute data

Returns:

  • (Object)

    the current value of data



25
26
27
# File 'lib/universa_tools/keyring.rb', line 25

def data
  @data
end

#file_nameObject

Returns the value of attribute file_name

Returns:

  • (Object)

    the current value of file_name



25
26
27
# File 'lib/universa_tools/keyring.rb', line 25

def file_name
  @file_name
end

#keyObject

Returns the value of attribute key

Returns:

  • (Object)

    the current value of key



25
26
27
# File 'lib/universa_tools/keyring.rb', line 25

def key
  @key
end

#tagObject

Returns the value of attribute tag

Returns:

  • (Object)

    the current value of tag



25
26
27
# File 'lib/universa_tools/keyring.rb', line 25

def tag
  @tag
end

Class Method Details

.load(main_key, file_name) ⇒ Object



30
31
32
33
34
# File 'lib/universa_tools/keyring.rb', line 30

def self.load(main_key, file_name)
  code, tag, packed, data = open(file_name, 'rb') { |f| Boss.load(main_key.etaDecrypt(f.read)) }
  code != 0 and raise IOError, "unsupported record format #{code}"
  KeyRecord.new(tag, Universa::PrivateKey.from_packed(packed), data, file_name)
end

Instance Method Details

#save(main_key) ⇒ Object



26
27
28
# File 'lib/universa_tools/keyring.rb', line 26

def save(main_key)
  open(file_name, 'wb') { |f| f << main_key.etaEncrypt(Boss.dump([0, tag, key.pack, data])) }
end