Debian Codegraph @

tests/compat-test2

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
8 if [scip-shell system . . `[`. -n "$CRYPTSETUP_TESTS_RUN_IN_MESON" ]; then
9 CRYPTSETUP_VALGRIND=$CRYPTSETUP
10 else
11 CRYPTSETUP_VALGRIND=../.libs/cryptsetup
12 CRYPTSETUP_LIB_VALGRIND=../.libs
13 fi
14
15 DEV_NAME=dummy
16 DEV_NAME2=dummy2
17 DEV_NAME3=dummy3
18 ORIG_IMG=luks-test-orig
19 IMG=luks-test
20 IMG10=luks-test-v10
21 HEADER_IMG=luks-header
22 HEADER_KEYU=luks2_keyslot_unassigned.img
23 HEADER_LUKS2_PV=blkid-luks2-pv.img
24 HEADER_LUKS2_INV=luks2_invalid_cipher.img
25 KEY1=key1
26 KEY2=key2
27 KEY5=key5
28 KEYE=keye
29 KEY_TZERO=key_trailing_zero
30 KEY_HALF_ZERO=key_half_zeroes
31 PWD0="compatkey"
32 PWD1="93R4P4pIqAH8"
33 PWD2="mymJeD8ivEhE"
34 PWD3="ocMakf3fAcQO"
35 PWD4="Qx3qn46vq0v"
36 PWDW="rUkL4RUryBom"
37 TEST_KEYRING_NAME="compattest2_keyring"
38 TEST_KEY_DESC0="compattest2_desc0"
39 TEST_KEY_DESC1="compattest2_desc1"
40 TEST_KEY_DESC2="compattest2_desc2"
41 VK_FILE="compattest2_vkfile"
42 IMPORT_TOKEN="{\"type\":\"some_type\",\"keyslots\":[],\"base64_data\":\"zxI7vKB1Qwl4VPB4D-N-OgcC14hPCG0IDu8O7eCqaQ\"}"
43 TOKEN_FILE0=test-token-file0
44 TOKEN_FILE1=test-token-file1
45 KEY_FILE0=test-key-file0
46 KEY_FILE1=test-key-file1
47
48 FAST_PBKDF_OPT="--pbkdf pbkdf2 --pbkdf-force-iterations 1000"
49
50 # 32 MiB + 1KiB to bypass minimal memory check (hardocoded)
51 FAST_PBKDF_ARGON_OPT="--pbkdf argon2id --pbkdf-force-iterations 4 --pbkdf-memory 32769 --pbkdf-parallel 1"
52
53 # TODO: this is configurable
54 LUKS2_LOCKING_DIR=/run/cryptsetupscip-shell filesystem . . `/run/cryptsetup`.
55 # hardcoded value
56 MEMORY_HARD_LOCK_FILE=LN_memory-hard-access
57
58 TEST_UUID="12345678-1234-1234-1234-123456789abc"
59
60 LOOPDEV=$(losetupscip-shell system . . losetup. -f 2>/dev/nullscip-shell filesystem . . `/dev/null`.)
61 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`.)
62
63 remove_mappingscip-shell shell shell-project 0.0.0 remove_mapping().()
64 {
65 [scip-shell system . . `[`. -b /dev/mapper/$DEV_NAME3 ] && dmsetup remove --retry $DEV_NAME3
66 [scip-shell system . . `[`. -b /dev/mapper/$DEV_NAME2 ] && dmsetup remove --retry $DEV_NAME2
67 [scip-shell system . . `[`. -b /dev/mapper/$DEV_NAME ] && dmsetup remove --retry $DEV_NAME
68 losetupscip-shell system . . losetup. -d $LOOPDEV >/dev/nullscip-shell filesystem . . `/dev/null`. 2>&1
69 rmscip-shell system . . rm. -f $ORIG_IMG $IMG $IMG10 $KEY1 $KEY2 $KEY5 $KEYE $KEY_TZERO $KEY_HALF_ZERO $HEADER_IMG $HEADER_KEYU $VK_FILE \
70 $HEADER_LUKS2_PV $HEADER_LUKS2_INV missing-file $TOKEN_FILE0 $TOKEN_FILE1 test_image_* \
71 $KEY_FILE0 $KEY_FILE1 >/dev/nullscip-shell filesystem . . `/dev/null`. 2>&1
72
73 # unlink whole test keyring
74 [scip-shell system . . `[`. -n "$TEST_KEYRING" ] && keyctl unlink $TEST_KEYRING "@u" >/dev/nullscip-shell filesystem . . `/dev/null`.
75 unset TEST_KEYRING
76
77 rmmod scsi_debug >/dev/nullscip-shell filesystem . . `/dev/null`. 2>&1
78 scsi_debug_teardownscip-shell shell shell-project 0.0.0 scsi_debug_teardown(). $DEV
79 }
80
81 force_ueventscip-shell shell shell-project 0.0.0 force_uevent().()
82 {
83 DNAME=$(echoscip-shell system . . echo. $LOOPDEV | cutscip-shell system . . cut. -f3 -d /scip-shell filesystem . . `/`.)
84 echoscip-shell system . . echo. "change" >/sys/block/$DNAME/uevent
85 }
86
87 failscip-shell shell shell-project 0.0.0 fail().()
88 {
89 [scip-shell system . . `[`. -n "$1" ] && echoscip-shell system . . echo. "$1"
90 remove_mappingscip-shell shell shell-project 0.0.0 remove_mapping().
91 echoscip-shell system . . echo. "FAILED backtrace:"
92 while caller $frame; do ((frame++)); done
93 exit 2
94 }
95
96 _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"; }
97 trap _sigchld CHLD
98
99 fips_modescip-shell shell shell-project 0.0.0 fips_mode().()
100 {
101 [scip-shell system . . `[`. -n "$FIPS_MODE" ] && [scip-shell system . . `[`. "$FIPS_MODE" -gt 0 ]
102 }
103
104 can_fail_fipsscip-shell shell shell-project 0.0.0 can_fail_fips().()
105 {
106 # Ignore this fail if running in FIPS mode
107 fips_modescip-shell shell shell-project 0.0.0 fips_mode(). || failscip-shell shell shell-project 0.0.0 fail(). $1
108 }
109
110 skipscip-shell shell shell-project 0.0.0 skip().()
111 {
112 [scip-shell system . . `[`. -n "$1" ] && echoscip-shell system . . echo. "$1"
113 remove_mappingscip-shell shell shell-project 0.0.0 remove_mapping().
114 exit 77
115 }
116
117 preparescip-shell shell shell-project 0.0.0 prepare().()
118 {
119 [scip-shell system . . `[`. -b /dev/mapper/$DEV_NAME ] && dmsetup remove --retry $DEV_NAME
120
121 case "$2" in
122 wipe)
123 remove_mappingscip-shell shell shell-project 0.0.0 remove_mapping().
124 ddscip-shell system . . dd. if=/dev/zeroscip-shell filesystem . . `/dev/zero`. of=$IMG bs=1M count=40 >/dev/nullscip-shell filesystem . . `/dev/null`. 2>&1
125 syncscip-shell system . . sync.
126 losetupscip-shell system . . losetup. $LOOPDEV $IMG
127 ;;
128 new)
129 remove_mappingscip-shell shell shell-project 0.0.0 remove_mapping().
130 xzscip-shell system . . xz. -cd compatimage.img.xz > $IMG
131 xzscip-shell system . . xz. -dk $HEADER_KEYU.xz
132 # FIXME: switch to internal loop (no losetup at all)
133 echoscip-shell system . . echo. "bad" | $CRYPTSETUP luksOpen --key-slot 0 --test-passphrase $IMG 2>&1 | \
134 grep "autoclear flag" && skipscip-shell shell shell-project 0.0.0 skip(). "WARNING: Too old kernel, test skipped."
135 losetupscip-shell system . . losetup. $LOOPDEV $IMG
136 xzscip-shell system . . xz. -cd compatv10image.img.xz > $IMG10
137 ;;
138 reuse | *)
139 if [scip-shell system . . `[`. ! -e $IMG ]; then
140 xzscip-shell system . . xz. -cd compatimage.img.xz > $IMG
141 losetupscip-shell system . . losetup. $LOOPDEV $IMG
142 fi
143 [scip-shell system . . `[`. ! -e $IMG10 ] && xzscip-shell system . . xz. -cd compatv10image.img.xz > $IMG10
144 ;;
145 esac
146
147 if [scip-shell system . . `[`. ! -e $KEY1 ]; then
148 #dd if=/dev/urandom of=$KEY1 count=1 bs=32 >/dev/null 2>&1
149 echoscip-shell system . . echo. -n $'\x48\xc6\x74\x4f\x41\x4e\x50\xc0\x79\xc2\x2d\x5b\x5f\x68\x84\x17' >$KEY1
150 echoscip-shell system . . echo. -n $'\x9c\x03\x5e\x1b\x4d\x0f\x9a\x75\xb3\x90\x70\x32\x0a\xf8\xae\xc4'>>$KEY1
151 fi
152
153 if [scip-shell system . . `[`. ! -e $KEY2 ]; then
154 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
155 fi
156
157 if [scip-shell system . . `[`. ! -e $KEY5 ]; then
158 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
159 fi
160
161 if [scip-shell system . . `[`. ! -e $KEYE ]; then
162 touchscip-shell system . . touch. $KEYE
163 fi
164
165 if [scip-shell system . . `[`. ! -e $KEY_TZERO ]; then
166 echoscip-shell system . . echo. -ne '\xa6\x32\x09\x5f\xdb\xbe\xf3\xc6\xa7\xac\xed\x85\x73\xac\xa8\xfb' >$KEY_TZERO
167 echoscip-shell system . . echo. -ne '\x09\xd4\x38\xfd\x58\x24\x17\x1b\x98\xa3\xef\x1e\xe4\x4b\xbc\x00'>>$KEY_TZERO
168 fi
169
170 if [scip-shell system . . `[`. ! -e $KEY_HALF_ZERO ]; then
171 echoscip-shell system . . echo. -ne '\xa6\x32\x09\x5f\xdb\xbe\xf3\xc6\xa7\xac\xed\x85\x73\xac\xa8\xfb' >$KEY_HALF_ZERO
172 echoscip-shell system . . echo. -ne '\x09\xd4\x38\xfd\x58\x24\x17\x1b\x98\xa3\xef\x1e\xe4\x4b\xbc\xc9'>>$KEY_HALF_ZERO
173 echoscip-shell system . . echo. -ne '\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00'>>$KEY_HALF_ZERO
174 echoscip-shell system . . echo. -ne '\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00'>>$KEY_HALF_ZERO
175 fi
176
177 cpscip-shell system . . cp. $IMG $ORIG_IMG
178 [scip-shell system . . `[`. -n "$1" ] && echoscip-shell system . . echo. "CASE: $1"
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 }
185
186 valgrind_setupscip-shell shell shell-project 0.0.0 valgrind_setup().()
187 {
188 command -v valgrind >/dev/nullscip-shell filesystem . . `/dev/null`. || failscip-shell shell shell-project 0.0.0 fail(). "Cannot find valgrind."
189 [scip-shell system . . `[`. ! -f $CRYPTSETUP_VALGRIND ] && failscip-shell shell shell-project 0.0.0 fail(). "Unable to get location of cryptsetup executable."
190 [scip-shell system . . `[`. ! -f valg.sh ] && failscip-shell shell shell-project 0.0.0 fail(). "Unable to get location of valg runner script."
191 if [scip-shell system . . `[`. -z "$CRYPTSETUP_TESTS_RUN_IN_MESON" ]; then
192 export LD_LIBRARY_PATH="$CRYPTSETUP_LIB_VALGRIND:$LD_LIBRARY_PATH"
193 fi
194 }
195
196 valgrind_runscip-shell shell shell-project 0.0.0 valgrind_run().()
197 {
198 INFOSTRING="$(basenamescip-shell system . . basename. ${BASH_SOURCE[1]})-line-${BASH_LINENO[0]}" ./valg.sh ${CRYPTSETUP_VALGRIND} "$@"
199 }
200
201 dm_crypt_capi_supportscip-shell shell shell-project 0.0.0 dm_crypt_capi_support().()
202 {
203 VER_STR=$(dmsetup targets | grepscip-shell system . . grep. crypt | cutscip-shell system . . cut. -f2 -dv)
204 [scip-shell system . . `[`. -z "$VER_STR" ] && failscip-shell shell shell-project 0.0.0 fail(). "Failed to parse dm-crypt version."
205
206 VER_MAJ=$(echoscip-shell system . . echo. $VER_STR | cutscip-shell system . . cut. -f 1 -d.)
207 VER_MIN=$(echoscip-shell system . . echo. $VER_STR | cutscip-shell system . . cut. -f 2 -d.)
208
209 [scip-shell system . . `[`. $VER_MAJ -gt 1 ] && return 0
210 if [scip-shell system . . `[`. $VER_MIN -ge 16 ]; then
211 return 0
212 fi
213 return 1
214 }
215
216 dm_crypt_keyring_supportscip-shell shell shell-project 0.0.0 dm_crypt_keyring_support().()
217 {
218 $CRYPTSETUP --version | grepscip-shell system . . grep. -q KEYRING || return 1
219
220 VER_STR=$(dmsetup targets | grepscip-shell system . . grep. crypt | cutscip-shell system . . cut. -f2 -dv)
221 [scip-shell system . . `[`. -z "$VER_STR" ] && failscip-shell shell shell-project 0.0.0 fail(). "Failed to parse dm-crypt version."
222
223 VER_MAJ=$(echoscip-shell system . . echo. $VER_STR | cutscip-shell system . . cut. -f 1 -d.)
224 VER_MIN=$(echoscip-shell system . . echo. $VER_STR | cutscip-shell system . . cut. -f 2 -d.)
225 VER_PTC=$(echoscip-shell system . . echo. $VER_STR | cutscip-shell system . . cut. -f 3 -d.)
226
227 testscip-shell system . . test. -d /proc/sys/kernel/keysscip-shell filesystem . . `/proc/sys/kernel/keys`. || return 1
228
229 [scip-shell system . . `[`. $VER_MAJ -gt 1 ] && return 0
230 [scip-shell system . . `[`. $VER_MAJ -eq 1 -a $VER_MIN -gt 18 ] && return 0
231 [scip-shell system . . `[`. $VER_MAJ -eq 1 -a $VER_MIN -eq 18 -a $VER_PTC -ge 1 ] && return 0
232 return 1
233 }
234
235 dm_crypt_keyring_flawedscip-shell shell shell-project 0.0.0 dm_crypt_keyring_flawed().()
236 {
237 dm_crypt_keyring_supportscip-shell shell shell-project 0.0.0 dm_crypt_keyring_support(). && return 1;
238
239 [scip-shell system . . `[`. $VER_MAJ -gt 1 ] && return 0
240 [scip-shell system . . `[`. $VER_MAJ -eq 1 -a $VER_MIN -ge 15 ] && return 0
241 return 1
242 }
243
244 dm_crypt_keyring_new_kernelscip-shell shell shell-project 0.0.0 dm_crypt_keyring_new_kernel().()
245 {
246 KER_STR=$(unamescip-shell system . . uname. -r)
247 [scip-shell system . . `[`. -z "$KER_STR" ] && failscip-shell shell shell-project 0.0.0 fail(). "Failed to parse kernel version."
248 KER_MAJ=$(echoscip-shell system . . echo. $KER_STR | cutscip-shell system . . cut. -f 1 -d.)
249 KER_MIN=$(echoscip-shell system . . echo. $KER_STR | cutscip-shell system . . cut. -f 2 -d.)
250
251 [scip-shell system . . `[`. $KER_MAJ -ge 5 ] && return 0
252 [scip-shell system . . `[`. $KER_MAJ -eq 4 -a $KER_MIN -ge 15 ] && return 0
253 return 1
254 }
255
256 dm_crypt_sector_size_supportscip-shell shell shell-project 0.0.0 dm_crypt_sector_size_support().()
257 {
258 VER_STR=$(dmsetup targets | grepscip-shell system . . grep. crypt | cutscip-shell system . . cut. -f2 -dv)
259 [scip-shell system . . `[`. -z "$VER_STR" ] && failscip-shell shell shell-project 0.0.0 fail(). "Failed to parse dm-crypt version."
260
261 VER_MAJ=$(echoscip-shell system . . echo. $VER_STR | cutscip-shell system . . cut. -f 1 -d.)
262 VER_MIN=$(echoscip-shell system . . echo. $VER_STR | cutscip-shell system . . cut. -f 2 -d.)
263 VER_PTC=$(echoscip-shell system . . echo. $VER_STR | cutscip-shell system . . cut. -f 3 -d.)
264
265 [scip-shell system . . `[`. $VER_MAJ -gt 1 ] && return 0
266 if [scip-shell system . . `[`. $VER_MIN -ge 17 -o \( $VER_MIN -eq 14 -a $VER_PTC -ge 5 \) ]; then
267 return 0
268 fi
269
270 return 1
271 }
272
273 test_and_prepare_keyringscip-shell shell shell-project 0.0.0 test_and_prepare_keyring().() {
274 command -v keyctl >/dev/nullscip-shell filesystem . . `/dev/null`. || skipscip-shell shell shell-project 0.0.0 skip(). "Cannot find keyctl, test skipped"
275 keyctl list "@s" > /dev/nullscip-shell filesystem . . `/dev/null`. || skipscip-shell shell shell-project 0.0.0 skip(). "Current session keyring is unreachable, test skipped"
276 TEST_KEYRING=$(keyctl newring $TEST_KEYRING_NAME "@u" 2> /dev/nullscip-shell filesystem . . `/dev/null`.)
277 testscip-shell system . . test. -n "$TEST_KEYRING" || skipscip-shell shell shell-project 0.0.0 skip(). "Failed to create keyring in user keyring"
278 keyctl search "@s" keyring "$TEST_KEYRING" > /dev/nullscip-shell filesystem . . `/dev/null`. 2>&1 || keyctl link "@u" "@s" > /dev/nullscip-shell filesystem . . `/dev/null`. 2>&1
279 load_keyscip-shell shell shell-project 0.0.0 load_key(). user test_key test_data "$TEST_KEYRING" || skipscip-shell shell shell-project 0.0.0 skip(). "Kernel keyring service is useless on this system, test skipped."
280 }
281
282 # $1 type
283 # $2 description
284 # $3 payload
285 # $4 keyring
286 load_keyscip-shell shell shell-project 0.0.0 load_key().()
287 {
288 [scip-shell system . . `[`. -z "$4" ] && failscip-shell shell shell-project 0.0.0 fail(). "Keyring not defined!"
289 keyctl add $@ >/dev/nullscip-shell filesystem . . `/dev/null`.
290 }
291
292 setup_luks2_envscip-shell shell shell-project 0.0.0 setup_luks2_env().() {
293 echoscip-shell system . . echo. $PWD1 | $CRYPTSETUP luksFormat --type luks2 $FAST_PBKDF_OPT $LOOPDEV || failscip-shell shell shell-project 0.0.0 fail().
294 $CRYPTSETUP luksDump $LOOPDEV >/dev/nullscip-shell filesystem . . `/dev/null`. || failscip-shell shell shell-project 0.0.0 fail().
295 echoscip-shell system . . echo. $PWD1 | $CRYPTSETUP open $LOOPDEV $DEV_NAME || failscip-shell shell shell-project 0.0.0 fail().
296 HAVE_KEYRING=$($CRYPTSETUP status $DEV_NAME | grepscip-shell system . . grep. "keyring")
297 if [scip-shell system . . `[`. -n "$HAVE_KEYRING" ]; then
298 HAVE_KEYRING=1
299 else
300 HAVE_KEYRING=0
301 fi
302 if $($CRYPTSETUP --version | grepscip-shell system . . grep. -q "BLKID"); then
303 HAVE_BLKID=1
304 else
305 HAVE_BLKID=0
306 fi
307 $CRYPTSETUP close $DEV_NAME || failscip-shell shell shell-project 0.0.0 fail().
308 }
309
310 # $1 path to scsi debug bdev
311 scsi_debug_teardownscip-shell shell shell-project 0.0.0 scsi_debug_teardown().() {
312 local _tries=15;
313
314 while [scip-shell system . . `[`. -b "$1" -a $_tries -gt 0 ]; do
315 rmmod scsi_debug >/dev/nullscip-shell filesystem . . `/dev/null`. 2>&1
316 if [scip-shell system . . `[`. -b "$1" ]; then
317 sleepscip-shell system . . sleep. .1
318 _tries=$((_tries-1))
319 fi
320 done
321
322 testscip-shell system . . test. ! -b "$1" || rmmod scsi_debug >/dev/nullscip-shell filesystem . . `/dev/null`. 2>&1
323 }
324
325 add_scsi_devicescip-shell shell shell-project 0.0.0 add_scsi_device().() {
326 scsi_debug_teardownscip-shell shell shell-project 0.0.0 scsi_debug_teardown(). $DEV
327 if [scip-shell system . . `[`. -d /sys/module/scsi_debugscip-shell filesystem . . `/sys/module/scsi_debug`. ] ; then
328 echoscip-shell system . . echo. "Cannot use scsi_debug module (in use or compiled-in), test skipped."
329 exit 77
330 fi
331 modprobe scsi_debug $@ delay=0 >/dev/nullscip-shell filesystem . . `/dev/null`. 2>&1
332 if [scip-shell system . . `[`. $? -ne 0 ] ; then
333 echoscip-shell system . . echo. "This kernel seems to not support proper scsi_debug module, test skipped."
334 exit 77
335 fi
336
337 sleepscip-shell system . . sleep. 1
338 DEV="/dev/"$(grepscip-shell system . . grep. -l -e scsi_debug /sys/block/*/device/model | cutscip-shell system . . cut. -f4 -d /scip-shell filesystem . . `/`.)
339 [scip-shell system . . `[`. -b $DEV ] || return 1
340 return 0
341 }
342
343 # $1 key name
344 # $2 keyring to link VK to
345 # $3 key type (optional)
346 test_vk_link_with_passphrase_checkscip-shell shell shell-project 0.0.0 test_vk_link_with_passphrase_check().() {
347 KEY_TYPE=${3:-user}
348 if [scip-shell system . . `[`. -z "$3" ]; then
349 KEY_DESC=$1
350 else
351 KEY_DESC="%$3:$1"
352 fi
353
354 KEYCTL_KEY_NAME="%$KEY_TYPE:$1"
355
356 echoscip-shell system . . echo. $PWD1 | $CRYPTSETUP open --test-passphrase $LOOPDEV --link-vk-to-keyring "$2"::"$KEY_DESC" || failscip-shell shell shell-project 0.0.0 fail().
357 keyctl search "$2" $KEY_TYPE $1 > /dev/nullscip-shell filesystem . . `/dev/null`. 2>&1 || failscip-shell shell shell-project 0.0.0 fail(). "VK is not linked to the specified keyring after --test-passphrase."
358 if [scip-shell system . . `[`. $KEY_TYPE = "user" ]; then
359 $CRYPTSETUP open $LOOPDEV --test-passphrase --volume-key-keyring $KEY_DESC <&-|| failscip-shell shell shell-project 0.0.0 fail(). "Failed to check volume passed via kernel keyring."
360 fi
361 keyctl unlink "$KEYCTL_KEY_NAME" "$2" || failscip-shell shell shell-project 0.0.0 fail().
362
363 echoscip-shell system . . echo. $PWD1 | $CRYPTSETUP open --test-passphrase $LOOPDEV || failscip-shell shell shell-project 0.0.0 fail().
364 keyctl search "$2" $KEY_TYPE $1 > /dev/nullscip-shell filesystem . . `/dev/null`. 2>&1 && failscip-shell shell shell-project 0.0.0 fail(). "VK is unexpectedly linked to the specified keyring."
365 }
366
367 # $1 key name
368 # $2 keyring to link VK to
369 # $3 key type (optional)
370 test_vk_linkscip-shell shell shell-project 0.0.0 test_vk_link().() {
371 KEY_TYPE=${3:-user}
372 if [scip-shell system . . `[`. -z "$3" ]; then
373 KEY_DESC=$1
374 else
375 KEY_DESC="%$3:$1"
376 fi
377
378 KEYCTL_KEY_NAME="%$KEY_TYPE:$1"
379
380 echoscip-shell system . . echo. $PWD1 | $CRYPTSETUP open $LOOPDEV $DEV_NAME --link-vk-to-keyring "$2"::"$KEY_DESC" || failscip-shell shell shell-project 0.0.0 fail().
381 keyctl search "$2" $KEY_TYPE $1 > /dev/nullscip-shell filesystem . . `/dev/null`. 2>&1 || failscip-shell shell shell-project 0.0.0 fail(). "VK is not linked to the specified keyring after activation."
382 $CRYPTSETUP close $DEV_NAME
383 keyctl search "$2" $KEY_TYPE $1 > /dev/nullscip-shell filesystem . . `/dev/null`. 2>&1 || failscip-shell shell shell-project 0.0.0 fail(). "VK is not linked to the specified keyring after deactivation."
384 keyctl unlink "$KEYCTL_KEY_NAME" "$2" || failscip-shell shell shell-project 0.0.0 fail().
385
386 echoscip-shell system . . echo. $PWD1 | $CRYPTSETUP open $LOOPDEV $DEV_NAME || failscip-shell shell shell-project 0.0.0 fail().
387 keyctl search "$2" $KEY_TYPE $1 > /dev/nullscip-shell filesystem . . `/dev/null`. 2>&1 && failscip-shell shell shell-project 0.0.0 fail(). "VK is linked to the specified keyring before resume with linking."
388 $CRYPTSETUP luksSuspend $DEV_NAME || failscip-shell shell shell-project 0.0.0 fail().
389 echoscip-shell system . . echo. $PWD1 | $CRYPTSETUP luksResume $DEV_NAME --link-vk-to-keyring "$2"::"$KEY_DESC" || failscip-shell shell shell-project 0.0.0 fail().
390 keyctl search "$2" $KEY_TYPE $1 > /dev/nullscip-shell filesystem . . `/dev/null`. 2>&1 || failscip-shell shell shell-project 0.0.0 fail(). "VK is not linked to the specified keyring after activation."
391 $CRYPTSETUP close $DEV_NAME
392 keyctl search "$2" $KEY_TYPE $1 > /dev/nullscip-shell filesystem . . `/dev/null`. 2>&1 || failscip-shell shell shell-project 0.0.0 fail(). "VK is not linked to the specified keyring after deactivation."
393 keyctl unlink "$KEYCTL_KEY_NAME" "$2" || failscip-shell shell shell-project 0.0.0 fail().
394 }
395
396 # $1 key name
397 # $2 keyring to link VK to
398 # $3 key type (optional)
399 test_vk_link_and_reactivatescip-shell shell shell-project 0.0.0 test_vk_link_and_reactivate().() {
400 KEY_TYPE=${3:-user}
401 if [scip-shell system . . `[`. -z "$3" ]; then
402 KEY_DESC=$1
403 else
404 KEY_DESC="%$3:$1"
405 fi
406
407 KEYCTL_KEY_NAME="%$KEY_TYPE:$1"
408
409 echoscip-shell system . . echo. $PWD1 | $CRYPTSETUP open $LOOPDEV $DEV_NAME --link-vk-to-keyring "$2"::"$KEY_DESC" || failscip-shell shell shell-project 0.0.0 fail().
410 keyctl search "$2" $KEY_TYPE $1 > /dev/nullscip-shell filesystem . . `/dev/null`. 2>&1 || failscip-shell shell shell-project 0.0.0 fail(). "VK is not linked to the specified keyring after activation."
411 $CRYPTSETUP close $DEV_NAME || failscip-shell shell shell-project 0.0.0 fail().
412 keyctl search "$2" $KEY_TYPE $1 > /dev/nullscip-shell filesystem . . `/dev/null`. 2>&1 || failscip-shell shell shell-project 0.0.0 fail(). "VK is not linked to the specified keyring after deactivation."
413 $CRYPTSETUP open $LOOPDEV $DEV_NAME --volume-key-keyring $KEY_DESC <&-|| failscip-shell shell shell-project 0.0.0 fail(). "Failed to unlock volume via a VK in keyring."
414 $CRYPTSETUP luksSuspend $DEV_NAME || failscip-shell shell shell-project 0.0.0 fail(). "Failed to suspend device."
415 $CRYPTSETUP luksResume $DEV_NAME --volume-key-keyring $KEY_DESC <&- || failscip-shell shell shell-project 0.0.0 fail(). "Failed to resume via a VK in keyring."
416
417 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().
418 echoscip-shell system . . echo. $PWD2 | $CRYPTSETUP luksOpen $LOOPDEV --test-passphrase 2>/dev/nullscip-shell filesystem . . `/dev/null`. && failscip-shell shell shell-project 0.0.0 fail().
419 echoscip-shell system . . echo. $PWD2 | $CRYPTSETUP luksAddKey $FAST_PBKDF_OPT --volume-key-keyring $KEY_DESC $LOOPDEV --new-key-slot 1 || failscip-shell shell shell-project 0.0.0 fail(). "Failed to add passphrase by VK in keyring."
420 echoscip-shell system . . echo. $PWD2 | $CRYPTSETUP luksOpen $LOOPDEV --test-passphrase 2>/dev/nullscip-shell filesystem . . `/dev/null`. || failscip-shell shell shell-project 0.0.0 fail().
421 $CRYPTSETUP luksKillSlot -q $LOOPDEV 1 2>/dev/nullscip-shell filesystem . . `/dev/null`. || failscip-shell shell shell-project 0.0.0 fail().
422
423 $CRYPTSETUP close $DEV_NAME || failscip-shell shell shell-project 0.0.0 fail().
424 # zero-out the key in keyring
425 keyctl pipe $KEYCTL_KEY_NAME | trscip-shell system . . tr. -c '\0' '\0' | keyctl pupdate $KEYCTL_KEY_NAME
426 $CRYPTSETUP open $LOOPDEV $DEV_NAME --volume-key-keyring $KEY_DESC <&- > /dev/nullscip-shell filesystem . . `/dev/null`. 2>&1 && failscip-shell shell shell-project 0.0.0 fail(). "Unlocked volume via a bad VK in keyring."
427 keyctl search "$2" $KEY_TYPE $1 > /dev/nullscip-shell filesystem . . `/dev/null`. 2>&1 || failscip-shell shell shell-project 0.0.0 fail(). "VK is not linked to the specified keyring after bad activation."
428 keyctl unlink $KEYCTL_KEY_NAME "$2" || failscip-shell shell shell-project 0.0.0 fail().
429 }
430
431 # $1 first key name
432 # $2 second key name
433 # $3 keyring to link VK to
434 # $4 key type (optional)
435 test_reencrypt_vk_linkscip-shell shell shell-project 0.0.0 test_reencrypt_vk_link().() {
436 KEY_TYPE=${4:-user}
437 if [scip-shell system . . `[`. -z "$4" ]; then
438 KEY_DESC=$1
439 else
440 KEY_DESC="%$4:$1"
441 fi
442 if [scip-shell system . . `[`. -z "$4" ]; then
443 KEY_DESC2=$2
444 else
445 KEY_DESC2="%$4:$2"
446 fi
447
448 KEYCTL_KEY_NAME="%$KEY_TYPE:$1"
449 KEYCTL_KEY_NAME2="%$KEY_TYPE:$2"
450
451 echoscip-shell system . . echo. $PWD1 | $CRYPTSETUP open $LOOPDEV $DEV_NAME --link-vk-to-keyring "$3"::"$KEY_DESC" --link-vk-to-keyring "$3"::"$KEY_DESC2" || failscip-shell shell shell-project 0.0.0 fail().
452 keyctl search "$3" $KEY_TYPE $1 > /dev/nullscip-shell filesystem . . `/dev/null`. 2>&1 || failscip-shell shell shell-project 0.0.0 fail(). "VK is not linked to the specified keyring after activation."
453
454 keyctl search "$3" $KEY_TYPE $1 > /dev/nullscip-shell filesystem . . `/dev/null`. 2>&1 || failscip-shell shell shell-project 0.0.0 fail(). "VK is not linked to the specified keyring after activation."
455 keyctl search "$3" $KEY_TYPE $2 > /dev/nullscip-shell filesystem . . `/dev/null`. 2>&1 || failscip-shell shell shell-project 0.0.0 fail(). "VK is not linked to the specified keyring after activation."
456 $CRYPTSETUP close $DEV_NAME || failscip-shell shell shell-project 0.0.0 fail().
457 keyctl search "$3" $KEY_TYPE $1 > /dev/nullscip-shell filesystem . . `/dev/null`. 2>&1 || failscip-shell shell shell-project 0.0.0 fail(). "VK is not linked to the specified keyring after deactivation."
458 keyctl search "$3" $KEY_TYPE $2 > /dev/nullscip-shell filesystem . . `/dev/null`. 2>&1 || failscip-shell shell shell-project 0.0.0 fail(). "VK is not linked to the specified keyring after deactivation."
459
460 keyctl unlink $KEYCTL_KEY_NAME "$3" || failscip-shell shell shell-project 0.0.0 fail().
461 keyctl unlink $KEYCTL_KEY_NAME2 "$3" || failscip-shell shell shell-project 0.0.0 fail().
462 }
463
464 # $1 first key name
465 # $2 second key name
466 # $3 keyring to link VK to
467 # $4 key type (optional)
468 test_reencrypt_vk_link_and_reactivatescip-shell shell shell-project 0.0.0 test_reencrypt_vk_link_and_reactivate().() {
469 KEY_TYPE=${4:-user}
470 if [scip-shell system . . `[`. -z "$4" ]; then
471 KEY_DESC=$1
472 else
473 KEY_DESC="%$4:$1"
474 fi
475 if [scip-shell system . . `[`. -z "$4" ]; then
476 KEY_DESC2=$2
477 else
478 KEY_DESC2="%$4:$2"
479 fi
480
481 KEYCTL_KEY_NAME="%$KEY_TYPE:$1"
482 KEYCTL_KEY_NAME2="%$KEY_TYPE:$2"
483
484 echoscip-shell system . . echo. $PWD1 | $CRYPTSETUP open $LOOPDEV $DEV_NAME --link-vk-to-keyring "$3"::"$KEY_DESC" --link-vk-to-keyring "$3"::"$KEY_DESC2" || failscip-shell shell shell-project 0.0.0 fail().
485 keyctl search "$3" $KEY_TYPE $1 > /dev/nullscip-shell filesystem . . `/dev/null`. 2>&1 || failscip-shell shell shell-project 0.0.0 fail(). "VK is not linked to the specified keyring after activation."
486
487 keyctl search "$3" $KEY_TYPE $1 > /dev/nullscip-shell filesystem . . `/dev/null`. 2>&1 || failscip-shell shell shell-project 0.0.0 fail(). "VK is not linked to the specified keyring after activation."
488 keyctl search "$3" $KEY_TYPE $2 > /dev/nullscip-shell filesystem . . `/dev/null`. 2>&1 || failscip-shell shell shell-project 0.0.0 fail(). "VK is not linked to the specified keyring after activation."
489 $CRYPTSETUP close $DEV_NAME || failscip-shell shell shell-project 0.0.0 fail().
490 keyctl search "$3" $KEY_TYPE $1 > /dev/nullscip-shell filesystem . . `/dev/null`. 2>&1 || failscip-shell shell shell-project 0.0.0 fail(). "VK is not linked to the specified keyring after deactivation."
491 keyctl search "$3" $KEY_TYPE $2 > /dev/nullscip-shell filesystem . . `/dev/null`. 2>&1 || failscip-shell shell shell-project 0.0.0 fail(). "VK is not linked to the specified keyring after deactivation."
492
493 echoscip-shell system . . echo. $PWD1 | $CRYPTSETUP open $LOOPDEV $DEV_NAME --volume-key-keyring "$KEY_DESC" --volume-key-keyring "$KEY_DESC2" || failscip-shell shell shell-project 0.0.0 fail().
494 $CRYPTSETUP close $DEV_NAME || failscip-shell shell shell-project 0.0.0 fail().
495
496 keyctl unlink $KEYCTL_KEY_NAME "$3" || failscip-shell shell shell-project 0.0.0 fail().
497 echoscip-shell system . . echo. $PWD1 | $CRYPTSETUP open $LOOPDEV $DEV_NAME --volume-key-keyring "$KEY_DESC" --volume-key-keyring "$KEY_DESC2" > /dev/nullscip-shell filesystem . . `/dev/null`. 2>&1 && failscip-shell shell shell-project 0.0.0 fail().
498 keyctl unlink $KEYCTL_KEY_NAME2 "$3" || failscip-shell shell shell-project 0.0.0 fail().
499 echoscip-shell system . . echo. $PWD1 | $CRYPTSETUP open $LOOPDEV $DEV_NAME --volume-key-keyring "$KEY_DESC" --volume-key-keyring "$KEY_DESC2" > /dev/nullscip-shell filesystem . . `/dev/null`. 2>&1 && failscip-shell shell shell-project 0.0.0 fail().
500 }
501
502
503 # $1 substring to search for in /proc/keys
504 wait_key_dissapearedscip-shell shell shell-project 0.0.0 wait_key_dissapeared().()
505 {
506 local ret=
507 local tries=50
508
509 grepscip-shell system . . grep. -q $1 /proc/keysscip-shell filesystem . . `/proc/keys`.
510 ret=$?
511
512 while [scip-shell system . . `[`. $ret -eq 0 -a $tries -gt 0 ]; do
513 sleepscip-shell system . . sleep. .1
514 grepscip-shell system . . grep. -q $1 /proc/keysscip-shell filesystem . . `/proc/keys`.
515 ret=$?
516 tries=$((tries-1))
517 done
518
519 testscip-shell system . . test. $ret -ne 0
520 }
521
522 expect_runscip-shell shell shell-project 0.0.0 expect_run().()
523 {
524 export INFOSTRING="$(basenamescip-shell system . . basename. ${BASH_SOURCE[1]})-line-${BASH_LINENO[0]}"
525 expect "$@"
526 }
527
528 # expected unlocked keyslot id
529 # command arguments
530 expect_unlocked_keyslotscip-shell shell shell-project 0.0.0 expect_unlocked_keyslot().()
531 {
532 command -v expect >/dev/nullscip-shell filesystem . . `/dev/null`. || {
533 echoscip-shell system . . echo. "WARNING: expect tool missing, interactive test will be skipped."
534 return 0
535 }
536
537 EXPECT_TIMEOUT=60
538 EXPECT_KEY=$1
539
540 expect_runscip-shell shell shell-project 0.0.0 expect_run(). - >/dev/nullscip-shell filesystem . . `/dev/null`. <<EOF
541 proc abort {} { send_error "Timeout. "; exit 2 }
542 set timeout $EXPECT_TIMEOUT
543 eval spawn $CRYPTSETUP_RAW $2
544 expect timeout abort "Key slot $EXPECT_KEY unlocked."
545 expect timeout abort "Command successful."
546 expect timeout abort eof
547 exit
548 EOF
549 [scip-shell system . . `[`. $? -eq 0 ] || return 1
550 }
551
552 # expected unlocked keyslot id
553 # password
554 # command arguments
555 expect_retried_unlocked_keyslotscip-shell shell shell-project 0.0.0 expect_retried_unlocked_keyslot().()
556 {
557 command -v expect >/dev/nullscip-shell filesystem . . `/dev/null`. || {
558 echoscip-shell system . . echo. "WARNING: expect tool missing, interactive test will be skipped."
559 return 0
560 }
561
562 EXPECT_TIMEOUT=60
563
564 expect_runscip-shell shell shell-project 0.0.0 expect_run(). - >/dev/nullscip-shell filesystem . . `/dev/null`. <<EOF
565 proc abort {} { send_error "Timeout. "; exit 2 }
566 set timeout $EXPECT_TIMEOUT
567 eval spawn $CRYPTSETUP_RAW $3
568 expect timeout abort "Enter passphrase for*:"
569 sleep 0.1
570 send "$2 x\n"
571 expect timeout abort "No key available with this passphrase."
572 expect timeout abort "Enter passphrase for*:"
573 sleep 0.1
574 send "$2\n"
575 expect timeout abort "Key slot $1 unlocked."
576 expect timeout abort "Command successful."
577 expect timeout abort eof
578 exit
579 EOF
580 [scip-shell system . . `[`. $? -eq 0 ] || return 1
581 }
582
583 export LANG=C
584
585 [scip-shell system . . `[`. ! -x "$CRYPTSETUP" ] && skipscip-shell shell shell-project 0.0.0 skip(). "Cannot find $CRYPTSETUP, test skipped."
586 [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."
587 [scip-shell system . . `[`. -z "$LOOPDEV" ] && skipscip-shell shell shell-project 0.0.0 skip(). "WARNING: Cannot find free loop device, test skipped."
588
589 preparescip-shell shell shell-project 0.0.0 prepare(). "[0] Detect LUKS2 environment" wipe
590 setup_luks2_envscip-shell shell shell-project 0.0.0 setup_luks2_env().
591
592 [scip-shell system . . `[`. -n "$VALG" ] && valgrind_setupscip-shell shell shell-project 0.0.0 valgrind_setup(). && CRYPTSETUP=valgrind_run
593
594 preparescip-shell shell shell-project 0.0.0 prepare(). "[1] Data offset" wipe
595 echoscip-shell system . . echo. $PWD1 | $CRYPTSETUP luksFormat $FAST_PBKDF_OPT --type luks2 $LOOPDEV -q --offset 1 2>/dev/nullscip-shell filesystem . . `/dev/null`. && failscip-shell shell shell-project 0.0.0 fail().
596 echoscip-shell system . . echo. $PWD1 | $CRYPTSETUP luksFormat $FAST_PBKDF_OPT --type luks2 $LOOPDEV -q --offset 16385 2>/dev/nullscip-shell filesystem . . `/dev/null`. && failscip-shell shell shell-project 0.0.0 fail().
597 echoscip-shell system . . echo. $PWD1 | $CRYPTSETUP luksFormat $FAST_PBKDF_OPT --type luks2 $LOOPDEV -q --offset 32 2>/dev/nullscip-shell filesystem . . `/dev/null`. && failscip-shell shell shell-project 0.0.0 fail().
598 echoscip-shell system . . echo. $PWD1 | $CRYPTSETUP luksFormat $FAST_PBKDF_OPT --type luks2 $LOOPDEV -q --align-payload 16384 --offset 16384 2>/dev/nullscip-shell filesystem . . `/dev/null`. && failscip-shell shell shell-project 0.0.0 fail().
599 echoscip-shell system . . echo. $PWD1 | $CRYPTSETUP luksFormat $FAST_PBKDF_OPT --type luks2 $LOOPDEV -q --offset 16384 || failscip-shell shell shell-project 0.0.0 fail().
600 $CRYPTSETUP -q luksDump $LOOPDEV | grepscip-shell system . . grep. -q "offset: $((512 * 16384)) \[bytes\]" || failscip-shell shell shell-project 0.0.0 fail().
601 echoscip-shell system . . echo. $PWD1 | $CRYPTSETUP luksFormat $FAST_PBKDF_OPT --type luks2 $LOOPDEV -q --sector-size 1024 --offset 16384 >/dev/nullscip-shell filesystem . . `/dev/null`. || failscip-shell shell shell-project 0.0.0 fail().
602 $CRYPTSETUP -q luksDump $LOOPDEV | grepscip-shell system . . grep. -q "offset: $((512 * 16384)) \[bytes\]" || failscip-shell shell shell-project 0.0.0 fail().
603 truncatescip-shell system . . truncate. -s 4096 $HEADER_IMG || failscip-shell shell shell-project 0.0.0 fail().
604 echoscip-shell system . . echo. $PWD1 | $CRYPTSETUP luksFormat $FAST_PBKDF_OPT --type luks2 $LOOPDEV --header $HEADER_IMG -q --offset 80000 >/dev/nullscip-shell filesystem . . `/dev/null`. 2>&1 || failscip-shell shell shell-project 0.0.0 fail().
605
606 preparescip-shell shell shell-project 0.0.0 prepare(). "[2] Sector size and old payload alignment" wipe
607 echoscip-shell system . . echo. $PWD1 | $CRYPTSETUP luksFormat $FAST_PBKDF_OPT --type luks2 $LOOPDEV -q --sector-size 511 2>/dev/nullscip-shell filesystem . . `/dev/null`. && failscip-shell shell shell-project 0.0.0 fail().
608 echoscip-shell system . . echo. $PWD1 | $CRYPTSETUP luksFormat $FAST_PBKDF_OPT --type luks2 $LOOPDEV -q --sector-size 256 2>/dev/nullscip-shell filesystem . . `/dev/null`. && failscip-shell shell shell-project 0.0.0 fail().
609 echoscip-shell system . . echo. $PWD1 | $CRYPTSETUP luksFormat $FAST_PBKDF_OPT --type luks2 $LOOPDEV -q --sector-size 8192 2>/dev/nullscip-shell filesystem . . `/dev/null`. && failscip-shell shell shell-project 0.0.0 fail().
610 echoscip-shell system . . echo. $PWD1 | $CRYPTSETUP luksFormat $FAST_PBKDF_OPT --type luks2 $LOOPDEV -q --sector-size 512 || failscip-shell shell shell-project 0.0.0 fail().
611 echoscip-shell system . . echo. $PWD1 | $CRYPTSETUP luksFormat $FAST_PBKDF_OPT --type luks2 $LOOPDEV -q --align-payload 5 || failscip-shell shell shell-project 0.0.0 fail().
612 echoscip-shell system . . echo. $PWD1 | $CRYPTSETUP luksFormat $FAST_PBKDF_OPT --type luks2 $LOOPDEV -q --sector-size 512 --align-payload 5 || failscip-shell shell shell-project 0.0.0 fail().
613 echoscip-shell system . . echo. $PWD1 | $CRYPTSETUP luksFormat $FAST_PBKDF_OPT --type luks2 $LOOPDEV -q --sector-size 2048 --align-payload 32 >/dev/nullscip-shell filesystem . . `/dev/null`. || failscip-shell shell shell-project 0.0.0 fail().
614 echoscip-shell system . . echo. $PWD1 | $CRYPTSETUP luksFormat $FAST_PBKDF_OPT --type luks2 $LOOPDEV -q --sector-size 4096 >/dev/nullscip-shell filesystem . . `/dev/null`. || failscip-shell shell shell-project 0.0.0 fail().
615 echoscip-shell system . . echo. $PWD1 | $CRYPTSETUP luksFormat $FAST_PBKDF_OPT --type luks2 $LOOPDEV -q --sector-size 2048 --align-payload 32768 >/dev/nullscip-shell filesystem . . `/dev/null`. || failscip-shell shell shell-project 0.0.0 fail().
616 $CRYPTSETUP -q luksDump $LOOPDEV | grepscip-shell system . . grep. -q "offset: $((512 * 32768)) \[bytes\]" || failscip-shell shell shell-project 0.0.0 fail().
617 echoscip-shell system . . echo. $PWD1 | $CRYPTSETUP luksFormat $FAST_PBKDF_OPT --type luks2 $LOOPDEV -q --sector-size 2048 >/dev/nullscip-shell filesystem . . `/dev/null`. || failscip-shell shell shell-project 0.0.0 fail().
618 echoscip-shell system . . echo. $PWD1 | $CRYPTSETUP luksFormat $FAST_PBKDF_OPT --type luks2 $LOOPDEV -q --sector-size 4096 --align-payload 32768 >/dev/nullscip-shell filesystem . . `/dev/null`. || failscip-shell shell shell-project 0.0.0 fail().
619 $CRYPTSETUP -q luksDump $LOOPDEV | grepscip-shell system . . grep. -q "offset: $((512 * 32768)) \[bytes\]" || failscip-shell shell shell-project 0.0.0 fail().
620
621 preparescip-shell shell shell-project 0.0.0 prepare(). "[3] format" wipe
622 echoscip-shell system . . echo. $PWD1 | $CRYPTSETUP -q $FAST_PBKDF_OPT -c aes-cbc-essiv:sha256 -s 128 luksFormat --type luks2 $LOOPDEV || failscip-shell shell shell-project 0.0.0 fail().
623 preparescip-shell shell shell-project 0.0.0 prepare(). "[4] format using hash sha512" wipe
624 echoscip-shell system . . echo. $PWD1 | $CRYPTSETUP $FAST_PBKDF_OPT -h sha512 -c aes-cbc-essiv:sha256 -s 128 luksFormat --type luks2 $LOOPDEV || failscip-shell shell shell-project 0.0.0 fail().
625 $CRYPTSETUP -q luksDump $LOOPDEV | grepscip-shell system . . grep. "0: pbkdf2" -A2 | grepscip-shell system . . grep. "Hash:" | grepscip-shell system . . grep. -qe sha512 || failscip-shell shell shell-project 0.0.0 fail().
626 # Check JSON dump for some mandatory section
627 $CRYPTSETUP -q luksDump $LOOPDEV --dump-json-metadata | grepscip-shell system . . grep. -q '"tokens":' || failscip-shell shell shell-project 0.0.0 fail().
628
629 preparescip-shell shell shell-project 0.0.0 prepare(). "[5] open"
630 echoscip-shell system . . echo. $PWD1 | $CRYPTSETUP luksOpen $LOOPDEV $DEV_NAME --test-passphrase || failscip-shell shell shell-project 0.0.0 fail().
631 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().
632 [scip-shell system . . `[`. $? -ne 2 ] && failscip-shell shell shell-project 0.0.0 fail(). "luksOpen should return EPERM exit code"
633 echoscip-shell system . . echo. $PWD1 | $CRYPTSETUP luksOpen $LOOPDEV $DEV_NAME || failscip-shell shell shell-project 0.0.0 fail().
634 check_existsscip-shell shell shell-project 0.0.0 check_exists().
635
636 # Key Slot 1 and key material section 1 must change, the rest must not.
637 preparescip-shell shell shell-project 0.0.0 prepare(). "[6] add key"
638 echoscip-shell system . . echo. -e "$PWD1\n$PWD2" | $CRYPTSETUP luksAddKey $LOOPDEV $FAST_PBKDF_OPT || failscip-shell shell shell-project 0.0.0 fail().
639 echoscip-shell system . . echo. $PWD2 | $CRYPTSETUP luksOpen $LOOPDEV $DEV_NAME || failscip-shell shell shell-project 0.0.0 fail().
640
641 # Unsuccessful Key Delete - nothing may change
642 preparescip-shell shell shell-project 0.0.0 prepare(). "[7] unsuccessful delete"
643 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().
644 [scip-shell system . . `[`. $? -ne 2 ] && failscip-shell shell shell-project 0.0.0 fail(). "luksKillSlot should return EPERM exit code"
645 #FIXME
646 #$CRYPTSETUP -q luksKillSlot $LOOPDEV 8 2>/dev/null && fail
647 #$CRYPTSETUP -q luksKillSlot $LOOPDEV 7 2>/dev/null && fail
648
649 # Delete Key Test
650 # Key Slot 1 and key material section 1 must change, the rest must not
651 preparescip-shell shell shell-project 0.0.0 prepare(). "[8] successful delete"
652 $CRYPTSETUP -q luksKillSlot $LOOPDEV 1 || failscip-shell shell shell-project 0.0.0 fail().
653 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().
654 [scip-shell system . . `[`. $? -ne 2 ] && failscip-shell shell shell-project 0.0.0 fail(). "luksOpen should return EPERM exit code"
655 echoscip-shell system . . echo. $PWD1 | $CRYPTSETUP luksOpen $LOOPDEV $DEV_NAME || failscip-shell shell shell-project 0.0.0 fail().
656
657 # Key Slot 1 and key material section 1 must change, the rest must not
658 preparescip-shell shell shell-project 0.0.0 prepare(). "[9] add key test for key files"
659 echoscip-shell system . . echo. $PWD1 | $CRYPTSETUP luksAddKey $FAST_PBKDF_OPT $LOOPDEV $KEY1 || failscip-shell shell shell-project 0.0.0 fail().
660 $CRYPTSETUP -d $KEY1 luksOpen $LOOPDEV $DEV_NAME || failscip-shell shell shell-project 0.0.0 fail().
661
662 # Key Slot 1 and key material section 1 must change, the rest must not
663 preparescip-shell shell shell-project 0.0.0 prepare(). "[10] delete key test with key1 as remaining key"
664 $CRYPTSETUP -d $KEY1 luksKillSlot $LOOPDEV 0 || failscip-shell shell shell-project 0.0.0 fail().
665 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().
666 $CRYPTSETUP luksOpen -d $KEY1 $LOOPDEV $DEV_NAME || failscip-shell shell shell-project 0.0.0 fail().
667
668 # Delete last slot
669 preparescip-shell shell shell-project 0.0.0 prepare(). "[11] delete last key" wipe
670 echoscip-shell system . . echo. $PWD1 | $CRYPTSETUP luksFormat --type luks2 $LOOPDEV $FAST_PBKDF_OPT || failscip-shell shell shell-project 0.0.0 fail().
671 echoscip-shell system . . echo. $PWD1 | $CRYPTSETUP luksKillSlot $LOOPDEV 0 || failscip-shell shell shell-project 0.0.0 fail().
672 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().
673
674 # Format test for ESSIV, and some other parameters.
675 preparescip-shell shell shell-project 0.0.0 prepare(). "[12] parameter variation test" wipe
676 $CRYPTSETUP -q $FAST_PBKDF_OPT -c aes-cbc-essiv:sha256 -s 128 luksFormat --type luks2 $LOOPDEV $KEY1 || failscip-shell shell shell-project 0.0.0 fail().
677 $CRYPTSETUP -d $KEY1 luksOpen $LOOPDEV $DEV_NAME || failscip-shell shell shell-project 0.0.0 fail().
678
679 preparescip-shell shell shell-project 0.0.0 prepare(). "[13] open/close - stacked devices" wipe
680 echoscip-shell system . . echo. $PWD1 | $CRYPTSETUP -q luksFormat --type luks2 $LOOPDEV $FAST_PBKDF_OPT || failscip-shell shell shell-project 0.0.0 fail().
681 echoscip-shell system . . echo. $PWD1 | $CRYPTSETUP -q luksOpen $LOOPDEV $DEV_NAME || failscip-shell shell shell-project 0.0.0 fail().
682 echoscip-shell system . . echo. $PWD1 | $CRYPTSETUP -q luksFormat --type luks2 /dev/mapper/$DEV_NAME $FAST_PBKDF_OPT || failscip-shell shell shell-project 0.0.0 fail().
683 echoscip-shell system . . echo. $PWD1 | $CRYPTSETUP -q luksOpen /dev/mapper/$DEV_NAME $DEV_NAME2 || failscip-shell shell shell-project 0.0.0 fail().
684 $CRYPTSETUP -q luksClose $DEV_NAME2 || failscip-shell shell shell-project 0.0.0 fail().
685 $CRYPTSETUP -q luksClose $DEV_NAME || failscip-shell shell shell-project 0.0.0 fail().
686
687 preparescip-shell shell shell-project 0.0.0 prepare(). "[14] format/open - passphrase on stdin & new line" wipe
688 # stdin defined by "-" must take even newline
689 #echo -n -e "$PWD1\n$PWD2" | $CRYPTSETUP -q luksFormat $LOOPDEV - || fail
690 echoscip-shell system . . echo. -n -e "$PWD1\n$PWD2" | $CRYPTSETUP $FAST_PBKDF_OPT -q --key-file=- luksFormat --type luks2 $LOOPDEV || failscip-shell shell shell-project 0.0.0 fail().
691 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().
692 $CRYPTSETUP -q luksClose $DEV_NAME || failscip-shell shell shell-project 0.0.0 fail().
693 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().
694 # now also try --key-file
695 echoscip-shell system . . echo. -n -e "$PWD1\n$PWD2" | $CRYPTSETUP $FAST_PBKDF_OPT -q luksFormat --type luks2 $LOOPDEV --key-file=- || failscip-shell shell shell-project 0.0.0 fail().
696 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().
697 $CRYPTSETUP -q luksClose $DEV_NAME || failscip-shell shell shell-project 0.0.0 fail().
698 # process newline if from stdin
699 echoscip-shell system . . echo. -n -e "$PWD1\n$PWD2" | $CRYPTSETUP $FAST_PBKDF_OPT -q luksFormat --type luks2 $LOOPDEV || failscip-shell shell shell-project 0.0.0 fail().
700 echoscip-shell system . . echo. "$PWD1" | $CRYPTSETUP -q luksOpen $LOOPDEV $DEV_NAME || failscip-shell shell shell-project 0.0.0 fail().
701 $CRYPTSETUP -q luksClose $DEV_NAME || failscip-shell shell shell-project 0.0.0 fail().
702
703 preparescip-shell shell shell-project 0.0.0 prepare(). "[15] UUID - use and report provided UUID" wipe
704 echoscip-shell system . . echo. $PWD1 | $CRYPTSETUP -q luksFormat $FAST_PBKDF_OPT --uuid blah --type luks2 $LOOPDEV 2>/dev/nullscip-shell filesystem . . `/dev/null`. && failscip-shell shell shell-project 0.0.0 fail().
705 echoscip-shell system . . echo. $PWD1 | $CRYPTSETUP -q luksFormat $FAST_PBKDF_OPT --uuid $TEST_UUID --type luks2 $LOOPDEV || failscip-shell shell shell-project 0.0.0 fail().
706 tst=$($CRYPTSETUP -q luksUUID $LOOPDEV)
707 [scip-shell system . . `[`. "$tst"x = "$TEST_UUID"x ] || failscip-shell shell shell-project 0.0.0 fail().
708 echoscip-shell system . . echo. $PWD1 | $CRYPTSETUP -q luksFormat $FAST_PBKDF_OPT --type luks2 $LOOPDEV || failscip-shell shell shell-project 0.0.0 fail().
709 $CRYPTSETUP -q luksUUID --uuid $TEST_UUID $LOOPDEV || failscip-shell shell shell-project 0.0.0 fail().
710 tst=$($CRYPTSETUP -q luksUUID $LOOPDEV)
711 [scip-shell system . . `[`. "$tst"x = "$TEST_UUID"x ] || failscip-shell shell shell-project 0.0.0 fail().
712
713 preparescip-shell shell shell-project 0.0.0 prepare(). "[16] luksFormat" wipe
714 echoscip-shell system . . echo. $PWD1 | $CRYPTSETUP -q luksFormat $FAST_PBKDF_OPT --volume-key-file /dev/urandomscip-shell filesystem . . `/dev/urandom`. --type luks2 $LOOPDEV || failscip-shell shell shell-project 0.0.0 fail().
715 echoscip-shell system . . echo. $PWD1 | $CRYPTSETUP -q luksFormat $FAST_PBKDF_OPT --volume-key-file /dev/urandomscip-shell filesystem . . `/dev/urandom`. --type luks2 $LOOPDEV -d $KEY1 || failscip-shell shell shell-project 0.0.0 fail().
716 $CRYPTSETUP -q luksFormat $FAST_PBKDF_OPT --volume-key-file /dev/urandomscip-shell filesystem . . `/dev/urandom`. -s 256 --uuid $TEST_UUID --type luks2 $LOOPDEV $KEY1 || failscip-shell shell shell-project 0.0.0 fail().
717 $CRYPTSETUP luksOpen -d $KEY1 $LOOPDEV $DEV_NAME || failscip-shell shell shell-project 0.0.0 fail().
718 $CRYPTSETUP -q luksClose $DEV_NAME || failscip-shell shell shell-project 0.0.0 fail().
719 # open by UUID
720 if [scip-shell system . . `[`. -d /dev/disk/by-uuidscip-shell filesystem . . `/dev/disk/by-uuid`. ] ; then
721 force_ueventscip-shell shell shell-project 0.0.0 force_uevent(). # some systems do not update loop by-uuid
722 $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().
723 $CRYPTSETUP luksOpen -d $KEY1 UUID=$TEST_UUID $DEV_NAME || failscip-shell shell shell-project 0.0.0 fail().
724 $CRYPTSETUP -q luksClose $DEV_NAME || failscip-shell shell shell-project 0.0.0 fail().
725 fi
726 # skip tests using empty passphrases
727 if ! fips_modescip-shell shell shell-project 0.0.0 fips_mode().; then
728 # empty keyfile
729 $CRYPTSETUP -q luksFormat $FAST_PBKDF_OPT --type luks2 $LOOPDEV $KEYE || failscip-shell shell shell-project 0.0.0 fail().
730 $CRYPTSETUP luksOpen -d $KEYE $LOOPDEV $DEV_NAME || failscip-shell shell shell-project 0.0.0 fail().
731 $CRYPTSETUP -q luksClose $DEV_NAME || failscip-shell shell shell-project 0.0.0 fail().
732 fi
733
734 # open by volume key
735 echoscip-shell system . . echo. $PWD1 | $CRYPTSETUP -q luksFormat $FAST_PBKDF_OPT -s 256 --volume-key-file $KEY1 --type luks2 $LOOPDEV || failscip-shell shell shell-project 0.0.0 fail().
736 $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().
737 $CRYPTSETUP luksOpen --volume-key-file $KEY1 $LOOPDEV $DEV_NAME || failscip-shell shell shell-project 0.0.0 fail().
738 $CRYPTSETUP -q luksClose $DEV_NAME || failscip-shell shell shell-project 0.0.0 fail().
739
740 preparescip-shell shell shell-project 0.0.0 prepare(). "[17] AddKey volume key, passphrase and keyfile" wipe
741 # volumekey
742 echoscip-shell system . . echo. $PWD1 | $CRYPTSETUP -q luksFormat $FAST_PBKDF_OPT --type luks2 $LOOPDEV --volume-key-file /dev/zeroscip-shell filesystem . . `/dev/zero`. --key-slot 3 || failscip-shell shell shell-project 0.0.0 fail().
743 echoscip-shell system . . echo. $PWD1 | $CRYPTSETUP luksOpen $LOOPDEV --test-passphrase || failscip-shell shell shell-project 0.0.0 fail().
744 $CRYPTSETUP luksDump $LOOPDEV | grepscip-shell system . . grep. -q "3: luks2" || failscip-shell shell shell-project 0.0.0 fail().
745 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().
746 echoscip-shell system . . echo. $PWD2 | $CRYPTSETUP luksOpen $LOOPDEV --test-passphrase --key-slot 4 || failscip-shell shell shell-project 0.0.0 fail().
747 $CRYPTSETUP luksDump $LOOPDEV | grepscip-shell system . . grep. -q "4: luks2" || failscip-shell shell shell-project 0.0.0 fail().
748 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().
749 $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().
750 $CRYPTSETUP luksOpen $LOOPDEV --test-passphrase --key-slot 5 -d $KEY1 || failscip-shell shell shell-project 0.0.0 fail().
751 $CRYPTSETUP luksDump $LOOPDEV | grepscip-shell system . . grep. -q "5: luks2" || failscip-shell shell shell-project 0.0.0 fail().
752
753 # special "-" handling
754 $CRYPTSETUP -q luksFormat $FAST_PBKDF_OPT --type luks2 $LOOPDEV $KEY1 --key-slot 3 || failscip-shell shell shell-project 0.0.0 fail().
755 echoscip-shell system . . echo. $PWD1 | $CRYPTSETUP luksAddKey $FAST_PBKDF_OPT $LOOPDEV -d $KEY1 - || failscip-shell shell shell-project 0.0.0 fail().
756 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().
757 echoscip-shell system . . echo. $PWD1 | $CRYPTSETUP luksOpen $LOOPDEV -d - --test-passphrase || failscip-shell shell shell-project 0.0.0 fail().
758 echoscip-shell system . . echo. $PWD1 | $CRYPTSETUP luksAddKey $FAST_PBKDF_OPT $LOOPDEV -d - $KEY2 || failscip-shell shell shell-project 0.0.0 fail().
759 $CRYPTSETUP luksOpen $LOOPDEV -d $KEY2 --test-passphrase || failscip-shell shell shell-project 0.0.0 fail().
760 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().
761 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().
762
763 # [0]PWD1 [1]PWD2 [2]$KEY1/1 [3]$KEY1 [4]$KEY2
764 $CRYPTSETUP -q luksFormat $FAST_PBKDF_OPT --type luks2 $LOOPDEV $KEY1 --key-slot 3 || failscip-shell shell shell-project 0.0.0 fail().
765 $CRYPTSETUP luksDump $LOOPDEV | grepscip-shell system . . grep. -q "3: luks2" || failscip-shell shell shell-project 0.0.0 fail().
766 $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().
767 # keyfile/keyfile
768 $CRYPTSETUP luksAddKey -q $LOOPDEV $FAST_PBKDF_OPT -d $KEY1 $KEY2 --key-slot 4 || failscip-shell shell shell-project 0.0.0 fail().
769 $CRYPTSETUP luksOpen $LOOPDEV -d $KEY2 --test-passphrase --key-slot 4 || failscip-shell shell shell-project 0.0.0 fail().
770 $CRYPTSETUP luksDump $LOOPDEV | grepscip-shell system . . grep. -q "4: luks2" || failscip-shell shell shell-project 0.0.0 fail().
771 # passphrase/keyfile
772 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().
773 $CRYPTSETUP luksDump $LOOPDEV | grepscip-shell system . . grep. -q "0: luks2" || failscip-shell shell shell-project 0.0.0 fail().
774 echoscip-shell system . . echo. $PWD1 | $CRYPTSETUP luksOpen $LOOPDEV --test-passphrase --key-slot 0 || failscip-shell shell shell-project 0.0.0 fail().
775 # passphrase/passphrase
776 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().
777 echoscip-shell system . . echo. $PWD2 | $CRYPTSETUP luksOpen $LOOPDEV --test-passphrase --key-slot 1 || failscip-shell shell shell-project 0.0.0 fail().
778 $CRYPTSETUP luksDump $LOOPDEV | grepscip-shell system . . grep. -q "1: luks2" || failscip-shell shell shell-project 0.0.0 fail().
779 # keyfile/passphrase
780 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().
781 $CRYPTSETUP luksDump $LOOPDEV | grepscip-shell system . . grep. -q "2: luks2" || failscip-shell shell shell-project 0.0.0 fail().
782
783 preparescip-shell shell shell-project 0.0.0 prepare(). "[18] RemoveKey passphrase and keyfile" reuse
784 $CRYPTSETUP luksDump $LOOPDEV | grepscip-shell system . . grep. -q "3: luks2" || failscip-shell shell shell-project 0.0.0 fail().
785 $CRYPTSETUP luksRemoveKey $LOOPDEV $KEY1 || failscip-shell shell shell-project 0.0.0 fail().
786 $CRYPTSETUP luksDump $LOOPDEV | grepscip-shell system . . grep. -q "3: luks2" && failscip-shell shell shell-project 0.0.0 fail().
787 $CRYPTSETUP luksRemoveKey $LOOPDEV $KEY1 2>/dev/nullscip-shell filesystem . . `/dev/null`. && failscip-shell shell shell-project 0.0.0 fail().
788 [scip-shell system . . `[`. $? -ne 2 ] && failscip-shell shell shell-project 0.0.0 fail(). "luksRemoveKey should return EPERM exit code"
789 $CRYPTSETUP luksRemoveKey $LOOPDEV $KEY2 --keyfile-size 1 2>/dev/nullscip-shell filesystem . . `/dev/null`. && failscip-shell shell shell-project 0.0.0 fail().
790 $CRYPTSETUP luksDump $LOOPDEV | grepscip-shell system . . grep. -q "4: luks2" || failscip-shell shell shell-project 0.0.0 fail().
791 $CRYPTSETUP luksRemoveKey $LOOPDEV $KEY2 || failscip-shell shell shell-project 0.0.0 fail().
792 $CRYPTSETUP luksDump $LOOPDEV | grepscip-shell system . . grep. -q "4: luks2" && failscip-shell shell shell-project 0.0.0 fail().
793 # if password or keyfile is provided, batch mode must not suppress it
794 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().
795 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().
796 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().
797 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().
798 $CRYPTSETUP luksDump $LOOPDEV | grepscip-shell system . . grep. -q "2: luks2" || failscip-shell shell shell-project 0.0.0 fail().
799 # kill slot using passphrase from 1
800 echoscip-shell system . . echo. $PWD2 | $CRYPTSETUP luksKillSlot $LOOPDEV 2 2>/dev/nullscip-shell filesystem . . `/dev/null`. || failscip-shell shell shell-project 0.0.0 fail().
801 $CRYPTSETUP luksDump $LOOPDEV | grepscip-shell system . . grep. -q "2: luks2" && failscip-shell shell shell-project 0.0.0 fail().
802 # remove key0 / slot 0
803 echoscip-shell system . . echo. $PWD1 | $CRYPTSETUP luksRemoveKey $LOOPDEV || failscip-shell shell shell-project 0.0.0 fail().
804 $CRYPTSETUP luksDump $LOOPDEV | grepscip-shell system . . grep. -q "0: luks2" && failscip-shell shell shell-project 0.0.0 fail().
805 # last keyslot, in batch mode no passphrase needed...
806 $CRYPTSETUP luksKillSlot -q $LOOPDEV 1 || failscip-shell shell shell-project 0.0.0 fail().
807 $CRYPTSETUP luksDump $LOOPDEV | grepscip-shell system . . grep. -q "1: luks2" && failscip-shell shell shell-project 0.0.0 fail().
808
809 preparescip-shell shell shell-project 0.0.0 prepare(). "[19] create & status & resize" wipe
810 echoscip-shell system . . echo. $PWD1 | $CRYPTSETUP luksFormat $FAST_PBKDF_OPT --type luks2 $LOOPDEV || failscip-shell shell shell-project 0.0.0 fail().
811 echoscip-shell system . . echo. $PWD1 | $CRYPTSETUP luksOpen $LOOPDEV $DEV_NAME || failscip-shell shell shell-project 0.0.0 fail().
812 if dm_crypt_keyring_supportscip-shell shell shell-project 0.0.0 dm_crypt_keyring_support().; then
813 echoscip-shell system . . echo. | $CRYPTSETUP -q resize --size 100 $DEV_NAME 2>/dev/nullscip-shell filesystem . . `/dev/null`. && failscip-shell shell shell-project 0.0.0 fail().
814 if [scip-shell system . . `[`. $HAVE_KEYRING -gt 0 -a -d /proc/sys/kernel/keysscip-shell filesystem . . `/proc/sys/kernel/keys`. ]; then
815 test_and_prepare_keyringscip-shell shell shell-project 0.0.0 test_and_prepare_keyring().
816 load_keyscip-shell shell shell-project 0.0.0 load_key(). user $TEST_KEY_DESC2 $PWD1 "$TEST_KEYRING" || skipscip-shell shell shell-project 0.0.0 skip(). "Kernel keyring service is useless on this system, test skipped."
817 $CRYPTSETUP token add $LOOPDEV --key-description $TEST_KEY_DESC2 --token-id 1 || failscip-shell shell shell-project 0.0.0 fail().
818 $CRYPTSETUP -q resize --size 99 $DEV_NAME <&- || failscip-shell shell shell-project 0.0.0 fail().
819 $CRYPTSETUP -q status $DEV_NAME | grepscip-shell system . . grep. "size:" | grepscip-shell system . . grep. -q "99 \[512-byte units\]" || failscip-shell shell shell-project 0.0.0 fail().
820 #replace kernel key with wrong pass
821 load_keyscip-shell shell shell-project 0.0.0 load_key(). user $TEST_KEY_DESC2 $PWD2 "$TEST_KEYRING" || skipscip-shell shell shell-project 0.0.0 skip(). "Kernel keyring service is useless on this system, test skipped."
822 # must fail due to --token-only
823 echoscip-shell system . . echo. $PWD1 | $CRYPTSETUP -q resize --token-only --size 100 $DEV_NAME && failscip-shell shell shell-project 0.0.0 fail().
824 $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().
825 # resize with keyring description
826 load_keyscip-shell shell shell-project 0.0.0 load_key(). user $TEST_KEY_DESC1 $PWD1 "$TEST_KEYRING" || failscip-shell shell shell-project 0.0.0 fail().
827 $CRYPTSETUP -q resize --size 99 $DEV_NAME --key-description $TEST_KEY_DESC1 || failscip-shell shell shell-project 0.0.0 fail().
828 $CRYPTSETUP -q status $DEV_NAME | grepscip-shell system . . grep. "size:" | grepscip-shell system . . grep. -q "99 \[512-byte units\]" || failscip-shell shell shell-project 0.0.0 fail().
829 fi
830 fi
831 echoscip-shell system . . echo. $PWD1 | $CRYPTSETUP -q resize --size 100 $DEV_NAME || failscip-shell shell shell-project 0.0.0 fail().
832 $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().
833 echoscip-shell system . . echo. $PWD1 | $CRYPTSETUP -q resize --device-size 51200 $DEV_NAME || failscip-shell shell shell-project 0.0.0 fail().
834 $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().
835 echoscip-shell system . . echo. $PWD1 | $CRYPTSETUP -q resize --device-size 1M $DEV_NAME || failscip-shell shell shell-project 0.0.0 fail().
836 $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().
837 echoscip-shell system . . echo. $PWD1 | $CRYPTSETUP -q resize --device-size 512k --size 1024 $DEV_NAME > /dev/nullscip-shell filesystem . . `/dev/null`. 2>&1 && failscip-shell shell shell-project 0.0.0 fail().
838 echoscip-shell system . . echo. $PWD1 | $CRYPTSETUP -q resize --device-size 4097 $DEV_NAME > /dev/nullscip-shell filesystem . . `/dev/null`. 2>&1 && failscip-shell shell shell-project 0.0.0 fail().
839 $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().
840 $CRYPTSETUP close $DEV_NAME || failscip-shell shell shell-project 0.0.0 fail().
841 echoscip-shell system . . echo. $PWD1 | $CRYPTSETUP luksOpen --disable-keyring $LOOPDEV $DEV_NAME || failscip-shell shell shell-project 0.0.0 fail().
842 echoscip-shell system . . echo. | $CRYPTSETUP -q resize --size 100 $DEV_NAME || failscip-shell shell shell-project 0.0.0 fail().
843 $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().
844 $CRYPTSETUP close $DEV_NAME || failscip-shell shell shell-project 0.0.0 fail().
845 echoscip-shell system . . echo. $PWD1 | $CRYPTSETUP luksOpen $LOOPDEV $DEV_NAME || failscip-shell shell shell-project 0.0.0 fail().
846 if dm_crypt_keyring_supportscip-shell shell shell-project 0.0.0 dm_crypt_keyring_support().; then
847 $CRYPTSETUP -q resize --disable-keyring --size 100 $DEV_NAME 2>/dev/nullscip-shell filesystem . . `/dev/null`. && failscip-shell shell shell-project 0.0.0 fail().
848 fi
849 if dm_crypt_sector_size_supportscip-shell shell shell-project 0.0.0 dm_crypt_sector_size_support().; then
850 $CRYPTSETUP close $DEV_NAME || failscip-shell shell shell-project 0.0.0 fail().
851 echoscip-shell system . . echo. $PWD1 | $CRYPTSETUP luksFormat $FAST_PBKDF_OPT --type luks2 --sector-size 4096 $LOOPDEV > /dev/nullscip-shell filesystem . . `/dev/null`. || failscip-shell shell shell-project 0.0.0 fail().
852 echoscip-shell system . . echo. $PWD1 | $CRYPTSETUP luksOpen $LOOPDEV $DEV_NAME || failscip-shell shell shell-project 0.0.0 fail().
853 echoscip-shell system . . echo. $PWD1 | $CRYPTSETUP -q resize --device-size 1M $DEV_NAME || failscip-shell shell shell-project 0.0.0 fail().
854 $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().
855 $CRYPTSETUP -q status $DEV_NAME | grepscip-shell system . . grep. "size:" | grepscip-shell system . . grep. -q "1048576 \[bytes\]" || failscip-shell shell shell-project 0.0.0 fail().
856 echoscip-shell system . . echo. $PWD1 | $CRYPTSETUP -q resize --device-size 2049s $DEV_NAME > /dev/nullscip-shell filesystem . . `/dev/null`. 2>&1 && failscip-shell shell shell-project 0.0.0 fail().
857 echoscip-shell system . . echo. $PWD1 | $CRYPTSETUP -q resize --size 2049 $DEV_NAME > /dev/nullscip-shell filesystem . . `/dev/null`. 2>&1 && failscip-shell shell shell-project 0.0.0 fail().
858 $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().
859 $CRYPTSETUP -q status $DEV_NAME | grepscip-shell system . . grep. "size:" | grepscip-shell system . . grep. -q "1048576 \[bytes\]" || failscip-shell shell shell-project 0.0.0 fail().
860 fi
861 $CRYPTSETUP close $DEV_NAME || failscip-shell shell shell-project 0.0.0 fail().
862 # Resize not aligned to logical block size
863 add_scsi_devicescip-shell shell shell-project 0.0.0 add_scsi_device(). dev_size_mb=32 sector_size=4096 || failscip-shell shell shell-project 0.0.0 fail(). "scsi_debug device not found"
864 echoscip-shell system . . echo. $PWD1 | $CRYPTSETUP luksFormat --type luks2 $FAST_PBKDF_OPT $DEV || failscip-shell shell shell-project 0.0.0 fail().
865 echoscip-shell system . . echo. $PWD1 | $CRYPTSETUP open $DEV $DEV_NAME || failscip-shell shell shell-project 0.0.0 fail().
866 OLD_SIZE=$($CRYPTSETUP status $DEV_NAME | grepscip-shell system . . grep. "^ \+size:" | sedscip-shell system . . sed. 's/.* \([0-9]\+\) .*/\1/') #'
867 echoscip-shell system . . echo. $PWD1 | $CRYPTSETUP resize $DEV_NAME -b 7 2> /dev/nullscip-shell filesystem . . `/dev/null`. && failscip-shell shell shell-project 0.0.0 fail().
868 dmsetup info $DEV_NAME | grepscip-shell system . . grep. -q SUSPENDED && failscip-shell shell shell-project 0.0.0 fail().
869 NEW_SIZE=$($CRYPTSETUP status $DEV_NAME | grepscip-shell system . . grep. "^ \+size:" | sedscip-shell system . . sed. 's/.* \([0-9]\+\) .*/\1/') #'
870 testscip-shell system . . test. $OLD_SIZE -eq $NEW_SIZE || failscip-shell shell shell-project 0.0.0 fail().
871 $CRYPTSETUP close $DEV_NAME || failscip-shell shell shell-project 0.0.0 fail().
872
873 preparescip-shell shell shell-project 0.0.0 prepare(). "[20] Disallow open/create if already mapped." wipe
874 $CRYPTSETUP create $DEV_NAME $LOOPDEV -d $KEY1 --cipher aes-cbc-essiv:sha256 --key-size 256 || failscip-shell shell shell-project 0.0.0 fail().
875 echoscip-shell system . . echo. $PWD1 | $CRYPTSETUP -q luksFormat $FAST_PBKDF_OPT --type luks2 $LOOPDEV 2>/dev/nullscip-shell filesystem . . `/dev/null`. && failscip-shell shell shell-project 0.0.0 fail().
876 $CRYPTSETUP remove $DEV_NAME || failscip-shell shell shell-project 0.0.0 fail().
877 echoscip-shell system . . echo. $PWD1 | $CRYPTSETUP -q luksFormat $FAST_PBKDF_OPT --type luks2 $LOOPDEV || failscip-shell shell shell-project 0.0.0 fail().
878 echoscip-shell system . . echo. $PWD1 | $CRYPTSETUP luksOpen $LOOPDEV $DEV_NAME || failscip-shell shell shell-project 0.0.0 fail().
879 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().
880 $CRYPTSETUP luksClose $DEV_NAME || failscip-shell shell shell-project 0.0.0 fail().
881
882 preparescip-shell shell shell-project 0.0.0 prepare(). "[21] luksDump" wipe
883 echoscip-shell system . . echo. $PWD1 | $CRYPTSETUP -q luksFormat --key-size 256 $FAST_PBKDF_OPT --uuid $TEST_UUID --type luks2 $LOOPDEV $KEY1 || failscip-shell shell shell-project 0.0.0 fail().
884 echoscip-shell system . . echo. $PWD1 | $CRYPTSETUP luksAddKey $FAST_PBKDF_OPT $LOOPDEV -d $KEY1 || failscip-shell shell shell-project 0.0.0 fail().
885 $CRYPTSETUP luksDump $LOOPDEV | grepscip-shell system . . grep. -q "0: luks2" || failscip-shell shell shell-project 0.0.0 fail().
886 $CRYPTSETUP luksDump $LOOPDEV | grepscip-shell system . . grep. -q $TEST_UUID || failscip-shell shell shell-project 0.0.0 fail().
887 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().
888 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().
889 $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().
890 echoscip-shell system . . echo. $PWD1 | $CRYPTSETUP luksDump -q $LOOPDEV --dump-master-key --master-key-file $VK_FILE >/dev/nullscip-shell filesystem . . `/dev/null`. || failscip-shell shell shell-project 0.0.0 fail().
891 rmscip-shell system . . rm. -f $VK_FILE
892 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().
893 echoscip-shell system . . echo. $PWD1 | $CRYPTSETUP luksDump -q $LOOPDEV --dump-volume-key --volume-key-file $VK_FILE 2>/dev/nullscip-shell filesystem . . `/dev/null`. && failscip-shell shell shell-project 0.0.0 fail().
894 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().
895 # Use volume key file without keyslots
896 $CRYPTSETUP luksErase -q $LOOPDEV || failscip-shell shell shell-project 0.0.0 fail().
897 $CRYPTSETUP luksOpen --volume-key-file $VK_FILE --key-size 256 --test-passphrase $LOOPDEV || failscip-shell shell shell-project 0.0.0 fail().
898 echoscip-shell system . . echo. $PWD1 | $CRYPTSETUP luksAddKey $FAST_PBKDF_OPT --volume-key-file $VK_FILE --key-size 256 $LOOPDEV || failscip-shell shell shell-project 0.0.0 fail().
899 echoscip-shell system . . echo. $PWD1 | $CRYPTSETUP luksOpen --test-passphrase $LOOPDEV || failscip-shell shell shell-project 0.0.0 fail().
900
901 preparescip-shell shell shell-project 0.0.0 prepare(). "[22] remove disappeared device" wipe
902 dmsetup create $DEV_NAME --table "0 39998 linear $LOOPDEV 2" || failscip-shell shell shell-project 0.0.0 fail().
903 echoscip-shell system . . echo. $PWD1 | $CRYPTSETUP -q $FAST_PBKDF_OPT luksFormat --type luks2 /dev/mapper/$DEV_NAME || failscip-shell shell shell-project 0.0.0 fail().
904 echoscip-shell system . . echo. $PWD1 | $CRYPTSETUP -q luksOpen /dev/mapper/$DEV_NAME $DEV_NAME2 || failscip-shell shell shell-project 0.0.0 fail().
905 # underlying device now returns error but node is still present
906 dmsetup load $DEV_NAME --table "0 40000 error" || failscip-shell shell shell-project 0.0.0 fail().
907 dmsetup resume $DEV_NAME || failscip-shell shell shell-project 0.0.0 fail().
908 $CRYPTSETUP -q luksClose $DEV_NAME2 || failscip-shell shell shell-project 0.0.0 fail().
909 dmsetup remove --retry $DEV_NAME || failscip-shell shell shell-project 0.0.0 fail().
910
911 preparescip-shell shell shell-project 0.0.0 prepare(). "[23] ChangeKey passphrase and keyfile" wipe
912 # [0]$KEY1 [1]key0
913 $CRYPTSETUP -q luksFormat --type luks2 $LOOPDEV $KEY1 $FAST_PBKDF_OPT --key-slot 0 --key-size 256 --luks2-keyslots-size 256k >/dev/nullscip-shell filesystem . . `/dev/null`. || failscip-shell shell shell-project 0.0.0 fail().
914 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().
915 # keyfile [0] / keyfile [0]
916 $CRYPTSETUP luksChangeKey $LOOPDEV $FAST_PBKDF_OPT -d $KEY1 $KEY2 --key-slot 0 || failscip-shell shell shell-project 0.0.0 fail().
917 # passphrase [1] / passphrase [1]
918 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().
919 # keyfile [0] / keyfile [new] - with LUKS2 it should stay
920 $CRYPTSETUP luksChangeKey $LOOPDEV $FAST_PBKDF_OPT -d $KEY2 $KEY1 || failscip-shell shell shell-project 0.0.0 fail().
921 $CRYPTSETUP luksDump $LOOPDEV | grepscip-shell system . . grep. -q "0: luks2" || failscip-shell shell shell-project 0.0.0 fail().
922 $CRYPTSETUP luksDump $LOOPDEV | grepscip-shell system . . grep. -q "2: luks2" && failscip-shell shell shell-project 0.0.0 fail().
923 # passphrase [1] / passphrase [new]
924 echoscip-shell system . . echo. -e "$PWD2\n$PWD1\n" | $CRYPTSETUP luksChangeKey $FAST_PBKDF_OPT $LOOPDEV || failscip-shell shell shell-project 0.0.0 fail().
925 $CRYPTSETUP luksDump $LOOPDEV | grepscip-shell system . . grep. -q "1: luks2" || failscip-shell shell shell-project 0.0.0 fail().
926 $CRYPTSETUP luksDump $LOOPDEV | grepscip-shell system . . grep. -q "2: luks2" && failscip-shell shell shell-project 0.0.0 fail().
927 # test out of raw area, change in-place (space only for 2 keyslots)
928 $CRYPTSETUP luksChangeKey $LOOPDEV $FAST_PBKDF_OPT -d $KEY1 $KEY2 || failscip-shell shell shell-project 0.0.0 fail().
929 $CRYPTSETUP luksDump $LOOPDEV | grepscip-shell system . . grep. -q "0: luks2" || failscip-shell shell shell-project 0.0.0 fail().
930 $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().
931 # make a free space in keyslot area
932 echoscip-shell system . . echo. $PWD1 | $CRYPTSETUP luksKillSlot -q $LOOPDEV 0 || failscip-shell shell shell-project 0.0.0 fail().
933
934 # assert LUKS2 does not overwrite existing area with specific keyslot id
935 AREA_OFFSET_OLD=$($CRYPTSETUP luksDump $LOOPDEV | grepscip-shell system . . grep. -e "1: luks2" -A12 | grepscip-shell system . . grep. -e "Area offset:" | cutscip-shell system . . cut. -d: -f 2 | sedscip-shell system . . sed. -e 's/[[:space:]]*\[bytes\]//g')
936 [scip-shell system . . `[`. 0$AREA_OFFSET_OLD -gt 0 ] || failscip-shell shell shell-project 0.0.0 fail().
937 echoscip-shell system . . echo. -e "$PWD1\n$PWD2\n" | $CRYPTSETUP luksChangeKey --key-slot 1 $LOOPDEV $FAST_PBKDF_OPT
938 AREA_OFFSET_NEW=$($CRYPTSETUP luksDump $LOOPDEV | grepscip-shell system . . grep. -e "1: luks2" -A12 | grepscip-shell system . . grep. -e "Area offset:" | cutscip-shell system . . cut. -d: -f 2 | sedscip-shell system . . sed. -e 's/[[:space:]]*\[bytes\]//g')
939 [scip-shell system . . `[`. 0$AREA_OFFSET_NEW -gt 0 ] || failscip-shell shell shell-project 0.0.0 fail().
940 [scip-shell system . . `[`. $AREA_OFFSET_OLD -ne $AREA_OFFSET_NEW ] || failscip-shell shell shell-project 0.0.0 fail(). "Area offsets remained same: old area $AREA_OFFSET_OLD, new area $AREA_OFFSET_NEW"
941
942 # assert LUKS2 does not overwrite existing area with any sklot
943 AREA_OFFSET_OLD=$($CRYPTSETUP luksDump $LOOPDEV | grepscip-shell system . . grep. -e "1: luks2" -A12 | grepscip-shell system . . grep. -e "Area offset:" | cutscip-shell system . . cut. -d: -f 2 | sedscip-shell system . . sed. -e 's/[[:space:]]*\[bytes\]//g')
944 [scip-shell system . . `[`. 0$AREA_OFFSET_OLD -gt 0 ] || failscip-shell shell shell-project 0.0.0 fail().
945 echoscip-shell system . . echo. -e "$PWD2\n$PWD1\n" | $CRYPTSETUP luksChangeKey $LOOPDEV $FAST_PBKDF_OPT
946 AREA_OFFSET_NEW=$($CRYPTSETUP luksDump $LOOPDEV | grepscip-shell system . . grep. -e "1: luks2" -A12 | grepscip-shell system . . grep. -e "Area offset:" | cutscip-shell system . . cut. -d: -f 2 | sedscip-shell system . . sed. -e 's/[[:space:]]*\[bytes\]//g')
947 [scip-shell system . . `[`. 0$AREA_OFFSET_NEW -gt 0 ] || failscip-shell shell shell-project 0.0.0 fail().
948 [scip-shell system . . `[`. $AREA_OFFSET_OLD -ne $AREA_OFFSET_NEW ] || failscip-shell shell shell-project 0.0.0 fail(). "Area offsets remained same: old area $AREA_OFFSET_OLD, new area $AREA_OFFSET_NEW"
949
950 preparescip-shell shell shell-project 0.0.0 prepare(). "[24] Keyfile limit" wipe
951 $CRYPTSETUP -q luksFormat $FAST_PBKDF_OPT --type luks2 $LOOPDEV $KEY1 --key-slot 0 -l 13 || failscip-shell shell shell-project 0.0.0 fail().
952 $CRYPTSETUP --key-file=$KEY1 luksOpen $LOOPDEV $DEV_NAME 2>/dev/nullscip-shell filesystem . . `/dev/null`. && failscip-shell shell shell-project 0.0.0 fail().
953 $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().
954 $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().
955 $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().
956 $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().
957 $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().
958 $CRYPTSETUP --key-file=$KEY1 -l 13 luksOpen $LOOPDEV $DEV_NAME || failscip-shell shell shell-project 0.0.0 fail().
959 $CRYPTSETUP luksClose $DEV_NAME || failscip-shell shell shell-project 0.0.0 fail().
960 $CRYPTSETUP luksAddKey $LOOPDEV -d $KEY1 $KEY2 2>/dev/nullscip-shell filesystem . . `/dev/null`. && failscip-shell shell shell-project 0.0.0 fail().
961 $CRYPTSETUP luksAddKey $LOOPDEV -d $KEY1 $KEY2 -l 14 2>/dev/nullscip-shell filesystem . . `/dev/null`. && failscip-shell shell shell-project 0.0.0 fail().
962 $CRYPTSETUP luksAddKey $LOOPDEV -d $KEY1 $KEY2 -l -1 2>/dev/nullscip-shell filesystem . . `/dev/null`. && failscip-shell shell shell-project 0.0.0 fail().
963 $CRYPTSETUP luksAddKey $LOOPDEV -d $KEY1 $KEY2 $FAST_PBKDF_OPT -l 13 --new-keyfile-size 12 || failscip-shell shell shell-project 0.0.0 fail().
964 $CRYPTSETUP luksRemoveKey $LOOPDEV $KEY2 2>/dev/nullscip-shell filesystem . . `/dev/null`. && failscip-shell shell shell-project 0.0.0 fail().
965 $CRYPTSETUP luksRemoveKey $LOOPDEV $KEY2 -l 12 || failscip-shell shell shell-project 0.0.0 fail().
966 $CRYPTSETUP luksChangeKey $LOOPDEV -d $KEY1 $KEY2 2>/dev/nullscip-shell filesystem . . `/dev/null`. && failscip-shell shell shell-project 0.0.0 fail().
967 [scip-shell system . . `[`. $? -ne 2 ] && failscip-shell shell shell-project 0.0.0 fail(). "luksChangeKey should return EPERM exit code"
968 $CRYPTSETUP luksChangeKey $LOOPDEV -d $KEY1 $KEY2 -l 14 2>/dev/nullscip-shell filesystem . . `/dev/null`. && failscip-shell shell shell-project 0.0.0 fail().
969 $CRYPTSETUP luksChangeKey $LOOPDEV -d $KEY1 $KEY2 $FAST_PBKDF_OPT -l 13 || failscip-shell shell shell-project 0.0.0 fail().
970 # -l is ignored for stdin if _only_ passphrase is used
971 echoscip-shell system . . echo. $PWD1 | $CRYPTSETUP luksAddKey $LOOPDEV -d $KEY2 $FAST_PBKDF_OPT || failscip-shell shell shell-project 0.0.0 fail().
972 # this is stupid, but expected
973 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().
974 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().
975 echoscip-shell system . . echo. -e "$PWD1\n" | $CRYPTSETUP luksRemoveKey $LOOPDEV -d- -l 12 || failscip-shell shell shell-project 0.0.0 fail().
976 # offset
977 $CRYPTSETUP -q luksFormat $FAST_PBKDF_OPT --type luks2 $LOOPDEV $KEY1 --key-slot 0 -l 13 --keyfile-offset 16 || failscip-shell shell shell-project 0.0.0 fail().
978 $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().
979 $CRYPTSETUP --key-file=$KEY1 -l 13 --keyfile-offset 16 luksOpen $LOOPDEV $DEV_NAME || failscip-shell shell shell-project 0.0.0 fail().
980 $CRYPTSETUP luksClose $DEV_NAME || failscip-shell shell shell-project 0.0.0 fail().
981 $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().
982 $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().
983 $CRYPTSETUP --key-file=$KEY2 --keyfile-offset 1 luksOpen $LOOPDEV $DEV_NAME || failscip-shell shell shell-project 0.0.0 fail().
984 $CRYPTSETUP luksClose $DEV_NAME || failscip-shell shell shell-project 0.0.0 fail().
985 $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().
986 $CRYPTSETUP luksOpen -d $KEY2 $LOOPDEV $DEV_NAME || failscip-shell shell shell-project 0.0.0 fail().
987 $CRYPTSETUP luksClose $DEV_NAME || failscip-shell shell shell-project 0.0.0 fail().
988
989 preparescip-shell shell shell-project 0.0.0 prepare(). "[25] Suspend/Resume" wipe
990 # LUKS
991 echoscip-shell system . . echo. $PWD1 | $CRYPTSETUP -q luksFormat $FAST_PBKDF_OPT --type luks2 $LOOPDEV || failscip-shell shell shell-project 0.0.0 fail().
992 echoscip-shell system . . echo. $PWD1 | $CRYPTSETUP -q luksOpen $LOOPDEV $DEV_NAME || failscip-shell shell shell-project 0.0.0 fail().
993 $CRYPTSETUP luksSuspend $DEV_NAME || failscip-shell shell shell-project 0.0.0 fail().
994 $CRYPTSETUP -q status $DEV_NAME | grepscip-shell system . . grep. -q "(suspended)" || failscip-shell shell shell-project 0.0.0 fail().
995 $CRYPTSETUP -q resize $DEV_NAME 2>/dev/nullscip-shell filesystem . . `/dev/null`. && failscip-shell shell shell-project 0.0.0 fail().
996 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().
997 [scip-shell system . . `[`. $? -ne 2 ] && failscip-shell shell shell-project 0.0.0 fail(). "luksResume should return EPERM exit code"
998 echoscip-shell system . . echo. $PWD1 | $CRYPTSETUP luksResume $DEV_NAME || failscip-shell shell shell-project 0.0.0 fail().
999 $CRYPTSETUP -q luksClose $DEV_NAME || failscip-shell shell shell-project 0.0.0 fail().
1000 echoscip-shell system . . echo. $PWD1 | $CRYPTSETUP -q luksFormat -c null $FAST_PBKDF_OPT --type luks2 $LOOPDEV || failscip-shell shell shell-project 0.0.0 fail().
1001 echoscip-shell system . . echo. $PWD1 | $CRYPTSETUP -q luksOpen $LOOPDEV $DEV_NAME || failscip-shell shell shell-project 0.0.0 fail().
1002 $CRYPTSETUP luksSuspend $DEV_NAME || failscip-shell shell shell-project 0.0.0 fail().
1003 $CRYPTSETUP -q status $DEV_NAME | grepscip-shell system . . grep. -q "(suspended)" || failscip-shell shell shell-project 0.0.0 fail().
1004 echoscip-shell system . . echo. $PWD1 | $CRYPTSETUP luksResume $DEV_NAME || failscip-shell shell shell-project 0.0.0 fail().
1005 $CRYPTSETUP -q luksClose $DEV_NAME || failscip-shell shell shell-project 0.0.0 fail().
1006
1007 preparescip-shell shell shell-project 0.0.0 prepare(). "[26] luksOpen/Resume with specified key slot number" wipe
1008 # first, let's try passphrase option
1009 echoscip-shell system . . echo. $PWD3 | $CRYPTSETUP -q luksFormat $FAST_PBKDF_OPT -S 5 --type luks2 $LOOPDEV || failscip-shell shell shell-project 0.0.0 fail().
1010 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().
1011 [scip-shell system . . `[`. -b /dev/mapper/$DEV_NAME ] && failscip-shell shell shell-project 0.0.0 fail().
1012 echoscip-shell system . . echo. $PWD3 | $CRYPTSETUP luksOpen -S 5 $LOOPDEV $DEV_NAME || failscip-shell shell shell-project 0.0.0 fail().
1013 check_existsscip-shell shell shell-project 0.0.0 check_exists().
1014 $CRYPTSETUP luksSuspend $DEV_NAME || failscip-shell shell shell-project 0.0.0 fail().
1015 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().
1016 $CRYPTSETUP -q status $DEV_NAME | grepscip-shell system . . grep. -q "(suspended)" || failscip-shell shell shell-project 0.0.0 fail().
1017 echoscip-shell system . . echo. $PWD3 | $CRYPTSETUP luksResume -S 5 $DEV_NAME || failscip-shell shell shell-project 0.0.0 fail().
1018 $CRYPTSETUP luksClose $DEV_NAME || failscip-shell shell shell-project 0.0.0 fail().
1019 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().
1020 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().
1021 [scip-shell system . . `[`. -b /dev/mapper/$DEV_NAME ] && failscip-shell shell shell-project 0.0.0 fail().
1022 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().
1023 [scip-shell system . . `[`. -b /dev/mapper/$DEV_NAME ] && failscip-shell shell shell-project 0.0.0 fail().
1024 # second, try it with keyfiles
1025 $CRYPTSETUP -q luksFormat -q -S 5 $FAST_PBKDF_OPT -d $KEY5 --type luks2 $LOOPDEV || failscip-shell shell shell-project 0.0.0 fail().
1026 $CRYPTSETUP luksAddKey -q $FAST_PBKDF_OPT -S 1 -d $KEY5 $LOOPDEV $KEY1 || failscip-shell shell shell-project 0.0.0 fail().
1027 $CRYPTSETUP luksOpen -S 5 -d $KEY5 $LOOPDEV $DEV_NAME || failscip-shell shell shell-project 0.0.0 fail().
1028 check_existsscip-shell shell shell-project 0.0.0 check_exists().
1029 $CRYPTSETUP luksSuspend $DEV_NAME || failscip-shell shell shell-project 0.0.0 fail().
1030 $CRYPTSETUP luksResume -S 1 -d $KEY5 $DEV_NAME 2>/dev/nullscip-shell filesystem . . `/dev/null`. && failscip-shell shell shell-project 0.0.0 fail().
1031 $CRYPTSETUP -q status $DEV_NAME | grepscip-shell system . . grep. -q "(suspended)" || failscip-shell shell shell-project 0.0.0 fail().
1032 $CRYPTSETUP luksResume -S 5 -d $KEY5 $DEV_NAME || failscip-shell shell shell-project 0.0.0 fail().
1033 $CRYPTSETUP luksClose $DEV_NAME || failscip-shell shell shell-project 0.0.0 fail().
1034 $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().
1035 [scip-shell system . . `[`. -b /dev/mapper/$DEV_NAME ] && failscip-shell shell shell-project 0.0.0 fail().
1036 $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().
1037 [scip-shell system . . `[`. -b /dev/mapper/$DEV_NAME ] && failscip-shell shell shell-project 0.0.0 fail().
1038 # test keyslot not assigned to segment is unable to unlock volume
1039 # otoh it should be allowed to test for proper passphrase
1040 preparescip-shell shell shell-project 0.0.0 prepare(). "" new
1041 echoscip-shell system . . echo. $PWD1 | $CRYPTSETUP open -S1 --test-passphrase $HEADER_KEYU || failscip-shell shell shell-project 0.0.0 fail().
1042 echoscip-shell system . . echo. $PWD1 | $CRYPTSETUP open --unbound --test-passphrase $HEADER_KEYU || failscip-shell shell shell-project 0.0.0 fail().
1043 echoscip-shell system . . echo. $PWD1 | $CRYPTSETUP open -S1 $HEADER_KEYU $DEV_NAME 2>/dev/nullscip-shell filesystem . . `/dev/null`. && failscip-shell shell shell-project 0.0.0 fail().
1044 [scip-shell system . . `[`. -b /dev/mapper/$DEV_NAME ] && failscip-shell shell shell-project 0.0.0 fail().
1045 echoscip-shell system . . echo. $PWD1 | $CRYPTSETUP open $HEADER_KEYU $DEV_NAME 2>/dev/nullscip-shell filesystem . . `/dev/null`. && failscip-shell shell shell-project 0.0.0 fail().
1046 [scip-shell system . . `[`. -b /dev/mapper/$DEV_NAME ] && failscip-shell shell shell-project 0.0.0 fail().
1047 echoscip-shell system . . echo. $PWD0 | $CRYPTSETUP open -S1 --test-passphrase $HEADER_KEYU $DEV_NAME 2>/dev/nullscip-shell filesystem . . `/dev/null`. && failscip-shell shell shell-project 0.0.0 fail().
1048 $CRYPTSETUP luksKillSlot -q $HEADER_KEYU 0
1049 $CRYPTSETUP luksDump $HEADER_KEYU | grepscip-shell system . . grep. -q "0: luks2" && failscip-shell shell shell-project 0.0.0 fail().
1050 echoscip-shell system . . echo. $PWD1 | $CRYPTSETUP open -S1 --test-passphrase $HEADER_KEYU || failscip-shell shell shell-project 0.0.0 fail().
1051 echoscip-shell system . . echo. $PWD1 | $CRYPTSETUP open --unbound --test-passphrase $HEADER_KEYU || failscip-shell shell shell-project 0.0.0 fail().
1052 echoscip-shell system . . echo. $PWD1 | $CRYPTSETUP open -S1 $HEADER_KEYU $DEV_NAME 2>/dev/nullscip-shell filesystem . . `/dev/null`. && failscip-shell shell shell-project 0.0.0 fail().
1053
1054 preparescip-shell shell shell-project 0.0.0 prepare(). "[27] Detached LUKS header" wipe
1055 echoscip-shell system . . echo. $PWD1 | $CRYPTSETUP luksFormat $FAST_PBKDF_OPT --type luks2 $LOOPDEV --header $HEADER_IMG || failscip-shell shell shell-project 0.0.0 fail().
1056 echoscip-shell system . . echo. $PWD1 | $CRYPTSETUP luksFormat $FAST_PBKDF_OPT --type luks2 $LOOPDEV --header $HEADER_IMG --align-payload 1 >/dev/nullscip-shell filesystem . . `/dev/null`. 2>&1 && failscip-shell shell shell-project 0.0.0 fail().
1057 echoscip-shell system . . echo. $PWD1 | $CRYPTSETUP -q luksFormat $FAST_PBKDF_OPT --type luks2 $LOOPDEV --header $HEADER_IMG --align-payload 8192 || failscip-shell shell shell-project 0.0.0 fail().
1058 echoscip-shell system . . echo. $PWD1 | $CRYPTSETUP -q luksFormat $FAST_PBKDF_OPT --type luks2 $LOOPDEV --header $HEADER_IMG --align-payload 4096 >/dev/nullscip-shell filesystem . . `/dev/null`. || failscip-shell shell shell-project 0.0.0 fail().
1059 $CRYPTSETUP luksDump $HEADER_IMG | grepscip-shell system . . grep. -e "0: crypt" -A1 | grepscip-shell system . . grep. -qe $((4096*512)) || failscip-shell shell shell-project 0.0.0 fail().
1060 echoscip-shell system . . echo. $PWD1 | $CRYPTSETUP -q luksFormat $FAST_PBKDF_OPT --type luks2 $LOOPDEV --header $HEADER_IMG --align-payload 0 --sector-size 512 || failscip-shell shell shell-project 0.0.0 fail().
1061 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().
1062 echoscip-shell system . . echo. $PWD1 | $CRYPTSETUP luksOpen $LOOPDEV --header $HEADER_IMG $DEV_NAME || failscip-shell shell shell-project 0.0.0 fail().
1063 echoscip-shell system . . echo. $PWD1 | $CRYPTSETUP -q resize $DEV_NAME --size 100 --header $HEADER_IMG || failscip-shell shell shell-project 0.0.0 fail().
1064 $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().
1065 $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().
1066 $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().
1067 $CRYPTSETUP luksSuspend $DEV_NAME --header $HEADER_IMG || failscip-shell shell shell-project 0.0.0 fail().
1068 echoscip-shell system . . echo. $PWD1 | $CRYPTSETUP luksResume $DEV_NAME --header $HEADER_IMG || failscip-shell shell shell-project 0.0.0 fail().
1069 $CRYPTSETUP luksSuspend $DEV_NAME || failscip-shell shell shell-project 0.0.0 fail().
1070 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().
1071 echoscip-shell system . . echo. $PWD1 | $CRYPTSETUP luksResume $DEV_NAME --header $HEADER_IMG || failscip-shell shell shell-project 0.0.0 fail().
1072 $CRYPTSETUP luksClose $DEV_NAME || failscip-shell shell shell-project 0.0.0 fail().
1073 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().
1074 $CRYPTSETUP luksDump _fakedev_ --header $HEADER_IMG | grepscip-shell system . . grep. -q "5: luks2" || failscip-shell shell shell-project 0.0.0 fail().
1075 $CRYPTSETUP luksKillSlot -q _fakedev_ --header $HEADER_IMG 5 || failscip-shell shell shell-project 0.0.0 fail().
1076 $CRYPTSETUP luksDump _fakedev_ --header $HEADER_IMG | grepscip-shell system . . grep. -q "5: luks2" && failscip-shell shell shell-project 0.0.0 fail().
1077 echoscip-shell system . . echo. $PWD1 | $CRYPTSETUP open --test-passphrase $HEADER_IMG || failscip-shell shell shell-project 0.0.0 fail().
1078 rmscip-shell system . . rm. $HEADER_IMG || failscip-shell shell shell-project 0.0.0 fail().
1079 # create exactly 16 MiBs LUKS2 header
1080 echoscip-shell system . . echo. $PWD1 | $CRYPTSETUP -q luksFormat $FAST_PBKDF_OPT --type luks2 $LOOPDEV --header $HEADER_IMG --luks2-keyslots-size 16352k --luks2-metadata-size 16k --offset 131072 >/dev/nullscip-shell filesystem . . `/dev/null`. || failscip-shell shell shell-project 0.0.0 fail().
1081 SIZE=$(statscip-shell system . . stat. --printf=%s $HEADER_IMG)
1082 testscip-shell system . . test. $SIZE -eq 16777216 || failscip-shell shell shell-project 0.0.0 fail().
1083 $CRYPTSETUP -q luksDump $HEADER_IMG | grepscip-shell system . . grep. -q "offset: $((512 * 131072)) \[bytes\]" || failscip-shell shell shell-project 0.0.0 fail().
1084
1085 preparescip-shell shell shell-project 0.0.0 prepare(). "[28] Repair metadata" wipe
1086 xzscip-shell system . . xz. -dk $HEADER_LUKS2_PV.xz
1087 if [scip-shell system . . `[`. "$HAVE_BLKID" -gt 0 ]; then
1088 $CRYPTSETUP isLuks --disable-locks $HEADER_LUKS2_PV && failscip-shell shell shell-project 0.0.0 fail().
1089 $CRYPTSETUP isLuks $HEADER_LUKS2_PV && failscip-shell shell shell-project 0.0.0 fail().
1090 $CRYPTSETUP isLuks --disable-locks --type luks2 $HEADER_LUKS2_PV && failscip-shell shell shell-project 0.0.0 fail().
1091 $CRYPTSETUP isLuks --type luks2 $HEADER_LUKS2_PV && failscip-shell shell shell-project 0.0.0 fail().
1092 fi
1093 $CRYPTSETUP -q repair $HEADER_LUKS2_PV >/dev/nullscip-shell filesystem . . `/dev/null`. || failscip-shell shell shell-project 0.0.0 fail().
1094 $CRYPTSETUP isLuks $HEADER_LUKS2_PV || failscip-shell shell shell-project 0.0.0 fail().
1095 $CRYPTSETUP isLuks --type luks2 $HEADER_LUKS2_PV || failscip-shell shell shell-project 0.0.0 fail().
1096 $CRYPTSETUP isLuks --type luks1 $HEADER_LUKS2_PV && failscip-shell shell shell-project 0.0.0 fail().
1097
1098 preparescip-shell shell shell-project 0.0.0 prepare(). "[29] LUKS erase" wipe
1099 $CRYPTSETUP -q luksFormat $FAST_PBKDF_OPT --type luks2 $LOOPDEV $KEY5 --key-slot 5 || failscip-shell shell shell-project 0.0.0 fail().
1100 $CRYPTSETUP luksAddKey -q $FAST_PBKDF_OPT -S 1 -d $KEY5 $LOOPDEV $KEY1 || failscip-shell shell shell-project 0.0.0 fail().
1101 $CRYPTSETUP luksDump $LOOPDEV | grepscip-shell system . . grep. -q "1: luks2" || failscip-shell shell shell-project 0.0.0 fail().
1102 $CRYPTSETUP luksDump $LOOPDEV | grepscip-shell system . . grep. -q "5: luks2" || failscip-shell shell shell-project 0.0.0 fail().
1103 $CRYPTSETUP luksErase -q $LOOPDEV || failscip-shell shell shell-project 0.0.0 fail().
1104 $CRYPTSETUP luksDump $LOOPDEV | grepscip-shell system . . grep. -q "1: luks2" && failscip-shell shell shell-project 0.0.0 fail().
1105 $CRYPTSETUP luksDump $LOOPDEV | grepscip-shell system . . grep. -q "5: luks2" && failscip-shell shell shell-project 0.0.0 fail().
1106
1107 preparescip-shell shell shell-project 0.0.0 prepare(). "[30] LUKS convert" wipe
1108 $CRYPTSETUP -q luksFormat $FAST_PBKDF_OPT --type luks1 $LOOPDEV $KEY5 --key-slot 5 || failscip-shell shell shell-project 0.0.0 fail().
1109 $CRYPTSETUP luksAddKey -q $FAST_PBKDF_OPT -S 1 -d $KEY5 $LOOPDEV $KEY1 || failscip-shell shell shell-project 0.0.0 fail().
1110 $CRYPTSETUP -q luksDump $LOOPDEV --dump-json-metadata >/dev/nullscip-shell filesystem . . `/dev/null`. 2>&1 && failscip-shell shell shell-project 0.0.0 fail().
1111 $CRYPTSETUP -q convert --type luks1 $LOOPDEV >/dev/nullscip-shell filesystem . . `/dev/null`. 2>&1 && failscip-shell shell shell-project 0.0.0 fail().
1112 $CRYPTSETUP luksDump $LOOPDEV | grepscip-shell system . . grep. -q "Key Slot 1: ENABLED" || failscip-shell shell shell-project 0.0.0 fail().
1113 $CRYPTSETUP luksDump $LOOPDEV | grepscip-shell system . . grep. -q "Key Slot 5: ENABLED" || failscip-shell shell shell-project 0.0.0 fail().
1114 $CRYPTSETUP -q convert --type luks2 $LOOPDEV || failscip-shell shell shell-project 0.0.0 fail().
1115 $CRYPTSETUP luksDump $LOOPDEV | grepscip-shell system . . grep. -q "1: luks2" || failscip-shell shell shell-project 0.0.0 fail().
1116 $CRYPTSETUP luksDump $LOOPDEV | grepscip-shell system . . grep. -q "5: luks2" || failscip-shell shell shell-project 0.0.0 fail().
1117 $CRYPTSETUP -q convert --type luks1 $LOOPDEV || failscip-shell shell shell-project 0.0.0 fail().
1118 # hash test
1119 $CRYPTSETUP -q luksFormat $FAST_PBKDF_OPT --type luks2 --sector-size 512 $LOOPDEV $KEY5 -S 0 --hash sha512 || failscip-shell shell shell-project 0.0.0 fail().
1120 $CRYPTSETUP luksAddKey -q $FAST_PBKDF_OPT -S 1 -d $KEY5 $LOOPDEV $KEY1 --hash sha256 || failscip-shell shell shell-project 0.0.0 fail().
1121 $CRYPTSETUP -q convert --type luks1 $LOOPDEV >/dev/nullscip-shell filesystem . . `/dev/null`. 2>&1 && failscip-shell shell shell-project 0.0.0 fail().
1122 $CRYPTSETUP -q luksKillSlot $LOOPDEV 1 || failscip-shell shell shell-project 0.0.0 fail().
1123 $CRYPTSETUP -q convert --type luks1 $LOOPDEV || failscip-shell shell shell-project 0.0.0 fail().
1124 $CRYPTSETUP luksDump $LOOPDEV | grepscip-shell system . . grep. -q "Key Slot 0: ENABLED" || failscip-shell shell shell-project 0.0.0 fail().
1125 $CRYPTSETUP luksOpen $LOOPDEV --test-passphrase --key-slot 0 -d $KEY5 || failscip-shell shell shell-project 0.0.0 fail().
1126 # sector size test
1127 $CRYPTSETUP -q luksFormat $FAST_PBKDF_OPT --type luks2 --sector-size 1024 $LOOPDEV $KEY5 || failscip-shell shell shell-project 0.0.0 fail().
1128 $CRYPTSETUP -q convert --type luks1 $LOOPDEV >/dev/nullscip-shell filesystem . . `/dev/null`. 2>&1 && failscip-shell shell shell-project 0.0.0 fail().
1129
1130 # create LUKS1 with data offset not aligned to 4KiB
1131 $CRYPTSETUP -q luksFormat $FAST_PBKDF_OPT --type luks1 $LOOPDEV $KEY5 --align-payload 4097 || failscip-shell shell shell-project 0.0.0 fail().
1132 $CRYPTSETUP -q convert --type luks2 $LOOPDEV || failscip-shell shell shell-project 0.0.0 fail().
1133 $CRYPTSETUP isLuks --type luks2 $LOOPDEV || failscip-shell shell shell-project 0.0.0 fail().
1134 $CRYPTSETUP luksOpen $LOOPDEV --test-passphrase --key-slot 0 -d $KEY5 || failscip-shell shell shell-project 0.0.0 fail().
1135
1136 # keyslot 1 area offset is higher than keyslot 0 area
1137 echoscip-shell system . . echo. $PWD1 | $CRYPTSETUP -q luksFormat $FAST_PBKDF_OPT --type luks2 --key-slot 0 $LOOPDEV || failscip-shell shell shell-project 0.0.0 fail().
1138 echoscip-shell system . . echo. -e "$PWD1\n$PWD2" | $CRYPTSETUP -q luksAddKey $FAST_PBKDF_OPT --key-slot 1 $LOOPDEV || failscip-shell shell shell-project 0.0.0 fail().
1139 echoscip-shell system . . echo. -e "$PWD1\n$PWD1" | $CRYPTSETUP -q luksChangeKey $FAST_PBKDF_OPT $LOOPDEV || failscip-shell shell shell-project 0.0.0 fail().
1140 # convert to LUKS1 and back; LUKS1 does not store length, only offset
1141 $CRYPTSETUP -q convert --type luks1 $LOOPDEV || failscip-shell shell shell-project 0.0.0 fail().
1142 echoscip-shell system . . echo. $PWD1 | $CRYPTSETUP -q open --test-passphrase $LOOPDEV || failscip-shell shell shell-project 0.0.0 fail().
1143 echoscip-shell system . . echo. $PWD2 | $CRYPTSETUP -q open --test-passphrase $LOOPDEV || failscip-shell shell shell-project 0.0.0 fail().
1144 $CRYPTSETUP -q convert --type luks2 $LOOPDEV || failscip-shell shell shell-project 0.0.0 fail().
1145 echoscip-shell system . . echo. $PWD1 | $CRYPTSETUP -q open --test-passphrase $LOOPDEV || failscip-shell shell shell-project 0.0.0 fail().
1146 echoscip-shell system . . echo. $PWD2 | $CRYPTSETUP -q open --test-passphrase $LOOPDEV || failscip-shell shell shell-project 0.0.0 fail().
1147
1148 if dm_crypt_keyring_flawedscip-shell shell shell-project 0.0.0 dm_crypt_keyring_flawed().; then
1149 preparescip-shell shell shell-project 0.0.0 prepare(). "[31] LUKS2 keyring dm-crypt bug" wipe
1150 echoscip-shell system . . echo. $PWD1 | $CRYPTSETUP luksFormat $FAST_PBKDF_OPT --type luks2 $LOOPDEV --header $HEADER_IMG || failscip-shell shell shell-project 0.0.0 fail().
1151 echoscip-shell system . . echo. $PWD1 | $CRYPTSETUP open $LOOPDEV --header $HEADER_IMG $DEV_NAME || failscip-shell shell shell-project 0.0.0 fail().
1152 $CRYPTSETUP -q status $DEV_NAME | grepscip-shell system . . grep. "key location:" | grepscip-shell system . . grep. -q "dm-crypt" || failscip-shell shell shell-project 0.0.0 fail().
1153 $CRYPTSETUP close $DEV_NAME || failscip-shell shell shell-project 0.0.0 fail().
1154 # key must not load in kernel key even when dm-crypt module is missing
1155 if rmmod dm-crypt >/dev/nullscip-shell filesystem . . `/dev/null`. 2>&1; then
1156 echoscip-shell system . . echo. $PWD1 | $CRYPTSETUP open $LOOPDEV --header $HEADER_IMG $DEV_NAME || failscip-shell shell shell-project 0.0.0 fail().
1157 $CRYPTSETUP -q status $DEV_NAME | grepscip-shell system . . grep. "key location:" | grepscip-shell system . . grep. -q "dm-crypt" || failscip-shell shell shell-project 0.0.0 fail().
1158 $CRYPTSETUP close $DEV_NAME || failscip-shell shell shell-project 0.0.0 fail().
1159 fi
1160 fi
1161
1162 if dm_crypt_keyring_supportscip-shell shell shell-project 0.0.0 dm_crypt_keyring_support(). && dm_crypt_keyring_new_kernelscip-shell shell shell-project 0.0.0 dm_crypt_keyring_new_kernel().; then
1163 preparescip-shell shell shell-project 0.0.0 prepare(). "[32] LUKS2 key in keyring" wipe
1164 echoscip-shell system . . echo. $PWD1 | $CRYPTSETUP luksFormat $FAST_PBKDF_OPT --type luks2 $LOOPDEV --header $HEADER_IMG || failscip-shell shell shell-project 0.0.0 fail().
1165
1166 # check keyring support detection works as expected
1167 rmmod dm-crypt >/dev/nullscip-shell filesystem . . `/dev/null`. 2>&1 || truescip-shell system . . true.
1168 echoscip-shell system . . echo. $PWD1 | $CRYPTSETUP open $LOOPDEV --header $HEADER_IMG $DEV_NAME || failscip-shell shell shell-project 0.0.0 fail().
1169 $CRYPTSETUP -q status $DEV_NAME | grepscip-shell system . . grep. "key location:" | grepscip-shell system . . grep. -q "keyring" || failscip-shell shell shell-project 0.0.0 fail().
1170 $CRYPTSETUP close $DEV_NAME || failscip-shell shell shell-project 0.0.0 fail().
1171
1172 echoscip-shell system . . echo. $PWD1 | $CRYPTSETUP open $LOOPDEV --disable-keyring --header $HEADER_IMG $DEV_NAME || failscip-shell shell shell-project 0.0.0 fail().
1173 $CRYPTSETUP -q status $DEV_NAME | grepscip-shell system . . grep. "key location:" | grepscip-shell system . . grep. -q "dm-crypt" || failscip-shell shell shell-project 0.0.0 fail().
1174 $CRYPTSETUP close $DEV_NAME || failscip-shell shell shell-project 0.0.0 fail().
1175
1176 echoscip-shell system . . echo. $PWD1 | $CRYPTSETUP open $LOOPDEV --disable-keyring --header $HEADER_IMG $DEV_NAME || failscip-shell shell shell-project 0.0.0 fail().
1177 $CRYPTSETUP luksSuspend $DEV_NAME || failscip-shell shell shell-project 0.0.0 fail().
1178 echoscip-shell system . . echo. $PWD1 | $CRYPTSETUP luksResume $DEV_NAME --header $HEADER_IMG || failscip-shell shell shell-project 0.0.0 fail().
1179 $CRYPTSETUP -q status $DEV_NAME | grepscip-shell system . . grep. "key location:" | grepscip-shell system . . grep. -q "keyring" || failscip-shell shell shell-project 0.0.0 fail().
1180 $CRYPTSETUP close $DEV_NAME || failscip-shell shell shell-project 0.0.0 fail().
1181
1182 echoscip-shell system . . echo. $PWD1 | $CRYPTSETUP open $LOOPDEV --header $HEADER_IMG $DEV_NAME || failscip-shell shell shell-project 0.0.0 fail().
1183 $CRYPTSETUP luksSuspend $DEV_NAME || failscip-shell shell shell-project 0.0.0 fail().
1184 echoscip-shell system . . echo. $PWD1 | $CRYPTSETUP luksResume --disable-keyring $DEV_NAME --header $HEADER_IMG || failscip-shell shell shell-project 0.0.0 fail().
1185 $CRYPTSETUP -q status $DEV_NAME | grepscip-shell system . . grep. "key location:" | grepscip-shell system . . grep. -q "dm-crypt" || failscip-shell shell shell-project 0.0.0 fail().
1186 $CRYPTSETUP close $DEV_NAME || failscip-shell shell shell-project 0.0.0 fail().
1187 fi
1188
1189 # FIXME: candidate for non-root tests
1190 preparescip-shell shell shell-project 0.0.0 prepare(). "[33] tokens" wipe
1191 echoscip-shell system . . echo. $PWD1 | $CRYPTSETUP luksFormat $FAST_PBKDF_OPT --type luks2 $LOOPDEV || failscip-shell shell shell-project 0.0.0 fail().
1192 if [scip-shell system . . `[`. $HAVE_KEYRING -gt 0 -a -d /proc/sys/kernel/keysscip-shell filesystem . . `/proc/sys/kernel/keys`. ]; then
1193
1194 test_and_prepare_keyringscip-shell shell shell-project 0.0.0 test_and_prepare_keyring().
1195
1196 $CRYPTSETUP token add $LOOPDEV --key-description $TEST_KEY_DESC0 --token-id 3 || failscip-shell shell shell-project 0.0.0 fail().
1197 $CRYPTSETUP luksDump $LOOPDEV | grepscip-shell system . . grep. -q -e "3: luks2-keyring" || failscip-shell shell shell-project 0.0.0 fail().
1198 # keyslot 5 is inactive
1199 $CRYPTSETUP token add $LOOPDEV --key-description $TEST_KEY_DESC1 --key-slot 5 2> /dev/nullscip-shell filesystem . . `/dev/null`. && failscip-shell shell shell-project 0.0.0 fail().
1200 # key description is not reachable
1201 $CRYPTSETUP open --token-only $LOOPDEV --test-passphrase && failscip-shell shell shell-project 0.0.0 fail().
1202 # wrong passphrase
1203 load_keyscip-shell shell shell-project 0.0.0 load_key(). user $TEST_KEY_DESC0 "blabla" "$TEST_KEYRING" || failscip-shell shell shell-project 0.0.0 fail(). "Cannot load 32 byte user key type"
1204 $CRYPTSETUP open --token-only $LOOPDEV --test-passphrase 2>/dev/nullscip-shell filesystem . . `/dev/null`. && failscip-shell shell shell-project 0.0.0 fail().
1205 load_keyscip-shell shell shell-project 0.0.0 load_key(). user $TEST_KEY_DESC0 $PWD1 "$TEST_KEYRING" || failscip-shell shell shell-project 0.0.0 fail(). "Cannot load 32 byte user key type"
1206 $CRYPTSETUP open --token-only $LOOPDEV --test-passphrase || failscip-shell shell shell-project 0.0.0 fail().
1207 $CRYPTSETUP open --token-only $LOOPDEV $DEV_NAME || failscip-shell shell shell-project 0.0.0 fail().
1208 $CRYPTSETUP status $DEV_NAME > /dev/nullscip-shell filesystem . . `/dev/null`. || failscip-shell shell shell-project 0.0.0 fail().
1209 $CRYPTSETUP luksSuspend $DEV_NAME || failscip-shell shell shell-project 0.0.0 fail().
1210 $CRYPTSETUP luksResume $DEV_NAME <&- || failscip-shell shell shell-project 0.0.0 fail().
1211 $CRYPTSETUP -q status $DEV_NAME | grepscip-shell system . . grep. -q "(suspended)" && failscip-shell shell shell-project 0.0.0 fail().
1212 $CRYPTSETUP luksSuspend $DEV_NAME || failscip-shell shell shell-project 0.0.0 fail().
1213 $CRYPTSETUP luksResume $DEV_NAME --token-type luks2-keyring <&- || failscip-shell shell shell-project 0.0.0 fail().
1214 $CRYPTSETUP close $DEV_NAME || failscip-shell shell shell-project 0.0.0 fail().
1215
1216 # check --token-type sort of works (TODO: extend tests when native systemd tokens are available)
1217 echoscip-shell system . . echo. -n "$IMPORT_TOKEN" | $CRYPTSETUP token import $LOOPDEV --token-id 22 || failscip-shell shell shell-project 0.0.0 fail().
1218 # this excludes keyring tokens from unlocking device
1219 $CRYPTSETUP open --token-only --token-type some_type $LOOPDEV --test-passphrase && failscip-shell shell shell-project 0.0.0 fail().
1220 $CRYPTSETUP open --token-only --token-type some_type $LOOPDEV $DEV_NAME && failscip-shell shell shell-project 0.0.0 fail().
1221 $CRYPTSETUP status $DEV_NAME > /dev/nullscip-shell filesystem . . `/dev/null`. && failscip-shell shell shell-project 0.0.0 fail().
1222
1223 $CRYPTSETUP token remove --token-id 3 $LOOPDEV || failscip-shell shell shell-project 0.0.0 fail().
1224 $CRYPTSETUP luksDump $LOOPDEV | grepscip-shell system . . grep. -q -e "3: luks2-keyring" && failscip-shell shell shell-project 0.0.0 fail().
1225
1226 # test we can remove keyslot with token
1227 echoscip-shell system . . echo. -e "$PWD1\n$PWD2" | $CRYPTSETUP luksAddKey -q -S4 $FAST_PBKDF_OPT $LOOPDEV || failscip-shell shell shell-project 0.0.0 fail().
1228 $CRYPTSETUP token add $LOOPDEV --key-description $TEST_KEY_DESC1 --key-slot 4 --token-id 0 || failscip-shell shell shell-project 0.0.0 fail().
1229 $CRYPTSETUP -q luksKillSlot $LOOPDEV 4 || failscip-shell shell shell-project 0.0.0 fail().
1230 $CRYPTSETUP token remove --token-id 0 $LOOPDEV || failscip-shell shell shell-project 0.0.0 fail().
1231
1232 # test we can add unassigned token
1233 $CRYPTSETUP token add $LOOPDEV --key-description $TEST_KEY_DESC0 --unbound --token-id 0 || failscip-shell shell shell-project 0.0.0 fail().
1234 $CRYPTSETUP open --token-only --token-id 0 --test-passphrase $LOOPDEV && failscip-shell shell shell-project 0.0.0 fail().
1235 $CRYPTSETUP token remove --token-id 0 $LOOPDEV || failscip-shell shell shell-project 0.0.0 fail().
1236
1237 # test token unassign works
1238 $CRYPTSETUP token add $LOOPDEV --key-description $TEST_KEY_DESC0 -S0 --token-id 0 || failscip-shell shell shell-project 0.0.0 fail().
1239 $CRYPTSETUP open --token-only --token-id 0 --test-passphrase $LOOPDEV || failscip-shell shell shell-project 0.0.0 fail().
1240 $CRYPTSETUP token unassign --token-id 0 $LOOPDEV 2>/dev/nullscip-shell filesystem . . `/dev/null`. && failscip-shell shell shell-project 0.0.0 fail().
1241 $CRYPTSETUP token unassign -S0 $LOOPDEV 2>/dev/nullscip-shell filesystem . . `/dev/null`. && failscip-shell shell shell-project 0.0.0 fail().
1242 $CRYPTSETUP token unassign --token-id 0 -S0 $LOOPDEV || failscip-shell shell shell-project 0.0.0 fail().
1243 $CRYPTSETUP open --token-only --token-id 0 --test-passphrase $LOOPDEV && failscip-shell shell shell-project 0.0.0 fail().
1244 $CRYPTSETUP token unassign --token-id 0 -S0 $LOOPDEV 2>/dev/nullscip-shell filesystem . . `/dev/null`. && failscip-shell shell shell-project 0.0.0 fail().
1245 $CRYPTSETUP token unassign --token-id 0 -S44 $LOOPDEV 2>/dev/nullscip-shell filesystem . . `/dev/null`. && failscip-shell shell shell-project 0.0.0 fail().
1246 $CRYPTSETUP token unassign --token-id 44 -S0 $LOOPDEV 2>/dev/nullscip-shell filesystem . . `/dev/null`. && failscip-shell shell shell-project 0.0.0 fail().
1247
1248 $CRYPTSETUP token remove $LOOPDEV --token-id 0 || failscip-shell shell shell-project 0.0.0 fail().
1249 $CRYPTSETUP token add $LOOPDEV --key-description $TEST_KEY_DESC0 -S0 --token-id 0 || failscip-shell shell shell-project 0.0.0 fail().
1250
1251 # token 8 assigned to keyslot 0 and 5. Unlocks only 5
1252 echoscip-shell system . . echo. "$PWD2" | $CRYPTSETUP luksAddKey -q -S5 $FAST_PBKDF_OPT --token-id 0 $LOOPDEV || failscip-shell shell shell-project 0.0.0 fail().
1253 echoscip-shell system . . echo. -n "{\"type\":\"luks2-keyring\",\"keyslots\":[\"0\",\"5\"],\"key_description\":\"$TEST_KEY_DESC1\"}" | $CRYPTSETUP token import $LOOPDEV --token-id 8 || failscip-shell shell shell-project 0.0.0 fail().
1254 load_keyscip-shell shell shell-project 0.0.0 load_key(). user $TEST_KEY_DESC1 "$PWD2" "$TEST_KEYRING" || failscip-shell shell shell-project 0.0.0 fail(). "Cannot load 32 byte user key type"
1255
1256 # token 3 assigned to keyslot 1 (wrong passphrase)
1257 echoscip-shell system . . echo. "$PWD3" | $CRYPTSETUP luksAddKey -q -S1 $FAST_PBKDF_OPT --token-id 0 $LOOPDEV || failscip-shell shell shell-project 0.0.0 fail().
1258 $CRYPTSETUP token add $LOOPDEV --key-description $TEST_KEY_DESC2 -S1 --token-id 3 || failscip-shell shell shell-project 0.0.0 fail().
1259 load_keyscip-shell shell shell-project 0.0.0 load_key(). user $TEST_KEY_DESC2 "$PWDW" "$TEST_KEYRING" || failscip-shell shell shell-project 0.0.0 fail(). "Cannot load 32 byte user key type"
1260
1261 # specific token, specific keyslot
1262 $CRYPTSETUP open --test-passphrase --token-id 0 -S0 $LOOPDEV --token-only <&- || failscip-shell shell shell-project 0.0.0 fail().
1263 # specific keyslot unlocked by any token
1264 $CRYPTSETUP open --test-passphrase -S0 $LOOPDEV --token-only <&- || failscip-shell shell shell-project 0.0.0 fail().
1265
1266 # token 0 unusable for keyslot 5
1267 $CRYPTSETUP open --test-passphrase --token-id 0 -S5 $LOOPDEV --token-only <&- >/dev/nullscip-shell filesystem . . `/dev/null`. && failscip-shell shell shell-project 0.0.0 fail().
1268 # backup interactive prompt should work
1269 echoscip-shell system . . echo. $PWD2 | $CRYPTSETUP open --test-passphrase --token-id 0 -S5 $LOOPDEV || failscip-shell shell shell-project 0.0.0 fail().
1270
1271 $CRYPTSETUP open --test-passphrase -S5 --token-id 8 $LOOPDEV <&- || failscip-shell shell shell-project 0.0.0 fail().
1272 $CRYPTSETUP open --test-passphrase -S5 $LOOPDEV <&- || failscip-shell shell shell-project 0.0.0 fail().
1273
1274 expect_unlocked_keyslotscip-shell shell shell-project 0.0.0 expect_unlocked_keyslot(). 5 "open -v --test-passphrase --token-id 8 -S5 $LOOPDEV" || failscip-shell shell shell-project 0.0.0 fail().
1275 expect_unlocked_keyslotscip-shell shell shell-project 0.0.0 expect_unlocked_keyslot(). 5 "open -v --test-passphrase --token-id 8 $LOOPDEV" || failscip-shell shell shell-project 0.0.0 fail().
1276
1277 $CRYPTSETUP open --test-passphrase -S0 --token-id 8 $LOOPDEV --token-only >/dev/nullscip-shell filesystem . . `/dev/null`. && failscip-shell shell shell-project 0.0.0 fail().
1278 [scip-shell system . . `[`. $? -ne 2 ] && failscip-shell shell shell-project 0.0.0 fail(). "open should return EPERM exit code."
1279 $CRYPTSETUP open --test-passphrase -S1 $LOOPDEV --token-only && failscip-shell shell shell-project 0.0.0 fail().
1280 [scip-shell system . . `[`. $? -ne 2 ] && failscip-shell shell shell-project 0.0.0 fail(). "open should return EPERM exit code."
1281 fi
1282 echoscip-shell system . . echo. -n "$IMPORT_TOKEN" | $CRYPTSETUP token import $LOOPDEV --token-id 10 || failscip-shell shell shell-project 0.0.0 fail().
1283 echoscip-shell system . . echo. -n "$IMPORT_TOKEN" | $CRYPTSETUP token import $LOOPDEV --token-id 11 --json-file - || failscip-shell shell shell-project 0.0.0 fail().
1284 echoscip-shell system . . echo. -n "$IMPORT_TOKEN" > $TOKEN_FILE0
1285 $CRYPTSETUP token import $LOOPDEV --token-id 12 --json-file $TOKEN_FILE0 || failscip-shell shell shell-project 0.0.0 fail().
1286 $CRYPTSETUP token import $LOOPDEV --token-id 12 --json-file $TOKEN_FILE0 2>/dev/nullscip-shell filesystem . . `/dev/null`. && failscip-shell shell shell-project 0.0.0 fail().
1287 $CRYPTSETUP token export $LOOPDEV --token-id 10 >$TOKEN_FILE1 || failscip-shell shell shell-project 0.0.0 fail().
1288 diffscip-shell system . . diff. $TOKEN_FILE0 $TOKEN_FILE1 || failscip-shell shell shell-project 0.0.0 fail().
1289 $CRYPTSETUP token export $LOOPDEV --token-id 11 >$TOKEN_FILE1 || failscip-shell shell shell-project 0.0.0 fail().
1290 diffscip-shell system . . diff. $TOKEN_FILE0 $TOKEN_FILE1 || failscip-shell shell shell-project 0.0.0 fail().
1291 $CRYPTSETUP token export $LOOPDEV --token-id 12 >$TOKEN_FILE1 || failscip-shell shell shell-project 0.0.0 fail().
1292 diffscip-shell system . . diff. $TOKEN_FILE0 $TOKEN_FILE1 || failscip-shell shell shell-project 0.0.0 fail().
1293 $CRYPTSETUP token export $LOOPDEV --token-id 12 --json-file $TOKEN_FILE1 || failscip-shell shell shell-project 0.0.0 fail().
1294 diffscip-shell system . . diff. $TOKEN_FILE0 $TOKEN_FILE1 || failscip-shell shell shell-project 0.0.0 fail().
1295 $CRYPTSETUP token export $LOOPDEV --token-id 12 > $TOKEN_FILE1 || failscip-shell shell shell-project 0.0.0 fail().
1296 diffscip-shell system . . diff. $TOKEN_FILE0 $TOKEN_FILE1 || failscip-shell shell shell-project 0.0.0 fail().
1297
1298 preparescip-shell shell shell-project 0.0.0 prepare(). "[34] LUKS keyslot priority" wipe
1299 echoscip-shell system . . echo. $PWD1 | $CRYPTSETUP luksFormat $FAST_PBKDF_OPT --type luks2 $LOOPDEV -S 1 || failscip-shell shell shell-project 0.0.0 fail().
1300 echoscip-shell system . . echo. -e "$PWD1\n$PWD2" | $CRYPTSETUP luksAddKey -q $LOOPDEV $FAST_PBKDF_OPT -S 5 || failscip-shell shell shell-project 0.0.0 fail().
1301 $CRYPTSETUP config $LOOPDEV -S 0 --priority prefer && failscip-shell shell shell-project 0.0.0 fail().
1302 $CRYPTSETUP config $LOOPDEV -S 1 --priority bla >/dev/nullscip-shell filesystem . . `/dev/null`. 2>&1 && failscip-shell shell shell-project 0.0.0 fail().
1303 $CRYPTSETUP config $LOOPDEV -S 1 --priority ignore || failscip-shell shell shell-project 0.0.0 fail().
1304 echoscip-shell system . . echo. $PWD1 | $CRYPTSETUP open $LOOPDEV --test-passphrase 2>/dev/nullscip-shell filesystem . . `/dev/null`. && failscip-shell shell shell-project 0.0.0 fail().
1305 echoscip-shell system . . echo. $PWD1 | $CRYPTSETUP open $LOOPDEV --test-passphrase -S 1 || failscip-shell shell shell-project 0.0.0 fail().
1306 echoscip-shell system . . echo. $PWD2 | $CRYPTSETUP open $LOOPDEV --test-passphrase || failscip-shell shell shell-project 0.0.0 fail().
1307 $CRYPTSETUP config $LOOPDEV -S 1 --priority normal || failscip-shell shell shell-project 0.0.0 fail().
1308 echoscip-shell system . . echo. $PWD1 | $CRYPTSETUP open $LOOPDEV --test-passphrase || failscip-shell shell shell-project 0.0.0 fail().
1309 $CRYPTSETUP config $LOOPDEV -S 1 --priority ignore || failscip-shell shell shell-project 0.0.0 fail().
1310 echoscip-shell system . . echo. $PWD1 | $CRYPTSETUP open $LOOPDEV --test-passphrase 2>/dev/nullscip-shell filesystem . . `/dev/null`. && failscip-shell shell shell-project 0.0.0 fail().
1311
1312 preparescip-shell shell shell-project 0.0.0 prepare(). "[35] LUKS label and subsystem" wipe
1313 echoscip-shell system . . echo. $PWD1 | $CRYPTSETUP luksFormat $FAST_PBKDF_OPT --type luks2 $LOOPDEV || failscip-shell shell shell-project 0.0.0 fail().
1314 $CRYPTSETUP luksDump $LOOPDEV | grepscip-shell system . . grep. "Subsystem:" | grepscip-shell system . . grep. -q "(no subsystem)" || failscip-shell shell shell-project 0.0.0 fail().
1315 $CRYPTSETUP luksDump $LOOPDEV | grepscip-shell system . . grep. "Label:" | grepscip-shell system . . grep. -q "(no label)" || failscip-shell shell shell-project 0.0.0 fail().
1316 echoscip-shell system . . echo. $PWD1 | $CRYPTSETUP -q luksFormat $FAST_PBKDF_OPT --type luks2 $LOOPDEV --subsystem SatelliteTwo --label TheLabel || failscip-shell shell shell-project 0.0.0 fail().
1317 $CRYPTSETUP luksDump $LOOPDEV | grepscip-shell system . . grep. "Subsystem:" | grepscip-shell system . . grep. -q "SatelliteTwo" || failscip-shell shell shell-project 0.0.0 fail().
1318 $CRYPTSETUP luksDump $LOOPDEV | grepscip-shell system . . grep. "Label:" | grepscip-shell system . . grep. -q "TheLabel" || failscip-shell shell shell-project 0.0.0 fail().
1319 $CRYPTSETUP config $LOOPDEV --subsystem SatelliteThree
1320 $CRYPTSETUP luksDump $LOOPDEV | grepscip-shell system . . grep. "Subsystem:" | grepscip-shell system . . grep. -q "SatelliteThree" || failscip-shell shell shell-project 0.0.0 fail().
1321 $CRYPTSETUP luksDump $LOOPDEV | grepscip-shell system . . grep. "Label:" | grepscip-shell system . . grep. -q "(no label)" || failscip-shell shell shell-project 0.0.0 fail().
1322 $CRYPTSETUP config $LOOPDEV --subsystem SatelliteThree --label TheLabel
1323 $CRYPTSETUP luksDump $LOOPDEV | grepscip-shell system . . grep. "Subsystem:" | grepscip-shell system . . grep. -q "SatelliteThree" || failscip-shell shell shell-project 0.0.0 fail().
1324 $CRYPTSETUP luksDump $LOOPDEV | grepscip-shell system . . grep. "Label:" | grepscip-shell system . . grep. -q "TheLabel" || failscip-shell shell shell-project 0.0.0 fail().
1325 $CRYPTSETUP config $LOOPDEV --label 0123456789abcdef0123456789abcdef0123456789abcdef 2>/dev/nullscip-shell filesystem . . `/dev/null`. && failscip-shell shell shell-project 0.0.0 fail().
1326 $CRYPTSETUP config $LOOPDEV --subsystem 0123456789abcdef0123456789abcdef0123456789abcdef 2>/dev/nullscip-shell filesystem . . `/dev/null`. && failscip-shell shell shell-project 0.0.0 fail().
1327
1328 preparescip-shell shell shell-project 0.0.0 prepare(). "[36] LUKS PBKDF setting" wipe
1329 echoscip-shell system . . echo. $PWD1 | $CRYPTSETUP luksFormat --type luks2 --pbkdf bla $LOOPDEV >/dev/nullscip-shell filesystem . . `/dev/null`. 2>&1 && failscip-shell shell shell-project 0.0.0 fail().
1330 # Force setting, no benchmark. PBKDF2 has 1000 iterations as a minimum
1331 echoscip-shell system . . echo. $PWD1 | $CRYPTSETUP luksFormat --type luks2 --pbkdf pbkdf2 --pbkdf-force-iterations 999 $LOOPDEV 2>/dev/nullscip-shell filesystem . . `/dev/null`. && failscip-shell shell shell-project 0.0.0 fail().
1332 echoscip-shell system . . echo. $PWD1 | $CRYPTSETUP -q luksFormat --type luks2 --pbkdf pbkdf2 --pbkdf-force-iterations 1234 $LOOPDEV || failscip-shell shell shell-project 0.0.0 fail().
1333 $CRYPTSETUP luksDump $LOOPDEV | grepscip-shell system . . grep. "Iterations:" | grepscip-shell system . . grep. -q "1234" || failscip-shell shell shell-project 0.0.0 fail().
1334 echoscip-shell system . . echo. $PWD1 | $CRYPTSETUP -q luksFormat --type luks2 --pbkdf argon2id --pbkdf-force-iterations 3 $LOOPDEV 2>/dev/nullscip-shell filesystem . . `/dev/null`. && failscip-shell shell shell-project 0.0.0 fail().
1335 echoscip-shell system . . echo. $PWD1 | $CRYPTSETUP -q luksFormat --type luks2 --pbkdf argon2id --pbkdf-parallel 99 $LOOPDEV 2>/dev/nullscip-shell filesystem . . `/dev/null`. && failscip-shell shell shell-project 0.0.0 fail().
1336 echoscip-shell system . . echo. $PWD1 | $CRYPTSETUP -q luksFormat --type luks2 --pbkdf argon2id --pbkdf-force-iterations 4 --pbkdf-memory 100000 $LOOPDEV || can_fail_fipsscip-shell shell shell-project 0.0.0 can_fail_fips().
1337 $CRYPTSETUP luksDump $LOOPDEV | grepscip-shell system . . grep. "PBKDF:" | grepscip-shell system . . grep. -q "argon2id" || can_fail_fipsscip-shell shell shell-project 0.0.0 can_fail_fips().
1338 echoscip-shell system . . echo. $PWD1 | $CRYPTSETUP -q luksFormat --type luks2 --pbkdf argon2i --pbkdf-force-iterations 4 \
1339 --pbkdf-memory 1234 --pbkdf-parallel 1 $LOOPDEV || can_fail_fipsscip-shell shell shell-project 0.0.0 can_fail_fips().
1340 $CRYPTSETUP luksDump $LOOPDEV | grepscip-shell system . . grep. "PBKDF:" | grepscip-shell system . . grep. -q "argon2i" || can_fail_fipsscip-shell shell shell-project 0.0.0 can_fail_fips().
1341 $CRYPTSETUP luksDump $LOOPDEV | grepscip-shell system . . grep. "Time cost:" | grepscip-shell system . . grep. -q "4" || can_fail_fipsscip-shell shell shell-project 0.0.0 can_fail_fips().
1342 $CRYPTSETUP luksDump $LOOPDEV | grepscip-shell system . . grep. "Memory:" | grepscip-shell system . . grep. -q "1234" || can_fail_fipsscip-shell shell shell-project 0.0.0 can_fail_fips().
1343 $CRYPTSETUP luksDump $LOOPDEV | grepscip-shell system . . grep. "Threads:" | grepscip-shell system . . grep. -q "1" || can_fail_fipsscip-shell shell shell-project 0.0.0 can_fail_fips().
1344 # Benchmark
1345 echoscip-shell system . . echo. $PWD1 | $CRYPTSETUP -q luksFormat --type luks2 --pbkdf argon2i -i 500 --pbkdf-memory 1234 --pbkdf-parallel 1 $LOOPDEV || can_fail_fipsscip-shell shell shell-project 0.0.0 can_fail_fips().
1346 [scip-shell system . . `[`. 0"$($CRYPTSETUP luksDump $LOOPDEV | grepscip-shell system . . grep. "Time cost:" | cutscip-shell system . . cut. -d: -f 2 | sedscip-shell system . . sed. -e 's/\ //g')" -gt 0 ] || can_fail_fipsscip-shell shell shell-project 0.0.0 can_fail_fips().
1347 [scip-shell system . . `[`. 0"$($CRYPTSETUP luksDump $LOOPDEV | grepscip-shell system . . grep. "Memory:" | cutscip-shell system . . cut. -d: -f 2 | sedscip-shell system . . sed. -e 's/\ //g')" -gt 0 ] || can_fail_fipsscip-shell shell shell-project 0.0.0 can_fail_fips().
1348 echoscip-shell system . . echo. $PWD1 | $CRYPTSETUP -q luksFormat --type luks2 --pbkdf pbkdf2 -i 500 $LOOPDEV || failscip-shell shell shell-project 0.0.0 fail().
1349 [scip-shell system . . `[`. 0"$($CRYPTSETUP luksDump $LOOPDEV | grepscip-shell system . . grep. -m1 "Iterations:" | cutscip-shell system . . cut. -d' ' -f 2 | sedscip-shell system . . sed. -e 's/\ //g')" -gt 1000 ] || failscip-shell shell shell-project 0.0.0 fail().
1350
1351 preparescip-shell shell shell-project 0.0.0 prepare(). "[37] LUKS Keyslot convert" wipe
1352 $CRYPTSETUP -q luksFormat $FAST_PBKDF_OPT --type luks1 $LOOPDEV $KEY5 --key-slot 5 || failscip-shell shell shell-project 0.0.0 fail().
1353 $CRYPTSETUP -q luksConvertKey $LOOPDEV --key-file $KEY5 2>/dev/nullscip-shell filesystem . . `/dev/null`. && failscip-shell shell shell-project 0.0.0 fail().
1354 $CRYPTSETUP -q convert --type luks2 $LOOPDEV || failscip-shell shell shell-project 0.0.0 fail().
1355 $CRYPTSETUP luksDump $LOOPDEV | grepscip-shell system . . grep. -q "5: luks2" || failscip-shell shell shell-project 0.0.0 fail().
1356 $CRYPTSETUP luksDump $LOOPDEV | grepscip-shell system . . grep. "PBKDF:" | grepscip-shell system . . grep. -q "pbkdf2" || failscip-shell shell shell-project 0.0.0 fail().
1357 $CRYPTSETUP -q luksConvertKey $LOOPDEV -S 5 --key-file $KEY5 --pbkdf argon2i -i1 --pbkdf-memory 32 || can_fail_fipsscip-shell shell shell-project 0.0.0 can_fail_fips().
1358 $CRYPTSETUP luksDump $LOOPDEV | grepscip-shell system . . grep. -q "5: luks2" || can_fail_fipsscip-shell shell shell-project 0.0.0 can_fail_fips().
1359 echoscip-shell system . . echo. $PWD1 | $CRYPTSETUP luksAddKey -q $FAST_PBKDF_OPT $LOOPDEV -S 1 --key-file $KEY5 || failscip-shell shell shell-project 0.0.0 fail().
1360 $CRYPTSETUP -q luksKillSlot $LOOPDEV 5 || failscip-shell shell shell-project 0.0.0 fail().
1361 $CRYPTSETUP luksDump $LOOPDEV | grepscip-shell system . . grep. -q "1: luks2" || failscip-shell shell shell-project 0.0.0 fail().
1362 $CRYPTSETUP luksDump $LOOPDEV | grepscip-shell system . . grep. "PBKDF:" | grepscip-shell system . . grep. -q "pbkdf2" || failscip-shell shell shell-project 0.0.0 fail().
1363 echoscip-shell system . . echo. $PWD1 | $CRYPTSETUP -q luksConvertKey $LOOPDEV -S 1 --pbkdf argon2i -i1 --pbkdf-memory 32 || can_fail_fipsscip-shell shell shell-project 0.0.0 can_fail_fips().
1364 $CRYPTSETUP luksDump $LOOPDEV | grepscip-shell system . . grep. -q "1: luks2" || can_fail_fipsscip-shell shell shell-project 0.0.0 can_fail_fips().
1365 echoscip-shell system . . echo. $PWD3 | $CRYPTSETUP luksAddKey -q $FAST_PBKDF_OPT -S 21 --unbound -s 72 $LOOPDEV || failscip-shell shell shell-project 0.0.0 fail().
1366 echoscip-shell system . . echo. $PWD3 | $CRYPTSETUP luksConvertKey --pbkdf-force-iterations 1001 --pbkdf pbkdf2 -S 21 $LOOPDEV || failscip-shell shell shell-project 0.0.0 fail().
1367
1368 preparescip-shell shell shell-project 0.0.0 prepare(). "[38] luksAddKey unbound tests" wipe
1369 $CRYPTSETUP -q luksFormat $FAST_PBKDF_OPT --type luks2 $LOOPDEV $KEY5 --key-slot 5 || failscip-shell shell shell-project 0.0.0 fail().
1370 # unbound key may have arbitrary size
1371 echoscip-shell system . . echo. $PWD1 | $CRYPTSETUP luksAddKey $FAST_PBKDF_OPT --unbound -s 72 $LOOPDEV || failscip-shell shell shell-project 0.0.0 fail().
1372 echoscip-shell system . . echo. $PWD2 | $CRYPTSETUP luksAddKey -q $FAST_PBKDF_OPT --unbound -s 72 -S 2 $LOOPDEV || failscip-shell shell shell-project 0.0.0 fail().
1373 $CRYPTSETUP luksDump $LOOPDEV | grepscip-shell system . . grep. -q "2: luks2 (unbound)" || failscip-shell shell shell-project 0.0.0 fail().
1374 ddscip-shell system . . dd. if=/dev/urandomscip-shell filesystem . . `/dev/urandom`. of=$KEY_FILE0 bs=64 count=1 > /dev/nullscip-shell filesystem . . `/dev/null`. 2>&1 || failscip-shell shell shell-project 0.0.0 fail().
1375 echoscip-shell system . . echo. $PWD3 | $CRYPTSETUP luksAddKey -q $FAST_PBKDF_OPT --unbound -s 512 -S 3 --volume-key-file $KEY_FILE0 $LOOPDEV || failscip-shell shell shell-project 0.0.0 fail().
1376 $CRYPTSETUP luksDump $LOOPDEV | grepscip-shell system . . grep. -q "3: luks2 (unbound)" || failscip-shell shell shell-project 0.0.0 fail().
1377 # unbound key size is required
1378 echoscip-shell system . . echo. $PWD1 | $CRYPTSETUP -q luksAddKey --unbound $LOOPDEV 2>/dev/nullscip-shell filesystem . . `/dev/null`. && failscip-shell shell shell-project 0.0.0 fail().
1379 echoscip-shell system . . echo. $PWD3 | $CRYPTSETUP -q luksAddKey --unbound --volume-key-file /dev/urandomscip-shell filesystem . . `/dev/urandom`. $LOOPDEV 2> /dev/nullscip-shell filesystem . . `/dev/null`. && failscip-shell shell shell-project 0.0.0 fail().
1380 # do not allow one to replace keyslot by unbound slot
1381 echoscip-shell system . . echo. $PWD1 | $CRYPTSETUP -q luksAddKey -S5 --unbound -s 32 $LOOPDEV 2>/dev/nullscip-shell filesystem . . `/dev/null`. && failscip-shell shell shell-project 0.0.0 fail().
1382 echoscip-shell system . . echo. $PWD2 | $CRYPTSETUP -q open $LOOPDEV $DEV_NAME 2> /dev/nullscip-shell filesystem . . `/dev/null`. && failscip-shell shell shell-project 0.0.0 fail().
1383 echoscip-shell system . . echo. $PWD2 | $CRYPTSETUP -q open -S2 $LOOPDEV $DEV_NAME 2> /dev/nullscip-shell filesystem . . `/dev/null`. && failscip-shell shell shell-project 0.0.0 fail().
1384 echoscip-shell system . . echo. $PWD2 | $CRYPTSETUP -q open -S2 $LOOPDEV --test-passphrase || failscip-shell shell shell-project 0.0.0 fail().
1385 echoscip-shell system . . echo. $PWD1 | $CRYPTSETUP -q open $LOOPDEV $DEV_NAME 2> /dev/nullscip-shell filesystem . . `/dev/null`. && failscip-shell shell shell-project 0.0.0 fail().
1386 # check we're able to change passphrase for unbound keyslot
1387 echoscip-shell system . . echo. -e "$PWD2\n$PWD3" | $CRYPTSETUP luksChangeKey $FAST_PBKDF_OPT -S 2 $LOOPDEV || failscip-shell shell shell-project 0.0.0 fail().
1388 echoscip-shell system . . echo. $PWD3 | $CRYPTSETUP open --test-passphrase -S 2 $LOOPDEV || failscip-shell shell shell-project 0.0.0 fail().
1389 echoscip-shell system . . echo. $PWD3 | $CRYPTSETUP -q open -S 2 $LOOPDEV $DEV_NAME 2> /dev/nullscip-shell filesystem . . `/dev/null`. && failscip-shell shell shell-project 0.0.0 fail().
1390 # do not allow adding keyslot by unbound keyslot
1391 echoscip-shell system . . echo. -e "$PWD3\n$PWD1" | $CRYPTSETUP -q luksAddKey $LOOPDEV 2> /dev/nullscip-shell filesystem . . `/dev/null`. && failscip-shell shell shell-project 0.0.0 fail().
1392 # check adding keyslot works when there's unbound keyslot
1393 echoscip-shell system . . echo. $PWD1 | $CRYPTSETUP luksAddKey -q $FAST_PBKDF_OPT $LOOPDEV --key-file $KEY5 -S8 || failscip-shell shell shell-project 0.0.0 fail().
1394 echoscip-shell system . . echo. $PWD1 | $CRYPTSETUP open $LOOPDEV $DEV_NAME || failscip-shell shell shell-project 0.0.0 fail().
1395 $CRYPTSETUP close $DEV_NAME || failscip-shell shell shell-project 0.0.0 fail().
1396 $CRYPTSETUP luksKillSlot -q $LOOPDEV 2
1397 $CRYPTSETUP luksDump $LOOPDEV | grepscip-shell system . . grep. -q "2: luks2 (unbound)" && failscip-shell shell shell-project 0.0.0 fail().
1398 echoscip-shell system . . echo. $PWD3 | $CRYPTSETUP luksDump --unbound --volume-key-file $KEY_FILE1 $LOOPDEV 2> /dev/nullscip-shell filesystem . . `/dev/null`. && failscip-shell shell shell-project 0.0.0 fail().
1399 echoscip-shell system . . echo. $PWD3 | $CRYPTSETUP luksDump --unbound 2> /dev/nullscip-shell filesystem . . `/dev/null`. $LOOPDEV 2> /dev/nullscip-shell filesystem . . `/dev/null`. && failscip-shell shell shell-project 0.0.0 fail().
1400 echoscip-shell system . . echo. $PWD3 | $CRYPTSETUP luksDump --unbound --volume-key-file $KEY_FILE1 -S3 $LOOPDEV > /dev/nullscip-shell filesystem . . `/dev/null`. || failscip-shell shell shell-project 0.0.0 fail().
1401 diffscip-shell system . . diff. $KEY_FILE0 $KEY_FILE1 || failscip-shell shell shell-project 0.0.0 fail().
1402 echoscip-shell system . . echo. $PWD3 | $CRYPTSETUP luksDump --unbound --volume-key-file $KEY_FILE1 -S3 $LOOPDEV 2> /dev/nullscip-shell filesystem . . `/dev/null`. && failscip-shell shell shell-project 0.0.0 fail().
1403 diffscip-shell system . . diff. $KEY_FILE0 $KEY_FILE1 || failscip-shell shell shell-project 0.0.0 fail().
1404 rmscip-shell system . . rm. $KEY_FILE1 || failscip-shell shell shell-project 0.0.0 fail().
1405 echoscip-shell system . . echo. $PWD3 | $CRYPTSETUP luksDump --unbound --volume-key-file $KEY_FILE1 -S3 $LOOPDEV | grepscip-shell system . . grep. -q "Unbound Key:" && failscip-shell shell shell-project 0.0.0 fail().
1406 echoscip-shell system . . echo. $PWD3 | $CRYPTSETUP luksDump --unbound -S3 $LOOPDEV | grepscip-shell system . . grep. -q "Unbound Key:" || failscip-shell shell shell-project 0.0.0 fail().
1407 $CRYPTSETUP luksKillSlot -q $LOOPDEV 3 || failscip-shell shell shell-project 0.0.0 fail().
1408 $CRYPTSETUP luksDump $LOOPDEV | grepscip-shell system . . grep. -q "3: luks2 (unbound)" && failscip-shell shell shell-project 0.0.0 fail().
1409
1410 preparescip-shell shell shell-project 0.0.0 prepare(). "[39] LUKS2 metadata variants" wipe
1411 tarscip-shell system . . tar. xJf luks2_mda_images.tar.xz
1412 echoscip-shell system . . echo. -n "$IMPORT_TOKEN" > $TOKEN_FILE0
1413 for mda in 16 32 64 128 256 512 1024 2048 4096 ; do
1414 echoscip-shell system . . echo. -n "[$mda KiB]"
1415 echoscip-shell system . . echo. $PWD4 | $CRYPTSETUP open test_image_$mda $DEV_NAME || failscip-shell shell shell-project 0.0.0 fail().
1416 $CRYPTSETUP close $DEV_NAME || failscip-shell shell shell-project 0.0.0 fail().
1417 echoscip-shell system . . echo. -e "$PWD4\n$PWD3" | $CRYPTSETUP luksAddKey -q -S9 $FAST_PBKDF_OPT test_image_$mda || failscip-shell shell shell-project 0.0.0 fail().
1418 echoscip-shell system . . echo. $PWD4 | $CRYPTSETUP open --test-passphrase test_image_$mda || failscip-shell shell shell-project 0.0.0 fail().
1419 echoscip-shell system . . echo. $PWD3 | $CRYPTSETUP open -S9 --test-passphrase test_image_$mda || failscip-shell shell shell-project 0.0.0 fail().
1420 echoscip-shell system . . echo. -n "$IMPORT_TOKEN" | $CRYPTSETUP token import test_image_$mda --token-id 10 || failscip-shell shell shell-project 0.0.0 fail().
1421 $CRYPTSETUP token export test_image_$mda --token-id 10 >$TOKEN_FILE1 || failscip-shell shell shell-project 0.0.0 fail().
1422 diffscip-shell system . . diff. $TOKEN_FILE1 $TOKEN_FILE0 || failscip-shell shell shell-project 0.0.0 fail().
1423 echoscip-shell system . . echo. -n "[OK]"
1424 done
1425 echoscip-shell system . . echo.
1426
1427 preparescip-shell shell shell-project 0.0.0 prepare(). "[40] LUKS2 metadata areas" wipe
1428 echoscip-shell system . . echo. $PWD1 | $CRYPTSETUP -q luksFormat $FAST_PBKDF_OPT --type luks2 $LOOPDEV 2> /dev/nullscip-shell filesystem . . `/dev/null`. || failscip-shell shell shell-project 0.0.0 fail().
1429 DEFAULT_OFFSET=$($CRYPTSETUP luksDump $LOOPDEV | grepscip-shell system . . grep. "offset: " | cutscip-shell system . . cut. -f 2 -d ' ')
1430 echoscip-shell system . . echo. $PWD1 | $CRYPTSETUP -q luksFormat $FAST_PBKDF_OPT --type luks1 $LOOPDEV --key-size 256 --luks2-metadata-size=128k --luks2-keyslots-size=128k 2> /dev/nullscip-shell filesystem . . `/dev/null`. && failscip-shell shell shell-project 0.0.0 fail().
1431 echoscip-shell system . . echo. $PWD1 | $CRYPTSETUP -q luksFormat $FAST_PBKDF_OPT --type luks2 $LOOPDEV --key-size 256 --luks2-metadata-size=128k --luks2-keyslots-size=127k 2> /dev/nullscip-shell filesystem . . `/dev/null`. && failscip-shell shell shell-project 0.0.0 fail().
1432 echoscip-shell system . . echo. $PWD1 | $CRYPTSETUP -q luksFormat $FAST_PBKDF_OPT --type luks2 $LOOPDEV --key-size 256 --luks2-metadata-size=127k --luks2-keyslots-size=128k 2> /dev/nullscip-shell filesystem . . `/dev/null`. && failscip-shell shell shell-project 0.0.0 fail().
1433 echoscip-shell system . . echo. $PWD1 | $CRYPTSETUP -q luksFormat $FAST_PBKDF_OPT --type luks2 $LOOPDEV --key-size 256 --luks2-metadata-size=128k --luks2-keyslots-size=129M >/dev/nullscip-shell filesystem . . `/dev/null`. 2>&1 && failscip-shell shell shell-project 0.0.0 fail().
1434 echoscip-shell system . . echo. $PWD1 | $CRYPTSETUP -q luksFormat $FAST_PBKDF_OPT --type luks2 $LOOPDEV --key-size 256 --luks2-metadata-size=128k --luks2-keyslots-size=128k >/dev/nullscip-shell filesystem . . `/dev/null`. || failscip-shell shell shell-project 0.0.0 fail().
1435 $CRYPTSETUP luksDump $LOOPDEV | grepscip-shell system . . grep. "Metadata area:" | grepscip-shell system . . grep. -q "131072 \[bytes\]" || failscip-shell shell shell-project 0.0.0 fail().
1436 $CRYPTSETUP luksDump $LOOPDEV | grepscip-shell system . . grep. "Keyslots area:" | grepscip-shell system . . grep. -q "131072 \[bytes\]" || failscip-shell shell shell-project 0.0.0 fail().
1437 echoscip-shell system . . echo. $PWD1 | $CRYPTSETUP -q luksFormat $FAST_PBKDF_OPT --type luks2 $LOOPDEV --key-size 256 --luks2-metadata-size=128k || failscip-shell shell shell-project 0.0.0 fail().
1438 $CRYPTSETUP luksDump $LOOPDEV | grepscip-shell system . . grep. "Metadata area:" | grepscip-shell system . . grep. -q "131072 \[bytes\]" || failscip-shell shell shell-project 0.0.0 fail().
1439 $CRYPTSETUP luksDump $LOOPDEV | grepscip-shell system . . grep. "Keyslots area:" | grepscip-shell system . . grep. -q "$((DEFAULT_OFFSET-2*131072)) \[bytes\]" || failscip-shell shell shell-project 0.0.0 fail().
1440 echoscip-shell system . . echo. $PWD1 | $CRYPTSETUP -q luksFormat $FAST_PBKDF_OPT --type luks2 $LOOPDEV --key-size 256 --luks2-keyslots-size=128k >/dev/nullscip-shell filesystem . . `/dev/null`. || failscip-shell shell shell-project 0.0.0 fail().
1441 $CRYPTSETUP luksDump $LOOPDEV | grepscip-shell system . . grep. "Metadata area:" | grepscip-shell system . . grep. -q "16384 \[bytes\]" || failscip-shell shell shell-project 0.0.0 fail().
1442 $CRYPTSETUP luksDump $LOOPDEV | grepscip-shell system . . grep. "Keyslots area:" | grepscip-shell system . . grep. -q "131072 \[bytes\]" || failscip-shell shell shell-project 0.0.0 fail().
1443 echoscip-shell system . . echo. $PWD1 | $CRYPTSETUP -q luksFormat $FAST_PBKDF_OPT --type luks2 $LOOPDEV --key-size 256 --offset 16384 || failscip-shell shell shell-project 0.0.0 fail().
1444 $CRYPTSETUP luksDump $LOOPDEV | grepscip-shell system . . grep. "Metadata area:" | grepscip-shell system . . grep. -q "16384 \[bytes\]" || failscip-shell shell shell-project 0.0.0 fail().
1445 $CRYPTSETUP luksDump $LOOPDEV | grepscip-shell system . . grep. "Keyslots area:" | grepscip-shell system . . grep. -q "8355840 \[bytes\]" || failscip-shell shell shell-project 0.0.0 fail().
1446 # data offset vs area size
1447 echoscip-shell system . . echo. $PWD1 | $CRYPTSETUP -q luksFormat $FAST_PBKDF_OPT --type luks2 $LOOPDEV --key-size 256 --offset 64 --luks2-keyslots-size=8192 >/dev/nullscip-shell filesystem . . `/dev/null`. 2>&1 && failscip-shell shell shell-project 0.0.0 fail().
1448 echoscip-shell system . . echo. $PWD1 | $CRYPTSETUP -q luksFormat $FAST_PBKDF_OPT --type luks2 $LOOPDEV --key-size 256 --offset $((256+56)) >/dev/nullscip-shell filesystem . . `/dev/null`. 2>&1 && failscip-shell shell shell-project 0.0.0 fail().
1449 echoscip-shell system . . echo. $PWD1 | $CRYPTSETUP -q luksFormat $FAST_PBKDF_OPT --type luks2 $LOOPDEV --key-size 256 --offset $((256+64)) >/dev/nullscip-shell filesystem . . `/dev/null`. || failscip-shell shell shell-project 0.0.0 fail().
1450
1451 preparescip-shell shell shell-project 0.0.0 prepare(). "[41] Per-keyslot encryption parameters" wipe
1452 KEYSLOT_CIPHER="aes-cbc-plain64"
1453 $CRYPTSETUP -q luksFormat --type luks2 $LOOPDEV $KEY1 $FAST_PBKDF_OPT --key-slot 0 --keyslot-cipher $KEYSLOT_CIPHER --keyslot-key-size 128 || failscip-shell shell shell-project 0.0.0 fail().
1454 [scip-shell system . . `[`. "$($CRYPTSETUP luksDump $IMG | grepscip-shell system . . grep. -A8 -m1 "0: luks2" | grepscip-shell system . . grep. "Cipher:" | sedscip-shell system . . sed. -e 's/[[:space:]]\+Cipher:\ \+//g')" = $KEYSLOT_CIPHER ] || failscip-shell shell shell-project 0.0.0 fail().
1455 [scip-shell system . . `[`. "$($CRYPTSETUP luksDump $IMG | grepscip-shell system . . grep. -A8 -m1 "0: luks2" | grepscip-shell system . . grep. "Cipher key:"| sedscip-shell system . . sed. -e 's/[[:space:]]\+Cipher\ key:\ \+//g')" = "128 bits" ] || failscip-shell shell shell-project 0.0.0 fail().
1456 $CRYPTSETUP luksAddKey -q $LOOPDEV -d $KEY1 $KEY2 $FAST_PBKDF_OPT --key-slot 1 --keyslot-cipher $KEYSLOT_CIPHER --keyslot-key-size 128 || failscip-shell shell shell-project 0.0.0 fail().
1457 [scip-shell system . . `[`. "$($CRYPTSETUP luksDump $IMG | grepscip-shell system . . grep. -A8 -m1 "1: luks2" | grepscip-shell system . . grep. "Cipher:" | sedscip-shell system . . sed. -e 's/[[:space:]]\+Cipher:\ \+//g')" = $KEYSLOT_CIPHER ] || failscip-shell shell shell-project 0.0.0 fail().
1458 [scip-shell system . . `[`. "$($CRYPTSETUP luksDump $IMG | grepscip-shell system . . grep. -A8 -m1 "1: luks2" | grepscip-shell system . . grep. "Cipher key:"| sedscip-shell system . . sed. -e 's/[[:space:]]\+Cipher\ key:\ \+//g')" = "128 bits" ] || failscip-shell shell shell-project 0.0.0 fail().
1459 $CRYPTSETUP luksAddKey -q $LOOPDEV -d $KEY1 $KEY2 $FAST_PBKDF_OPT --key-slot 2 || failscip-shell shell shell-project 0.0.0 fail().
1460 $CRYPTSETUP luksChangeKey $LOOPDEV $FAST_PBKDF_OPT -d $KEY2 $KEY1 --key-slot 2 --keyslot-cipher $KEYSLOT_CIPHER --keyslot-key-size 128 || failscip-shell shell shell-project 0.0.0 fail().
1461 [scip-shell system . . `[`. "$($CRYPTSETUP luksDump $IMG | grepscip-shell system . . grep. -A8 -m1 "2: luks2" | grepscip-shell system . . grep. "Cipher:" | sedscip-shell system . . sed. -e 's/[[:space:]]\+Cipher:\ \+//g')" = $KEYSLOT_CIPHER ] || failscip-shell shell shell-project 0.0.0 fail().
1462 [scip-shell system . . `[`. "$($CRYPTSETUP luksDump $IMG | grepscip-shell system . . grep. -A8 -m1 "2: luks2" | grepscip-shell system . . grep. "Cipher key:"| sedscip-shell system . . sed. -e 's/[[:space:]]\+Cipher\ key:\ \+//g')" = "128 bits" ] || failscip-shell shell shell-project 0.0.0 fail().
1463 # unbound keyslot
1464 echoscip-shell system . . echo. $PWD3 | $CRYPTSETUP luksAddKey -q $FAST_PBKDF_OPT --key-slot 21 --unbound -s 72 --keyslot-cipher $KEYSLOT_CIPHER --keyslot-key-size 128 $LOOPDEV || failscip-shell shell shell-project 0.0.0 fail().
1465 [scip-shell system . . `[`. "$($CRYPTSETUP luksDump $IMG | grepscip-shell system . . grep. -A8 -m1 "21: luks2" | grepscip-shell system . . grep. "Cipher:" | sedscip-shell system . . sed. -e 's/[[:space:]]\+Cipher:\ \+//g')" = $KEYSLOT_CIPHER ] || failscip-shell shell shell-project 0.0.0 fail().
1466 [scip-shell system . . `[`. "$($CRYPTSETUP luksDump $IMG | grepscip-shell system . . grep. -A8 -m1 "21: luks2" | grepscip-shell system . . grep. "Cipher key:"| sedscip-shell system . . sed. -e 's/[[:space:]]\+Cipher\ key:\ \+//g')" = "128 bits" ] || failscip-shell shell shell-project 0.0.0 fail().
1467 echoscip-shell system . . echo. $PWD3 | $CRYPTSETUP luksAddKey -q $FAST_PBKDF_OPT --key-slot 22 --unbound -s 72 $LOOPDEV || failscip-shell shell shell-project 0.0.0 fail().
1468 echoscip-shell system . . echo. $PWD3 | $CRYPTSETUP luksConvertKey --key-slot 22 $LOOPDEV --keyslot-cipher $KEYSLOT_CIPHER --keyslot-key-size 128 $LOOPDEV || failscip-shell shell shell-project 0.0.0 fail().
1469 [scip-shell system . . `[`. "$($CRYPTSETUP luksDump $IMG | grepscip-shell system . . grep. -A8 -m1 "22: luks2" | grepscip-shell system . . grep. "Cipher:" | sedscip-shell system . . sed. -e 's/[[:space:]]\+Cipher:\ \+//g')" = $KEYSLOT_CIPHER ] || failscip-shell shell shell-project 0.0.0 fail().
1470 [scip-shell system . . `[`. "$($CRYPTSETUP luksDump $IMG | grepscip-shell system . . grep. -A8 -m1 "22: luks2" | grepscip-shell system . . grep. "Cipher key:"| sedscip-shell system . . sed. -e 's/[[:space:]]\+Cipher\ key:\ \+//g')" = "128 bits" ] || failscip-shell shell shell-project 0.0.0 fail().
1471
1472 preparescip-shell shell shell-project 0.0.0 prepare(). "[42] Some encryption compatibility mode tests" wipe
1473 CIPHERS="aes-ecb aes-cbc-null aes-cbc-plain64 aes-cbc-essiv:sha256 aes-xts-plain64"
1474 key_size=256
1475 for cipher in $CIPHERS ; do
1476 echoscip-shell system . . echo. -n "[$cipher/$key_size]"
1477 $CRYPTSETUP -q luksFormat --type luks2 $LOOPDEV $KEY1 $FAST_PBKDF_OPT --cipher $cipher --key-size $key_size || failscip-shell shell shell-project 0.0.0 fail().
1478 done
1479 echoscip-shell system . . echo.
1480
1481 preparescip-shell shell shell-project 0.0.0 prepare(). "[43] New luksAddKey options." wipe
1482 rmscip-shell system . . rm. -f $VK_FILE
1483 echoscip-shell system . . echo. "$PWD1" | $CRYPTSETUP luksFormat --type luks2 $FAST_PBKDF_OPT $IMG || failscip-shell shell shell-project 0.0.0 fail().
1484 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().
1485
1486 # pass pass
1487 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().
1488 echoscip-shell system . . echo. $PWD2 | $CRYPTSETUP open -q --test-passphrase -S1 $IMG || failscip-shell shell shell-project 0.0.0 fail().
1489
1490 # pass file
1491 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().
1492 $CRYPTSETUP open --test-passphrase -q -S2 -d $KEY1 $IMG || failscip-shell shell shell-project 0.0.0 fail().
1493
1494 # file pass
1495 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().
1496 echoscip-shell system . . echo. $PWD3 | $CRYPTSETUP open -q --test-passphrase -S3 $IMG || failscip-shell shell shell-project 0.0.0 fail().
1497
1498 # file file
1499 $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().
1500 $CRYPTSETUP open --test-passphrase -q -S4 -d $KEY2 $IMG || failscip-shell shell shell-project 0.0.0 fail().
1501
1502 # vk pass
1503 echoscip-shell system . . echo. $PWD4 | $CRYPTSETUP luksAddKey -q $FAST_PBKDF_OPT -S5 --volume-key-file $VK_FILE $IMG || failscip-shell shell shell-project 0.0.0 fail().
1504 echoscip-shell system . . echo. $PWD4 | $CRYPTSETUP open -q --test-passphrase -S5 $IMG || failscip-shell shell shell-project 0.0.0 fail().
1505
1506 # vk file
1507 $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().
1508 $CRYPTSETUP open --test-passphrase -q -S6 -d $KEY5 $IMG || failscip-shell shell shell-project 0.0.0 fail().
1509
1510 if [scip-shell system . . `[`. $HAVE_KEYRING -gt 0 -a -d /proc/sys/kernel/keysscip-shell filesystem . . `/proc/sys/kernel/keys`. ]; then
1511 test_and_prepare_keyringscip-shell shell shell-project 0.0.0 test_and_prepare_keyring().
1512 load_keyscip-shell shell shell-project 0.0.0 load_key(). user $TEST_KEY_DESC0 $PWD1 "$TEST_KEYRING" || failscip-shell shell shell-project 0.0.0 fail(). "Cannot load 32 byte user key type"
1513 load_keyscip-shell shell shell-project 0.0.0 load_key(). user $TEST_KEY_DESC1 $PWDW "$TEST_KEYRING" || failscip-shell shell shell-project 0.0.0 fail(). "Cannot load 32 byte user key type"
1514 $CRYPTSETUP token add $IMG --key-description $TEST_KEY_DESC0 --token-id 0 -S0 || failscip-shell shell shell-project 0.0.0 fail().
1515 $CRYPTSETUP token add $IMG --key-description $TEST_KEY_DESC1 --token-id 1 --unbound || failscip-shell shell shell-project 0.0.0 fail().
1516
1517 # pass token
1518 echoscip-shell system . . echo. -e "$PWD1" | $CRYPTSETUP luksAddKey -q -S7 --new-token-id 1 $FAST_PBKDF_OPT $IMG || failscip-shell shell shell-project 0.0.0 fail().
1519 $CRYPTSETUP open -q --test-passphrase --token-only --token-id 1 -q $IMG || failscip-shell shell shell-project 0.0.0 fail().
1520 echoscip-shell system . . echo. $PWD1 | $CRYPTSETUP luksKillSlot $IMG 7 || failscip-shell shell shell-project 0.0.0 fail().
1521 $CRYPTSETUP open -q --test-passphrase --token-only --token-id 1 -q $IMG && failscip-shell shell shell-project 0.0.0 fail().
1522
1523 # file token
1524 $CRYPTSETUP luksAddKey -q $FAST_PBKDF_OPT -S2 --new-key-slot 7 --new-token-id 1 -d $KEY1 $IMG || failscip-shell shell shell-project 0.0.0 fail().
1525 $CRYPTSETUP open -q --test-passphrase --token-only --token-id 1 -q $IMG || failscip-shell shell shell-project 0.0.0 fail().
1526 echoscip-shell system . . echo. $PWD1 | $CRYPTSETUP luksKillSlot $IMG 7 || failscip-shell shell shell-project 0.0.0 fail().
1527 $CRYPTSETUP open -q --test-passphrase --token-only --token-id 1 -q $IMG && failscip-shell shell shell-project 0.0.0 fail().
1528
1529 # vk token
1530 $CRYPTSETUP luksAddKey -q $FAST_PBKDF_OPT -S7 --volume-key-file $VK_FILE --new-token-id 1 $IMG || failscip-shell shell shell-project 0.0.0 fail().
1531 $CRYPTSETUP open -q --test-passphrase --token-only --token-id 1 -q $IMG || failscip-shell shell shell-project 0.0.0 fail().
1532 echoscip-shell system . . echo. $PWD1 | $CRYPTSETUP luksKillSlot $IMG 7 || failscip-shell shell shell-project 0.0.0 fail().
1533 $CRYPTSETUP open -q --test-passphrase --token-only --token-id 1 -q $IMG && failscip-shell shell shell-project 0.0.0 fail().
1534
1535 # token pass
1536 echoscip-shell system . . echo. $PWD4 | $CRYPTSETUP luksAddKey -q $FAST_PBKDF_OPT -S7 --token-id 0 $IMG || failscip-shell shell shell-project 0.0.0 fail().
1537 echoscip-shell system . . echo. $PWD4 | $CRYPTSETUP open -q --test-passphrase -S7 $IMG || failscip-shell shell shell-project 0.0.0 fail().
1538
1539 # token file
1540 echoscip-shell system . . echo. $PWD4 | $CRYPTSETUP luksAddKey -q $FAST_PBKDF_OPT -S8 --token-id 0 $IMG $KEY2 || failscip-shell shell shell-project 0.0.0 fail().
1541 $CRYPTSETUP open -q --test-passphrase -S8 --key-file $KEY2 $IMG || failscip-shell shell shell-project 0.0.0 fail().
1542
1543 # token token
1544 $CRYPTSETUP luksAddKey -q $FAST_PBKDF_OPT -S9 --token-id 0 --new-token-id 1 $IMG || failscip-shell shell shell-project 0.0.0 fail().
1545 $CRYPTSETUP open -q --test-passphrase --token-only --token-id 1 -q $IMG || failscip-shell shell shell-project 0.0.0 fail().
1546 echoscip-shell system . . echo. $PWD1 | $CRYPTSETUP luksKillSlot $IMG 9 || failscip-shell shell shell-project 0.0.0 fail().
1547 $CRYPTSETUP open -q --test-passphrase --token-only --token-id 1 -q $IMG && failscip-shell shell shell-project 0.0.0 fail().
1548
1549 # reuse same token
1550 $CRYPTSETUP luksAddKey -q $FAST_PBKDF_OPT -S0 --new-key-slot 9 --token-id 0 --new-token-id 0 $IMG || failscip-shell shell shell-project 0.0.0 fail().
1551 $CRYPTSETUP open -q --test-passphrase --token-only --token-id 0 -q $IMG || failscip-shell shell shell-project 0.0.0 fail().
1552 echoscip-shell system . . echo. $PWD1 | $CRYPTSETUP luksKillSlot $IMG 9 || failscip-shell shell shell-project 0.0.0 fail().
1553
1554 # reuse same token
1555 $CRYPTSETUP luksAddKey -q $FAST_PBKDF_OPT --token-id 0 --new-token-id 0 $IMG || failscip-shell shell shell-project 0.0.0 fail().
1556 echoscip-shell system . . echo. $PWD1 | $CRYPTSETUP luksKillSlot $IMG 9 || failscip-shell shell shell-project 0.0.0 fail().
1557 $CRYPTSETUP open -q --test-passphrase --token-only --token-id 0 -q $IMG || failscip-shell shell shell-project 0.0.0 fail().
1558 fi
1559
1560 if dm_crypt_capi_supportscip-shell shell shell-project 0.0.0 dm_crypt_capi_support().; then
1561 preparescip-shell shell shell-project 0.0.0 prepare(). "[44] LUKS2 invalid cipher (kernel cipher driver name)" wipe
1562 xzscip-shell system . . xz. -dk $HEADER_LUKS2_INV.xz
1563 ddscip-shell system . . dd. if=$HEADER_LUKS2_INV of=$IMG conv=notrunc >/dev/nullscip-shell filesystem . . `/dev/null`. 2>&1
1564 $CRYPTSETUP -q luksDump $LOOPDEV | grepscip-shell system . . grep. -q "capi:xts(ecb(aes-generic))-plain64" || failscip-shell shell shell-project 0.0.0 fail().
1565 echoscip-shell system . . echo. $PWD1 | $CRYPTSETUP open $LOOPDEV --test-passphrase || failscip-shell shell shell-project 0.0.0 fail().
1566 echoscip-shell system . . echo. $PWD1 | $CRYPTSETUP open $LOOPDEV $DEV_NAME 2>&1 | grepscip-shell system . . grep. -q "No known cipher specification pattern" || failscip-shell shell shell-project 0.0.0 fail().
1567 echoscip-shell system . . echo. $PWD1 | $CRYPTSETUP reencrypt $LOOPDEV >/dev/nullscip-shell filesystem . . `/dev/null`. 2>&1 && failscip-shell shell shell-project 0.0.0 fail().
1568 fi
1569
1570 if [scip-shell system . . `[`. $HAVE_KEYRING -gt 0 -a -d /proc/sys/kernel/keysscip-shell filesystem . . `/proc/sys/kernel/keys`. ]; then
1571 preparescip-shell shell shell-project 0.0.0 prepare(). "[45] Link VK to a keyring and use custom VK type." wipe
1572
1573 echoscip-shell system . . echo. $PWD1 | $CRYPTSETUP -q luksFormat $FAST_PBKDF_OPT --type luks2 $LOOPDEV 2> /dev/nullscip-shell filesystem . . `/dev/null`. || failscip-shell shell shell-project 0.0.0 fail().
1574 KEY_NAME="cryptsetup:test_volume_key_id"
1575 KEY_NAME2="cryptsetup:test_volume_key_id2"
1576 KEY_NAME3="cryptsetup:test_volume_key_id3"
1577 test_and_prepare_keyringscip-shell shell shell-project 0.0.0 test_and_prepare_keyring().
1578 KID=$(echoscip-shell system . . echo. -n test | keyctl padd user my_token @s)
1579 keyctl unlink $KID >/dev/nullscip-shell filesystem . . `/dev/null`. 2>&1 @s && SESSION_KEYRING_WORKS=1
1580 KID=$(echoscip-shell system . . echo. -n test | keyctl padd user my_token @us)
1581 keyctl unlink $KID >/dev/nullscip-shell filesystem . . `/dev/null`. 2>&1 @us && USER_SESSION_KEYRING_WORKS=1
1582
1583 test_vk_linkscip-shell shell shell-project 0.0.0 test_vk_link(). $KEY_NAME "@u"
1584 test_vk_linkscip-shell shell shell-project 0.0.0 test_vk_link(). $KEY_NAME "@u" "user"
1585 [[ ! -z "$SESSION_KEYRING_WORKS" ]] && test_vk_linkscip-shell shell shell-project 0.0.0 test_vk_link(). $KEY_NAME "@s"
1586 [[ ! -z "$SESSION_KEYRING_WORKS" ]] && test_vk_linkscip-shell shell shell-project 0.0.0 test_vk_link(). $KEY_NAME "@s" "logon"
1587 [[ ! -z "$SESSION_KEYRING_WORKS" ]] && test_vk_linkscip-shell shell shell-project 0.0.0 test_vk_link(). $KEY_NAME "@s" "user"
1588 test_vk_linkscip-shell shell shell-project 0.0.0 test_vk_link(). $KEY_NAME "%:$TEST_KEYRING_NAME"
1589 test_vk_linkscip-shell shell shell-project 0.0.0 test_vk_link(). $KEY_NAME "%:$TEST_KEYRING_NAME" "user"
1590 test_vk_linkscip-shell shell shell-project 0.0.0 test_vk_link(). $KEY_NAME "%:$TEST_KEYRING_NAME" "logon"
1591 # explicitly specify keyring key type
1592 test_vk_linkscip-shell shell shell-project 0.0.0 test_vk_link(). $KEY_NAME "%keyring:$TEST_KEYRING_NAME"
1593
1594 test_vk_link_and_reactivatescip-shell shell shell-project 0.0.0 test_vk_link_and_reactivate(). $KEY_NAME "@u" "user"
1595 test_vk_link_and_reactivatescip-shell shell shell-project 0.0.0 test_vk_link_and_reactivate(). $KEY_NAME "@u"
1596 [[ ! -z "$SESSION_KEYRING_WORKS" ]] && test_vk_link_and_reactivatescip-shell shell shell-project 0.0.0 test_vk_link_and_reactivate(). $KEY_NAME "@s" "user"
1597 test_vk_link_and_reactivatescip-shell shell shell-project 0.0.0 test_vk_link_and_reactivate(). $KEY_NAME "%:$TEST_KEYRING_NAME" "user"
1598 # explicitly specify keyring key type
1599 test_vk_link_and_reactivatescip-shell shell shell-project 0.0.0 test_vk_link_and_reactivate(). $KEY_NAME "%keyring:$TEST_KEYRING_NAME" "user"
1600 test_vk_link_and_reactivatescip-shell shell shell-project 0.0.0 test_vk_link_and_reactivate(). $KEY_NAME "%keyring:$TEST_KEYRING_NAME"
1601
1602 test_vk_link_with_passphrase_checkscip-shell shell shell-project 0.0.0 test_vk_link_with_passphrase_check(). $KEY_NAME "%:$TEST_KEYRING_NAME"
1603 test_vk_link_with_passphrase_checkscip-shell shell shell-project 0.0.0 test_vk_link_with_passphrase_check(). $KEY_NAME "%:$TEST_KEYRING_NAME" "user"
1604 test_vk_link_with_passphrase_checkscip-shell shell shell-project 0.0.0 test_vk_link_with_passphrase_check(). $KEY_NAME "%:$TEST_KEYRING_NAME" "logon"
1605
1606 # test numeric keyring name -5 is user session (@us) keyring
1607 echoscip-shell system . . echo. $PWD1 | $CRYPTSETUP open $LOOPDEV $DEV_NAME --link-vk-to-keyring -5::%logon:$KEY_NAME || failscip-shell shell shell-project 0.0.0 fail().
1608 keyctl search @us logon $KEY_NAME > /dev/nullscip-shell filesystem . . `/dev/null`. 2>&1 || failscip-shell shell shell-project 0.0.0 fail(). "VK is not linked to the specified keyring after activation."
1609 $CRYPTSETUP close $DEV_NAME
1610 keyctl search @us logon $KEY_NAME > /dev/nullscip-shell filesystem . . `/dev/null`. 2>&1 || failscip-shell shell shell-project 0.0.0 fail(). "VK is not linked to the specified keyring after deactivation."
1611 keyctl unlink "%logon:$KEY_NAME" @us || failscip-shell shell shell-project 0.0.0 fail().
1612
1613 # test malformed keyring descriptions and key types
1614 # missing key description
1615 echoscip-shell system . . echo. $PWD1 | $CRYPTSETUP open $LOOPDEV $DEV_NAME --link-vk-to-keyring "%$TEST_KEYRING_NAME::" > /dev/nullscip-shell filesystem . . `/dev/null`. 2>&1 && failscip-shell shell shell-project 0.0.0 fail().
1616 # malformed keyring description
1617 echoscip-shell system . . echo. $PWD1 | $CRYPTSETUP open $LOOPDEV $DEV_NAME --link-vk-to-keyring ":$TEST_KEYRING_NAME::$KEY_NAME" > /dev/nullscip-shell filesystem . . `/dev/null`. 2>&1 && failscip-shell shell shell-project 0.0.0 fail().
1618 echoscip-shell system . . echo. $PWD1 | $CRYPTSETUP open $LOOPDEV $DEV_NAME --link-vk-to-keyring "@uuu::$KEY_NAME" > /dev/nullscip-shell filesystem . . `/dev/null`. 2>&1 && failscip-shell shell shell-project 0.0.0 fail().
1619 echoscip-shell system . . echo. $PWD1 | $CRYPTSETUP open $LOOPDEV $DEV_NAME --link-vk-to-keyring "@usu::$KEY_NAME" > /dev/nullscip-shell filesystem . . `/dev/null`. 2>&1 && failscip-shell shell shell-project 0.0.0 fail().
1620
1621 echoscip-shell system . . echo. $PWD1 | $CRYPTSETUP open $LOOPDEV $DEV_NAME --link-vk-to-keyring "$TEST_KEYRING_NAME::%user" > /dev/nullscip-shell filesystem . . `/dev/null`. 2>&1 && failscip-shell shell shell-project 0.0.0 fail().
1622 echoscip-shell system . . echo. $PWD1 | $CRYPTSETUP open $LOOPDEV $DEV_NAME --link-vk-to-keyring "$TEST_KEYRING_NAME::%user:" > /dev/nullscip-shell filesystem . . `/dev/null`. 2>&1 && failscip-shell shell shell-project 0.0.0 fail().
1623 echoscip-shell system . . echo. $PWD1 | $CRYPTSETUP open $LOOPDEV $DEV_NAME --link-vk-to-keyring "%user:$KEY_NAME" > /dev/nullscip-shell filesystem . . `/dev/null`. 2>&1 && failscip-shell shell shell-project 0.0.0 fail().
1624
1625 echoscip-shell system . . echo. $PWD1 | $CRYPTSETUP open $LOOPDEV $DEV_NAME --link-vk-to-keyring "@t::%0:$KEY_NAME" > /dev/nullscip-shell filesystem . . `/dev/null`. 2>&1 && failscip-shell shell shell-project 0.0.0 fail().
1626 echoscip-shell system . . echo. $PWD1 | $CRYPTSETUP open $LOOPDEV $DEV_NAME --link-vk-to-keyring "@t::%blah:$KEY_NAME" > /dev/nullscip-shell filesystem . . `/dev/null`. 2>&1 && failscip-shell shell shell-project 0.0.0 fail().
1627 echoscip-shell system . . echo. $PWD1 | $CRYPTSETUP open $LOOPDEV $DEV_NAME --link-vk-to-keyring "@t::%userlogon:$KEY_NAME" > /dev/nullscip-shell filesystem . . `/dev/null`. 2>&1 && failscip-shell shell shell-project 0.0.0 fail().
1628
1629 # test that only one VK name is used, when the device is not in reencryption
1630 echoscip-shell system . . echo. $PWD1 | $CRYPTSETUP open $LOOPDEV $DEV_NAME --link-vk-to-keyring "@u::%user:$KEY_NAME" --link-vk-to-keyring "@u::%user:$KEY_NAME2" > /dev/nullscip-shell filesystem . . `/dev/null`. 2>&1 || failscip-shell shell shell-project 0.0.0 fail().
1631 keyctl unlink "%user:$KEY_NAME" @u || failscip-shell shell shell-project 0.0.0 fail().
1632 keyctl unlink "%user:$KEY_NAME2" @u > /dev/nullscip-shell filesystem . . `/dev/null`. 2>&1 && failscip-shell shell shell-project 0.0.0 fail().
1633 $CRYPTSETUP close $DEV_NAME || failscip-shell shell shell-project 0.0.0 fail().
1634
1635 # test linkning multiple VKs during reencryption
1636 echoscip-shell system . . echo. $PWD1 | $CRYPTSETUP -q reencrypt $LOOPDEV --init-only
1637
1638 test_reencrypt_vk_linkscip-shell shell shell-project 0.0.0 test_reencrypt_vk_link(). $KEY_NAME $KEY_NAME2 "@u"
1639 test_reencrypt_vk_linkscip-shell shell shell-project 0.0.0 test_reencrypt_vk_link(). $KEY_NAME $KEY_NAME2 "@u" "user"
1640 [[ ! -z "$SESSION_KEYRING_WORKS" ]] && test_reencrypt_vk_linkscip-shell shell shell-project 0.0.0 test_reencrypt_vk_link(). $KEY_NAME $KEY_NAME2 "@s"
1641 [[ ! -z "$SESSION_KEYRING_WORKS" ]] && test_reencrypt_vk_linkscip-shell shell shell-project 0.0.0 test_reencrypt_vk_link(). $KEY_NAME $KEY_NAME2 "@s" "logon"
1642 [[ ! -z "$SESSION_KEYRING_WORKS" ]] && test_reencrypt_vk_linkscip-shell shell shell-project 0.0.0 test_reencrypt_vk_link(). $KEY_NAME $KEY_NAME2 "@s" "user"
1643 test_reencrypt_vk_linkscip-shell shell shell-project 0.0.0 test_reencrypt_vk_link(). $KEY_NAME $KEY_NAME2 "%:$TEST_KEYRING_NAME"
1644 test_reencrypt_vk_linkscip-shell shell shell-project 0.0.0 test_reencrypt_vk_link(). $KEY_NAME $KEY_NAME2 "%:$TEST_KEYRING_NAME" "user"
1645 test_reencrypt_vk_linkscip-shell shell shell-project 0.0.0 test_reencrypt_vk_link(). $KEY_NAME $KEY_NAME2 "%:$TEST_KEYRING_NAME" "logon"
1646 # explicitly specify keyring key type
1647 test_reencrypt_vk_linkscip-shell shell shell-project 0.0.0 test_reencrypt_vk_link(). $KEY_NAME $KEY_NAME2 "%keyring:$TEST_KEYRING_NAME"
1648
1649 test_reencrypt_vk_link_and_reactivatescip-shell shell shell-project 0.0.0 test_reencrypt_vk_link_and_reactivate(). $KEY_NAME $KEY_NAME2 "@u"
1650 test_reencrypt_vk_link_and_reactivatescip-shell shell shell-project 0.0.0 test_reencrypt_vk_link_and_reactivate(). $KEY_NAME $KEY_NAME2 "@u" "user"
1651 [[ ! -z "$SESSION_KEYRING_WORKS" ]] && test_reencrypt_vk_link_and_reactivatescip-shell shell shell-project 0.0.0 test_reencrypt_vk_link_and_reactivate(). $KEY_NAME $KEY_NAME2 "@s"
1652 [[ ! -z "$SESSION_KEYRING_WORKS" ]] && test_reencrypt_vk_link_and_reactivatescip-shell shell shell-project 0.0.0 test_reencrypt_vk_link_and_reactivate(). $KEY_NAME $KEY_NAME2 "@s" "user"
1653 test_reencrypt_vk_link_and_reactivatescip-shell shell shell-project 0.0.0 test_reencrypt_vk_link_and_reactivate(). $KEY_NAME $KEY_NAME2 "%:$TEST_KEYRING_NAME"
1654 test_reencrypt_vk_link_and_reactivatescip-shell shell shell-project 0.0.0 test_reencrypt_vk_link_and_reactivate(). $KEY_NAME $KEY_NAME2 "%:$TEST_KEYRING_NAME" "user"
1655
1656 # explicitly specify keyring key type
1657 test_reencrypt_vk_linkscip-shell shell shell-project 0.0.0 test_reencrypt_vk_link(). $KEY_NAME $KEY_NAME2 "%keyring:$TEST_KEYRING_NAME"
1658
1659 # the keyring and key type have to be the same for both keys
1660 echoscip-shell system . . echo. $PWD1 | $CRYPTSETUP open $LOOPDEV $DEV_NAME --link-vk-to-keyring "@s::%user:$KEY_NAME" --link-vk-to-keyring "@u::%user:$KEY_NAME2" > /dev/nullscip-shell filesystem . . `/dev/null`. 2>&1 && failscip-shell shell shell-project 0.0.0 fail().
1661 echoscip-shell system . . echo. $PWD1 | $CRYPTSETUP open $LOOPDEV $DEV_NAME --link-vk-to-keyring "@u::%logon:$KEY_NAME" --link-vk-to-keyring "@u::%user:$KEY_NAME2" > /dev/nullscip-shell filesystem . . `/dev/null`. 2>&1 && failscip-shell shell shell-project 0.0.0 fail().
1662 echoscip-shell system . . echo. $PWD1 | $CRYPTSETUP open $LOOPDEV $DEV_NAME --link-vk-to-keyring "@s::%logon:$KEY_NAME" --link-vk-to-keyring "@u::%user:$KEY_NAME2" > /dev/nullscip-shell filesystem . . `/dev/null`. 2>&1 && failscip-shell shell shell-project 0.0.0 fail().
1663
1664 # supply one/three key name(s) when two names are required
1665 echoscip-shell system . . echo. $PWD1 | $CRYPTSETUP open $LOOPDEV $DEV_NAME --link-vk-to-keyring "@s::%logon:$KEY_NAME" > /dev/nullscip-shell filesystem . . `/dev/null`. 2>&1 && failscip-shell shell shell-project 0.0.0 fail().
1666 echoscip-shell system . . echo. $PWD1 | $CRYPTSETUP open $LOOPDEV $DEV_NAME --link-vk-to-keyring "@s::%logon:$KEY_NAME" --link-vk-to-keyring "@s::%logon:$KEY_NAME2" --link-vk-to-keyring "@s::%logon:$KEY_NAME3" > /dev/nullscip-shell filesystem . . `/dev/null`. 2>&1 && failscip-shell shell shell-project 0.0.0 fail().
1667 fi
1668
1669 preparescip-shell shell shell-project 0.0.0 prepare(). "[46] Blkid disable check" wipe
1670 if [scip-shell system . . `[`. "$HAVE_BLKID" -gt 0 ]; then
1671 xzscip-shell system . . xz. -dkf $HEADER_LUKS2_PV.xz
1672 # batch mode disables blkid print, use --debug to check it
1673 echoscip-shell system . . echo. $PWD1 | $CRYPTSETUP -q --debug luksFormat $FAST_PBKDF_OPT --type luks2 $HEADER_LUKS2_PV 2>&1 | grepscip-shell system . . grep. "signature" | grepscip-shell system . . grep. -q "LVM2_member" || failscip-shell shell shell-project 0.0.0 fail().
1674 xzscip-shell system . . xz. -dkf $HEADER_LUKS2_PV.xz
1675 echoscip-shell system . . echo. $PWD1 | $CRYPTSETUP -q --debug --disable-blkid luksFormat $FAST_PBKDF_OPT --type luks2 $HEADER_LUKS2_PV 2>&1 | grepscip-shell system . . grep. -q "LVM2_member" && failscip-shell shell shell-project 0.0.0 fail().
1676 fi
1677
1678 preparescip-shell shell shell-project 0.0.0 prepare(). "[47] Init from suspended device" wipe
1679 dmsetup create $DEV_NAME --table "0 39998 linear $LOOPDEV 2" || failscip-shell shell shell-project 0.0.0 fail().
1680 echoscip-shell system . . echo. $PWD1 | $CRYPTSETUP -q $FAST_PBKDF_OPT luksFormat --type luks2 --header $HEADER_IMG /dev/mapper/$DEV_NAME || failscip-shell shell shell-project 0.0.0 fail().
1681 echoscip-shell system . . echo. $PWD1 | $CRYPTSETUP -q luksOpen --header $HEADER_IMG /dev/mapper/$DEV_NAME $DEV_NAME2 || failscip-shell shell shell-project 0.0.0 fail().
1682 # underlying device now returns error but node is still present
1683 dmsetup load $DEV_NAME --table "0 40000 error" || failscip-shell shell shell-project 0.0.0 fail().
1684 dmsetup resume $DEV_NAME || failscip-shell shell shell-project 0.0.0 fail().
1685 dmsetup suspend $DEV_NAME || failscip-shell shell shell-project 0.0.0 fail().
1686 # status must print data even if data device is suspended
1687 $CRYPTSETUP -q status --debug --header $HEADER_IMG $DEV_NAME2 | grepscip-shell system . . grep. "type:" | grepscip-shell system . . grep. -q "LUKS2" || failscip-shell shell shell-project 0.0.0 fail().
1688 dmsetup resume $DEV_NAME || failscip-shell shell shell-project 0.0.0 fail().
1689 $CRYPTSETUP -q luksClose $DEV_NAME2 || failscip-shell shell shell-project 0.0.0 fail().
1690 dmsetup remove --retry $DEV_NAME || failscip-shell shell shell-project 0.0.0 fail().
1691
1692 preparescip-shell shell shell-project 0.0.0 prepare(). "[48] Zoned device is unusable for LUKS header" wipe
1693 add_scsi_devicescip-shell shell shell-project 0.0.0 add_scsi_device(). dev_size_mb=32 sector_size=4096 zbc=host-managed
1694 if [scip-shell system . . `[`. $? -eq 0 ] ; then
1695 echoscip-shell system . . echo. $PWD1 | $CRYPTSETUP luksFormat --type luks1 $FAST_PBKDF_OPT $DEV > /dev/nullscip-shell filesystem . . `/dev/null`. 2>&1 && failscip-shell shell shell-project 0.0.0 fail().
1696 echoscip-shell system . . echo. $PWD1 | $CRYPTSETUP luksFormat --type luks1 $FAST_PBKDF_OPT --header $HEADER_IMG $DEV >/dev/nullscip-shell filesystem . . `/dev/null`. || failscip-shell shell shell-project 0.0.0 fail().
1697 echoscip-shell system . . echo. $PWD1 | $CRYPTSETUP open --header $HEADER_IMG $DEV $DEV_NAME || failscip-shell shell shell-project 0.0.0 fail().
1698 $CRYPTSETUP close $DEV_NAME || failscip-shell shell shell-project 0.0.0 fail().
1699 echoscip-shell system . . echo. $PWD1 | $CRYPTSETUP luksFormat --type luks2 $FAST_PBKDF_OPT $DEV > /dev/nullscip-shell filesystem . . `/dev/null`. 2>&1 && failscip-shell shell shell-project 0.0.0 fail().
1700 echoscip-shell system . . echo. $PWD1 | $CRYPTSETUP luksFormat --type luks2 $FAST_PBKDF_OPT --header $HEADER_IMG $DEV >/dev/nullscip-shell filesystem . . `/dev/null`. || failscip-shell shell shell-project 0.0.0 fail().
1701 echoscip-shell system . . echo. $PWD1 | $CRYPTSETUP open --header $HEADER_IMG $DEV $DEV_NAME || failscip-shell shell shell-project 0.0.0 fail().
1702 $CRYPTSETUP close $DEV_NAME || failscip-shell shell shell-project 0.0.0 fail().
1703 fi
1704
1705 if [scip-shell system . . `[`. $HAVE_KEYRING -gt 0 -a -d /proc/sys/kernel/keysscip-shell filesystem . . `/proc/sys/kernel/keys`. ]; then
1706 preparescip-shell shell shell-project 0.0.0 prepare(). "[49] Keyring description use" wipe
1707 test_and_prepare_keyringscip-shell shell shell-project 0.0.0 test_and_prepare_keyring().
1708 load_keyscip-shell shell shell-project 0.0.0 load_key(). user $TEST_KEY_DESC1 $PWD1 "$TEST_KEYRING" || failscip-shell shell shell-project 0.0.0 fail().
1709 load_keyscip-shell shell shell-project 0.0.0 load_key(). user $TEST_KEY_DESC2 $PWD2 "$TEST_KEYRING" || failscip-shell shell shell-project 0.0.0 fail().
1710 $CRYPTSETUP -q luksFormat $FAST_PBKDF_OPT --type luks2 $LOOPDEV --disable-keyring --key-description $TEST_KEY_DESC1 2>/dev/nullscip-shell filesystem . . `/dev/null`. && failscip-shell shell shell-project 0.0.0 fail().
1711 $CRYPTSETUP -q luksFormat $FAST_PBKDF_OPT --type luks2 $LOOPDEV --key-description $TEST_KEY_DESC1 || failscip-shell shell shell-project 0.0.0 fail().
1712 $CRYPTSETUP -q luksDump $LOOPDEV --dump-volume-key --key-description $TEST_KEY_DESC1 >/dev/nullscip-shell filesystem . . `/dev/null`. || failscip-shell shell shell-project 0.0.0 fail().
1713 $CRYPTSETUP -q open $LOOPDEV $DEV_NAME --key-description $TEST_KEY_DESC1 || failscip-shell shell shell-project 0.0.0 fail().
1714 $CRYPTSETUP luksSuspend $DEV_NAME || failscip-shell shell shell-project 0.0.0 fail().
1715 $CRYPTSETUP luksResume $DEV_NAME --key-description $TEST_KEY_DESC1 || failscip-shell shell shell-project 0.0.0 fail().
1716 $CRYPTSETUP -q close $DEV_NAME || failscip-shell shell shell-project 0.0.0 fail().
1717 echoscip-shell system . . echo. $PWD1 | $CRYPTSETUP luksAddKey $FAST_PBKDF_OPT --new-key-description $TEST_KEY_DESC2 $LOOPDEV --disable-keyring 2>/dev/nullscip-shell filesystem . . `/dev/null`. && failscip-shell shell shell-project 0.0.0 fail().
1718 echoscip-shell system . . echo. $PWD1 | $CRYPTSETUP luksAddKey $FAST_PBKDF_OPT --new-key-description $TEST_KEY_DESC2 $LOOPDEV --new-key-slot 1 || failscip-shell shell shell-project 0.0.0 fail().
1719 $CRYPTSETUP -q open $LOOPDEV --test-passphrase --key-description $TEST_KEY_DESC2 || failscip-shell shell shell-project 0.0.0 fail().
1720 $CRYPTSETUP -q luksKillSlot $LOOPDEV 1 || failscip-shell shell shell-project 0.0.0 fail().
1721 echoscip-shell system . . echo. $PWD2 | $CRYPTSETUP luksAddKey $FAST_PBKDF_OPT --key-description $TEST_KEY_DESC1 $LOOPDEV --new-key-slot 1 || failscip-shell shell shell-project 0.0.0 fail().
1722 $CRYPTSETUP -q open $LOOPDEV --test-passphrase --key-description $TEST_KEY_DESC2 || failscip-shell shell shell-project 0.0.0 fail().
1723 $CRYPTSETUP -q luksKillSlot $LOOPDEV 1 || failscip-shell shell shell-project 0.0.0 fail().
1724 $CRYPTSETUP luksAddKey $FAST_PBKDF_OPT --key-description $TEST_KEY_DESC1 --new-key-description $TEST_KEY_DESC2 $LOOPDEV --new-key-slot 1 || failscip-shell shell shell-project 0.0.0 fail().
1725 $CRYPTSETUP -q open $LOOPDEV --test-passphrase --key-description $TEST_KEY_DESC2 || failscip-shell shell shell-project 0.0.0 fail().
1726 $CRYPTSETUP -q luksKillSlot $LOOPDEV 1 || failscip-shell shell shell-project 0.0.0 fail().
1727 fi
1728
1729 preparescip-shell shell shell-project 0.0.0 prepare(). "[50] Interactive retry keyslot test" wipe
1730 echoscip-shell system . . echo. $PWD1 | $CRYPTSETUP -q luksFormat $FAST_PBKDF_OPT --type luks2 $LOOPDEV || failscip-shell shell shell-project 0.0.0 fail().
1731 echoscip-shell system . . echo. $PWD2 | $CRYPTSETUP -q luksAddKey $FAST_PBKDF_OPT --unbound --key-size 256 $LOOPDEV || failscip-shell shell shell-project 0.0.0 fail().
1732 expect_retried_unlocked_keyslotscip-shell shell shell-project 0.0.0 expect_retried_unlocked_keyslot(). 0 $PWD1 "open -v --test-passphrase --tries 2 $LOOPDEV" || failscip-shell shell shell-project 0.0.0 fail().
1733 expect_retried_unlocked_keyslotscip-shell shell shell-project 0.0.0 expect_retried_unlocked_keyslot(). 1 $PWD2 "open -v --test-passphrase --tries 2 -S1 $LOOPDEV" || failscip-shell shell shell-project 0.0.0 fail().
1734
1735 preparescip-shell shell shell-project 0.0.0 prepare(). "[51] Early check for active name." wipe
1736 DM_BAD_NAME=x/x
1737 DM_LONG_NAME=0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef
1738 echoscip-shell system . . echo. $PWD1 | $CRYPTSETUP luksFormat -q $FAST_PBKDF_OPT --type luks2 $LOOPDEV || failscip-shell shell shell-project 0.0.0 fail().
1739 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().
1740 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().
1741
1742 if ! fips_modescip-shell shell shell-project 0.0.0 fips_mode(). -a -d $LUKS2_LOCKING_DIR; then
1743 touchscip-shell system . . touch. $LUKS2_LOCKING_DIR/$MEMORY_HARD_LOCK_FILE
1744 preparescip-shell shell shell-project 0.0.0 prepare(). "[52] Test pbkdf serialization flag." wipe
1745 echoscip-shell system . . echo. $PWD1 | $CRYPTSETUP luksFormat -q $FAST_PBKDF_ARGON_OPT --type luks2 $LOOPDEV || failscip-shell shell shell-project 0.0.0 fail().
1746 testscip-shell system . . test. -f $LUKS2_LOCKING_DIR/$MEMORY_HARD_LOCK_FILE || failscip-shell shell shell-project 0.0.0 fail(). "The locking file disappeared unexpectedly"
1747 echoscip-shell system . . echo. $PWD1 | $CRYPTSETUP open --serialize-memory-hard-pbkdf --test-passphrase $LOOPDEV || failscip-shell shell shell-project 0.0.0 fail().
1748 testscip-shell system . . test. -f $LUKS2_LOCKING_DIR/$MEMORY_HARD_LOCK_FILE && failscip-shell shell shell-project 0.0.0 fail(). "The --serialize-memory-hard-pbkdf option did not remove the locking file (did not use the file)."
1749 fi
1750
1751 preparescip-shell shell shell-project 0.0.0 prepare(). "[53] Truncated keys." wipe
1752 echoscip-shell system . . echo. "$PWD1" | $CRYPTSETUP luksFormat -q --type luks2 $FAST_PBKDF_OPT --volume-key-file $KEY_TZERO -s256 $LOOPDEV || failscip-shell shell shell-project 0.0.0 fail().
1753 $CRYPTSETUP open -q --test-passphrase $LOOPDEV --volume-key-file $KEY_TZERO -s248 2>/dev/nullscip-shell filesystem . . `/dev/null`. && failscip-shell shell shell-project 0.0.0 fail().
1754 # cut the trailing zero byte
1755 truncatescip-shell system . . truncate. -c -s 31 $KEY_TZERO || failscip-shell shell shell-project 0.0.0 fail().
1756 echoscip-shell system . . echo. $PWD1 | $CRYPTSETUP luksAddKey -q $FAST_PBKDF_OPT --volume-key-file $KEY_TZERO $LOOPDEV 2>/dev/nullscip-shell filesystem . . `/dev/null`. && failscip-shell shell shell-project 0.0.0 fail().
1757 echoscip-shell system . . echo. $PWD3 | $CRYPTSETUP luksAddKey -q $FAST_PBKDF_OPT -S5 --unbound --volume-key-file $KEY_TZERO -s248 $LOOPDEV || failscip-shell shell shell-project 0.0.0 fail().
1758 echoscip-shell system . . echo. $PWD3 | $CRYPTSETUP open --test-passphrase -S5 $LOOPDEV || failscip-shell shell shell-project 0.0.0 fail().
1759 $CRYPTSETUP luksDump $LOOPDEV | grepscip-shell system . . grep. -q "5: luks2 (unbound)" || failscip-shell shell shell-project 0.0.0 fail().
1760
1761 # test (doubled) AES-256-XTS key with second half of the buffer with zero bytes
1762 echoscip-shell system . . echo. "$PWD1" | $CRYPTSETUP luksFormat -q --type luks2 $FAST_PBKDF_OPT --volume-key-file $KEY_HALF_ZERO -s512 $LOOPDEV || failscip-shell shell shell-project 0.0.0 fail().
1763 $CRYPTSETUP open -q --test-passphrase $LOOPDEV --volume-key-file $KEY_HALF_ZERO -s504 2>/dev/nullscip-shell filesystem . . `/dev/null`. && failscip-shell shell shell-project 0.0.0 fail().
1764 $CRYPTSETUP open -q --test-passphrase $LOOPDEV --volume-key-file $KEY_HALF_ZERO -s256 2>/dev/nullscip-shell filesystem . . `/dev/null`. && failscip-shell shell shell-project 0.0.0 fail().
1765
1766 # cut the trailing zero byte
1767 truncatescip-shell system . . truncate. -c -s 63 $KEY_HALF_ZERO || failscip-shell shell shell-project 0.0.0 fail().
1768 echoscip-shell system . . echo. $PWD2 | $CRYPTSETUP luksAddKey -q $FAST_PBKDF_OPT --volume-key-file $KEY_HALF_ZERO $LOOPDEV 2>/dev/nullscip-shell filesystem . . `/dev/null`. && failscip-shell shell shell-project 0.0.0 fail().
1769 echoscip-shell system . . echo. $PWD2 | $CRYPTSETUP luksAddKey -q $FAST_PBKDF_OPT -S5 --unbound --volume-key-file $KEY_HALF_ZERO -s504 $LOOPDEV || failscip-shell shell shell-project 0.0.0 fail().
1770 echoscip-shell system . . echo. $PWD2 | $CRYPTSETUP open --test-passphrase -S5 $LOOPDEV || failscip-shell shell shell-project 0.0.0 fail().
1771 $CRYPTSETUP luksDump $LOOPDEV | grepscip-shell system . . grep. -q "5: luks2 (unbound)" || failscip-shell shell shell-project 0.0.0 fail().
1772
1773 # truncate entire zeroed part
1774 truncatescip-shell system . . truncate. -c -s 32 $KEY_HALF_ZERO || failscip-shell shell shell-project 0.0.0 fail().
1775 echoscip-shell system . . echo. $PWD2 | $CRYPTSETUP luksAddKey -q $FAST_PBKDF_OPT --volume-key-file $KEY_HALF_ZERO $LOOPDEV 2>/dev/nullscip-shell filesystem . . `/dev/null`. && failscip-shell shell shell-project 0.0.0 fail().
1776 echoscip-shell system . . echo. $PWD3 | $CRYPTSETUP luksAddKey -q $FAST_PBKDF_OPT -S6 --unbound --volume-key-file $KEY_HALF_ZERO -s256 $LOOPDEV || failscip-shell shell shell-project 0.0.0 fail().
1777 $CRYPTSETUP luksDump $LOOPDEV | grepscip-shell system . . grep. -q "6: luks2 (unbound)" || failscip-shell shell shell-project 0.0.0 fail().
1778 echoscip-shell system . . echo. $PWD3 | $CRYPTSETUP open --test-passphrase -S6 $LOOPDEV || failscip-shell shell shell-project 0.0.0 fail().
1779 echoscip-shell system . . echo. $PWD3 | $CRYPTSETUP open -S6 $LOOPDEV $DEV_NAME 2>/dev/nullscip-shell filesystem . . `/dev/null`. && failscip-shell shell shell-project 0.0.0 fail().
1780
1781 if dm_crypt_keyring_supportscip-shell shell shell-project 0.0.0 dm_crypt_keyring_support(). && dm_crypt_keyring_new_kernelscip-shell shell shell-project 0.0.0 dm_crypt_keyring_new_kernel().; then
1782 preparescip-shell shell shell-project 0.0.0 prepare(). "[54] Intermediary keyring VK cleanup" wipe
1783 echoscip-shell system . . echo. $PWD1 | $CRYPTSETUP luksFormat $FAST_PBKDF_OPT --type luks2 $LOOPDEV || failscip-shell shell shell-project 0.0.0 fail().
1784 UUID=$($CRYPTSETUP luksUUID $LOOPDEV)
1785
1786 echoscip-shell system . . echo. $PWD1 | $CRYPTSETUP open $LOOPDEV $DEV_NAME || failscip-shell shell shell-project 0.0.0 fail().
1787 $CRYPTSETUP -q status $DEV_NAME | grepscip-shell system . . grep. "key location:" | grepscip-shell system . . grep. -q "keyring" || failscip-shell shell shell-project 0.0.0 fail().
1788
1789 # after cryptsetup open exits both the intermediary keyring and VK logon key must be gone
1790 wait_key_dissapearedscip-shell shell shell-project 0.0.0 wait_key_dissapeared(). "keyring.*cryptsetup-${UUID:0:8}" || failscip-shell shell shell-project 0.0.0 fail(). "Intermediary keyring persists in /proc/keys after process exit"
1791 wait_key_dissapearedscip-shell shell shell-project 0.0.0 wait_key_dissapeared(). "logon.*cryptsetup:${UUID}" || failscip-shell shell shell-project 0.0.0 fail(). "VK logon key persists in /proc/keys after process exit"
1792
1793 $CRYPTSETUP close $DEV_NAME || failscip-shell shell shell-project 0.0.0 fail().
1794 fi
1795
1796 remove_mappingscip-shell shell shell-project 0.0.0 remove_mapping().
1797 exit 0