| 1 | #!/bin/bash |
| 2 | # |
| 3 | # Test integritysetup compatibility. |
| 4 | # |
| 5 | [ -z "$CRYPTSETUP_PATH" ] && CRYPTSETUP_PATH=".." |
| 6 | INTSETUP=$CRYPTSETUP_PATH/integritysetup |
| 7 | |
| 8 | if [ -n "$CRYPTSETUP_TESTS_RUN_IN_MESON" ]; then |
| 9 | INTSETUP_VALGRIND=$INTSETUP |
| 10 | else |
| 11 | INTSETUP_VALGRIND=../.libs/integritysetup |
| 12 | INTSETUP_LIB_VALGRIND=../.libs |
| 13 | fi |
| 14 | |
| 15 | DEV_NAME=dmc_test |
| 16 | DEV_NAME2=dmc_fake |
| 17 | DEV_LOOP="" |
| 18 | DEV=test123.img |
| 19 | DEV2=test124.img |
| 20 | KEY_FILE=key.img |
| 21 | KEY_FILE2=key2.img |
| 22 | |
| 23 | dmremove() { # device |
| 24 | udevadm settle >/dev/null 2>&1 |
| 25 | dmsetup remove --retry $1 >/dev/null 2>&1 |
| 26 | } |
| 27 | |
| 28 | cleanup() { |
| 29 | [ -b /dev/mapper/$DEV_NAME ] && dmremove $DEV_NAME |
| 30 | [ -b /dev/mapper/$DEV_NAME2 ] && dmremove $DEV_NAME2 |
| 31 | [ -n "$DEV_LOOP" ] && losetup -d "$DEV_LOOP" |
| 32 | DEV_LOOP="" |
| 33 | IDEV="" |
| 34 | rm -f $DEV $DEV2 $KEY_FILE $KEY_FILE2 >/dev/null 2>&1 |
| 35 | } |
| 36 | |
| 37 | fail() |
| 38 | { |
| 39 | [ -n "$1" ] && echo "$1" |
| 40 | echo "FAILED backtrace:" |
| 41 | while caller $frame; do ((frame++)); done |
| 42 | cleanup |
| 43 | exit 100 |
| 44 | } |
| 45 | |
| 46 | _sigchld() { local c=$?; [ $c -eq 139 ] && fail "Segfault"; [ $c -eq 134 ] && fail "Aborted"; } |
| 47 | trap _sigchld CHLD |
| 48 | |
| 49 | skip() |
| 50 | { |
| 51 | [ -n "$1" ] && echo "$1" |
| 52 | exit 77 |
| 53 | } |
| 54 | |
| 55 | dm_integrity_features() |
| 56 | { |
| 57 | VER_STR=$(dmsetup targets | grep integrity | cut -f2 -dv) |
| 58 | [ -z "$VER_STR" ] && skip "Cannot find dm-integrity target, test skipped." |
| 59 | |
| 60 | VER_MAJ=$(echo $VER_STR | cut -f 1 -d.) |
| 61 | VER_MIN=$(echo $VER_STR | cut -f 2 -d.) |
| 62 | VER_PTC=$(echo $VER_STR | cut -f 3 -d.) |
| 63 | |
| 64 | [ $VER_MAJ -lt 1 ] && return |
| 65 | [ $VER_MAJ -gt 1 ] && { |
| 66 | DM_INTEGRITY_META=1 |
| 67 | DM_INTEGRITY_RECALC=1 |
| 68 | DM_INTEGRITY_BITMAP=1 |
| 69 | DM_INTEGRITY_RESIZE_SUPPORTED=1 |
| 70 | DM_INTEGRITY_HMAC_FIX=1 |
| 71 | DM_INTEGRITY_RESET=1 |
| 72 | DM_INTEGRITY_INLINE=1 |
| 73 | DM_INTEGRITY_RECALCULATE_INLINE=1 |
| 74 | return |
| 75 | } |
| 76 | [ $VER_MIN -gt 1 ] && { |
| 77 | DM_INTEGRITY_META=1 |
| 78 | DM_INTEGRITY_RECALC=1 |
| 79 | } |
| 80 | [ $VER_MIN -gt 2 ] && { |
| 81 | DM_INTEGRITY_BITMAP=1 |
| 82 | } |
| 83 | [ $VER_MIN -gt 5 ] && { |
| 84 | DM_INTEGRITY_RESIZE_SUPPORTED=1 |
| 85 | } |
| 86 | [ $VER_MIN -gt 6 ] && { |
| 87 | DM_INTEGRITY_HMAC_FIX=1 |
| 88 | } |
| 89 | [ $VER_MIN -gt 7 ] && { |
| 90 | DM_INTEGRITY_RESET=1 |
| 91 | } |
| 92 | [ $VER_MIN -ge 12 ] && { |
| 93 | DM_INTEGRITY_INLINE=1 |
| 94 | } |
| 95 | [ $VER_MIN -ge 13 ] && { |
| 96 | DM_INTEGRITY_RECALCULATE_INLINE=1 |
| 97 | } |
| 98 | } |
| 99 | |
| 100 | add_device() { |
| 101 | cleanup |
| 102 | dd if=/dev/urandom of=$KEY_FILE bs=4096 count=1 >/dev/null 2>&1 |
| 103 | dd if=/dev/urandom of=$KEY_FILE2 bs=1 count=32 >/dev/null 2>&1 |
| 104 | dd if=/dev/zero of=$DEV bs=1M count=32 >/dev/null 2>&1 |
| 105 | dd if=/dev/zero of=$DEV2 bs=1M count=32 >/dev/null 2>&1 |
| 106 | IDEV=$DEV |
| 107 | INLINE_PARAMS="" |
| 108 | } |
| 109 | |
| 110 | add_device_inline() { |
| 111 | cleanup |
| 112 | add_device |
| 113 | DEV_LOOP=$(losetup -f $DEV --show) |
| 114 | [ -z "$DEV_LOOP" ] && fail |
| 115 | dmsetup create $DEV_NAME2 --table "0 32768 integrity $DEV_LOOP 0 64 J 2 block_size:4096 fix_padding" |
| 116 | [ ! -b /dev/mapper/$DEV_NAME2 ] && fail |
| 117 | IDEV=/dev/mapper/$DEV_NAME2 |
| 118 | INLINE_PARAMS="--integrity-inline " |
| 119 | } |
| 120 | |
| 121 | status_check() # name value |
| 122 | { |
| 123 | X=$($INTSETUP status $DEV_NAME | grep "$1" | sed 's/.*: //' | sed 's/^[[:space:]]*//') |
| 124 | if [ "$X" != "$2" ] ; then |
| 125 | echo "[status FAIL]" |
| 126 | echo " Expecting $1:$2 got \"$X\"." |
| 127 | fail |
| 128 | fi |
| 129 | } |
| 130 | |
| 131 | dump_check() # name value |
| 132 | { |
| 133 | X=$($INTSETUP dump $IDEV | grep "$1" | sed 's/.*: //' | cut -d' ' -f 1) |
| 134 | if [ "$X" != "$2" ] ; then |
| 135 | echo "[dump FAIL]" |
| 136 | echo " Expecting $1:$2 got \"$X\"." |
| 137 | fail |
| 138 | fi |
| 139 | } |
| 140 | |
| 141 | kernel_param_check() # number value |
| 142 | { |
| 143 | X=$(dmsetup table $DEV_NAME | cut -d " " -f $1) |
| 144 | if [ "$X" != $2 ] ; then |
| 145 | echo "[param_check FAIL]" |
| 146 | echo "Expecting $2 got \"$X\"." |
| 147 | fail |
| 148 | fi |
| 149 | } |
| 150 | |
| 151 | kernel_param_grep() |
| 152 | { |
| 153 | dmsetup table $DEV_NAME | grep -q "$1" |
| 154 | } |
| 155 | |
| 156 | valgrind_setup() |
| 157 | { |
| 158 | command -v valgrind >/dev/null || fail "Cannot find valgrind." |
| 159 | [ ! -f $INTSETUP_VALGRIND ] && fail "Unable to get location of cryptsetup executable." |
| 160 | [ ! -f valg.sh ] && fail "Unable to get location of valg runner script." |
| 161 | if [ -z "$CRYPTSETUP_TESTS_RUN_IN_MESON" ]; then |
| 162 | export LD_LIBRARY_PATH="$INTSETUP_LIB_VALGRIND:$LD_LIBRARY_PATH" |
| 163 | fi |
| 164 | } |
| 165 | |
| 166 | valgrind_run() |
| 167 | { |
| 168 | INFOSTRING="$(basename ${BASH_SOURCE[1]})-line-${BASH_LINENO[0]}" ./valg.sh ${INTSETUP_VALGRIND} "$@" |
| 169 | } |
| 170 | |
| 171 | int_check_sum_only() # checksum |
| 172 | { |
| 173 | VSUM=$(sha256sum /dev/mapper/$DEV_NAME | cut -d' ' -f 1) |
| 174 | if [ "$VSUM" = "$1" ] ; then |
| 175 | echo -n "[CHECKSUM OK]" |
| 176 | else |
| 177 | echo "[FAIL]" |
| 178 | echo " Expecting $1 got $VSUM." |
| 179 | fail |
| 180 | fi |
| 181 | } |
| 182 | |
| 183 | int_check_sum() # alg checksum [keyfile keysize] |
| 184 | { |
| 185 | if [ -n "$4" ] ; then |
| 186 | KEY_PARAMS="--integrity-key-file $3 --integrity-key-size $4" |
| 187 | else |
| 188 | KEY_PARAMS="" |
| 189 | fi |
| 190 | |
| 191 | # Fill device with zeroes and reopen it |
| 192 | dd if=/dev/zero of=/dev/mapper/$DEV_NAME bs=1M oflag=direct >/dev/null 2>&1 |
| 193 | dmremove $DEV_NAME |
| 194 | |
| 195 | $INTSETUP open $IDEV $DEV_NAME --integrity $1 $KEY_PARAMS || fail "Cannot activate device." |
| 196 | |
| 197 | int_check_sum_only $2 |
| 198 | } |
| 199 | |
| 200 | intformat() # alg alg_out tagsize outtagsize sector_size csum [keyfile keysize] |
| 201 | { |
| 202 | if [ -n "$8" ] ; then |
| 203 | KEY_PARAMS="--integrity-key-file $7 --integrity-key-size $8" |
| 204 | else |
| 205 | KEY_PARAMS="" |
| 206 | fi |
| 207 | |
| 208 | if [ $3 -ne 0 ] ; then |
| 209 | TAG_PARAMS="--tag-size $3" |
| 210 | else |
| 211 | TAG_PARAMS="" |
| 212 | fi |
| 213 | |
| 214 | echo -n "[INTEGRITY:$2:$4:$5]" |
| 215 | [ -n "$8" ] && echo -n "[KEYFILE:$8]" |
| 216 | echo -n "[FORMAT]" |
| 217 | $INTSETUP format --integrity-legacy-padding -q --integrity $1 $INLINE_PARAMS $TAG_PARAMS --sector-size $5 $KEY_PARAMS $IDEV >/dev/null 2>&1 |
| 218 | if [ $? -ne 0 ] ; then |
| 219 | if [[ $1 =~ "sha2" || $1 =~ "crc" ]] ; then |
| 220 | fail "Cannot format device." |
| 221 | fi |
| 222 | echo "[N/A]" |
| 223 | return |
| 224 | fi |
| 225 | |
| 226 | dump_check "tag size" $4 |
| 227 | dump_check "sector size" $5 |
| 228 | echo -n "[ACTIVATE]" |
| 229 | $INTSETUP open $IDEV $DEV_NAME --integrity $1 $KEY_PARAMS || fail "Cannot activate device." |
| 230 | if [ -n "$8" ]; then |
| 231 | KEY_HEX=$(xxd -c 4096 -l $8 -p $7) |
| 232 | [ -z "$KEY_HEX" ] && fail "Cannot decode key." |
| 233 | dmsetup table --showkeys $DEV_NAME | grep -q $KEY_HEX || fail "Key mismatch." |
| 234 | fi |
| 235 | status_check "tag size" "$4 [bytes]" |
| 236 | status_check "integrity" $2 |
| 237 | status_check "sector size" "$5 [bytes]" |
| 238 | |
| 239 | SIZE_BYTES=$(blockdev --getsize64 /dev/mapper/$DEV_NAME) |
| 240 | SIZE_512S=$(( $SIZE_BYTES / 512 )) |
| 241 | status_check " size" "$SIZE_512S [512-byte units] ($SIZE_BYTES [bytes])" |
| 242 | |
| 243 | int_check_sum $1 $6 $7 $8 |
| 244 | |
| 245 | echo -n "[REMOVE]" |
| 246 | $INTSETUP close $DEV_NAME || fail "Cannot deactivate device." |
| 247 | echo "[OK]" |
| 248 | } |
| 249 | |
| 250 | int_error_detection() # mode alg tagsize outtagsize sector_size key_file key_size |
| 251 | { |
| 252 | if [ "$1" == "B" ] ; then |
| 253 | INT_MODE="-B" |
| 254 | else |
| 255 | INT_MODE="" |
| 256 | fi |
| 257 | if [ -n "$7" ] ; then |
| 258 | KEY_PARAMS="--integrity-key-file $6 --integrity-key-size $7" |
| 259 | else |
| 260 | KEY_PARAMS="" |
| 261 | fi |
| 262 | if [ $3 -ne 0 ] ; then |
| 263 | TAG_PARAMS="--tag-size $3" |
| 264 | else |
| 265 | TAG_PARAMS="" |
| 266 | fi |
| 267 | dd if=/dev/zero of=$IDEV bs=1M count=32 >/dev/null 2>&1 |
| 268 | |
| 269 | echo -n "[INTEGRITY:$1:$2:$4:$5]" |
| 270 | echo -n "[FORMAT]" |
| 271 | $INTSETUP format -q --integrity $2 $INLINE_PARAMS $TAG_PARAMS --sector-size $5 $KEY_PARAMS $IDEV $INT_MODE >/dev/null 2>&1 |
| 272 | if [ $? -ne 0 ] ; then |
| 273 | if [[ $2 =~ "sha2" || $2 =~ "crc" ]] ; then |
| 274 | fail "Cannot format device." |
| 275 | fi |
| 276 | echo "[N/A]" |
| 277 | return |
| 278 | fi |
| 279 | echo -n "[ACTIVATE]" |
| 280 | $INTSETUP open $IDEV $DEV_NAME --integrity $2 --integrity-no-journal $KEY_PARAMS $INT_MODE || fail "Cannot activate device." |
| 281 | |
| 282 | if [ -n "$6" -a -n "$7" ]; then |
| 283 | echo -n "[KEYED HASH]" |
| 284 | KEY_HEX=$(xxd -c 256 -l $7 -p $6) |
| 285 | [ -z "$KEY_HEX" ] && fail "Cannot decode key." |
| 286 | dmsetup table --showkeys $DEV_NAME | grep -q $KEY_HEX || fail "Key mismatch." |
| 287 | fi |
| 288 | |
| 289 | echo -n "[WRITE DATA]" |
| 290 | echo -n "EXAMPLE TEXT" | dd of=/dev/mapper/$DEV_NAME >/dev/null 2>&1 || fail "Cannot write to device." |
| 291 | $INTSETUP close $DEV_NAME || fail "Cannot deactivate device." |
| 292 | |
| 293 | # find offset of data area |
| 294 | ARR=($(dd if=$IDEV bs=512 2>/dev/null | hexdump -C | grep 'EXAMPLE TEXT')) |
| 295 | OFF_HEX=${ARR[0]} |
| 296 | OFF_DEC=$((16#$OFF_HEX)) |
| 297 | |
| 298 | echo -n "[CORRUPT DATA:$OFF_DEC]" |
| 299 | echo -n "Z" | dd of=$IDEV bs=1 seek=$OFF_DEC conv=notrunc >/dev/null 2>&1 || fail "Cannot write to device." |
| 300 | |
| 301 | echo -n "[DETECT ERROR]" |
| 302 | $INTSETUP open $IDEV $DEV_NAME --integrity $2 $KEY_PARAMS $INT_MODE || fail "Cannot activate device." |
| 303 | dd if=/dev/mapper/$DEV_NAME >/dev/null 2>&1 && fail "Error detection failed." |
| 304 | echo -n "[REMOVE]" |
| 305 | $INTSETUP close $DEV_NAME || fail "Cannot deactivate device." |
| 306 | echo "[OK]" |
| 307 | } |
| 308 | |
| 309 | int_journal() # 1 alg, 2 tagsize, 3 sector_size, 4 watermark, 5 commit_time, 6 journal_integrity, 7 key-file, 8 key-size, 9 journal_integrity_out |
| 310 | { |
| 311 | echo -n "[INTEGRITY JOURNAL:$6:${4}%:${5}ms:$8]" |
| 312 | echo -n "[FORMAT]" |
| 313 | ARGS="--integrity $1 --journal-watermark $4 --journal-commit-time $5 --journal-integrity $6 --journal-integrity-key-file $7 --journal-integrity-key-size $8" |
| 314 | $INTSETUP format -q --tag-size $2 --sector-size $3 $ARGS $DEV || fail "Cannot format device." |
| 315 | |
| 316 | echo -n "[ACTIVATE]" |
| 317 | |
| 318 | $INTSETUP open $DEV $DEV_NAME $ARGS || fail "Cannot activate device." |
| 319 | |
| 320 | echo -n "[KEYED HASH]" |
| 321 | KEY_HEX=$(xxd -c 4096 -l $8 -p $7) |
| 322 | [ -z "$KEY_HEX" ] && fail "Cannot decode key." |
| 323 | dmsetup table --showkeys $DEV_NAME | grep -q $KEY_HEX || fail "Key mismatch." |
| 324 | |
| 325 | status_check "journal watermark" "${4}%" |
| 326 | status_check "journal commit time" "${5} [ms]" |
| 327 | status_check "journal integrity MAC" $9 |
| 328 | |
| 329 | echo -n "[REMOVE]" |
| 330 | $INTSETUP close $DEV_NAME || fail "Cannot deactivate device." |
| 331 | echo "[OK]" |
| 332 | } |
| 333 | |
| 334 | |
| 335 | int_journal_crypt() # crypt_alg crypt_alg_kernel crypt_key crypt_key_size |
| 336 | { |
| 337 | echo -n "[JOURNAL CRYPT:$1:${4}B]" |
| 338 | |
| 339 | echo -n "[FORMAT]" |
| 340 | ARGS="--journal-crypt $1 --journal-crypt-key-file $3 --journal-crypt-key-size $4" |
| 341 | $INTSETUP format -q $ARGS $DEV || fail "Cannot format device." |
| 342 | |
| 343 | echo -n "[ACTIVATE]" |
| 344 | $INTSETUP open $DEV $DEV_NAME $ARGS || fail "Cannot activate device." |
| 345 | |
| 346 | KEY_HEX=$(xxd -c 256 -l $4 -p $3) |
| 347 | [ -z "$KEY_HEX" ] && fail "Cannot decode key." |
| 348 | dmsetup table --showkeys $DEV_NAME | grep -q "journal_crypt:$2:$KEY_HEX" || fail "Key mismatch." |
| 349 | |
| 350 | $INTSETUP close $DEV_NAME |
| 351 | echo "[OK]" |
| 352 | } |
| 353 | |
| 354 | int_mode() # alg tag_size sector_size [keyfile keysize] |
| 355 | { |
| 356 | if [ -n "$5" ] ; then |
| 357 | KEY_PARAMS="--integrity-key-file $4 --integrity-key-size $5" |
| 358 | else |
| 359 | KEY_PARAMS="" |
| 360 | fi |
| 361 | |
| 362 | echo -n "[MODE TESTS:$1:$2:$3]" |
| 363 | ARGS="--tag-size $2 --sector-size $3" |
| 364 | |
| 365 | $INTSETUP format -q $ARGS $KEY_PARAMS $DEV --integrity $1 || fail "Cannot format device." |
| 366 | |
| 367 | echo -n "[JOURNALED WRITES]" |
| 368 | $INTSETUP open $DEV $DEV_NAME --integrity $1 $KEY_PARAMS || fail "Cannot activate device with journal." |
| 369 | status_check "mode" "read/write" |
| 370 | kernel_param_check 7 "J" |
| 371 | |
| 372 | $INTSETUP close $DEV_NAME || fail "Cannot deactivate device." |
| 373 | |
| 374 | echo -n "[DIRECT WRITES]" |
| 375 | $INTSETUP open $DEV $DEV_NAME --integrity $1 $KEY_PARAMS --integrity-no-journal || fail "Cannot activate device without journal." |
| 376 | status_check "mode" "read/write" |
| 377 | status_check "journal" "not active" |
| 378 | kernel_param_check 7 "D" |
| 379 | |
| 380 | $INTSETUP close $DEV_NAME || fail "Cannot deactivate device." |
| 381 | |
| 382 | echo -n "[RECOVERY MODE]" |
| 383 | $INTSETUP open $DEV $DEV_NAME --integrity $1 $KEY_PARAMS --integrity-recovery-mode || fail "Cannot activate device in recovery mode." |
| 384 | status_check "mode" "read/write recovery" |
| 385 | kernel_param_check 7 "R" |
| 386 | |
| 387 | $INTSETUP close $DEV_NAME || fail "Cannot deactivate device." |
| 388 | |
| 389 | echo "[OK]" |
| 390 | } |
| 391 | |
| 392 | check_device_size() # device_name expected_size error_message |
| 393 | { |
| 394 | CURRENT_SIZE=$(dmsetup table | grep $1 | cut -d' ' -f 3) |
| 395 | [ $CURRENT_SIZE -eq $2 ] || fail "$3: expected $1 to be of size $2, but is $CURRENT_SIZE" |
| 396 | } |
| 397 | |
| 398 | test_resize() # description detached_metadata wipe args |
| 399 | { |
| 400 | echo -n "$1" |
| 401 | if [ -z "$DM_INTEGRITY_RESIZE_SUPPORTED" ] ; then |
| 402 | echo "[N/A]" |
| 403 | return |
| 404 | fi |
| 405 | |
| 406 | args="$4" |
| 407 | if [ $2 -ne 0 ] ; then |
| 408 | echo -n "[DETACHED]" |
| 409 | else |
| 410 | echo -n "[INTERLEAVE]" |
| 411 | fi |
| 412 | if [ $3 -ne 0 ] ; then |
| 413 | wipe_flag="--wipe" |
| 414 | echo -n "[WIPE]" |
| 415 | else |
| 416 | wipe_flag="" |
| 417 | echo -n "[RECALCULATE]" |
| 418 | fi |
| 419 | |
| 420 | add_device |
| 421 | if [ $2 -ne 0 ] ; then |
| 422 | echo -n "[FORMAT]" |
| 423 | $INTSETUP format -q $args $DEV2 --data-device $DEV >/dev/null 2>&1 || fail "Cannot format device." |
| 424 | echo -n "[ACTIVATE]" |
| 425 | $INTSETUP open -q $args $DEV2 $DEV_NAME --data-device $DEV >/dev/null 2>&1 || fail "Cannot activate device." |
| 426 | else |
| 427 | echo -n "[FORMAT]" |
| 428 | $INTSETUP format -q $args $DEV >/dev/null 2>&1 || fail "Cannot format device." |
| 429 | echo -n "[ACTIVATE]" |
| 430 | $INTSETUP open -q $args $DEV $DEV_NAME >/dev/null 2>&1 || fail "Cannot activate device." |
| 431 | fi |
| 432 | |
| 433 | if [ $2 -ne 0 ] ; then |
| 434 | # the whole device has 32MiB, if metadata is detached |
| 435 | WHOLE_DISK_SIZE=65536 |
| 436 | else |
| 437 | WHOLE_DISK_SIZE=$(dmsetup table | grep $DEV_NAME | cut -d' ' -f 3) |
| 438 | fi |
| 439 | |
| 440 | echo -n "[SHRINK]" |
| 441 | $INTSETUP resize -q $wipe_flag $DEV_NAME --device-size 1MiB || fail "Failed to resize the device to 1MiB." |
| 442 | dd if=/dev/mapper/$DEV_NAME >/dev/null 2>&1 || fail "Errors detected after shrink." |
| 443 | check_device_size $DEV_NAME $(( 1024*1024 / 512 )) "Shrinking device failed" |
| 444 | |
| 445 | echo -n "[FILL]" |
| 446 | $INTSETUP resize -q $wipe_flag $DEV_NAME --device-size 0 || fail "Failed to resize the device to maximum size." |
| 447 | dd if=/dev/mapper/$DEV_NAME >/dev/null 2>&1 || fail "Errors detected after resize to maximum size." |
| 448 | check_device_size $DEV_NAME $WHOLE_DISK_SIZE "Resizing disk to maximum size failed" |
| 449 | |
| 450 | echo -n "[EXPAND FIXED]" |
| 451 | truncate -s 64M $DEV || fail |
| 452 | $INTSETUP resize -q $wipe_flag $DEV_NAME --device-size 40MiB || fail "Failed to expand the device to a fixed size." |
| 453 | dd if=/dev/mapper/$DEV_NAME >/dev/null 2>&1 || fail "Errors detected after expanding to a fixed size." |
| 454 | check_device_size $DEV_NAME $(( 40*1024*1024 / 512 )) "Resizing disk after expanding to a fixed size failed" |
| 455 | |
| 456 | echo -n "[FILL]" |
| 457 | $INTSETUP resize -q $wipe_flag $DEV_NAME --device-size 0 >/dev/null 2>&1 || fail "Failed to resize the device to maximum size after increasing image size." |
| 458 | dd if=/dev/mapper/$DEV_NAME >/dev/null 2>&1 || fail "Error detection failed after increasing image size." |
| 459 | CURRENT_SIZE=$(dmsetup table | grep $DEV_NAME | cut -d' ' -f 3) |
| 460 | [ $CURRENT_SIZE -ge $(( 40*1024*1024 / 512 )) ] || fail "Growing integrity device failed $CURRENT_SIZE is not greater than 40MB ($(( 40*1024*1024 / 512 )) blocks)." |
| 461 | if [ $2 -ne 0 ] ; then |
| 462 | [ $CURRENT_SIZE -eq 131072 ] || fail "Growing integrity device failed $CURRENT_SIZE is not equal to 64MB (131072 blocks)." |
| 463 | fi |
| 464 | |
| 465 | echo -n "[REMOVE]" |
| 466 | $INTSETUP close $DEV_NAME || fail "Cannot deactivate device." |
| 467 | echo "[OK]" |
| 468 | } |
| 469 | |
| 470 | [ $(id -u) != 0 ] && skip "WARNING: You must be root to run this test, test skipped." |
| 471 | [ ! -x "$INTSETUP" ] && skip "Cannot find $INTSETUP, test skipped." |
| 472 | command -v blockdev >/dev/null || skip "Cannot find blockdev utility, test skipped." |
| 473 | |
| 474 | [ -n "$VALG" ] && valgrind_setup && INTSETUP=valgrind_run |
| 475 | command -v hexdump >/dev/null || skip "WARNING: hexdump tool required." |
| 476 | command -v xxd >/dev/null || skip "WARNING: xxd tool required." |
| 477 | modprobe dm-integrity >/dev/null 2>&1 |
| 478 | dm_integrity_features |
| 479 | |
| 480 | echo "Integrity mode tests:" |
| 481 | add_device |
| 482 | intformat blake2s-256 blake2s-256 32 32 512 8e5fe4119558e117bfc40e3b0f13ade3abe497b52604d4c7cca0cfd6c7f4cf11 |
| 483 | intformat blake2b-256 blake2b-256 32 32 512 8e5fe4119558e117bfc40e3b0f13ade3abe497b52604d4c7cca0cfd6c7f4cf11 |
| 484 | intformat crc32c crc32c 0 4 512 08f63eb27fb9ce2ce903b0a56429c68ce5e209253ba42154841ef045a53839d7 |
| 485 | intformat crc32 crc32 0 4 512 08f63eb27fb9ce2ce903b0a56429c68ce5e209253ba42154841ef045a53839d7 |
| 486 | intformat xxhash64 xxhash64 0 8 512 6ff6bb889a8485f1fb26aa82671ff5da64f60381fc469e31d7be6094241eee09 |
| 487 | intformat sha1 sha1 0 20 512 6eedd6344dab8875cd185fcd6565dfc869ab36bc57e577f40c685290b1fa7fe7 |
| 488 | intformat sha1 sha1 16 16 4096 e152ec88227b539cd9cafd8bdb587a1072d720cd6bcebe1398d4136c9e7f337b |
| 489 | intformat sha256 sha256 0 32 512 8e5fe4119558e117bfc40e3b0f13ade3abe497b52604d4c7cca0cfd6c7f4cf11 |
| 490 | intformat hmac-sha256 hmac\(sha256\) 0 32 512 8e5fe4119558e117bfc40e3b0f13ade3abe497b52604d4c7cca0cfd6c7f4cf11 $KEY_FILE 32 |
| 491 | intformat sha256 sha256 0 32 4096 33f7dfa5163ca9f740383fb8b0919574e38a7b20a94a4170fde4238196b7c4b4 |
| 492 | intformat hmac-sha256 hmac\(sha256\) 0 32 4096 33f7dfa5163ca9f740383fb8b0919574e38a7b20a94a4170fde4238196b7c4b4 $KEY_FILE 32 |
| 493 | intformat hmac-sha256 hmac\(sha256\) 0 32 4096 33f7dfa5163ca9f740383fb8b0919574e38a7b20a94a4170fde4238196b7c4b4 $KEY_FILE 4096 |
| 494 | |
| 495 | echo "Error detection tests:" |
| 496 | int_error_detection J crc32c 0 4 512 |
| 497 | int_error_detection J crc32c 0 4 4096 |
| 498 | int_error_detection J crc32 0 4 512 |
| 499 | int_error_detection J crc32 0 4 4096 |
| 500 | int_error_detection J xxhash64 0 8 512 |
| 501 | int_error_detection J xxhash64 0 8 4096 |
| 502 | int_error_detection J sha1 0 20 512 |
| 503 | int_error_detection J sha1 16 16 512 |
| 504 | int_error_detection J sha1 0 20 4096 |
| 505 | int_error_detection J sha256 0 32 512 |
| 506 | int_error_detection J sha256 0 32 4096 |
| 507 | |
| 508 | int_error_detection J hmac-sha256 0 32 512 $KEY_FILE 32 |
| 509 | int_error_detection J hmac-sha256 0 32 4096 $KEY_FILE 32 |
| 510 | |
| 511 | if [ -n "$DM_INTEGRITY_INLINE" ] ; then |
| 512 | echo "Integrity mode tests (inline tags): " |
| 513 | add_device_inline |
| 514 | intformat crc32c crc32c 0 4 4096 98abca7cb88f35f1944dface4c5040423a99886f4e5a716f061fd153d8661fe8 |
| 515 | intformat crc32 crc32 0 4 4096 98abca7cb88f35f1944dface4c5040423a99886f4e5a716f061fd153d8661fe8 |
| 516 | intformat xxhash64 xxhash64 0 8 4096 98abca7cb88f35f1944dface4c5040423a99886f4e5a716f061fd153d8661fe8 |
| 517 | intformat sha1 sha1 0 20 4096 98abca7cb88f35f1944dface4c5040423a99886f4e5a716f061fd153d8661fe8 |
| 518 | intformat sha1 sha1 16 16 4096 98abca7cb88f35f1944dface4c5040423a99886f4e5a716f061fd153d8661fe8 |
| 519 | intformat sha256 sha256 0 32 4096 98abca7cb88f35f1944dface4c5040423a99886f4e5a716f061fd153d8661fe8 |
| 520 | intformat hmac-sha256 hmac\(sha256\) 0 32 4096 98abca7cb88f35f1944dface4c5040423a99886f4e5a716f061fd153d8661fe8 $KEY_FILE 32 |
| 521 | intformat hmac-sha256 hmac\(sha256\) 0 32 4096 98abca7cb88f35f1944dface4c5040423a99886f4e5a716f061fd153d8661fe8 $KEY_FILE 4096 |
| 522 | echo "Error detection tests (inline tags):" |
| 523 | int_error_detection J crc32c 0 4 4096 |
| 524 | int_error_detection J crc32 0 4 4096 |
| 525 | int_error_detection J xxhash64 0 8 4096 |
| 526 | int_error_detection J sha1 0 20 4096 |
| 527 | int_error_detection J sha256 0 32 4096 |
| 528 | int_error_detection J hmac-sha256 0 32 4096 $KEY_FILE 32 |
| 529 | fi |
| 530 | |
| 531 | echo "Journal parameters tests:" |
| 532 | add_device |
| 533 | # Watermark is calculated in kernel, so it can be rounded down/up |
| 534 | int_journal crc32 4 512 66 1000 hmac-sha256 $KEY_FILE 32 hmac\(sha256\) |
| 535 | int_journal sha256 32 4096 34 5000 hmac-sha1 $KEY_FILE 16 hmac\(sha1\) |
| 536 | int_journal sha1 20 512 75 9999 hmac-sha256 $KEY_FILE 32 hmac\(sha256\) |
| 537 | int_journal sha1 20 512 75 9999 hmac-sha256 $KEY_FILE 4096 hmac\(sha256\) |
| 538 | |
| 539 | echo "Journal encryption tests:" |
| 540 | int_journal_crypt cbc-aes cbc\(aes\) $KEY_FILE 32 |
| 541 | int_journal_crypt cbc-aes cbc\(aes\) $KEY_FILE 16 |
| 542 | int_journal_crypt ctr-aes ctr\(aes\) $KEY_FILE 32 |
| 543 | int_journal_crypt ctr-aes ctr\(aes\) $KEY_FILE 16 |
| 544 | |
| 545 | echo "Mode tests:" |
| 546 | int_mode crc32c 4 512 |
| 547 | int_mode crc32 4 512 |
| 548 | int_mode sha1 20 512 |
| 549 | int_mode sha256 32 512 |
| 550 | int_mode hmac-sha256 32 512 $KEY_FILE 32 |
| 551 | int_mode hmac-sha256 32 4096 $KEY_FILE 32 |
| 552 | |
| 553 | recalc_test() # $1 checksum |
| 554 | { |
| 555 | $INTSETUP format -q $IDEV $INLINE_PARAMS --sector-size 4096 --no-wipe || fail "Cannot format device." |
| 556 | $INTSETUP open $IDEV $DEV_NAME --integrity-recalculate || fail "Cannot activate device." |
| 557 | dd if=/dev/mapper/$DEV_NAME of=/dev/null bs=1M 2>/dev/null || fail "Cannot recalculate tags in-kernel" |
| 558 | int_check_sum_only $1 |
| 559 | $INTSETUP close $DEV_NAME || fail "Cannot deactivate device." |
| 560 | echo -n "[OK]" |
| 561 | if [ -n "$DM_INTEGRITY_RESET" ] ; then |
| 562 | $INTSETUP open $IDEV $DEV_NAME -I sha256 --integrity-recalculate-reset || fail "Cannot activate device." |
| 563 | dd if=/dev/mapper/$DEV_NAME of=/dev/null bs=1M 2>/dev/null || fail "Cannot reset recalculate tags in-kernel" |
| 564 | int_check_sum_only $1 |
| 565 | $INTSETUP close $DEV_NAME || fail "Cannot deactivate device." |
| 566 | echo "[RESET OK]" |
| 567 | else |
| 568 | echo "[RESET N/A]" |
| 569 | fi |
| 570 | } |
| 571 | if [ -n "$DM_INTEGRITY_RECALC" ] ; then |
| 572 | echo -n "Recalculate tags in-kernel:" |
| 573 | add_device |
| 574 | recalc_test eab969b9d69b73dd20bf3f3d2a14936710595fd7ec61be6729690dde86cc7ba6 |
| 575 | if [ -n "$DM_INTEGRITY_RECALCULATE_INLINE" ] ; then |
| 576 | echo -n "Recalculate tags in-kernel (inline tags):" |
| 577 | add_device_inline 65072 |
| 578 | recalc_test 98abca7cb88f35f1944dface4c5040423a99886f4e5a716f061fd153d8661fe8 |
| 579 | fi |
| 580 | fi |
| 581 | |
| 582 | echo -n "Separate metadata device:" |
| 583 | if [ -n "$DM_INTEGRITY_META" ] ; then |
| 584 | add_device |
| 585 | $INTSETUP format -q $DEV --data-device $DEV2 || fail "Cannot format device." |
| 586 | $INTSETUP open $DEV --data-device $DEV2 $DEV_NAME || fail "Cannot activate device." |
| 587 | int_check_sum_only 83ee47245398adee79bd9c0a8bc57b821e92aba10f5f9ade8a5d1fae4d8c4302 |
| 588 | $INTSETUP status $DEV_NAME | grep -q 'metadata device:' || fail |
| 589 | $INTSETUP close $DEV_NAME || fail "Cannot deactivate device." |
| 590 | echo "[OK]" |
| 591 | else |
| 592 | echo "[N/A]" |
| 593 | fi |
| 594 | |
| 595 | echo -n "Bitmap mode parameters:" |
| 596 | if [ -n "$DM_INTEGRITY_BITMAP" ] ; then |
| 597 | add_device |
| 598 | $INTSETUP format -q $DEV --integrity-bitmap-mode $DEV2 || fail "Cannot format device." |
| 599 | $INTSETUP open $DEV --integrity-bitmap-mode --bitmap-sectors-per-bit 65536 --bitmap-flush-time 5000 $DEV_NAME || fail "Cannot activate device." |
| 600 | $INTSETUP status $DEV_NAME | grep -q 'bitmap 512-byte sectors per bit: 65536' || fail |
| 601 | $INTSETUP status $DEV_NAME | grep -q 'bitmap flush interval: 5000 \[ms\]' || fail |
| 602 | $INTSETUP close $DEV_NAME || fail "Cannot deactivate device." |
| 603 | echo "[OK]" |
| 604 | echo "Bitmap error detection tests:" |
| 605 | int_error_detection B crc32c 0 4 512 |
| 606 | int_error_detection B crc32c 0 4 4096 |
| 607 | int_error_detection B sha256 0 32 512 |
| 608 | int_error_detection B sha256 0 32 4096 |
| 609 | int_error_detection B hmac-sha256 0 32 512 $KEY_FILE 32 |
| 610 | int_error_detection B hmac-sha256 0 32 4096 $KEY_FILE 32 |
| 611 | else |
| 612 | echo "[N/A]" |
| 613 | fi |
| 614 | |
| 615 | echo -n "Big device:" |
| 616 | add_device |
| 617 | DEV_LOOP=$(losetup -f $DEV --show) |
| 618 | if [ -n "$DEV_LOOP" ] ; then |
| 619 | dmsetup create $DEV_NAME2 <<EOF |
| 620 | 0 16284 linear $DEV_LOOP 0 |
| 621 | 16284 80000000000 zero |
| 622 | EOF |
| 623 | [ ! -b /dev/mapper/$DEV_NAME2 ] && fail |
| 624 | $INTSETUP format -q -s 512 --no-wipe /dev/mapper/$DEV_NAME2 |
| 625 | $INTSETUP open /dev/mapper/$DEV_NAME2 $DEV_NAME || fail |
| 626 | D_SIZE=$($INTSETUP dump /dev/mapper/$DEV_NAME2 | grep "data size:" | cut -d' ' -f 3) |
| 627 | A_SIZE=$(blockdev --getsz /dev/mapper/$DEV_NAME) |
| 628 | # Compare strings (to avoid 64bit integers), not integers |
| 629 | [ -n "$A_SIZE" -a "$D_SIZE" != "$A_SIZE" ] && fail |
| 630 | echo "[OK]" |
| 631 | else |
| 632 | echo "[N/A]" |
| 633 | fi |
| 634 | |
| 635 | echo -n "Deferred removal of device:" |
| 636 | add_device |
| 637 | $INTSETUP format -q $DEV || fail "Cannot format device." |
| 638 | $INTSETUP open $DEV $DEV_NAME || fail "Cannot activate device." |
| 639 | dmsetup create $DEV_NAME2 --table "0 8 linear /dev/mapper/$DEV_NAME 0" |
| 640 | [ ! -b /dev/mapper/$DEV_NAME2 ] && fail |
| 641 | $INTSETUP close $DEV_NAME >/dev/null 2>&1 && fail |
| 642 | $INTSETUP -q status $DEV_NAME >/dev/null 2>&1 || fail |
| 643 | $INTSETUP close --deferred $DEV_NAME >/dev/null 2>&1 |
| 644 | if [ $? -eq 0 ] ; then |
| 645 | dmsetup info $DEV_NAME | grep -q "DEFERRED REMOVE" || fail |
| 646 | $INTSETUP close --cancel-deferred $DEV_NAME >/dev/null 2>&1 |
| 647 | dmsetup info $DEV_NAME | grep -q "DEFERRED REMOVE" >/dev/null 2>&1 && fail |
| 648 | $INTSETUP close --deferred $DEV_NAME >/dev/null 2>&1 |
| 649 | dmsetup remove $DEV_NAME2 || fail |
| 650 | $INTSETUP -q status $DEV_NAME >/dev/null 2>&1 && fail |
| 651 | echo "[OK]" |
| 652 | else |
| 653 | dmsetup remove $DEV_NAME2 >/dev/null 2>&1 |
| 654 | $INTSETUP close $DEV_NAME >/dev/null 2>&1 |
| 655 | echo "[N/A]" |
| 656 | fi |
| 657 | |
| 658 | echo -n "Fixed HMAC and legacy flags:" |
| 659 | if [ -n "$DM_INTEGRITY_HMAC_FIX" ] ; then |
| 660 | add_device |
| 661 | # only data HMAC |
| 662 | ARGS="--integrity hmac-sha256 --integrity-key-file $KEY_FILE --integrity-key-size 32" |
| 663 | $INTSETUP format -q $DEV --integrity-legacy-hmac --no-wipe --tag-size 32 $ARGS || fail "Cannot format device." |
| 664 | $INTSETUP open $DEV $DEV_NAME --integrity-legacy-hmac --integrity-recalculate $ARGS >/dev/null 2>&1 && fail "Cannot activate device." |
| 665 | $INTSETUP open $DEV $DEV_NAME --integrity-legacy-hmac --integrity-legacy-recalculate $ARGS || fail "Cannot activate device." |
| 666 | kernel_param_grep "fix_hmac" && fail "fix_hmac should not be set" |
| 667 | kernel_param_grep "fix_padding" || fail "Missing fix_padding" |
| 668 | kernel_param_grep "legacy_recalculate" || fail "Missing legacy_recalculate" |
| 669 | $INTSETUP close $DEV_NAME || fail "Cannot deactivate device." |
| 670 | # New version - must fail (no journal HMAC) |
| 671 | $INTSETUP format -q $DEV --no-wipe --tag-size 32 $ARGS || fail "Cannot format device." |
| 672 | $INTSETUP open $DEV $DEV_NAME --integrity-recalculate $ARGS >/dev/null 2>&1 && fail "Cannot activate device." |
| 673 | $INTSETUP open $DEV $DEV_NAME --integrity-legacy-recalculate $ARGS || fail "Cannot activate device." |
| 674 | kernel_param_grep "fix_padding" || fail "Missing fix_padding" |
| 675 | kernel_param_grep "fix_hmac" || fail "Missing fix_hmac" |
| 676 | kernel_param_grep "legacy_recalculate" || fail "Missing legacy_recalculate" |
| 677 | $INTSETUP close $DEV_NAME || fail "Cannot deactivate device." |
| 678 | |
| 679 | # data and journal HMAC |
| 680 | ARGS="$ARGS --journal-integrity hmac-sha256 --journal-integrity-key-file $KEY_FILE2 --journal-integrity-key-size 32" |
| 681 | $INTSETUP format -q $DEV --integrity-legacy-hmac --no-wipe --tag-size 32 $ARGS || fail "Cannot format device." |
| 682 | $INTSETUP open $DEV $DEV_NAME --integrity-legacy-hmac --integrity-recalculate $ARGS >/dev/null 2>&1 && fail "Cannot activate device." |
| 683 | $INTSETUP open $DEV $DEV_NAME --integrity-legacy-hmac --integrity-legacy-recalculate $ARGS || fail "Cannot activate device." |
| 684 | kernel_param_grep "fix_hmac" && fail "fix_hmac should not be set" |
| 685 | kernel_param_grep "fix_padding" || fail "Missing fix_padding" |
| 686 | kernel_param_grep "legacy_recalculate" || fail "Missing legacy_recalculate" |
| 687 | $INTSETUP close $DEV_NAME || fail "Cannot deactivate device." |
| 688 | # New fixed version |
| 689 | $INTSETUP format -q $DEV --no-wipe --tag-size 32 $ARGS || fail "Cannot format device." |
| 690 | $INTSETUP dump $DEV | grep "flags" | grep -q "fix_hmac" || fail "Flag for HMAC not set." |
| 691 | $INTSETUP open $DEV $DEV_NAME --integrity-recalculate $ARGS || fail "Cannot activate device." |
| 692 | kernel_param_grep "fix_padding" || fail "Missing fix_padding" |
| 693 | kernel_param_grep "fix_hmac" || fail "Missing fix_hmac" |
| 694 | $INTSETUP close $DEV_NAME || fail "Cannot deactivate device." |
| 695 | echo "[OK]" |
| 696 | else |
| 697 | echo "[N/A]" |
| 698 | fi |
| 699 | |
| 700 | # shrinking the mapping should also work on older kernels |
| 701 | echo -n "[INTEGRITY BASIC RESIZE NOKEY]" |
| 702 | add_device |
| 703 | ARGS="--integrity crc32" |
| 704 | |
| 705 | echo -n "[FORMAT]" |
| 706 | $INTSETUP format -q $DEV $ARGS || fail "Cannot format device." |
| 707 | echo -n "[ACTIVATE]" |
| 708 | $INTSETUP open -q $DEV $DEV_NAME $ARGS >/dev/null 2>&1 || fail "Cannot activate device." |
| 709 | echo -n "[SHRINK]" |
| 710 | $INTSETUP resize $DEV_NAME --device-size 1MiB >/dev/null 2>&1 || fail "Failed to resize the device to 1MiB." |
| 711 | check_device_size $DEV_NAME $(( 1024*1024 / 512 )) "Shrinking device failed" |
| 712 | dd if=/dev/mapper/$DEV_NAME >/dev/null 2>&1 || fail "Errors detected after resize." |
| 713 | echo "[OK]" |
| 714 | |
| 715 | if [ -n "$DM_INTEGRITY_INLINE" ] ; then |
| 716 | echo -n "[INTEGRITY BASIC RESIZE NOKEY (inline tags)]" |
| 717 | add_device_inline |
| 718 | ARGS="--integrity crc32" |
| 719 | |
| 720 | echo -n "[FORMAT]" |
| 721 | $INTSETUP format -q $IDEV $INLINE_PARAMS --sector-size 4096 $ARGS || fail "Cannot format device." |
| 722 | echo -n "[ACTIVATE]" |
| 723 | $INTSETUP open -q $IDEV $DEV_NAME $ARGS >/dev/null 2>&1 || fail "Cannot activate device." |
| 724 | echo -n "[RESIZE]" |
| 725 | $INTSETUP resize $DEV_NAME --device-size 1MiB >/dev/null 2>&1 || fail "Failed to resize the device to 1MiB." |
| 726 | check_device_size $DEV_NAME $(( 1024*1024 / 512 )) "Shrinking device failed" |
| 727 | $INTSETUP resize $DEV_NAME --device-size 8MiB >/dev/null 2>&1 || fail "Failed to resize the device to 8MiB." |
| 728 | check_device_size $DEV_NAME $(( 8*1024*1024 / 512 )) "Enlarging device failed" |
| 729 | dd if=/dev/mapper/$DEV_NAME >/dev/null 2>&1 || fail "Errors detected after resize." |
| 730 | echo "[OK]" |
| 731 | fi |
| 732 | |
| 733 | echo -n "[INTEGRITY BASIC RESIZE KEY]" |
| 734 | add_device |
| 735 | ARGS="--integrity hmac-sha256 --integrity-key-size 128 --integrity-key-file $KEY_FILE --journal-integrity hmac-sha256 --journal-integrity-key-file $KEY_FILE --journal-integrity-key-size 128 --journal-crypt ctr-aes --journal-crypt-key-size 16 --journal-crypt-key-file $KEY_FILE" |
| 736 | |
| 737 | echo -n "[FORMAT]" |
| 738 | $INTSETUP format -q $DEV $ARGS || fail "Cannot format device." |
| 739 | echo -n "[ACTIVATE]" |
| 740 | $INTSETUP open -q $DEV $DEV_NAME $ARGS >/dev/null 2>&1 || fail "Cannot activate device." |
| 741 | echo -n "[SHRINK]" |
| 742 | $INTSETUP resize $DEV_NAME --device-size 1MiB >/dev/null 2>&1 || fail "Failed to resize the device to 1MiB." |
| 743 | check_device_size $DEV_NAME $(( 1024*1024 / 512 )) "Shrinking device failed" |
| 744 | dd if=/dev/mapper/$DEV_NAME >/dev/null 2>&1 || fail "Errors detected after resize." |
| 745 | echo "[OK]" |
| 746 | |
| 747 | test_resize "[INTEGRITY RESIZE NOKEY]" 0 0 "--integrity crc32" |
| 748 | test_resize "[INTEGRITY RESIZE NOKEY]" 0 1 "--integrity crc32" |
| 749 | test_resize "[INTEGRITY RESIZE NOKEY DETACHED]" 1 0 "--integrity crc32" |
| 750 | test_resize "[INTEGRITY RESIZE NOKEY DETACHED]" 1 1 "--integrity crc32" |
| 751 | test_resize "[INTEGRITY RESIZE NOKEY BITMAP]" 0 1 "--integrity crc32 -B" |
| 752 | # FIXME: Enable following test when kernel patch "dm-integrity: fix recalculation in bitmap mode" reaches mainline kernel |
| 753 | # test_resize "[INTEGRITY RESIZE NOKEY BITMAP]" 0 0 "--integrity crc32 -B" |
| 754 | if [ -n "$DM_INTEGRITY_HMAC_FIX" ] ; then |
| 755 | test_resize "[INTEGRITY RESIZE KEY]" 0 0 "--integrity hmac-sha256 --integrity-key-size 128 --integrity-key-file $KEY_FILE --journal-integrity hmac-sha256 --journal-integrity-key-file $KEY_FILE --journal-integrity-key-size 128 --journal-crypt ctr-aes --journal-crypt-key-size 16 --journal-crypt-key-file $KEY_FILE" |
| 756 | test_resize "[INTEGRITY RESIZE KEY]" 0 1 "--integrity hmac-sha256 --integrity-key-size 128 --integrity-key-file $KEY_FILE --journal-integrity hmac-sha256 --journal-integrity-key-file $KEY_FILE --journal-integrity-key-size 128 --journal-crypt ctr-aes --journal-crypt-key-size 16 --journal-crypt-key-file $KEY_FILE" |
| 757 | test_resize "[INTEGRITY RESIZE KEY DETACHED]" 1 0 "--integrity hmac-sha256 --integrity-key-size 128 --integrity-key-file $KEY_FILE --journal-integrity hmac-sha256 --journal-integrity-key-file $KEY_FILE --journal-integrity-key-size 128 --journal-crypt ctr-aes --journal-crypt-key-size 16 --journal-crypt-key-file $KEY_FILE" |
| 758 | test_resize "[INTEGRITY RESIZE KEY DETACHED]" 1 1 "--integrity hmac-sha256 --integrity-key-size 128 --integrity-key-file $KEY_FILE --journal-integrity hmac-sha256 --journal-integrity-key-file $KEY_FILE --journal-integrity-key-size 128 --journal-crypt ctr-aes --journal-crypt-key-size 16 --journal-crypt-key-file $KEY_FILE" |
| 759 | fi |
| 760 | |
| 761 | echo -n "Early check for active name:" |
| 762 | add_device |
| 763 | DM_BAD_NAME=x/x |
| 764 | DM_LONG_NAME=0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef |
| 765 | $INTSETUP format -q $DEV --no-wipe || fail "Cannot format device." |
| 766 | $INTSETUP open $DEV $DM_BAD_NAME 2>/dev/null && fail "Cannot activate device." |
| 767 | $INTSETUP open $DEV $DM_LONG_NAME 2>/dev/null && fail "Cannot activate device." |
| 768 | echo "[OK]" |
| 769 | |
| 770 | cleanup |