Debian Codegraph @

tests/compat-test

raw symbols SCIP
1 #!/bin/bashscip-shell filesystem . . `/bin/bash`.
2
3 PS4='$LINENO:'
4 [scip-shell system . . `[`. -z "$CRYPTSETUP_PATH" ] && CRYPTSETUP_PATH=".."
5 CRYPTSETUP=$CRYPTSETUP_PATH/cryptsetup
6 CRYPTSETUP_RAW=$CRYPTSETUP
7 CRYPTOCHECK=./crypto-check
8
9 if [scip-shell system . . `[`. -n "$CRYPTSETUP_TESTS_RUN_IN_MESON" ]; then
10 CRYPTSETUP_VALGRIND=$CRYPTSETUP
11 else
12 CRYPTSETUP_VALGRIND=../.libs/cryptsetup
13 CRYPTSETUP_LIB_VALGRIND=../.libs
14 fi
15
16 DIFFER=./differ
17 DEV_NAME=dummy
18 DEV_NAME2=dummy2
19 DEV_NAME3=dummy3
20 ORIG_IMG=luks-test-orig
21 IMG=luks-test
22 IMG10=luks-test-v10
23 HEADER_IMG=luks-header
24 KEY1=key1
25 KEY2=key2
26 KEY5=key5
27 KEYE=keye
28 KEY_TZERO=key_trailing_zero
29 KEY_HALF_ZERO=key_half_zeroes
30 PWD0="compatkey"
31 PWD1="93R4P4pIqAH8"
32 PWD2="mymJeD8ivEhE"
33 PWD3="ocMakf3fAcQO"
34 PWDW="rUkL4RUryBom"
35 VK_FILE="compattest_vkfile"
36
37 FAST_PBKDF_OPT="--pbkdf pbkdf2 --pbkdf-force-iterations 1000"
38 PLAIN_OPT="--hash sha256 --cipher aes-cbc-essiv:sha256 --key-size 256"
39
40 LUKS_HEADER="S0-5 S6-7 S8-39 S40-71 S72-103 S104-107 S108-111 R112-131 R132-163 S164-167 S168-207 A0-591"
41 KEY_SLOT0="S208-211 S212-215 R216-247 A248-251 A251-255"
42 KEY_MATERIAL0="R4096-68096"
43 KEY_MATERIAL0_EXT="R4096-68096"
44
45 KEY_SLOT1="S256-259 S260-263 R264-295 A296-299 A300-303"
46 KEY_MATERIAL1="R69632-133632"
47 KEY_MATERIAL1_EXT="S69632-133632"
48
49 KEY_SLOT5="S448-451 S452-455 R456-487 A488-491 A492-495"
50 KEY_MATERIAL5="R331776-395264"
51 KEY_MATERIAL5_EXT="S331776-395264"
52
53 TEST_UUID="12345678-1234-1234-1234-123456789abc"
54
55 LOOPDEV=$(losetupscip-shell system . . losetup. -f 2>/dev/nullscip-shell filesystem . . `/dev/null`.)
56 FIPS_MODE=$(catscip-shell system . . cat. /proc/sys/crypto/fips_enabledscip-shell filesystem . . `/proc/sys/crypto/fips_enabled`. 2>/dev/nullscip-shell filesystem . . `/dev/null`.)
57
58 remove_mappingscip-shell shell shell-project 0.0.0 remove_mapping().()
59 {
60 [scip-shell system . . `[`. -b /dev/mapper/$DEV_NAME3 ] && dmsetup remove --retry $DEV_NAME3 >/dev/nullscip-shell filesystem . . `/dev/null`. 2>&1
61 [scip-shell system . . `[`. -b /dev/mapper/$DEV_NAME2 ] && dmsetup remove --retry $DEV_NAME2 >/dev/nullscip-shell filesystem . . `/dev/null`. 2>&1
62 [scip-shell system . . `[`. -b /dev/mapper/$DEV_NAME ] && dmsetup remove --retry $DEV_NAME >/dev/nullscip-shell filesystem . . `/dev/null`. 2>&1
63 losetupscip-shell system . . losetup. -d $LOOPDEV >/dev/nullscip-shell filesystem . . `/dev/null`. 2>&1
64 rmscip-shell system . . rm. -f $ORIG_IMG $IMG $IMG10 $KEY1 $KEY2 $KEY5 $KEYE $KEY_TZERO $KEY_HALF_ZERO $HEADER_IMG $VK_FILE missing-file >/dev/nullscip-shell filesystem . . `/dev/null`. 2>&1
65 rmmod scsi_debug >/dev/nullscip-shell filesystem . . `/dev/null`. 2>&1
66 scsi_debug_teardownscip-shell shell shell-project 0.0.0 scsi_debug_teardown(). $DEV
67 }
68
69 force_ueventscip-shell shell shell-project 0.0.0 force_uevent().()
70 {
71 DNAME=$(echoscip-shell system . . echo. $LOOPDEV | cutscip-shell system . . cut. -f3 -d /scip-shell filesystem . . `/`.)
72 echoscip-shell system . . echo. "change" >/sys/block/$DNAME/uevent
73 }
74
75 failscip-shell shell shell-project 0.0.0 fail().()
76 {
77 [scip-shell system . . `[`. -n "$1" ] && echoscip-shell system . . echo. "$1"
78 remove_mappingscip-shell shell shell-project 0.0.0 remove_mapping().
79 echoscip-shell system . . echo. "FAILED backtrace:"
80 while caller $frame; do ((frame++)); done
81 exit 2
82 }
83
84 _sigchldscip-shell shell shell-project 0.0.0 _sigchld().() { local c=$?; [scip-shell system . . `[`. $c -eq 139 ] && failscip-shell shell shell-project 0.0.0 fail(). "Segfault"; [scip-shell system . . `[`. $c -eq 134 ] && failscip-shell shell shell-project 0.0.0 fail(). "Aborted"; }
85 trap _sigchld CHLD
86
87 fips_modescip-shell shell shell-project 0.0.0 fips_mode().()
88 {
89 [scip-shell system . . `[`. -n "$FIPS_MODE" ] && [scip-shell system . . `[`. "$FIPS_MODE" -gt 0 ]
90 }
91
92 can_fail_fipsscip-shell shell shell-project 0.0.0 can_fail_fips().()
93 {
94 # Ignore this fail if running in FIPS mode
95 fips_modescip-shell shell shell-project 0.0.0 fips_mode(). || failscip-shell shell shell-project 0.0.0 fail(). $1
96 }
97
98 skipscip-shell shell shell-project 0.0.0 skip().()
99 {
100 [scip-shell system . . `[`. -n "$1" ] && echoscip-shell system . . echo. "$1"
101 remove_mappingscip-shell shell shell-project 0.0.0 remove_mapping().
102 [scip-shell system . . `[`. -n "$2" ] && exit $2
103 exit 77
104 }
105
106 preparescip-shell shell shell-project 0.0.0 prepare().()
107 {
108 [scip-shell system . . `[`. -b /dev/mapper/$DEV_NAME ] && dmsetup remove --retry $DEV_NAME >/dev/nullscip-shell filesystem . . `/dev/null`. 2>&1
109
110 case "$2" in
111 file)
112 remove_mappingscip-shell shell shell-project 0.0.0 remove_mapping().
113 ddscip-shell system . . dd. if=/dev/zeroscip-shell filesystem . . `/dev/zero`. of=$IMG bs=1k count=10000 >/dev/nullscip-shell filesystem . . `/dev/null`. 2>&1
114 syncscip-shell system . . sync.
115 ;;
116 wipe)
117 remove_mappingscip-shell shell shell-project 0.0.0 remove_mapping().
118 ddscip-shell system . . dd. if=/dev/zeroscip-shell filesystem . . `/dev/zero`. of=$IMG bs=1k count=10000 >/dev/nullscip-shell filesystem . . `/dev/null`. 2>&1
119 syncscip-shell system . . sync.
120 losetupscip-shell system . . losetup. $LOOPDEV $IMG
121 ;;
122 new)
123 remove_mappingscip-shell shell shell-project 0.0.0 remove_mapping().
124 xzscip-shell system . . xz. -cd compatimage.img.xz > $IMG
125 # FIXME: switch to internal loop (no losetup at all)
126 echoscip-shell system . . echo. "bad" | $CRYPTSETUP luksOpen --key-slot 0 --test-passphrase $IMG 2>&1 | \
127 grep "autoclear flag" && skipscip-shell shell shell-project 0.0.0 skip(). "WARNING: Too old kernel, test skipped."
128 losetupscip-shell system . . losetup. $LOOPDEV $IMG
129 xzscip-shell system . . xz. -cd compatv10image.img.xz > $IMG10
130 ;;
131 reuse | *)
132 if [scip-shell system . . `[`. ! -e $IMG ]; then
133 xzscip-shell system . . xz. -cd compatimage.img.xz > $IMG
134 losetupscip-shell system . . losetup. $LOOPDEV $IMG
135 fi
136 [scip-shell system . . `[`. ! -e $IMG10 ] && xzscip-shell system . . xz. -cd compatv10image.img.xz > $IMG10
137 ;;
138 esac
139
140 if [scip-shell system . . `[`. ! -e $KEY1 ]; then
141 #dd if=/dev/urandom of=$KEY1 count=1 bs=32 >/dev/null 2>&1
142 echoscip-shell system . . echo. -n $'\x48\xc6\x74\x4f\x41\x4e\x50\xc0\x79\xc2\x2d\x5b\x5f\x68\x84\x17' >$KEY1
143 echoscip-shell system . . echo. -n $'\x9c\x03\x5e\x1b\x4d\x0f\x9a\x75\xb3\x90\x70\x32\x0a\xf8\xae\xc4'>>$KEY1
144 fi
145
146 if [scip-shell system . . `[`. ! -e $KEY_TZERO ]; then
147 echoscip-shell system . . echo. -ne '\xa6\x32\x09\x5f\xdb\xbe\xf3\xc6\xa7\x4c\xe5\x85\x73\xac\xa8\xfb' >$KEY_TZERO
148 echoscip-shell system . . echo. -ne '\x09\xd4\x38\xfd\x58\x24\x17\x1b\x98\xa3\xef\x1e\xe4\x4b\xbc\x00'>>$KEY_TZERO
149 fi
150
151 if [scip-shell system . . `[`. ! -e $KEY_HALF_ZERO ]; then
152 echoscip-shell system . . echo. -ne '\xa6\x32\x09\x5f\xdb\xbe\xf3\xc6\xa7\x4c\xe5\x85\x73\xac\xa8\xfb' >$KEY_HALF_ZERO
153 echoscip-shell system . . echo. -ne '\x09\xd4\x38\xfd\x58\x24\x17\x1b\x98\xa3\xef\x1e\xe4\x4b\xbc\xc9'>>$KEY_HALF_ZERO
154 echoscip-shell system . . echo. -ne '\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00'>>$KEY_HALF_ZERO
155 echoscip-shell system . . echo. -ne '\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00'>>$KEY_HALF_ZERO
156 fi
157
158 if [scip-shell system . . `[`. ! -e $KEY2 ]; then
159 ddscip-shell system . . dd. if=/dev/urandomscip-shell filesystem . . `/dev/urandom`. of=$KEY2 count=1 bs=16 >/dev/nullscip-shell filesystem . . `/dev/null`. 2>&1
160 fi
161
162 if [scip-shell system . . `[`. ! -e $KEY5 ]; then
163 ddscip-shell system . . dd. if=/dev/urandomscip-shell filesystem . . `/dev/urandom`. of=$KEY5 count=1 bs=16 >/dev/nullscip-shell filesystem . . `/dev/null`. 2>&1
164 fi
165
166 if [scip-shell system . . `[`. ! -e $KEYE ]; then
167 touchscip-shell system . . touch. $KEYE
168 fi
169
170 cpscip-shell system . . cp. $IMG $ORIG_IMG
171 [scip-shell system . . `[`. -n "$1" ] && echoscip-shell system . . echo. "CASE: $1"
172 }
173
174 checkscip-shell shell shell-project 0.0.0 check().()
175 {
176 syncscip-shell system . . sync.
177 [scip-shell system . . `[`. -z "$1" ] && return
178 $DIFFER $ORIG_IMG $IMG $1 || failscip-shell shell shell-project 0.0.0 fail().
179 }
180
181 check_existsscip-shell shell shell-project 0.0.0 check_exists().()
182 {
183 [scip-shell system . . `[`. -b /dev/mapper/$DEV_NAME ] || failscip-shell shell shell-project 0.0.0 fail().
184 checkscip-shell shell shell-project 0.0.0 check(). $1
185 }
186
187 # $1 path to scsi debug bdev
188 scsi_debug_teardownscip-shell shell shell-project 0.0.0 scsi_debug_teardown().() {
189 local _tries=15;
190
191 while [scip-shell system . . `[`. -b "$1" -a $_tries -gt 0 ]; do
192 rmmod scsi_debug >/dev/nullscip-shell filesystem . . `/dev/null`. 2>&1
193 if [scip-shell system . . `[`. -b "$1" ]; then
194 sleepscip-shell system . . sleep. .1
195 _tries=$((_tries-1))
196 fi
197 done
198
199 testscip-shell system . . test. ! -b "$1" || rmmod scsi_debug >/dev/nullscip-shell filesystem . . `/dev/null`. 2>&1
200 }
201
202 add_scsi_devicescip-shell shell shell-project 0.0.0 add_scsi_device().() {
203 scsi_debug_teardownscip-shell shell shell-project 0.0.0 scsi_debug_teardown(). $DEV
204 if [scip-shell system . . `[`. -d /sys/module/scsi_debugscip-shell filesystem . . `/sys/module/scsi_debug`. ] ; then
205 echoscip-shell system . . echo. "Cannot use scsi_debug module (in use or compiled-in), test skipped."
206 exit 77
207 fi
208 modprobe scsi_debug $@ delay=0 >/dev/nullscip-shell filesystem . . `/dev/null`. 2>&1
209 if [scip-shell system . . `[`. $? -ne 0 ] ; then
210 echoscip-shell system . . echo. "This kernel seems to not support proper scsi_debug module, test skipped."
211 exit 77
212 fi
213
214 sleepscip-shell system . . sleep. 1
215 DEV="/dev/"$(grepscip-shell system . . grep. -l -e scsi_debug /sys/block/*/device/model | cutscip-shell system . . cut. -f4 -d /scip-shell filesystem . . `/`.)
216 [scip-shell system . . `[`. -b $DEV ] || failscip-shell shell shell-project 0.0.0 fail(). "Cannot find $DEV."
217 }
218
219 valgrind_setupscip-shell shell shell-project 0.0.0 valgrind_setup().()
220 {
221 [scip-shell system . . `[`. -n "$VALG" ] || return
222 command -v valgrind >/dev/nullscip-shell filesystem . . `/dev/null`. || failscip-shell shell shell-project 0.0.0 fail(). "Cannot find valgrind."
223 [scip-shell system . . `[`. ! -f $CRYPTSETUP_VALGRIND ] && failscip-shell shell shell-project 0.0.0 fail(). "Unable to get location of cryptsetup executable."
224 [scip-shell system . . `[`. ! -f valg.sh ] && failscip-shell shell shell-project 0.0.0 fail(). "Unable to get location of valg runner script."
225 if [scip-shell system . . `[`. -z "$CRYPTSETUP_TESTS_RUN_IN_MESON" ]; then
226 export LD_LIBRARY_PATH="$CRYPTSETUP_LIB_VALGRIND:$LD_LIBRARY_PATH"
227 fi
228 CRYPTSETUP=valgrind_run
229 CRYPTSETUP_RAW="./valg.sh ${CRYPTSETUP_VALGRIND}"
230 }
231
232 valgrind_runscip-shell shell shell-project 0.0.0 valgrind_run().()
233 {
234 export INFOSTRING="$(basenamescip-shell system . . basename. ${BASH_SOURCE[1]})-line-${BASH_LINENO[0]}"
235 $CRYPTSETUP_RAW "$@"
236 }
237
238 expect_runscip-shell shell shell-project 0.0.0 expect_run().()
239 {
240 export INFOSTRING="$(basenamescip-shell system . . basename. ${BASH_SOURCE[1]})-line-${BASH_LINENO[0]}"
241 expect "$@"
242 }
243
244 export LANG=C
245
246 [scip-shell system . . `[`. ! -x "$CRYPTSETUP" ] && skipscip-shell shell shell-project 0.0.0 skip(). "Cannot find $CRYPTSETUP, test skipped."
247 valgrind_setupscip-shell shell shell-project 0.0.0 valgrind_setup().
248
249 preparescip-shell shell shell-project 0.0.0 prepare(). "Image in file tests (root capabilities not required)" file
250 echoscip-shell system . . echo. "[1] format"
251 echoscip-shell system . . echo. $PWD1 | $CRYPTSETUP luksFormat --type luks1 -c 'capi:xts(aes)-plain64' $IMG $FAST_PBKDF_OPT || failscip-shell shell shell-project 0.0.0 fail().
252 echoscip-shell system . . echo. $PWD0 | $CRYPTSETUP luksOpen $IMG --test-passphrase 2>/dev/nullscip-shell filesystem . . `/dev/null`. && failscip-shell shell shell-project 0.0.0 fail().
253 echoscip-shell system . . echo. $PWD1 | $CRYPTSETUP luksFormat --type luks1 $IMG $FAST_PBKDF_OPT --disable-blkid || failscip-shell shell shell-project 0.0.0 fail().
254 echoscip-shell system . . echo. "[2] open"
255 echoscip-shell system . . echo. $PWD0 | $CRYPTSETUP luksOpen $IMG --test-passphrase 2>/dev/nullscip-shell filesystem . . `/dev/null`. && failscip-shell shell shell-project 0.0.0 fail().
256 [scip-shell system . . `[`. $? -ne 2 ] && failscip-shell shell shell-project 0.0.0 fail(). "luksOpen should return EPERM exit code"
257 echoscip-shell system . . echo. $PWD1 | $CRYPTSETUP luksOpen $IMG --test-passphrase || failscip-shell shell shell-project 0.0.0 fail().
258 # test detached header --test-passphrase
259 echoscip-shell system . . echo. $PWD1 | $CRYPTSETUP -q luksFormat --type luks1 $FAST_PBKDF_OPT --header $HEADER_IMG $IMG || failscip-shell shell shell-project 0.0.0 fail().
260 echoscip-shell system . . echo. $PWD1 | $CRYPTSETUP open --test-passphrase $HEADER_IMG || failscip-shell shell shell-project 0.0.0 fail().
261 rmscip-shell system . . rm. -f $HEADER_IMG
262 echoscip-shell system . . echo. "[3] add key"
263 echoscip-shell system . . echo. $PWD1 | $CRYPTSETUP luksAddKey $IMG $FAST_PBKDF_OPT 2>/dev/nullscip-shell filesystem . . `/dev/null`. && failscip-shell shell shell-project 0.0.0 fail().
264 echoscip-shell system . . echo. -e "$PWD1\n$PWD2" | $CRYPTSETUP luksAddKey $IMG $FAST_PBKDF_OPT || failscip-shell shell shell-project 0.0.0 fail().
265 echoscip-shell system . . echo. -e "$PWD0\n$PWD1" | $CRYPTSETUP luksAddKey $IMG $FAST_PBKDF_OPT 2>/dev/nullscip-shell filesystem . . `/dev/null`. && failscip-shell shell shell-project 0.0.0 fail().
266 echoscip-shell system . . echo. "[4] change key"
267 echoscip-shell system . . echo. -e "$PWD1\n$PWD0\n" | $CRYPTSETUP luksChangeKey --force-password $FAST_PBKDF_OPT $IMG || failscip-shell shell shell-project 0.0.0 fail().
268 echoscip-shell system . . echo. -e "$PWD1\n$PWD2\n" | $CRYPTSETUP luksChangeKey $FAST_PBKDF_OPT $IMG 2>/dev/nullscip-shell filesystem . . `/dev/null`. && failscip-shell shell shell-project 0.0.0 fail().
269 [scip-shell system . . `[`. $? -ne 2 ] && failscip-shell shell shell-project 0.0.0 fail(). "luksChangeKey should return EPERM exit code"
270 echoscip-shell system . . echo. "[5] remove key"
271 # delete active keys PWD0, PWD2
272 echoscip-shell system . . echo. $PWD1 | $CRYPTSETUP luksRemoveKey $IMG 2>/dev/nullscip-shell filesystem . . `/dev/null`. && failscip-shell shell shell-project 0.0.0 fail().
273 [scip-shell system . . `[`. $? -ne 2 ] && failscip-shell shell shell-project 0.0.0 fail(). "luksRemove should return EPERM exit code"
274 echoscip-shell system . . echo. $PWD0 | $CRYPTSETUP luksRemoveKey $IMG || failscip-shell shell shell-project 0.0.0 fail().
275 echoscip-shell system . . echo. $PWD2 | $CRYPTSETUP luksRemoveKey $IMG || failscip-shell shell shell-project 0.0.0 fail().
276 # check if keys were deleted
277 echoscip-shell system . . echo. $PWD0 | $CRYPTSETUP luksOpen $IMG --test-passphrase 2>/dev/nullscip-shell filesystem . . `/dev/null`. && failscip-shell shell shell-project 0.0.0 fail().
278 [scip-shell system . . `[`. $? -ne 1 ] && failscip-shell shell shell-project 0.0.0 fail(). "luksOpen should return ENOENT exit code"
279 echoscip-shell system . . echo. $PWD2 | $CRYPTSETUP luksOpen $IMG --test-passphrase 2>/dev/nullscip-shell filesystem . . `/dev/null`. && failscip-shell shell shell-project 0.0.0 fail().
280 [scip-shell system . . `[`. $? -ne 1 ] && failscip-shell shell shell-project 0.0.0 fail(). "luksOpen should return ENOENT exit code"
281 echoscip-shell system . . echo. "[6] kill slot"
282 # format new luks device with active keys PWD1, PWD2
283 echoscip-shell system . . echo. $PWD1 | $CRYPTSETUP -q luksFormat --type luks1 $IMG $FAST_PBKDF_OPT || failscip-shell shell shell-project 0.0.0 fail().
284 echoscip-shell system . . echo. -e "$PWD1\n$PWD2" | $CRYPTSETUP luksAddKey $IMG $FAST_PBKDF_OPT || failscip-shell shell shell-project 0.0.0 fail().
285 # deactivate keys by killing slots
286 $CRYPTSETUP luksDump $IMG | grepscip-shell system . . grep. -q "Key Slot 0: ENABLED" || failscip-shell shell shell-project 0.0.0 fail().
287 $CRYPTSETUP luksDump $IMG | grepscip-shell system . . grep. -q "Key Slot 1: ENABLED" || failscip-shell shell shell-project 0.0.0 fail().
288 $CRYPTSETUP luksDump $IMG | grepscip-shell system . . grep. -q "Key Slot 2: DISABLED" || failscip-shell shell shell-project 0.0.0 fail().
289 echoscip-shell system . . echo. $PWD1 | $CRYPTSETUP -q luksKillSlot $IMG 0 2>/dev/nullscip-shell filesystem . . `/dev/null`. && failscip-shell shell shell-project 0.0.0 fail().
290 echoscip-shell system . . echo. $PWD2 | $CRYPTSETUP -q luksKillSlot $IMG 0 || failscip-shell shell shell-project 0.0.0 fail().
291 $CRYPTSETUP luksDump $IMG | grepscip-shell system . . grep. -q "Key Slot 0: DISABLED" || failscip-shell shell shell-project 0.0.0 fail().
292 echoscip-shell system . . echo. $PWD1 | $CRYPTSETUP -q luksKillSlot $IMG 1 2>/dev/nullscip-shell filesystem . . `/dev/null`. && failscip-shell shell shell-project 0.0.0 fail().
293 [scip-shell system . . `[`. $? -ne 2 ] && failscip-shell shell shell-project 0.0.0 fail(). "luksKill should return EPERM exit code"
294 echoscip-shell system . . echo. $PWD2 | $CRYPTSETUP -q luksKillSlot $IMG 1 || failscip-shell shell shell-project 0.0.0 fail().
295 $CRYPTSETUP luksDump $IMG | grepscip-shell system . . grep. -q "Key Slot 1: DISABLED" || failscip-shell shell shell-project 0.0.0 fail().
296 # check if keys were deactivated
297 echoscip-shell system . . echo. $PWD1 | $CRYPTSETUP luksOpen $IMG --test-passphrase 2>/dev/nullscip-shell filesystem . . `/dev/null`. && failscip-shell shell shell-project 0.0.0 fail().
298 echoscip-shell system . . echo. $PWD2 | $CRYPTSETUP luksOpen $IMG --test-passphrase 2>/dev/nullscip-shell filesystem . . `/dev/null`. && failscip-shell shell shell-project 0.0.0 fail().
299 echoscip-shell system . . echo. "[7] header backup"
300 echoscip-shell system . . echo. $PWD1 | $CRYPTSETUP -q luksFormat --type luks1 $IMG $FAST_PBKDF_OPT || failscip-shell shell shell-project 0.0.0 fail().
301 $CRYPTSETUP luksHeaderBackup $IMG --header-backup-file $HEADER_IMG || failscip-shell shell shell-project 0.0.0 fail().
302 echoscip-shell system . . echo. $PWD1 | $CRYPTSETUP luksRemoveKey $IMG || failscip-shell shell shell-project 0.0.0 fail().
303 echoscip-shell system . . echo. $PWD1 | $CRYPTSETUP luksOpen $IMG --test-passphrase 2>/dev/nullscip-shell filesystem . . `/dev/null`. && failscip-shell shell shell-project 0.0.0 fail().
304 echoscip-shell system . . echo. "[8] header restore"
305 $CRYPTSETUP luksHeaderRestore -q $IMG --header-backup-file $HEADER_IMG || failscip-shell shell shell-project 0.0.0 fail().
306 echoscip-shell system . . echo. $PWD1 | $CRYPTSETUP luksOpen $IMG --test-passphrase || failscip-shell shell shell-project 0.0.0 fail().
307 echoscip-shell system . . echo. "[9] luksDump"
308 echoscip-shell system . . echo. $PWD1 | $CRYPTSETUP -q luksFormat --type luks1 $FAST_PBKDF_OPT --uuid $TEST_UUID $IMG $KEY1 || failscip-shell shell shell-project 0.0.0 fail().
309 echoscip-shell system . . echo. $PWD1 | $CRYPTSETUP luksAddKey $FAST_PBKDF_OPT $IMG -d $KEY1 || failscip-shell shell shell-project 0.0.0 fail().
310 $CRYPTSETUP luksDump $IMG | grepscip-shell system . . grep. -q "Key Slot 0: ENABLED" || failscip-shell shell shell-project 0.0.0 fail().
311 $CRYPTSETUP luksDump $IMG | grepscip-shell system . . grep. -q $TEST_UUID || failscip-shell shell shell-project 0.0.0 fail().
312 echoscip-shell system . . echo. $PWDW | $CRYPTSETUP luksDump $IMG --dump-volume-key 2>/dev/nullscip-shell filesystem . . `/dev/null`. && failscip-shell shell shell-project 0.0.0 fail().
313 echoscip-shell system . . echo. $PWDW | $CRYPTSETUP luksDump $IMG --dump-master-key 2>/dev/nullscip-shell filesystem . . `/dev/null`. && failscip-shell shell shell-project 0.0.0 fail().
314 echoscip-shell system . . echo. $PWD1 | $CRYPTSETUP luksDump $IMG --dump-volume-key | grepscip-shell system . . grep. -q "MK dump:" || failscip-shell shell shell-project 0.0.0 fail().
315 echoscip-shell system . . echo. $PWD1 | $CRYPTSETUP luksDump $IMG --dump-master-key | grepscip-shell system . . grep. -q "MK dump:" || failscip-shell shell shell-project 0.0.0 fail().
316 $CRYPTSETUP luksDump -q $IMG --dump-volume-key -d $KEY1 | grepscip-shell system . . grep. -q "MK dump:" || failscip-shell shell shell-project 0.0.0 fail().
317 echoscip-shell system . . echo. $PWD1 | $CRYPTSETUP luksDump -q $IMG --dump-master-key --master-key-file $VK_FILE >/dev/nullscip-shell filesystem . . `/dev/null`. || failscip-shell shell shell-project 0.0.0 fail().
318 rmscip-shell system . . rm. -f $VK_FILE
319 echoscip-shell system . . echo. $PWD1 | $CRYPTSETUP luksDump -q $IMG --dump-volume-key --volume-key-file $VK_FILE >/dev/nullscip-shell filesystem . . `/dev/null`. || failscip-shell shell shell-project 0.0.0 fail().
320 echoscip-shell system . . echo. $PWD1 | $CRYPTSETUP luksDump -q $IMG --dump-volume-key --volume-key-file $VK_FILE 2>/dev/nullscip-shell filesystem . . `/dev/null`. && failscip-shell shell shell-project 0.0.0 fail().
321 echoscip-shell system . . echo. $PWD1 | $CRYPTSETUP luksAddKey $FAST_PBKDF_OPT --volume-key-file $VK_FILE $IMG || failscip-shell shell shell-project 0.0.0 fail().
322
323 echoscip-shell system . . echo. "[10] uuid"
324 echoscip-shell system . . echo. $PWD1 | $CRYPTSETUP -q luksFormat --type luks1 $FAST_PBKDF_OPT --uuid $TEST_UUID $IMG || failscip-shell shell shell-project 0.0.0 fail().
325 $CRYPTSETUP -q luksUUID $IMG | grepscip-shell system . . grep. -q $TEST_UUID || failscip-shell shell shell-project 0.0.0 fail().
326
327 [scip-shell system . . `[`. $(idscip-shell system . . id. -u) != 0 ] && skipscip-shell shell shell-project 0.0.0 skip(). "WARNING: You must be root to run this test, test skipped."
328 [scip-shell system . . `[`. -z "$LOOPDEV" ] && skipscip-shell shell shell-project 0.0.0 skip(). "WARNING: Cannot find free loop device, test skipped."
329 [scip-shell system . . `[`. ! -x "$DIFFER" ] && skipscip-shell shell shell-project 0.0.0 skip(). "Cannot find $DIFFER, test skipped."
330 [scip-shell system . . `[`. ! -x "$CRYPTOCHECK" ] && skipscip-shell shell shell-project 0.0.0 skip(). "Cannot find $CRYPTOCHECK, test skipped."
331
332 $CRYPTOCHECK cipher-kernel aes xts 256
333 if [scip-shell system . . `[`. $? -eq 0 ] ; then
334 echoscip-shell system . . echo. "[11] benchmark"
335 $CRYPTSETUP benchmark -c aes-xts --key-size 128 >/dev/nullscip-shell filesystem . . `/dev/null`. 2>&1 && failscip-shell shell shell-project 0.0.0 fail().
336 $CRYPTSETUP benchmark -c aes-xts >/dev/nullscip-shell filesystem . . `/dev/null`. || failscip-shell shell shell-project 0.0.0 fail().
337 $CRYPTSETUP benchmark -c aes-xts-plain64 >/dev/nullscip-shell filesystem . . `/dev/null`. || failscip-shell shell shell-project 0.0.0 fail().
338 $CRYPTSETUP benchmark -c capi:xts\(aes\) >/dev/nullscip-shell filesystem . . `/dev/null`. || failscip-shell shell shell-project 0.0.0 fail().
339 $CRYPTSETUP benchmark -c capi:xts\(aes\)-plain64 >/dev/nullscip-shell filesystem . . `/dev/null`. || failscip-shell shell shell-project 0.0.0 fail().
340 fi
341
342 # LUKS root-tests
343 preparescip-shell shell shell-project 0.0.0 prepare(). "[1] open - compat image - acceptance check" new
344 echoscip-shell system . . echo. $PWD0 | $CRYPTSETUP luksOpen $LOOPDEV $DEV_NAME || failscip-shell shell shell-project 0.0.0 fail().
345 check_existsscip-shell shell shell-project 0.0.0 check_exists().
346 ORG_SHA256=$(sha256sumscip-shell system . . sha256sum. -b /dev/mapper/$DEV_NAME | cutscip-shell system . . cut. -f 1 -d' ')
347 [scip-shell system . . `[`. "$ORG_SHA256" = 7428e8f2436882a07eb32765086f5c899474c08b5576f556b573d2aabdf923e8 ] || failscip-shell shell shell-project 0.0.0 fail().
348 $CRYPTSETUP -q luksClose $DEV_NAME || failscip-shell shell shell-project 0.0.0 fail().
349
350 # Check it can be opened from header backup as well
351 $CRYPTSETUP luksHeaderBackup $IMG --header-backup-file $HEADER_IMG || failscip-shell shell shell-project 0.0.0 fail().
352 echoscip-shell system . . echo. $PWD0 | $CRYPTSETUP luksOpen $IMG10 $DEV_NAME --header $HEADER_IMG || failscip-shell shell shell-project 0.0.0 fail().
353 check_existsscip-shell shell shell-project 0.0.0 check_exists().
354 $CRYPTSETUP -q luksClose $DEV_NAME || failscip-shell shell shell-project 0.0.0 fail().
355 # Check restore
356 $CRYPTSETUP luksHeaderRestore -q $IMG --header-backup-file $HEADER_IMG || failscip-shell shell shell-project 0.0.0 fail().
357
358 # Repeat for V1.0 header - not aligned first keyslot
359 if ! fips_modescip-shell shell shell-project 0.0.0 fips_mode().; then
360 echoscip-shell system . . echo. $PWD0 | $CRYPTSETUP luksOpen $IMG10 $DEV_NAME || failscip-shell shell shell-project 0.0.0 fail().
361 check_existsscip-shell shell shell-project 0.0.0 check_exists().
362 ORG_SHA1=$(sha1sumscip-shell system . . sha1sum. -b /dev/mapper/$DEV_NAME | cutscip-shell system . . cut. -f 1 -d' ')
363 [scip-shell system . . `[`. "$ORG_SHA1" = 51b48c2471a7593ceaf14dc5e66bca86ed05f6cc ] || failscip-shell shell shell-project 0.0.0 fail().
364 $CRYPTSETUP -q luksClose $DEV_NAME || failscip-shell shell shell-project 0.0.0 fail().
365
366 rmscip-shell system . . rm. -f $HEADER_IMG
367 $CRYPTSETUP luksHeaderBackup $IMG10 --header-backup-file $HEADER_IMG
368 echoscip-shell system . . echo. $PWD0 | $CRYPTSETUP luksOpen $IMG10 $DEV_NAME --header $HEADER_IMG || failscip-shell shell shell-project 0.0.0 fail().
369 check_existsscip-shell shell shell-project 0.0.0 check_exists().
370 $CRYPTSETUP -q luksClose $DEV_NAME || failscip-shell shell shell-project 0.0.0 fail().
371 fi
372
373 preparescip-shell shell shell-project 0.0.0 prepare(). "[2] open - compat image - denial check" new
374 echoscip-shell system . . echo. $PWDW | $CRYPTSETUP luksOpen $LOOPDEV $DEV_NAME 2>/dev/nullscip-shell filesystem . . `/dev/null`. && failscip-shell shell shell-project 0.0.0 fail().
375 echoscip-shell system . . echo. $PWDW | $CRYPTSETUP luksOpen $IMG10 $DEV_NAME 2>/dev/nullscip-shell filesystem . . `/dev/null`. && failscip-shell shell shell-project 0.0.0 fail().
376 checkscip-shell shell shell-project 0.0.0 check().
377
378 # All headers items and first key material section must change
379 preparescip-shell shell shell-project 0.0.0 prepare(). "[3] format" wipe
380 echoscip-shell system . . echo. $PWD1 | $CRYPTSETUP -i 1000 -c aes-cbc-essiv:sha256 -s 128 luksFormat --type luks1 $LOOPDEV || failscip-shell shell shell-project 0.0.0 fail().
381 checkscip-shell shell shell-project 0.0.0 check(). "$LUKS_HEADER $KEY_SLOT0 $KEY_MATERIAL0"
382
383 preparescip-shell shell shell-project 0.0.0 prepare(). "[4] format using hash sha512" wipe
384 echoscip-shell system . . echo. $PWD1 | $CRYPTSETUP -i 1000 -h sha512 -c aes-cbc-essiv:sha256 -s 128 luksFormat --type luks1 $LOOPDEV || failscip-shell shell shell-project 0.0.0 fail().
385 checkscip-shell shell shell-project 0.0.0 check(). "$LUKS_HEADER $KEY_SLOT0 $KEY_MATERIAL0"
386
387 preparescip-shell shell shell-project 0.0.0 prepare(). "[5] open"
388 echoscip-shell system . . echo. $PWD1 | $CRYPTSETUP luksOpen $LOOPDEV $DEV_NAME --test-passphrase || failscip-shell shell shell-project 0.0.0 fail().
389 echoscip-shell system . . echo. $PWDW | $CRYPTSETUP luksOpen $LOOPDEV $DEV_NAME --test-passphrase 2>/dev/nullscip-shell filesystem . . `/dev/null`. && failscip-shell shell shell-project 0.0.0 fail().
390 echoscip-shell system . . echo. $PWD1 | $CRYPTSETUP luksOpen $LOOPDEV $DEV_NAME || failscip-shell shell shell-project 0.0.0 fail().
391 check_existsscip-shell shell shell-project 0.0.0 check_exists().
392
393 # Key Slot 1 and key material section 1 must change, the rest must not.
394 preparescip-shell shell shell-project 0.0.0 prepare(). "[6] add key"
395 echoscip-shell system . . echo. -e "$PWD1\n$PWD2" | $CRYPTSETUP luksAddKey $LOOPDEV || failscip-shell shell shell-project 0.0.0 fail().
396 checkscip-shell shell shell-project 0.0.0 check(). "$KEY_SLOT1 $KEY_MATERIAL1"
397 echoscip-shell system . . echo. $PWD2 | $CRYPTSETUP luksOpen $LOOPDEV $DEV_NAME || failscip-shell shell shell-project 0.0.0 fail().
398
399 # Unsuccessful Key Delete - nothing may change
400 preparescip-shell shell shell-project 0.0.0 prepare(). "[7] unsuccessful delete"
401 echoscip-shell system . . echo. $PWDW | $CRYPTSETUP luksKillSlot $LOOPDEV 1 2>/dev/nullscip-shell filesystem . . `/dev/null`. && failscip-shell shell shell-project 0.0.0 fail().
402 $CRYPTSETUP -q luksKillSlot $LOOPDEV 8 2>/dev/nullscip-shell filesystem . . `/dev/null`. && failscip-shell shell shell-project 0.0.0 fail().
403 $CRYPTSETUP -q luksKillSlot $LOOPDEV 7 2>/dev/nullscip-shell filesystem . . `/dev/null`. && failscip-shell shell shell-project 0.0.0 fail().
404 checkscip-shell shell shell-project 0.0.0 check().
405
406 # Delete Key Test
407 # Key Slot 1 and key material section 1 must change, the rest must not
408 preparescip-shell shell shell-project 0.0.0 prepare(). "[8] successful delete"
409 $CRYPTSETUP -q luksKillSlot $LOOPDEV 1 || failscip-shell shell shell-project 0.0.0 fail().
410 checkscip-shell shell shell-project 0.0.0 check(). "$KEY_SLOT1 $KEY_MATERIAL1_EXT"
411 echoscip-shell system . . echo. $PWD2 | $CRYPTSETUP luksOpen $LOOPDEV $DEV_NAME 2> /dev/nullscip-shell filesystem . . `/dev/null`. && failscip-shell shell shell-project 0.0.0 fail().
412 echoscip-shell system . . echo. $PWD1 | $CRYPTSETUP luksOpen $LOOPDEV $DEV_NAME || failscip-shell shell shell-project 0.0.0 fail().
413
414 # Key Slot 1 and key material section 1 must change, the rest must not
415 preparescip-shell shell shell-project 0.0.0 prepare(). "[9] add key test for key files"
416 echoscip-shell system . . echo. $PWD1 | $CRYPTSETUP luksAddKey $FAST_PBKDF_OPT $LOOPDEV $KEY1 || failscip-shell shell shell-project 0.0.0 fail().
417 checkscip-shell shell shell-project 0.0.0 check(). "$KEY_SLOT1 $KEY_MATERIAL1"
418 $CRYPTSETUP -d $KEY1 luksOpen $LOOPDEV $DEV_NAME || failscip-shell shell shell-project 0.0.0 fail().
419
420 # Key Slot 1 and key material section 1 must change, the rest must not
421 preparescip-shell shell shell-project 0.0.0 prepare(). "[10] delete key test with key1 as remaining key"
422 $CRYPTSETUP -d $KEY1 luksKillSlot $LOOPDEV 0 || failscip-shell shell shell-project 0.0.0 fail().
423 checkscip-shell shell shell-project 0.0.0 check(). "$KEY_SLOT0 $KEY_MATERIAL0_EXT"
424 echoscip-shell system . . echo. $PWD1 | $CRYPTSETUP luksOpen $LOOPDEV $DEV_NAME 2>/dev/nullscip-shell filesystem . . `/dev/null`. && failscip-shell shell shell-project 0.0.0 fail().
425 $CRYPTSETUP luksOpen -d $KEY1 $LOOPDEV $DEV_NAME || failscip-shell shell shell-project 0.0.0 fail().
426
427 # Delete last slot
428 preparescip-shell shell shell-project 0.0.0 prepare(). "[11] delete last key" wipe
429 echoscip-shell system . . echo. $PWD1 | $CRYPTSETUP luksFormat --type luks1 $LOOPDEV $FAST_PBKDF_OPT || failscip-shell shell shell-project 0.0.0 fail().
430 echoscip-shell system . . echo. $PWD1 | $CRYPTSETUP luksKillSlot $LOOPDEV 0 || failscip-shell shell shell-project 0.0.0 fail().
431 echoscip-shell system . . echo. $PWD1 | $CRYPTSETUP luksOpen $LOOPDEV $DEV_NAME 2>/dev/nullscip-shell filesystem . . `/dev/null`. && failscip-shell shell shell-project 0.0.0 fail().
432
433 # Format test for ESSIV, and some other parameters.
434 preparescip-shell shell shell-project 0.0.0 prepare(). "[12] parameter variation test" wipe
435 $CRYPTSETUP -q -i 1000 -c aes-cbc-essiv:sha256 -s 128 luksFormat --type luks1 $LOOPDEV $KEY1 || failscip-shell shell shell-project 0.0.0 fail().
436 checkscip-shell shell shell-project 0.0.0 check(). "$LUKS_HEADER $KEY_SLOT0 $KEY_MATERIAL0"
437 $CRYPTSETUP -d $KEY1 luksOpen $LOOPDEV $DEV_NAME || failscip-shell shell shell-project 0.0.0 fail().
438
439 preparescip-shell shell shell-project 0.0.0 prepare(). "[13] open/close - stacked devices" wipe
440 echoscip-shell system . . echo. $PWD1 | $CRYPTSETUP -q luksFormat --type luks1 $LOOPDEV $FAST_PBKDF_OPT || failscip-shell shell shell-project 0.0.0 fail().
441 echoscip-shell system . . echo. $PWD1 | $CRYPTSETUP -q luksOpen $LOOPDEV $DEV_NAME || failscip-shell shell shell-project 0.0.0 fail().
442 echoscip-shell system . . echo. $PWD1 | $CRYPTSETUP -q luksFormat --type luks1 /dev/mapper/$DEV_NAME || failscip-shell shell shell-project 0.0.0 fail().
443 echoscip-shell system . . echo. $PWD1 | $CRYPTSETUP -q luksOpen /dev/mapper/$DEV_NAME $DEV_NAME2 || failscip-shell shell shell-project 0.0.0 fail().
444 $CRYPTSETUP -q luksClose $DEV_NAME2 || failscip-shell shell shell-project 0.0.0 fail().
445 $CRYPTSETUP -q luksClose $DEV_NAME || failscip-shell shell shell-project 0.0.0 fail().
446
447 preparescip-shell shell shell-project 0.0.0 prepare(). "[14] format/open - passphrase on stdin & new line" wipe
448 # stdin defined by "-" must take even newline
449 #echo -n -e "$PWD1\n$PWD2" | $CRYPTSETUP -q luksFormat $LOOPDEV - || fail
450 echoscip-shell system . . echo. -n -e "$PWD1\n$PWD2" | $CRYPTSETUP $FAST_PBKDF_OPT -q --key-file=- luksFormat --type luks1 $LOOPDEV || failscip-shell shell shell-project 0.0.0 fail().
451 echoscip-shell system . . echo. -n -e "$PWD1\n$PWD2" | $CRYPTSETUP -q --key-file=- luksOpen $LOOPDEV $DEV_NAME || failscip-shell shell shell-project 0.0.0 fail().
452 $CRYPTSETUP -q luksClose $DEV_NAME || failscip-shell shell shell-project 0.0.0 fail().
453 echoscip-shell system . . echo. -n -e "$PWD1\n$PWD2" | $CRYPTSETUP -q luksOpen $LOOPDEV $DEV_NAME 2>/dev/nullscip-shell filesystem . . `/dev/null`. && failscip-shell shell shell-project 0.0.0 fail().
454 # now also try --key-file
455 echoscip-shell system . . echo. -n -e "$PWD1\n$PWD2" | $CRYPTSETUP $FAST_PBKDF_OPT -q luksFormat --type luks1 $LOOPDEV --key-file=- || failscip-shell shell shell-project 0.0.0 fail().
456 echoscip-shell system . . echo. -n -e "$PWD1\n$PWD2" | $CRYPTSETUP -q --key-file=- luksOpen $LOOPDEV $DEV_NAME || failscip-shell shell shell-project 0.0.0 fail().
457 $CRYPTSETUP -q luksClose $DEV_NAME || failscip-shell shell shell-project 0.0.0 fail().
458 # process newline if from stdin
459 echoscip-shell system . . echo. -n -e "$PWD1\n$PWD2" | $CRYPTSETUP $FAST_PBKDF_OPT -q luksFormat --type luks1 $LOOPDEV || failscip-shell shell shell-project 0.0.0 fail().
460 echoscip-shell system . . echo. "$PWD1" | $CRYPTSETUP -q luksOpen $LOOPDEV $DEV_NAME || failscip-shell shell shell-project 0.0.0 fail().
461 $CRYPTSETUP -q luksClose $DEV_NAME || failscip-shell shell shell-project 0.0.0 fail().
462
463 preparescip-shell shell shell-project 0.0.0 prepare(). "[15] UUID - use and report provided UUID" wipe
464 echoscip-shell system . . echo. $PWD1 | $CRYPTSETUP -q luksFormat --type luks1 $FAST_PBKDF_OPT --uuid blah $LOOPDEV 2>/dev/nullscip-shell filesystem . . `/dev/null`. && failscip-shell shell shell-project 0.0.0 fail().
465 echoscip-shell system . . echo. $PWD1 | $CRYPTSETUP -q luksFormat --type luks1 $FAST_PBKDF_OPT --uuid $TEST_UUID $LOOPDEV || failscip-shell shell shell-project 0.0.0 fail().
466 tst=$($CRYPTSETUP -q luksUUID $LOOPDEV)
467 [scip-shell system . . `[`. "$tst"x = "$TEST_UUID"x ] || failscip-shell shell shell-project 0.0.0 fail().
468 echoscip-shell system . . echo. $PWD1 | $CRYPTSETUP -q luksFormat --type luks1 $FAST_PBKDF_OPT $LOOPDEV || failscip-shell shell shell-project 0.0.0 fail().
469 $CRYPTSETUP -q luksUUID --uuid $TEST_UUID $LOOPDEV || failscip-shell shell shell-project 0.0.0 fail().
470 tst=$($CRYPTSETUP -q luksUUID $LOOPDEV)
471 [scip-shell system . . `[`. "$tst"x = "$TEST_UUID"x ] || failscip-shell shell shell-project 0.0.0 fail().
472
473 preparescip-shell shell shell-project 0.0.0 prepare(). "[16] luksFormat" wipe
474 echoscip-shell system . . echo. $PWD1 | $CRYPTSETUP -q luksFormat --type luks1 $FAST_PBKDF_OPT --volume-key-file /dev/urandomscip-shell filesystem . . `/dev/urandom`. $LOOPDEV || failscip-shell shell shell-project 0.0.0 fail().
475 echoscip-shell system . . echo. $PWD1 | $CRYPTSETUP -q luksFormat --type luks1 $FAST_PBKDF_OPT --volume-key-file /dev/urandomscip-shell filesystem . . `/dev/urandom`. $LOOPDEV -d $KEY1 || failscip-shell shell shell-project 0.0.0 fail().
476 $CRYPTSETUP -q luksFormat --type luks1 $FAST_PBKDF_OPT --volume-key-file /dev/urandomscip-shell filesystem . . `/dev/urandom`. -s 256 --uuid $TEST_UUID $LOOPDEV $KEY1 || failscip-shell shell shell-project 0.0.0 fail().
477 $CRYPTSETUP luksOpen -d $KEY1 $LOOPDEV $DEV_NAME || failscip-shell shell shell-project 0.0.0 fail().
478 $CRYPTSETUP -q luksClose $DEV_NAME || failscip-shell shell shell-project 0.0.0 fail().
479 # open by UUID
480 if [scip-shell system . . `[`. -d /dev/disk/by-uuidscip-shell filesystem . . `/dev/disk/by-uuid`. ] ; then
481 force_ueventscip-shell shell shell-project 0.0.0 force_uevent(). # some systems do not update loop by-uuid
482 $CRYPTSETUP luksOpen -d $KEY1 UUID=X$TEST_UUID $DEV_NAME 2>/dev/nullscip-shell filesystem . . `/dev/null`. && failscip-shell shell shell-project 0.0.0 fail().
483 $CRYPTSETUP luksOpen -d $KEY1 UUID=$TEST_UUID $DEV_NAME || failscip-shell shell shell-project 0.0.0 fail().
484 $CRYPTSETUP -q luksClose $DEV_NAME || failscip-shell shell shell-project 0.0.0 fail().
485 fi
486 # skip tests using empty passphrase
487 if ! fips_modescip-shell shell shell-project 0.0.0 fips_mode().; then
488 # empty keyfile
489 $CRYPTSETUP -q luksFormat --type luks1 $FAST_PBKDF_OPT $LOOPDEV $KEYE || failscip-shell shell shell-project 0.0.0 fail().
490 $CRYPTSETUP luksOpen -d $KEYE $LOOPDEV $DEV_NAME || failscip-shell shell shell-project 0.0.0 fail().
491 $CRYPTSETUP -q luksClose $DEV_NAME || failscip-shell shell shell-project 0.0.0 fail().
492 fi
493 # open by volume key
494 echoscip-shell system . . echo. $PWD1 | $CRYPTSETUP -q luksFormat --type luks1 $FAST_PBKDF_OPT -s 256 --volume-key-file $KEY1 $LOOPDEV || failscip-shell shell shell-project 0.0.0 fail().
495 $CRYPTSETUP luksOpen --volume-key-file /dev/urandomscip-shell filesystem . . `/dev/urandom`. $LOOPDEV $DEV_NAME 2>/dev/nullscip-shell filesystem . . `/dev/null`. && failscip-shell shell shell-project 0.0.0 fail().
496 $CRYPTSETUP luksOpen --volume-key-file $KEY1 $LOOPDEV $DEV_NAME || failscip-shell shell shell-project 0.0.0 fail().
497 $CRYPTSETUP -q luksClose $DEV_NAME || failscip-shell shell shell-project 0.0.0 fail().
498 # unsupported pe-keyslot encryption
499 echoscip-shell system . . echo. $PWD1 | $CRYPTSETUP -q luksFormat --type luks1 $FAST_PBKDF_OPT -s 128 --keyslot-cipher "aes-cbc-plain" $LOOPDEV 2>/dev/nullscip-shell filesystem . . `/dev/null`. && failscip-shell shell shell-project 0.0.0 fail().
500 echoscip-shell system . . echo. $PWD1 | $CRYPTSETUP -q luksFormat --type luks1 $FAST_PBKDF_OPT -s 128 --keyslot-key-size 256 $LOOPDEV 2>/dev/nullscip-shell filesystem . . `/dev/null`. && failscip-shell shell shell-project 0.0.0 fail().
501
502 preparescip-shell shell shell-project 0.0.0 prepare(). "[17] AddKey volume key, passphrase and keyfile" wipe
503 # volumekey
504 echoscip-shell system . . echo. $PWD1 | $CRYPTSETUP -q luksFormat --type luks1 $FAST_PBKDF_OPT $LOOPDEV --volume-key-file /dev/zeroscip-shell filesystem . . `/dev/zero`. --key-slot 3 || failscip-shell shell shell-project 0.0.0 fail().
505 echoscip-shell system . . echo. $PWD1 | $CRYPTSETUP luksOpen $LOOPDEV --test-passphrase || failscip-shell shell shell-project 0.0.0 fail().
506 $CRYPTSETUP luksDump $LOOPDEV | grepscip-shell system . . grep. -q "Key Slot 3: ENABLED" || failscip-shell shell shell-project 0.0.0 fail().
507 echoscip-shell system . . echo. $PWD2 | $CRYPTSETUP luksAddKey -q $FAST_PBKDF_OPT $LOOPDEV --volume-key-file /dev/zeroscip-shell filesystem . . `/dev/zero`. --key-slot 4 || failscip-shell shell shell-project 0.0.0 fail().
508 echoscip-shell system . . echo. $PWD2 | $CRYPTSETUP luksOpen $LOOPDEV --test-passphrase --key-slot 4 || failscip-shell shell shell-project 0.0.0 fail().
509 $CRYPTSETUP luksDump $LOOPDEV | grepscip-shell system . . grep. -q "Key Slot 4: ENABLED" || failscip-shell shell shell-project 0.0.0 fail().
510 echoscip-shell system . . echo. $PWD3 | $CRYPTSETUP luksAddKey -q $FAST_PBKDF_OPT $LOOPDEV --volume-key-file /dev/nullscip-shell filesystem . . `/dev/null`. --key-slot 5 2>/dev/nullscip-shell filesystem . . `/dev/null`. && failscip-shell shell shell-project 0.0.0 fail().
511 $CRYPTSETUP luksAddKey -q $FAST_PBKDF_OPT $LOOPDEV --volume-key-file /dev/zeroscip-shell filesystem . . `/dev/zero`. --key-slot 5 $KEY1 || failscip-shell shell shell-project 0.0.0 fail().
512 $CRYPTSETUP luksOpen $LOOPDEV --test-passphrase --key-slot 5 -d $KEY1 || failscip-shell shell shell-project 0.0.0 fail().
513 $CRYPTSETUP luksDump $LOOPDEV | grepscip-shell system . . grep. -q "Key Slot 5: ENABLED" || failscip-shell shell shell-project 0.0.0 fail().
514
515 # special "-" handling
516 $CRYPTSETUP -q luksFormat --type luks1 $FAST_PBKDF_OPT $LOOPDEV $KEY1 --key-slot 3 || failscip-shell shell shell-project 0.0.0 fail().
517 echoscip-shell system . . echo. $PWD1 | $CRYPTSETUP luksAddKey $FAST_PBKDF_OPT $LOOPDEV -d $KEY1 - || failscip-shell shell shell-project 0.0.0 fail().
518 echoscip-shell system . . echo. $PWD1 | $CRYPTSETUP luksOpen $LOOPDEV --test-passphrase 2>/dev/nullscip-shell filesystem . . `/dev/null`. && failscip-shell shell shell-project 0.0.0 fail().
519 echoscip-shell system . . echo. $PWD1 | $CRYPTSETUP luksOpen $LOOPDEV -d - --test-passphrase || failscip-shell shell shell-project 0.0.0 fail().
520 echoscip-shell system . . echo. $PWD1 | $CRYPTSETUP luksAddKey $FAST_PBKDF_OPT $LOOPDEV -d - $KEY2 || failscip-shell shell shell-project 0.0.0 fail().
521 $CRYPTSETUP luksOpen $LOOPDEV -d $KEY2 --test-passphrase || failscip-shell shell shell-project 0.0.0 fail().
522 echoscip-shell system . . echo. $PWD1 | $CRYPTSETUP luksOpen $LOOPDEV -d - -d $KEY1 --test-passphrase 2>/dev/nullscip-shell filesystem . . `/dev/null`. && failscip-shell shell shell-project 0.0.0 fail().
523 echoscip-shell system . . echo. $PWD1 | $CRYPTSETUP luksOpen $LOOPDEV -d $KEY1 -d $KEY1 --test-passphrase 2>/dev/nullscip-shell filesystem . . `/dev/null`. && failscip-shell shell shell-project 0.0.0 fail().
524
525 # [0]PWD1 [1]PWD2 [2]$KEY1/1 [3]$KEY1 [4]$KEY2
526 $CRYPTSETUP -q luksFormat --type luks1 $FAST_PBKDF_OPT $LOOPDEV $KEY1 --key-slot 3 || failscip-shell shell shell-project 0.0.0 fail().
527 $CRYPTSETUP luksDump $LOOPDEV | grepscip-shell system . . grep. -q "Key Slot 3: ENABLED" || failscip-shell shell shell-project 0.0.0 fail().
528 $CRYPTSETUP luksAddKey -q $LOOPDEV $FAST_PBKDF_OPT -d $KEY1 $KEY2 --key-slot 3 2>/dev/nullscip-shell filesystem . . `/dev/null`. && failscip-shell shell shell-project 0.0.0 fail().
529 # keyfile/keyfile
530 $CRYPTSETUP luksAddKey -q $LOOPDEV $FAST_PBKDF_OPT -d $KEY1 $KEY2 --key-slot 4 || failscip-shell shell shell-project 0.0.0 fail().
531 $CRYPTSETUP luksOpen $LOOPDEV -d $KEY2 --test-passphrase --key-slot 4 || failscip-shell shell shell-project 0.0.0 fail().
532 $CRYPTSETUP luksDump $LOOPDEV | grepscip-shell system . . grep. -q "Key Slot 4: ENABLED" || failscip-shell shell shell-project 0.0.0 fail().
533 # passphrase/keyfile
534 echoscip-shell system . . echo. $PWD1 | $CRYPTSETUP luksAddKey -q $FAST_PBKDF_OPT $LOOPDEV -d $KEY1 --key-slot 0 || failscip-shell shell shell-project 0.0.0 fail().
535 $CRYPTSETUP luksDump $LOOPDEV | grepscip-shell system . . grep. -q "Key Slot 0: ENABLED" || failscip-shell shell shell-project 0.0.0 fail().
536 echoscip-shell system . . echo. $PWD1 | $CRYPTSETUP luksOpen $LOOPDEV --test-passphrase --key-slot 0 || failscip-shell shell shell-project 0.0.0 fail().
537 # passphrase/passphrase
538 echoscip-shell system . . echo. -e "$PWD1\n$PWD2\n" | $CRYPTSETUP luksAddKey -q $FAST_PBKDF_OPT $LOOPDEV --key-slot 1 || failscip-shell shell shell-project 0.0.0 fail().
539 echoscip-shell system . . echo. $PWD2 | $CRYPTSETUP luksOpen $LOOPDEV --test-passphrase --key-slot 1 || failscip-shell shell shell-project 0.0.0 fail().
540 $CRYPTSETUP luksDump $LOOPDEV | grepscip-shell system . . grep. -q "Key Slot 1: ENABLED" || failscip-shell shell shell-project 0.0.0 fail().
541 # keyfile/passphrase
542 echoscip-shell system . . echo. -e "$PWD2\n" | $CRYPTSETUP luksAddKey -q $FAST_PBKDF_OPT $LOOPDEV $KEY1 --key-slot 2 --new-keyfile-size 8 || failscip-shell shell shell-project 0.0.0 fail().
543 $CRYPTSETUP luksDump $LOOPDEV | grepscip-shell system . . grep. -q "Key Slot 2: ENABLED" || failscip-shell shell shell-project 0.0.0 fail().
544
545 preparescip-shell shell shell-project 0.0.0 prepare(). "[18] RemoveKey passphrase and keyfile" reuse
546 $CRYPTSETUP luksRemoveKey $LOOPDEV $KEY1 || failscip-shell shell shell-project 0.0.0 fail().
547 $CRYPTSETUP luksDump $LOOPDEV | grepscip-shell system . . grep. -q "Key Slot 3: DISABLED" || failscip-shell shell shell-project 0.0.0 fail().
548 $CRYPTSETUP luksRemoveKey $LOOPDEV $KEY1 2>/dev/nullscip-shell filesystem . . `/dev/null`. && failscip-shell shell shell-project 0.0.0 fail().
549 $CRYPTSETUP luksAddKey -q $LOOPDEV $FAST_PBKDF_OPT -d $KEY2 $KEY1 --key-slot 3 2>/dev/nullscip-shell filesystem . . `/dev/null`. || failscip-shell shell shell-project 0.0.0 fail().
550 $CRYPTSETUP luksDump $LOOPDEV | grepscip-shell system . . grep. -q "Key Slot 3: ENABLED" || failscip-shell shell shell-project 0.0.0 fail().
551 $CRYPTSETUP luksRemoveKey $LOOPDEV $KEY2 --keyfile-size 1 2>/dev/nullscip-shell filesystem . . `/dev/null`. && failscip-shell shell shell-project 0.0.0 fail().
552 $CRYPTSETUP luksRemoveKey $LOOPDEV $KEY2 || failscip-shell shell shell-project 0.0.0 fail().
553 $CRYPTSETUP luksDump $LOOPDEV | grepscip-shell system . . grep. -q "Key Slot 4: DISABLED" || failscip-shell shell shell-project 0.0.0 fail().
554 # if password or keyfile is provided, batch mode must not suppress it
555 echoscip-shell system . . echo. "badpw" | $CRYPTSETUP luksKillSlot $LOOPDEV 2 2>/dev/nullscip-shell filesystem . . `/dev/null`. && failscip-shell shell shell-project 0.0.0 fail().
556 echoscip-shell system . . echo. "badpw" | $CRYPTSETUP luksKillSlot $LOOPDEV 2 -q 2>/dev/nullscip-shell filesystem . . `/dev/null`. && failscip-shell shell shell-project 0.0.0 fail().
557 echoscip-shell system . . echo. "badpw" | $CRYPTSETUP luksKillSlot $LOOPDEV 2 --key-file=- 2>/dev/nullscip-shell filesystem . . `/dev/null`. && failscip-shell shell shell-project 0.0.0 fail().
558 echoscip-shell system . . echo. "badpw" | $CRYPTSETUP luksKillSlot $LOOPDEV 2 --key-file=- -q 2>/dev/nullscip-shell filesystem . . `/dev/null`. && failscip-shell shell shell-project 0.0.0 fail().
559 $CRYPTSETUP luksDump $LOOPDEV | grepscip-shell system . . grep. -q "Key Slot 2: ENABLED" || failscip-shell shell shell-project 0.0.0 fail().
560 # kill slot using passphrase from 1
561 echoscip-shell system . . echo. $PWD2 | $CRYPTSETUP luksKillSlot $LOOPDEV 2 || failscip-shell shell shell-project 0.0.0 fail().
562 $CRYPTSETUP luksDump $LOOPDEV | grepscip-shell system . . grep. -q "Key Slot 2: DISABLED" || failscip-shell shell shell-project 0.0.0 fail().
563 # kill slot with redirected stdin
564 $CRYPTSETUP luksKillSlot $LOOPDEV 3 </dev/nullscip-shell filesystem . . `/dev/null`. 2>/dev/nullscip-shell filesystem . . `/dev/null`. || failscip-shell shell shell-project 0.0.0 fail().
565 $CRYPTSETUP luksDump $LOOPDEV | grepscip-shell system . . grep. -q "Key Slot 3: DISABLED" || failscip-shell shell shell-project 0.0.0 fail().
566 # remove key0 / slot 0
567 echoscip-shell system . . echo. $PWD1 | $CRYPTSETUP luksRemoveKey $LOOPDEV || failscip-shell shell shell-project 0.0.0 fail().
568 $CRYPTSETUP luksDump $LOOPDEV | grepscip-shell system . . grep. -q "Key Slot 0: DISABLED" || failscip-shell shell shell-project 0.0.0 fail().
569 # last keyslot, in batch mode no passphrase needed...
570 $CRYPTSETUP luksKillSlot -q $LOOPDEV 1 || failscip-shell shell shell-project 0.0.0 fail().
571 $CRYPTSETUP luksDump $LOOPDEV | grepscip-shell system . . grep. -q "Key Slot 1: DISABLED" || failscip-shell shell shell-project 0.0.0 fail().
572
573 preparescip-shell shell shell-project 0.0.0 prepare(). "[19] create & status & resize" wipe
574 echoscip-shell system . . echo. $PWD1 | $CRYPTSETUP create $DEV_NAME $LOOPDEV --hash xxx --cipher aes-cbc-essiv:sha256 --key-size 256 2>/dev/nullscip-shell filesystem . . `/dev/null`. && failscip-shell shell shell-project 0.0.0 fail().
575 echoscip-shell system . . echo. $PWD1 | $CRYPTSETUP create $DEV_NAME $LOOPDEV $PLAIN_OPT --offset 3 --skip 4 --readonly || failscip-shell shell shell-project 0.0.0 fail().
576 $CRYPTSETUP -q status $DEV_NAME | grepscip-shell system . . grep. "offset:" | grepscip-shell system . . grep. -q "3 \[512-byte units\]" || failscip-shell shell shell-project 0.0.0 fail().
577 $CRYPTSETUP -q status $DEV_NAME | grepscip-shell system . . grep. "skipped:" | grepscip-shell system . . grep. -q "4 \[512-byte units\]" || failscip-shell shell shell-project 0.0.0 fail().
578 $CRYPTSETUP -q status $DEV_NAME | grepscip-shell system . . grep. "mode:" | grepscip-shell system . . grep. -q "readonly" || failscip-shell shell shell-project 0.0.0 fail().
579 $CRYPTSETUP -q resize $DEV_NAME --size 100 || failscip-shell shell shell-project 0.0.0 fail().
580 $CRYPTSETUP -q status $DEV_NAME | grepscip-shell system . . grep. "size:" | grepscip-shell system . . grep. -q "100 \[512-byte units\]" || failscip-shell shell shell-project 0.0.0 fail().
581 $CRYPTSETUP -q resize $DEV_NAME || failscip-shell shell shell-project 0.0.0 fail().
582 $CRYPTSETUP -q status $DEV_NAME | grepscip-shell system . . grep. "size:" | grepscip-shell system . . grep. -q "19997 \[512-byte units\]" || failscip-shell shell shell-project 0.0.0 fail().
583 $CRYPTSETUP -q resize $DEV_NAME --device-size 1M || failscip-shell shell shell-project 0.0.0 fail().
584 $CRYPTSETUP -q status $DEV_NAME | grepscip-shell system . . grep. "size:" | grepscip-shell system . . grep. -q "2048 \[512-byte units\]" || failscip-shell shell shell-project 0.0.0 fail().
585 $CRYPTSETUP -q resize $DEV_NAME --device-size 512k --size 1023 >/dev/nullscip-shell filesystem . . `/dev/null`. 2>&1 && failscip-shell shell shell-project 0.0.0 fail().
586 $CRYPTSETUP -q status $DEV_NAME | grepscip-shell system . . grep. "size:" | grepscip-shell system . . grep. -q "2048 \[512-byte units\]" || failscip-shell shell shell-project 0.0.0 fail().
587 $CRYPTSETUP -q resize $DEV_NAME --device-size 513 >/dev/nullscip-shell filesystem . . `/dev/null`. 2>&1 && failscip-shell shell shell-project 0.0.0 fail().
588 $CRYPTSETUP -q status $DEV_NAME | grepscip-shell system . . grep. "size:" | grepscip-shell system . . grep. -q "2048 \[512-byte units\]" || failscip-shell shell shell-project 0.0.0 fail().
589 # Resize underlying loop device as well
590 truncatescip-shell system . . truncate. -s 16M $IMG || failscip-shell shell shell-project 0.0.0 fail().
591 $CRYPTSETUP -q resize $DEV_NAME || failscip-shell shell shell-project 0.0.0 fail().
592 $CRYPTSETUP -q status $DEV_NAME | grepscip-shell system . . grep. "size:" | grepscip-shell system . . grep. -q "32765 \[512-byte units\]" || failscip-shell shell shell-project 0.0.0 fail().
593 $CRYPTSETUP -q remove $DEV_NAME || failscip-shell shell shell-project 0.0.0 fail().
594 $CRYPTSETUP -q status $DEV_NAME >/dev/nullscip-shell filesystem . . `/dev/null`. && failscip-shell shell shell-project 0.0.0 fail().
595 echoscip-shell system . . echo. $PWD1 | $CRYPTSETUP create $DEV_NAME $PLAIN_OPT $LOOPDEV || failscip-shell shell shell-project 0.0.0 fail().
596 $CRYPTSETUP -q remove $DEV_NAME || failscip-shell shell shell-project 0.0.0 fail().
597 echoscip-shell system . . echo. $PWD1 | $CRYPTSETUP -q create $DEV_NAME $PLAIN_OPT $LOOPDEV || failscip-shell shell shell-project 0.0.0 fail().
598 $CRYPTSETUP -q remove $DEV_NAME || failscip-shell shell shell-project 0.0.0 fail().
599 echoscip-shell system . . echo. $PWD1 | $CRYPTSETUP -q create $DEV_NAME $PLAIN_OPT --size 100 $LOOPDEV || failscip-shell shell shell-project 0.0.0 fail().
600 $CRYPTSETUP -q status $DEV_NAME | grepscip-shell system . . grep. "size:" | grepscip-shell system . . grep. -q "100 \[512-byte units\]" || failscip-shell shell shell-project 0.0.0 fail().
601 $CRYPTSETUP -q remove $DEV_NAME || failscip-shell shell shell-project 0.0.0 fail().
602 # 4k sector resize (if kernel supports it)
603 echoscip-shell system . . echo. $PWD1 | $CRYPTSETUP -q open --type plain $PLAIN_OPT $LOOPDEV $DEV_NAME --sector-size 4096 --size 8 >/dev/nullscip-shell filesystem . . `/dev/null`. 2>&1
604 if [scip-shell system . . `[`. $? -eq 0 ] ; then
605 $CRYPTSETUP -q status $DEV_NAME | grepscip-shell system . . grep. "size:" | grepscip-shell system . . grep. -q "8 \[512-byte units\]" || failscip-shell shell shell-project 0.0.0 fail().
606 $CRYPTSETUP -q resize $DEV_NAME --size 16 || failscip-shell shell shell-project 0.0.0 fail().
607 $CRYPTSETUP -q status $DEV_NAME | grepscip-shell system . . grep. "size:" | grepscip-shell system . . grep. -q "16 \[512-byte units\]" || failscip-shell shell shell-project 0.0.0 fail().
608 $CRYPTSETUP -q resize $DEV_NAME --size 9 2>/dev/nullscip-shell filesystem . . `/dev/null`. && failscip-shell shell shell-project 0.0.0 fail().
609 $CRYPTSETUP -q status $DEV_NAME | grepscip-shell system . . grep. "size:" | grepscip-shell system . . grep. -q "16 \[512-byte units\]" || failscip-shell shell shell-project 0.0.0 fail().
610 $CRYPTSETUP -q resize $DEV_NAME --device-size 4608 2>/dev/nullscip-shell filesystem . . `/dev/null`. && failscip-shell shell shell-project 0.0.0 fail().
611 $CRYPTSETUP -q status $DEV_NAME | grepscip-shell system . . grep. "size:" | grepscip-shell system . . grep. -q "16 \[512-byte units\]" || failscip-shell shell shell-project 0.0.0 fail().
612 $CRYPTSETUP -q remove $DEV_NAME || failscip-shell shell shell-project 0.0.0 fail().
613 fi
614 # Resize not aligned to logical block size
615 add_scsi_devicescip-shell shell shell-project 0.0.0 add_scsi_device(). dev_size_mb=32 sector_size=4096
616 echoscip-shell system . . echo. $PWD1 | $CRYPTSETUP create $DEV_NAME $PLAIN_OPT $DEV || failscip-shell shell shell-project 0.0.0 fail().
617 OLD_SIZE=$($CRYPTSETUP status $DEV_NAME | grepscip-shell system . . grep. "^ \+size:" | sedscip-shell system . . sed. 's/.* \([0-9]\+\) .*/\1/')
618 $CRYPTSETUP resize $DEV_NAME -b 7 2> /dev/nullscip-shell filesystem . . `/dev/null`. && failscip-shell shell shell-project 0.0.0 fail().
619 dmsetup info $DEV_NAME | grepscip-shell system . . grep. -q SUSPENDED && failscip-shell shell shell-project 0.0.0 fail().
620 NEW_SIZE=$($CRYPTSETUP status $DEV_NAME | grepscip-shell system . . grep. "^ \+size:" | sedscip-shell system . . sed. 's/.* \([0-9]\+\) .*/\1/')
621 testscip-shell system . . test. $OLD_SIZE -eq $NEW_SIZE || failscip-shell shell shell-project 0.0.0 fail().
622 $CRYPTSETUP close $DEV_NAME || failscip-shell shell shell-project 0.0.0 fail().
623 # Add check for unaligned plain crypt activation
624 echoscip-shell system . . echo. $PWD1 | $CRYPTSETUP create $DEV_NAME $PLAIN_OPT $DEV -b 7 2>/dev/nullscip-shell filesystem . . `/dev/null`. && failscip-shell shell shell-project 0.0.0 fail().
625 $CRYPTSETUP status $DEV_NAME >/dev/nullscip-shell filesystem . . `/dev/null`. 2>&1 && failscip-shell shell shell-project 0.0.0 fail().
626 # verify is ignored on non-tty input
627 echoscip-shell system . . echo. $PWD1 | $CRYPTSETUP create $DEV_NAME $LOOPDEV --hash sha256 --verify-passphrase 2>/dev/nullscip-shell filesystem . . `/dev/null`. || failscip-shell shell shell-project 0.0.0 fail().
628 $CRYPTSETUP -q remove $DEV_NAME || failscip-shell shell shell-project 0.0.0 fail().
629 $CRYPTSETUP create --cipher aes-cbc-essiv:sha256 --key-size 256 $DEV_NAME $LOOPDEV -d $KEY1 --key-size 255 2>/dev/nullscip-shell filesystem . . `/dev/null`. && failscip-shell shell shell-project 0.0.0 fail().
630 $CRYPTSETUP create --cipher aes-cbc-essiv:sha256 --key-size 256 $DEV_NAME $LOOPDEV -d $KEY1 --key-size -1 2>/dev/nullscip-shell filesystem . . `/dev/null`. && failscip-shell shell shell-project 0.0.0 fail().
631 $CRYPTSETUP create --cipher aes-cbc-essiv:sha256 --key-size 256 $DEV_NAME $LOOPDEV -d $KEY1 -l -1 2>/dev/nullscip-shell filesystem . . `/dev/null`. && failscip-shell shell shell-project 0.0.0 fail().
632 $CRYPTSETUP create --cipher aes-cbc-essiv:sha256 --key-size 256 $DEV_NAME $LOOPDEV -d $KEY1 || failscip-shell shell shell-project 0.0.0 fail().
633 $CRYPTSETUP create --cipher aes-cbc-essiv:sha256 --key-size 256 $DEV_NAME $LOOPDEV -d $KEY1 2>/dev/nullscip-shell filesystem . . `/dev/null`. && failscip-shell shell shell-project 0.0.0 fail().
634 $CRYPTSETUP create --cipher aes-cbc-essiv:sha256 --key-size 256 $DEV_NAME $LOOPDEV -d blah 2>/dev/nullscip-shell filesystem . . `/dev/null`. && failscip-shell shell shell-project 0.0.0 fail().
635 $CRYPTSETUP -q remove $DEV_NAME || failscip-shell shell shell-project 0.0.0 fail().
636 $CRYPTSETUP create --cipher aes-cbc-essiv:sha256 --key-size 256 $DEV_NAME $LOOPDEV -d /dev/urandomscip-shell filesystem . . `/dev/urandom`. || failscip-shell shell shell-project 0.0.0 fail().
637 $CRYPTSETUP -q remove $DEV_NAME || failscip-shell shell shell-project 0.0.0 fail().
638
639 preparescip-shell shell shell-project 0.0.0 prepare(). "[20] Disallow open/create if already mapped." wipe
640 $CRYPTSETUP create --cipher aes-cbc-essiv:sha256 --key-size 256 $DEV_NAME $LOOPDEV -d $KEY1 || failscip-shell shell shell-project 0.0.0 fail().
641 $CRYPTSETUP create --cipher aes-cbc-essiv:sha256 --key-size 256 $DEV_NAME $LOOPDEV -d $KEY1 2>/dev/nullscip-shell filesystem . . `/dev/null`. && failscip-shell shell shell-project 0.0.0 fail().
642 $CRYPTSETUP create --cipher aes-cbc-essiv:sha256 --key-size 256 $DEV_NAME2 $LOOPDEV -d $KEY1 2>/dev/nullscip-shell filesystem . . `/dev/null`. && failscip-shell shell shell-project 0.0.0 fail().
643 echoscip-shell system . . echo. $PWD1 | $CRYPTSETUP -q luksFormat --type luks1 $LOOPDEV 2>/dev/nullscip-shell filesystem . . `/dev/null`. && failscip-shell shell shell-project 0.0.0 fail().
644 $CRYPTSETUP remove $DEV_NAME || failscip-shell shell shell-project 0.0.0 fail().
645 echoscip-shell system . . echo. $PWD1 | $CRYPTSETUP -q luksFormat --type luks1 $LOOPDEV || failscip-shell shell shell-project 0.0.0 fail().
646 echoscip-shell system . . echo. $PWD1 | $CRYPTSETUP luksOpen $LOOPDEV $DEV_NAME || failscip-shell shell shell-project 0.0.0 fail().
647 echoscip-shell system . . echo. $PWD1 | $CRYPTSETUP luksOpen $LOOPDEV $DEV_NAME2 2>/dev/nullscip-shell filesystem . . `/dev/null`. && failscip-shell shell shell-project 0.0.0 fail().
648 $CRYPTSETUP luksClose $DEV_NAME || failscip-shell shell shell-project 0.0.0 fail().
649
650 preparescip-shell shell shell-project 0.0.0 prepare(). "[21] luksDump" wipe
651 echoscip-shell system . . echo. $PWD1 | $CRYPTSETUP -q luksFormat --type luks1 $FAST_PBKDF_OPT --uuid $TEST_UUID $LOOPDEV $KEY1 || failscip-shell shell shell-project 0.0.0 fail().
652 echoscip-shell system . . echo. $PWD1 | $CRYPTSETUP luksAddKey $FAST_PBKDF_OPT $LOOPDEV -d $KEY1 || failscip-shell shell shell-project 0.0.0 fail().
653 $CRYPTSETUP luksDump $LOOPDEV | grepscip-shell system . . grep. -q "Key Slot 0: ENABLED" || failscip-shell shell shell-project 0.0.0 fail().
654 $CRYPTSETUP luksDump $LOOPDEV | grepscip-shell system . . grep. -q $TEST_UUID || failscip-shell shell shell-project 0.0.0 fail().
655 echoscip-shell system . . echo. $PWDW | $CRYPTSETUP luksDump $LOOPDEV --dump-volume-key 2>/dev/nullscip-shell filesystem . . `/dev/null`. && failscip-shell shell shell-project 0.0.0 fail().
656 echoscip-shell system . . echo. $PWD1 | $CRYPTSETUP luksDump $LOOPDEV --dump-volume-key | grepscip-shell system . . grep. -q "MK dump:" || failscip-shell shell shell-project 0.0.0 fail().
657 $CRYPTSETUP luksDump -q $LOOPDEV --dump-volume-key -d $KEY1 | grepscip-shell system . . grep. -q "MK dump:" || failscip-shell shell shell-project 0.0.0 fail().
658 echoscip-shell system . . echo. $PWD1 | $CRYPTSETUP luksDump -q $LOOPDEV --dump-volume-key --volume-key-file $VK_FILE > /dev/nullscip-shell filesystem . . `/dev/null`. || failscip-shell shell shell-project 0.0.0 fail().
659 echoscip-shell system . . echo. $PWD1 | $CRYPTSETUP luksAddKey $FAST_PBKDF_OPT --volume-key-file $VK_FILE $LOOPDEV || failscip-shell shell shell-project 0.0.0 fail().
660
661 preparescip-shell shell shell-project 0.0.0 prepare(). "[22] remove disappeared device" wipe
662 dmsetup create $DEV_NAME --table "0 5000 linear $LOOPDEV 2" || failscip-shell shell shell-project 0.0.0 fail().
663 echoscip-shell system . . echo. $PWD1 | $CRYPTSETUP -q $FAST_PBKDF_OPT luksFormat --type luks1 /dev/mapper/$DEV_NAME || failscip-shell shell shell-project 0.0.0 fail().
664 echoscip-shell system . . echo. $PWD1 | $CRYPTSETUP -q luksOpen /dev/mapper/$DEV_NAME $DEV_NAME2 || failscip-shell shell shell-project 0.0.0 fail().
665 # underlying device now returns error but node is still present
666 dmsetup load $DEV_NAME --table "0 5000 error" || failscip-shell shell shell-project 0.0.0 fail().
667 dmsetup resume $DEV_NAME || failscip-shell shell shell-project 0.0.0 fail().
668 $CRYPTSETUP -q luksClose $DEV_NAME2 || failscip-shell shell shell-project 0.0.0 fail().
669 dmsetup remove --retry $DEV_NAME || failscip-shell shell shell-project 0.0.0 fail().
670
671 preparescip-shell shell shell-project 0.0.0 prepare(). "[23] ChangeKey passphrase and keyfile" wipe
672 # [0]$KEY1 [1]key0
673 $CRYPTSETUP -q luksFormat --type luks1 $LOOPDEV $KEY1 $FAST_PBKDF_OPT --key-slot 0 || failscip-shell shell shell-project 0.0.0 fail().
674 echoscip-shell system . . echo. $PWD1 | $CRYPTSETUP luksAddKey -q $LOOPDEV $FAST_PBKDF_OPT -d $KEY1 --key-slot 1 || failscip-shell shell shell-project 0.0.0 fail().
675 # keyfile [0] / keyfile [0]
676 $CRYPTSETUP luksChangeKey $LOOPDEV $FAST_PBKDF_OPT -d $KEY1 $KEY2 --key-slot 0 || failscip-shell shell shell-project 0.0.0 fail().
677 # passphrase [1] / passphrase [1]
678 echoscip-shell system . . echo. -e "$PWD1\n$PWD2\n" | $CRYPTSETUP luksChangeKey $LOOPDEV $FAST_PBKDF_OPT --key-slot 1 || failscip-shell shell shell-project 0.0.0 fail().
679 # keyfile [0] / keyfile [new]
680 $CRYPTSETUP luksChangeKey $LOOPDEV $FAST_PBKDF_OPT -d $KEY2 $KEY1 || failscip-shell shell shell-project 0.0.0 fail().
681 $CRYPTSETUP luksDump $LOOPDEV | grepscip-shell system . . grep. -q "Key Slot 0: DISABLED" || failscip-shell shell shell-project 0.0.0 fail().
682 # passphrase [1] / passphrase [new]
683 echoscip-shell system . . echo. -e "$PWD2\n$PWD1\n" | $CRYPTSETUP luksChangeKey $FAST_PBKDF_OPT $LOOPDEV || failscip-shell shell shell-project 0.0.0 fail().
684 $CRYPTSETUP luksDump $LOOPDEV | grepscip-shell system . . grep. -q "Key Slot 1: DISABLED" || failscip-shell shell shell-project 0.0.0 fail().
685 # use all slots
686 $CRYPTSETUP luksAddKey $LOOPDEV -d $KEY1 $KEY2 $FAST_PBKDF_OPT || failscip-shell shell shell-project 0.0.0 fail().
687 $CRYPTSETUP luksAddKey $LOOPDEV -d $KEY1 $KEY2 $FAST_PBKDF_OPT || failscip-shell shell shell-project 0.0.0 fail().
688 $CRYPTSETUP luksAddKey $LOOPDEV -d $KEY1 $KEY2 $FAST_PBKDF_OPT || failscip-shell shell shell-project 0.0.0 fail().
689 $CRYPTSETUP luksAddKey $LOOPDEV -d $KEY1 $KEY2 $FAST_PBKDF_OPT || failscip-shell shell shell-project 0.0.0 fail().
690 $CRYPTSETUP luksAddKey $LOOPDEV -d $KEY1 $KEY2 $FAST_PBKDF_OPT || failscip-shell shell shell-project 0.0.0 fail().
691 $CRYPTSETUP luksAddKey $LOOPDEV -d $KEY1 $KEY2 $FAST_PBKDF_OPT || failscip-shell shell shell-project 0.0.0 fail().
692 # still allows replace
693 $CRYPTSETUP luksChangeKey $LOOPDEV $FAST_PBKDF_OPT -d $KEY1 $KEY2 || failscip-shell shell shell-project 0.0.0 fail().
694 $CRYPTSETUP luksChangeKey $LOOPDEV $FAST_PBKDF_OPT -d $KEY1 $KEY2 2>/dev/nullscip-shell filesystem . . `/dev/null`. && failscip-shell shell shell-project 0.0.0 fail().
695
696 preparescip-shell shell shell-project 0.0.0 prepare(). "[24] Keyfile limit" wipe
697 $CRYPTSETUP -q luksFormat --type luks1 $FAST_PBKDF_OPT $LOOPDEV $KEY1 --key-slot 0 -l 13 || failscip-shell shell shell-project 0.0.0 fail().
698 $CRYPTSETUP --key-file=$KEY1 luksOpen $LOOPDEV $DEV_NAME 2>/dev/nullscip-shell filesystem . . `/dev/null`. && failscip-shell shell shell-project 0.0.0 fail().
699 $CRYPTSETUP --key-file=$KEY1 -l 0 luksOpen $LOOPDEV $DEV_NAME 2>/dev/nullscip-shell filesystem . . `/dev/null`. && failscip-shell shell shell-project 0.0.0 fail().
700 $CRYPTSETUP --key-file=$KEY1 -l -1 luksOpen $LOOPDEV $DEV_NAME 2>/dev/nullscip-shell filesystem . . `/dev/null`. && failscip-shell shell shell-project 0.0.0 fail().
701 $CRYPTSETUP --key-file=$KEY1 -l 14 luksOpen $LOOPDEV $DEV_NAME 2>/dev/nullscip-shell filesystem . . `/dev/null`. && failscip-shell shell shell-project 0.0.0 fail().
702 $CRYPTSETUP --key-file=$KEY1 -l 13 --keyfile-offset 1 luksOpen $LOOPDEV $DEV_NAME 2>/dev/nullscip-shell filesystem . . `/dev/null`. && failscip-shell shell shell-project 0.0.0 fail().
703 $CRYPTSETUP --key-file=$KEY1 -l 13 --keyfile-offset -1 luksOpen $LOOPDEV $DEV_NAME 2>/dev/nullscip-shell filesystem . . `/dev/null`. && failscip-shell shell shell-project 0.0.0 fail().
704 $CRYPTSETUP --key-file=$KEY1 -l 13 luksOpen $LOOPDEV $DEV_NAME || failscip-shell shell shell-project 0.0.0 fail().
705 $CRYPTSETUP luksClose $DEV_NAME || failscip-shell shell shell-project 0.0.0 fail().
706 $CRYPTSETUP luksAddKey $LOOPDEV -d $KEY1 $KEY2 $FAST_PBKDF_OPT 2>/dev/nullscip-shell filesystem . . `/dev/null`. && failscip-shell shell shell-project 0.0.0 fail().
707 $CRYPTSETUP luksAddKey $LOOPDEV -d $KEY1 $KEY2 $FAST_PBKDF_OPT -l 14 2>/dev/nullscip-shell filesystem . . `/dev/null`. && failscip-shell shell shell-project 0.0.0 fail().
708 $CRYPTSETUP luksAddKey $LOOPDEV -d $KEY1 $KEY2 $FAST_PBKDF_OPT -l -1 2>/dev/nullscip-shell filesystem . . `/dev/null`. && failscip-shell shell shell-project 0.0.0 fail().
709 $CRYPTSETUP luksAddKey $LOOPDEV -d $KEY1 $KEY2 $FAST_PBKDF_OPT -l 13 --new-keyfile-size 12 || failscip-shell shell shell-project 0.0.0 fail().
710 $CRYPTSETUP luksRemoveKey $LOOPDEV $KEY2 2>/dev/nullscip-shell filesystem . . `/dev/null`. && failscip-shell shell shell-project 0.0.0 fail().
711 $CRYPTSETUP luksRemoveKey $LOOPDEV $KEY2 -l 12 || failscip-shell shell shell-project 0.0.0 fail().
712 $CRYPTSETUP luksChangeKey $LOOPDEV -d $KEY1 $KEY2 $FAST_PBKDF_OPT 2>/dev/nullscip-shell filesystem . . `/dev/null`. && failscip-shell shell shell-project 0.0.0 fail().
713 $CRYPTSETUP luksChangeKey $LOOPDEV -d $KEY1 $KEY2 $FAST_PBKDF_OPT -l 14 2>/dev/nullscip-shell filesystem . . `/dev/null`. && failscip-shell shell shell-project 0.0.0 fail().
714 $CRYPTSETUP luksChangeKey $LOOPDEV -d $KEY1 $KEY2 $FAST_PBKDF_OPT -l 13 || failscip-shell shell shell-project 0.0.0 fail().
715 # -l is ignored for stdin if _only_ passphrase is used
716 echoscip-shell system . . echo. $PWD1 | $CRYPTSETUP luksAddKey $LOOPDEV -d $KEY2 $FAST_PBKDF_OPT || failscip-shell shell shell-project 0.0.0 fail().
717 # this is stupid, but expected
718 echoscip-shell system . . echo. $PWD1 | $CRYPTSETUP luksRemoveKey $LOOPDEV -l 11 2>/dev/nullscip-shell filesystem . . `/dev/null`. && failscip-shell shell shell-project 0.0.0 fail().
719 echoscip-shell system . . echo. $PWDW"0" | $CRYPTSETUP luksRemoveKey $LOOPDEV -l 12 2>/dev/nullscip-shell filesystem . . `/dev/null`. && failscip-shell shell shell-project 0.0.0 fail().
720 echoscip-shell system . . echo. -e "$PWD1\n" | $CRYPTSETUP luksRemoveKey $LOOPDEV -d- -l 12 || failscip-shell shell shell-project 0.0.0 fail().
721 # offset
722 $CRYPTSETUP -q luksFormat --type luks1 $FAST_PBKDF_OPT $LOOPDEV $KEY1 --key-slot 0 -l 13 --keyfile-offset 16 || failscip-shell shell shell-project 0.0.0 fail().
723 $CRYPTSETUP --key-file=$KEY1 -l 13 --keyfile-offset 15 luksOpen $LOOPDEV $DEV_NAME 2>/dev/nullscip-shell filesystem . . `/dev/null`. && failscip-shell shell shell-project 0.0.0 fail().
724 $CRYPTSETUP --key-file=$KEY1 -l 13 --keyfile-offset 16 luksOpen $LOOPDEV $DEV_NAME || failscip-shell shell shell-project 0.0.0 fail().
725 $CRYPTSETUP luksClose $DEV_NAME || failscip-shell shell shell-project 0.0.0 fail().
726 $CRYPTSETUP luksAddKey $LOOPDEV $FAST_PBKDF_OPT -d $KEY1 -l 13 --keyfile-offset 16 $KEY2 --new-keyfile-offset 1 || failscip-shell shell shell-project 0.0.0 fail().
727 $CRYPTSETUP --key-file=$KEY2 --keyfile-offset 11 luksOpen $LOOPDEV $DEV_NAME 2>/dev/nullscip-shell filesystem . . `/dev/null`. && failscip-shell shell shell-project 0.0.0 fail().
728 $CRYPTSETUP --key-file=$KEY2 --keyfile-offset 1 luksOpen $LOOPDEV $DEV_NAME || failscip-shell shell shell-project 0.0.0 fail().
729 $CRYPTSETUP luksClose $DEV_NAME || failscip-shell shell shell-project 0.0.0 fail().
730 $CRYPTSETUP luksChangeKey $LOOPDEV $FAST_PBKDF_OPT -d $KEY2 --keyfile-offset 1 $KEY2 --new-keyfile-offset 0 || failscip-shell shell shell-project 0.0.0 fail().
731 $CRYPTSETUP luksOpen -d $KEY2 $LOOPDEV $DEV_NAME || failscip-shell shell shell-project 0.0.0 fail().
732 $CRYPTSETUP luksClose $DEV_NAME || failscip-shell shell shell-project 0.0.0 fail().
733 # large device with keyfile
734 echoscip-shell system . . echo. -e '0 10000000 error'\\n'10000000 1000000 zero' | dmsetup create $DEV_NAME2 || failscip-shell shell shell-project 0.0.0 fail().
735 $CRYPTSETUP -q luksFormat --type luks1 $FAST_PBKDF_OPT $LOOPDEV /dev/mapper/$DEV_NAME2 -l 13 --keyfile-offset 5120000000 || failscip-shell shell shell-project 0.0.0 fail().
736 $CRYPTSETUP --key-file=/dev/mapper/$DEV_NAME2 -l 13 --keyfile-offset 5119999999 luksOpen $LOOPDEV $DEV_NAME 2>/dev/nullscip-shell filesystem . . `/dev/null`. && failscip-shell shell shell-project 0.0.0 fail().
737 $CRYPTSETUP --key-file=/dev/mapper/$DEV_NAME2 -l 13 --keyfile-offset 5120000000 luksOpen $LOOPDEV $DEV_NAME || failscip-shell shell shell-project 0.0.0 fail().
738 $CRYPTSETUP luksClose $DEV_NAME || failscip-shell shell shell-project 0.0.0 fail().
739 $CRYPTSETUP luksChangeKey $LOOPDEV $FAST_PBKDF_OPT -d /dev/mapper/$DEV_NAME2 \
740 --keyfile-offset 5120000000 -l 13 /dev/mapper/$DEV_NAME2 --new-keyfile-offset 5120000001 --new-keyfile-size 15 || failscip-shell shell shell-project 0.0.0 fail().
741 dmsetup remove --retry $DEV_NAME2
742
743 preparescip-shell shell shell-project 0.0.0 prepare(). "[25] Create shared segments" wipe
744 echoscip-shell system . . echo. $PWD1 | $CRYPTSETUP create $DEV_NAME $LOOPDEV $PLAIN_OPT --offset 0 --size 256 || failscip-shell shell shell-project 0.0.0 fail().
745 echoscip-shell system . . echo. $PWD1 | $CRYPTSETUP create $DEV_NAME2 $LOOPDEV $PLAIN_OPT --offset 512 --size 256 2>/dev/nullscip-shell filesystem . . `/dev/null`. && failscip-shell shell shell-project 0.0.0 fail().
746 echoscip-shell system . . echo. $PWD1 | $CRYPTSETUP create $DEV_NAME2 $LOOPDEV $PLAIN_OPT --offset 512 --size 256 --shared || failscip-shell shell shell-project 0.0.0 fail().
747 $CRYPTSETUP -q remove $DEV_NAME2 || failscip-shell shell shell-project 0.0.0 fail().
748 $CRYPTSETUP -q remove $DEV_NAME || failscip-shell shell shell-project 0.0.0 fail().
749
750 preparescip-shell shell shell-project 0.0.0 prepare(). "[26] Suspend/Resume" wipe
751 # only LUKS is supported
752 echoscip-shell system . . echo. $PWD1 | $CRYPTSETUP create $DEV_NAME $PLAIN_OPT $LOOPDEV || failscip-shell shell shell-project 0.0.0 fail().
753 $CRYPTSETUP luksSuspend $DEV_NAME 2>/dev/nullscip-shell filesystem . . `/dev/null`. && failscip-shell shell shell-project 0.0.0 fail().
754 $CRYPTSETUP luksResume $DEV_NAME 2>/dev/nullscip-shell filesystem . . `/dev/null`. && failscip-shell shell shell-project 0.0.0 fail().
755 $CRYPTSETUP -q remove $DEV_NAME || failscip-shell shell shell-project 0.0.0 fail().
756 $CRYPTSETUP luksSuspend $DEV_NAME 2>/dev/nullscip-shell filesystem . . `/dev/null`. && failscip-shell shell shell-project 0.0.0 fail().
757 # LUKS
758 echoscip-shell system . . echo. $PWD1 | $CRYPTSETUP -q luksFormat --type luks1 $FAST_PBKDF_OPT $LOOPDEV || failscip-shell shell shell-project 0.0.0 fail().
759 echoscip-shell system . . echo. $PWD1 | $CRYPTSETUP -q luksOpen $LOOPDEV $DEV_NAME || failscip-shell shell shell-project 0.0.0 fail().
760 $CRYPTSETUP luksSuspend $DEV_NAME || failscip-shell shell shell-project 0.0.0 fail().
761 $CRYPTSETUP -q status $DEV_NAME | grepscip-shell system . . grep. -q "(suspended)" || failscip-shell shell shell-project 0.0.0 fail().
762 $CRYPTSETUP -q resize $DEV_NAME 2>/dev/nullscip-shell filesystem . . `/dev/null`. && failscip-shell shell shell-project 0.0.0 fail().
763 echoscip-shell system . . echo. $PWDW | $CRYPTSETUP luksResume $DEV_NAME 2>/dev/nullscip-shell filesystem . . `/dev/null`. && failscip-shell shell shell-project 0.0.0 fail().
764 [scip-shell system . . `[`. $? -ne 2 ] && failscip-shell shell shell-project 0.0.0 fail(). "luksResume should return EPERM exit code"
765 echoscip-shell system . . echo. $PWD1 | $CRYPTSETUP luksResume $DEV_NAME || failscip-shell shell shell-project 0.0.0 fail().
766 $CRYPTSETUP -q luksClose $DEV_NAME || failscip-shell shell shell-project 0.0.0 fail().
767 # skip tests using empty passphrase
768 if ! fips_modescip-shell shell shell-project 0.0.0 fips_mode().; then
769 echoscip-shell system . . echo. | $CRYPTSETUP -q luksFormat -c null $FAST_PBKDF_OPT --type luks1 $LOOPDEV || failscip-shell shell shell-project 0.0.0 fail().
770 echoscip-shell system . . echo. | $CRYPTSETUP -q luksOpen $LOOPDEV $DEV_NAME || failscip-shell shell shell-project 0.0.0 fail().
771 $CRYPTSETUP luksSuspend $DEV_NAME || failscip-shell shell shell-project 0.0.0 fail().
772 $CRYPTSETUP -q status $DEV_NAME | grepscip-shell system . . grep. -q "(suspended)" || failscip-shell shell shell-project 0.0.0 fail().
773 echoscip-shell system . . echo. | $CRYPTSETUP luksResume $DEV_NAME || failscip-shell shell shell-project 0.0.0 fail().
774 $CRYPTSETUP -q luksClose $DEV_NAME || failscip-shell shell shell-project 0.0.0 fail().
775 fi
776
777 preparescip-shell shell shell-project 0.0.0 prepare(). "[27] luksOpen/luksResume with specified key slot number" wipe
778 # first, let's try passphrase option
779 echoscip-shell system . . echo. $PWD3 | $CRYPTSETUP luksFormat --type luks1 $FAST_PBKDF_OPT -S 5 $LOOPDEV || failscip-shell shell shell-project 0.0.0 fail().
780 checkscip-shell shell shell-project 0.0.0 check(). $LUKS_HEADER $KEY_SLOT5 $KEY_MATERIAL5
781 echoscip-shell system . . echo. $PWD3 | $CRYPTSETUP luksOpen -S 4 $LOOPDEV $DEV_NAME 2>/dev/nullscip-shell filesystem . . `/dev/null`. && failscip-shell shell shell-project 0.0.0 fail().
782 [scip-shell system . . `[`. -b /dev/mapper/$DEV_NAME ] && failscip-shell shell shell-project 0.0.0 fail().
783 echoscip-shell system . . echo. $PWD3 | $CRYPTSETUP luksOpen -S 5 $LOOPDEV $DEV_NAME || failscip-shell shell shell-project 0.0.0 fail().
784 check_existsscip-shell shell shell-project 0.0.0 check_exists().
785 $CRYPTSETUP luksSuspend $DEV_NAME || failscip-shell shell shell-project 0.0.0 fail().
786 echoscip-shell system . . echo. $PWD3 | $CRYPTSETUP luksResume -S 4 $DEV_NAME 2>/dev/nullscip-shell filesystem . . `/dev/null`. && failscip-shell shell shell-project 0.0.0 fail().
787 $CRYPTSETUP -q status $DEV_NAME | grepscip-shell system . . grep. -q "(suspended)" || failscip-shell shell shell-project 0.0.0 fail().
788 echoscip-shell system . . echo. $PWD3 | $CRYPTSETUP luksResume -S 5 $DEV_NAME || failscip-shell shell shell-project 0.0.0 fail().
789 $CRYPTSETUP luksClose $DEV_NAME || failscip-shell shell shell-project 0.0.0 fail().
790 echoscip-shell system . . echo. -e "$PWD3\n$PWD1" | $CRYPTSETUP luksAddKey -q $FAST_PBKDF_OPT -S 0 $LOOPDEV || failscip-shell shell shell-project 0.0.0 fail().
791 checkscip-shell shell shell-project 0.0.0 check(). $LUKS_HEADER $KEY_SLOT0 $KEY_MATERIAL0
792 echoscip-shell system . . echo. $PWD3 | $CRYPTSETUP luksOpen -S 0 $LOOPDEV $DEV_NAME 2>/dev/nullscip-shell filesystem . . `/dev/null`. && failscip-shell shell shell-project 0.0.0 fail().
793 [scip-shell system . . `[`. -b /dev/mapper/$DEV_NAME ] && failscip-shell shell shell-project 0.0.0 fail().
794 echoscip-shell system . . echo. $PWD1 | $CRYPTSETUP luksOpen -S 5 $LOOPDEV $DEV_NAME 2>/dev/nullscip-shell filesystem . . `/dev/null`. && failscip-shell shell shell-project 0.0.0 fail().
795 [scip-shell system . . `[`. -b /dev/mapper/$DEV_NAME ] && failscip-shell shell shell-project 0.0.0 fail().
796 # second, try it with keyfiles
797 $CRYPTSETUP luksFormat --type luks1 -q -S 5 -d $KEY5 $LOOPDEV || failscip-shell shell shell-project 0.0.0 fail().
798 checkscip-shell shell shell-project 0.0.0 check(). $LUKS_HEADER $KEY_SLOT5 $KEY_MATERIAL5
799 $CRYPTSETUP luksAddKey -q $FAST_PBKDF_OPT -S 1 -d $KEY5 $LOOPDEV $KEY1 || failscip-shell shell shell-project 0.0.0 fail().
800 checkscip-shell shell shell-project 0.0.0 check(). $LUKS_HEADER $KEY_SLOT1 $KEY_MATERIAL1
801 $CRYPTSETUP luksOpen -S 5 -d $KEY5 $LOOPDEV $DEV_NAME || failscip-shell shell shell-project 0.0.0 fail().
802 check_existsscip-shell shell shell-project 0.0.0 check_exists().
803 $CRYPTSETUP luksSuspend $DEV_NAME || failscip-shell shell shell-project 0.0.0 fail().
804 $CRYPTSETUP luksResume -S 1 -d $KEY5 $DEV_NAME 2>/dev/nullscip-shell filesystem . . `/dev/null`. && failscip-shell shell shell-project 0.0.0 fail().
805 $CRYPTSETUP -q status $DEV_NAME | grepscip-shell system . . grep. -q "(suspended)" || failscip-shell shell shell-project 0.0.0 fail().
806 $CRYPTSETUP luksResume -S 5 -d $KEY5 $DEV_NAME || failscip-shell shell shell-project 0.0.0 fail().
807 $CRYPTSETUP luksClose $DEV_NAME || failscip-shell shell shell-project 0.0.0 fail().
808 $CRYPTSETUP luksOpen -S 1 -d $KEY5 $LOOPDEV $DEV_NAME 2>/dev/nullscip-shell filesystem . . `/dev/null`. && failscip-shell shell shell-project 0.0.0 fail().
809 [scip-shell system . . `[`. -b /dev/mapper/$DEV_NAME ] && failscip-shell shell shell-project 0.0.0 fail().
810 $CRYPTSETUP luksOpen -S 5 -d $KEY1 $LOOPDEV $DEV_NAME 2>/dev/nullscip-shell filesystem . . `/dev/null`. && failscip-shell shell shell-project 0.0.0 fail().
811 [scip-shell system . . `[`. -b /dev/mapper/$DEV_NAME ] && failscip-shell shell shell-project 0.0.0 fail().
812
813 preparescip-shell shell shell-project 0.0.0 prepare(). "[28] Detached LUKS header" wipe
814 echoscip-shell system . . echo. $PWD1 | $CRYPTSETUP luksFormat --type luks1 $FAST_PBKDF_OPT $LOOPDEV --header $HEADER_IMG || failscip-shell shell shell-project 0.0.0 fail().
815 echoscip-shell system . . echo. $PWD1 | $CRYPTSETUP luksFormat --type luks1 $FAST_PBKDF_OPT $LOOPDEV --header $HEADER_IMG --align-payload 1 >/dev/nullscip-shell filesystem . . `/dev/null`. 2>&1 && failscip-shell shell shell-project 0.0.0 fail().
816 echoscip-shell system . . echo. $PWD1 | $CRYPTSETUP -q luksFormat --type luks1 $FAST_PBKDF_OPT $LOOPDEV --header $HEADER_IMG --align-payload 8192 || failscip-shell shell shell-project 0.0.0 fail().
817 echoscip-shell system . . echo. $PWD1 | $CRYPTSETUP -q luksFormat --type luks1 $FAST_PBKDF_OPT $LOOPDEV --header $HEADER_IMG --align-payload 0 || failscip-shell shell shell-project 0.0.0 fail().
818 echoscip-shell system . . echo. $PWD1 | $CRYPTSETUP -q luksFormat --type luks1 $FAST_PBKDF_OPT $LOOPDEV --header $HEADER_IMG --align-payload 8192 --offset 8192 >/dev/nullscip-shell filesystem . . `/dev/null`. 2>&1 && failscip-shell shell shell-project 0.0.0 fail().
819 truncatescip-shell system . . truncate. -s 4096 $HEADER_IMG || failscip-shell shell shell-project 0.0.0 fail().
820 echoscip-shell system . . echo. $PWD1 | $CRYPTSETUP -q luksFormat --type luks1 $FAST_PBKDF_OPT $LOOPDEV --header $HEADER_IMG -S7 >/dev/nullscip-shell filesystem . . `/dev/null`. 2>&1 || failscip-shell shell shell-project 0.0.0 fail().
821 echoscip-shell system . . echo. $PWD1 | $CRYPTSETUP -q luksFormat --type luks1 $FAST_PBKDF_OPT $LOOPDEV --header $HEADER_IMG --offset 80000 >/dev/nullscip-shell filesystem . . `/dev/null`. 2>&1 || failscip-shell shell shell-project 0.0.0 fail().
822 echoscip-shell system . . echo. $PWD1 | $CRYPTSETUP -q luksFormat --type luks1 $FAST_PBKDF_OPT $LOOPDEV --header $HEADER_IMG --offset 8192 || failscip-shell shell shell-project 0.0.0 fail().
823 echoscip-shell system . . echo. $PWD1 | $CRYPTSETUP -q luksFormat --type luks1 $FAST_PBKDF_OPT $LOOPDEV --header $HEADER_IMG --offset 0 || failscip-shell shell shell-project 0.0.0 fail().
824 echoscip-shell system . . echo. $PWD1 | $CRYPTSETUP luksOpen $LOOPDEV-missing --header $HEADER_IMG $DEV_NAME 2>/dev/nullscip-shell filesystem . . `/dev/null`. && failscip-shell shell shell-project 0.0.0 fail().
825 echoscip-shell system . . echo. $PWD1 | $CRYPTSETUP luksOpen $LOOPDEV --header $HEADER_IMG $DEV_NAME || failscip-shell shell shell-project 0.0.0 fail().
826 $CRYPTSETUP -q resize $DEV_NAME --size 100 --header $HEADER_IMG || failscip-shell shell shell-project 0.0.0 fail().
827 $CRYPTSETUP -q status $DEV_NAME --header $HEADER_IMG | grepscip-shell system . . grep. "size:" | grepscip-shell system . . grep. -q "100 \[512-byte units\]" || failscip-shell shell shell-project 0.0.0 fail().
828 $CRYPTSETUP -q status $DEV_NAME | grepscip-shell system . . grep. "type:" | grepscip-shell system . . grep. -q "n/a" || failscip-shell shell shell-project 0.0.0 fail().
829 $CRYPTSETUP -q status $DEV_NAME | grepscip-shell system . . grep. "size:" | grepscip-shell system . . grep. -q "100 \[512-byte units\]" || failscip-shell shell shell-project 0.0.0 fail().
830 $CRYPTSETUP luksSuspend $DEV_NAME --header $HEADER_IMG || failscip-shell shell shell-project 0.0.0 fail().
831 echoscip-shell system . . echo. $PWD1 | $CRYPTSETUP luksResume $DEV_NAME --header $HEADER_IMG || failscip-shell shell shell-project 0.0.0 fail().
832 $CRYPTSETUP luksSuspend $DEV_NAME || failscip-shell shell shell-project 0.0.0 fail().
833 echoscip-shell system . . echo. $PWD1 | $CRYPTSETUP luksResume $DEV_NAME 2>/dev/nullscip-shell filesystem . . `/dev/null`. && failscip-shell shell shell-project 0.0.0 fail().
834 echoscip-shell system . . echo. $PWD1 | $CRYPTSETUP luksResume $DEV_NAME --header $HEADER_IMG || failscip-shell shell shell-project 0.0.0 fail().
835 $CRYPTSETUP luksClose $DEV_NAME || failscip-shell shell shell-project 0.0.0 fail().
836 echoscip-shell system . . echo. $PWD1 | $CRYPTSETUP luksAddKey -q $FAST_PBKDF_OPT -S 5 _fakedev_ --header $HEADER_IMG $KEY5 || failscip-shell shell shell-project 0.0.0 fail().
837 $CRYPTSETUP luksDump _fakedev_ --header $HEADER_IMG | grepscip-shell system . . grep. -q "Key Slot 5: ENABLED" || failscip-shell shell shell-project 0.0.0 fail().
838 $CRYPTSETUP luksKillSlot -q _fakedev_ --header $HEADER_IMG 5 || failscip-shell shell shell-project 0.0.0 fail().
839 $CRYPTSETUP luksDump _fakedev_ --header $HEADER_IMG | grepscip-shell system . . grep. -q "Key Slot 5: DISABLED" || failscip-shell shell shell-project 0.0.0 fail().
840 echoscip-shell system . . echo. $PWD1 | $CRYPTSETUP open --test-passphrase $HEADER_IMG || failscip-shell shell shell-project 0.0.0 fail().
841
842 preparescip-shell shell shell-project 0.0.0 prepare(). "[29] Repair metadata" wipe
843 $CRYPTSETUP -q luksFormat --type luks1 $FAST_PBKDF_OPT $LOOPDEV $KEY1 --key-slot 0 || failscip-shell shell shell-project 0.0.0 fail().
844 # second sector overwrite should corrupt keyslot 6+7
845 ddscip-shell system . . dd. if=/dev/urandomscip-shell filesystem . . `/dev/urandom`. of=$LOOPDEV bs=512 seek=1 count=1 >/dev/nullscip-shell filesystem . . `/dev/null`. 2>&1
846 $CRYPTSETUP luksOpen -d $KEY1 $LOOPDEV $DEV_NAME >/dev/nullscip-shell filesystem . . `/dev/null`. 2>&1 && failscip-shell shell shell-project 0.0.0 fail().
847 $CRYPTSETUP -q repair $LOOPDEV >/dev/nullscip-shell filesystem . . `/dev/null`. 2>&1 || failscip-shell shell shell-project 0.0.0 fail().
848 $CRYPTSETUP luksOpen -d $KEY1 $LOOPDEV $DEV_NAME || failscip-shell shell shell-project 0.0.0 fail().
849 $CRYPTSETUP luksClose $DEV_NAME || failscip-shell shell shell-project 0.0.0 fail().
850 # fix ecb-plain
851 $CRYPTSETUP -q luksFormat --type luks1 $FAST_PBKDF_OPT $LOOPDEV $KEY1 --hash sha256 -c aes-ecb || failscip-shell shell shell-project 0.0.0 fail().
852 echoscip-shell system . . echo. -n "ecb-xxx" | ddscip-shell system . . dd. of=$LOOPDEV bs=1 seek=40 >/dev/nullscip-shell filesystem . . `/dev/null`. 2>&1
853 $CRYPTSETUP -q repair $LOOPDEV >/dev/nullscip-shell filesystem . . `/dev/null`. 2>&1 || failscip-shell shell shell-project 0.0.0 fail().
854 $CRYPTSETUP luksOpen -d $KEY1 $LOOPDEV $DEV_NAME || failscip-shell shell shell-project 0.0.0 fail().
855 $CRYPTSETUP luksClose $DEV_NAME || failscip-shell shell shell-project 0.0.0 fail().
856 # fix uppercase hash
857 echoscip-shell system . . echo. -n "SHA256" | ddscip-shell system . . dd. of=$LOOPDEV bs=1 seek=72 >/dev/nullscip-shell filesystem . . `/dev/null`. 2>&1
858 $CRYPTSETUP -q repair $LOOPDEV >/dev/nullscip-shell filesystem . . `/dev/null`. 2>&1 || failscip-shell shell shell-project 0.0.0 fail().
859 $CRYPTSETUP luksOpen -d $KEY1 $LOOPDEV $DEV_NAME || failscip-shell shell shell-project 0.0.0 fail().
860 $CRYPTSETUP luksClose $DEV_NAME || failscip-shell shell shell-project 0.0.0 fail().
861
862 preparescip-shell shell shell-project 0.0.0 prepare(). "[30] LUKS erase" wipe
863 $CRYPTSETUP -q luksFormat --type luks1 $FAST_PBKDF_OPT $LOOPDEV $KEY5 --key-slot 5 || failscip-shell shell shell-project 0.0.0 fail().
864 $CRYPTSETUP luksAddKey -q $FAST_PBKDF_OPT -S 1 -d $KEY5 $LOOPDEV $KEY1 || failscip-shell shell shell-project 0.0.0 fail().
865 $CRYPTSETUP luksDump $LOOPDEV | grepscip-shell system . . grep. -q "Key Slot 1: ENABLED" || failscip-shell shell shell-project 0.0.0 fail().
866 $CRYPTSETUP luksDump $LOOPDEV | grepscip-shell system . . grep. -q "Key Slot 5: ENABLED" || failscip-shell shell shell-project 0.0.0 fail().
867 $CRYPTSETUP luksErase -q $LOOPDEV || failscip-shell shell shell-project 0.0.0 fail().
868 $CRYPTSETUP luksDump $LOOPDEV | grepscip-shell system . . grep. -q "Key Slot 1: DISABLED" || failscip-shell shell shell-project 0.0.0 fail().
869 $CRYPTSETUP luksDump $LOOPDEV | grepscip-shell system . . grep. -q "Key Slot 5: DISABLED" || failscip-shell shell shell-project 0.0.0 fail().
870
871 preparescip-shell shell shell-project 0.0.0 prepare(). "[31] Deferred removal of device" wipe
872 echoscip-shell system . . echo. $PWD1 | $CRYPTSETUP open --type plain $PLAIN_OPT $LOOPDEV $DEV_NAME || failscip-shell shell shell-project 0.0.0 fail().
873 echoscip-shell system . . echo. $PWD2 | $CRYPTSETUP open --type plain $PLAIN_OPT /dev/mapper/$DEV_NAME $DEV_NAME2 || failscip-shell shell shell-project 0.0.0 fail().
874 $CRYPTSETUP close $DEV_NAME >/dev/nullscip-shell filesystem . . `/dev/null`. 2>&1 && failscip-shell shell shell-project 0.0.0 fail().
875 $CRYPTSETUP -q status $DEV_NAME >/dev/nullscip-shell filesystem . . `/dev/null`. 2>&1 || failscip-shell shell shell-project 0.0.0 fail().
876 $CRYPTSETUP close --deferred $DEV_NAME >/dev/nullscip-shell filesystem . . `/dev/null`. 2>&1
877 if [scip-shell system . . `[`. $? -eq 0 ] ; then
878 dmsetup info $DEV_NAME | grepscip-shell system . . grep. -q "DEFERRED REMOVE" || failscip-shell shell shell-project 0.0.0 fail().
879 $CRYPTSETUP -q status $DEV_NAME >/dev/nullscip-shell filesystem . . `/dev/null`. 2>&1 || failscip-shell shell shell-project 0.0.0 fail().
880 $CRYPTSETUP close --cancel-deferred $DEV_NAME >/dev/nullscip-shell filesystem . . `/dev/null`. 2>&1
881 dmsetup info $DEV_NAME | grepscip-shell system . . grep. -q "DEFERRED REMOVE" >/dev/nullscip-shell filesystem . . `/dev/null`. 2>&1 && failscip-shell shell shell-project 0.0.0 fail().
882 $CRYPTSETUP close --deferred $DEV_NAME >/dev/nullscip-shell filesystem . . `/dev/null`. 2>&1
883 $CRYPTSETUP close $DEV_NAME2 || failscip-shell shell shell-project 0.0.0 fail().
884 $CRYPTSETUP -q status $DEV_NAME >/dev/nullscip-shell filesystem . . `/dev/null`. 2>&1 && failscip-shell shell shell-project 0.0.0 fail().
885 else
886 $CRYPTSETUP close $DEV_NAME2 >/dev/nullscip-shell filesystem . . `/dev/null`. 2>&1
887 $CRYPTSETUP close $DEV_NAME >/dev/nullscip-shell filesystem . . `/dev/null`. 2>&1
888 fi
889 # Deferred remove of device without DM-UUID
890 dmsetup create $DEV_NAME --table "0 8 crypt aes-xts-plain64 e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855 0 $LOOPDEV 0" || failscip-shell shell shell-project 0.0.0 fail().
891 $CRYPTSETUP close --deferred $DEV_NAME || failscip-shell shell shell-project 0.0.0 fail().
892
893 # Interactive tests
894 # Do not remove sleep 0.1 below, the password query flushes TTY buffer (so the code is racy).
895 command -v expect >/dev/nullscip-shell filesystem . . `/dev/null`. || skipscip-shell shell shell-project 0.0.0 skip(). "WARNING: expect tool missing, interactive test will be skipped." 0
896
897 preparescip-shell shell shell-project 0.0.0 prepare(). "[32] Interactive password retry from terminal." new
898 EXPECT_DEV=$(losetupscip-shell system . . losetup. $LOOPDEV | sedscip-shell system . . sed. -e "s/.*(\(.*\))/\1/")
899 EXPECT_TIMEOUT=60
900
901 expect_runscip-shell shell shell-project 0.0.0 expect_run(). - >/dev/nullscip-shell filesystem . . `/dev/null`. <<EOF
902 proc abort {} { send_error "Timeout. "; exit 2 }
903 set timeout $EXPECT_TIMEOUT
904 eval spawn $CRYPTSETUP_RAW luksOpen -v -T 2 $LOOPDEV $DEV_NAME
905 expect timeout abort "Enter passphrase for $EXPECT_DEV:"
906 sleep 0.1
907 send "$PWD0 x\n"
908 expect timeout abort "No key available with this passphrase."
909 expect timeout abort "Enter passphrase for $EXPECT_DEV:"
910 sleep 0.1
911 send "$PWD0\n"
912 expect timeout abort "Key slot 0 unlocked."
913 expect timeout abort "Command successful."
914 expect timeout abort eof
915 exit
916 EOF
917 [scip-shell system . . `[`. $? -eq 0 ] || failscip-shell shell shell-project 0.0.0 fail(). "Expect script failed."
918 check_existsscip-shell shell shell-project 0.0.0 check_exists().
919 $CRYPTSETUP -q luksClose $DEV_NAME || failscip-shell shell shell-project 0.0.0 fail().
920
921 preparescip-shell shell shell-project 0.0.0 prepare(). "[33] Interactive unsuccessful password retry from terminal." new
922 expect_runscip-shell shell shell-project 0.0.0 expect_run(). - >/dev/nullscip-shell filesystem . . `/dev/null`. <<EOF
923 proc abort {} { send_error "Timeout. "; exit 2 }
924 set timeout $EXPECT_TIMEOUT
925 eval spawn $CRYPTSETUP_RAW luksOpen -v -T 2 $LOOPDEV $DEV_NAME
926 expect timeout abort "Enter passphrase for $EXPECT_DEV:"
927 sleep 0.1
928 send "$PWD0 x\n"
929 expect timeout abort "No key available with this passphrase."
930 expect timeout abort "Enter passphrase for $EXPECT_DEV:"
931 sleep 0.1
932 send "$PWD0 y\n"
933 expect timeout abort "No key available with this passphrase."
934 expect timeout abort eof
935 exit
936 EOF
937 [scip-shell system . . `[`. $? -eq 0 ] || failscip-shell shell shell-project 0.0.0 fail(). "Expect script failed."
938
939 preparescip-shell shell shell-project 0.0.0 prepare(). "[34] Interactive kill of last key slot." new
940 expect_runscip-shell shell shell-project 0.0.0 expect_run(). - >/dev/nullscip-shell filesystem . . `/dev/null`. <<EOF
941 proc abort {} { send_error "Timeout. "; exit 2 }
942 set timeout $EXPECT_TIMEOUT
943 eval spawn $CRYPTSETUP_RAW luksKillSlot -v $LOOPDEV 0
944 expect timeout abort "Are you sure? (Type 'yes' in capital letters):"
945 send "YES\n"
946 expect timeout abort "Enter any remaining passphrase:"
947 sleep 0.1
948 send "$PWD0\n"
949 expect timeout abort "Command successful."
950 expect timeout abort eof
951 eval spawn $CRYPTSETUP_RAW luksKillSlot -v $LOOPDEV 0
952 expect timeout abort "Keyslot 0 is not active."
953 expect timeout abort eof
954 exit
955 EOF
956 [scip-shell system . . `[`. $? -eq 0 ] || failscip-shell shell shell-project 0.0.0 fail(). "Expect script failed."
957
958 preparescip-shell shell shell-project 0.0.0 prepare(). "[35] Interactive format of device." wipe
959 expect_runscip-shell shell shell-project 0.0.0 expect_run(). - >/dev/nullscip-shell filesystem . . `/dev/null`. <<EOF
960 proc abort {} { send_error "Timeout. "; exit 2 }
961 set timeout $EXPECT_TIMEOUT
962 eval spawn $CRYPTSETUP_RAW luksFormat --type luks1 --force-password $FAST_PBKDF_OPT -v $LOOPDEV
963 expect timeout abort "Are you sure? (Type 'yes' in capital letters):"
964 send "YES\n"
965 expect timeout abort "Enter passphrase for $EXPECT_DEV:"
966 sleep 0.1
967 send "$PWD0\n"
968 expect timeout abort "Verify passphrase:"
969 sleep 0.1
970 send "$PWD0\n"
971 expect timeout abort "Command successful."
972 expect timeout abort eof
973 eval spawn $CRYPTSETUP_RAW luksOpen -v $LOOPDEV --test-passphrase
974 expect timeout abort "Enter passphrase for $EXPECT_DEV:"
975 sleep 0.1
976 send "$PWD0\n"
977 expect timeout abort "Command successful."
978 expect timeout abort eof
979 exit
980 EOF
981 [scip-shell system . . `[`. $? -eq 0 ] || failscip-shell shell shell-project 0.0.0 fail(). "Expect script failed."
982
983 preparescip-shell shell shell-project 0.0.0 prepare(). "[36] Interactive unsuccessful format of device." new
984 expect_runscip-shell shell shell-project 0.0.0 expect_run(). - >/dev/nullscip-shell filesystem . . `/dev/null`. <<EOF
985 proc abort {} { send_error "Timeout. "; exit 2 }
986 set timeout $EXPECT_TIMEOUT
987 eval spawn $CRYPTSETUP_RAW erase -v $LOOPDEV
988 expect timeout abort "Are you sure? (Type 'yes' in capital letters):"
989 send "YES\n"
990 expect timeout abort "Command successful."
991 expect timeout abort eof
992 eval spawn $CRYPTSETUP_RAW luksFormat --type luks1 --force-password $FAST_PBKDF_OPT -v $LOOPDEV
993 expect timeout abort "Are you sure? (Type 'yes' in capital letters):"
994 send "YES\n"
995 expect timeout abort "Enter passphrase for $EXPECT_DEV:"
996 sleep 0.1
997 send "$PWD0\n"
998 expect timeout abort "Verify passphrase:"
999 sleep 0.1
1000 send "$PWD0 x\n"
1001 expect timeout abort "Passphrases do not match."
1002 expect timeout abort eof
1003 eval spawn $CRYPTSETUP_RAW luksOpen -v $LOOPDEV -T 1 --test-passphrase
1004 expect timeout abort "Enter passphrase for $EXPECT_DEV:"
1005 sleep 0.1
1006 send "$PWD0\n"
1007 expect timeout abort "No usable keyslot is available."
1008 expect timeout abort eof
1009 exit
1010 EOF
1011 [scip-shell system . . `[`. $? -eq 0 ] || failscip-shell shell shell-project 0.0.0 fail(). "Expect script failed."
1012
1013 preparescip-shell shell shell-project 0.0.0 prepare(). "[37] Interactive add key." new
1014 expect_runscip-shell shell shell-project 0.0.0 expect_run(). - >/dev/nullscip-shell filesystem . . `/dev/null`. <<EOF
1015 proc abort {} { send_error "Timeout. "; exit 2 }
1016 set timeout $EXPECT_TIMEOUT
1017 eval spawn $CRYPTSETUP_RAW luksAddKey -S 2 $FAST_PBKDF_OPT -v $LOOPDEV
1018 expect timeout abort "Enter any existing passphrase:"
1019 sleep 0.1
1020 send "$PWD0\n"
1021 expect timeout abort "Enter new passphrase for key slot:"
1022 sleep 0.1
1023 send "$PWD1\n"
1024 expect timeout abort "Verify passphrase:"
1025 sleep 0.1
1026 send "$PWD1\n"
1027 expect timeout abort "Command successful."
1028 expect timeout abort eof
1029 eval spawn $CRYPTSETUP_RAW luksOpen -v $LOOPDEV --test-passphrase
1030 expect timeout abort "Enter passphrase"
1031 sleep 0.1
1032 send "$PWD1\n"
1033 expect timeout abort "Command successful."
1034 expect timeout abort eof
1035 eval spawn $CRYPTSETUP_RAW luksKillSlot -v $LOOPDEV 1
1036 expect timeout abort "Keyslot 1 is not active."
1037 expect timeout abort eof
1038 eval spawn $CRYPTSETUP_RAW luksKillSlot -v $LOOPDEV 2
1039 expect timeout abort "Enter any remaining passphrase:"
1040 sleep 0.1
1041 send "$PWD0\n"
1042 expect timeout abort "Key slot 2 removed."
1043 expect timeout abort eof
1044 exit
1045 EOF
1046 [scip-shell system . . `[`. $? -eq 0 ] || failscip-shell shell shell-project 0.0.0 fail(). "Expect script failed."
1047
1048 preparescip-shell shell shell-project 0.0.0 prepare(). "[38] Interactive change key." new
1049 expect_runscip-shell shell shell-project 0.0.0 expect_run(). - >/dev/nullscip-shell filesystem . . `/dev/null`. <<EOF
1050 proc abort {} { send_error "Timeout. "; exit 2 }
1051 set timeout $EXPECT_TIMEOUT
1052 eval spawn $CRYPTSETUP_RAW luksChangeKey $FAST_PBKDF_OPT -v $LOOPDEV
1053 expect timeout abort "Enter passphrase to be changed:"
1054 sleep 0.1
1055 send "$PWD0\n"
1056 expect timeout abort "Enter new passphrase:"
1057 sleep 0.1
1058 send "$PWD1\n"
1059 expect timeout abort "Verify passphrase:"
1060 sleep 0.1
1061 send "$PWD1\n"
1062 expect timeout abort "Command successful."
1063 expect timeout abort eof
1064 eval spawn $CRYPTSETUP_RAW luksOpen -v $LOOPDEV --test-passphrase
1065 expect timeout abort "Enter passphrase for $EXPECT_DEV:"
1066 sleep 0.1
1067 send "$PWD1\n"
1068 expect timeout abort "Command successful."
1069 expect timeout abort eof
1070 exit
1071 EOF
1072 [scip-shell system . . `[`. $? -eq 0 ] || failscip-shell shell shell-project 0.0.0 fail(). "Expect script failed."
1073
1074 preparescip-shell shell shell-project 0.0.0 prepare(). "[39] Interactive suspend and resume." new
1075 echoscip-shell system . . echo. $PWD0 | $CRYPTSETUP luksOpen $LOOPDEV $DEV_NAME || failscip-shell shell shell-project 0.0.0 fail().
1076 expect_runscip-shell shell shell-project 0.0.0 expect_run(). - >/dev/nullscip-shell filesystem . . `/dev/null`. <<EOF
1077 proc abort {} { send_error "Timeout. "; exit 2 }
1078 set timeout $EXPECT_TIMEOUT
1079 eval spawn $CRYPTSETUP_RAW luksSuspend -v $DEV_NAME
1080 expect timeout abort "Command successful."
1081 expect timeout abort eof
1082 eval spawn $CRYPTSETUP_RAW luksResume -v -T 3 $DEV_NAME
1083 expect timeout abort "Enter passphrase for $EXPECT_DEV:"
1084 sleep 0.1
1085 send "$PWD0 x\n"
1086 expect timeout abort "No key available with this passphrase."
1087 expect timeout abort "Enter passphrase for $EXPECT_DEV:"
1088 sleep 0.1
1089 send "$PWD1\n"
1090 expect timeout abort "No key available with this passphrase."
1091 expect timeout abort "Enter passphrase for $EXPECT_DEV:"
1092 sleep 0.1
1093 send "$PWD0 y\n"
1094 expect timeout abort "No key available with this passphrase."
1095 expect timeout abort eof
1096 eval spawn $CRYPTSETUP_RAW luksResume -v $DEV_NAME
1097 expect timeout abort "Enter passphrase for $EXPECT_DEV:"
1098 sleep 0.1
1099 send "$PWD0\n"
1100 expect timeout abort "Command successful."
1101 expect timeout abort eof
1102 exit
1103 EOF
1104 [scip-shell system . . `[`. $? -eq 0 ] || failscip-shell shell shell-project 0.0.0 fail(). "Expect script failed."
1105 $CRYPTSETUP remove $DEV_NAME || failscip-shell shell shell-project 0.0.0 fail().
1106
1107 preparescip-shell shell shell-project 0.0.0 prepare(). "[40] Long passphrase from TTY." wipe
1108 EXPECT_DEV=$(losetupscip-shell system . . losetup. $LOOPDEV | sedscip-shell system . . sed. -e "s/.*(\(.*\))/\1/")
1109
1110 # Password of maximal length 512 characters
1111 LONG_PWD=\
1112 "0123456789abcdef0123456789ABCDEF0123456789abcdef0123456789ABCDEF"\
1113 "Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do "\
1114 "eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut e"\
1115 "nim ad minim veniam, quis nostrud exercitation ullamco laboris n"\
1116 "isi ut aliquip ex ea commodo consequat. Duis aute irure dolor in"\
1117 " reprehenderit in voluptate velit esse cillum dolore eu fugiat n"\
1118 "ulla pariatur. Excepteur sint occaecat cupidatat non proident, s"\
1119 "unt in culpa qui officia deserunt mollit anim id est laborum.DEF"
1120
1121 echoscip-shell system . . echo. -n "$LONG_PWD" >$KEYE
1122
1123 expect_runscip-shell shell shell-project 0.0.0 expect_run(). - >/dev/nullscip-shell filesystem . . `/dev/null`. <<EOF
1124 proc abort {} { send_error "Timeout. "; exit 2 }
1125 set timeout $EXPECT_TIMEOUT
1126 eval spawn $CRYPTSETUP_RAW luksFormat --type luks1 --force-password $FAST_PBKDF_OPT -v $LOOPDEV
1127 expect timeout abort "Are you sure? (Type 'yes' in capital letters):"
1128 send "YES\n"
1129 expect timeout abort "Enter passphrase for $EXPECT_DEV:"
1130 sleep 0.1
1131 send "$LONG_PWD\n"
1132 expect timeout abort "Verify passphrase:"
1133 sleep 0.1
1134 send "$LONG_PWD\n"
1135 expect timeout abort "Command successful."
1136 expect timeout abort eof
1137 eval spawn $CRYPTSETUP_RAW luksOpen -v $LOOPDEV --test-passphrase --key-file $KEYE
1138 expect timeout abort "Command successful."
1139 expect timeout abort eof
1140 EOF
1141 [scip-shell system . . `[`. $? -eq 0 ] || failscip-shell shell shell-project 0.0.0 fail(). "Expect script failed."
1142
1143 preparescip-shell shell shell-project 0.0.0 prepare(). "[41] New luksAddKey options." file
1144 rmscip-shell system . . rm. -f $VK_FILE
1145 echoscip-shell system . . echo. "$PWD1" | $CRYPTSETUP luksFormat --type luks1 $FAST_PBKDF_OPT $IMG || failscip-shell shell shell-project 0.0.0 fail().
1146 echoscip-shell system . . echo. $PWD1 | $CRYPTSETUP luksDump -q $IMG --dump-volume-key --volume-key-file $VK_FILE >/dev/nullscip-shell filesystem . . `/dev/null`. || failscip-shell shell shell-project 0.0.0 fail().
1147
1148 # pass pass
1149 echoscip-shell system . . echo. -e "$PWD1\n$PWD2" | $CRYPTSETUP luksAddKey -q -S1 $FAST_PBKDF_OPT $IMG || failscip-shell shell shell-project 0.0.0 fail().
1150 echoscip-shell system . . echo. $PWD2 | $CRYPTSETUP open -q --test-passphrase -S1 $IMG || failscip-shell shell shell-project 0.0.0 fail().
1151
1152 # pass file
1153 echoscip-shell system . . echo. "$PWD2" | $CRYPTSETUP luksAddKey -q $FAST_PBKDF_OPT -S1 --new-key-slot 2 $IMG $KEY1 || failscip-shell shell shell-project 0.0.0 fail().
1154 $CRYPTSETUP open --test-passphrase -q -S2 -d $KEY1 $IMG || failscip-shell shell shell-project 0.0.0 fail().
1155
1156 # file pass
1157 echoscip-shell system . . echo. "$PWD3" | $CRYPTSETUP luksAddKey -q $FAST_PBKDF_OPT -S2 -d $KEY1 --new-key-slot 3 $IMG || failscip-shell shell shell-project 0.0.0 fail().
1158 echoscip-shell system . . echo. $PWD3 | $CRYPTSETUP open -q --test-passphrase -S3 $IMG || failscip-shell shell shell-project 0.0.0 fail().
1159
1160 # file file
1161 $CRYPTSETUP luksAddKey -q $FAST_PBKDF_OPT -S2 --new-key-slot 4 -d $KEY1 --new-keyfile $KEY2 $IMG || failscip-shell shell shell-project 0.0.0 fail().
1162 $CRYPTSETUP open --test-passphrase -q -S4 -d $KEY2 $IMG || failscip-shell shell shell-project 0.0.0 fail().
1163
1164 # vk pass
1165 echoscip-shell system . . echo. $PWD3 | $CRYPTSETUP luksAddKey -q $FAST_PBKDF_OPT -S5 --volume-key-file $VK_FILE $IMG || failscip-shell shell shell-project 0.0.0 fail().
1166 echoscip-shell system . . echo. $PWD3 | $CRYPTSETUP open -q --test-passphrase -S5 $IMG || failscip-shell shell shell-project 0.0.0 fail().
1167
1168 # vk file
1169 $CRYPTSETUP luksAddKey -q $FAST_PBKDF_OPT -S6 --volume-key-file $VK_FILE --new-keyfile $KEY5 $IMG || failscip-shell shell shell-project 0.0.0 fail().
1170 $CRYPTSETUP open --test-passphrase -q -S6 -d $KEY5 $IMG || failscip-shell shell shell-project 0.0.0 fail().
1171
1172 preparescip-shell shell shell-project 0.0.0 prepare(). "[40] Early check for active name." wipe
1173 DM_BAD_NAME=x/x
1174 DM_LONG_NAME=0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef
1175 echoscip-shell system . . echo. $PWD1 | $CRYPTSETUP open --type plain $LOOPDEV $DM_BAD_NAME --hash sha256 --cipher aes-cbc-essiv:sha256 --key-size 256 2>/dev/nullscip-shell filesystem . . `/dev/null`. && failscip-shell shell shell-project 0.0.0 fail().
1176 echoscip-shell system . . echo. $PWD1 | $CRYPTSETUP open --type plain $LOOPDEV $DM_LONG_NAME --hash sha256 --cipher aes-cbc-essiv:sha256 --key-size 256 2>/dev/nullscip-shell filesystem . . `/dev/null`. && failscip-shell shell shell-project 0.0.0 fail().
1177 echoscip-shell system . . echo. $PWD1 | $CRYPTSETUP luksFormat --type luks1 $FAST_PBKDF_OPT $LOOPDEV || failscip-shell shell shell-project 0.0.0 fail().
1178 echoscip-shell system . . echo. $PWD1 | $CRYPTSETUP luksOpen $LOOPDEV $DM_BAD_NAME 2>/dev/nullscip-shell filesystem . . `/dev/null`. && failscip-shell shell shell-project 0.0.0 fail().
1179 echoscip-shell system . . echo. $PWD1 | $CRYPTSETUP luksOpen $LOOPDEV $DM_LONG_NAME 2>/dev/nullscip-shell filesystem . . `/dev/null`. && failscip-shell shell shell-project 0.0.0 fail().
1180
1181 preparescip-shell shell shell-project 0.0.0 prepare(). "[41] Truncated keys." wipe
1182 echoscip-shell system . . echo. "$PWD1" | $CRYPTSETUP luksFormat -q --type luks1 $FAST_PBKDF_OPT --volume-key-file $KEY_TZERO -s256 $IMG || failscip-shell shell shell-project 0.0.0 fail().
1183 $CRYPTSETUP open -q --test-passphrase $IMG --volume-key-file $KEY_TZERO -s248 2>/dev/nullscip-shell filesystem . . `/dev/null`. && failscip-shell shell shell-project 0.0.0 fail().
1184 # cut the trailing zero byte
1185 truncatescip-shell system . . truncate. -c -s 31 $KEY_TZERO || failscip-shell shell shell-project 0.0.0 fail().
1186 echoscip-shell system . . echo. $PWD3 | $CRYPTSETUP luksAddKey -q $FAST_PBKDF_OPT -S5 --volume-key-file $KEY_TZERO $IMG 2>/dev/nullscip-shell filesystem . . `/dev/null`. && failscip-shell shell shell-project 0.0.0 fail().
1187 $CRYPTSETUP luksErase -q $IMG || failscip-shell shell shell-project 0.0.0 fail().
1188 echoscip-shell system . . echo. $PWD3 | $CRYPTSETUP luksAddKey -q $FAST_PBKDF_OPT -S5 --volume-key-file $KEY_TZERO $IMG 2>/dev/nullscip-shell filesystem . . `/dev/null`. && failscip-shell shell shell-project 0.0.0 fail().
1189
1190 echoscip-shell system . . echo. "$PWD1" | $CRYPTSETUP luksFormat -q --type luks1 $FAST_PBKDF_OPT --volume-key-file $KEY_HALF_ZERO -s512 $IMG || failscip-shell shell shell-project 0.0.0 fail().
1191 $CRYPTSETUP open -q --test-passphrase $IMG --volume-key-file $KEY_HALF_ZERO -s496 2>/dev/nullscip-shell filesystem . . `/dev/null`. && failscip-shell shell shell-project 0.0.0 fail().
1192 $CRYPTSETUP open -q --test-passphrase $IMG --volume-key-file $KEY_HALF_ZERO -s256 2>/dev/nullscip-shell filesystem . . `/dev/null`. && failscip-shell shell shell-project 0.0.0 fail().
1193 # cut the trailing zero byte
1194 truncatescip-shell system . . truncate. -c -s 63 $KEY_HALF_ZERO || failscip-shell shell shell-project 0.0.0 fail().
1195 echoscip-shell system . . echo. $PWD3 | $CRYPTSETUP luksAddKey -q $FAST_PBKDF_OPT -S5 --volume-key-file $KEY_HALF_ZERO $IMG 2>/dev/nullscip-shell filesystem . . `/dev/null`. && failscip-shell shell shell-project 0.0.0 fail().
1196 # cut all remaining zero bytes down to 256bits key
1197 truncatescip-shell system . . truncate. -c -s 32 $KEY_HALF_ZERO || failscip-shell shell shell-project 0.0.0 fail().
1198 echoscip-shell system . . echo. $PWD3 | $CRYPTSETUP luksAddKey -q $FAST_PBKDF_OPT -S5 --volume-key-file $KEY_HALF_ZERO $IMG 2>/dev/nullscip-shell filesystem . . `/dev/null`. && failscip-shell shell shell-project 0.0.0 fail().
1199 $CRYPTSETUP luksErase -q $IMG || failscip-shell shell shell-project 0.0.0 fail().
1200 truncatescip-shell system . . truncate. -c -s 63 $KEY_HALF_ZERO || failscip-shell shell shell-project 0.0.0 fail().
1201 echoscip-shell system . . echo. $PWD3 | $CRYPTSETUP luksAddKey -q $FAST_PBKDF_OPT -S5 --volume-key-file $KEY_HALF_ZERO $IMG 2>/dev/nullscip-shell filesystem . . `/dev/null`. && failscip-shell shell shell-project 0.0.0 fail().
1202 truncatescip-shell system . . truncate. -c -s 32 $KEY_HALF_ZERO || failscip-shell shell shell-project 0.0.0 fail().
1203 echoscip-shell system . . echo. $PWD3 | $CRYPTSETUP luksAddKey -q $FAST_PBKDF_OPT -S5 --volume-key-file $KEY_HALF_ZERO $IMG 2>/dev/nullscip-shell filesystem . . `/dev/null`. && failscip-shell shell shell-project 0.0.0 fail().
1204
1205 remove_mappingscip-shell shell shell-project 0.0.0 remove_mapping().
1206 exit 0