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.
23 [ -n "$SKIP_TEST_LUKS_SH" ] && {
24 echo "test-luks.sh skipped (environment variable set)"
30 ../fish/guestfish --keys-from-stdin <<EOF
33 part-disk /dev/sda mbr
35 # Create LUKS device with key "key0" in slot 0.
36 luks-format /dev/sda1 0
40 luks-open /dev/sda1 lukstest
43 # Put some LVM structures on the encrypted device.
44 pvcreate /dev/mapper/lukstest
45 vgcreate VG /dev/mapper/lukstest
51 luks-close /dev/mapper/lukstest
53 # Add keys in other slots.
54 luks-add-key /dev/sda1 1
57 luks-add-key /dev/sda1 2
60 luks-add-key /dev/sda1 3
64 # Check we can open the device with one of the new keys.
65 luks-open /dev/sda1 lukstest
67 luks-close /dev/mapper/lukstest
68 luks-open /dev/sda1 lukstest
70 luks-close /dev/mapper/lukstest
73 luks-kill-slot /dev/sda1 1
76 # This is expected to fail.
77 -luks-open /dev/sda1 lukstest
81 luks-kill-slot /dev/sda1 3
83 luks-add-key /dev/sda1 3
87 luks-open /dev/sda1 lukstest
89 luks-close /dev/mapper/lukstest