Class: EncryptionKeyItem

Inherits:
Object
  • Object
show all
Defined in:
lib/encryption_key.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(hash_) ⇒ EncryptionKeyItem

Returns a new instance of EncryptionKeyItem.



22
23
24
# File 'lib/encryption_key.rb', line 22

def initialize(hash_)
	@identifier, @data, @validation, @iterations, @level = hash_.values_at("identifier", "data", "validation", "iterations", "level")
end

Instance Attribute Details

#decrypted_master_keyObject (readonly)

Returns the value of attribute decrypted_master_key.



20
21
22
# File 'lib/encryption_key.rb', line 20

def decrypted_master_key
  @decrypted_master_key
end

#identifierObject (readonly)

Returns the value of attribute identifier.



20
21
22
# File 'lib/encryption_key.rb', line 20

def identifier
  @identifier
end

#levelObject (readonly)

Returns the value of attribute level.



20
21
22
# File 'lib/encryption_key.rb', line 20

def level
  @level
end

Instance Method Details

#unlock(password) ⇒ Object



26
27
28
29
30
31
# File 'lib/encryption_key.rb', line 26

def unlock(password)
	@decrypted_master_key = Decrypt.decrypt_pbkdf2(password, @data, @iterations)
	return false unless @decrypted_master_key
	validation_key = Decrypt.decrypt_ssl(@decrypted_master_key, @validation)
	@decrypted_master_key == validation_key
end