Debian Codegraph @

tests/luks2-reencryption-test

raw symbols SCIP
1 #!/bin/bashscip-shell filesystem . . `/bin/bash`.
2
3 #PS4='$LINENO:'
4 [scip-shell system . . `[`. -z "$CRYPTSETUP_PATH" ] && CRYPTSETUP_PATH=".."
5 CRYPTSETUP=$CRYPTSETUP_PATH/cryptsetup
6
7 if [scip-shell system . . `[`. -n "$CRYPTSETUP_TESTS_RUN_IN_MESON" ]; then
8 CRYPTSETUP_VALGRIND=$CRYPTSETUP
9 else
10 CRYPTSETUP_VALGRIND=../.libs/cryptsetup
11 CRYPTSETUP_LIB_VALGRIND=../.libs
12 fi
13
14 FAST_PBKDF2="--pbkdf pbkdf2 --pbkdf-force-iterations 1000"
15 FAST_PBKDF_ARGON="--pbkdf-force-iterations 4 --pbkdf-memory 32 --pbkdf-parallel 1"
16 DEFAULT_ARGON="argon2i"
17
18 DEV=""
19 OVRDEV="123reenc321"
20 DEVBIG="reenc2134"
21 DEV_NAME=reenc9768
22 DEV_NAME2=reenc97682
23 IMG=reenc-data
24 IMG_HDR=$IMG.hdr
25 HEADER_LUKS2_PV=blkid-luks2-pv.img
26 IMG_FS=xfs_512_block_size.img
27 KEY1=key1
28 VKEY1=vkey1
29 VKEY2=vkey2
30 BACKUP_FILE=reenc_header_baseline.img
31 PWD1="93R4P4pIqAH8"
32 PWD2="1cND4319812f"
33 PWD3="1-9Qu5Ejfnqv"
34 PWD4="d54uVMKW-'7M"
35 PWD5="oDe{yCiZ_';_"
36 PWD6="T'E'Y_}<'9=q"
37 PWD7="UR%]T;x*w{3V"
38
39 DEV_LINK="reenc-test-link"
40 KEYRING="luks2_reencryption_test_kr"
41 KEY_TYPE="user"
42 KEY_NAME1="luks2-reencryption-test1"
43 KEY_NAME2="luks2-reencryption-test2"
44 KEY_NAME3="luks2-reencryption-test3"
45 KEY_NAME4="luks2-reencryption-test4"
46 KEY_NAME5="luks2-reencryption-test5"
47 KEY_NAME6="luks2-reencryption-test6"
48 KEY_NAME7="luks2-reencryption-key-desc1"
49 KEY_NAME_VK1="luks2-reencryption-test-vk1"
50 KEY_NAME_VK2="luks2-reencryption-test-vk2"
51 KEY_SPEC1="${KEYRING}::%${KEY_TYPE}:${KEY_NAME1}"
52 KEY_SPEC2="${KEYRING}::%${KEY_TYPE}:${KEY_NAME2}"
53 HAVE_KEYRING=0
54 JSON_MSIZE=16384
55 IMG_JSON=luks2-digest-1.json
56
57 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`.)
58
59 dm_crypt_featuresscip-shell shell shell-project 0.0.0 dm_crypt_features().()
60 {
61 VER_STR=$(dmsetup targets | grepscip-shell system . . grep. crypt | cutscip-shell system . . cut. -f2 -dv)
62 [scip-shell system . . `[`. -z "$VER_STR" ] && failscip-shell shell shell-project 0.0.0 fail(). "Failed to parse dm-crypt version."
63
64 VER_MAJ=$(echoscip-shell system . . echo. $VER_STR | cutscip-shell system . . cut. -f 1 -d.)
65 VER_MIN=$(echoscip-shell system . . echo. $VER_STR | cutscip-shell system . . cut. -f 2 -d.)
66 VER_PTC=$(echoscip-shell system . . echo. $VER_STR | cutscip-shell system . . cut. -f 3 -d.)
67
68 [scip-shell system . . `[`. $VER_MAJ -lt 1 ] && return
69 [scip-shell system . . `[`. $VER_MAJ -gt 1 ] && {
70 DM_PERF_CPU=1
71 DM_SECTOR_SIZE=1
72 return
73 }
74
75 [scip-shell system . . `[`. $VER_MIN -lt 14 ] && return
76 DM_PERF_CPU=1
77 if [scip-shell system . . `[`. $VER_MIN -ge 17 ]; then
78 DM_SECTOR_SIZE=1
79 fi
80 }
81
82 dm_delay_featuresscip-shell shell shell-project 0.0.0 dm_delay_features().()
83 {
84 local _ver_str=$(dmsetup targets | grepscip-shell system . . grep. delay | cutscip-shell system . . cut. -f2 -dv)
85 [scip-shell system . . `[`. -z "$_ver_str" ] && return 1
86 return 0
87 }
88
89 # $1 path to scsi debug bdev
90 scsi_debug_teardownscip-shell shell shell-project 0.0.0 scsi_debug_teardown().() {
91 local _tries=15;
92
93 while [scip-shell system . . `[`. -b "$1" -a $_tries -gt 0 ]; do
94 rmmod scsi_debug >/dev/nullscip-shell filesystem . . `/dev/null`. 2>&1
95 if [scip-shell system . . `[`. -b "$1" ]; then
96 sleepscip-shell system . . sleep. .1
97 _tries=$((_tries-1))
98 fi
99 done
100
101 testscip-shell system . . test. ! -b "$1" || rmmod scsi_debug >/dev/nullscip-shell filesystem . . `/dev/null`. 2>&1
102 }
103
104 remove_mappingscip-shell shell shell-project 0.0.0 remove_mapping().()
105 {
106 [scip-shell system . . `[`. -b /dev/mapper/$DEV_NAME ] && {
107 dmsetup resume $DEV_NAME
108 dmsetup remove --retry $DEV_NAME
109 }
110 [scip-shell system . . `[`. -b /dev/mapper/$DEV_NAME2 ] && {
111 dmsetup resume $DEV_NAME2
112 dmsetup remove --retry $DEV_NAME2
113 }
114 [scip-shell system . . `[`. -b /dev/mapper/$DEV_NAME-overlay ] && {
115 dmsetup resume $DEV_NAME-overlay
116 dmsetup remove --retry $DEV_NAME-overlay
117 }
118 [scip-shell system . . `[`. -b /dev/mapper/$DEV_NAME-hotzone-forward ] && {
119 dmsetup resume $DEV_NAME-hotzone-forward
120 dmsetup remove --retry $DEV_NAME-hotzone-forward
121 }
122 [scip-shell system . . `[`. -b /dev/mapper/$DEV_NAME-hotzone-backward ] && {
123 dmsetup resume $DEV_NAME-hotzone-backward
124 dmsetup remove --retry $DEV_NAME-hotzone-backward
125 }
126 [scip-shell system . . `[`. -b /dev/mapper/$OVRDEV ] && dmsetup remove --retry $OVRDEV 2>/dev/nullscip-shell filesystem . . `/dev/null`.
127 [scip-shell system . . `[`. -b /dev/mapper/$OVRDEV-err ] && dmsetup remove --retry $OVRDEV-err 2>/dev/nullscip-shell filesystem . . `/dev/null`.
128 [scip-shell system . . `[`. -n "$LOOPDEV" ] && losetupscip-shell system . . losetup. -d $LOOPDEV
129 unset LOOPDEV
130 rmscip-shell system . . rm. -f $IMG $IMG_JSON $IMG_HDR $KEY1 $VKEY1 $VKEY2 $BACKUP_FILE $DEVBIG $DEV_LINK $HEADER_LUKS2_PV $IMG_FS >/dev/nullscip-shell filesystem . . `/dev/null`. 2>&1
131 rmmod scsi_debug >/dev/nullscip-shell filesystem . . `/dev/null`. 2>&1
132 scsi_debug_teardownscip-shell shell shell-project 0.0.0 scsi_debug_teardown(). $DEV
133 }
134
135 cleanup_keyringscip-shell shell shell-project 0.0.0 cleanup_keyring().()
136 {
137 if [scip-shell system . . `[`. $HAVE_KEYRING -eq 1 ]; then
138 keyctl unlink %:$KEYRING "@s" >/dev/nullscip-shell filesystem . . `/dev/null`. 2>&1 || echoscip-shell system . . echo. "Failed to unlink test keyring."
139 fi
140 }
141
142 failscip-shell shell shell-project 0.0.0 fail().()
143 {
144 local frame=0
145 [scip-shell system . . `[`. -n "$1" ] && echoscip-shell system . . echo. "$1"
146 echoscip-shell system . . echo. "FAILED backtrace:"
147 while caller $frame; do ((frame++)); done
148 remove_mappingscip-shell shell shell-project 0.0.0 remove_mapping().
149 cleanup_keyringscip-shell shell shell-project 0.0.0 cleanup_keyring().
150 exit 2
151 }
152
153 _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"; }
154 trap _sigchld CHLD
155
156 skipscip-shell shell shell-project 0.0.0 skip().()
157 {
158 [scip-shell system . . `[`. -n "$1" ] && echoscip-shell system . . echo. "$1"
159 remove_mappingscip-shell shell shell-project 0.0.0 remove_mapping().
160 cleanup_keyringscip-shell shell shell-project 0.0.0 cleanup_keyring().
161 exit 77
162 }
163
164 fips_modescip-shell shell shell-project 0.0.0 fips_mode().()
165 {
166 [scip-shell system . . `[`. -n "$FIPS_MODE" ] && [scip-shell system . . `[`. "$FIPS_MODE" -gt 0 ]
167 }
168
169 add_scsi_devicescip-shell shell shell-project 0.0.0 add_scsi_device().() {
170 scsi_debug_teardownscip-shell shell shell-project 0.0.0 scsi_debug_teardown(). $DEV
171 if [scip-shell system . . `[`. -d /sys/module/scsi_debugscip-shell filesystem . . `/sys/module/scsi_debug`. ] ; then
172 echoscip-shell system . . echo. "Cannot use scsi_debug module (in use or compiled-in), test skipped."
173 exit 77
174 fi
175 modprobe scsi_debug $@ delay=0 >/dev/nullscip-shell filesystem . . `/dev/null`. 2>&1
176 if [scip-shell system . . `[`. $? -ne 0 ] ; then
177 echoscip-shell system . . echo. "This kernel seems to not support proper scsi_debug module, test skipped."
178 exit 77
179 fi
180
181 sleepscip-shell system . . sleep. 1
182 DEV="/dev/"$(grepscip-shell system . . grep. -l -e scsi_debug /sys/block/*/device/model | cutscip-shell system . . cut. -f4 -d /scip-shell filesystem . . `/`.)
183 [scip-shell system . . `[`. -b $DEV ] || failscip-shell shell shell-project 0.0.0 fail(). "Cannot find $DEV."
184 }
185
186 open_cryptscip-shell shell shell-project 0.0.0 open_crypt().() # $1 pwd, $2 hdr
187 {
188 if [scip-shell system . . `[`. -n "$2" ] ; then
189 echoscip-shell system . . echo. "$1" | $CRYPTSETUP luksOpen $DEV $DEV_NAME --header $2 || failscip-shell shell shell-project 0.0.0 fail().
190 elif [scip-shell system . . `[`. -n "$1" ] ; then
191 echoscip-shell system . . echo. "$1" | $CRYPTSETUP luksOpen $DEV $DEV_NAME || failscip-shell shell shell-project 0.0.0 fail().
192 else
193 $CRYPTSETUP luksOpen -d $KEY1 $DEV $DEV_NAME || failscip-shell shell shell-project 0.0.0 fail().
194 fi
195 }
196
197 wipe_dev_headscip-shell shell shell-project 0.0.0 wipe_dev_head().() # $1 dev, $2 length (in MiBs)
198 {
199 ddscip-shell system . . dd. if=/dev/zeroscip-shell filesystem . . `/dev/zero`. of=$1 bs=1M count=$2 conv=notrunc >/dev/nullscip-shell filesystem . . `/dev/null`. 2>&1
200 }
201
202 wipe_devscip-shell shell shell-project 0.0.0 wipe_dev().() # $1 dev
203 {
204 if [scip-shell system . . `[`. -b $1 ] ; then
205 blkdiscardscip-shell system . . blkdiscard. --zeroout $1 2>/dev/nullscip-shell filesystem . . `/dev/null`. || ddscip-shell system . . dd. if=/dev/zeroscip-shell filesystem . . `/dev/zero`. of=$1 bs=1M conv=notrunc >/dev/nullscip-shell filesystem . . `/dev/null`. 2>&1
206 if [scip-shell system . . `[`. $# -gt 2 ]; then
207 ddscip-shell system . . dd. if=/dev/urandomscip-shell filesystem . . `/dev/urandom`. of=$1 bs=1M seek=$2 conv=notrunc >/dev/nullscip-shell filesystem . . `/dev/null`. 2>&1
208 fi
209 else
210 local size=$(statscip-shell system . . stat. --printf="%s" $1)
211 truncatescip-shell system . . truncate. -s 0 $1 || failscip-shell shell shell-project 0.0.0 fail().
212 if [scip-shell system . . `[`. $# -gt 2 ]; then
213 local diff=$((size-$2*1024*1024))
214 echoscip-shell system . . echo. "size: $size, diff: $diff"
215 truncatescip-shell system . . truncate. -s $diff $1 || failscip-shell shell shell-project 0.0.0 fail().
216 # wipe_dev_head $1 $((diff/(1024*1024)))
217 ddscip-shell system . . dd. if=/dev/urandomscip-shell filesystem . . `/dev/urandom`. of=$1 bs=1M seek=$2 size=$((diff/(1024*1024))) conv=notrunc >/dev/nullscip-shell filesystem . . `/dev/null`. 2>&1
218 else
219 truncatescip-shell system . . truncate. -s $size $1 || failscip-shell shell shell-project 0.0.0 fail().
220 fi
221 fi
222 }
223
224 wipescip-shell shell shell-project 0.0.0 wipe().() # $1 pass, $2 hdr
225 {
226 open_cryptscip-shell shell shell-project 0.0.0 open_crypt(). $1 $2
227 wipe_devscip-shell shell shell-project 0.0.0 wipe_dev(). /dev/mapper/$DEV_NAME
228 udevadm settle >/dev/nullscip-shell filesystem . . `/dev/null`. 2>&1
229 $CRYPTSETUP luksClose $DEV_NAME || failscip-shell shell shell-project 0.0.0 fail().
230 }
231
232 preparescip-shell shell shell-project 0.0.0 prepare().() # $1 dev1_siz
233 {
234 remove_mappingscip-shell shell shell-project 0.0.0 remove_mapping().
235
236 if [scip-shell system . . `[`. ! -e $KEY1 ]; then
237 ddscip-shell system . . dd. if=/dev/urandomscip-shell filesystem . . `/dev/urandom`. of=$KEY1 count=1 bs=32 >/dev/nullscip-shell filesystem . . `/dev/null`. 2>&1
238 fi
239
240 if [scip-shell system . . `[`. ! -e $VKEY1 ]; then
241 echoscip-shell system . . echo. -n $'\x44\xc6\x74\x4f\x41\x4e\x50\xc0\x79\xc2\x2d\x5b\x5f\x68\x84\x17' >$VKEY1
242 echoscip-shell system . . echo. -n $'\x9c\x03\xba\xbe\x4d\x0f\x9a\x75\xb3\x90\x70\x32\x0a\xf8\xae\xc4'>>$VKEY1
243 fi
244
245 # if [ ! -e $VKEY2 ]; then
246 # echo -n $'\x41\xc6\x74\x4f\x41\x4e\x50\xc0\x79\xc2\x2d\x5b\x5f\x68\x84\x17' >$VKEY2
247 # echo -n $'\x9c\x03\xba\xbe\x4d\x0f\x9a\x75\xb3\x90\x70\x32\x0a\xf8\xae\xc5'>>$VKEY2
248 # fi
249
250 add_scsi_devicescip-shell shell shell-project 0.0.0 add_scsi_device(). $@
251 }
252
253 preparebigscip-shell shell shell-project 0.0.0 preparebig().() # $1 dev1_siz
254 {
255 remove_mappingscip-shell shell shell-project 0.0.0 remove_mapping().
256
257 if [scip-shell system . . `[`. ! -e $KEY1 ]; then
258 ddscip-shell system . . dd. if=/dev/urandomscip-shell filesystem . . `/dev/urandom`. of=$KEY1 count=1 bs=32 >/dev/nullscip-shell filesystem . . `/dev/null`. 2>&1
259 fi
260
261 truncatescip-shell system . . truncate. -s "$1"M $DEVBIG || failscip-shell shell shell-project 0.0.0 fail().
262 LOOPDEV=$(losetupscip-shell system . . losetup. -f)
263 losetupscip-shell system . . losetup. -f $DEVBIG || failscip-shell shell shell-project 0.0.0 fail().
264 DEV=$LOOPDEV
265 }
266
267 check_hash_devscip-shell shell shell-project 0.0.0 check_hash_dev().() # $1 dev, $2 hash
268 {
269 HASH=$(sha1sumscip-shell system . . sha1sum. $1 | cutscip-shell system . . cut. -d' ' -f 1)
270 [scip-shell system . . `[`. $HASH != "$2" ] && failscip-shell shell shell-project 0.0.0 fail(). "HASH differs (expected: $2) (result $HASH)"
271 }
272
273 check_hashscip-shell shell shell-project 0.0.0 check_hash().() # $1 pwd, $2 hash, $3 hdr
274 {
275 open_cryptscip-shell shell shell-project 0.0.0 open_crypt(). $1 $3
276 check_hash_devscip-shell shell shell-project 0.0.0 check_hash_dev(). /dev/mapper/$DEV_NAME $2
277 $CRYPTSETUP remove $DEV_NAME || failscip-shell shell shell-project 0.0.0 fail().
278 }
279
280 check_hash_dev_headscip-shell shell shell-project 0.0.0 check_hash_dev_head().() # $1 dev, $2 len, $3 hash
281 {
282 local hash=$(ddscip-shell system . . dd. if=$1 bs=512 count=$2 2>/dev/nullscip-shell filesystem . . `/dev/null`. | sha1sumscip-shell system . . sha1sum. | cutscip-shell system . . cut. -d' ' -f1)
283 [scip-shell system . . `[`. $hash != "$3" ] && failscip-shell shell shell-project 0.0.0 fail(). "HASH differs (expected: $3) (result $hash)"
284 }
285
286 check_hash_headscip-shell shell shell-project 0.0.0 check_hash_head().() # $1 pwd, $2 len, $3 hash, $4 hdr
287 {
288 open_cryptscip-shell shell shell-project 0.0.0 open_crypt(). $1 $4
289 check_hash_dev_headscip-shell shell shell-project 0.0.0 check_hash_dev_head(). /dev/mapper/$DEV_NAME $2 $3
290 $CRYPTSETUP remove $DEV_NAME || failscip-shell shell shell-project 0.0.0 fail().
291 }
292
293 resize_filescip-shell shell shell-project 0.0.0 resize_file().() # $1 dev, $2 shrink bytes
294 {
295 local size=$(statscip-shell system . . stat. --printf="%s" $1)
296 truncatescip-shell system . . truncate. -s $(($size + $2)) $1 || failscip-shell shell shell-project 0.0.0 fail().
297 losetupscip-shell system . . losetup. -c $LOOPDEV
298 }
299
300 error_ioscip-shell shell shell-project 0.0.0 error_io().() { # $1 dmdev, $2 data dev, $3 offset, $4 size
301 local _dev_size=$(blockdevscip-shell system . . blockdev. --getsz /dev/mapper/$1)
302 local _offset=$(($3+$4))
303 local _size=$((_dev_size-_offset))
304 local _table=
305 dmsetup create $1-err --table "0 $_dev_size error" || failscip-shell shell shell-project 0.0.0 fail().
306
307 if [scip-shell system . . `[`. $3 -ne 0 ]; then
308 _table="0 $3 linear $2 0\n"
309 fi
310
311 _table=$_table"$3 $4 error"
312
313 if [scip-shell system . . `[`. $_size -ne 0 ]; then
314 _table="$_table\n$_offset $_size linear $2 $_offset"
315 fi
316
317 echoscip-shell system . . echo. -e "$_table" | dmsetup load $1 || failscip-shell shell shell-project 0.0.0 fail().
318 dmsetup resume $1 || failscip-shell shell shell-project 0.0.0 fail().
319 blockdevscip-shell system . . blockdev. --setra 0 /dev/mapper/$1
320 }
321
322 error_writesscip-shell shell shell-project 0.0.0 error_writes().() { # $1 dmdev, $2 data dev, $3 offset, $4 size
323 local _dev_size=$(blockdevscip-shell system . . blockdev. --getsz /dev/mapper/$1)
324 local _offset=$(($3+$4))
325 local _size=$((_dev_size-_offset))
326 local _err=$1-err
327 local _table=
328 dmsetup create $_err --table "0 $_dev_size error" || failscip-shell shell shell-project 0.0.0 fail().
329
330 if [scip-shell system . . `[`. $3 -ne 0 ]; then
331 _table="0 $3 linear $2 0\n"
332 fi
333
334 _table=$_table"$3 $4 delay $2 $3 0 /dev/mapper/$_err $3 0"
335
336 if [scip-shell system . . `[`. $_size -ne 0 ]; then
337 _table="$_table\n$_offset $_size linear $2 $_offset"
338 fi
339
340 echoscip-shell system . . echo. -e "$_table" | dmsetup load $1 || failscip-shell shell shell-project 0.0.0 fail().
341 dmsetup resume $1 || failscip-shell shell shell-project 0.0.0 fail().
342 blockdevscip-shell system . . blockdev. --setra 0 /dev/mapper/$1
343 blockdevscip-shell system . . blockdev. --setra 0 /dev/mapper/$_err
344 }
345
346 fix_writesscip-shell shell shell-project 0.0.0 fix_writes().() { # $1 dmdev, $2 data dev
347 local _dev_size=$(blockdevscip-shell system . . blockdev. --getsz /dev/mapper/$1)
348 dmsetup load $1 --table "0 $_dev_size linear $2 0" || failscip-shell shell shell-project 0.0.0 fail().
349 dmsetup resume $1 || failscip-shell shell shell-project 0.0.0 fail().
350 dmsetup remove --retry $1-err 2>/dev/nullscip-shell filesystem . . `/dev/null`. || failscip-shell shell shell-project 0.0.0 fail().
351 }
352
353 prepare_linear_devscip-shell shell shell-project 0.0.0 prepare_linear_dev().() {
354 local _sizemb=$1
355 shift
356
357 if [scip-shell system . . `[`. "$_sizemb" -gt 32 ]; then
358 preparebigscip-shell shell shell-project 0.0.0 preparebig(). $_sizemb
359 else
360 preparescip-shell shell shell-project 0.0.0 prepare(). dev_size_mb=$_sizemb $@
361 fi
362
363 dmsetup create $OVRDEV --table "0 $((_sizemb*1024*2)) linear $DEV 0" || failscip-shell shell shell-project 0.0.0 fail().
364
365 OLD_DEV=$DEV
366 DEV=/dev/mapper/$OVRDEV
367 }
368
369 get_error_offsetsscip-shell shell shell-project 0.0.0 get_error_offsets().() # $1 devsize, $2 minimal offset, $3 sector_size [512 if omitted], $4 max offset
370 {
371 local _devsize=$(($1*1024*2))
372 local _sector_size=${3:-512}
373 local _max_offset=${4:-$_devsize}
374 _sector_size=$((_sector_size/512))
375
376 # 8 sectors minimal size (4096)
377 ERRLENGTH=$((($RANDOM%56)+8))
378 ERRLENGTH=$(($ERRLENGTH-($ERRLENGTH%$_sector_size)))
379
380 ERROFFSET=$(($2+((2*$RANDOM)%($_max_offset-$2-$ERRLENGTH))))
381 ERROFFSET=$(($ERROFFSET-($ERROFFSET%$_sector_size)))
382 }
383
384 reencrypt_recoverscip-shell shell shell-project 0.0.0 reencrypt_recover().() { # $1 sector size, $2 resilience, $3 digest, [$4 header]
385 echoscip-shell system . . echo. -n "resilience mode: $2 ..."
386 local _hdr=""
387 testscip-shell system . . test. -z "$4" || _hdr="--header $4"
388
389 error_writesscip-shell shell shell-project 0.0.0 error_writes(). $OVRDEV $OLD_DEV $ERROFFSET $ERRLENGTH
390 echoscip-shell system . . echo. $PWD1 | $CRYPTSETUP reencrypt $DEV $_hdr --hotzone-size 1M --resilience $2 --sector-size $1 --force-offline-reencrypt -q $FAST_PBKDF_ARGON >/dev/nullscip-shell filesystem . . `/dev/null`. 2>&1 && failscip-shell shell shell-project 0.0.0 fail().
391 fix_writesscip-shell shell shell-project 0.0.0 fix_writes(). $OVRDEV $OLD_DEV
392
393 echoscip-shell system . . echo. $PWD1 | $CRYPTSETUP -q repair $DEV $_hdr || failscip-shell shell shell-project 0.0.0 fail().
394
395 check_hashscip-shell shell shell-project 0.0.0 check_hash(). $PWD1 $3 $4
396
397 echoscip-shell system . . echo. $PWD1 | $CRYPTSETUP reencrypt $DEV $_hdr --resilience $2 --sector-size $1 -q $FAST_PBKDF_ARGON || failscip-shell shell shell-project 0.0.0 fail().
398 check_hashscip-shell shell shell-project 0.0.0 check_hash(). $PWD1 $3 $4
399
400 echoscip-shell system . . echo. "[OK]"
401 }
402
403 reencrypt_recover_onlinescip-shell shell shell-project 0.0.0 reencrypt_recover_online().() { # $1 sector size, $2 resilience, $3 digest, [$4 header]
404 echoscip-shell system . . echo. -n "resilience mode: $2 ..."
405 local _hdr=""
406 testscip-shell system . . test. -z "$4" || _hdr="--header $4"
407
408 echoscip-shell system . . echo. $PWD1 | $CRYPTSETUP open $DEV $_hdr $DEV_NAME || failscip-shell shell shell-project 0.0.0 fail().
409
410 error_writesscip-shell shell shell-project 0.0.0 error_writes(). $OVRDEV $OLD_DEV $ERROFFSET $ERRLENGTH
411 echoscip-shell system . . echo. $PWD1 | $CRYPTSETUP reencrypt --active-name $DEV_NAME $_hdr --hotzone-size 1M --resilience $2 --sector-size $1 -q $FAST_PBKDF_ARGON >/dev/nullscip-shell filesystem . . `/dev/null`. 2>&1 && failscip-shell shell shell-project 0.0.0 fail().
412 $CRYPTSETUP status $DEV_NAME $_hdr | grepscip-shell system . . grep. -q "reencryption: in-progress" || failscip-shell shell shell-project 0.0.0 fail().
413 $CRYPTSETUP close $DEV_NAME || failscip-shell shell shell-project 0.0.0 fail().
414 fix_writesscip-shell shell shell-project 0.0.0 fix_writes(). $OVRDEV $OLD_DEV
415
416 # recovery during activation
417 echoscip-shell system . . echo. $PWD1 | $CRYPTSETUP open $DEV $_hdr $DEV_NAME || failscip-shell shell shell-project 0.0.0 fail().
418 check_hash_devscip-shell shell shell-project 0.0.0 check_hash_dev(). /dev/mapper/$DEV_NAME $3
419
420 $CRYPTSETUP luksDump ${4:-$DEV} | grepscip-shell system . . grep. -q "online-reencrypt"
421 if [scip-shell system . . `[`. $? -eq 0 ]; then
422 $CRYPTSETUP status $DEV_NAME $_hdr | grepscip-shell system . . grep. -q "reencryption: in-progress" || failscip-shell shell shell-project 0.0.0 fail().
423 echoscip-shell system . . echo. $PWD1 | $CRYPTSETUP reencrypt --active-name $DEV_NAME $_hdr --resilience $2 --resume-only -q || failscip-shell shell shell-project 0.0.0 fail().
424 check_hash_devscip-shell shell shell-project 0.0.0 check_hash_dev(). /dev/mapper/$DEV_NAME $3
425 fi
426
427 $CRYPTSETUP close $DEV_NAME || failscip-shell shell shell-project 0.0.0 fail().
428 echoscip-shell system . . echo. "[OK]"
429 }
430
431 reencrypt_recover_online_vkscip-shell shell shell-project 0.0.0 reencrypt_recover_online_vk().() { # $1 sector size, $2 resilience, $3 digest, [$4 header]
432 echoscip-shell system . . echo. -n "resilience mode: $2 ..."
433 local _hdr=""
434 testscip-shell system . . test. -z "$4" || _hdr="--header $4"
435
436 echoscip-shell system . . echo. $PWD1 | $CRYPTSETUP open $DEV $_hdr $DEV_NAME || failscip-shell shell shell-project 0.0.0 fail().
437 echoscip-shell system . . echo. $PWD1 | $CRYPTSETUP reencrypt --active-name $DEV_NAME $_hdr --hotzone-size 1M --resilience $2 --sector-size $1 -q $FAST_PBKDF_ARGON --init-only >/dev/nullscip-shell filesystem . . `/dev/null`. 2>&1 || failscip-shell shell shell-project 0.0.0 fail().
438 $CRYPTSETUP close $DEV_NAME || failscip-shell shell shell-project 0.0.0 fail().
439
440 echoscip-shell system . . echo. $PWD1 | $CRYPTSETUP open --link-vk-to-keyring $KEY_SPEC1 --link-vk-to-keyring $KEY_SPEC2 $DEV $_hdr $DEV_NAME || failscip-shell shell shell-project 0.0.0 fail().
441
442 error_writesscip-shell shell shell-project 0.0.0 error_writes(). $OVRDEV $OLD_DEV $ERROFFSET $ERRLENGTH
443 echoscip-shell system . . echo. $PWD1 | $CRYPTSETUP reencrypt --active-name $DEV_NAME $_hdr --hotzone-size 1M --resilience $2 --sector-size $1 -q $FAST_PBKDF_ARGON >/dev/nullscip-shell filesystem . . `/dev/null`. 2>&1 && failscip-shell shell shell-project 0.0.0 fail().
444 $CRYPTSETUP status $DEV_NAME $_hdr | grepscip-shell system . . grep. -q "reencryption: in-progress" || failscip-shell shell shell-project 0.0.0 fail().
445 $CRYPTSETUP close $DEV_NAME || failscip-shell shell shell-project 0.0.0 fail().
446 fix_writesscip-shell shell shell-project 0.0.0 fix_writes(). $OVRDEV $OLD_DEV
447
448 # recovery during activation
449 $CRYPTSETUP open --volume-key-keyring $KEY_NAME1 --volume-key-keyring $KEY_NAME2 $DEV $_hdr $DEV_NAME || failscip-shell shell shell-project 0.0.0 fail().
450 check_hash_devscip-shell shell shell-project 0.0.0 check_hash_dev(). /dev/mapper/$DEV_NAME $3
451
452 $CRYPTSETUP luksDump ${4:-$DEV} | grepscip-shell system . . grep. -q "online-reencrypt"
453 if [scip-shell system . . `[`. $? -eq 0 ]; then
454 $CRYPTSETUP status $DEV_NAME $_hdr | grepscip-shell system . . grep. -q "reencryption: in-progress" || failscip-shell shell shell-project 0.0.0 fail().
455 echoscip-shell system . . echo. $PWD1 | $CRYPTSETUP reencrypt --active-name $DEV_NAME $_hdr --resilience $2 --resume-only -q || failscip-shell shell shell-project 0.0.0 fail().
456 check_hash_devscip-shell shell shell-project 0.0.0 check_hash_dev(). /dev/mapper/$DEV_NAME $3
457 fi
458
459 $CRYPTSETUP close $DEV_NAME || failscip-shell shell shell-project 0.0.0 fail().
460 echoscip-shell system . . echo. "[OK]"
461 }
462
463 encrypt_recoverscip-shell shell shell-project 0.0.0 encrypt_recover().() { # $1 sector size, $2 reduce size, $3 digest, $4 device size in sectors, $5 origin digest
464 wipe_devscip-shell shell shell-project 0.0.0 wipe_dev(). $DEV
465 check_hash_devscip-shell shell shell-project 0.0.0 check_hash_dev(). $DEV $5
466
467 echoscip-shell system . . echo. -n "resilience mode: datashift ..."
468
469 echoscip-shell system . . echo. $PWD1 | $CRYPTSETUP reencrypt $DEV --encrypt --reduce-device-size $2 --sector-size $1 -q $FAST_PBKDF_ARGON --init-only >/dev/nullscip-shell filesystem . . `/dev/null`. 2>&1 || failscip-shell shell shell-project 0.0.0 fail().
470
471 error_writesscip-shell shell shell-project 0.0.0 error_writes(). $OVRDEV $OLD_DEV $ERROFFSET $ERRLENGTH
472 echoscip-shell system . . echo. $PWD1 | $CRYPTSETUP reencrypt $DEV -q >/dev/nullscip-shell filesystem . . `/dev/null`. 2>&1 && failscip-shell shell shell-project 0.0.0 fail().
473 fix_writesscip-shell shell shell-project 0.0.0 fix_writes(). $OVRDEV $OLD_DEV
474
475 echoscip-shell system . . echo. $PWD1 | $CRYPTSETUP -q repair $DEV || failscip-shell shell shell-project 0.0.0 fail().
476
477 $CRYPTSETUP luksDump $DEV | grepscip-shell system . . grep. -q "online-reencrypt"
478 if [scip-shell system . . `[`. $? -eq 0 ]; then
479 check_hashscip-shell shell shell-project 0.0.0 check_hash(). $PWD1 $3
480 echoscip-shell system . . echo. $PWD1 | $CRYPTSETUP reencrypt $DEV --sector-size $1 -q $FAST_PBKDF_ARGON || failscip-shell shell shell-project 0.0.0 fail().
481 fi
482
483 check_hash_headscip-shell shell shell-project 0.0.0 check_hash_head(). $PWD1 $4 $3
484
485 echoscip-shell system . . echo. "[OK]"
486 }
487
488 encrypt_recover_onlinescip-shell shell shell-project 0.0.0 encrypt_recover_online().() { # $1 sector size, $2 reduce size, $3 digest, $4 device size in sectors, $5 origin digest
489 wipe_devscip-shell shell shell-project 0.0.0 wipe_dev(). $DEV
490 check_hash_devscip-shell shell shell-project 0.0.0 check_hash_dev(). $DEV $5
491
492 echoscip-shell system . . echo. -n "resilience mode: datashift ..."
493
494 echoscip-shell system . . echo. $PWD1 | $CRYPTSETUP reencrypt $DEV --encrypt --reduce-device-size $2 --sector-size $1 -q $FAST_PBKDF_ARGON --init-only > /dev/nullscip-shell filesystem . . `/dev/null`. || failscip-shell shell shell-project 0.0.0 fail().
495 echoscip-shell system . . echo. $PWD1 | $CRYPTSETUP open $DEV $DEV_NAME || failscip-shell shell shell-project 0.0.0 fail().
496
497 error_writesscip-shell shell shell-project 0.0.0 error_writes(). $OVRDEV $OLD_DEV $ERROFFSET $ERRLENGTH
498 echoscip-shell system . . echo. $PWD1 | $CRYPTSETUP reencrypt $DEV -q >/dev/nullscip-shell filesystem . . `/dev/null`. 2>&1 && failscip-shell shell shell-project 0.0.0 fail().
499 $CRYPTSETUP status $DEV_NAME | grepscip-shell system . . grep. -q "reencryption: in-progress" || failscip-shell shell shell-project 0.0.0 fail().
500 $CRYPTSETUP close $DEV_NAME || failscip-shell shell shell-project 0.0.0 fail().
501 fix_writesscip-shell shell shell-project 0.0.0 fix_writes(). $OVRDEV $OLD_DEV
502
503 # recovery in activation
504 echoscip-shell system . . echo. $PWD1 | $CRYPTSETUP open $DEV $DEV_NAME || failscip-shell shell shell-project 0.0.0 fail().
505
506 $CRYPTSETUP luksDump $DEV | grepscip-shell system . . grep. -q "online-reencrypt"
507 if [scip-shell system . . `[`. $? -eq 0 ]; then
508 $CRYPTSETUP status $DEV_NAME | grepscip-shell system . . grep. -q "reencryption: in-progress" || failscip-shell shell shell-project 0.0.0 fail().
509 check_hash_devscip-shell shell shell-project 0.0.0 check_hash_dev(). /dev/mapper/$DEV_NAME $3
510 echoscip-shell system . . echo. $PWD1 | $CRYPTSETUP reencrypt --resume-only --active-name $DEV_NAME -q || failscip-shell shell shell-project 0.0.0 fail().
511 fi
512
513 $CRYPTSETUP close $DEV_NAME || failscip-shell shell shell-project 0.0.0 fail().
514 check_hash_headscip-shell shell shell-project 0.0.0 check_hash_head(). $PWD1 $4 $3
515
516 echoscip-shell system . . echo. "[OK]"
517 }
518
519 encrypt_recover_detachedscip-shell shell shell-project 0.0.0 encrypt_recover_detached().() { # $1 sector size, $2 resilience, $3 digest, $4 hdr
520 wipe_devscip-shell shell shell-project 0.0.0 wipe_dev(). $DEV
521 check_hash_devscip-shell shell shell-project 0.0.0 check_hash_dev(). $DEV $3
522
523 echoscip-shell system . . echo. -n "resilience mode: $2 ..."
524
525 error_writesscip-shell shell shell-project 0.0.0 error_writes(). $OVRDEV $OLD_DEV $ERROFFSET $ERRLENGTH
526 echoscip-shell system . . echo. $PWD1 | $CRYPTSETUP reencrypt $DEV --encrypt --hotzone-size 1M --header $4 --resilience $2 --sector-size $1 -q $FAST_PBKDF_ARGON 2>/dev/nullscip-shell filesystem . . `/dev/null`. && failscip-shell shell shell-project 0.0.0 fail().
527 fix_writesscip-shell shell shell-project 0.0.0 fix_writes(). $OVRDEV $OLD_DEV
528
529 echoscip-shell system . . echo. $PWD1 | $CRYPTSETUP repair $DEV --header $4 || failscip-shell shell shell-project 0.0.0 fail().
530
531 check_hashscip-shell shell shell-project 0.0.0 check_hash(). $PWD1 $3 $4
532
533 echoscip-shell system . . echo. $PWD1 | $CRYPTSETUP reencrypt $DEV --header $4 --resilience $2 --sector-size $1 -q $FAST_PBKDF_ARGON || failscip-shell shell shell-project 0.0.0 fail().
534 check_hashscip-shell shell shell-project 0.0.0 check_hash(). $PWD1 $3 $4
535
536 [scip-shell system . . `[`. -f $4 ] && rmscip-shell system . . rm. -f $4
537
538 echoscip-shell system . . echo. "[OK]"
539 }
540
541 encrypt_recover_detached_onlinescip-shell shell shell-project 0.0.0 encrypt_recover_detached_online().() { # $1 sector size, $2 resilience, $3 digest, $4 hdr
542 wipe_devscip-shell shell shell-project 0.0.0 wipe_dev(). $DEV
543 check_hash_devscip-shell shell shell-project 0.0.0 check_hash_dev(). $DEV $3
544
545 echoscip-shell system . . echo. -n "resilience mode: $2 ..."
546
547 echoscip-shell system . . echo. $PWD1 | $CRYPTSETUP reencrypt $DEV --encrypt --hotzone-size 1M --header $4 --resilience $2 --sector-size $1 -q $FAST_PBKDF_ARGON --init-only || failscip-shell shell shell-project 0.0.0 fail().
548 echoscip-shell system . . echo. $PWD1 | $CRYPTSETUP open $DEV --header $4 $DEV_NAME || failscip-shell shell shell-project 0.0.0 fail().
549
550 error_writesscip-shell shell shell-project 0.0.0 error_writes(). $OVRDEV $OLD_DEV $ERROFFSET $ERRLENGTH
551 echoscip-shell system . . echo. $PWD1 | $CRYPTSETUP reencrypt -q $DEV --header $4 --hotzone-size 1M 2>/dev/nullscip-shell filesystem . . `/dev/null`. && failscip-shell shell shell-project 0.0.0 fail().
552 $CRYPTSETUP status $DEV_NAME --header $4 | grepscip-shell system . . grep. -q "reencryption: in-progress" || failscip-shell shell shell-project 0.0.0 fail().
553 $CRYPTSETUP close $DEV_NAME || failscip-shell shell shell-project 0.0.0 fail().
554 fix_writesscip-shell shell shell-project 0.0.0 fix_writes(). $OVRDEV $OLD_DEV
555
556 echoscip-shell system . . echo. $PWD1 | $CRYPTSETUP open $DEV --header $4 $DEV_NAME || failscip-shell shell shell-project 0.0.0 fail().
557 check_hash_devscip-shell shell shell-project 0.0.0 check_hash_dev(). /dev/mapper/$DEV_NAME $3
558
559 $CRYPTSETUP luksDump $4 | grepscip-shell system . . grep. -q "online-reencrypt"
560 if [scip-shell system . . `[`. $? -eq 0 ]; then
561 $CRYPTSETUP status $DEV_NAME --header $4 | grepscip-shell system . . grep. -q "reencryption: in-progress" || failscip-shell shell shell-project 0.0.0 fail().
562 echoscip-shell system . . echo. $PWD1 | $CRYPTSETUP reencrypt --active-name $DEV_NAME --resume-only --header $4 --resilience $2 -q || failscip-shell shell shell-project 0.0.0 fail().
563 check_hash_devscip-shell shell shell-project 0.0.0 check_hash_dev(). /dev/mapper/$DEV_NAME $3
564 fi
565
566 $CRYPTSETUP close $DEV_NAME || failscip-shell shell shell-project 0.0.0 fail().
567
568 [scip-shell system . . `[`. -f $4 ] && rmscip-shell system . . rm. -f $4
569
570 echoscip-shell system . . echo. "[OK]"
571 }
572
573 decrypt_recover_detachedscip-shell shell shell-project 0.0.0 decrypt_recover_detached().() { # $1 sector size, $2 resilience, $3 digest, $4 hdr
574 echoscip-shell system . . echo. $PWD1 | $CRYPTSETUP -q luksFormat --type luks2 --sector-size $1 --header $4 $FAST_PBKDF_ARGON $DEV || failscip-shell shell shell-project 0.0.0 fail().
575 wipescip-shell shell shell-project 0.0.0 wipe(). $PWD1 $4
576 check_hashscip-shell shell shell-project 0.0.0 check_hash(). $PWD1 $3 $4
577
578 echoscip-shell system . . echo. -n "resilience mode: $2 ..."
579
580 error_writesscip-shell shell shell-project 0.0.0 error_writes(). $OVRDEV $OLD_DEV $ERROFFSET $ERRLENGTH
581 echoscip-shell system . . echo. $PWD1 | $CRYPTSETUP reencrypt $DEV --decrypt --hotzone-size 1M --header $4 --resilience $2 -q 2>/dev/nullscip-shell filesystem . . `/dev/null`. && failscip-shell shell shell-project 0.0.0 fail().
582 fix_writesscip-shell shell shell-project 0.0.0 fix_writes(). $OVRDEV $OLD_DEV
583
584 echoscip-shell system . . echo. $PWD1 | $CRYPTSETUP repair $DEV --header $4 || failscip-shell shell shell-project 0.0.0 fail().
585
586 $CRYPTSETUP luksDump $4 | grepscip-shell system . . grep. -q "online-reencrypt"
587 if [scip-shell system . . `[`. $? -eq 0 ]; then
588 check_hashscip-shell shell shell-project 0.0.0 check_hash(). $PWD1 $3 $4
589 echoscip-shell system . . echo. $PWD1 | $CRYPTSETUP reencrypt $DEV --resume-only --header $4 --resilience $2 -q || failscip-shell shell shell-project 0.0.0 fail().
590 fi
591
592 check_hash_devscip-shell shell shell-project 0.0.0 check_hash_dev(). $DEV $3
593
594 [scip-shell system . . `[`. -f $4 ] && rmscip-shell system . . rm. -f $4
595
596 echoscip-shell system . . echo. "[OK]"
597 }
598
599 decrypt_recover_detached_onlinescip-shell shell shell-project 0.0.0 decrypt_recover_detached_online().() { # $1 sector size, $2 resilience, $3 digest, $4 hdr
600 echoscip-shell system . . echo. $PWD1 | $CRYPTSETUP -q luksFormat --type luks2 --sector-size $1 --header $4 $FAST_PBKDF_ARGON $DEV || failscip-shell shell shell-project 0.0.0 fail().
601 echoscip-shell system . . echo. $PWD1 | $CRYPTSETUP open $DEV --header $4 $DEV_NAME || failscip-shell shell shell-project 0.0.0 fail().
602 wipe_devscip-shell shell shell-project 0.0.0 wipe_dev(). /dev/mapper/$DEV_NAME
603 check_hash_devscip-shell shell shell-project 0.0.0 check_hash_dev(). /dev/mapper/$DEV_NAME $3
604
605 echoscip-shell system . . echo. -n "resilience mode: $2 ..."
606
607 error_writesscip-shell shell shell-project 0.0.0 error_writes(). $OVRDEV $OLD_DEV $ERROFFSET $ERRLENGTH
608 echoscip-shell system . . echo. $PWD1 | $CRYPTSETUP reencrypt $DEV --decrypt --hotzone-size 1M --header $4 --resilience $2 -q 2>/dev/nullscip-shell filesystem . . `/dev/null`. && failscip-shell shell shell-project 0.0.0 fail().
609 $CRYPTSETUP status $DEV_NAME --header $4 | grepscip-shell system . . grep. -q "reencryption: in-progress" || failscip-shell shell shell-project 0.0.0 fail().
610 $CRYPTSETUP close $DEV_NAME || failscip-shell shell shell-project 0.0.0 fail().
611 fix_writesscip-shell shell shell-project 0.0.0 fix_writes(). $OVRDEV $OLD_DEV
612
613 # recovery during activation
614 echoscip-shell system . . echo. $PWD1 | $CRYPTSETUP open $DEV --header $4 $DEV_NAME || failscip-shell shell shell-project 0.0.0 fail().
615
616 $CRYPTSETUP luksDump $4 | grepscip-shell system . . grep. -q "online-reencrypt"
617 if [scip-shell system . . `[`. $? -eq 0 ]; then
618 $CRYPTSETUP status $DEV_NAME --header $4 | grepscip-shell system . . grep. -q "reencryption: in-progress" || failscip-shell shell shell-project 0.0.0 fail().
619 check_hash_devscip-shell shell shell-project 0.0.0 check_hash_dev(). /dev/mapper/$DEV_NAME $3
620 echoscip-shell system . . echo. $PWD1 | $CRYPTSETUP reencrypt $DEV --header $4 --resilience $2 -q || failscip-shell shell shell-project 0.0.0 fail().
621 fi
622
623 $CRYPTSETUP status $DEV_NAME >/dev/nullscip-shell filesystem . . `/dev/null`. 2>&1 && failscip-shell shell shell-project 0.0.0 fail().
624 check_hash_devscip-shell shell shell-project 0.0.0 check_hash_dev(). $DEV $3
625
626 [scip-shell system . . `[`. -f $4 ] && rmscip-shell system . . rm. -f $4
627
628 echoscip-shell system . . echo. "[OK]"
629 }
630
631 decrypt_recoverscip-shell shell shell-project 0.0.0 decrypt_recover().() { # $1 hash, $2 hdr, $3 dev size, $4 resilience, $5 hotzone size
632 local _res=""
633 local _maxhz=""
634 testscip-shell system . . test. -z "$4" || _res="--resilience $4"
635 testscip-shell system . . test. -z "$5" || _maxhz="--hotzone-size $5"
636 echoscip-shell system . . echo. -n "[${4:-default}]"
637
638 echoscip-shell system . . echo. $PWD1 | $CRYPTSETUP reencrypt $DEV --decrypt --header $2 --init-only $_maxhz >/dev/nullscip-shell filesystem . . `/dev/null`. || failscip-shell shell shell-project 0.0.0 fail().
639
640 error_writesscip-shell shell shell-project 0.0.0 error_writes(). $OVRDEV $OLD_DEV $ERROFFSET $ERRLENGTH
641 echoscip-shell system . . echo. $PWD1 | $CRYPTSETUP reencrypt $DEV --header $2 -q $_res >/dev/nullscip-shell filesystem . . `/dev/null`. 2>&1 && failscip-shell shell shell-project 0.0.0 fail().
642 fix_writesscip-shell shell shell-project 0.0.0 fix_writes(). $OVRDEV $OLD_DEV
643
644 echoscip-shell system . . echo. $PWD1 | $CRYPTSETUP -q repair $DEV --header $2 || failscip-shell shell shell-project 0.0.0 fail().
645
646 $CRYPTSETUP luksDump $2 | grepscip-shell system . . grep. -q "online-reencrypt"
647 if [scip-shell system . . `[`. $? -eq 0 ]; then
648 check_hashscip-shell shell shell-project 0.0.0 check_hash(). $PWD1 $1 $2
649 echoscip-shell system . . echo. $PWD1 | $CRYPTSETUP reencrypt $DEV --header $2 $_res -q $FAST_PBKDF_ARGON || failscip-shell shell shell-project 0.0.0 fail().
650 fi
651
652 check_hash_dev_headscip-shell shell shell-project 0.0.0 check_hash_dev_head(). $DEV $3 $1
653
654 [scip-shell system . . `[`. -f $2 ] && rmscip-shell system . . rm. -f $2
655
656 echoscip-shell system . . echo. -n "[OK]"
657 }
658
659 decrypt_recover_onlinescip-shell shell shell-project 0.0.0 decrypt_recover_online().() { # $1 hash, $2 hdr, $3 dev size
660 local _res=""
661 local _maxhz=""
662 testscip-shell system . . test. -z "$4" || _res="--resilience $4"
663 testscip-shell system . . test. -z "$5" || _maxhz="--hotzone-size $5"
664 echoscip-shell system . . echo. -n "[${4:-default}]"
665
666 echoscip-shell system . . echo. $PWD1 | $CRYPTSETUP reencrypt $DEV --decrypt --header $2 $_maxhz --init-only >/dev/nullscip-shell filesystem . . `/dev/null`. 2>&1 || failscip-shell shell shell-project 0.0.0 fail().
667
668 error_writesscip-shell shell shell-project 0.0.0 error_writes(). $OVRDEV $OLD_DEV $ERROFFSET $ERRLENGTH
669 echoscip-shell system . . echo. $PWD1 | $CRYPTSETUP reencrypt $DEV --header $2 -q $_res >/dev/nullscip-shell filesystem . . `/dev/null`. 2>&1 && failscip-shell shell shell-project 0.0.0 fail().
670 $CRYPTSETUP status $DEV_NAME --header $2 | grepscip-shell system . . grep. -q "reencryption: in-progress" || failscip-shell shell shell-project 0.0.0 fail().
671 $CRYPTSETUP close $DEV_NAME || failscip-shell shell shell-project 0.0.0 fail().
672 fix_writesscip-shell shell shell-project 0.0.0 fix_writes(). $OVRDEV $OLD_DEV
673
674 # recovery during activation
675 echoscip-shell system . . echo. $PWD1 | $CRYPTSETUP open $DEV --header $2 $DEV_NAME || failscip-shell shell shell-project 0.0.0 fail().
676
677 check_hash_devscip-shell shell shell-project 0.0.0 check_hash_dev(). /dev/mapper/$DEV_NAME $1
678 echoscip-shell system . . echo. $PWD1 | $CRYPTSETUP reencrypt $DEV --header $2 -q || failscip-shell shell shell-project 0.0.0 fail().
679
680 $CRYPTSETUP status $DEV_NAME >/dev/nullscip-shell filesystem . . `/dev/null`. 2>&1 && failscip-shell shell shell-project 0.0.0 fail().
681 check_hash_dev_headscip-shell shell shell-project 0.0.0 check_hash_dev_head(). $DEV $3 $1
682
683 [scip-shell system . . `[`. -f $2 ] && rmscip-shell system . . rm. -f $2
684
685 echoscip-shell system . . echo. -n "[OK]"
686 }
687
688 decrypt_recover_online_movedscip-shell shell shell-project 0.0.0 decrypt_recover_online_moved().() { # $1 hash, $2 hdr, $3 dev size
689 local _res=""
690 local _maxhz=""
691 testscip-shell system . . test. -z "$4" || _res="--resilience $4"
692 testscip-shell system . . test. -z "$5" || _maxhz="--hotzone-size $5"
693 echoscip-shell system . . echo. -n "[${4:-default}]"
694
695 echoscip-shell system . . echo. $PWD1 | $CRYPTSETUP reencrypt $DEV --decrypt --header $2 $_maxhz $_res --init-only >/dev/nullscip-shell filesystem . . `/dev/null`. 2>&1 || failscip-shell shell shell-project 0.0.0 fail().
696
697 error_writesscip-shell shell shell-project 0.0.0 error_writes(). $OVRDEV $OLD_DEV $ERROFFSET $ERRLENGTH
698 echoscip-shell system . . echo. $PWD1 | $CRYPTSETUP reencrypt $DEV --header $2 -q $_res >/dev/nullscip-shell filesystem . . `/dev/null`. 2>&1 && failscip-shell shell shell-project 0.0.0 fail().
699 $CRYPTSETUP status $DEV_NAME --header $2 | grepscip-shell system . . grep. -q "reencryption: in-progress" || failscip-shell shell shell-project 0.0.0 fail().
700 $CRYPTSETUP close $DEV_NAME || failscip-shell shell shell-project 0.0.0 fail().
701 fix_writesscip-shell shell shell-project 0.0.0 fix_writes(). $OVRDEV $OLD_DEV
702
703 # recovery but activation fails due to last segment recovery makes it plaintext device
704 echoscip-shell system . . echo. $PWD1 | $CRYPTSETUP open $DEV --header $2 $DEV_NAME 2>/dev/nullscip-shell filesystem . . `/dev/null`. && failscip-shell shell shell-project 0.0.0 fail().
705
706 $CRYPTSETUP status $DEV_NAME >/dev/nullscip-shell filesystem . . `/dev/null`. 2>&1 && failscip-shell shell shell-project 0.0.0 fail().
707 check_hash_dev_headscip-shell shell shell-project 0.0.0 check_hash_dev_head(). $DEV $3 $1
708
709 [scip-shell system . . `[`. -f $2 ] && rmscip-shell system . . rm. -f $2
710
711 echoscip-shell system . . echo. -n "[OK]"
712 }
713
714 # sector size (bytes)
715 # reenc dev size (sectors)
716 # reenc dev digest
717 # resilience
718 # orig size
719 # orig size digest
720 # hdr (optional)
721 reencrypt_offline_fixed_sizescip-shell shell shell-project 0.0.0 reencrypt_offline_fixed_size().() {
722 local _esz=$(($1>>9))
723 local _hdr=""
724 # round-up fixed size to megabytes
725 local _mbs=$((($2>>11)+1))
726 testscip-shell system . . test. -z "$7" || _hdr="--header $7"
727
728 if [scip-shell system . . `[`. -z "$7" ]; then
729 echoscip-shell system . . echo. $PWD1 | $CRYPTSETUP -q luksFormat --type luks2 --offset 16384 $FAST_PBKDF_ARGON $DEV || failscip-shell shell shell-project 0.0.0 fail().
730 else
731 echoscip-shell system . . echo. $PWD1 | $CRYPTSETUP -q luksFormat --type luks2 --header $7 $FAST_PBKDF_ARGON $DEV || failscip-shell shell shell-project 0.0.0 fail().
732 fi
733 echoscip-shell system . . echo. $PWD1 | $CRYPTSETUP open $_hdr $DEV $DEV_NAME || failscip-shell shell shell-project 0.0.0 fail().
734 wipe_dev_headscip-shell shell shell-project 0.0.0 wipe_dev_head(). /dev/mapper/$DEV_NAME $_mbs
735 $CRYPTSETUP close $DEV_NAME || failscip-shell shell shell-project 0.0.0 fail().
736
737 # reencrypt with fixed device size
738 echoscip-shell system . . echo. $PWD1 | $CRYPTSETUP reencrypt -q $FAST_PBKDF_ARGON $DEV $_hdr --sector-size $1 --device-size $2s --resilience $4 --force-offline-reencrypt || failscip-shell shell shell-project 0.0.0 fail().
739
740 check_hash_headscip-shell shell shell-project 0.0.0 check_hash_head(). $PWD1 $2 $3 $7
741 wipescip-shell shell shell-project 0.0.0 wipe(). $PWD1 $7
742
743 # try to reencrypt device size + 1 encryption sector size
744 echoscip-shell system . . echo. $PWD1 | $CRYPTSETUP reencrypt -q $FAST_PBKDF_ARGON $DEV $_hdr --sector-size $1 --init-only --force-offline-reencrypt || failscip-shell shell shell-project 0.0.0 fail().
745 echoscip-shell system . . echo. $PWD1 | $CRYPTSETUP reencrypt -q $FAST_PBKDF_ARGON $DEV $_hdr --device-size $(($5+_esz))s --resilience $4 2>/dev/nullscip-shell filesystem . . `/dev/null`. && failscip-shell shell shell-project 0.0.0 fail().
746 check_hashscip-shell shell shell-project 0.0.0 check_hash(). $PWD1 $6 $7
747
748 # misaligned reencryption size
749 if [scip-shell system . . `[`. $_esz -gt 1 ]; then
750 echoscip-shell system . . echo. $PWD1 | $CRYPTSETUP reencrypt -q $FAST_PBKDF_ARGON $DEV $_hdr --device-size $(($2+_esz-1))s --resilience $4 2>/dev/nullscip-shell filesystem . . `/dev/null`. && failscip-shell shell shell-project 0.0.0 fail().
751 $CRYPTSETUP luksDump ${7:-$DEV} | grepscip-shell system . . grep. -q "2: crypt" || failscip-shell shell shell-project 0.0.0 fail().
752 $CRYPTSETUP luksDump ${7:-$DEV} | grepscip-shell system . . grep. -q "3: crypt" && failscip-shell shell shell-project 0.0.0 fail().
753 check_hashscip-shell shell shell-project 0.0.0 check_hash(). $PWD1 $6 $7
754 fi
755 }
756
757 # sector size (bytes)
758 # reenc dev size (sectors)
759 # reenc dev digest
760 # resilience
761 # orig size
762 # orig size digest
763 # hdr
764 encrypt_offline_fixed_sizescip-shell shell shell-project 0.0.0 encrypt_offline_fixed_size().() {
765 local _esz=$(($1>>9))
766
767 # reencrypt with fixed device size
768 wipe_devscip-shell shell shell-project 0.0.0 wipe_dev(). $DEV
769 echoscip-shell system . . echo. $PWD1 | $CRYPTSETUP reencrypt --encrypt -q $FAST_PBKDF_ARGON $DEV --header $7 --sector-size $1 --device-size $2s --resilience $4 || failscip-shell shell shell-project 0.0.0 fail().
770 check_hash_headscip-shell shell shell-project 0.0.0 check_hash_head(). $PWD1 $2 $3 $7
771 [scip-shell system . . `[`. -f $7 ] && rmscip-shell system . . rm. -f $7
772
773 # try to reencrypt device size + 1 encryption sector size
774 wipe_devscip-shell shell shell-project 0.0.0 wipe_dev(). $DEV
775 echoscip-shell system . . echo. $PWD1 | $CRYPTSETUP reencrypt --encrypt -q $FAST_PBKDF_ARGON $DEV --header $7 --sector-size $1 --init-only || failscip-shell shell shell-project 0.0.0 fail().
776 echoscip-shell system . . echo. $PWD1 | $CRYPTSETUP reencrypt -q $FAST_PBKDF_ARGON $DEV --header $7 --device-size $(($5+_esz))s --resilience $4 2>/dev/nullscip-shell filesystem . . `/dev/null`. && failscip-shell shell shell-project 0.0.0 fail().
777 check_hashscip-shell shell shell-project 0.0.0 check_hash(). $PWD1 $6 $7
778
779 # misaligned reencryption size
780 if [scip-shell system . . `[`. $_esz -gt 1 ]; then
781 [scip-shell system . . `[`. -f $7 ] && rmscip-shell system . . rm. -f $7
782 echoscip-shell system . . echo. $PWD1 | $CRYPTSETUP reencrypt --encrypt -q $FAST_PBKDF_ARGON $DEV --header $7 --sector-size $1 --init-only || failscip-shell shell shell-project 0.0.0 fail().
783 echoscip-shell system . . echo. $PWD1 | $CRYPTSETUP reencrypt -q $DEV --header $7 --device-size $(($2+_esz-1))s --resilience $4 2>/dev/nullscip-shell filesystem . . `/dev/null`. && failscip-shell shell shell-project 0.0.0 fail().
784 $CRYPTSETUP luksDump $7 | grepscip-shell system . . grep. -q "2: crypt" || failscip-shell shell shell-project 0.0.0 fail().
785 $CRYPTSETUP luksDump $7 | grepscip-shell system . . grep. -q "3: crypt" && failscip-shell shell shell-project 0.0.0 fail().
786 check_hashscip-shell shell shell-project 0.0.0 check_hash(). $PWD1 $6 $7
787 fi
788
789 [scip-shell system . . `[`. -f $7 ] && rmscip-shell system . . rm. -f $7
790 }
791
792 # sector size (bytes)
793 # reenc dev size (sectors)
794 # reenc dev digest
795 # resilience
796 # orig size
797 # orig size digest
798 # hdr
799 decrypt_offline_fixed_sizescip-shell shell shell-project 0.0.0 decrypt_offline_fixed_size().() {
800 local _esz=$(($1>>9))
801
802 # decrypt with fixed device size
803 echoscip-shell system . . echo. $PWD1 | $CRYPTSETUP luksFormat --type luks2 -q $FAST_PBKDF_ARGON $DEV --header $7 --sector-size $1 || failscip-shell shell shell-project 0.0.0 fail().
804 wipescip-shell shell shell-project 0.0.0 wipe(). $PWD1 $7
805 echoscip-shell system . . echo. $PWD1 | $CRYPTSETUP reencrypt --decrypt -q $DEV --header $7 --device-size $2s --resilience $4 || failscip-shell shell shell-project 0.0.0 fail().
806
807 dmsetup load $OVRDEV --table "0 $2 linear $OLD_DEV 0" || failscip-shell shell shell-project 0.0.0 fail().
808 dmsetup resume $OVRDEV || failscip-shell shell shell-project 0.0.0 fail().
809 check_hash_devscip-shell shell shell-project 0.0.0 check_hash_dev(). $DEV $3
810 dmsetup load $OVRDEV --table "0 $5 linear $OLD_DEV 0" || failscip-shell shell shell-project 0.0.0 fail().
811 dmsetup resume $OVRDEV || failscip-shell shell shell-project 0.0.0 fail().
812
813 # try to decrypt device size + 1 encryption sector size
814 echoscip-shell system . . echo. $PWD1 | $CRYPTSETUP luksFormat --type luks2 -q $FAST_PBKDF_ARGON $DEV --header $7 --sector-size $1 || failscip-shell shell shell-project 0.0.0 fail().
815 wipescip-shell shell shell-project 0.0.0 wipe(). $PWD1 $7
816 echoscip-shell system . . echo. $PWD1 | $CRYPTSETUP reencrypt --decrypt -q $FAST_PBKDF_ARGON $DEV --header $7 --init-only || failscip-shell shell shell-project 0.0.0 fail().
817 echoscip-shell system . . echo. $PWD1 | $CRYPTSETUP reencrypt -q $FAST_PBKDF_ARGON $DEV --header $7 --device-size $(($5+_esz))s --resilience $4 2>/dev/nullscip-shell filesystem . . `/dev/null`. && failscip-shell shell shell-project 0.0.0 fail().
818 check_hashscip-shell shell shell-project 0.0.0 check_hash(). $PWD1 $6 $7
819
820 # misaligned reencryption size
821 if [scip-shell system . . `[`. $_esz -gt 1 ]; then
822 echoscip-shell system . . echo. $PWD1 | $CRYPTSETUP reencrypt -q $DEV --header $7 --device-size $(($2+_esz-1))s --resilience $4 2>/dev/nullscip-shell filesystem . . `/dev/null`. && failscip-shell shell shell-project 0.0.0 fail().
823 $CRYPTSETUP luksDump $7 | grepscip-shell system . . grep. -q "2: linear\|2: crypt" || failscip-shell shell shell-project 0.0.0 fail().
824 $CRYPTSETUP luksDump $7 | grepscip-shell system . . grep. -q "3: crypt\|3: linear" && failscip-shell shell shell-project 0.0.0 fail().
825 check_hashscip-shell shell shell-project 0.0.0 check_hash(). $PWD1 $6 $7
826 fi
827 }
828
829 # sector size (bytes)
830 # reenc dev size (sectors)
831 # reenc dev digest
832 # resilience
833 # orig size
834 # orig size digest
835 # hdr (optional)
836 reencrypt_online_fixed_sizescip-shell shell shell-project 0.0.0 reencrypt_online_fixed_size().() {
837 local _esz=$(($1>>9))
838 local _hdr=""
839 testscip-shell system . . test. -z "$7" || _hdr="--header $7"
840
841 if [scip-shell system . . `[`. -z "$_hdr" ]; then
842 echoscip-shell system . . echo. $PWD1 | $CRYPTSETUP -q luksFormat --sector-size 512 --type luks2 --offset 16384 $FAST_PBKDF_ARGON $DEV || failscip-shell shell shell-project 0.0.0 fail().
843 else
844 echoscip-shell system . . echo. $PWD1 | $CRYPTSETUP -q luksFormat --sector-size 512 --type luks2 $_hdr $FAST_PBKDF_ARGON $DEV || failscip-shell shell shell-project 0.0.0 fail().
845 fi
846 wipescip-shell shell shell-project 0.0.0 wipe(). $PWD1 $7
847
848 # reencrypt with fixed device size
849 echoscip-shell system . . echo. $PWD1 | $CRYPTSETUP open $DEV $_hdr $DEV_NAME || failscip-shell shell shell-project 0.0.0 fail().
850 echoscip-shell system . . echo. $PWD1 | $CRYPTSETUP resize $DEV_NAME $_hdr --size $2 || failscip-shell shell shell-project 0.0.0 fail().
851 echoscip-shell system . . echo. $PWD1 | $CRYPTSETUP reencrypt -q $FAST_PBKDF_ARGON $DEV $_hdr --sector-size $1 --resilience $4 || failscip-shell shell shell-project 0.0.0 fail().
852 $CRYPTSETUP -q status $DEV_NAME | grepscip-shell system . . grep. "size:" | grepscip-shell system . . grep. -q "$2 \[512-byte units\]" || failscip-shell shell shell-project 0.0.0 fail().
853 $CRYPTSETUP close $DEV_NAME || failscip-shell shell shell-project 0.0.0 fail().
854 check_hash_headscip-shell shell shell-project 0.0.0 check_hash_head(). $PWD1 $2 $3 $7
855 wipescip-shell shell shell-project 0.0.0 wipe(). $PWD1 $7
856
857 # active device != requested reencryption size
858 echoscip-shell system . . echo. $PWD1 | $CRYPTSETUP open $DEV $_hdr $DEV_NAME || failscip-shell shell shell-project 0.0.0 fail().
859 echoscip-shell system . . echo. $PWD1 | $CRYPTSETUP resize $DEV_NAME $_hdr --size $2 || failscip-shell shell shell-project 0.0.0 fail().
860 echoscip-shell system . . echo. $PWD1 | $CRYPTSETUP reencrypt -q $FAST_PBKDF_ARGON $DEV $_hdr --sector-size $1 --init-only || failscip-shell shell shell-project 0.0.0 fail().
861 echoscip-shell system . . echo. $PWD1 | $CRYPTSETUP reencrypt -q $FAST_PBKDF_ARGON $DEV $_hdr --device-size $(($2-_esz))s --resilience $4 2>/dev/nullscip-shell filesystem . . `/dev/null`. && failscip-shell shell shell-project 0.0.0 fail().
862 echoscip-shell system . . echo. $PWD1 | $CRYPTSETUP reencrypt -q $FAST_PBKDF_ARGON $DEV $_hdr --device-size $2s --resilience $4 || failscip-shell shell shell-project 0.0.0 fail().
863 $CRYPTSETUP -q status $DEV_NAME | grepscip-shell system . . grep. "size:" | grepscip-shell system . . grep. -q "$2 \[512-byte units\]" || failscip-shell shell shell-project 0.0.0 fail().
864 $CRYPTSETUP close $DEV_NAME || failscip-shell shell shell-project 0.0.0 fail().
865 check_hash_headscip-shell shell shell-project 0.0.0 check_hash_head(). $PWD1 $2 $3 $7
866
867 # misaligned reencryption size
868 if [scip-shell system . . `[`. $_esz -gt 1 ]; then
869 if [scip-shell system . . `[`. -z "$_hdr" ]; then
870 echoscip-shell system . . echo. $PWD1 | $CRYPTSETUP -q luksFormat --sector-size 512 --type luks2 --offset 16384 $FAST_PBKDF_ARGON $DEV || failscip-shell shell shell-project 0.0.0 fail().
871 else
872 echoscip-shell system . . echo. $PWD1 | $CRYPTSETUP -q luksFormat --sector-size 512 --type luks2 $_hdr $FAST_PBKDF_ARGON $DEV || failscip-shell shell shell-project 0.0.0 fail().
873 fi
874 wipescip-shell shell shell-project 0.0.0 wipe(). $PWD1 $7
875 check_hashscip-shell shell shell-project 0.0.0 check_hash(). $PWD1 $6 $7
876
877 echoscip-shell system . . echo. $PWD1 | $CRYPTSETUP open $DEV $_hdr $DEV_NAME || failscip-shell shell shell-project 0.0.0 fail().
878 echoscip-shell system . . echo. $PWD1 | $CRYPTSETUP resize $DEV_NAME $_hdr --size $(($2+_esz-1)) || failscip-shell shell shell-project 0.0.0 fail().
879 echoscip-shell system . . echo. $PWD1 | $CRYPTSETUP reencrypt -q $FAST_PBKDF_ARGON $DEV $_hdr --sector-size $1 --init-only || failscip-shell shell shell-project 0.0.0 fail().
880 echoscip-shell system . . echo. $PWD1 | $CRYPTSETUP reencrypt -q $FAST_PBKDF_ARGON $DEV $_hdr --resilience $4 2>/dev/nullscip-shell filesystem . . `/dev/null`. && failscip-shell shell shell-project 0.0.0 fail().
881 $CRYPTSETUP close $DEV_NAME || failscip-shell shell shell-project 0.0.0 fail().
882 check_hashscip-shell shell shell-project 0.0.0 check_hash(). $PWD1 $6 $7
883 fi
884
885 [scip-shell system . . `[`. -n "$7" -a -f "$7" ] && rmscip-shell system . . rm. -f $7
886 }
887
888 reformat_reencrypt_devicescip-shell shell shell-project 0.0.0 reformat_reencrypt_device().() {
889 if [scip-shell system . . `[`. ! -e $BACKUP_FILE ]; then
890 echoscip-shell system . . echo. $PWD1 | $CRYPTSETUP -q luksFormat --type luks2 -S0 $FAST_PBKDF_ARGON $DEV || failscip-shell shell shell-project 0.0.0 fail().
891 echoscip-shell system . . echo. -e "$PWD1\n$PWD2" | $CRYPTSETUP -q luksAddKey -S2 $FAST_PBKDF_ARGON $DEV || failscip-shell shell shell-project 0.0.0 fail().
892 echoscip-shell system . . echo. -e "$PWD1\n$PWD3" | $CRYPTSETUP -q luksAddKey -S4 $FAST_PBKDF_ARGON $DEV || failscip-shell shell shell-project 0.0.0 fail().
893 echoscip-shell system . . echo. -e "$PWD1\n$PWD4" | $CRYPTSETUP -q luksAddKey -S6 $FAST_PBKDF_ARGON $DEV || failscip-shell shell shell-project 0.0.0 fail().
894 echoscip-shell system . . echo. -e "$PWD1\n$PWD5" | $CRYPTSETUP -q luksAddKey -S8 $FAST_PBKDF_ARGON $DEV || failscip-shell shell shell-project 0.0.0 fail().
895 echoscip-shell system . . echo. -e "$PWD1\n$PWD6" | $CRYPTSETUP -q luksAddKey -S10 $FAST_PBKDF_ARGON $DEV || failscip-shell shell shell-project 0.0.0 fail().
896 echoscip-shell system . . echo. -e "$PWD1\n$PWD7" | $CRYPTSETUP -q luksAddKey -S12 $FAST_PBKDF_ARGON $DEV || failscip-shell shell shell-project 0.0.0 fail().
897
898 $CRYPTSETUP token add $DEV --token-id 1 --key-description $KEY_NAME3 -S6
899 $CRYPTSETUP token add $DEV --token-id 2 --key-description $KEY_NAME4 -S8
900 $CRYPTSETUP token add $DEV --token-id 3 --key-description $KEY_NAME5 -S10
901 echoscip-shell system . . echo. -e "{\"type\":\"luks2-keyring\",\"keyslots\":[\"4\", \"12\"],\"key_description\":\"$KEY_NAME6\"}" | $CRYPTSETUP token import $DEV --token-id 4 --json-file -
902
903 $CRYPTSETUP -q luksHeaderBackup --header-backup-file $BACKUP_FILE $DEV || failscip-shell shell shell-project 0.0.0 fail().
904 else
905 $CRYPTSETUP -q luksHeaderRestore --header-backup-file $BACKUP_FILE $DEV || failscip-shell shell shell-project 0.0.0 fail().
906 fi
907 }
908
909 prepare_vk_keyringscip-shell shell shell-project 0.0.0 prepare_vk_keyring().()
910 {
911 local s_desc=$(keyctl rdescribe @s | cutscip-shell system . . cut. -d';' -f5)
912 local us_desc=$(keyctl rdescribe @us | cutscip-shell system . . cut. -d';' -f5)
913
914 if [scip-shell system . . `[`. "$s_desc" = "$us_desc" -a -n "$s_desc" ]; then
915 echoscip-shell system . . echo. "Session keyring is missing. Giving new one to parent process..."
916 keyctl new_session > /dev/nullscip-shell filesystem . . `/dev/null`. || failscip-shell shell shell-project 0.0.0 fail().
917 fi
918
919 keyctl newring $KEYRING "@s" >/dev/nullscip-shell filesystem . . `/dev/null`. || failscip-shell shell shell-project 0.0.0 fail(). "Failed to setup test keyring environment"
920 keyctl search "@s" keyring $KEYRING >/dev/nullscip-shell filesystem . . `/dev/null`. 2>&1 || failscip-shell shell shell-project 0.0.0 fail(). "Could not find test keyring in a session keyring."
921
922 echoscip-shell system . . echo. -n $PWD4 | keyctl padd user $KEY_NAME3 %:$KEYRING > /dev/nullscip-shell filesystem . . `/dev/null`. || failscip-shell shell shell-project 0.0.0 fail().
923 echoscip-shell system . . echo. -n "wRonG_passFrejz" | keyctl padd user $KEY_NAME5 %:$KEYRING > /dev/nullscip-shell filesystem . . `/dev/null`. || failscip-shell shell shell-project 0.0.0 fail().
924 echoscip-shell system . . echo. -n $PWD7 | keyctl padd user $KEY_NAME6 %:$KEYRING > /dev/nullscip-shell filesystem . . `/dev/null`. || failscip-shell shell shell-project 0.0.0 fail().
925 echoscip-shell system . . echo. -n $PWD2 | keyctl padd user $KEY_NAME7 %:$KEYRING > /dev/nullscip-shell filesystem . . `/dev/null`. || failscip-shell shell shell-project 0.0.0 fail().
926 }
927
928 setup_luks2_envscip-shell shell shell-project 0.0.0 setup_luks2_env().() {
929 echoscip-shell system . . echo. $PWD1 | $CRYPTSETUP luksFormat --type luks2 -c aes-xts-plain64 $FAST_PBKDF_ARGON $DEV || failscip-shell shell shell-project 0.0.0 fail().
930 echoscip-shell system . . echo. $PWD1 | $CRYPTSETUP open $DEV $DEV_NAME || failscip-shell shell shell-project 0.0.0 fail().
931 local check_keyring=$($CRYPTSETUP status $DEV_NAME | grepscip-shell system . . grep. "key location: keyring")
932 if [scip-shell system . . `[`. -n "$check_keyring" ]; then
933 bin_checkscip-shell shell shell-project 0.0.0 bin_check(). keyctl
934 HAVE_KEYRING=1
935 prepare_vk_keyringscip-shell shell shell-project 0.0.0 prepare_vk_keyring().
936 fi
937 DEF_XTS_KEY=$($CRYPTSETUP status $DEV_NAME | grepscip-shell system . . grep. "keysize:" | sedscip-shell system . . sed. 's/\( keysize: \)\([0-9]\+\)\(.*\)/\2/')
938 [scip-shell system . . `[`. -n "$DEF_XTS_KEY" ] || failscip-shell shell shell-project 0.0.0 fail(). "Failed to parse xts mode key size."
939 $CRYPTSETUP close $DEV_NAME || failscip-shell shell shell-project 0.0.0 fail().
940 }
941
942 check_blkidscip-shell shell shell-project 0.0.0 check_blkid().() {
943 bin_checkscip-shell shell shell-project 0.0.0 bin_check(). blkid
944 xzscip-shell system . . xz. -dkf $HEADER_LUKS2_PV.xz
945 if ! $($CRYPTSETUP --version | grepscip-shell system . . grep. -q "BLKID"); then
946 HAVE_BLKID=0
947 elif $(blkidscip-shell system . . blkid. -p -n crypto_LUKS $HEADER_LUKS2_PV >/dev/nullscip-shell filesystem . . `/dev/null`. 2>&1); then
948 HAVE_BLKID=1
949 xzscip-shell system . . xz. -dkf $IMG_FS.xz
950 blkidscip-shell system . . blkid. $IMG_FS | grepscip-shell system . . grep. -q BLOCK_SIZE && BLKID_BLOCK_SIZE_SUPPORT=1
951 else
952 HAVE_BLKID=0
953 fi
954 }
955
956 valgrind_setupscip-shell shell shell-project 0.0.0 valgrind_setup().()
957 {
958 command -v valgrind >/dev/nullscip-shell filesystem . . `/dev/null`. || failscip-shell shell shell-project 0.0.0 fail(). "Cannot find valgrind."
959 [scip-shell system . . `[`. ! -f $CRYPTSETUP_VALGRIND ] && failscip-shell shell shell-project 0.0.0 fail(). "Unable to get location of cryptsetup executable."
960 [scip-shell system . . `[`. ! -f valg.sh ] && failscip-shell shell shell-project 0.0.0 fail(). "Unable to get location of valg runner script."
961 if [scip-shell system . . `[`. -z "$CRYPTSETUP_TESTS_RUN_IN_MESON" ]; then
962 export LD_LIBRARY_PATH="$CRYPTSETUP_LIB_VALGRIND:$LD_LIBRARY_PATH"
963 fi
964 }
965
966 valgrind_runscip-shell shell shell-project 0.0.0 valgrind_run().()
967 {
968 INFOSTRING="$(basenamescip-shell system . . basename. ${BASH_SOURCE[1]})-line-${BASH_LINENO[0]}" ./valg.sh ${CRYPTSETUP_VALGRIND} "$@"
969 }
970
971 bin_checkscip-shell shell shell-project 0.0.0 bin_check().()
972 {
973 command -v $1 >/dev/nullscip-shell filesystem . . `/dev/null`. || skipscip-shell shell shell-project 0.0.0 skip(). "WARNING: test require $1 binary, test skipped."
974 }
975
976 _ddscip-shell shell shell-project 0.0.0 _dd().()
977 {
978 ddscip-shell system . . dd. $@ status=none conv=notrunc bs=1
979 }
980
981 img_json_savescip-shell shell shell-project 0.0.0 img_json_save().()
982 {
983 local _hdr=$IMG
984 [scip-shell system . . `[`. -z "$1" ] || _hdr="$1"
985 # FIXME: why --json-file cannot be used?
986 $CRYPTSETUP luksDump --dump-json-metadata $_hdr | jqscip-shell system . . jq. -c -M . | trscip-shell system . . tr. -d '\n' >$IMG_JSON
987 }
988
989 # header mangle functions
990 img_update_jsonscip-shell shell shell-project 0.0.0 img_update_json().()
991 {
992 local _hdr="$IMG"
993 local LUKS2_BIN1_OFFSET=448
994 local LUKS2_BIN2_OFFSET=$((LUKS2_BIN1_OFFSET + $JSON_MSIZE))
995 local LUKS2_JSON_SIZE=$(($JSON_MSIZE - 4096))
996
997 # if present jq script, mangle JSON
998 if [scip-shell system . . `[`. -n "$1" ]; then
999 local JSON=$(catscip-shell system . . cat. $IMG_JSON)
1000 echoscip-shell system . . echo. $JSON | jqscip-shell system . . jq. -M -c "$1" >$IMG_JSON || failscip-shell shell shell-project 0.0.0 fail().
1001 local JSON=$(catscip-shell system . . cat. $IMG_JSON)
1002 echoscip-shell system . . echo. $JSON | trscip-shell system . . tr. -d '\n' >$IMG_JSON || failscip-shell shell shell-project 0.0.0 fail().
1003 fi
1004
1005 [scip-shell system . . `[`. -z "$2" ] || _hdr="$2"
1006
1007 # wipe JSON areas
1008 _ddscip-shell shell shell-project 0.0.0 _dd(). if=/dev/zeroscip-shell filesystem . . `/dev/zero`. of=$_hdr count=$LUKS2_JSON_SIZE seek=4096
1009 _ddscip-shell shell shell-project 0.0.0 _dd(). if=/dev/zeroscip-shell filesystem . . `/dev/zero`. of=$_hdr count=$LUKS2_JSON_SIZE seek=$(($JSON_MSIZE + 4096))
1010
1011 # write JSON data
1012 _ddscip-shell shell shell-project 0.0.0 _dd(). if=$IMG_JSON of=$_hdr count=$LUKS2_JSON_SIZE seek=4096
1013 _ddscip-shell shell shell-project 0.0.0 _dd(). if=$IMG_JSON of=$_hdr count=$LUKS2_JSON_SIZE seek=$(($JSON_MSIZE + 4096))
1014
1015 # erase sha256 checksums
1016 _ddscip-shell shell shell-project 0.0.0 _dd(). if=/dev/zeroscip-shell filesystem . . `/dev/zero`. of=$_hdr count=64 seek=$LUKS2_BIN1_OFFSET
1017 _ddscip-shell shell shell-project 0.0.0 _dd(). if=/dev/zeroscip-shell filesystem . . `/dev/zero`. of=$_hdr count=64 seek=$LUKS2_BIN2_OFFSET
1018
1019 # calculate sha256 and write chexksums
1020 local SUM1_HEX=$(_ddscip-shell shell shell-project 0.0.0 _dd(). if=$_hdr count=$JSON_MSIZE | sha256sumscip-shell system . . sha256sum. | cutscip-shell system . . cut. -d ' ' -f 1)
1021 echoscip-shell system . . echo. $SUM1_HEX | xxd -r -p | _ddscip-shell shell shell-project 0.0.0 _dd(). of=$_hdr seek=$LUKS2_BIN1_OFFSET count=64 || failscip-shell shell shell-project 0.0.0 fail().
1022
1023 local SUM2_HEX=$(_ddscip-shell shell shell-project 0.0.0 _dd(). if=$_hdr skip=$JSON_MSIZE count=$JSON_MSIZE | sha256sumscip-shell system . . sha256sum. | cutscip-shell system . . cut. -d ' ' -f 1)
1024 echoscip-shell system . . echo. $SUM2_HEX | xxd -r -p | _ddscip-shell shell shell-project 0.0.0 _dd(). of=$_hdr seek=$LUKS2_BIN2_OFFSET count=64 || failscip-shell shell shell-project 0.0.0 fail().
1025 }
1026
1027 [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."
1028 [scip-shell system . . `[`. ! -x "$CRYPTSETUP" ] && skipscip-shell shell shell-project 0.0.0 skip(). "Cannot find $CRYPTSETUP, test skipped."
1029 fips_modescip-shell shell shell-project 0.0.0 fips_mode(). && skipscip-shell shell shell-project 0.0.0 skip(). "This test cannot be run in FIPS mode."
1030 modprobe --dry-run scsi_debug >/dev/nullscip-shell filesystem . . `/dev/null`. 2>&1 || skipscip-shell shell shell-project 0.0.0 skip(). "This kernel seems to not support proper scsi_debug module, test skipped."
1031 modprobe dm-crypt >/dev/nullscip-shell filesystem . . `/dev/null`. 2>&1 || failscip-shell shell shell-project 0.0.0 fail(). "dm-crypt failed to load"
1032 modprobe dm-delay > /dev/nullscip-shell filesystem . . `/dev/null`. 2>&1
1033 dm_crypt_featuresscip-shell shell shell-project 0.0.0 dm_crypt_features().
1034 bin_checkscip-shell shell shell-project 0.0.0 bin_check(). jq
1035 bin_checkscip-shell shell shell-project 0.0.0 bin_check(). sha256sum
1036 bin_checkscip-shell shell shell-project 0.0.0 bin_check(). xxd
1037
1038 if [scip-shell system . . `[`. -n "$DM_SECTOR_SIZE" ]; then
1039 TEST_SECTORS="512 4096"
1040 else
1041 TEST_SECTORS="512"
1042 fi
1043
1044 modinfo scsi_debug -p | grepscip-shell system . . grep. -q opt_xferlen_exp && OPT_XFERLEN_EXP="opt_xferlen_exp=6"
1045
1046 export LANG=C
1047
1048 [scip-shell system . . `[`. -n "$VALG" ] && valgrind_setupscip-shell shell shell-project 0.0.0 valgrind_setup(). && CRYPTSETUP=valgrind_run
1049
1050 # REENCRYPTION tests
1051
1052 # 28 MiBs of zeros (32MiBs - 4MiB LUKS2 header)
1053 HASH1=4da90c0638bd7d29ce3d0ace3df5ee99706c23da
1054 # 1 MiB of zeros
1055 HASH2=3b71f43ff30f4b15b5cd85dd9e95ebc7e84eb5a3
1056 # 256 MiBs of zeros
1057 HASH3=7b91dbdc56c5781edf6c8847b4aa6965566c5c75
1058 # 64 MiBs of zeroes
1059 HASH4=44fac4bedde4df04b9572ac665d3ac2c5cd00c7d
1060 # 56 MiBs of zeroes
1061 HASH5=bcd8ce9b30a43b2dacdf479493c93e167ef60946
1062 # 43 MiBs of zeroes
1063 HASH6=2cf8a5f40a2ab5373c5425d6071da480f1ce08e8
1064 # 31 MiBs of zeroes
1065 HASH7=7ed56dd14d2841cf169fe503d097be04192666bd
1066 # 60 MiBs of zeroes
1067 HASH8=233ba936226a3ac499e67babaebd0d4aafb9761a
1068 # 240 MiBs of zeroes (256MiBs - 16MiBs default LUKS2 header size)
1069 HASH9=045eebed703cce308e049deb019b877f0445862f
1070 # 16 MiBs of zeroes
1071 HASH10=3b4417fc421cee30a9ad0fd9319220a8dae32da2
1072
1073 preparescip-shell shell shell-project 0.0.0 prepare(). dev_size_mb=32
1074 setup_luks2_envscip-shell shell shell-project 0.0.0 setup_luks2_env().
1075
1076 # Check that we can use other ciphers than AES in userspace backend.
1077 echoscip-shell system . . echo. $PWD1 | $CRYPTSETUP -q luksFormat --type luks2 -c twofish-xts-plain64 $FAST_PBKDF_ARGON $DEV || skipscip-shell shell shell-project 0.0.0 skip(). "Cannot use Twofish cipher, test skipped"
1078 echoscip-shell system . . echo. $PWD1 | $CRYPTSETUP reencrypt $DEV -q $FAST_PBKDF_ARGON 2>/dev/nullscip-shell filesystem . . `/dev/null`. || skipscip-shell shell shell-project 0.0.0 skip(). "Cannot use Twofish cipher, test skipped"
1079 echoscip-shell system . . echo. $PWD1 | $CRYPTSETUP -q luksFormat --type luks2 -c serpent-xts-plain64 $FAST_PBKDF_ARGON $DEV || skipscip-shell shell shell-project 0.0.0 skip(). "Cannot use Serpent cipher, test skipped"
1080 echoscip-shell system . . echo. $PWD1 | $CRYPTSETUP reencrypt $DEV -q $FAST_PBKDF_ARGON 2>/dev/nullscip-shell filesystem . . `/dev/null`. || skipscip-shell shell shell-project 0.0.0 skip(). "Cannot use Serpent cipher, test skipped."
1081 wipe_devscip-shell shell shell-project 0.0.0 wipe_dev(). $DEV
1082
1083 echoscip-shell system . . echo. "[1] Reencryption"
1084 echoscip-shell system . . echo. -n "[512 sector]"
1085 echoscip-shell system . . echo. $PWD1 | $CRYPTSETUP -q luksFormat --type luks2 -s 128 -c aes-cbc-essiv:sha256 --offset 8192 $FAST_PBKDF_ARGON $DEV || failscip-shell shell shell-project 0.0.0 fail().
1086 wipescip-shell shell shell-project 0.0.0 wipe(). $PWD1
1087 check_hashscip-shell shell shell-project 0.0.0 check_hash(). $PWD1 $HASH1
1088 echoscip-shell system . . echo. $PWD1 | $CRYPTSETUP reencrypt $DEV -q $FAST_PBKDF_ARGON 2>&1 | tailscip-shell system . . tail. -1 | grepscip-shell system . . grep. -q "not supported" && skipscip-shell shell shell-project 0.0.0 skip(). " No reenryption support, test skipped."
1089 echoscip-shell system . . echo. $PWD1 | $CRYPTSETUP reencrypt $DEV -q $FAST_PBKDF_ARGON || failscip-shell shell shell-project 0.0.0 fail().
1090 check_hashscip-shell shell shell-project 0.0.0 check_hash(). $PWD1 $HASH1
1091 echoscip-shell system . . echo. $PWD1 | $CRYPTSETUP reencrypt $DEV -q -s 256 -c twofish-cbc-essiv:sha256 --resilience journal $FAST_PBKDF_ARGON || failscip-shell shell shell-project 0.0.0 fail().
1092 check_hashscip-shell shell shell-project 0.0.0 check_hash(). $PWD1 $HASH1
1093 echoscip-shell system . . echo. $PWD1 | $CRYPTSETUP reencrypt $DEV -q --resilience none $FAST_PBKDF_ARGON || failscip-shell shell shell-project 0.0.0 fail().
1094 check_hashscip-shell shell shell-project 0.0.0 check_hash(). $PWD1 $HASH1
1095 echoscip-shell system . . echo. $PWD1 | $CRYPTSETUP reencrypt $DEV -q -s 128 -c aes-cbc-essiv:sha256 --resilience checksum $FAST_PBKDF_ARGON || failscip-shell shell shell-project 0.0.0 fail().
1096 check_hashscip-shell shell shell-project 0.0.0 check_hash(). $PWD1 $HASH1
1097 # simple test --active-name can consume absolute path to mapping
1098 echoscip-shell system . . echo. $PWD1 | $CRYPTSETUP reencrypt $DEV -q -c aes-xts-plain64 --init-only $FAST_PBKDF_ARGON || failscip-shell shell shell-project 0.0.0 fail().
1099 echoscip-shell system . . echo. $PWD1 | $CRYPTSETUP open $DEV $DEV_NAME || failscip-shell shell shell-project 0.0.0 fail().
1100 echoscip-shell system . . echo. $PWD1 | $CRYPTSETUP reencrypt --active-name /dev/mapper/$DEV_NAME --resilience none -q || failscip-shell shell shell-project 0.0.0 fail().
1101 XTS_KEY=$($CRYPTSETUP status $DEV_NAME | grepscip-shell system . . grep. "keysize:" | sedscip-shell system . . sed. 's/\( keysize: \)\([0-9]\+\)\(.*\)/\2/')
1102 [scip-shell system . . `[`. "$XTS_KEY" -eq "$DEF_XTS_KEY" ] || failscip-shell shell shell-project 0.0.0 fail(). "xts mode has wrong key size after reencryption ($XTS_KEY != expected $DEF_XTS_KEY)"
1103 echoscip-shell system . . echo. $PWD1 | $CRYPTSETUP close $DEV_NAME || failscip-shell shell shell-project 0.0.0 fail().
1104 echoscip-shell system . . echo. -n "[OK][4096 sector]"
1105 preparescip-shell shell shell-project 0.0.0 prepare(). sector_size=4096 dev_size_mb=32
1106 echoscip-shell system . . echo. $PWD1 | $CRYPTSETUP -q luksFormat --type luks2 -s 128 -c aes-cbc-essiv:sha256 --offset 8192 $FAST_PBKDF_ARGON $DEV || failscip-shell shell shell-project 0.0.0 fail().
1107 wipescip-shell shell shell-project 0.0.0 wipe(). $PWD1
1108 echoscip-shell system . . echo. $PWD1 | $CRYPTSETUP reencrypt $DEV -q $FAST_PBKDF_ARGON || failscip-shell shell shell-project 0.0.0 fail().
1109 check_hashscip-shell shell shell-project 0.0.0 check_hash(). $PWD1 $HASH1
1110 echoscip-shell system . . echo. $PWD1 | $CRYPTSETUP reencrypt $DEV -q -s 256 -c twofish-cbc-essiv:sha256 --resilience journal $FAST_PBKDF_ARGON || failscip-shell shell shell-project 0.0.0 fail().
1111 check_hashscip-shell shell shell-project 0.0.0 check_hash(). $PWD1 $HASH1
1112 echoscip-shell system . . echo. $PWD1 | $CRYPTSETUP reencrypt $DEV -q --resilience none $FAST_PBKDF_ARGON || failscip-shell shell shell-project 0.0.0 fail().
1113 check_hashscip-shell shell shell-project 0.0.0 check_hash(). $PWD1 $HASH1
1114 echoscip-shell system . . echo. $PWD1 | $CRYPTSETUP reencrypt $DEV -q -s 128 -c aes-cbc-essiv:sha256 --resilience checksum $FAST_PBKDF_ARGON || failscip-shell shell shell-project 0.0.0 fail().
1115 check_hashscip-shell shell shell-project 0.0.0 check_hash(). $PWD1 $HASH1
1116 if [scip-shell system . . `[`. -n "$DM_SECTOR_SIZE" ]; then
1117 echoscip-shell system . . echo. $PWD1 | $CRYPTSETUP reencrypt $DEV -q $FAST_PBKDF_ARGON --sector-size 4096 || failscip-shell shell shell-project 0.0.0 fail().
1118 check_hashscip-shell shell shell-project 0.0.0 check_hash(). $PWD1 $HASH1
1119 echoscip-shell system . . echo. $PWD1 | $CRYPTSETUP reencrypt $DEV -q -s 256 -c twofish-cbc-essiv:sha256 --resilience journal --sector-size 2048 $FAST_PBKDF_ARGON || failscip-shell shell shell-project 0.0.0 fail().
1120 check_hashscip-shell shell shell-project 0.0.0 check_hash(). $PWD1 $HASH1
1121 echoscip-shell system . . echo. $PWD1 | $CRYPTSETUP reencrypt $DEV -q --resilience none $FAST_PBKDF_ARGON --sector-size 1024 || failscip-shell shell shell-project 0.0.0 fail().
1122 check_hashscip-shell shell shell-project 0.0.0 check_hash(). $PWD1 $HASH1
1123 echoscip-shell system . . echo. $PWD1 | $CRYPTSETUP reencrypt $DEV -q -s 128 -c aes-cbc-essiv:sha256 --resilience checksum --sector-size 512 $FAST_PBKDF_ARGON || failscip-shell shell shell-project 0.0.0 fail().
1124 check_hashscip-shell shell shell-project 0.0.0 check_hash(). $PWD1 $HASH1
1125 fi
1126 echoscip-shell system . . echo. -n "[OK][4096/512 sector]"
1127 preparescip-shell shell shell-project 0.0.0 prepare(). sector_size=512 physblk_exp=3 dev_size_mb=32
1128 echoscip-shell system . . echo. $PWD1 | $CRYPTSETUP -q luksFormat --type luks2 -s 128 -c aes-cbc-essiv:sha256 --offset 8192 $FAST_PBKDF_ARGON $DEV || failscip-shell shell shell-project 0.0.0 fail().
1129 wipescip-shell shell shell-project 0.0.0 wipe(). $PWD1
1130 echoscip-shell system . . echo. $PWD1 | $CRYPTSETUP reencrypt $DEV -q $FAST_PBKDF_ARGON || failscip-shell shell shell-project 0.0.0 fail().
1131 check_hashscip-shell shell shell-project 0.0.0 check_hash(). $PWD1 $HASH1
1132 echoscip-shell system . . echo. $PWD1 | $CRYPTSETUP reencrypt $DEV -q -s 256 -c twofish-cbc-essiv:sha256 --resilience journal $FAST_PBKDF_ARGON || failscip-shell shell shell-project 0.0.0 fail().
1133 check_hashscip-shell shell shell-project 0.0.0 check_hash(). $PWD1 $HASH1
1134 echoscip-shell system . . echo. $PWD1 | $CRYPTSETUP reencrypt $DEV -q --resilience none $FAST_PBKDF_ARGON || failscip-shell shell shell-project 0.0.0 fail().
1135 check_hashscip-shell shell shell-project 0.0.0 check_hash(). $PWD1 $HASH1
1136 echoscip-shell system . . echo. $PWD1 | $CRYPTSETUP reencrypt $DEV -q -s 128 -c aes-cbc-essiv:sha256 --resilience checksum $FAST_PBKDF_ARGON || failscip-shell shell shell-project 0.0.0 fail().
1137 check_hashscip-shell shell shell-project 0.0.0 check_hash(). $PWD1 $HASH1
1138 echoscip-shell system . . echo. "[OK]"
1139
1140 # reencrypt minimal device size (FIXME: change data device size to single encryption sector size)
1141 # temporary small device size is default luks2 hdr size + 1MiB
1142 echoscip-shell system . . echo. -n "[small device reencryption]"
1143 preparescip-shell shell shell-project 0.0.0 prepare(). dev_size_mb=5
1144 echoscip-shell system . . echo. $PWD1 | $CRYPTSETUP -q luksFormat --type luks2 -s 128 -c aes-cbc-essiv:sha256 --offset 8192 $FAST_PBKDF_ARGON $DEV || failscip-shell shell shell-project 0.0.0 fail().
1145 wipescip-shell shell shell-project 0.0.0 wipe(). $PWD1
1146 check_hashscip-shell shell shell-project 0.0.0 check_hash(). $PWD1 $HASH2
1147 echoscip-shell system . . echo. $PWD1 | $CRYPTSETUP reencrypt $DEV -q $FAST_PBKDF_ARGON || failscip-shell shell shell-project 0.0.0 fail().
1148 check_hashscip-shell shell shell-project 0.0.0 check_hash(). $PWD1 $HASH2
1149 echoscip-shell system . . echo. $PWD1 | $CRYPTSETUP reencrypt $DEV -q -s 256 -c twofish-cbc-essiv:sha256 --resilience journal $FAST_PBKDF_ARGON || failscip-shell shell shell-project 0.0.0 fail().
1150 check_hashscip-shell shell shell-project 0.0.0 check_hash(). $PWD1 $HASH2
1151 echoscip-shell system . . echo. $PWD1 | $CRYPTSETUP reencrypt $DEV -q --resilience none $FAST_PBKDF_ARGON || failscip-shell shell shell-project 0.0.0 fail().
1152 check_hashscip-shell shell shell-project 0.0.0 check_hash(). $PWD1 $HASH2
1153 echoscip-shell system . . echo. $PWD1 | $CRYPTSETUP reencrypt $DEV -q -s 128 -c aes-cbc-essiv:sha256 --resilience checksum $FAST_PBKDF_ARGON || failscip-shell shell shell-project 0.0.0 fail().
1154 check_hashscip-shell shell shell-project 0.0.0 check_hash(). $PWD1 $HASH2
1155 if [scip-shell system . . `[`. -n "$DM_SECTOR_SIZE" ]; then
1156 echoscip-shell system . . echo. $PWD1 | $CRYPTSETUP reencrypt $DEV -q $FAST_PBKDF_ARGON --sector-size 4096 --force-offline-reencrypt || failscip-shell shell shell-project 0.0.0 fail().
1157 check_hashscip-shell shell shell-project 0.0.0 check_hash(). $PWD1 $HASH2
1158 echoscip-shell system . . echo. $PWD1 | $CRYPTSETUP reencrypt $DEV -q -s 256 -c twofish-cbc-essiv:sha256 --resilience journal --sector-size 2048 $FAST_PBKDF_ARGON || failscip-shell shell shell-project 0.0.0 fail().
1159 check_hashscip-shell shell shell-project 0.0.0 check_hash(). $PWD1 $HASH2
1160 echoscip-shell system . . echo. $PWD1 | $CRYPTSETUP reencrypt $DEV -q --resilience none $FAST_PBKDF_ARGON --sector-size 1024 || failscip-shell shell shell-project 0.0.0 fail().
1161 check_hashscip-shell shell shell-project 0.0.0 check_hash(). $PWD1 $HASH2
1162 echoscip-shell system . . echo. $PWD1 | $CRYPTSETUP reencrypt $DEV -q -s 128 -c aes-cbc-essiv:sha256 --resilience checksum --sector-size 512 $FAST_PBKDF_ARGON || failscip-shell shell shell-project 0.0.0 fail().
1163 check_hashscip-shell shell shell-project 0.0.0 check_hash(). $PWD1 $HASH2
1164 fi
1165 echoscip-shell system . . echo. "[OK]"
1166
1167 echoscip-shell system . . echo. "[2] Encryption with data shift"
1168 # well, movin' zeroes :-)
1169 preparebigscip-shell shell shell-project 0.0.0 preparebig(). 64
1170 wipe_devscip-shell shell shell-project 0.0.0 wipe_dev(). $DEV
1171 check_hash_devscip-shell shell shell-project 0.0.0 check_hash_dev(). $DEV $HASH4
1172 echoscip-shell system . . echo. $PWD1 | $CRYPTSETUP reencrypt $DEV --encrypt -c aes-cbc-essiv:sha256 -s 128 --reduce-device-size 8M -q $FAST_PBKDF_ARGON || failscip-shell shell shell-project 0.0.0 fail().
1173 check_hash_headscip-shell shell shell-project 0.0.0 check_hash_head(). $PWD1 $((56*1024*2)) $HASH5
1174 wipe_devscip-shell shell shell-project 0.0.0 wipe_dev(). $DEV
1175 echoscip-shell system . . echo. $PWD1 | $CRYPTSETUP reencrypt $DEV --encrypt -c twofish-cbc-essiv:sha256 -s 128 --reduce-device-size 21M -q $FAST_PBKDF_ARGON || failscip-shell shell shell-project 0.0.0 fail().
1176 check_hash_headscip-shell shell shell-project 0.0.0 check_hash_head(). $PWD1 $((43*1024*2)) $HASH6
1177 wipe_devscip-shell shell shell-project 0.0.0 wipe_dev(). $DEV
1178 # offset 21504 equals 10,5MiBs, equals --reduce-device-size 21M from test above (30M is ignored here, we'll reduce it to 21M in cryptsetup anyway)
1179 echoscip-shell system . . echo. $PWD1 | $CRYPTSETUP reencrypt $DEV --encrypt -c twofish-cbc-essiv:sha256 -s 128 --offset 21504 --reduce-device-size 30M -q $FAST_PBKDF_ARGON > /dev/nullscip-shell filesystem . . `/dev/null`. || failscip-shell shell shell-project 0.0.0 fail().
1180 check_hash_headscip-shell shell shell-project 0.0.0 check_hash_head(). $PWD1 $((43*1024*2)) $HASH6
1181 wipe_devscip-shell shell shell-project 0.0.0 wipe_dev(). $DEV
1182 echoscip-shell system . . echo. $PWD1 | $CRYPTSETUP reencrypt $DEV --encrypt --reduce-device-size 33M -q $FAST_PBKDF_ARGON || failscip-shell shell shell-project 0.0.0 fail().
1183 check_hash_headscip-shell shell shell-project 0.0.0 check_hash_head(). $PWD1 $((31*1024*2)) $HASH7
1184 wipe_devscip-shell shell shell-project 0.0.0 wipe_dev(). $DEV
1185 echoscip-shell system . . echo. $PWD1 | $CRYPTSETUP reencrypt $DEV --encrypt --reduce-device-size 64M -q $FAST_PBKDF_ARGON > /dev/nullscip-shell filesystem . . `/dev/null`. 2>&1 && failscip-shell shell shell-project 0.0.0 fail().
1186 echoscip-shell system . . echo. $PWD1 | $CRYPTSETUP reencrypt --encrypt --reduce-device-size 8M --init-only -q $FAST_PBKDF_ARGON $DEV || failscip-shell shell shell-project 0.0.0 fail().
1187 resize_filescip-shell shell shell-project 0.0.0 resize_file(). $DEVBIG -512
1188 echoscip-shell system . . echo. $PWD1 | $CRYPTSETUP reencrypt -q $DEV 2> /dev/nullscip-shell filesystem . . `/dev/null`. && failscip-shell shell shell-project 0.0.0 fail().
1189 resize_filescip-shell shell shell-project 0.0.0 resize_file(). $DEVBIG 512
1190 wipe_devscip-shell shell shell-project 0.0.0 wipe_dev(). $DEV
1191 echoscip-shell system . . echo. $PWD1 | $CRYPTSETUP reencrypt $DEV --encrypt -c aes-cbc-essiv:sha256 -s 128 --offset 32760 --reduce-device-size 8M -q $FAST_PBKDF_ARGON --init-only >/dev/nullscip-shell filesystem . . `/dev/null`. 2>&1 && failscip-shell shell shell-project 0.0.0 fail().
1192 # data offset at 21MiB
1193 echoscip-shell system . . echo. $PWD1 | $CRYPTSETUP reencrypt $DEV --encrypt --header $IMG_HDR --offset 43008 --reduce-device-size 21M -q $FAST_PBKDF_ARGON || failscip-shell shell shell-project 0.0.0 fail().
1194 check_hashscip-shell shell shell-project 0.0.0 check_hash(). $PWD1 $HASH6 $IMG_HDR
1195 $CRYPTSETUP luksHeaderRestore --header-backup-file $IMG_HDR $DEV -q || failscip-shell shell shell-project 0.0.0 fail().
1196 check_hashscip-shell shell shell-project 0.0.0 check_hash(). $PWD1 $HASH6
1197
1198 # Device activation after encryption initialization
1199 wipe_devscip-shell shell shell-project 0.0.0 wipe_dev(). $DEV
1200 echoscip-shell system . . echo. $PWD1 | $CRYPTSETUP reencrypt $DEV --encrypt --init-only -c aes-cbc-essiv:sha256 -s 128 -S11 --reduce-device-size 8M -q $FAST_PBKDF_ARGON $DEV_NAME >/dev/nullscip-shell filesystem . . `/dev/null`. || failscip-shell shell shell-project 0.0.0 fail().
1201 $CRYPTSETUP status $DEV_NAME >/dev/nullscip-shell filesystem . . `/dev/null`. 2>&1 || failscip-shell shell shell-project 0.0.0 fail().
1202 check_hash_devscip-shell shell shell-project 0.0.0 check_hash_dev(). /dev/mapper/$DEV_NAME $HASH5
1203 echoscip-shell system . . echo. $PWD1 | $CRYPTSETUP reencrypt --resume-only $DEV -q || failscip-shell shell shell-project 0.0.0 fail().
1204 check_hash_devscip-shell shell shell-project 0.0.0 check_hash_dev(). /dev/mapper/$DEV_NAME $HASH5
1205
1206 echoscip-shell system . . echo. $PWD1 | $CRYPTSETUP reencrypt $DEV --encrypt -c aes-cbc-essiv:sha256 -s 128 --reduce-device-size 8M -q $FAST_PBKDF_ARGON $DEV_NAME 2>/dev/nullscip-shell filesystem . . `/dev/null`. && failscip-shell shell shell-project 0.0.0 fail().
1207 $CRYPTSETUP close $DEV_NAME
1208 check_hash_headscip-shell shell shell-project 0.0.0 check_hash_head(). $PWD1 $((56*1024*2)) $HASH5
1209
1210 # Device activation using key file
1211 wipe_devscip-shell shell shell-project 0.0.0 wipe_dev(). $DEV
1212 echoscip-shell system . . echo. -n $PWD1 > $KEY1
1213 $CRYPTSETUP reencrypt $DEV --encrypt --init-only -c aes-cbc-essiv:sha256 -s 128 --reduce-device-size 8M --key-file $KEY1 -q $FAST_PBKDF_ARGON $DEV_NAME >/dev/nullscip-shell filesystem . . `/dev/null`. || failscip-shell shell shell-project 0.0.0 fail().
1214 $CRYPTSETUP status $DEV_NAME >/dev/nullscip-shell filesystem . . `/dev/null`. 2>&1 || failscip-shell shell shell-project 0.0.0 fail().
1215 $CRYPTSETUP close $DEV_NAME
1216 echoscip-shell system . . echo. $PWD1 | $CRYPTSETUP open $DEV --test-passphrase || failscip-shell shell shell-project 0.0.0 fail().
1217
1218 # Small device encryption test
1219 preparebigscip-shell shell shell-project 0.0.0 preparebig(). 65
1220 # wipe only 1st MiB (final data size after encryption)
1221 wipe_devscip-shell shell shell-project 0.0.0 wipe_dev(). $DEV 1
1222 check_hash_dev_headscip-shell shell shell-project 0.0.0 check_hash_dev_head(). $DEV 2048 $HASH2
1223 echoscip-shell system . . echo. $PWD1 | $CRYPTSETUP reencrypt $DEV --encrypt --reduce-device-size 64M -q $FAST_PBKDF_ARGON || failscip-shell shell shell-project 0.0.0 fail().
1224 check_hash_headscip-shell shell shell-project 0.0.0 check_hash_head(). $PWD1 2048 $HASH2
1225
1226 wipe_dev_headscip-shell shell shell-project 0.0.0 wipe_dev_head(). $DEV 1
1227 echoscip-shell system . . echo. $PWD1 | $CRYPTSETUP reencrypt $DEV --encrypt --reduce-device-size 64M --init-only -q $FAST_PBKDF_ARGON $DEV_NAME >/dev/nullscip-shell filesystem . . `/dev/null`. || failscip-shell shell shell-project 0.0.0 fail().
1228 check_hash_dev_headscip-shell shell shell-project 0.0.0 check_hash_dev_head(). /dev/mapper/$DEV_NAME 2048 $HASH2
1229 echoscip-shell system . . echo. $PWD1 | $CRYPTSETUP reencrypt $DEV -q || failscip-shell shell shell-project 0.0.0 fail().
1230 check_hash_dev_headscip-shell shell shell-project 0.0.0 check_hash_dev_head(). /dev/mapper/$DEV_NAME 2048 $HASH2
1231 $CRYPTSETUP close $DEV_NAME || failscip-shell shell shell-project 0.0.0 fail().
1232
1233 # encryption with both data shift and reduced data size
1234 prepare_linear_devscip-shell shell shell-project 0.0.0 prepare_linear_dev(). 65
1235
1236 # --reduce-device-size + --device-size (1MiB+512B) is larger than real device size
1237 echoscip-shell system . . echo. $PWD1 | $CRYPTSETUP reencrypt $DEV --encrypt --init-only --device-size 2049s --reduce-device-size 64M -q $FAST_PBKDF_ARGON >/dev/nullscip-shell filesystem . . `/dev/null`. 2>&1 && failscip-shell shell shell-project 0.0.0 fail().
1238 $CRYPTSETUP isLuks --type luks2 $DEV && failscip-shell shell shell-project 0.0.0 fail().
1239 # no changes in data device
1240 check_hash_dev_headscip-shell shell shell-project 0.0.0 check_hash_dev_head(). $DEV 2048 $HASH2
1241
1242 # --reduce-device-size (1MiB+8KiB) + --device-size (64MiB - (8KiB-512B)) is larger than real device size
1243 echoscip-shell system . . echo. $PWD1 | $CRYPTSETUP reencrypt $DEV --encrypt --init-only --device-size 131057s --reduce-device-size 2064s -q $FAST_PBKDF_ARGON >/dev/nullscip-shell filesystem . . `/dev/null`. 2>&1 && failscip-shell shell shell-project 0.0.0 fail().
1244 $CRYPTSETUP isLuks --type luks2 $DEV && failscip-shell shell shell-project 0.0.0 fail().
1245 # no changes in data device
1246 check_hash_dev_headscip-shell shell shell-project 0.0.0 check_hash_dev_head(). $DEV 2048 $HASH2
1247
1248 echoscip-shell system . . echo. $PWD1 | $CRYPTSETUP reencrypt $DEV --encrypt --device-size 1M --reduce-device-size 32M -q $FAST_PBKDF_ARGON || failscip-shell shell shell-project 0.0.0 fail().
1249 check_hash_headscip-shell shell shell-project 0.0.0 check_hash_head(). $PWD1 2048 $HASH2
1250
1251 # test limit values (--device-size + --reduce-device-size = real device size)
1252 wipe_dev_headscip-shell shell shell-project 0.0.0 wipe_dev_head(). $DEV 43
1253 echoscip-shell system . . echo. $PWD1 | $CRYPTSETUP reencrypt $DEV --encrypt --device-size 43M --reduce-device-size 22M -q $FAST_PBKDF_ARGON || failscip-shell shell shell-project 0.0.0 fail().
1254 check_hash_headscip-shell shell shell-project 0.0.0 check_hash_head(). $PWD1 88064 $HASH6
1255
1256 wipe_dev_headscip-shell shell shell-project 0.0.0 wipe_dev_head(). $DEV 1
1257 # check reencryption code does not touch data in-between --device-size and --reduce-device-size
1258 # data device: [ reduce-device-size / 2 ] [ device-size ] [ error minefield ] [ reduce-device-size / 2]
1259 ERROFFSET=34816
1260 ERRLENGTH=65536
1261 error_ioscip-shell shell shell-project 0.0.0 error_io(). $OVRDEV $OLD_DEV $ERROFFSET $ERRLENGTH
1262 echoscip-shell system . . echo. $PWD1 | $CRYPTSETUP reencrypt $DEV --encrypt --device-size 1M --reduce-device-size 32M -q $FAST_PBKDF_ARGON || failscip-shell shell shell-project 0.0.0 fail().
1263 fix_writesscip-shell shell shell-project 0.0.0 fix_writes(). $OVRDEV $OLD_DEV
1264 check_hash_headscip-shell shell shell-project 0.0.0 check_hash_head(). $PWD1 2048 $HASH2
1265
1266 wipe_dev_headscip-shell shell shell-project 0.0.0 wipe_dev_head(). $DEV 43
1267
1268 ERROFFSET=104448
1269 ERRLENGTH=12288
1270 # data device: [ reduce-device-size / 2 ] [ device-size ] [ error minefield ] [ reduce-device-size / 2]
1271 error_ioscip-shell shell shell-project 0.0.0 error_io(). $OVRDEV $OLD_DEV $ERROFFSET $ERRLENGTH
1272 echoscip-shell system . . echo. $PWD1 | $CRYPTSETUP reencrypt $DEV --encrypt --device-size 43M --reduce-device-size 16M -q $FAST_PBKDF_ARGON || failscip-shell shell shell-project 0.0.0 fail().
1273 fix_writesscip-shell shell shell-project 0.0.0 fix_writes(). $OVRDEV $OLD_DEV
1274 check_hash_headscip-shell shell shell-project 0.0.0 check_hash_head(). $PWD1 88064 $HASH6
1275
1276 echoscip-shell system . . echo. "[3] Encryption with detached header"
1277 preparebigscip-shell shell shell-project 0.0.0 preparebig(). 256
1278 wipe_devscip-shell shell shell-project 0.0.0 wipe_dev(). $DEV
1279 echoscip-shell system . . echo. $PWD1 | $CRYPTSETUP reencrypt --encrypt -c aes-cbc-essiv:sha256 -s 128 --header $IMG_HDR -q $FAST_PBKDF_ARGON $DEV || failscip-shell shell shell-project 0.0.0 fail().
1280 check_hashscip-shell shell shell-project 0.0.0 check_hash(). $PWD1 $HASH3 $IMG_HDR
1281 wipe_devscip-shell shell shell-project 0.0.0 wipe_dev(). $DEV
1282 rmscip-shell system . . rm. -f $IMG_HDR
1283 echoscip-shell system . . echo. $PWD1 | $CRYPTSETUP reencrypt --encrypt --resilience journal --header $IMG_HDR -q $FAST_PBKDF_ARGON $DEV || failscip-shell shell shell-project 0.0.0 fail().
1284 check_hashscip-shell shell shell-project 0.0.0 check_hash(). $PWD1 $HASH3 $IMG_HDR
1285 wipe_devscip-shell shell shell-project 0.0.0 wipe_dev(). $DEV
1286 rmscip-shell system . . rm. -f $IMG_HDR
1287 echoscip-shell system . . echo. $PWD1 | $CRYPTSETUP reencrypt --encrypt -c twofish-cbc-essiv:sha256 -s 128 --resilience none --header $IMG_HDR -q $FAST_PBKDF_ARGON $DEV || failscip-shell shell shell-project 0.0.0 fail().
1288 check_hashscip-shell shell shell-project 0.0.0 check_hash(). $PWD1 $HASH3 $IMG_HDR
1289 wipe_devscip-shell shell shell-project 0.0.0 wipe_dev(). $DEV
1290 rmscip-shell system . . rm. -f $IMG_HDR
1291 echoscip-shell system . . echo. $PWD1 | $CRYPTSETUP reencrypt --encrypt -c serpent-xts-plain --resilience checksum --header $IMG_HDR -q $FAST_PBKDF_ARGON $DEV || failscip-shell shell shell-project 0.0.0 fail().
1292 check_hashscip-shell shell shell-project 0.0.0 check_hash(). $PWD1 $HASH3 $IMG_HDR
1293 rmscip-shell system . . rm. -f $IMG_HDR
1294
1295 # Device activation after encryption initialization
1296 wipe_devscip-shell shell shell-project 0.0.0 wipe_dev(). $DEV
1297 echoscip-shell system . . echo. $PWD1 | $CRYPTSETUP reencrypt --encrypt --init-only -c aes-cbc-essiv:sha256 -s 128 --header $IMG_HDR -q $FAST_PBKDF_ARGON $DEV $DEV_NAME >/dev/nullscip-shell filesystem . . `/dev/null`. || failscip-shell shell shell-project 0.0.0 fail().
1298 $CRYPTSETUP status $DEV_NAME >/dev/nullscip-shell filesystem . . `/dev/null`. 2>&1 || failscip-shell shell shell-project 0.0.0 fail().
1299 check_hash_devscip-shell shell shell-project 0.0.0 check_hash_dev(). /dev/mapper/$DEV_NAME $HASH3
1300 echoscip-shell system . . echo. $PWD1 | $CRYPTSETUP reencrypt --resume-only --header $IMG_HDR --active-name $DEV_NAME -q || failscip-shell shell shell-project 0.0.0 fail().
1301 check_hash_devscip-shell shell shell-project 0.0.0 check_hash_dev(). /dev/mapper/$DEV_NAME $HASH3
1302 echoscip-shell system . . echo. $PWD1 | $CRYPTSETUP reencrypt $DEV --encrypt -c aes-cbc-essiv:sha256 -s 128 --reduce-device-size 8M -q $FAST_PBKDF_ARGON $DEV_NAME 2>/dev/nullscip-shell filesystem . . `/dev/null`. && failscip-shell shell shell-project 0.0.0 fail().
1303 $CRYPTSETUP close $DEV_NAME
1304 check_hashscip-shell shell shell-project 0.0.0 check_hash(). $PWD1 $HASH3 $IMG_HDR
1305 rmscip-shell system . . rm. -f $IMG_HDR
1306
1307 # Device encryption with data offset set in detached header
1308 wipe_devscip-shell shell shell-project 0.0.0 wipe_dev(). $DEV
1309 ddscip-shell system . . dd. if=/dev/urandomscip-shell filesystem . . `/dev/urandom`. of=$DEV bs=512 count=32768 >/dev/nullscip-shell filesystem . . `/dev/null`. 2>&1
1310 echoscip-shell system . . echo. $PWD1 | $CRYPTSETUP reencrypt --encrypt --header $IMG_HDR --offset 32768 -q $FAST_PBKDF_ARGON $DEV || failscip-shell shell shell-project 0.0.0 fail().
1311 check_hashscip-shell shell shell-project 0.0.0 check_hash(). $PWD1 $HASH9 $IMG_HDR
1312 rmscip-shell system . . rm. -f $IMG_HDR
1313
1314 # Device activation using key file
1315 wipe_devscip-shell shell shell-project 0.0.0 wipe_dev(). $DEV
1316 echoscip-shell system . . echo. -n $PWD1 > $KEY1
1317 $CRYPTSETUP reencrypt $DEV --encrypt --init-only -c aes-cbc-essiv:sha256 -s 128 --header $IMG_HDR --key-file $KEY1 -q $FAST_PBKDF_ARGON $DEV_NAME >/dev/nullscip-shell filesystem . . `/dev/null`. || failscip-shell shell shell-project 0.0.0 fail().
1318 $CRYPTSETUP status $DEV_NAME >/dev/nullscip-shell filesystem . . `/dev/null`. 2>&1 || failscip-shell shell shell-project 0.0.0 fail().
1319 $CRYPTSETUP close $DEV_NAME
1320 echoscip-shell system . . echo. $PWD1 | $CRYPTSETUP open --header $IMG_HDR $DEV --test-passphrase || failscip-shell shell shell-project 0.0.0 fail().
1321
1322 # Encrypt without size reduction must not allow header device same as data device
1323 wipe_dev_headscip-shell shell shell-project 0.0.0 wipe_dev_head(). $DEV 1
1324 echoscip-shell system . . echo. $PWD1 | $CRYPTSETUP reencrypt $DEV --type luks2 --encrypt --header $DEV -q $FAST_PBKDF_ARGON 2>/dev/nullscip-shell filesystem . . `/dev/null`. && failscip-shell shell shell-project 0.0.0 fail().
1325 $CRYPTSETUP isLUKS $DEV 2>/dev/nullscip-shell filesystem . . `/dev/null`. && failscip-shell shell shell-project 0.0.0 fail().
1326 lnscip-shell system . . ln. -s $DEV $DEV_LINK || failscip-shell shell shell-project 0.0.0 fail().
1327 echoscip-shell system . . echo. $PWD1 | $CRYPTSETUP reencrypt $DEV --type luks2 --encrypt --header $DEV_LINK -q $FAST_PBKDF_ARGON 2>/dev/nullscip-shell filesystem . . `/dev/null`. && failscip-shell shell shell-project 0.0.0 fail().
1328 $CRYPTSETUP isLUKS $DEV 2>/dev/nullscip-shell filesystem . . `/dev/null`. && failscip-shell shell shell-project 0.0.0 fail().
1329 rmscip-shell system . . rm. -f $DEV_LINK || failscip-shell shell shell-project 0.0.0 fail().
1330
1331 ddscip-shell system . . dd. if=/dev/zeroscip-shell filesystem . . `/dev/zero`. of=$IMG bs=4k count=1 >/dev/nullscip-shell filesystem . . `/dev/null`. 2>&1
1332 echoscip-shell system . . echo. $PWD1 | $CRYPTSETUP reencrypt $IMG --type luks2 --encrypt --header $IMG -q $FAST_PBKDF_ARGON 2>/dev/nullscip-shell filesystem . . `/dev/null`. && failscip-shell shell shell-project 0.0.0 fail().
1333 $CRYPTSETUP isLUKS $IMG 2>/dev/nullscip-shell filesystem . . `/dev/null`. && failscip-shell shell shell-project 0.0.0 fail().
1334 lnscip-shell system . . ln. -s $IMG $DEV_LINK || failscip-shell shell shell-project 0.0.0 fail().
1335 echoscip-shell system . . echo. $PWD1 | $CRYPTSETUP reencrypt $IMG --type luks2 --encrypt --header $DEV_LINK -q $FAST_PBKDF_ARGON 2>/dev/nullscip-shell filesystem . . `/dev/null`. && failscip-shell shell shell-project 0.0.0 fail().
1336 $CRYPTSETUP isLUKS $IMG 2>/dev/nullscip-shell filesystem . . `/dev/null`. && failscip-shell shell shell-project 0.0.0 fail().
1337
1338 echoscip-shell system . . echo. "[4] Reencryption with detached header"
1339 wipescip-shell shell shell-project 0.0.0 wipe(). $PWD1 $IMG_HDR
1340 echoscip-shell system . . echo. $PWD1 | $CRYPTSETUP reencrypt -c aes-cbc-essiv:sha256 -s 128 --header $IMG_HDR -q $FAST_PBKDF_ARGON $DEV || failscip-shell shell shell-project 0.0.0 fail().
1341 check_hashscip-shell shell shell-project 0.0.0 check_hash(). $PWD1 $HASH3 $IMG_HDR
1342 echoscip-shell system . . echo. $PWD1 | $CRYPTSETUP reencrypt --resilience journal --header $IMG_HDR -q $FAST_PBKDF_ARGON $DEV || failscip-shell shell shell-project 0.0.0 fail().
1343 check_hashscip-shell shell shell-project 0.0.0 check_hash(). $PWD1 $HASH3 $IMG_HDR
1344 echoscip-shell system . . echo. $PWD1 | $CRYPTSETUP reencrypt -c twofish-cbc-essiv:sha256 -s 128 --resilience none --header $IMG_HDR -q $FAST_PBKDF_ARGON $DEV || failscip-shell shell shell-project 0.0.0 fail().
1345 check_hashscip-shell shell shell-project 0.0.0 check_hash(). $PWD1 $HASH3 $IMG_HDR
1346 echoscip-shell system . . echo. $PWD1 | $CRYPTSETUP reencrypt -c serpent-xts-plain --resilience checksum --header $IMG_HDR -q $FAST_PBKDF_ARGON $DEV || failscip-shell shell shell-project 0.0.0 fail().
1347 check_hashscip-shell shell shell-project 0.0.0 check_hash(). $PWD1 $HASH3 $IMG_HDR
1348 # trivial check for detached header misuse
1349 ddscip-shell system . . dd. if=/dev/zeroscip-shell filesystem . . `/dev/zero`. of=$IMG bs=4k count=1 >/dev/nullscip-shell filesystem . . `/dev/null`. 2>&1
1350 echoscip-shell system . . echo. $PWD1 | $CRYPTSETUP luksFormat --type luks2 -c aes-cbc-essiv:sha256 -s 128 --header $IMG_HDR -q $FAST_PBKDF_ARGON $DEV || failscip-shell shell shell-project 0.0.0 fail().
1351 echoscip-shell system . . echo. $PWD1 | $CRYPTSETUP open $IMG $DEV_NAME --header $IMG_HDR || failscip-shell shell shell-project 0.0.0 fail().
1352 echoscip-shell system . . echo. $PWD1 | $CRYPTSETUP open $DEV $DEV_NAME2 --header $IMG_HDR || failscip-shell shell shell-project 0.0.0 fail().
1353 echoscip-shell system . . echo. $PWD1 | $CRYPTSETUP reencrypt --active-name $DEV_NAME --header $IMG_HDR -q || failscip-shell shell shell-project 0.0.0 fail().
1354 # key description mismatch in active device
1355 echoscip-shell system . . echo. $PWD1 | $CRYPTSETUP reencrypt --active-name $DEV_NAME2 --header $IMG_HDR >/dev/nullscip-shell filesystem . . `/dev/null`. 2>&1 && failscip-shell shell shell-project 0.0.0 fail().
1356 # also check it can abort initialization in this case
1357 $CRYPTSETUP luksDump $IMG_HDR | grepscip-shell system . . grep. -q "online-reencrypt" && failscip-shell shell shell-project 0.0.0 fail().
1358 $CRYPTSETUP close $DEV_NAME || failscip-shell shell shell-project 0.0.0 fail().
1359 $CRYPTSETUP close $DEV_NAME2 || failscip-shell shell shell-project 0.0.0 fail().
1360
1361 echoscip-shell system . . echo. "[5] Decryption with detached header"
1362 echoscip-shell system . . echo. $PWD1 | $CRYPTSETUP luksFormat --type luks2 --sector-size 512 -c aes-cbc-essiv:sha256 -s 128 --header $IMG_HDR -q $FAST_PBKDF_ARGON $DEV || failscip-shell shell shell-project 0.0.0 fail().
1363 wipescip-shell shell shell-project 0.0.0 wipe(). $PWD1 $IMG_HDR
1364 echoscip-shell system . . echo. $PWD1 | $CRYPTSETUP reencrypt -q --decrypt --header $IMG_HDR $DEV || failscip-shell shell shell-project 0.0.0 fail().
1365 check_hash_devscip-shell shell shell-project 0.0.0 check_hash_dev(). $DEV $HASH3
1366 echoscip-shell system . . echo. $PWD1 | $CRYPTSETUP luksFormat --type luks2 --header $IMG_HDR -q $FAST_PBKDF_ARGON $DEV || failscip-shell shell shell-project 0.0.0 fail().
1367 wipescip-shell shell shell-project 0.0.0 wipe(). $PWD1 $IMG_HDR
1368 echoscip-shell system . . echo. $PWD1 | $CRYPTSETUP reencrypt -q --decrypt --resilience journal --header $IMG_HDR $DEV || failscip-shell shell shell-project 0.0.0 fail().
1369 check_hash_devscip-shell shell shell-project 0.0.0 check_hash_dev(). $DEV $HASH3
1370 echoscip-shell system . . echo. $PWD1 | $CRYPTSETUP luksFormat --type luks2 -c twofish-cbc-essiv:sha256 -s 128 --header $IMG_HDR -q $FAST_PBKDF_ARGON $DEV || failscip-shell shell shell-project 0.0.0 fail().
1371 wipescip-shell shell shell-project 0.0.0 wipe(). $PWD1 $IMG_HDR
1372 echoscip-shell system . . echo. $PWD1 | $CRYPTSETUP reencrypt -q --decrypt --resilience none --header $IMG_HDR $DEV || failscip-shell shell shell-project 0.0.0 fail().
1373 check_hash_devscip-shell shell shell-project 0.0.0 check_hash_dev(). $DEV $HASH3
1374 echoscip-shell system . . echo. $PWD1 | $CRYPTSETUP luksFormat --type luks2 -c serpent-xts-plain --header $IMG_HDR -q $FAST_PBKDF_ARGON $DEV || failscip-shell shell shell-project 0.0.0 fail().
1375 wipescip-shell shell shell-project 0.0.0 wipe(). $PWD1 $IMG_HDR
1376 echoscip-shell system . . echo. $PWD1 | $CRYPTSETUP reencrypt -q --decrypt --resilience checksum --header $IMG_HDR $DEV || failscip-shell shell shell-project 0.0.0 fail().
1377 check_hash_devscip-shell shell shell-project 0.0.0 check_hash_dev(). $DEV $HASH3
1378
1379 # check deferred remove works as expected after decryption
1380 echoscip-shell system . . echo. $PWD1 | $CRYPTSETUP luksFormat --type luks2 --sector-size 512 -c serpent-xts-plain --header $IMG_HDR -q $FAST_PBKDF_ARGON $DEV || failscip-shell shell shell-project 0.0.0 fail().
1381 open_cryptscip-shell shell shell-project 0.0.0 open_crypt(). $PWD1 $IMG_HDR
1382 dmsetup create $DEV_NAME2 --table "0 1 linear /dev/mapper/$DEV_NAME 0" || failscip-shell shell shell-project 0.0.0 fail().
1383 echoscip-shell system . . echo. $PWD1 | $CRYPTSETUP reencrypt -q --decrypt --resilience checksum --header $IMG_HDR --active-name $DEV_NAME || failscip-shell shell shell-project 0.0.0 fail().
1384 $CRYPTSETUP status $DEV_NAME >/dev/nullscip-shell filesystem . . `/dev/null`. || failscip-shell shell shell-project 0.0.0 fail().
1385 dmsetup remove --retry $DEV_NAME2
1386 $CRYPTSETUP status $DEV_NAME >/dev/nullscip-shell filesystem . . `/dev/null`. 2>&1 && failscip-shell shell shell-project 0.0.0 fail().
1387
1388 # check tool can block some funny user ideas
1389 preparebigscip-shell shell shell-project 0.0.0 preparebig(). 64
1390 lnscip-shell system . . ln. -s $DEV $DEV_LINK || failscip-shell shell shell-project 0.0.0 fail().
1391 echoscip-shell system . . echo. $PWD1 | $CRYPTSETUP luksFormat --type luks2 -c serpent-xts-plain -q $FAST_PBKDF_ARGON $DEV || failscip-shell shell shell-project 0.0.0 fail().
1392 echoscip-shell system . . echo. $PWD1 | $CRYPTSETUP reencrypt --decrypt $DEV -q 2>/dev/nullscip-shell filesystem . . `/dev/null`. && failscip-shell shell shell-project 0.0.0 fail().
1393 echoscip-shell system . . echo. $PWD1 | $CRYPTSETUP reencrypt --decrypt $DEV --header $DEV -q 2>/dev/nullscip-shell filesystem . . `/dev/null`. && failscip-shell shell shell-project 0.0.0 fail().
1394 echoscip-shell system . . echo. $PWD1 | $CRYPTSETUP reencrypt --decrypt $DEV --header $DEV_LINK -q 2>/dev/nullscip-shell filesystem . . `/dev/null`. && failscip-shell shell shell-project 0.0.0 fail().
1395 open_cryptscip-shell shell shell-project 0.0.0 open_crypt(). $PWD1
1396 echoscip-shell system . . echo. $PWD1 | $CRYPTSETUP reencrypt --decrypt --active-name $DEV_NAME -q 2>/dev/nullscip-shell filesystem . . `/dev/null`. && failscip-shell shell shell-project 0.0.0 fail().
1397 echoscip-shell system . . echo. $PWD1 | $CRYPTSETUP reencrypt --decrypt --active-name $DEV_NAME --header $DEV -q 2>/dev/nullscip-shell filesystem . . `/dev/null`. && failscip-shell shell shell-project 0.0.0 fail().
1398 echoscip-shell system . . echo. $PWD1 | $CRYPTSETUP reencrypt --decrypt --active-name $DEV_NAME --header $DEV_LINK -q 2>/dev/nullscip-shell filesystem . . `/dev/null`. && failscip-shell shell shell-project 0.0.0 fail().
1399 $CRYPTSETUP status $DEV_NAME | grepscip-shell system . . grep. -q "reencryption: in-progress" && failscip-shell shell shell-project 0.0.0 fail().
1400 $CRYPTSETUP close $DEV_NAME
1401
1402 # yet another funny idea
1403 rmscip-shell system . . rm. -f $IMG_HDR
1404 $CRYPTSETUP luksHeaderBackup --header-backup-file $IMG_HDR $DEV || failscip-shell shell shell-project 0.0.0 fail().
1405 chmodscip-shell system . . chmod. +w $IMG_HDR || failscip-shell shell shell-project 0.0.0 fail().
1406 command -v wipefs >/dev/nullscip-shell filesystem . . `/dev/null`. && {
1407 wipefsscip-shell system . . wipefs. -a $DEV >/dev/nullscip-shell filesystem . . `/dev/null`. 2>&1 || failscip-shell shell shell-project 0.0.0 fail().
1408 }
1409 open_cryptscip-shell shell shell-project 0.0.0 open_crypt(). $PWD1 $IMG_HDR
1410 echoscip-shell system . . echo. $PWD1 | $CRYPTSETUP reencrypt --active-name $DEV_NAME --decrypt --header $IMG_HDR -q 2>/dev/nullscip-shell filesystem . . `/dev/null`. && failscip-shell shell shell-project 0.0.0 fail().
1411 $CRYPTSETUP status $DEV_NAME | grepscip-shell system . . grep. -q "reencryption: in-progress" && failscip-shell shell shell-project 0.0.0 fail().
1412 $CRYPTSETUP close $DEV_NAME || failscip-shell shell shell-project 0.0.0 fail().
1413
1414 if ! dm_delay_featuresscip-shell shell shell-project 0.0.0 dm_delay_features().; then
1415 echoscip-shell system . . echo. "dm-delay target is missing, skipping recovery tests."
1416 remove_mappingscip-shell shell shell-project 0.0.0 remove_mapping().
1417 exit 0
1418 fi
1419
1420 echoscip-shell system . . echo. "[6] Reencryption recovery"
1421 # (check opt-io size optimization in reencryption code does not affect recovery)
1422 # device with opt-io size 32k
1423 prepare_linear_devscip-shell shell shell-project 0.0.0 prepare_linear_dev(). 32 opt_blks=64 $OPT_XFERLEN_EXP
1424 OFFSET=8192
1425
1426 echoscip-shell system . . echo. "sector size 512->512"
1427
1428 get_error_offsetsscip-shell shell shell-project 0.0.0 get_error_offsets(). 32 $OFFSET
1429 echoscip-shell system . . echo. $PWD1 | $CRYPTSETUP -q luksFormat --type luks2 --sector-size 512 --offset $OFFSET $FAST_PBKDF_ARGON $DEV || failscip-shell shell shell-project 0.0.0 fail().
1430 wipescip-shell shell shell-project 0.0.0 wipe(). $PWD1
1431
1432 echoscip-shell system . . echo. "ERR writes to sectors [$ERROFFSET,$(($ERROFFSET+$ERRLENGTH-1))]"
1433 reencrypt_recoverscip-shell shell shell-project 0.0.0 reencrypt_recover(). 512 checksum $HASH1
1434 reencrypt_recoverscip-shell shell shell-project 0.0.0 reencrypt_recover(). 512 journal $HASH1
1435
1436 if [scip-shell system . . `[`. -n "$DM_SECTOR_SIZE" ]; then
1437 echoscip-shell system . . echo. "sector size 512->4096"
1438
1439 get_error_offsetsscip-shell shell shell-project 0.0.0 get_error_offsets(). 32 $OFFSET 4096
1440 echoscip-shell system . . echo. $PWD1 | $CRYPTSETUP -q luksFormat --type luks2 --sector-size 512 --offset $OFFSET $FAST_PBKDF_ARGON $DEV || failscip-shell shell shell-project 0.0.0 fail().
1441 wipescip-shell shell shell-project 0.0.0 wipe(). $PWD1
1442
1443 echoscip-shell system . . echo. "ERR writes to sectors [$ERROFFSET,$(($ERROFFSET+$ERRLENGTH-1))]"
1444 reencrypt_recoverscip-shell shell shell-project 0.0.0 reencrypt_recover(). 4096 checksum $HASH1
1445 echoscip-shell system . . echo. $PWD1 | $CRYPTSETUP -q luksFormat --type luks2 --sector-size 512 --offset $OFFSET $FAST_PBKDF_ARGON $DEV || failscip-shell shell shell-project 0.0.0 fail().
1446 wipescip-shell shell shell-project 0.0.0 wipe(). $PWD1
1447 reencrypt_recoverscip-shell shell shell-project 0.0.0 reencrypt_recover(). 4096 journal $HASH1
1448
1449 echoscip-shell system . . echo. "sector size 4096->4096"
1450
1451 get_error_offsetsscip-shell shell shell-project 0.0.0 get_error_offsets(). 32 $OFFSET 4096
1452 echoscip-shell system . . echo. $PWD1 | $CRYPTSETUP -q luksFormat --type luks2 -s 128 --sector-size 4096 -c aes-cbc-essiv:sha256 --offset $OFFSET $FAST_PBKDF_ARGON $DEV || failscip-shell shell shell-project 0.0.0 fail().
1453 wipescip-shell shell shell-project 0.0.0 wipe(). $PWD1
1454
1455 echoscip-shell system . . echo. "ERR writes to sectors [$ERROFFSET,$(($ERROFFSET+$ERRLENGTH-1))]"
1456 reencrypt_recoverscip-shell shell shell-project 0.0.0 reencrypt_recover(). 4096 checksum $HASH1
1457 reencrypt_recoverscip-shell shell shell-project 0.0.0 reencrypt_recover(). 4096 journal $HASH1
1458 fi
1459
1460 echoscip-shell system . . echo. "[7] Reencryption recovery (online i/o error)"
1461
1462 echoscip-shell system . . echo. "sector size 512->512"
1463
1464 get_error_offsetsscip-shell shell shell-project 0.0.0 get_error_offsets(). 32 $OFFSET
1465 echoscip-shell system . . echo. $PWD1 | $CRYPTSETUP -q luksFormat --type luks2 --sector-size 512 --offset $OFFSET $FAST_PBKDF_ARGON $DEV || failscip-shell shell shell-project 0.0.0 fail().
1466 wipescip-shell shell shell-project 0.0.0 wipe(). $PWD1
1467
1468 echoscip-shell system . . echo. "ERR writes to sectors [$ERROFFSET,$(($ERROFFSET+$ERRLENGTH-1))]"
1469 reencrypt_recover_onlinescip-shell shell shell-project 0.0.0 reencrypt_recover_online(). 512 checksum $HASH1
1470 reencrypt_recover_onlinescip-shell shell shell-project 0.0.0 reencrypt_recover_online(). 512 journal $HASH1
1471
1472 if [scip-shell system . . `[`. -n "$DM_SECTOR_SIZE" ]; then
1473 echoscip-shell system . . echo. "sector size 512->4096"
1474
1475 get_error_offsetsscip-shell shell shell-project 0.0.0 get_error_offsets(). 32 $OFFSET 4096
1476 echoscip-shell system . . echo. $PWD1 | $CRYPTSETUP -q luksFormat --type luks2 --sector-size 512 --offset $OFFSET $FAST_PBKDF_ARGON $DEV || failscip-shell shell shell-project 0.0.0 fail().
1477 wipescip-shell shell shell-project 0.0.0 wipe(). $PWD1
1478
1479 echoscip-shell system . . echo. "ERR writes to sectors [$ERROFFSET,$(($ERROFFSET+$ERRLENGTH-1))]"
1480 reencrypt_recover_onlinescip-shell shell shell-project 0.0.0 reencrypt_recover_online(). 4096 checksum $HASH1
1481 echoscip-shell system . . echo. $PWD1 | $CRYPTSETUP -q luksFormat --type luks2 --sector-size 512 --offset $OFFSET $FAST_PBKDF_ARGON $DEV || failscip-shell shell shell-project 0.0.0 fail().
1482 wipescip-shell shell shell-project 0.0.0 wipe(). $PWD1
1483 reencrypt_recover_onlinescip-shell shell shell-project 0.0.0 reencrypt_recover_online(). 4096 journal $HASH1
1484
1485 echoscip-shell system . . echo. "sector size 4096->4096"
1486
1487 get_error_offsetsscip-shell shell shell-project 0.0.0 get_error_offsets(). 32 $OFFSET 4096
1488 echoscip-shell system . . echo. $PWD1 | $CRYPTSETUP -q luksFormat --type luks2 -s 128 --sector-size 4096 -c aes-cbc-essiv:sha256 --offset $OFFSET $FAST_PBKDF_ARGON $DEV || failscip-shell shell shell-project 0.0.0 fail().
1489 wipescip-shell shell shell-project 0.0.0 wipe(). $PWD1
1490
1491 echoscip-shell system . . echo. "ERR writes to sectors [$ERROFFSET,$(($ERROFFSET+$ERRLENGTH-1))]"
1492 reencrypt_recover_onlinescip-shell shell shell-project 0.0.0 reencrypt_recover_online(). 4096 checksum $HASH1
1493 reencrypt_recover_onlinescip-shell shell shell-project 0.0.0 reencrypt_recover_online(). 4096 journal $HASH1
1494 fi
1495
1496 if [scip-shell system . . `[`. $HAVE_KEYRING -eq 1 ]; then
1497 echoscip-shell system . . echo. "sector size 512->512 (recovery by VK)"
1498
1499 get_error_offsetsscip-shell shell shell-project 0.0.0 get_error_offsets(). 32 $OFFSET
1500 echoscip-shell system . . echo. $PWD1 | $CRYPTSETUP -q luksFormat --type luks2 --sector-size 512 --offset $OFFSET $FAST_PBKDF_ARGON $DEV || failscip-shell shell shell-project 0.0.0 fail().
1501 wipescip-shell shell shell-project 0.0.0 wipe(). $PWD1
1502
1503 echoscip-shell system . . echo. "ERR writes to sectors (recovery by VK) [$ERROFFSET,$(($ERROFFSET+$ERRLENGTH-1))]"
1504 reencrypt_recover_online_vkscip-shell shell shell-project 0.0.0 reencrypt_recover_online_vk(). 512 checksum $HASH1
1505 reencrypt_recover_online_vkscip-shell shell shell-project 0.0.0 reencrypt_recover_online_vk(). 512 journal $HASH1
1506
1507 if [scip-shell system . . `[`. -n "$DM_SECTOR_SIZE" ]; then
1508 echoscip-shell system . . echo. "sector size 512->4096"
1509
1510 get_error_offsetsscip-shell shell shell-project 0.0.0 get_error_offsets(). 32 $OFFSET 4096
1511 echoscip-shell system . . echo. $PWD1 | $CRYPTSETUP -q luksFormat --type luks2 --sector-size 512 --offset $OFFSET $FAST_PBKDF_ARGON $DEV || failscip-shell shell shell-project 0.0.0 fail().
1512 wipescip-shell shell shell-project 0.0.0 wipe(). $PWD1
1513
1514 echoscip-shell system . . echo. "ERR writes to sectors (recovery by VK) [$ERROFFSET,$(($ERROFFSET+$ERRLENGTH-1))]"
1515 reencrypt_recover_online_vkscip-shell shell shell-project 0.0.0 reencrypt_recover_online_vk(). 4096 checksum $HASH1
1516 echoscip-shell system . . echo. $PWD1 | $CRYPTSETUP -q luksFormat --type luks2 --sector-size 512 --offset $OFFSET $FAST_PBKDF_ARGON $DEV || failscip-shell shell shell-project 0.0.0 fail().
1517 wipescip-shell shell shell-project 0.0.0 wipe(). $PWD1
1518 reencrypt_recover_online_vkscip-shell shell shell-project 0.0.0 reencrypt_recover_online_vk(). 4096 journal $HASH1
1519
1520 echoscip-shell system . . echo. "sector size 4096->4096"
1521
1522 get_error_offsetsscip-shell shell shell-project 0.0.0 get_error_offsets(). 32 $OFFSET 4096
1523 echoscip-shell system . . echo. $PWD1 | $CRYPTSETUP -q luksFormat --type luks2 -s 128 --sector-size 4096 -c aes-cbc-essiv:sha256 --offset $OFFSET $FAST_PBKDF_ARGON $DEV || failscip-shell shell shell-project 0.0.0 fail().
1524 wipescip-shell shell shell-project 0.0.0 wipe(). $PWD1
1525
1526 echoscip-shell system . . echo. "ERR writes to sectors (recovery by VK) [$ERROFFSET,$(($ERROFFSET+$ERRLENGTH-1))]"
1527 reencrypt_recover_online_vkscip-shell shell shell-project 0.0.0 reencrypt_recover_online_vk(). 4096 checksum $HASH1
1528 reencrypt_recover_online_vkscip-shell shell shell-project 0.0.0 reencrypt_recover_online_vk(). 4096 journal $HASH1
1529 fi
1530 fi
1531
1532 echoscip-shell system . . echo. "[8] Reencryption with detached header recovery"
1533 prepare_linear_devscip-shell shell shell-project 0.0.0 prepare_linear_dev(). 31 opt_blks=64 $OPT_XFERLEN_EXP
1534
1535 echoscip-shell system . . echo. "sector size 512->512"
1536
1537 get_error_offsetsscip-shell shell shell-project 0.0.0 get_error_offsets(). 31 0
1538 echoscip-shell system . . echo. $PWD1 | $CRYPTSETUP -q luksFormat --type luks2 --sector-size 512 --header $IMG_HDR $FAST_PBKDF_ARGON $DEV || failscip-shell shell shell-project 0.0.0 fail().
1539 wipescip-shell shell shell-project 0.0.0 wipe(). $PWD1 $IMG_HDR
1540 check_hashscip-shell shell shell-project 0.0.0 check_hash(). $PWD1 $HASH7 $IMG_HDR
1541
1542 echoscip-shell system . . echo. "ERR writes to sectors [$ERROFFSET,$(($ERROFFSET+$ERRLENGTH-1))]"
1543 reencrypt_recoverscip-shell shell shell-project 0.0.0 reencrypt_recover(). 512 checksum $HASH7 $IMG_HDR
1544 reencrypt_recoverscip-shell shell shell-project 0.0.0 reencrypt_recover(). 512 journal $HASH7 $IMG_HDR
1545
1546 if [scip-shell system . . `[`. -n "$DM_SECTOR_SIZE" ]; then
1547 echoscip-shell system . . echo. "sector size 512->4096"
1548
1549 get_error_offsetsscip-shell shell shell-project 0.0.0 get_error_offsets(). 31 0 4096
1550 echoscip-shell system . . echo. $PWD1 | $CRYPTSETUP -q luksFormat --type luks2 --sector-size 512 --header $IMG_HDR $FAST_PBKDF_ARGON $DEV || failscip-shell shell shell-project 0.0.0 fail().
1551 wipescip-shell shell shell-project 0.0.0 wipe(). $PWD1 $IMG_HDR
1552
1553 echoscip-shell system . . echo. "ERR writes to sectors [$ERROFFSET,$(($ERROFFSET+$ERRLENGTH-1))]"
1554 reencrypt_recoverscip-shell shell shell-project 0.0.0 reencrypt_recover(). 4096 checksum $HASH7 $IMG_HDR
1555 echoscip-shell system . . echo. $PWD1 | $CRYPTSETUP -q luksFormat --type luks2 --sector-size 512 --header $IMG_HDR $FAST_PBKDF_ARGON $DEV || failscip-shell shell shell-project 0.0.0 fail().
1556 wipescip-shell shell shell-project 0.0.0 wipe(). $PWD1 $IMG_HDR
1557 reencrypt_recoverscip-shell shell shell-project 0.0.0 reencrypt_recover(). 4096 journal $HASH7 $IMG_HDR
1558
1559 echoscip-shell system . . echo. "sector size 4096->4096"
1560
1561 get_error_offsetsscip-shell shell shell-project 0.0.0 get_error_offsets(). 31 0 4096
1562 echoscip-shell system . . echo. $PWD1 | $CRYPTSETUP -q luksFormat --type luks2 --sector-size 4096 --header $IMG_HDR $FAST_PBKDF_ARGON $DEV || failscip-shell shell shell-project 0.0.0 fail().
1563 wipescip-shell shell shell-project 0.0.0 wipe(). $PWD1 $IMG_HDR
1564
1565 echoscip-shell system . . echo. "ERR writes to sectors [$ERROFFSET,$(($ERROFFSET+$ERRLENGTH-1))]"
1566 reencrypt_recoverscip-shell shell shell-project 0.0.0 reencrypt_recover(). 4096 checksum $HASH7 $IMG_HDR
1567 reencrypt_recoverscip-shell shell shell-project 0.0.0 reencrypt_recover(). 4096 journal $HASH7 $IMG_HDR
1568 fi
1569
1570 echoscip-shell system . . echo. "[9] Reencryption with detached header recovery (online i/o error)"
1571
1572 echoscip-shell system . . echo. "sector size 512->512"
1573
1574 get_error_offsetsscip-shell shell shell-project 0.0.0 get_error_offsets(). 31 0
1575 echoscip-shell system . . echo. $PWD1 | $CRYPTSETUP -q luksFormat --type luks2 --sector-size 512 --header $IMG_HDR $FAST_PBKDF_ARGON $DEV || failscip-shell shell shell-project 0.0.0 fail().
1576 wipescip-shell shell shell-project 0.0.0 wipe(). $PWD1 $IMG_HDR
1577
1578 echoscip-shell system . . echo. "ERR writes to sectors [$ERROFFSET,$(($ERROFFSET+$ERRLENGTH-1))]"
1579 reencrypt_recover_onlinescip-shell shell shell-project 0.0.0 reencrypt_recover_online(). 512 checksum $HASH7 $IMG_HDR
1580 reencrypt_recover_onlinescip-shell shell shell-project 0.0.0 reencrypt_recover_online(). 512 journal $HASH7 $IMG_HDR
1581
1582 if [scip-shell system . . `[`. -n "$DM_SECTOR_SIZE" ]; then
1583 echoscip-shell system . . echo. "sector size 512->4096"
1584
1585 get_error_offsetsscip-shell shell shell-project 0.0.0 get_error_offsets(). 31 0 4096
1586 echoscip-shell system . . echo. $PWD1 | $CRYPTSETUP -q luksFormat --type luks2 --sector-size 512 --header $IMG_HDR $FAST_PBKDF_ARGON $DEV || failscip-shell shell shell-project 0.0.0 fail().
1587 wipescip-shell shell shell-project 0.0.0 wipe(). $PWD1 $IMG_HDR
1588
1589 echoscip-shell system . . echo. "ERR writes to sectors [$ERROFFSET,$(($ERROFFSET+$ERRLENGTH-1))]"
1590 reencrypt_recover_onlinescip-shell shell shell-project 0.0.0 reencrypt_recover_online(). 4096 checksum $HASH7 $IMG_HDR
1591 echoscip-shell system . . echo. $PWD1 | $CRYPTSETUP -q luksFormat --type luks2 --sector-size 512 --header $IMG_HDR $FAST_PBKDF_ARGON $DEV || failscip-shell shell shell-project 0.0.0 fail().
1592 wipescip-shell shell shell-project 0.0.0 wipe(). $PWD1 $IMG_HDR
1593 reencrypt_recover_onlinescip-shell shell shell-project 0.0.0 reencrypt_recover_online(). 4096 journal $HASH7 $IMG_HDR
1594
1595 echoscip-shell system . . echo. "sector size 4096->4096"
1596
1597 get_error_offsetsscip-shell shell shell-project 0.0.0 get_error_offsets(). 31 0 4096
1598 echoscip-shell system . . echo. $PWD1 | $CRYPTSETUP -q luksFormat --type luks2 --sector-size 4096 --header $IMG_HDR $FAST_PBKDF_ARGON $DEV || failscip-shell shell shell-project 0.0.0 fail().
1599 wipescip-shell shell shell-project 0.0.0 wipe(). $PWD1 $IMG_HDR
1600
1601 echoscip-shell system . . echo. "ERR writes to sectors [$ERROFFSET,$(($ERROFFSET+$ERRLENGTH-1))]"
1602 reencrypt_recover_onlinescip-shell shell shell-project 0.0.0 reencrypt_recover_online(). 4096 checksum $HASH7 $IMG_HDR
1603 reencrypt_recover_onlinescip-shell shell shell-project 0.0.0 reencrypt_recover_online(). 4096 journal $HASH7 $IMG_HDR
1604 fi
1605
1606 echoscip-shell system . . echo. "[10] Encryption recovery"
1607 prepare_linear_devscip-shell shell shell-project 0.0.0 prepare_linear_dev(). 64
1608 OFFSET=$((2*1024*2))
1609
1610 echoscip-shell system . . echo. "sector size 512"
1611
1612 get_error_offsetsscip-shell shell shell-project 0.0.0 get_error_offsets(). 64 $OFFSET 512 $((62*1024*2))
1613
1614 echoscip-shell system . . echo. "ERR writes to sectors [$ERROFFSET,$(($ERROFFSET+$ERRLENGTH-1))]"
1615 encrypt_recoverscip-shell shell shell-project 0.0.0 encrypt_recover(). 512 4M $HASH8 $((60*1024*2)) $HASH4
1616
1617 if [scip-shell system . . `[`. -n "$DM_SECTOR_SIZE" ]; then
1618 echoscip-shell system . . echo. "sector size 4096"
1619
1620 get_error_offsetsscip-shell shell shell-project 0.0.0 get_error_offsets(). 64 $OFFSET 4096 $((62*1024*2))
1621
1622 echoscip-shell system . . echo. "ERR writes to sectors [$ERROFFSET,$(($ERROFFSET+$ERRLENGTH-1))]"
1623 encrypt_recoverscip-shell shell shell-project 0.0.0 encrypt_recover(). 4096 4M $HASH8 $((60*1024*2)) $HASH4
1624 fi
1625
1626 echoscip-shell system . . echo. "[11] Encryption recovery (online i/o error)"
1627
1628 echoscip-shell system . . echo. "sector size 512"
1629
1630 get_error_offsetsscip-shell shell shell-project 0.0.0 get_error_offsets(). 64 $OFFSET 512 $((62*1024*2))
1631
1632 echoscip-shell system . . echo. "ERR writes to sectors [$ERROFFSET,$(($ERROFFSET+$ERRLENGTH-1))]"
1633 encrypt_recover_onlinescip-shell shell shell-project 0.0.0 encrypt_recover_online(). 512 4M $HASH8 $((60*1024*2)) $HASH4
1634
1635 if [scip-shell system . . `[`. -n "$DM_SECTOR_SIZE" ]; then
1636 echoscip-shell system . . echo. "sector size 4096"
1637
1638 get_error_offsetsscip-shell shell shell-project 0.0.0 get_error_offsets(). 64 $OFFSET 4096 $((62*1024*2))
1639
1640 echoscip-shell system . . echo. "ERR writes to sectors [$ERROFFSET,$(($ERROFFSET+$ERRLENGTH-1))]"
1641 encrypt_recover_onlinescip-shell shell shell-project 0.0.0 encrypt_recover_online(). 4096 4M $HASH8 $((60*1024*2)) $HASH4
1642 fi
1643
1644 echoscip-shell system . . echo. "[12] Encryption with detached header recovery"
1645 prepare_linear_devscip-shell shell shell-project 0.0.0 prepare_linear_dev(). 31 opt_blks=64 $OPT_XFERLEN_EXP
1646
1647 get_error_offsetsscip-shell shell shell-project 0.0.0 get_error_offsets(). 31 0
1648
1649 echoscip-shell system . . echo. "sector size 512"
1650
1651 echoscip-shell system . . echo. "ERR writes to sectors [$ERROFFSET,$(($ERROFFSET+$ERRLENGTH-1))]"
1652 encrypt_recover_detachedscip-shell shell shell-project 0.0.0 encrypt_recover_detached(). 512 checksum $HASH7 $IMG_HDR
1653 encrypt_recover_detachedscip-shell shell shell-project 0.0.0 encrypt_recover_detached(). 512 journal $HASH7 $IMG_HDR
1654
1655 if [scip-shell system . . `[`. -n "$DM_SECTOR_SIZE" ]; then
1656 get_error_offsetsscip-shell shell shell-project 0.0.0 get_error_offsets(). 31 0 4096
1657
1658 echoscip-shell system . . echo. "sector size 4096"
1659
1660 echoscip-shell system . . echo. "ERR writes to sectors [$ERROFFSET,$(($ERROFFSET+$ERRLENGTH-1))]"
1661 encrypt_recover_detachedscip-shell shell shell-project 0.0.0 encrypt_recover_detached(). 4096 checksum $HASH7 $IMG_HDR
1662 encrypt_recover_detachedscip-shell shell shell-project 0.0.0 encrypt_recover_detached(). 4096 journal $HASH7 $IMG_HDR
1663 fi
1664
1665 echoscip-shell system . . echo. "[13] Encryption with detached header recovery (online i/o error)"
1666
1667 get_error_offsetsscip-shell shell shell-project 0.0.0 get_error_offsets(). 31 0
1668
1669 echoscip-shell system . . echo. "sector size 512"
1670
1671 echoscip-shell system . . echo. "ERR writes to sectors [$ERROFFSET,$(($ERROFFSET+$ERRLENGTH-1))]"
1672 encrypt_recover_detached_onlinescip-shell shell shell-project 0.0.0 encrypt_recover_detached_online(). 512 checksum $HASH7 $IMG_HDR
1673 encrypt_recover_detached_onlinescip-shell shell shell-project 0.0.0 encrypt_recover_detached_online(). 512 journal $HASH7 $IMG_HDR
1674
1675 if [scip-shell system . . `[`. -n "$DM_SECTOR_SIZE" ]; then
1676 get_error_offsetsscip-shell shell shell-project 0.0.0 get_error_offsets(). 31 0 4096
1677
1678 echoscip-shell system . . echo. "sector size 4096"
1679
1680 echoscip-shell system . . echo. "ERR writes to sectors [$ERROFFSET,$(($ERROFFSET+$ERRLENGTH-1))]"
1681 encrypt_recover_detached_onlinescip-shell shell shell-project 0.0.0 encrypt_recover_detached_online(). 4096 checksum $HASH7 $IMG_HDR
1682 encrypt_recover_detached_onlinescip-shell shell shell-project 0.0.0 encrypt_recover_detached_online(). 4096 journal $HASH7 $IMG_HDR
1683 fi
1684
1685 echoscip-shell system . . echo. "[14] Decryption with detached header recovery"
1686
1687 echoscip-shell system . . echo. "sector size 512"
1688
1689 # TODO: What should decryption do when it finishes decryption during recovery (with open)
1690 get_error_offsetsscip-shell shell shell-project 0.0.0 get_error_offsets(). 31 2049
1691
1692 echoscip-shell system . . echo. "ERR writes to sectors [$ERROFFSET,$(($ERROFFSET+$ERRLENGTH-1))]"
1693 decrypt_recover_detachedscip-shell shell shell-project 0.0.0 decrypt_recover_detached(). 512 journal $HASH7 $IMG_HDR
1694 decrypt_recover_detachedscip-shell shell shell-project 0.0.0 decrypt_recover_detached(). 512 checksum $HASH7 $IMG_HDR
1695
1696 if [scip-shell system . . `[`. -n "$DM_SECTOR_SIZE" ]; then
1697 echoscip-shell system . . echo. "sector size 4096"
1698
1699 # TODO: What should decryption do when it finishes decryption during recovery (with open)
1700 get_error_offsetsscip-shell shell shell-project 0.0.0 get_error_offsets(). 31 2048 4096
1701
1702 echoscip-shell system . . echo. "ERR writes to sectors [$ERROFFSET,$(($ERROFFSET+$ERRLENGTH-1))]"
1703 decrypt_recover_detachedscip-shell shell shell-project 0.0.0 decrypt_recover_detached(). 4096 checksum $HASH7 $IMG_HDR
1704 decrypt_recover_detachedscip-shell shell shell-project 0.0.0 decrypt_recover_detached(). 4096 journal $HASH7 $IMG_HDR
1705 fi
1706
1707 echoscip-shell system . . echo. "[15] Decryption with detached header recovery (online i/o error)"
1708
1709 echoscip-shell system . . echo. "sector size 512"
1710
1711 # TODO: What should decryption do when it finishes decryption during recovery (with open)
1712 get_error_offsetsscip-shell shell shell-project 0.0.0 get_error_offsets(). 31 2049
1713
1714 echoscip-shell system . . echo. "ERR writes to sectors [$ERROFFSET,$(($ERROFFSET+$ERRLENGTH-1))]"
1715 decrypt_recover_detached_onlinescip-shell shell shell-project 0.0.0 decrypt_recover_detached_online(). 512 journal $HASH7 $IMG_HDR
1716 decrypt_recover_detached_onlinescip-shell shell shell-project 0.0.0 decrypt_recover_detached_online(). 512 checksum $HASH7 $IMG_HDR
1717
1718 if [scip-shell system . . `[`. -n "$DM_SECTOR_SIZE" ]; then
1719 echoscip-shell system . . echo. "sector size 4096"
1720
1721 # TODO: What should decryption do when it finishes decryption during recovery (with open)
1722 get_error_offsetsscip-shell shell shell-project 0.0.0 get_error_offsets(). 31 2048 4096
1723
1724 echoscip-shell system . . echo. "ERR writes to sectors [$ERROFFSET,$(($ERROFFSET+$ERRLENGTH-1))]"
1725 decrypt_recover_detached_onlinescip-shell shell shell-project 0.0.0 decrypt_recover_detached_online(). 4096 checksum $HASH7 $IMG_HDR
1726 decrypt_recover_detached_onlinescip-shell shell shell-project 0.0.0 decrypt_recover_detached_online(). 4096 journal $HASH7 $IMG_HDR
1727 fi
1728
1729 echoscip-shell system . . echo. "[16] Offline reencryption with fixed device size."
1730 preparebigscip-shell shell shell-project 0.0.0 preparebig(). 68
1731
1732 for test_sector_size in $TEST_SECTORS; do
1733 printfscip-shell system . . printf. "sector size %4s: " $test_sector_size
1734 for test_res in checksum journal none; do
1735 echoscip-shell system . . echo. -n "[$test_res]"
1736 reencrypt_offline_fixed_sizescip-shell shell shell-project 0.0.0 reencrypt_offline_fixed_size(). $test_sector_size 2048 $HASH2 $test_res $((60*1024*2)) $HASH8
1737 reencrypt_offline_fixed_sizescip-shell shell shell-project 0.0.0 reencrypt_offline_fixed_size(). $test_sector_size $((28*1024*2)) $HASH1 $test_res $((60*1024*2)) $HASH8
1738 reencrypt_offline_fixed_sizescip-shell shell shell-project 0.0.0 reencrypt_offline_fixed_size(). $test_sector_size $((31*1024*2)) $HASH7 $test_res $((60*1024*2)) $HASH8
1739 echoscip-shell system . . echo. -n "[OK]"
1740 done
1741 echoscip-shell system . . echo. ""
1742 done
1743
1744 echoscip-shell system . . echo. "[17] Online reencryption with fixed device size."
1745 for test_sector_size in $TEST_SECTORS; do
1746 printfscip-shell system . . printf. "sector size %4s: " $test_sector_size
1747 for test_res in checksum journal none; do
1748 echoscip-shell system . . echo. -n "[$test_res]"
1749 reencrypt_online_fixed_sizescip-shell shell shell-project 0.0.0 reencrypt_online_fixed_size(). $test_sector_size 2048 $HASH2 $test_res $((60*1024*2)) $HASH8
1750 reencrypt_online_fixed_sizescip-shell shell shell-project 0.0.0 reencrypt_online_fixed_size(). $test_sector_size $((28*1024*2)) $HASH1 $test_res $((60*1024*2)) $HASH8
1751 reencrypt_online_fixed_sizescip-shell shell shell-project 0.0.0 reencrypt_online_fixed_size(). $test_sector_size $((31*1024*2)) $HASH7 $test_res $((60*1024*2)) $HASH8
1752 echoscip-shell system . . echo. -n "[OK]"
1753 done
1754 echoscip-shell system . . echo. ""
1755 done
1756
1757 echoscip-shell system . . echo. "[18] Offline reencryption with fixed device size (detached header)."
1758 preparebigscip-shell shell shell-project 0.0.0 preparebig(). 60
1759
1760 for test_sector_size in $TEST_SECTORS; do
1761 printfscip-shell system . . printf. "sector size %4s: " $test_sector_size
1762 for test_res in checksum journal none; do
1763 echoscip-shell system . . echo. -n "[$test_res]"
1764 reencrypt_offline_fixed_sizescip-shell shell shell-project 0.0.0 reencrypt_offline_fixed_size(). $test_sector_size 2048 $HASH2 $test_res $((60*1024*2)) $HASH8 $IMG_HDR
1765 reencrypt_offline_fixed_sizescip-shell shell shell-project 0.0.0 reencrypt_offline_fixed_size(). $test_sector_size $((28*1024*2)) $HASH1 $test_res $((60*1024*2)) $HASH8 $IMG_HDR
1766 reencrypt_offline_fixed_sizescip-shell shell shell-project 0.0.0 reencrypt_offline_fixed_size(). $test_sector_size $((31*1024*2)) $HASH7 $test_res $((60*1024*2)) $HASH8 $IMG_HDR
1767 echoscip-shell system . . echo. -n "[OK]"
1768 done
1769 echoscip-shell system . . echo. ""
1770 done
1771
1772 echoscip-shell system . . echo. "[19] Online reencryption with fixed device size (detached header)."
1773 for test_sector_size in $TEST_SECTORS; do
1774 printfscip-shell system . . printf. "sector size %4s: " $test_sector_size
1775 for test_res in checksum journal none; do
1776 echoscip-shell system . . echo. -n "[$test_res]"
1777 reencrypt_online_fixed_sizescip-shell shell shell-project 0.0.0 reencrypt_online_fixed_size(). $test_sector_size 2048 $HASH2 $test_res $((60*1024*2)) $HASH8 $IMG_HDR
1778 reencrypt_online_fixed_sizescip-shell shell shell-project 0.0.0 reencrypt_online_fixed_size(). $test_sector_size $((28*1024*2)) $HASH1 $test_res $((60*1024*2)) $HASH8 $IMG_HDR
1779 reencrypt_online_fixed_sizescip-shell shell shell-project 0.0.0 reencrypt_online_fixed_size(). $test_sector_size $((31*1024*2)) $HASH7 $test_res $((60*1024*2)) $HASH8 $IMG_HDR
1780 echoscip-shell system . . echo. -n "[OK]"
1781 done
1782 echoscip-shell system . . echo. ""
1783 done
1784
1785 echoscip-shell system . . echo. "[20] Offline encryption with fixed device size (detached header)."
1786 for test_sector_size in $TEST_SECTORS; do
1787 printfscip-shell system . . printf. "sector size %4s: " $test_sector_size
1788 for test_res in checksum journal none; do
1789 echoscip-shell system . . echo. -n "[$test_res]"
1790 encrypt_offline_fixed_sizescip-shell shell shell-project 0.0.0 encrypt_offline_fixed_size(). $test_sector_size 2048 $HASH2 $test_res $((60*1024*2)) $HASH8 $IMG_HDR
1791 encrypt_offline_fixed_sizescip-shell shell shell-project 0.0.0 encrypt_offline_fixed_size(). $test_sector_size $((28*1024*2)) $HASH1 $test_res $((60*1024*2)) $HASH8 $IMG_HDR
1792 encrypt_offline_fixed_sizescip-shell shell shell-project 0.0.0 encrypt_offline_fixed_size(). $test_sector_size $((31*1024*2)) $HASH7 $test_res $((60*1024*2)) $HASH8 $IMG_HDR
1793 echoscip-shell system . . echo. -n "[OK]"
1794 done
1795 echoscip-shell system . . echo. ""
1796 done
1797
1798 echoscip-shell system . . echo. "[21] Offline decryption with fixed device size (detached header)."
1799 prepare_linear_devscip-shell shell shell-project 0.0.0 prepare_linear_dev(). 60
1800 for test_sector_size in $TEST_SECTORS; do
1801 printfscip-shell system . . printf. "sector size %4s: " $test_sector_size
1802 for test_res in checksum journal none; do
1803 echoscip-shell system . . echo. -n "[$test_res]"
1804 decrypt_offline_fixed_sizescip-shell shell shell-project 0.0.0 decrypt_offline_fixed_size(). $test_sector_size 2048 $HASH2 $test_res $((60*1024*2)) $HASH8 $IMG_HDR
1805 decrypt_offline_fixed_sizescip-shell shell shell-project 0.0.0 decrypt_offline_fixed_size(). $test_sector_size $((28*1024*2)) $HASH1 $test_res $((60*1024*2)) $HASH8 $IMG_HDR
1806 decrypt_offline_fixed_sizescip-shell shell shell-project 0.0.0 decrypt_offline_fixed_size(). $test_sector_size $((31*1024*2)) $HASH7 $test_res $((60*1024*2)) $HASH8 $IMG_HDR
1807 echoscip-shell system . . echo. -n "[OK]"
1808 done
1809 echoscip-shell system . . echo. ""
1810 done
1811
1812 echoscip-shell system . . echo. "[22] Multi-keyslot device reencryption"
1813 preparescip-shell shell shell-project 0.0.0 prepare(). dev_size_mb=17
1814 echoscip-shell system . . echo. $PWD1 | $CRYPTSETUP -q luksFormat --type luks2 --offset 32768 $FAST_PBKDF_ARGON $DEV || failscip-shell shell shell-project 0.0.0 fail().
1815 echoscip-shell system . . echo. -e "$PWD1\n$PWD2" | $CRYPTSETUP -q luksAddKey $FAST_PBKDF2 $DEV || failscip-shell shell shell-project 0.0.0 fail().
1816 echoscip-shell system . . echo. -e "$PWD1\n$PWD3" | $CRYPTSETUP -q luksAddKey $FAST_PBKDF_ARGON $DEV || failscip-shell shell shell-project 0.0.0 fail().
1817 wipescip-shell shell shell-project 0.0.0 wipe(). $PWD1
1818
1819 echoscip-shell system . . echo. -e "$PWD1\n$PWD2\n$PWD3" | $CRYPTSETUP reencrypt $DEV -q || failscip-shell shell shell-project 0.0.0 fail().
1820 check_hashscip-shell shell shell-project 0.0.0 check_hash(). $PWD1 $HASH2
1821 check_hashscip-shell shell shell-project 0.0.0 check_hash(). $PWD2 $HASH2
1822 check_hashscip-shell shell shell-project 0.0.0 check_hash(). $PWD3 $HASH2
1823
1824 # check at least pbkdf type is preserved
1825 $CRYPTSETUP luksDump $DEV | grepscip-shell system . . grep. -e "3: luks2" -A5 | grepscip-shell system . . grep. -q "argon2" || failscip-shell shell shell-project 0.0.0 fail().
1826 $CRYPTSETUP luksDump $DEV | grepscip-shell system . . grep. -e "4: luks2" -A5 | grepscip-shell system . . grep. -q "pbkdf2" || failscip-shell shell shell-project 0.0.0 fail().
1827 $CRYPTSETUP luksDump $DEV | grepscip-shell system . . grep. -e "5: luks2" -A5 | grepscip-shell system . . grep. -q "argon2" || failscip-shell shell shell-project 0.0.0 fail().
1828
1829 echoscip-shell system . . echo. $PWD1 | $CRYPTSETUP -q luksAddKey $FAST_PBKDF2 $DEV $KEY1 || failscip-shell shell shell-project 0.0.0 fail().
1830
1831 # with more keyslots, specific has to be selected
1832 $CRYPTSETUP reencrypt $DEV -d $KEY1 -q 2>/dev/nullscip-shell filesystem . . `/dev/null`. && failscip-shell shell shell-project 0.0.0 fail().
1833 $CRYPTSETUP reencrypt $DEV -d $KEY1 -q -S0 || failscip-shell shell shell-project 0.0.0 fail().
1834 open_cryptscip-shell shell shell-project 0.0.0 open_crypt().
1835 check_hash_devscip-shell shell shell-project 0.0.0 check_hash_dev(). /dev/mapper/$DEV_NAME $HASH2
1836 $CRYPTSETUP close $DEV_NAME
1837
1838 # there should be single keyslot now
1839 $CRYPTSETUP reencrypt $DEV -d $KEY1 -q || failscip-shell shell shell-project 0.0.0 fail().
1840 echoscip-shell system . . echo. $PWD1 | $CRYPTSETUP -q luksAddKey $FAST_PBKDF2 $DEV -S1 -d $KEY1 || failscip-shell shell shell-project 0.0.0 fail().
1841
1842 echoscip-shell system . . echo. $PWD3 | $CRYPTSETUP -q luksAddKey $FAST_PBKDF2 $DEV -S2 --unbound --key-size 32 || failscip-shell shell shell-project 0.0.0 fail().
1843 echoscip-shell system . . echo. $PWD3 | $CRYPTSETUP -q luksAddKey $FAST_PBKDF2 $DEV -S22 --unbound --key-size 32 || failscip-shell shell shell-project 0.0.0 fail().
1844 echoscip-shell system . . echo. $PWD3 | $CRYPTSETUP -q luksAddKey $FAST_PBKDF2 $DEV -S23 --unbound --key-size 32 || failscip-shell shell shell-project 0.0.0 fail().
1845
1846 echoscip-shell system . . echo. $PWD1 | $CRYPTSETUP reencrypt $DEV -S1 -q || failscip-shell shell shell-project 0.0.0 fail().
1847 $CRYPTSETUP open --test-passphrase -d $KEY1 $DEV 2>/dev/nullscip-shell filesystem . . `/dev/null`. && failscip-shell shell shell-project 0.0.0 fail().
1848 echoscip-shell system . . echo. $PWD3 | $CRYPTSETUP open --test-passphrase -S2 $DEV || failscip-shell shell shell-project 0.0.0 fail().
1849 echoscip-shell system . . echo. $PWD3 | $CRYPTSETUP open --test-passphrase -S22 $DEV || failscip-shell shell shell-project 0.0.0 fail().
1850 check_hashscip-shell shell shell-project 0.0.0 check_hash(). $PWD1 $HASH2
1851
1852 # fill 31 keyslots
1853 COUNT=27
1854 while [scip-shell system . . `[`. $COUNT -gt 0 ]; do
1855 echoscip-shell system . . echo. -e "$PWD1\n$PWD1" | $CRYPTSETUP luksAddKey $DEV -q $FAST_PBKDF_ARGON || failscip-shell shell shell-project 0.0.0 fail().
1856 COUNT=$((COUNT-1))
1857 done
1858
1859 echoscip-shell system . . echo. $PWD1 | $CRYPTSETUP reencrypt $DEV -S0 -q 2>/dev/nullscip-shell filesystem . . `/dev/null`. && failscip-shell shell shell-project 0.0.0 fail().
1860 echoscip-shell system . . echo. $PWD1 | $CRYPTSETUP luksKillSlot $DEV 30 || failscip-shell shell shell-project 0.0.0 fail().
1861 echoscip-shell system . . echo. $PWD1 | $CRYPTSETUP reencrypt $DEV -q -S0 || failscip-shell shell shell-project 0.0.0 fail().
1862
1863 COUNT=14
1864 while [scip-shell system . . `[`. $COUNT -gt 0 ]; do
1865 echoscip-shell system . . echo. -e "$PWD1\n$PWD1" | $CRYPTSETUP luksAddKey $DEV -q $FAST_PBKDF_ARGON || failscip-shell shell shell-project 0.0.0 fail().
1866 COUNT=$((COUNT-1))
1867 done
1868
1869 echoscip-shell system . . echo. -e "$PWD1\n$PWD1\n$PWD1\n$PWD1\n$PWD1\n$PWD1\n$PWD1\n$PWD1\n$PWD1\n$PWD1\n$PWD1\n$PWD1\n$PWD1\n$PWD1\n$PWD1" | $CRYPTSETUP reencrypt $DEV -q 2>/dev/nullscip-shell filesystem . . `/dev/null`. && failscip-shell shell shell-project 0.0.0 fail().
1870 echoscip-shell system . . echo. $PWD1 | $CRYPTSETUP luksKillSlot $DEV 1 || failscip-shell shell shell-project 0.0.0 fail().
1871 # one wrong passphrase
1872 echoscip-shell system . . echo. -e "$PWD1\n$PWD1\n$PWD1\n$PWD1\n$PWD1\n$PWD1\n$PWD1\n$PWD1\n$PWD1\n$PWD1\n$PWD1\n$PWD1\n$PWD1\n$PWD2" | $CRYPTSETUP reencrypt $DEV -q 2>/dev/nullscip-shell filesystem . . `/dev/null`. && failscip-shell shell shell-project 0.0.0 fail().
1873 echoscip-shell system . . echo. $PWD1 | $CRYPTSETUP reencrypt $DEV --resume-only -q 2>/dev/nullscip-shell filesystem . . `/dev/null`. && failscip-shell shell shell-project 0.0.0 fail().
1874 echoscip-shell system . . echo. -e "$PWD1\n$PWD1\n$PWD1\n$PWD1\n$PWD1\n$PWD1\n$PWD1\n$PWD1\n$PWD1\n$PWD1\n$PWD1\n$PWD1\n$PWD1\n$PWD1" | $CRYPTSETUP reencrypt $DEV -q || failscip-shell shell shell-project 0.0.0 fail().
1875
1876 #test error path behaves as expected for initialization with not enough space in binary area
1877 # create LUKS2 header with keyslots binary space for exactly 4 keyslots
1878 echoscip-shell system . . echo. $PWD1 | $CRYPTSETUP -q luksFormat --type luks2 --luks2-keyslots-size $((4*258048)) -S0 -s512 --cipher aes-xts-plain64 $FAST_PBKDF_ARGON $DEV >/dev/nullscip-shell filesystem . . `/dev/null`. || failscip-shell shell shell-project 0.0.0 fail().
1879 echoscip-shell system . . echo. -e "$PWD1\n$PWD2" | $CRYPTSETUP luksAddKey -S1 $DEV -q $FAST_PBKDF_ARGON || failscip-shell shell shell-project 0.0.0 fail().
1880 echoscip-shell system . . echo. -e "$PWD1\n$PWD2" | $CRYPTSETUP luksAddKey -S2 $DEV -q $FAST_PBKDF_ARGON || failscip-shell shell shell-project 0.0.0 fail().
1881 # there is not enough space in binary area for keyslot id 4 (replacement for id 2)
1882 echoscip-shell system . . echo. -e "$PWD1\n$PWD2\n$PWD2" | $CRYPTSETUP reencrypt $DEV --init-only -q 2>/dev/nullscip-shell filesystem . . `/dev/null`. && failscip-shell shell shell-project 0.0.0 fail().
1883 $CRYPTSETUP luksDump $DEV | grepscip-shell system . . grep. -q "online-reencrypt" && failscip-shell shell shell-project 0.0.0 fail().
1884 # check cli removed all unbound keyslots created in-before reencryption initialization
1885 $CRYPTSETUP luksDump $DEV | grepscip-shell system . . grep. -q "unbound" && failscip-shell shell shell-project 0.0.0 fail().
1886
1887 echoscip-shell system . . echo. $PWD1 | $CRYPTSETUP luksKillSlot $DEV 2 || failscip-shell shell shell-project 0.0.0 fail().
1888 # there is not enough space in binary area for reencryption keyslot
1889 echoscip-shell system . . echo. -e "$PWD1\n$PWD2" | $CRYPTSETUP reencrypt $DEV --init-only -q 2>/dev/nullscip-shell filesystem . . `/dev/null`. && failscip-shell shell shell-project 0.0.0 fail().
1890 $CRYPTSETUP luksDump $DEV | grepscip-shell system . . grep. -q "online-reencrypt" && failscip-shell shell shell-project 0.0.0 fail().
1891 # check cli removed all unbound keyslots created in-before reencryption initialization
1892 $CRYPTSETUP luksDump $DEV | grepscip-shell system . . grep. -q "unbound" && failscip-shell shell shell-project 0.0.0 fail().
1893
1894 echoscip-shell system . . echo. "[23] Reencryption with specified new volume key"
1895 preparescip-shell shell shell-project 0.0.0 prepare(). dev_size_mb=32
1896 echoscip-shell system . . echo. $PWD1 | $CRYPTSETUP -q luksFormat --type luks2 -s 256 -c aes-cbc-essiv:sha256 --offset 8192 $FAST_PBKDF_ARGON $DEV || failscip-shell shell shell-project 0.0.0 fail().
1897 echoscip-shell system . . echo. -e "$PWD1\n$PWD3" | $CRYPTSETUP -q luksAddKey $FAST_PBKDF_ARGON $DEV || failscip-shell shell shell-project 0.0.0 fail().
1898 wipescip-shell shell shell-project 0.0.0 wipe(). $PWD1
1899 echoscip-shell system . . echo. $PWD1 | $CRYPTSETUP reencrypt $DEV -q -S0 $FAST_PBKDF_ARGON --new-volume-key-file $VKEY1 --new-key-size 128 || failscip-shell shell shell-project 0.0.0 fail().
1900 check_hashscip-shell shell shell-project 0.0.0 check_hash(). $PWD1 $HASH1
1901 $CRYPTSETUP luksErase -q $DEV || failscip-shell shell shell-project 0.0.0 fail().
1902 echoscip-shell system . . echo. $PWD1 | $CRYPTSETUP luksAddKey -q $FAST_PBKDF_ARGON --volume-key-file $VKEY1 -s 128 $DEV || failscip-shell shell shell-project 0.0.0 fail().
1903 check_hashscip-shell shell shell-project 0.0.0 check_hash(). $PWD1 $HASH1
1904
1905 echoscip-shell system . . echo. "[24] Reencryption with initial cipher_null"
1906 # aka custom encryption
1907 preparescip-shell shell shell-project 0.0.0 prepare(). dev_size_mb=32
1908 echoscip-shell system . . echo. $PWD1 | $CRYPTSETUP -q luksFormat --type luks2 -s 128 -c cipher_null-ecb --offset 8192 $FAST_PBKDF_ARGON $DEV || failscip-shell shell shell-project 0.0.0 fail().
1909 wipescip-shell shell shell-project 0.0.0 wipe(). $PWD1
1910 echoscip-shell system . . echo. $PWD1 | $CRYPTSETUP reencrypt $DEV -c aes-xts-plain64 -q $FAST_PBKDF_ARGON || failscip-shell shell shell-project 0.0.0 fail().
1911 check_hashscip-shell shell shell-project 0.0.0 check_hash(). $PWD1 $HASH1
1912
1913 # online
1914 echoscip-shell system . . echo. $PWD1 | $CRYPTSETUP -q luksFormat --type luks2 -s 128 -c cipher_null-ecb --offset 8192 $FAST_PBKDF_ARGON $DEV || failscip-shell shell shell-project 0.0.0 fail().
1915 wipescip-shell shell shell-project 0.0.0 wipe(). $PWD1
1916 echoscip-shell system . . echo. $PWD1 | $CRYPTSETUP open $DEV $DEV_NAME
1917 echoscip-shell system . . echo. $PWD1 | $CRYPTSETUP reencrypt $DEV -c aes-xts-plain64 -q $FAST_PBKDF_ARGON || failscip-shell shell shell-project 0.0.0 fail().
1918 check_hash_devscip-shell shell shell-project 0.0.0 check_hash_dev(). /dev/mapper/$DEV_NAME $HASH1
1919 if [scip-shell system . . `[`. $HAVE_KEYRING -gt 0 ]; then
1920 $CRYPTSETUP status $DEV_NAME | grepscip-shell system . . grep. -q "key location: keyring" || failscip-shell shell shell-project 0.0.0 fail().
1921 fi
1922 $CRYPTSETUP close $DEV_NAME
1923
1924 # FIXME: Add test luks2 image with both keyslot and data using cipher_null and verify LUKS2 reencryption fixes this.
1925
1926 ## simulate LUKS2 device with cipher_null in both keyslot and segment (it can be created only by up conversion from LUKS1)
1927 #echo $PWD1 | $CRYPTSETUP -q luksFormat --type luks1 -s 128 -c cipher_null-ecb --offset 8192 $FAST_PBKDF2 $DEV || fail
1928 #$CRYPTSETUP convert -q --type luks2 $DEV || fail
1929 #wipe $PWD1
1930 #echo $PWD1 | $CRYPTSETUP reencrypt $DEV -q $FAST_PBKDF_ARGON >/dev/null || fail
1931 #check_hash $PWD1 $HASH1
1932 ## both keyslot and segment cipher must not be null after reencryption with default params
1933 #$CRYPTSETUP luksDump $DEV | grep -q "cipher_null" && fail
1934
1935 # multistep reencryption with initial cipher_null
1936 preparebigscip-shell shell shell-project 0.0.0 preparebig(). 64
1937 echoscip-shell system . . echo. $PWD1 | $CRYPTSETUP luksFormat --type luks2 $DEV -c null --offset 16384 -q $FAST_PBKDF_ARGON || failscip-shell shell shell-project 0.0.0 fail().
1938 echoscip-shell system . . echo. $PWD1 | $CRYPTSETUP open $DEV $DEV_NAME
1939 wipe_devscip-shell shell shell-project 0.0.0 wipe_dev(). /dev/mapper/$DEV_NAME
1940 echoscip-shell system . . echo. $PWD1 | $CRYPTSETUP reencrypt $DEV --hotzone-size 1M --resilience none -q $FAST_PBKDF_ARGON >/dev/nullscip-shell filesystem . . `/dev/null`. || failscip-shell shell shell-project 0.0.0 fail().
1941 $CRYPTSETUP close $DEV_NAME
1942 check_hashscip-shell shell shell-project 0.0.0 check_hash(). $PWD1 $HASH5
1943
1944 echoscip-shell system . . echo. $PWD1 | $CRYPTSETUP luksFormat --type luks2 $DEV -c null --offset 16384 -q $FAST_PBKDF_ARGON || failscip-shell shell shell-project 0.0.0 fail().
1945 wipescip-shell shell shell-project 0.0.0 wipe(). $PWD1
1946 echoscip-shell system . . echo. $PWD1 | $CRYPTSETUP reencrypt $DEV --hotzone-size 1M --resilience none -q $FAST_PBKDF_ARGON >/dev/nullscip-shell filesystem . . `/dev/null`. || failscip-shell shell shell-project 0.0.0 fail().
1947 check_hashscip-shell shell shell-project 0.0.0 check_hash(). $PWD1 $HASH5
1948
1949 echoscip-shell system . . echo. "[25] Reencryption recovery with cipher_null"
1950 # (check opt-io size optimization in reencryption code does not affect recovery)
1951 # device with opt-io size 32k
1952 prepare_linear_devscip-shell shell shell-project 0.0.0 prepare_linear_dev(). 32 opt_blks=64 $OPT_XFERLEN_EXP
1953 OFFSET=8192
1954
1955 echoscip-shell system . . echo. "sector size 512->512"
1956
1957 get_error_offsetsscip-shell shell shell-project 0.0.0 get_error_offsets(). 32 $OFFSET
1958 echoscip-shell system . . echo. $PWD1 | $CRYPTSETUP -q luksFormat --type luks2 -c null --sector-size 512 --offset $OFFSET $FAST_PBKDF_ARGON $DEV || failscip-shell shell shell-project 0.0.0 fail().
1959 wipescip-shell shell shell-project 0.0.0 wipe(). $PWD1
1960
1961 echoscip-shell system . . echo. "ERR writes to sectors [$ERROFFSET,$(($ERROFFSET+$ERRLENGTH-1))]"
1962 reencrypt_recoverscip-shell shell shell-project 0.0.0 reencrypt_recover(). 512 checksum $HASH1
1963 echoscip-shell system . . echo. $PWD1 | $CRYPTSETUP -q luksFormat --type luks2 -c null --sector-size 512 --offset $OFFSET $FAST_PBKDF_ARGON $DEV || failscip-shell shell shell-project 0.0.0 fail().
1964 wipescip-shell shell shell-project 0.0.0 wipe(). $PWD1
1965 reencrypt_recoverscip-shell shell shell-project 0.0.0 reencrypt_recover(). 512 journal $HASH1
1966
1967 if [scip-shell system . . `[`. -n "$DM_SECTOR_SIZE" ]; then
1968 echoscip-shell system . . echo. "sector size 512->4096"
1969
1970 get_error_offsetsscip-shell shell shell-project 0.0.0 get_error_offsets(). 32 $OFFSET 4096
1971 echoscip-shell system . . echo. $PWD1 | $CRYPTSETUP -q luksFormat --type luks2 -c null --sector-size 512 --offset $OFFSET $FAST_PBKDF_ARGON $DEV || failscip-shell shell shell-project 0.0.0 fail().
1972 wipescip-shell shell shell-project 0.0.0 wipe(). $PWD1
1973
1974 echoscip-shell system . . echo. "ERR writes to sectors [$ERROFFSET,$(($ERROFFSET+$ERRLENGTH-1))]"
1975 reencrypt_recoverscip-shell shell shell-project 0.0.0 reencrypt_recover(). 4096 checksum $HASH1
1976 echoscip-shell system . . echo. $PWD1 | $CRYPTSETUP -q luksFormat --type luks2 -c null --sector-size 512 --offset $OFFSET $FAST_PBKDF_ARGON $DEV || failscip-shell shell shell-project 0.0.0 fail().
1977 wipescip-shell shell shell-project 0.0.0 wipe(). $PWD1
1978 reencrypt_recoverscip-shell shell shell-project 0.0.0 reencrypt_recover(). 4096 journal $HASH1
1979
1980 echoscip-shell system . . echo. "sector size 4096->4096"
1981
1982 get_error_offsetsscip-shell shell shell-project 0.0.0 get_error_offsets(). 32 $OFFSET 4096
1983 echoscip-shell system . . echo. $PWD1 | $CRYPTSETUP -q luksFormat --type luks2 -c null --sector-size 4096 --offset $OFFSET $FAST_PBKDF_ARGON $DEV || failscip-shell shell shell-project 0.0.0 fail().
1984 wipescip-shell shell shell-project 0.0.0 wipe(). $PWD1
1985
1986 echoscip-shell system . . echo. "ERR writes to sectors [$ERROFFSET,$(($ERROFFSET+$ERRLENGTH-1))]"
1987 reencrypt_recoverscip-shell shell shell-project 0.0.0 reencrypt_recover(). 4096 checksum $HASH1
1988 reencrypt_recoverscip-shell shell shell-project 0.0.0 reencrypt_recover(). 4096 journal $HASH1
1989 fi
1990
1991 echoscip-shell system . . echo. "[26] Reencryption recovery with cipher_null (online i/o error)"
1992
1993 echoscip-shell system . . echo. "sector size 512->512"
1994
1995 get_error_offsetsscip-shell shell shell-project 0.0.0 get_error_offsets(). 32 $OFFSET
1996 echoscip-shell system . . echo. $PWD1 | $CRYPTSETUP -q luksFormat --type luks2 --sector-size 512 -c null --offset $OFFSET $FAST_PBKDF_ARGON $DEV || failscip-shell shell shell-project 0.0.0 fail().
1997 wipescip-shell shell shell-project 0.0.0 wipe(). $PWD1
1998
1999 echoscip-shell system . . echo. "ERR writes to sectors [$ERROFFSET,$(($ERROFFSET+$ERRLENGTH-1))]"
2000 reencrypt_recover_onlinescip-shell shell shell-project 0.0.0 reencrypt_recover_online(). 512 checksum $HASH1
2001 echoscip-shell system . . echo. $PWD1 | $CRYPTSETUP -q luksFormat --type luks2 --sector-size 512 -c null --offset $OFFSET $FAST_PBKDF_ARGON $DEV || failscip-shell shell shell-project 0.0.0 fail().
2002 wipescip-shell shell shell-project 0.0.0 wipe(). $PWD1
2003 reencrypt_recover_onlinescip-shell shell shell-project 0.0.0 reencrypt_recover_online(). 512 journal $HASH1
2004
2005 if [scip-shell system . . `[`. -n "$DM_SECTOR_SIZE" ]; then
2006 echoscip-shell system . . echo. "sector size 512->4096"
2007
2008 get_error_offsetsscip-shell shell shell-project 0.0.0 get_error_offsets(). 32 $OFFSET 4096
2009 echoscip-shell system . . echo. $PWD1 | $CRYPTSETUP -q luksFormat --type luks2 -c null --sector-size 512 --offset $OFFSET $FAST_PBKDF_ARGON $DEV || failscip-shell shell shell-project 0.0.0 fail().
2010 wipescip-shell shell shell-project 0.0.0 wipe(). $PWD1
2011
2012 echoscip-shell system . . echo. "ERR writes to sectors [$ERROFFSET,$(($ERROFFSET+$ERRLENGTH-1))]"
2013 reencrypt_recover_onlinescip-shell shell shell-project 0.0.0 reencrypt_recover_online(). 4096 checksum $HASH1
2014 echoscip-shell system . . echo. $PWD1 | $CRYPTSETUP -q luksFormat --type luks2 -c null --sector-size 512 --offset $OFFSET $FAST_PBKDF_ARGON $DEV || failscip-shell shell shell-project 0.0.0 fail().
2015 wipescip-shell shell shell-project 0.0.0 wipe(). $PWD1
2016 reencrypt_recover_onlinescip-shell shell shell-project 0.0.0 reencrypt_recover_online(). 4096 journal $HASH1
2017
2018 echoscip-shell system . . echo. "sector size 4096->4096"
2019
2020 get_error_offsetsscip-shell shell shell-project 0.0.0 get_error_offsets(). 32 $OFFSET 4096
2021 echoscip-shell system . . echo. $PWD1 | $CRYPTSETUP -q luksFormat --type luks2 -c null --sector-size 4096 --offset $OFFSET $FAST_PBKDF_ARGON $DEV || failscip-shell shell shell-project 0.0.0 fail().
2022 wipescip-shell shell shell-project 0.0.0 wipe(). $PWD1
2023
2024 echoscip-shell system . . echo. "ERR writes to sectors [$ERROFFSET,$(($ERROFFSET+$ERRLENGTH-1))]"
2025 reencrypt_recover_onlinescip-shell shell shell-project 0.0.0 reencrypt_recover_online(). 4096 checksum $HASH1
2026 reencrypt_recover_onlinescip-shell shell shell-project 0.0.0 reencrypt_recover_online(). 4096 journal $HASH1
2027 fi
2028
2029 echoscip-shell system . . echo. "[27] Verify test passphrase mode works with reencryption metadata"
2030 echoscip-shell system . . echo. $PWD1 | $CRYPTSETUP -S5 -q luksFormat --type luks2 $FAST_PBKDF_ARGON $DEV || failscip-shell shell shell-project 0.0.0 fail().
2031 echoscip-shell system . . echo. -e "$PWD1\n$PWD1" | $CRYPTSETUP luksAddKey --unbound -s80 -S0 $FAST_PBKDF_ARGON $DEV || failscip-shell shell shell-project 0.0.0 fail().
2032 echoscip-shell system . . echo. $PWD1 | $CRYPTSETUP reencrypt --init-only $DEV || failscip-shell shell shell-project 0.0.0 fail().
2033 echoscip-shell system . . echo. $PWD1 | $CRYPTSETUP open --test-passphrase $DEV || failscip-shell shell shell-project 0.0.0 fail().
2034
2035 echoscip-shell system . . echo. $PWD1 | $CRYPTSETUP -q luksFormat -S5 --header $IMG_HDR --type luks2 $FAST_PBKDF_ARGON $DEV || failscip-shell shell shell-project 0.0.0 fail().
2036 echoscip-shell system . . echo. -e "$PWD1\n$PWD1" | $CRYPTSETUP luksAddKey --unbound -s80 -S0 $FAST_PBKDF_ARGON $IMG_HDR || failscip-shell shell shell-project 0.0.0 fail().
2037 echoscip-shell system . . echo. $PWD1 | $CRYPTSETUP reencrypt --decrypt --init-only --header $IMG_HDR $DEV || failscip-shell shell shell-project 0.0.0 fail().
2038 echoscip-shell system . . echo. $PWD1 | $CRYPTSETUP open --test-passphrase $IMG_HDR || failscip-shell shell shell-project 0.0.0 fail().
2039 rmscip-shell system . . rm. -f $IMG_HDR
2040 wipe_dev_headscip-shell shell shell-project 0.0.0 wipe_dev_head(). $DEV 1
2041
2042 echoscip-shell system . . echo. $PWD1 | $CRYPTSETUP reencrypt -q --encrypt --init-only --header $IMG_HDR $FAST_PBKDF_ARGON $DEV || failscip-shell shell shell-project 0.0.0 fail().
2043 echoscip-shell system . . echo. $PWD1 | $CRYPTSETUP open --test-passphrase $IMG_HDR || failscip-shell shell shell-project 0.0.0 fail().
2044
2045 echoscip-shell system . . echo. $PWD1 | $CRYPTSETUP reencrypt --encrypt --init-only --reduce-device-size 8M $FAST_PBKDF_ARGON $DEV || failscip-shell shell shell-project 0.0.0 fail().
2046 echoscip-shell system . . echo. $PWD1 | $CRYPTSETUP open --test-passphrase $DEV || failscip-shell shell shell-project 0.0.0 fail().
2047
2048 echoscip-shell system . . echo. "[28] Prevent nested encryption"
2049 prepare_linear_devscip-shell shell shell-project 0.0.0 prepare_linear_dev(). 32 opt_blks=64 $OPT_XFERLEN_EXP
2050
2051 #device already LUKS2
2052 echoscip-shell system . . echo. $PWD1 | $CRYPTSETUP -q luksFormat --type luks2 $FAST_PBKDF2 $DEV || failscip-shell shell shell-project 0.0.0 fail().
2053
2054 echoscip-shell system . . echo. $PWD1 | $CRYPTSETUP reencrypt -q --encrypt --type luks1 --reduce-device-size 2m $FAST_PBKDF2 $DEV 2>/dev/nullscip-shell filesystem . . `/dev/null`. && failscip-shell shell shell-project 0.0.0 fail().
2055 echoscip-shell system . . echo. $PWD1 | $CRYPTSETUP reencrypt -q --encrypt --type luks1 --header $IMG_HDR $FAST_PBKDF2 $DEV 2>/dev/nullscip-shell filesystem . . `/dev/null`. && failscip-shell shell shell-project 0.0.0 fail().
2056 testscip-shell system . . test. -f $IMG_HDR && failscip-shell shell shell-project 0.0.0 fail().
2057 echoscip-shell system . . echo. $PWD1 | $CRYPTSETUP reencrypt -q --encrypt --type luks2 --reduce-device-size 2m $FAST_PBKDF2 $DEV 2>/dev/nullscip-shell filesystem . . `/dev/null`. && failscip-shell shell shell-project 0.0.0 fail().
2058 echoscip-shell system . . echo. $PWD1 | $CRYPTSETUP reencrypt -q --encrypt --type luks2 --header $IMG_HDR $FAST_PBKDF2 $DEV 2>/dev/nullscip-shell filesystem . . `/dev/null`. && failscip-shell shell shell-project 0.0.0 fail().
2059 testscip-shell system . . test. -f $IMG_HDR && failscip-shell shell shell-project 0.0.0 fail().
2060 #type mismatch
2061 echoscip-shell system . . echo. $PWD1 | $CRYPTSETUP reencrypt -q --type luks1 $DEV 2>/dev/nullscip-shell filesystem . . `/dev/null`. && failscip-shell shell shell-project 0.0.0 fail().
2062 wipe_devscip-shell shell shell-project 0.0.0 wipe_dev(). $DEV
2063
2064 #detached header already LUKS2
2065 echoscip-shell system . . echo. $PWD1 | $CRYPTSETUP -q luksFormat --type luks2 --header $IMG_HDR $FAST_PBKDF2 $DEV || failscip-shell shell shell-project 0.0.0 fail().
2066
2067 echoscip-shell system . . echo. $PWD1 | $CRYPTSETUP reencrypt -q --encrypt --type luks1 --header $IMG_HDR $FAST_PBKDF2 $DEV 2>/dev/nullscip-shell filesystem . . `/dev/null`. && failscip-shell shell shell-project 0.0.0 fail().
2068 echoscip-shell system . . echo. $PWD1 | $CRYPTSETUP reencrypt -q --encrypt --type luks2 --header $IMG_HDR $FAST_PBKDF2 $DEV 2>/dev/nullscip-shell filesystem . . `/dev/null`. && failscip-shell shell shell-project 0.0.0 fail().
2069 echoscip-shell system . . echo. $PWD1 | $CRYPTSETUP reencrypt -q --type luks1 --header $IMG_HDR $DEV 2>/dev/nullscip-shell filesystem . . `/dev/null`. && failscip-shell shell shell-project 0.0.0 fail().
2070 rmscip-shell system . . rm. -f $IMG_HDR
2071
2072 #data device already in reencryption
2073 echoscip-shell system . . echo. $PWD1 | $CRYPTSETUP -q luksFormat --type luks2 $FAST_PBKDF2 $DEV || failscip-shell shell shell-project 0.0.0 fail().
2074 echoscip-shell system . . echo. $PWD1 | $CRYPTSETUP reencrypt --init-only $FAST_PBKDF_ARGON $DEV || failscip-shell shell shell-project 0.0.0 fail().
2075
2076 echoscip-shell system . . echo. $PWD1 | $CRYPTSETUP reencrypt -q --encrypt --type luks1 --header $IMG_HDR $FAST_PBKDF2 $DEV 2>/dev/nullscip-shell filesystem . . `/dev/null`. && failscip-shell shell shell-project 0.0.0 fail().
2077 testscip-shell system . . test. -f $IMG_HDR && failscip-shell shell shell-project 0.0.0 fail().
2078 echoscip-shell system . . echo. $PWD1 | $CRYPTSETUP reencrypt -q --encrypt --type luks2 --header $IMG_HDR $FAST_PBKDF2 $DEV 2>/dev/nullscip-shell filesystem . . `/dev/null`. && failscip-shell shell shell-project 0.0.0 fail().
2079 testscip-shell system . . test. -f $IMG_HDR && failscip-shell shell shell-project 0.0.0 fail().
2080 #type mismatch
2081 echoscip-shell system . . echo. $PWD1 | $CRYPTSETUP reencrypt -q --type luks1 $DEV 2>/dev/nullscip-shell filesystem . . `/dev/null`. && failscip-shell shell shell-project 0.0.0 fail().
2082 wipe_devscip-shell shell shell-project 0.0.0 wipe_dev(). $DEV
2083 rmscip-shell system . . rm. -f $IMG_HDR
2084
2085 #header in reencryption (type mismatch)
2086 echoscip-shell system . . echo. $PWD1 | $CRYPTSETUP reencrypt --encrypt --init-only --type luks2 --header $IMG_HDR $FAST_PBKDF2 $DEV || failscip-shell shell shell-project 0.0.0 fail().
2087 echoscip-shell system . . echo. $PWD1 | $CRYPTSETUP reencrypt -q --encrypt --type luks1 --header $IMG_HDR $FAST_PBKDF2 $DEV 2>/dev/nullscip-shell filesystem . . `/dev/null`. && failscip-shell shell shell-project 0.0.0 fail().
2088
2089 echoscip-shell system . . echo. "[29] Conflicting reencryption parameters"
2090 echoscip-shell system . . echo. $PWD1 | $CRYPTSETUP -q luksFormat --type luks2 $FAST_PBKDF2 $DEV || failscip-shell shell shell-project 0.0.0 fail().
2091 echoscip-shell system . . echo. $PWD1 | $CRYPTSETUP reencrypt $DEV -q --init-only $FAST_PBKDF_ARGON || failscip-shell shell shell-project 0.0.0 fail().
2092 echoscip-shell system . . echo. $PWD1 | $CRYPTSETUP reencrypt --encrypt --reduce-device-size 4M $DEV -q $FAST_PBKDF_ARGON 2> /dev/nullscip-shell filesystem . . `/dev/null`. && failscip-shell shell shell-project 0.0.0 fail().
2093 echoscip-shell system . . echo. $PWD1 | $CRYPTSETUP reencrypt --decrypt $DEV -q $FAST_PBKDF_ARGON 2> /dev/nullscip-shell filesystem . . `/dev/null`. && failscip-shell shell shell-project 0.0.0 fail().
2094 echoscip-shell system . . echo. $PWD1 | $CRYPTSETUP reencrypt $DEV -q --resilience datashift 2> /dev/nullscip-shell filesystem . . `/dev/null`. && failscip-shell shell shell-project 0.0.0 fail().
2095 echoscip-shell system . . echo. $PWD1 | $CRYPTSETUP reencrypt $DEV -q --resilience datashift-checksum 2> /dev/nullscip-shell filesystem . . `/dev/null`. && failscip-shell shell shell-project 0.0.0 fail().
2096 echoscip-shell system . . echo. $PWD1 | $CRYPTSETUP reencrypt $DEV -q --resilience datashift-journal 2> /dev/nullscip-shell filesystem . . `/dev/null`. && failscip-shell shell shell-project 0.0.0 fail().
2097 wipe_dev_headscip-shell shell shell-project 0.0.0 wipe_dev_head(). $DEV 1
2098 echoscip-shell system . . echo. $PWD1 | $CRYPTSETUP reencrypt --encrypt --init-only --reduce-device-size 16M $DEV -q $FAST_PBKDF_ARGON 2> /dev/nullscip-shell filesystem . . `/dev/null`. || failscip-shell shell shell-project 0.0.0 fail().
2099 echoscip-shell system . . echo. $PWD1 | $CRYPTSETUP reencrypt --decrypt $DEV -q $FAST_PBKDF_ARGON 2> /dev/nullscip-shell filesystem . . `/dev/null`. && failscip-shell shell shell-project 0.0.0 fail().
2100 echoscip-shell system . . echo. $PWD1 | $CRYPTSETUP reencrypt $DEV -q --resilience journal 2> /dev/nullscip-shell filesystem . . `/dev/null`. && failscip-shell shell shell-project 0.0.0 fail().
2101 echoscip-shell system . . echo. $PWD1 | $CRYPTSETUP reencrypt $DEV -q --resilience datashift-checksum 2> /dev/nullscip-shell filesystem . . `/dev/null`. && failscip-shell shell shell-project 0.0.0 fail().
2102 echoscip-shell system . . echo. $PWD1 | $CRYPTSETUP reencrypt $DEV -q --resilience datashift-journal 2> /dev/nullscip-shell filesystem . . `/dev/null`. && failscip-shell shell shell-project 0.0.0 fail().
2103 wipe_dev_headscip-shell shell shell-project 0.0.0 wipe_dev_head(). $DEV 1
2104 echoscip-shell system . . echo. $PWD1 | $CRYPTSETUP -q luksFormat --type luks2 --header $IMG_HDR $FAST_PBKDF2 $DEV || failscip-shell shell shell-project 0.0.0 fail().
2105 echoscip-shell system . . echo. $PWD1 | $CRYPTSETUP reencrypt $DEV -q --header $IMG_HDR --init-only $FAST_PBKDF_ARGON || failscip-shell shell shell-project 0.0.0 fail().
2106 echoscip-shell system . . echo. $PWD1 | $CRYPTSETUP reencrypt --encrypt --header $IMG_HDR $DEV -q $FAST_PBKDF_ARGON 2> /dev/nullscip-shell filesystem . . `/dev/null`. && failscip-shell shell shell-project 0.0.0 fail().
2107 echoscip-shell system . . echo. $PWD1 | $CRYPTSETUP reencrypt --decrypt --header $IMG_HDR $DEV -q $FAST_PBKDF_ARGON 2> /dev/nullscip-shell filesystem . . `/dev/null`. && failscip-shell shell shell-project 0.0.0 fail().
2108 echoscip-shell system . . echo. $PWD1 | $CRYPTSETUP reencrypt $DEV -q --header $IMG_HDR --resilience datashift-checksum 2>/dev/nullscip-shell filesystem . . `/dev/null`. && failscip-shell shell shell-project 0.0.0 fail().
2109 echoscip-shell system . . echo. $PWD1 | $CRYPTSETUP reencrypt $DEV -q --header $IMG_HDR --resilience datashift-journal 2>/dev/nullscip-shell filesystem . . `/dev/null`. && failscip-shell shell shell-project 0.0.0 fail().
2110 rmscip-shell system . . rm. -f $IMG_HDR
2111 echoscip-shell system . . echo. $PWD1 | $CRYPTSETUP reencrypt $DEV -q --encrypt --header $IMG_HDR --init-only $FAST_PBKDF_ARGON || failscip-shell shell shell-project 0.0.0 fail().
2112 echoscip-shell system . . echo. $PWD1 | $CRYPTSETUP reencrypt --decrypt --header $IMG_HDR $DEV -q $FAST_PBKDF_ARGON 2> /dev/nullscip-shell filesystem . . `/dev/null`. && failscip-shell shell shell-project 0.0.0 fail().
2113 echoscip-shell system . . echo. $PWD1 | $CRYPTSETUP -q luksFormat --type luks2 --header $IMG_HDR $FAST_PBKDF2 $DEV || failscip-shell shell shell-project 0.0.0 fail().
2114 echoscip-shell system . . echo. $PWD1 | $CRYPTSETUP reencrypt $DEV -q --decrypt --header $IMG_HDR --init-only $FAST_PBKDF_ARGON || failscip-shell shell shell-project 0.0.0 fail().
2115 echoscip-shell system . . echo. $PWD1 | $CRYPTSETUP reencrypt --encrypt --header $IMG_HDR $DEV -q $FAST_PBKDF_ARGON 2> /dev/nullscip-shell filesystem . . `/dev/null`. && failscip-shell shell shell-project 0.0.0 fail().
2116 rmscip-shell system . . rm. -f $IMG_HDR
2117 echoscip-shell system . . echo. $PWD1 | $CRYPTSETUP -q luksFormat --type luks2 $FAST_PBKDF2 $DEV || failscip-shell shell shell-project 0.0.0 fail().
2118 echoscip-shell system . . echo. $PWD1 | $CRYPTSETUP reencrypt --decrypt $DEV --header $IMG_HDR -q --init-only $FAST_PBKDF_ARGON --resilience datashift 2> /dev/nullscip-shell filesystem . . `/dev/null`. && failscip-shell shell shell-project 0.0.0 fail().
2119 testscip-shell system . . test. -f $IMG_HDR && failscip-shell shell shell-project 0.0.0 fail().
2120 echoscip-shell system . . echo. $PWD1 | $CRYPTSETUP reencrypt --decrypt $DEV --header $IMG_HDR -q --init-only $FAST_PBKDF_ARGON --resilience none 2> /dev/nullscip-shell filesystem . . `/dev/null`. && failscip-shell shell shell-project 0.0.0 fail().
2121 testscip-shell system . . test. -f $IMG_HDR && failscip-shell shell shell-project 0.0.0 fail().
2122 $CRYPTSETUP luksDump $DEV | grepscip-shell system . . grep. -q "online-reencrypt" && failscip-shell shell shell-project 0.0.0 fail().
2123 echoscip-shell system . . echo. $PWD1 | $CRYPTSETUP reencrypt --decrypt $DEV --header $IMG_HDR -q --init-only $FAST_PBKDF_ARGON --resilience checksum --hotzone-size 4m || failscip-shell shell shell-project 0.0.0 fail().
2124 $CRYPTSETUP isLuks $DEV -q && failscip-shell shell shell-project 0.0.0 fail().
2125 # $CRYPTSETUP luksDump $IMG_HDR
2126 echoscip-shell system . . echo. $PWD1 | $CRYPTSETUP reencrypt --decrypt $DEV --header $IMG_HDR -q --resilience datashift 2> /dev/nullscip-shell filesystem . . `/dev/null`. && failscip-shell shell shell-project 0.0.0 fail().
2127 echoscip-shell system . . echo. $PWD1 | $CRYPTSETUP reencrypt --decrypt $DEV --header $IMG_HDR -q --resilience none 2> /dev/nullscip-shell filesystem . . `/dev/null`. && failscip-shell shell shell-project 0.0.0 fail().
2128 echoscip-shell system . . echo. $PWD1 | $CRYPTSETUP reencrypt --decrypt $DEV --header $IMG_HDR -q --resilience journal || failscip-shell shell shell-project 0.0.0 fail().
2129 rmscip-shell system . . rm. -f $IMG_HDR
2130
2131 check_blkidscip-shell shell shell-project 0.0.0 check_blkid().
2132 if [scip-shell system . . `[`. "$HAVE_BLKID" -gt 0 ]; then
2133 echoscip-shell system . . echo. "[30] Prevent nested encryption of broken LUKS device"
2134 rmscip-shell system . . rm. -f $IMG_HDR
2135 xzscip-shell system . . xz. -dkf $HEADER_LUKS2_PV.xz
2136 wipe_devscip-shell shell shell-project 0.0.0 wipe_dev(). $DEV
2137
2138 # broken header
2139 echoscip-shell system . . echo. $PWD1 | $CRYPTSETUP reencrypt -q --header $HEADER_LUKS2_PV $DEV $FAST_PBKDF_ARGON --encrypt --type luks2 2>/dev/nullscip-shell filesystem . . `/dev/null`. && failscip-shell shell shell-project 0.0.0 fail().
2140 $CRYPTSETUP isLuks $HEADER_LUKS2_PV && failscip-shell shell shell-project 0.0.0 fail().
2141 # broken device
2142 echoscip-shell system . . echo. $PWD1 | $CRYPTSETUP reencrypt -q $HEADER_LUKS2_PV $FAST_PBKDF_ARGON --encrypt --force-offline-reencrypt --type luks2 --reduce-device-size 8m 2>/dev/nullscip-shell filesystem . . `/dev/null`. && failscip-shell shell shell-project 0.0.0 fail().
2143 $CRYPTSETUP isLuks $HEADER_LUKS2_PV && failscip-shell shell shell-project 0.0.0 fail().
2144 # broken data device only
2145 echoscip-shell system . . echo. $PWD1 | $CRYPTSETUP reencrypt -q --header $IMG_HDR $HEADER_LUKS2_PV $FAST_PBKDF_ARGON --encrypt --force-offline-reencrypt --type luks2 2>/dev/nullscip-shell filesystem . . `/dev/null`. && failscip-shell shell shell-project 0.0.0 fail().
2146 testscip-shell system . . test. -f $IMG_HDR && failscip-shell shell shell-project 0.0.0 fail().
2147 fi
2148
2149 if [scip-shell system . . `[`. -n "$DM_SECTOR_SIZE" -a $HAVE_BLKID -gt 0 ]; then
2150 echoscip-shell system . . echo. "[31] Prevent dangerous sector size increase"
2151 preparebigscip-shell shell shell-project 0.0.0 preparebig(). 64
2152 echoscip-shell system . . echo. $PWD1 | $CRYPTSETUP luksFormat -q --sector-size 512 --type luks2 $FAST_PBKDF_ARGON $DEV || failscip-shell shell shell-project 0.0.0 fail().
2153
2154 # block encryption sector size increase on offline device
2155 echoscip-shell system . . echo. $PWD1 | $CRYPTSETUP reencrypt --init-only -q --sector-size 1024 $FAST_PBKDF_ARGON $DEV 2>/dev/nullscip-shell filesystem . . `/dev/null`. && failscip-shell shell shell-project 0.0.0 fail().
2156 $CRYPTSETUP luksDump $DEV | grepscip-shell system . . grep. -q "online-reencrypt" && failscip-shell shell shell-project 0.0.0 fail().
2157 echoscip-shell system . . echo. $PWD1 | $CRYPTSETUP reencrypt -q --sector-size 1024 $FAST_PBKDF_ARGON $DEV 2>/dev/nullscip-shell filesystem . . `/dev/null`. && failscip-shell shell shell-project 0.0.0 fail().
2158 $CRYPTSETUP luksDump $DEV | grepscip-shell system . . grep. -q "online-reencrypt" && failscip-shell shell shell-project 0.0.0 fail().
2159 $CRYPTSETUP luksDump $DEV | grepscip-shell system . . grep. -q "sector: 1024" && failscip-shell shell shell-project 0.0.0 fail().
2160
2161 # --force-offline-reencrypt can bypass the constraint
2162 echoscip-shell system . . echo. $PWD1 | $CRYPTSETUP reencrypt --force-offline-reencrypt --init-only -q --sector-size 1024 $FAST_PBKDF_ARGON $DEV || failscip-shell shell shell-project 0.0.0 fail().
2163 # resume must work
2164 echoscip-shell system . . echo. $PWD1 | $CRYPTSETUP reencrypt -q $FAST_PBKDF_ARGON $DEV || failscip-shell shell shell-project 0.0.0 fail().
2165
2166 # online with no superblock is fine
2167 echoscip-shell system . . echo. $PWD1 | $CRYPTSETUP open -q $DEV $DEV_NAME || failscip-shell shell shell-project 0.0.0 fail().
2168 echoscip-shell system . . echo. $PWD1 | $CRYPTSETUP reencrypt --init-only -q --sector-size 4096 $FAST_PBKDF_ARGON $DEV || failscip-shell shell shell-project 0.0.0 fail().
2169 $CRYPTSETUP close $DEV_NAME || failscip-shell shell shell-project 0.0.0 fail().
2170
2171 # sector size decrease is ok
2172 echoscip-shell system . . echo. $PWD1 | $CRYPTSETUP luksFormat -q --sector-size 4096 --type luks2 $FAST_PBKDF_ARGON $DEV || failscip-shell shell shell-project 0.0.0 fail().
2173 echoscip-shell system . . echo. $PWD1 | $CRYPTSETUP reencrypt --init-only -q --sector-size 1024 $FAST_PBKDF_ARGON $DEV || failscip-shell shell shell-project 0.0.0 fail().
2174
2175 if [scip-shell system . . `[`. -n "$BLKID_BLOCK_SIZE_SUPPORT" ]; then
2176 xzscip-shell system . . xz. -dkf $IMG_FS.xz
2177 # encryption checks must work in offline mode
2178 echoscip-shell system . . echo. $PWD1 | $CRYPTSETUP reencrypt --encrypt --force-offline-reencrypt --sector-size 1024 -q --header $IMG_HDR $IMG_FS $FAST_PBKDF_ARGON --init-only --type luks2 2>/dev/nullscip-shell filesystem . . `/dev/null`. && failscip-shell shell shell-project 0.0.0 fail().
2179 testscip-shell system . . test. -f $IMG_HDR && failscip-shell shell shell-project 0.0.0 fail().
2180
2181 echoscip-shell system . . echo. $PWD1 | $CRYPTSETUP reencrypt --encrypt --force-offline-reencrypt --sector-size 1024 -q --header $IMG_HDR $IMG_FS $FAST_PBKDF_ARGON --type luks2 2>/dev/nullscip-shell filesystem . . `/dev/null`. && failscip-shell shell shell-project 0.0.0 fail().
2182 testscip-shell system . . test. -f $IMG_HDR && failscip-shell shell shell-project 0.0.0 fail().
2183
2184 echoscip-shell system . . echo. $PWD1 | $CRYPTSETUP reencrypt --encrypt --force-offline-reencrypt --sector-size 1024 -q --reduce-device-size 8m $IMG_FS $FAST_PBKDF_ARGON --init-only --type luks2 2>/dev/nullscip-shell filesystem . . `/dev/null`. && failscip-shell shell shell-project 0.0.0 fail().
2185 $CRYPTSETUP isLuks $IMG_FS && failscip-shell shell shell-project 0.0.0 fail().
2186 echoscip-shell system . . echo. $PWD1 | $CRYPTSETUP reencrypt --encrypt --force-offline-reencrypt --sector-size 1024 -q --reduce-device-size 8m $IMG_FS $FAST_PBKDF_ARGON --type luks2 2>/dev/nullscip-shell filesystem . . `/dev/null`. && failscip-shell shell shell-project 0.0.0 fail().
2187 $CRYPTSETUP isLuks $IMG_FS && failscip-shell shell shell-project 0.0.0 fail().
2188
2189 echoscip-shell system . . echo. $PWD1 | $CRYPTSETUP luksFormat -q --sector-size 512 --type luks2 $FAST_PBKDF_ARGON $DEV || failscip-shell shell shell-project 0.0.0 fail().
2190 echoscip-shell system . . echo. $PWD1 | $CRYPTSETUP open -q $DEV $DEV_NAME || failscip-shell shell shell-project 0.0.0 fail().
2191 ddscip-shell system . . dd. if=$IMG_FS of=/dev/mapper/$DEV_NAME bs=1M >/dev/nullscip-shell filesystem . . `/dev/null`. 2>&1
2192
2193 echoscip-shell system . . echo. $PWD1 | $CRYPTSETUP reencrypt --init-only -q --sector-size 1024 $FAST_PBKDF_ARGON $DEV 2>/dev/nullscip-shell filesystem . . `/dev/null`. && failscip-shell shell shell-project 0.0.0 fail().
2194 $CRYPTSETUP status $DEV_NAME | grepscip-shell system . . grep. -q "reencryption: in-progress" && failscip-shell shell shell-project 0.0.0 fail().
2195 echoscip-shell system . . echo. $PWD1 | $CRYPTSETUP reencrypt --init-only -q --sector-size 1024 --active-name $DEV_NAME $FAST_PBKDF_ARGON 2>/dev/nullscip-shell filesystem . . `/dev/null`. && failscip-shell shell shell-project 0.0.0 fail().
2196 $CRYPTSETUP status $DEV_NAME | grepscip-shell system . . grep. -q "reencryption: in-progress" && failscip-shell shell shell-project 0.0.0 fail().
2197 echoscip-shell system . . echo. $PWD1 | $CRYPTSETUP reencrypt -q --sector-size 1024 $FAST_PBKDF_ARGON $DEV 2>/dev/nullscip-shell filesystem . . `/dev/null`. && failscip-shell shell shell-project 0.0.0 fail().
2198 $CRYPTSETUP luksDump $DEV | grepscip-shell system . . grep. -q "sector: 512" || failscip-shell shell shell-project 0.0.0 fail().
2199 echoscip-shell system . . echo. $PWD1 | $CRYPTSETUP reencrypt -q --sector-size 1024 --active-name $DEV_NAME $FAST_PBKDF_ARGON 2>/dev/nullscip-shell filesystem . . `/dev/null`. && failscip-shell shell shell-project 0.0.0 fail().
2200 $CRYPTSETUP luksDump $DEV | grepscip-shell system . . grep. -q "sector: 512" || failscip-shell shell shell-project 0.0.0 fail().
2201 fi
2202 fi
2203
2204 echoscip-shell system . . echo. "[32] Removal of encryption (LUKS2 legacy cryptsetup-reencrypt test)."
2205 preparescip-shell shell shell-project 0.0.0 prepare(). dev_size_mb=32
2206 OFFSET=8192
2207
2208 # offline decryption with shift
2209 echoscip-shell system . . echo. $PWD1 | $CRYPTSETUP -q luksFormat --type luks2 $FAST_PBKDF_ARGON $DEV --offset 8192 || failscip-shell shell shell-project 0.0.0 fail().
2210 wipescip-shell shell shell-project 0.0.0 wipe(). $PWD1
2211 echoscip-shell system . . echo. $PWD1 | $CRYPTSETUP reencrypt $DEV -q --decrypt --header $IMG_HDR || failscip-shell shell shell-project 0.0.0 fail().
2212 check_hash_dev_headscip-shell shell shell-project 0.0.0 check_hash_dev_head(). $DEV 57344 $HASH1
2213 # FIXME: Should not reencryption remove it automatically?
2214 rmscip-shell system . . rm. -f $IMG_HDR
2215
2216 # online decryption with shift
2217 echoscip-shell system . . echo. $PWD1 | $CRYPTSETUP -q luksFormat --type luks2 $FAST_PBKDF_ARGON $DEV --offset 8192 || failscip-shell shell shell-project 0.0.0 fail().
2218 echoscip-shell system . . echo. $PWD1 | $CRYPTSETUP open $DEV $DEV_NAME || failscip-shell shell shell-project 0.0.0 fail().
2219 wipe_devscip-shell shell shell-project 0.0.0 wipe_dev(). /dev/mapper/$DEV_NAME
2220 echoscip-shell system . . echo. $PWD1 | $CRYPTSETUP reencrypt $DEV -q --decrypt --header $IMG_HDR || failscip-shell shell shell-project 0.0.0 fail().
2221 check_hash_dev_headscip-shell shell shell-project 0.0.0 check_hash_dev_head(). $DEV 57344 $HASH1
2222 # FIXME: Should not reencryption remove it automatically?
2223 rmscip-shell system . . rm. -f $IMG_HDR
2224
2225 # offline decryption (separate initialization and decryption steps)
2226 echoscip-shell system . . echo. $PWD1 | $CRYPTSETUP -q luksFormat --type luks2 $FAST_PBKDF_ARGON $DEV --offset 8192 || failscip-shell shell shell-project 0.0.0 fail().
2227 wipescip-shell shell shell-project 0.0.0 wipe(). $PWD1
2228 echoscip-shell system . . echo. $PWD1 | $CRYPTSETUP reencrypt $DEV -q --decrypt --header $IMG_HDR --init-only || failscip-shell shell shell-project 0.0.0 fail().
2229 check_hashscip-shell shell shell-project 0.0.0 check_hash(). $PWD1 $HASH1 $IMG_HDR
2230 echoscip-shell system . . echo. $PWD1 | $CRYPTSETUP reencrypt $DEV -q --decrypt --header $IMG_HDR || failscip-shell shell shell-project 0.0.0 fail().
2231 check_hash_dev_headscip-shell shell shell-project 0.0.0 check_hash_dev_head(). $DEV 57344 $HASH1
2232 # FIXME: Should not reencryption remove it automatically?
2233 rmscip-shell system . . rm. -f $IMG_HDR
2234
2235 # online decryption with shift
2236 echoscip-shell system . . echo. $PWD1 | $CRYPTSETUP -q luksFormat --type luks2 $FAST_PBKDF_ARGON $DEV --offset 8192 || failscip-shell shell shell-project 0.0.0 fail().
2237 echoscip-shell system . . echo. $PWD1 | $CRYPTSETUP open $DEV $DEV_NAME || failscip-shell shell shell-project 0.0.0 fail().
2238 wipe_devscip-shell shell shell-project 0.0.0 wipe_dev(). /dev/mapper/$DEV_NAME
2239 echoscip-shell system . . echo. $PWD1 | $CRYPTSETUP reencrypt $DEV -q --decrypt --header $IMG_HDR --init-only || failscip-shell shell shell-project 0.0.0 fail().
2240 check_hash_devscip-shell shell shell-project 0.0.0 check_hash_dev(). /dev/mapper/$DEV_NAME $HASH1
2241 echoscip-shell system . . echo. $PWD1 | $CRYPTSETUP reencrypt $DEV -q --decrypt --header $IMG_HDR || failscip-shell shell shell-project 0.0.0 fail().
2242 check_hash_dev_headscip-shell shell shell-project 0.0.0 check_hash_dev_head(). $DEV 57344 $HASH1
2243 # FIXME: Should not reencryption remove it automatically?
2244 rmscip-shell system . . rm. -f $IMG_HDR
2245
2246 # same tests just with date size == LUKS2 header size
2247 echoscip-shell system . . echo. $PWD1 | $CRYPTSETUP -q luksFormat --type luks2 $FAST_PBKDF_ARGON $DEV --offset 32768 || failscip-shell shell shell-project 0.0.0 fail().
2248 wipescip-shell shell shell-project 0.0.0 wipe(). $PWD1
2249 check_hashscip-shell shell shell-project 0.0.0 check_hash(). $PWD1 $HASH10
2250 echoscip-shell system . . echo. $PWD1 | $CRYPTSETUP reencrypt $DEV -q --decrypt --header $IMG_HDR || failscip-shell shell shell-project 0.0.0 fail().
2251 check_hash_dev_headscip-shell shell shell-project 0.0.0 check_hash_dev_head(). $DEV 32768 $HASH10
2252 # FIXME: Should not reencryption remove it automatically?
2253 rmscip-shell system . . rm. -f $IMG_HDR
2254
2255 echoscip-shell system . . echo. $PWD1 | $CRYPTSETUP -q luksFormat --type luks2 $FAST_PBKDF_ARGON $DEV --offset 32768 || failscip-shell shell shell-project 0.0.0 fail().
2256 echoscip-shell system . . echo. $PWD1 | $CRYPTSETUP open $DEV $DEV_NAME || failscip-shell shell shell-project 0.0.0 fail().
2257 wipe_devscip-shell shell shell-project 0.0.0 wipe_dev(). /dev/mapper/$DEV_NAME
2258 echoscip-shell system . . echo. $PWD1 | $CRYPTSETUP reencrypt $DEV -q --decrypt --header $IMG_HDR || failscip-shell shell shell-project 0.0.0 fail().
2259 check_hash_dev_headscip-shell shell shell-project 0.0.0 check_hash_dev_head(). $DEV 32768 $HASH10
2260 # FIXME: Should not reencryption remove it automatically?
2261 rmscip-shell system . . rm. -f $IMG_HDR
2262
2263 echoscip-shell system . . echo. $PWD1 | $CRYPTSETUP -q luksFormat --type luks2 $FAST_PBKDF_ARGON $DEV --offset 32768 || failscip-shell shell shell-project 0.0.0 fail().
2264 wipescip-shell shell shell-project 0.0.0 wipe(). $PWD1
2265 echoscip-shell system . . echo. $PWD1 | $CRYPTSETUP reencrypt $DEV -q --decrypt --header $IMG_HDR --init-only || failscip-shell shell shell-project 0.0.0 fail().
2266 check_hashscip-shell shell shell-project 0.0.0 check_hash(). $PWD1 $HASH10 $IMG_HDR
2267 echoscip-shell system . . echo. $PWD1 | $CRYPTSETUP reencrypt $DEV -q --decrypt --header $IMG_HDR || failscip-shell shell shell-project 0.0.0 fail().
2268 check_hash_dev_headscip-shell shell shell-project 0.0.0 check_hash_dev_head(). $DEV 32768 $HASH10
2269 # FIXME: Should not reencryption remove it automatically?
2270 rmscip-shell system . . rm. -f $IMG_HDR
2271
2272 echoscip-shell system . . echo. $PWD1 | $CRYPTSETUP -q luksFormat --type luks2 $FAST_PBKDF_ARGON $DEV --offset 32768 || failscip-shell shell shell-project 0.0.0 fail().
2273 echoscip-shell system . . echo. $PWD1 | $CRYPTSETUP open $DEV $DEV_NAME || failscip-shell shell shell-project 0.0.0 fail().
2274 wipe_devscip-shell shell shell-project 0.0.0 wipe_dev(). /dev/mapper/$DEV_NAME
2275 echoscip-shell system . . echo. $PWD1 | $CRYPTSETUP reencrypt $DEV -q --decrypt --header $IMG_HDR --init-only || failscip-shell shell shell-project 0.0.0 fail().
2276 check_hash_devscip-shell shell shell-project 0.0.0 check_hash_dev(). /dev/mapper/$DEV_NAME $HASH10
2277 echoscip-shell system . . echo. $PWD1 | $CRYPTSETUP reencrypt $DEV -q --decrypt --header $IMG_HDR || failscip-shell shell shell-project 0.0.0 fail().
2278 check_hash_dev_headscip-shell shell shell-project 0.0.0 check_hash_dev_head(). $DEV 32768 $HASH10
2279 # FIXME: Should not reencryption remove it automatically?
2280 rmscip-shell system . . rm. -f $IMG_HDR
2281
2282 # 1MiB data size
2283 echoscip-shell system . . echo. $PWD1 | $CRYPTSETUP -q luksFormat --type luks2 $FAST_PBKDF_ARGON $DEV --offset 63488 || failscip-shell shell shell-project 0.0.0 fail().
2284 echoscip-shell system . . echo. $PWD1 | $CRYPTSETUP open $DEV $DEV_NAME || failscip-shell shell shell-project 0.0.0 fail().
2285 wipe_devscip-shell shell shell-project 0.0.0 wipe_dev(). /dev/mapper/$DEV_NAME
2286 # --hotzone-size larger than data expected to get auto corrected by library
2287 echoscip-shell system . . echo. $PWD1 | $CRYPTSETUP reencrypt $DEV -q --decrypt --header $IMG_HDR --init-only --hotzone-size 4M || failscip-shell shell shell-project 0.0.0 fail().
2288 check_hash_devscip-shell shell shell-project 0.0.0 check_hash_dev(). /dev/mapper/$DEV_NAME $HASH2
2289 echoscip-shell system . . echo. $PWD1 | $CRYPTSETUP reencrypt $DEV -q --decrypt --header $IMG_HDR || failscip-shell shell shell-project 0.0.0 fail().
2290 check_hash_dev_headscip-shell shell shell-project 0.0.0 check_hash_dev_head(). $DEV 2048 $HASH2
2291 rmscip-shell system . . rm. -f $IMG_HDR
2292
2293 # small device (less than header size)
2294 preparescip-shell shell shell-project 0.0.0 prepare(). dev_size_mb=5
2295 echoscip-shell system . . echo. $PWD1 | $CRYPTSETUP -q luksFormat --type luks2 -S5 $FAST_PBKDF_ARGON $DEV --offset 8192 || failscip-shell shell shell-project 0.0.0 fail().
2296 wipescip-shell shell shell-project 0.0.0 wipe(). $PWD1
2297 echoscip-shell system . . echo. $PWD1 | $CRYPTSETUP reencrypt $DEV -q --decrypt --header $IMG_HDR || failscip-shell shell shell-project 0.0.0 fail().
2298 check_hash_dev_headscip-shell shell shell-project 0.0.0 check_hash_dev_head(). $DEV 2048 $HASH2
2299 # FIXME: Should not reencryption remove it automatically?
2300 rmscip-shell system . . rm. -f $IMG_HDR
2301
2302 echoscip-shell system . . echo. $PWD1 | $CRYPTSETUP -q luksFormat --type luks2 -S5 $FAST_PBKDF_ARGON $DEV --offset 8192 || failscip-shell shell shell-project 0.0.0 fail().
2303 echoscip-shell system . . echo. $PWD1 | $CRYPTSETUP open $DEV $DEV_NAME || failscip-shell shell shell-project 0.0.0 fail().
2304 wipe_devscip-shell shell shell-project 0.0.0 wipe_dev(). /dev/mapper/$DEV_NAME
2305 echoscip-shell system . . echo. $PWD1 | $CRYPTSETUP reencrypt $DEV -q --decrypt --header $IMG_HDR || failscip-shell shell shell-project 0.0.0 fail().
2306 check_hash_dev_headscip-shell shell shell-project 0.0.0 check_hash_dev_head(). $DEV 2048 $HASH2
2307 rmscip-shell system . . rm. -f $IMG_HDR
2308
2309 # initialization by --active-name parameter
2310 echoscip-shell system . . echo. $PWD1 | $CRYPTSETUP -q luksFormat --type luks2 $FAST_PBKDF_ARGON $DEV --offset 8192 || failscip-shell shell shell-project 0.0.0 fail().
2311 echoscip-shell system . . echo. $PWD1 | $CRYPTSETUP open $DEV $DEV_NAME || failscip-shell shell shell-project 0.0.0 fail().
2312 wipe_devscip-shell shell shell-project 0.0.0 wipe_dev(). /dev/mapper/$DEV_NAME
2313 echoscip-shell system . . echo. $PWD1 | $CRYPTSETUP reencrypt -q --decrypt --header $IMG_HDR --active-name $DEV_NAME || failscip-shell shell shell-project 0.0.0 fail().
2314 check_hash_dev_headscip-shell shell shell-project 0.0.0 check_hash_dev_head(). $DEV 2048 $HASH2
2315 rmscip-shell system . . rm. -f $IMG_HDR
2316
2317 # initialization and resume by --active-name parameter
2318 echoscip-shell system . . echo. $PWD1 | $CRYPTSETUP -q luksFormat --type luks2 $FAST_PBKDF_ARGON $DEV --offset 8192 || failscip-shell shell shell-project 0.0.0 fail().
2319 echoscip-shell system . . echo. $PWD1 | $CRYPTSETUP open $DEV $DEV_NAME || failscip-shell shell shell-project 0.0.0 fail().
2320 wipe_devscip-shell shell shell-project 0.0.0 wipe_dev(). /dev/mapper/$DEV_NAME
2321 echoscip-shell system . . echo. $PWD1 | $CRYPTSETUP reencrypt -q --decrypt --header $IMG_HDR --active-name $DEV_NAME --init-only || failscip-shell shell shell-project 0.0.0 fail().
2322 check_hash_devscip-shell shell shell-project 0.0.0 check_hash_dev(). /dev/mapper/$DEV_NAME $HASH2
2323 echoscip-shell system . . echo. $PWD1 | $CRYPTSETUP reencrypt $DEV -q --header $IMG_HDR --active-name $DEV_NAME || failscip-shell shell shell-project 0.0.0 fail().
2324 check_hash_dev_headscip-shell shell shell-project 0.0.0 check_hash_dev_head(). $DEV 2048 $HASH2
2325 rmscip-shell system . . rm. -f $IMG_HDR
2326
2327 # run in single command by --active-name parameter
2328 echoscip-shell system . . echo. $PWD1 | $CRYPTSETUP -q luksFormat --type luks2 $FAST_PBKDF_ARGON $DEV --offset 8192 || failscip-shell shell shell-project 0.0.0 fail().
2329 echoscip-shell system . . echo. $PWD1 | $CRYPTSETUP open $DEV $DEV_NAME || failscip-shell shell shell-project 0.0.0 fail().
2330 wipe_devscip-shell shell shell-project 0.0.0 wipe_dev(). /dev/mapper/$DEV_NAME
2331 echoscip-shell system . . echo. $PWD1 | $CRYPTSETUP reencrypt -q --decrypt --header $IMG_HDR --active-name $DEV_NAME || failscip-shell shell shell-project 0.0.0 fail().
2332 check_hash_dev_headscip-shell shell shell-project 0.0.0 check_hash_dev_head(). $DEV 2048 $HASH2
2333 rmscip-shell system . . rm. -f $IMG_HDR
2334
2335 # Regression test for decryption with detached header and digest id != 0
2336 echoscip-shell system . . echo. $PWD1 | $CRYPTSETUP -q luksFormat --type luks2 $FAST_PBKDF_ARGON $DEV --offset 8192 || failscip-shell shell shell-project 0.0.0 fail().
2337 img_json_savescip-shell shell shell-project 0.0.0 img_json_save(). $DEV
2338 # replace digest id 0 with 1
2339 img_update_jsonscip-shell shell shell-project 0.0.0 img_update_json(). '.digests."1" = .digests."0" | del(.digests."0")' $DEV
2340 wipescip-shell shell shell-project 0.0.0 wipe(). $PWD1
2341 check_hashscip-shell shell shell-project 0.0.0 check_hash(). $PWD1 $HASH2
2342 echoscip-shell system . . echo. $PWD1 | $CRYPTSETUP reencrypt -q --decrypt --header $IMG_HDR $DEV || failscip-shell shell shell-project 0.0.0 fail().
2343 check_hash_dev_headscip-shell shell shell-project 0.0.0 check_hash_dev_head(). $DEV 2048 $HASH2
2344 rmscip-shell system . . rm. -f $IMG_HDR
2345
2346 echoscip-shell system . . echo. "[33] Decryption with datashift recovery (error in shift area)."
2347 prepare_linear_devscip-shell shell shell-project 0.0.0 prepare_linear_dev(). 32
2348 echoscip-shell system . . echo. "sector size 512"
2349
2350 # avoid error in moved segment area on purpose
2351 # Also do not create write error in last segment because
2352 # that would not trigger reencryption crash (read would pass)
2353 get_error_offsetsscip-shell shell shell-project 0.0.0 get_error_offsets(). 32 $OFFSET 512 $((32-1024*2-$OFFSET))
2354 echoscip-shell system . . echo. $PWD1 | $CRYPTSETUP -q luksFormat --type luks2 --sector-size 512 --offset $OFFSET $FAST_PBKDF_ARGON $DEV || failscip-shell shell shell-project 0.0.0 fail().
2355 wipescip-shell shell shell-project 0.0.0 wipe(). $PWD1
2356
2357 echoscip-shell system . . echo. "ERR writes to sectors [$ERROFFSET,$(($ERROFFSET+$ERRLENGTH-1))]"
2358 echoscip-shell system . . echo. -n "resilience:"
2359 decrypt_recoverscip-shell shell shell-project 0.0.0 decrypt_recover(). $HASH1 $IMG_HDR $((32*1024*2-$OFFSET))
2360
2361 if [scip-shell system . . `[`. -n "$DM_SECTOR_SIZE" ]; then
2362 echoscip-shell system . . echo. -e "\nsector size 4096"
2363
2364 get_error_offsetsscip-shell shell shell-project 0.0.0 get_error_offsets(). 32 $OFFSET 4096 $((32-1024*2-$OFFSET))
2365 echoscip-shell system . . echo. $PWD1 | $CRYPTSETUP -q luksFormat --type luks2 --sector-size 4096 --offset $OFFSET $FAST_PBKDF_ARGON $DEV || failscip-shell shell shell-project 0.0.0 fail().
2366 wipescip-shell shell shell-project 0.0.0 wipe(). $PWD1
2367
2368 echoscip-shell system . . echo. "ERR writes to sectors [$ERROFFSET,$(($ERROFFSET+$ERRLENGTH-1))]"
2369 echoscip-shell system . . echo. -n "resilience:"
2370 decrypt_recoverscip-shell shell shell-project 0.0.0 decrypt_recover(). $HASH1 $IMG_HDR $((32*1024*2-$OFFSET))
2371 fi
2372 echoscip-shell system . . echo. ""
2373
2374 echoscip-shell system . . echo. "[34] Decryption with datashift recovery (error in moved segment)."
2375 echoscip-shell system . . echo. "sector size 512"
2376
2377 HZ_SIZE=$((3*1024*2))
2378
2379 # move injected error in moved segment area
2380 get_error_offsetsscip-shell shell shell-project 0.0.0 get_error_offsets(). 32 0 512 $HZ_SIZE
2381 echoscip-shell system . . echo. "ERR writes to sectors [$ERROFFSET,$(($ERROFFSET+$ERRLENGTH-1))]"
2382
2383 echoscip-shell system . . echo. -n "resilience:"
2384 for res in datashift-journal datashift-checksum; do
2385
2386 echoscip-shell system . . echo. $PWD1 | $CRYPTSETUP -q luksFormat --type luks2 --sector-size 512 --offset $OFFSET $FAST_PBKDF_ARGON $DEV || failscip-shell shell shell-project 0.0.0 fail().
2387 wipescip-shell shell shell-project 0.0.0 wipe(). $PWD1
2388
2389 decrypt_recoverscip-shell shell shell-project 0.0.0 decrypt_recover(). $HASH1 $IMG_HDR $((32*1024*2-$OFFSET)) $res $(($HZ_SIZE*512))
2390 done
2391
2392 if [scip-shell system . . `[`. -n "$DM_SECTOR_SIZE" ]; then
2393 echoscip-shell system . . echo. -e "\nsector size 4096"
2394
2395 # move injected error in moved segment area
2396 get_error_offsetsscip-shell shell shell-project 0.0.0 get_error_offsets(). 32 0 4096 $HZ_SIZE
2397 echoscip-shell system . . echo. "ERR writes to sectors [$ERROFFSET,$(($ERROFFSET+$ERRLENGTH-1))]"
2398
2399 echoscip-shell system . . echo. -n "resilience:"
2400 for res in datashift-journal datashift-checksum; do
2401 echoscip-shell system . . echo. $PWD1 | $CRYPTSETUP -q luksFormat --type luks2 --sector-size 4096 --offset $OFFSET $FAST_PBKDF_ARGON $DEV || failscip-shell shell shell-project 0.0.0 fail().
2402 wipescip-shell shell shell-project 0.0.0 wipe(). $PWD1
2403
2404 decrypt_recoverscip-shell shell shell-project 0.0.0 decrypt_recover(). $HASH1 $IMG_HDR $((32*1024*2-$OFFSET)) $res $(($HZ_SIZE*512))
2405 done
2406 fi
2407 echoscip-shell system . . echo. ""
2408
2409 echoscip-shell system . . echo. "[35] Decryption with datashift recovery (online i/o error in shift area)."
2410 echoscip-shell system . . echo. "sector size 512"
2411
2412 echoscip-shell system . . echo. $PWD1 | $CRYPTSETUP -q luksFormat --type luks2 --sector-size 512 --offset $OFFSET $FAST_PBKDF_ARGON $DEV || failscip-shell shell shell-project 0.0.0 fail().
2413 echoscip-shell system . . echo. $PWD1 | $CRYPTSETUP open $DEV $DEV_NAME || failscip-shell shell shell-project 0.0.0 fail().
2414 wipe_devscip-shell shell shell-project 0.0.0 wipe_dev(). /dev/mapper/$DEV_NAME
2415
2416 # avoid error in moved segment area on purpose
2417 # Also do not create write error in last segment because
2418 # that would not trigger reencryption crash (read would pass)
2419 get_error_offsetsscip-shell shell shell-project 0.0.0 get_error_offsets(). 32 $OFFSET 512 $((32-1024*2-$OFFSET))
2420 echoscip-shell system . . echo. "ERR writes to sectors [$ERROFFSET,$(($ERROFFSET+$ERRLENGTH-1))]"
2421
2422 echoscip-shell system . . echo. -n "resilience:"
2423 decrypt_recover_onlinescip-shell shell shell-project 0.0.0 decrypt_recover_online(). $HASH1 $IMG_HDR $((32*1024*2-$OFFSET))
2424
2425 if [scip-shell system . . `[`. -n "$DM_SECTOR_SIZE" ]; then
2426 echoscip-shell system . . echo. -e "\nsector size 4096"
2427
2428 get_error_offsetsscip-shell shell shell-project 0.0.0 get_error_offsets(). 32 $OFFSET 4096 $((32-1024*2-$OFFSET))
2429 echoscip-shell system . . echo. $PWD1 | $CRYPTSETUP -q luksFormat --type luks2 --sector-size 4096 --offset $OFFSET $FAST_PBKDF_ARGON $DEV || failscip-shell shell shell-project 0.0.0 fail().
2430 echoscip-shell system . . echo. $PWD1 | $CRYPTSETUP open $DEV $DEV_NAME || failscip-shell shell shell-project 0.0.0 fail().
2431 wipe_devscip-shell shell shell-project 0.0.0 wipe_dev(). /dev/mapper/$DEV_NAME
2432
2433 echoscip-shell system . . echo. "ERR writes to sectors [$ERROFFSET,$(($ERROFFSET+$ERRLENGTH-1))]"
2434 echoscip-shell system . . echo. -n "resilience:"
2435 decrypt_recover_onlinescip-shell shell shell-project 0.0.0 decrypt_recover_online(). $HASH1 $IMG_HDR $((32*1024*2-$OFFSET))
2436 fi
2437 echoscip-shell system . . echo. ""
2438
2439 echoscip-shell system . . echo. "[36] Decryption with datashift recovery (online i/o error in moved segment)."
2440 echoscip-shell system . . echo. "sector size 512"
2441
2442 # move injected error in moved segment area
2443 get_error_offsetsscip-shell shell shell-project 0.0.0 get_error_offsets(). 32 0 512 $HZ_SIZE
2444 echoscip-shell system . . echo. "ERR writes to sectors [$ERROFFSET,$(($ERROFFSET+$ERRLENGTH-1))]"
2445
2446 echoscip-shell system . . echo. -n "resilience:"
2447 for res in datashift-journal datashift-checksum; do
2448
2449 echoscip-shell system . . echo. $PWD1 | $CRYPTSETUP -q luksFormat --type luks2 --sector-size 512 --offset $OFFSET $FAST_PBKDF_ARGON $DEV || failscip-shell shell shell-project 0.0.0 fail().
2450 echoscip-shell system . . echo. $PWD1 | $CRYPTSETUP open $DEV $DEV_NAME || failscip-shell shell shell-project 0.0.0 fail().
2451 wipe_devscip-shell shell shell-project 0.0.0 wipe_dev(). /dev/mapper/$DEV_NAME
2452
2453 decrypt_recover_online_movedscip-shell shell shell-project 0.0.0 decrypt_recover_online_moved(). $HASH1 $IMG_HDR $((32*1024*2-$OFFSET)) $res $(($HZ_SIZE*512))
2454 done
2455
2456 if [scip-shell system . . `[`. -n "$DM_SECTOR_SIZE" ]; then
2457 echoscip-shell system . . echo. -e "\nsector size 4096"
2458
2459 get_error_offsetsscip-shell shell shell-project 0.0.0 get_error_offsets(). 32 0 4096 $HZ_SIZE
2460 echoscip-shell system . . echo. "ERR writes to sectors [$ERROFFSET,$(($ERROFFSET+$ERRLENGTH-1))]"
2461
2462 echoscip-shell system . . echo. -n "resilience:"
2463 for res in datashift-journal datashift-checksum; do
2464
2465 echoscip-shell system . . echo. $PWD1 | $CRYPTSETUP -q luksFormat --type luks2 --sector-size 4096 --offset $OFFSET $FAST_PBKDF_ARGON $DEV || failscip-shell shell shell-project 0.0.0 fail().
2466 echoscip-shell system . . echo. $PWD1 | $CRYPTSETUP open $DEV $DEV_NAME || failscip-shell shell shell-project 0.0.0 fail().
2467 wipe_devscip-shell shell shell-project 0.0.0 wipe_dev(). /dev/mapper/$DEV_NAME
2468
2469 decrypt_recover_online_movedscip-shell shell shell-project 0.0.0 decrypt_recover_online_moved(). $HASH1 $IMG_HDR $((32*1024*2-$OFFSET)) $res $(($HZ_SIZE*512))
2470 done
2471 fi
2472 echoscip-shell system . . echo. ""
2473
2474 echoscip-shell system . . echo. "[37] Decryption with datashift (large data offsets)"
2475 prepare_linear_devscip-shell shell shell-project 0.0.0 prepare_linear_dev(). 512
2476
2477 echoscip-shell system . . echo. $PWD1 | $CRYPTSETUP -q luksFormat --type luks2 --sector-size 512 --offset 1015808 --luks2-keyslots-size 16M $FAST_PBKDF_ARGON $DEV || failscip-shell shell shell-project 0.0.0 fail().
2478 wipescip-shell shell shell-project 0.0.0 wipe(). $PWD1
2479 echoscip-shell system . . echo. $PWD1 | $CRYPTSETUP reencrypt --decrypt --header $IMG_HDR $DEV -q || failscip-shell shell shell-project 0.0.0 fail().
2480 check_hash_dev_headscip-shell shell shell-project 0.0.0 check_hash_dev_head(). $DEV $((16*1024*2)) $HASH10
2481 rmscip-shell system . . rm. -f $IMG_HDR
2482
2483 echoscip-shell system . . echo. $PWD1 | $CRYPTSETUP -q luksFormat --type luks2 --sector-size 512 --offset 1015808 --luks2-keyslots-size 16M $FAST_PBKDF_ARGON $DEV || failscip-shell shell shell-project 0.0.0 fail().
2484 echoscip-shell system . . echo. $PWD1 | $CRYPTSETUP open $DEV $DEV_NAME
2485 wipe_devscip-shell shell shell-project 0.0.0 wipe_dev(). /dev/mapper/$DEV_NAME
2486 echoscip-shell system . . echo. $PWD1 | $CRYPTSETUP reencrypt --decrypt --header $IMG_HDR $DEV -q || failscip-shell shell shell-project 0.0.0 fail().
2487 check_hash_dev_headscip-shell shell shell-project 0.0.0 check_hash_dev_head(). $DEV $((16*1024*2)) $HASH10
2488 rmscip-shell system . . rm. -f $IMG_HDR
2489
2490 echoscip-shell system . . echo. $PWD1 | $CRYPTSETUP -q luksFormat --type luks2 --sector-size 512 --offset 1046528 --luks2-keyslots-size 16M $FAST_PBKDF_ARGON $DEV || failscip-shell shell shell-project 0.0.0 fail().
2491 wipescip-shell shell shell-project 0.0.0 wipe(). $PWD1
2492 echoscip-shell system . . echo. $PWD1 | $CRYPTSETUP reencrypt --decrypt --header $IMG_HDR $DEV -q || failscip-shell shell shell-project 0.0.0 fail().
2493 check_hash_dev_headscip-shell shell shell-project 0.0.0 check_hash_dev_head(). $DEV 2048 $HASH2
2494 rmscip-shell system . . rm. -f $IMG_HDR
2495
2496 echoscip-shell system . . echo. $PWD1 | $CRYPTSETUP -q luksFormat --type luks2 --sector-size 512 --offset 1046528 --luks2-keyslots-size 16M $FAST_PBKDF_ARGON $DEV || failscip-shell shell shell-project 0.0.0 fail().
2497 echoscip-shell system . . echo. $PWD1 | $CRYPTSETUP open $DEV $DEV_NAME
2498 wipe_devscip-shell shell shell-project 0.0.0 wipe_dev(). /dev/mapper/$DEV_NAME
2499 echoscip-shell system . . echo. $PWD1 | $CRYPTSETUP reencrypt --decrypt --header $IMG_HDR $DEV -q || failscip-shell shell shell-project 0.0.0 fail().
2500 check_hash_dev_headscip-shell shell shell-project 0.0.0 check_hash_dev_head(). $DEV 2048 $HASH2
2501
2502 echoscip-shell system . . echo. "[38] Reencrypt by keyslot context (new initialization and resume methods)"
2503 preparescip-shell shell shell-project 0.0.0 prepare(). dev_size_mb=32
2504
2505 # keyslot0 - pass1
2506 # keyslot2 - pass2
2507 # keyslot4 - pass3, token4 (wrong pass)
2508 # keyslot6 - pass4, token1
2509 # keyslot8 - pass5, token2 (missing)
2510 # keyslot10 - pass6, token3 (wrong pass)
2511 # keyslot12 - pass7, token4
2512 reformat_reencrypt_devicescip-shell shell shell-project 0.0.0 reformat_reencrypt_device().
2513
2514 # tokens
2515 $CRYPTSETUP reencrypt -q --token-id 1 $DEV <&- || failscip-shell shell shell-project 0.0.0 fail().
2516 reformat_reencrypt_devicescip-shell shell shell-project 0.0.0 reformat_reencrypt_device().
2517 $CRYPTSETUP reencrypt -q --token-only $DEV <&- || failscip-shell shell shell-project 0.0.0 fail().
2518 reformat_reencrypt_devicescip-shell shell shell-project 0.0.0 reformat_reencrypt_device().
2519 $CRYPTSETUP reencrypt -q --token-type luks2-keyring $DEV <&- || failscip-shell shell shell-project 0.0.0 fail().
2520
2521 reformat_reencrypt_devicescip-shell shell shell-project 0.0.0 reformat_reencrypt_device().
2522 # keyslots 6 and 12 are unlocked by tokens 1 and 4
2523 echoscip-shell system . . echo. -e "$PWD1\n$PWD2\n$PWD3\n$PWD5\n$PWD6" | $CRYPTSETUP reencrypt -q $DEV || failscip-shell shell shell-project 0.0.0 fail().
2524
2525 # keyfile
2526 echoscip-shell system . . echo. -n $PWD2 > $KEY1
2527 reformat_reencrypt_devicescip-shell shell shell-project 0.0.0 reformat_reencrypt_device().
2528 $CRYPTSETUP reencrypt -q --key-file $KEY1 $DEV 2>/dev/nullscip-shell filesystem . . `/dev/null`. <&- && failscip-shell shell shell-project 0.0.0 fail().
2529 $CRYPTSETUP reencrypt -q --key-file $KEY1 -S4 $DEV 2>/dev/nullscip-shell filesystem . . `/dev/null`. <&- && failscip-shell shell shell-project 0.0.0 fail().
2530 $CRYPTSETUP reencrypt -q --key-file $KEY1 -S2 $DEV <&- || failscip-shell shell shell-project 0.0.0 fail().
2531
2532 # passphrase in keyring
2533 reformat_reencrypt_devicescip-shell shell shell-project 0.0.0 reformat_reencrypt_device().
2534 $CRYPTSETUP reencrypt -q --key-description $KEY_NAME7 $DEV 2>/dev/nullscip-shell filesystem . . `/dev/null`. <&- && failscip-shell shell shell-project 0.0.0 fail().
2535 $CRYPTSETUP reencrypt -q --key-description $KEY_NAME7 -S4 $DEV 2>/dev/nullscip-shell filesystem . . `/dev/null`. <&- && failscip-shell shell shell-project 0.0.0 fail().
2536 $CRYPTSETUP reencrypt -q --key-description $KEY_NAME7 -S2 $DEV <&- || failscip-shell shell shell-project 0.0.0 fail().
2537
2538 # tokens
2539 reformat_reencrypt_devicescip-shell shell shell-project 0.0.0 reformat_reencrypt_device().
2540 $CRYPTSETUP reencrypt -q --token-id 1 $DEV --init-only <&- || failscip-shell shell shell-project 0.0.0 fail().
2541 $CRYPTSETUP open --token-id 1 $DEV $DEV_NAME <&- || failscip-shell shell shell-project 0.0.0 fail().
2542 $CRYPTSETUP reencrypt -q --token-id 1 $DEV --resume-only <&- || failscip-shell shell shell-project 0.0.0 fail().
2543 $CRYPTSETUP close $DEV_NAME || failscip-shell shell shell-project 0.0.0 fail().
2544
2545 reformat_reencrypt_devicescip-shell shell shell-project 0.0.0 reformat_reencrypt_device().
2546 $CRYPTSETUP reencrypt -q --token-only --init-only $DEV <&- || failscip-shell shell shell-project 0.0.0 fail().
2547 $CRYPTSETUP open --token-only $DEV $DEV_NAME <&- || failscip-shell shell shell-project 0.0.0 fail().
2548 $CRYPTSETUP reencrypt -q --token-only --resume-only $DEV <&- || failscip-shell shell shell-project 0.0.0 fail().
2549 $CRYPTSETUP close $DEV_NAME || failscip-shell shell shell-project 0.0.0 fail().
2550
2551 reformat_reencrypt_devicescip-shell shell shell-project 0.0.0 reformat_reencrypt_device().
2552 $CRYPTSETUP reencrypt -q --token-type luks2-keyring --init-only $DEV <&- || failscip-shell shell shell-project 0.0.0 fail().
2553 $CRYPTSETUP open --token-type luks2-keyring $DEV $DEV_NAME <&- || failscip-shell shell shell-project 0.0.0 fail().
2554 $CRYPTSETUP reencrypt -q --token-type luks2-keyring --resume-only $DEV <&- || failscip-shell shell shell-project 0.0.0 fail().
2555 $CRYPTSETUP close $DEV_NAME || failscip-shell shell shell-project 0.0.0 fail().
2556
2557 reformat_reencrypt_devicescip-shell shell shell-project 0.0.0 reformat_reencrypt_device().
2558 echoscip-shell system . . echo. -e "$PWD1\n$PWD2\n$PWD3\n$PWD5\n$PWD6" | $CRYPTSETUP reencrypt --init-only -q $DEV || failscip-shell shell shell-project 0.0.0 fail().
2559 echoscip-shell system . . echo. $PWD1 | $CRYPTSETUP open $DEV $DEV_NAME || failscip-shell shell shell-project 0.0.0 fail().
2560 echoscip-shell system . . echo. -e $PWD1 | $CRYPTSETUP reencrypt --resume-only -q $DEV || failscip-shell shell shell-project 0.0.0 fail().
2561 $CRYPTSETUP close $DEV_NAME || failscip-shell shell shell-project 0.0.0 fail().
2562
2563 # keyfile
2564 echoscip-shell system . . echo. -n $PWD2 > $KEY1
2565 reformat_reencrypt_devicescip-shell shell shell-project 0.0.0 reformat_reencrypt_device().
2566 $CRYPTSETUP reencrypt -q --init-only --key-file $KEY1 $DEV 2>/dev/nullscip-shell filesystem . . `/dev/null`. <&- && failscip-shell shell shell-project 0.0.0 fail().
2567 $CRYPTSETUP reencrypt -q --init-only --key-file $KEY1 -S4 $DEV 2>/dev/nullscip-shell filesystem . . `/dev/null`. <&- && failscip-shell shell shell-project 0.0.0 fail().
2568
2569 $CRYPTSETUP reencrypt -q --init-only --key-file $KEY1 -S2 $DEV <&- || failscip-shell shell shell-project 0.0.0 fail().
2570 $CRYPTSETUP open --key-file $KEY1 $DEV $DEV_NAME <&- || failscip-shell shell shell-project 0.0.0 fail().
2571 $CRYPTSETUP reencrypt -q --resume-only --key-file $KEY1 $DEV <&- || failscip-shell shell shell-project 0.0.0 fail().
2572 $CRYPTSETUP close $DEV_NAME || failscip-shell shell shell-project 0.0.0 fail().
2573
2574 # passphrase in keyring
2575 reformat_reencrypt_devicescip-shell shell shell-project 0.0.0 reformat_reencrypt_device().
2576 $CRYPTSETUP reencrypt -q --init-only --key-description $KEY_NAME7 $DEV 2>/dev/nullscip-shell filesystem . . `/dev/null`. <&- && failscip-shell shell shell-project 0.0.0 fail().
2577 $CRYPTSETUP reencrypt -q --init-only --key-description $KEY_NAME7 -S4 $DEV 2>/dev/nullscip-shell filesystem . . `/dev/null`. <&- && failscip-shell shell shell-project 0.0.0 fail().
2578 $CRYPTSETUP reencrypt -q --init-only --key-description $KEY_NAME7 -S2 $DEV <&- || failscip-shell shell shell-project 0.0.0 fail().
2579 $CRYPTSETUP open -q --key-description $KEY_NAME7 $DEV $DEV_NAME <&- || failscip-shell shell shell-project 0.0.0 fail().
2580 $CRYPTSETUP reencrypt -q --resume-only --key-description $KEY_NAME7 $DEV <&- || failscip-shell shell shell-project 0.0.0 fail().
2581 $CRYPTSETUP close $DEV_NAME || failscip-shell shell shell-project 0.0.0 fail().
2582
2583 # volume key
2584 reformat_reencrypt_devicescip-shell shell shell-project 0.0.0 reformat_reencrypt_device().
2585 echoscip-shell system . . echo. $PWD1 | $CRYPTSETUP luksDump --dump-volume-key --volume-key-file $VKEY2 $DEV >/dev/nullscip-shell filesystem . . `/dev/null`. || failscip-shell shell shell-project 0.0.0 fail().
2586
2587 $CRYPTSETUP -q reencrypt --force-no-keyslots --volume-key-file $VKEY2 --new-volume-key-file $VKEY1 --new-key-size 256 $DEV <&- || failscip-shell shell shell-project 0.0.0 fail().
2588
2589 # missing key size information (no active keyslot)
2590 $CRYPTSETUP open --test-passphrase --volume-key-file $VKEY1 $DEV <&- 2>/dev/nullscip-shell filesystem . . `/dev/null`. && failscip-shell shell shell-project 0.0.0 fail().
2591 $CRYPTSETUP open --test-passphrase --volume-key-file $VKEY1 --key-size 256 $DEV <&- || failscip-shell shell shell-project 0.0.0 fail().
2592 $CRYPTSETUP open --test-passphrase --volume-key-file $VKEY2 --key-size 512 $DEV 2>/dev/nullscip-shell filesystem . . `/dev/null`. <&- && failscip-shell shell shell-project 0.0.0 fail().
2593
2594 echoscip-shell system . . echo. $PWD1 | $CRYPTSETUP luksAddKey --volume-key-file $VKEY1 --key-size 256 $FAST_PBKDF_ARGON $DEV || failscip-shell shell shell-project 0.0.0 fail().
2595 echoscip-shell system . . echo. $PWD1 | $CRYPTSETUP open --test-passphrase $DEV || failscip-shell shell shell-project 0.0.0 fail().
2596
2597 reformat_reencrypt_devicescip-shell shell shell-project 0.0.0 reformat_reencrypt_device().
2598 $CRYPTSETUP -q reencrypt --init-only --force-no-keyslots --volume-key-file $VKEY2 --new-volume-key-file $VKEY1 --new-key-size 256 $DEV <&- || failscip-shell shell shell-project 0.0.0 fail().
2599
2600 # For unlock operation we do not require specific --volume-key-file ordering (unlike in reencryption initialization)
2601 $CRYPTSETUP -q open --test-passphrase --volume-key-file $VKEY1 --key-size 256 --volume-key-file $VKEY2 --key-size 512 $DEV <&- || failscip-shell shell shell-project 0.0.0 fail().
2602
2603 # with 2 --volume-key-files options --key-size must be also supplied twice
2604 $CRYPTSETUP -q open --test-passphrase --volume-key-file $VKEY1 --volume-key-file $VKEY2 --key-size 512 $DEV 2>/dev/nullscip-shell filesystem . . `/dev/null`. <&- && failscip-shell shell shell-project 0.0.0 fail().
2605 # Missing old volume key
2606 $CRYPTSETUP -q open --test-passphrase --volume-key-file $VKEY2 --key-size 512 $DEV <&- 2>/dev/nullscip-shell filesystem . . `/dev/null`. && failscip-shell shell shell-project 0.0.0 fail().
2607
2608 $CRYPTSETUP -q open --volume-key-file $VKEY2 --key-size 512 --volume-key-file $VKEY1 --key-size 256 $DEV $DEV_NAME <&- || failscip-shell shell shell-project 0.0.0 fail().
2609
2610 $CRYPTSETUP -q reencrypt --resume-only --volume-key-file $VKEY2 --new-volume-key-file $VKEY1 --key-size 512 --new-key-size 256 $DEV <&- || failscip-shell shell shell-project 0.0.0 fail().
2611 $CRYPTSETUP close $DEV_NAME || failscip-shell shell shell-project 0.0.0 fail().
2612
2613 # wrong key size
2614 $CRYPTSETUP -q open --test-passphrase --volume-key-file $VKEY1 --key-size 512 $DEV <&- 2>/dev/nullscip-shell filesystem . . `/dev/null`. && failscip-shell shell shell-project 0.0.0 fail().
2615 # wrong key
2616 $CRYPTSETUP -q open --test-passphrase --volume-key-file $VKEY2 --key-size 256 $DEV <&- 2>/dev/nullscip-shell filesystem . . `/dev/null`. && failscip-shell shell shell-project 0.0.0 fail().
2617
2618 # missing key size
2619 $CRYPTSETUP -q open --test-passphrase --volume-key-file $VKEY1 $DEV <&- 2>/dev/nullscip-shell filesystem . . `/dev/null`. && failscip-shell shell shell-project 0.0.0 fail().
2620 $CRYPTSETUP -q open --test-passphrase --volume-key-file $VKEY1 --key-size 256 $DEV <&- || failscip-shell shell shell-project 0.0.0 fail().
2621
2622 # no remaining keyslots test (--force-no-keyslots is not needed)
2623 reformat_reencrypt_devicescip-shell shell shell-project 0.0.0 reformat_reencrypt_device().
2624 $CRYPTSETUP -q luksErase $DEV || failscip-shell shell shell-project 0.0.0 fail().
2625
2626 $CRYPTSETUP -q reencrypt --volume-key-file $VKEY2 -s 512 --new-volume-key-file $VKEY1 --new-key-size 256 $DEV <&- || failscip-shell shell shell-project 0.0.0 fail().
2627 $CRYPTSETUP open --test-passphrase --volume-key-file $VKEY1 --key-size 256 $DEV <&- || failscip-shell shell shell-project 0.0.0 fail().
2628
2629 reformat_reencrypt_devicescip-shell shell shell-project 0.0.0 reformat_reencrypt_device().
2630 $CRYPTSETUP -q luksErase $DEV || failscip-shell shell shell-project 0.0.0 fail().
2631 $CRYPTSETUP -q reencrypt --init-only --volume-key-file $VKEY2 -s 512 --new-volume-key-file $VKEY1 --new-key-size 256 $DEV <&- || failscip-shell shell shell-project 0.0.0 fail().
2632
2633 # For unlock operation we do not require specific --volume-key-file ordering (unlike in reencryption initialization)
2634 $CRYPTSETUP -q open --test-passphrase --volume-key-file $VKEY1 --key-size 256 --volume-key-file $VKEY2 --key-size 512 $DEV <&- || failscip-shell shell shell-project 0.0.0 fail().
2635
2636 # with 2 --volume-key-files options --key-size must be also supplied twice
2637 $CRYPTSETUP -q open --test-passphrase --volume-key-file $VKEY1 --volume-key-file $VKEY2 --key-size 512 $DEV 2>/dev/nullscip-shell filesystem . . `/dev/null`. <&- && failscip-shell shell shell-project 0.0.0 fail().
2638 # Missing old volume key
2639 $CRYPTSETUP -q open --test-passphrase --volume-key-file $VKEY2 --key-size 512 $DEV <&- 2>/dev/nullscip-shell filesystem . . `/dev/null`. && failscip-shell shell shell-project 0.0.0 fail().
2640
2641 $CRYPTSETUP -q open --volume-key-file $VKEY2 --key-size 512 --volume-key-file $VKEY1 --key-size 256 $DEV $DEV_NAME <&- || failscip-shell shell shell-project 0.0.0 fail().
2642
2643 $CRYPTSETUP -q reencrypt --resume-only --volume-key-file $VKEY2 --new-volume-key-file $VKEY1 --key-size 512 --new-key-size 256 $DEV <&- || failscip-shell shell shell-project 0.0.0 fail().
2644 $CRYPTSETUP close $DEV_NAME || failscip-shell shell shell-project 0.0.0 fail().
2645
2646 # reencryption by volume key in kernel keyring
2647 reformat_reencrypt_devicescip-shell shell shell-project 0.0.0 reformat_reencrypt_device().
2648 headscip-shell system . . head. -c 64 $VKEY2 | keyctl padd user $KEY_NAME_VK2 %:$KEYRING > /dev/nullscip-shell filesystem . . `/dev/null`. || failscip-shell shell shell-project 0.0.0 fail().
2649 headscip-shell system . . head. -c 32 $VKEY1 | keyctl padd user $KEY_NAME_VK1 %:$KEYRING > /dev/nullscip-shell filesystem . . `/dev/null`. || failscip-shell shell shell-project 0.0.0 fail().
2650
2651 $CRYPTSETUP -q reencrypt --force-no-keyslots --volume-key-keyring $KEY_NAME_VK2 --new-volume-key-keyring $KEY_NAME_VK1 $DEV <&- || failscip-shell shell shell-project 0.0.0 fail().
2652
2653 # test unlock with key after reencryption
2654 $CRYPTSETUP open --test-passphrase --volume-key-keyring $KEY_NAME_VK1 $DEV <&- || failscip-shell shell shell-project 0.0.0 fail().
2655 $CRYPTSETUP open --test-passphrase --volume-key-keyring $KEY_NAME_VK2 $DEV <&- 2>/dev/nullscip-shell filesystem . . `/dev/null`. && failscip-shell shell shell-project 0.0.0 fail().
2656
2657 reformat_reencrypt_devicescip-shell shell shell-project 0.0.0 reformat_reencrypt_device().
2658 $CRYPTSETUP -q reencrypt --init-only --force-no-keyslots --volume-key-keyring $KEY_NAME_VK2 --new-volume-key-keyring $KEY_NAME_VK1 $DEV <&- || failscip-shell shell shell-project 0.0.0 fail().
2659
2660 # For unlock operation we do not require specific --volume-key-file ordering (unlike in reencryption initialization)
2661 $CRYPTSETUP -q open --test-passphrase --volume-key-keyring $KEY_NAME_VK1 --volume-key-keyring $KEY_NAME_VK2 $DEV <&- || failscip-shell shell shell-project 0.0.0 fail().
2662
2663 # Missing old volume key
2664 $CRYPTSETUP -q open --test-passphrase --volume-key-keyring $KEY_NAME_VK1 $DEV <&- 2>/dev/nullscip-shell filesystem . . `/dev/null`. && failscip-shell shell shell-project 0.0.0 fail().
2665
2666 $CRYPTSETUP -q open --volume-key-keyring $KEY_NAME_VK1 --volume-key-keyring $KEY_NAME_VK2 $DEV $DEV_NAME <&- || failscip-shell shell shell-project 0.0.0 fail().
2667
2668 $CRYPTSETUP -q reencrypt --resume-only --volume-key-keyring $KEY_NAME_VK2 --new-volume-key-keyring $KEY_NAME_VK1 $DEV <&- || failscip-shell shell shell-project 0.0.0 fail().
2669 $CRYPTSETUP close $DEV_NAME || failscip-shell shell shell-project 0.0.0 fail().
2670
2671 # no remaining keyslots test (--force-no-keyslots is not needed)
2672 reformat_reencrypt_devicescip-shell shell shell-project 0.0.0 reformat_reencrypt_device().
2673 $CRYPTSETUP -q luksErase $DEV || failscip-shell shell shell-project 0.0.0 fail().
2674
2675 $CRYPTSETUP -q reencrypt --volume-key-keyring $KEY_NAME_VK2 --new-volume-key-keyring $KEY_NAME_VK1 $DEV <&- || failscip-shell shell shell-project 0.0.0 fail().
2676
2677 reformat_reencrypt_devicescip-shell shell shell-project 0.0.0 reformat_reencrypt_device().
2678 $CRYPTSETUP -q luksErase $DEV || failscip-shell shell shell-project 0.0.0 fail().
2679 $CRYPTSETUP -q reencrypt --init-only --volume-key-keyring $KEY_NAME_VK2 --new-volume-key-keyring $KEY_NAME_VK1 $DEV <&- || failscip-shell shell shell-project 0.0.0 fail().
2680
2681 # For unlock operation we do not require specific --volume-key-file ordering (unlike in reencryption initialization)
2682 $CRYPTSETUP -q open --test-passphrase --volume-key-keyring $KEY_NAME_VK1 --volume-key-keyring $KEY_NAME_VK2 $DEV <&- || failscip-shell shell shell-project 0.0.0 fail().
2683
2684 # Missing old volume key
2685 $CRYPTSETUP -q open --test-passphrase --volume-key-keyring $KEY_NAME_VK2 $DEV <&- 2>/dev/nullscip-shell filesystem . . `/dev/null`. && failscip-shell shell shell-project 0.0.0 fail().
2686
2687 $CRYPTSETUP -q open --volume-key-keyring $KEY_NAME_VK1 --volume-key-keyring $KEY_NAME_VK2 $DEV $DEV_NAME <&- || failscip-shell shell shell-project 0.0.0 fail().
2688
2689 $CRYPTSETUP -q reencrypt --resume-only --volume-key-keyring $KEY_NAME_VK2 --new-volume-key-keyring $KEY_NAME_VK1 $DEV <&- || failscip-shell shell shell-project 0.0.0 fail().
2690 $CRYPTSETUP close $DEV_NAME || failscip-shell shell shell-project 0.0.0 fail().
2691
2692 # test b0rked kernel keys
2693 reformat_reencrypt_devicescip-shell shell shell-project 0.0.0 reformat_reencrypt_device().
2694 # erase all but one keyslot so that we verify original volume key size
2695 $CRYPTSETUP luksKillSlot -q $DEV 4 || failscip-shell shell shell-project 0.0.0 fail().
2696 $CRYPTSETUP luksKillSlot -q $DEV 6 || failscip-shell shell shell-project 0.0.0 fail().
2697 $CRYPTSETUP luksKillSlot -q $DEV 8 || failscip-shell shell shell-project 0.0.0 fail().
2698 $CRYPTSETUP luksKillSlot -q $DEV 10 || failscip-shell shell shell-project 0.0.0 fail().
2699 $CRYPTSETUP luksKillSlot -q $DEV 12 || failscip-shell shell shell-project 0.0.0 fail().
2700
2701 headscip-shell system . . head. -c 63 $VKEY2 | keyctl padd user $KEY_NAME_VK2 %:$KEYRING > /dev/nullscip-shell filesystem . . `/dev/null`. || failscip-shell shell shell-project 0.0.0 fail().
2702 $CRYPTSETUP -q reencrypt --init-only --volume-key-keyring $KEY_NAME_VK2 --new-volume-key-keyring $KEY_NAME_VK1 $DEV <&- 2>/dev/nullscip-shell filesystem . . `/dev/null`. && failscip-shell shell shell-project 0.0.0 fail().
2703 $CRYPTSETUP luksDump $DEV | grepscip-shell system . . grep. -q "online-reencrypt" && failscip-shell shell shell-project 0.0.0 fail(). "Failed initialization with reencryption flag"
2704
2705 headscip-shell system . . head. -c 64 $VKEY2 | keyctl padd user $KEY_NAME_VK2 %:$KEYRING > /dev/nullscip-shell filesystem . . `/dev/null`. || failscip-shell shell shell-project 0.0.0 fail().
2706 $CRYPTSETUP open --test-passphrase --volume-key-keyring $KEY_NAME_VK2 $DEV || failscip-shell shell shell-project 0.0.0 fail().
2707
2708 # new key size incompatible with cipher
2709 headscip-shell system . . head. -c 31 $VKEY1 | keyctl padd user $KEY_NAME_VK1 %:$KEYRING > /dev/nullscip-shell filesystem . . `/dev/null`. || failscip-shell shell shell-project 0.0.0 fail().
2710 $CRYPTSETUP -q reencrypt --init-only --volume-key-keyring $KEY_NAME_VK2 --new-volume-key-keyring $KEY_NAME_VK1 $DEV <&- 2>/dev/nullscip-shell filesystem . . `/dev/null`. && failscip-shell shell shell-project 0.0.0 fail().
2711 $CRYPTSETUP luksDump $DEV | grepscip-shell system . . grep. -q "online-reencrypt" && failscip-shell shell shell-project 0.0.0 fail(). "Failed initialization with reencryption flag"
2712
2713 remove_mappingscip-shell shell shell-project 0.0.0 remove_mapping().
2714 cleanup_keyringscip-shell shell shell-project 0.0.0 cleanup_keyring().
2715 exit 0