3 # Copyright (C) 2010 Red Hat Inc.
5 # This program is free software; you can redistribute it and/or modify
6 # it under the terms of the GNU General Public License as published by
7 # the Free Software Foundation; either version 2 of the License, or
8 # (at your option) any later version.
10 # This program is distributed in the hope that it will be useful,
11 # but WITHOUT ANY WARRANTY; without even the implied warranty of
12 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 # GNU General Public License for more details.
15 # You should have received a copy of the GNU General Public License
16 # along with this program; if not, write to the Free Software
17 # Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
19 # Test LUKS device creation, opening, key slots.
25 ../fish/guestfish --keys-from-stdin <<EOF
28 part-disk /dev/sda mbr
30 # Create LUKS device with key "key0" in slot 0.
31 luks-format /dev/sda1 0
35 luks-open /dev/sda1 lukstest
38 # Put some LVM structures on the encrypted device.
39 pvcreate /dev/mapper/lukstest
40 vgcreate VG /dev/mapper/lukstest
46 luks-close /dev/mapper/lukstest
48 # Add keys in other slots.
49 luks-add-key /dev/sda1 1
52 luks-add-key /dev/sda1 2
55 luks-add-key /dev/sda1 3
59 # Check we can open the device with one of the new keys.
60 luks-open /dev/sda1 lukstest
62 luks-close /dev/mapper/lukstest
63 luks-open /dev/sda1 lukstest
65 luks-close /dev/mapper/lukstest
68 luks-kill-slot /dev/sda1 1
71 # This is expected to fail.
72 -luks-open /dev/sda1 lukstest
76 luks-kill-slot /dev/sda1 3
78 luks-add-key /dev/sda1 3
82 luks-open /dev/sda1 lukstest
84 luks-close /dev/mapper/lukstest