Class: Arver::LuksWrapper

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

Class Method Summary collapse

Class Method Details

.addKey(key_slot, partition) ⇒ Object



3
4
5
# File 'lib/arver/luks_wrapper.rb', line 3

def self.addKey( key_slot, partition )
  Arver::SSHCommandWrapper.create( "cryptsetup", [ "--batch-mode", "--key-slot=#{key_slot}", "luksAddKey", partition.device_path ], partition.parent, true )
end

.changeKey(key_slot, partition) ⇒ Object



6
7
8
# File 'lib/arver/luks_wrapper.rb', line 6

def self.changeKey( key_slot, partition )
  Arver::SSHCommandWrapper.create( "cryptsetup", [ "--batch-mode", "--key-slot=#{key_slot}", "luksChangeKey", partition.device_path ], partition.parent, true )
end

.close(partition) ⇒ Object



9
10
11
# File 'lib/arver/luks_wrapper.rb', line 9

def self.close( partition )
  Arver::SSHCommandWrapper.create( "cryptsetup", [ "luksClose", "#{partition.name}"], partition.parent, true )
end

.create(key_slot, partition) ⇒ Object



15
16
17
# File 'lib/arver/luks_wrapper.rb', line 15

def self.create( key_slot, partition )
  Arver::SSHCommandWrapper.create( "cryptsetup", [ "--batch-mode", "--key-slot=#{key_slot}", "--cipher=aes-cbc-essiv:sha256", "--key-size=256", "luksFormat", partition.device_path ], partition.parent, true )
end

.dump(partition) ⇒ Object



12
13
14
# File 'lib/arver/luks_wrapper.rb', line 12

def self.dump( partition )
  Arver::SSHCommandWrapper.create( "cryptsetup", [ "luksDump", partition.device_path ], partition.parent, true )
end

.killSlot(key_slot, partition) ⇒ Object



18
19
20
# File 'lib/arver/luks_wrapper.rb', line 18

def self.killSlot( key_slot, partition )
  Arver::SSHCommandWrapper.create( "cryptsetup", [ "--batch-mode", "luksKillSlot", partition.device_path, key_slot ], partition.parent, true )
end

.open(partition) ⇒ Object



21
22
23
# File 'lib/arver/luks_wrapper.rb', line 21

def self.open( partition )
  Arver::SSHCommandWrapper.create( "cryptsetup", [ "--batch-mode", "luksOpen", "-T 1", partition.device_path, partition.name ], partition.parent, true )
end

.open?(partition) ⇒ Boolean

Returns:

  • (Boolean)


24
25
26
# File 'lib/arver/luks_wrapper.rb', line 24

def self.open?( partition )
  Arver::SSHCommandWrapper.create( "test", [ "-b", "/dev/mapper/#{partition.name}" ], partition.parent, true )
end

.was_wrong_key?(command_wrapper) ⇒ Boolean

Returns:

  • (Boolean)


27
28
29
30
# File 'lib/arver/luks_wrapper.rb', line 27

def self.was_wrong_key?( command_wrapper )
  # before version 1.2 return value was 234
  command_wrapper.return_value == 234 || command_wrapper.return_value == 2
end