| 1 | #!/bin/bashscip-shell filesystem . . `/bin/bash`. |
| 2 | |
| 3 | PS4='$LINENO:' |
| 4 | [scip-shell system . . `[`. -z "$CRYPTSETUP_PATH" ] && CRYPTSETUP_PATH=".." |
| 5 | CRYPTSETUP=$CRYPTSETUP_PATH/cryptsetup |
| 6 | CRYPTSETUP_RAW=$CRYPTSETUP |
| 7 | |
| 8 | if [scip-shell system . . `[`. -n "$CRYPTSETUP_TESTS_RUN_IN_MESON" ]; then |
| 9 | CRYPTSETUP_VALGRIND=$CRYPTSETUP |
| 10 | else |
| 11 | CRYPTSETUP_VALGRIND=../.libs/cryptsetup |
| 12 | CRYPTSETUP_LIB_VALGRIND=../.libs |
| 13 | fi |
| 14 | |
| 15 | DEV_NAME=dummy |
| 16 | DEV_NAME2=dummy2 |
| 17 | NO_HEADER_IMG=missing-header |
| 18 | HEADER_IMG=luks-header |
| 19 | HEADER_LUKS2_INV=luks2_invalid_cipher.img |
| 20 | KEY1=key1 |
| 21 | KEY2=key2 |
| 22 | KEY5=key5 |
| 23 | KEYE=keye |
| 24 | KEY_PWD1=key_pwd1 |
| 25 | OPAL2_ADMIN_PIN="adminPin01" |
| 26 | PWD1="93R4P4pIqAH8" |
| 27 | PWD2="mymJeD8ivEhE" |
| 28 | PWD3="ocMakf3fAcQO" |
| 29 | PWD4="Qx3qn46vq0v" |
| 30 | PWDW="rUkL4RUryBom" |
| 31 | TEST_KEYRING_NAME="compattest2_keyring" |
| 32 | TEST_TOKEN0="compattest2_desc0" |
| 33 | TEST_TOKEN1="compattest2_desc1" |
| 34 | VK_FILE="compattest2_vkfile" |
| 35 | IMPORT_TOKEN="{\"type\":\"some_type\",\"keyslots\":[],\"base64_data\":\"zxI7vKB1Qwl4VPB4D-N-OgcC14hPCG0IDu8O7eCqaQ\"}" |
| 36 | TOKEN_FILE0=test-token-file0 |
| 37 | TOKEN_FILE1=test-token-file1 |
| 38 | KEY_FILE0=test-key-file0 |
| 39 | KEY_FILE1=test-key-file1 |
| 40 | |
| 41 | FAST_PBKDF_OPT="--pbkdf pbkdf2 --pbkdf-force-iterations 1000" |
| 42 | |
| 43 | TEST_UUID="12345678-1234-1234-1234-123456789abc" |
| 44 | |
| 45 | 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`.) |
| 46 | |
| 47 | remove_mappingscip-shell shell shell-project 0.0.0 remove_mapping().() |
| 48 | { |
| 49 | [scip-shell system . . `[`. -b /dev/mapper/$DEV_NAME2 ] && dmsetup remove --retry $DEV_NAME2 |
| 50 | [scip-shell system . . `[`. -b /dev/mapper/$DEV_NAME ] && dmsetup remove --retry $DEV_NAME |
| 51 | [scip-shell system . . `[`. -b /dev/mapper/"$DEV_NAME"_dif ] && dmsetup remove --retry "$DEV_NAME"_dif |
| 52 | rmscip-shell system . . rm. -f $KEY1 $KEY2 $KEY5 $KEYE $HEADER_IMG $VK_FILE \ |
| 53 | $HEADER_LUKS2_INV missing-file $TOKEN_FILE0 $TOKEN_FILE1 test_image_* \ |
| 54 | $KEY_FILE0 $KEY_FILE1 $KEY_PWD1 $NO_HEADER_IMG >/dev/nullscip-shell filesystem . . `/dev/null`. 2>&1 |
| 55 | |
| 56 | # unlink whole test keyring |
| 57 | [scip-shell system . . `[`. -n "$TEST_KEYRING" ] && keyctl unlink $TEST_KEYRING "@u" >/dev/nullscip-shell filesystem . . `/dev/null`. |
| 58 | unset TEST_KEYRING |
| 59 | } |
| 60 | |
| 61 | failscip-shell shell shell-project 0.0.0 fail().() |
| 62 | { |
| 63 | [scip-shell system . . `[`. -n "$1" ] && echoscip-shell system . . echo. "$1" |
| 64 | remove_mappingscip-shell shell shell-project 0.0.0 remove_mapping(). |
| 65 | reset_device_psid_nofailscip-shell shell shell-project 0.0.0 reset_device_psid_nofail(). |
| 66 | echoscip-shell system . . echo. "FAILED backtrace:" |
| 67 | while caller $frame; do ((frame++)); done |
| 68 | exit 2 |
| 69 | } |
| 70 | |
| 71 | _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"; } |
| 72 | trap _sigchld CHLD |
| 73 | |
| 74 | fips_modescip-shell shell shell-project 0.0.0 fips_mode().() |
| 75 | { |
| 76 | [scip-shell system . . `[`. -n "$FIPS_MODE" ] && [scip-shell system . . `[`. "$FIPS_MODE" -gt 0 ] |
| 77 | } |
| 78 | |
| 79 | can_fail_fipsscip-shell shell shell-project 0.0.0 can_fail_fips().() |
| 80 | { |
| 81 | # Ignore this fail if running in FIPS mode |
| 82 | fips_modescip-shell shell shell-project 0.0.0 fips_mode(). || failscip-shell shell shell-project 0.0.0 fail(). $1 |
| 83 | } |
| 84 | |
| 85 | skipscip-shell shell shell-project 0.0.0 skip().() |
| 86 | { |
| 87 | [scip-shell system . . `[`. -n "$1" ] && echoscip-shell system . . echo. "$1" |
| 88 | remove_mappingscip-shell shell shell-project 0.0.0 remove_mapping(). |
| 89 | exit 77 |
| 90 | } |
| 91 | |
| 92 | reset_device_psidscip-shell shell shell-project 0.0.0 reset_device_psid().() |
| 93 | { |
| 94 | $CRYPTSETUP_RAW luksErase --hw-opal-factory-reset --key-file $OPAL2_PSID_FILE $OPAL2_DEV -q || \ |
| 95 | fail "PSID reset fail, wrong device used?" |
| 96 | } |
| 97 | |
| 98 | reset_device_psid_nofailscip-shell shell shell-project 0.0.0 reset_device_psid_nofail().() |
| 99 | { |
| 100 | $CRYPTSETUP_RAW luksErase --hw-opal-factory-reset --key-file $OPAL2_PSID_FILE $OPAL2_DEV -q 2>/dev/nullscip-shell filesystem . . `/dev/null`. |
| 101 | } |
| 102 | |
| 103 | preparescip-shell shell shell-project 0.0.0 prepare().() |
| 104 | { |
| 105 | [scip-shell system . . `[`. -b /dev/mapper/$DEV_NAME ] && dmsetup remove --retry $DEV_NAME |
| 106 | |
| 107 | case "$2" in |
| 108 | reset) |
| 109 | remove_mappingscip-shell shell shell-project 0.0.0 remove_mapping(). |
| 110 | reset_device_psidscip-shell shell shell-project 0.0.0 reset_device_psid(). |
| 111 | ;; |
| 112 | wipe) |
| 113 | $CRYPTSETUP_RAW isLuks --type luks2 $HEADER_IMG -q 2>/dev/nullscip-shell filesystem . . `/dev/null`. |
| 114 | if [scip-shell system . . `[`. $? -eq 0 ]; then |
| 115 | echoscip-shell system . . echo. $OPAL2_ADMIN_PIN | $CRYPTSETUP_RAW luksErase $OPAL2_DEV -q --header $HEADER_IMG |
| 116 | else |
| 117 | echoscip-shell system . . echo. $OPAL2_ADMIN_PIN | $CRYPTSETUP_RAW luksErase $OPAL2_DEV -q 2>/dev/nullscip-shell filesystem . . `/dev/null`. |
| 118 | fi |
| 119 | remove_mappingscip-shell shell shell-project 0.0.0 remove_mapping(). |
| 120 | ;; |
| 121 | new) |
| 122 | remove_mappingscip-shell shell shell-project 0.0.0 remove_mapping(). |
| 123 | ;; |
| 124 | reuse | *) |
| 125 | ;; |
| 126 | esac |
| 127 | |
| 128 | if [scip-shell system . . `[`. ! -e $KEY1 ]; then |
| 129 | echoscip-shell system . . echo. -n $'\x48\xc6\x74\x4f\x41\x4e\x50\xc0\x79\xc2\x2d\x5b\x5f\x68\x84\x17' >$KEY1 |
| 130 | echoscip-shell system . . echo. -n $'\x9c\x03\x5e\x1b\x4d\x0f\x9a\x75\xb3\x90\x70\x32\x0a\xf8\xae\xc4'>>$KEY1 |
| 131 | fi |
| 132 | |
| 133 | if [scip-shell system . . `[`. ! -e $KEY2 ]; then |
| 134 | ddscip-shell system . . dd. if=/dev/urandomscip-shell filesystem . . `/dev/urandom`. of=$KEY2 count=1 bs=64 >/dev/nullscip-shell filesystem . . `/dev/null`. 2>&1 |
| 135 | fi |
| 136 | |
| 137 | if [scip-shell system . . `[`. ! -e $KEY5 ]; then |
| 138 | ddscip-shell system . . dd. if=/dev/urandomscip-shell filesystem . . `/dev/urandom`. of=$KEY5 count=1 bs=16 >/dev/nullscip-shell filesystem . . `/dev/null`. 2>&1 |
| 139 | fi |
| 140 | |
| 141 | if [scip-shell system . . `[`. ! -e $KEY_PWD1 ]; then |
| 142 | echoscip-shell system . . echo. -n "$PWD1" > $KEY_PWD1 |
| 143 | fi |
| 144 | |
| 145 | if [scip-shell system . . `[`. ! -e $KEYE ]; then |
| 146 | touchscip-shell system . . touch. $KEYE |
| 147 | fi |
| 148 | |
| 149 | [scip-shell system . . `[`. -n "$1" ] && echoscip-shell system . . echo. "CASE: $1" |
| 150 | } |
| 151 | |
| 152 | check_existsscip-shell shell shell-project 0.0.0 check_exists().() |
| 153 | { |
| 154 | [scip-shell system . . `[`. -b /dev/mapper/$DEV_NAME ] || failscip-shell shell shell-project 0.0.0 fail(). |
| 155 | } |
| 156 | |
| 157 | valgrind_setupscip-shell shell shell-project 0.0.0 valgrind_setup().() |
| 158 | { |
| 159 | command -v valgrind >/dev/nullscip-shell filesystem . . `/dev/null`. || failscip-shell shell shell-project 0.0.0 fail(). "Cannot find valgrind." |
| 160 | [scip-shell system . . `[`. ! -f $CRYPTSETUP_VALGRIND ] && failscip-shell shell shell-project 0.0.0 fail(). "Unable to get location of cryptsetup executable." |
| 161 | [scip-shell system . . `[`. ! -f valg.sh ] && failscip-shell shell shell-project 0.0.0 fail(). "Unable to get location of valg runner script." |
| 162 | if [scip-shell system . . `[`. -z "$CRYPTSETUP_TESTS_RUN_IN_MESON" ]; then |
| 163 | export LD_LIBRARY_PATH="$CRYPTSETUP_LIB_VALGRIND:$LD_LIBRARY_PATH" |
| 164 | fi |
| 165 | } |
| 166 | |
| 167 | valgrind_runscip-shell shell shell-project 0.0.0 valgrind_run().() |
| 168 | { |
| 169 | INFOSTRING="$(basenamescip-shell system . . basename. ${BASH_SOURCE[1]})-line-${BASH_LINENO[0]}" ./valg.sh ${CRYPTSETUP_VALGRIND} "$@" |
| 170 | } |
| 171 | |
| 172 | dm_crypt_keyring_supportscip-shell shell shell-project 0.0.0 dm_crypt_keyring_support().() |
| 173 | { |
| 174 | VER_STR=$(dmsetup targets | grepscip-shell system . . grep. crypt | cutscip-shell system . . cut. -f2 -dv) |
| 175 | [scip-shell system . . `[`. -z "$VER_STR" ] && failscip-shell shell shell-project 0.0.0 fail(). "Failed to parse dm-crypt version." |
| 176 | |
| 177 | VER_MAJ=$(echoscip-shell system . . echo. $VER_STR | cutscip-shell system . . cut. -f 1 -d.) |
| 178 | VER_MIN=$(echoscip-shell system . . echo. $VER_STR | cutscip-shell system . . cut. -f 2 -d.) |
| 179 | VER_PTC=$(echoscip-shell system . . echo. $VER_STR | cutscip-shell system . . cut. -f 3 -d.) |
| 180 | |
| 181 | testscip-shell system . . test. -d /proc/sys/kernel/keysscip-shell filesystem . . `/proc/sys/kernel/keys`. || return 1 |
| 182 | |
| 183 | [scip-shell system . . `[`. $VER_MAJ -gt 1 ] && return 0 |
| 184 | [scip-shell system . . `[`. $VER_MAJ -eq 1 -a $VER_MIN -gt 18 ] && return 0 |
| 185 | [scip-shell system . . `[`. $VER_MAJ -eq 1 -a $VER_MIN -eq 18 -a $VER_PTC -ge 1 ] && return 0 |
| 186 | return 1 |
| 187 | } |
| 188 | |
| 189 | dm_crypt_keyring_new_kernelscip-shell shell shell-project 0.0.0 dm_crypt_keyring_new_kernel().() |
| 190 | { |
| 191 | KER_STR=$(unamescip-shell system . . uname. -r) |
| 192 | [scip-shell system . . `[`. -z "$KER_STR" ] && failscip-shell shell shell-project 0.0.0 fail(). "Failed to parse kernel version." |
| 193 | KER_MAJ=$(echoscip-shell system . . echo. $KER_STR | cutscip-shell system . . cut. -f 1 -d.) |
| 194 | KER_MIN=$(echoscip-shell system . . echo. $KER_STR | cutscip-shell system . . cut. -f 2 -d.) |
| 195 | |
| 196 | [scip-shell system . . `[`. $KER_MAJ -ge 5 ] && return 0 |
| 197 | [scip-shell system . . `[`. $KER_MAJ -eq 4 -a $KER_MIN -ge 15 ] && return 0 |
| 198 | return 1 |
| 199 | } |
| 200 | |
| 201 | test_and_prepare_keyringscip-shell shell shell-project 0.0.0 test_and_prepare_keyring().() { |
| 202 | command -v keyctl >/dev/nullscip-shell filesystem . . `/dev/null`. || skipscip-shell shell shell-project 0.0.0 skip(). "Cannot find keyctl, test skipped" |
| 203 | keyctl list "@s" > /dev/nullscip-shell filesystem . . `/dev/null`. || skipscip-shell shell shell-project 0.0.0 skip(). "Current session keyring is unreachable, test skipped" |
| 204 | TEST_KEYRING=$(keyctl newring $TEST_KEYRING_NAME "@u" 2> /dev/nullscip-shell filesystem . . `/dev/null`.) |
| 205 | testscip-shell system . . test. -n "$TEST_KEYRING" || skipscip-shell shell shell-project 0.0.0 skip(). "Failed to create keyring in user keyring" |
| 206 | keyctl search "@s" keyring "$TEST_KEYRING" > /dev/nullscip-shell filesystem . . `/dev/null`. 2>&1 || keyctl link "@u" "@s" > /dev/nullscip-shell filesystem . . `/dev/null`. 2>&1 |
| 207 | load_keyscip-shell shell shell-project 0.0.0 load_key(). user test_key test_data "$TEST_KEYRING" || skipscip-shell shell shell-project 0.0.0 skip(). "Kernel keyring service is useless on this system, test skipped." |
| 208 | } |
| 209 | |
| 210 | # $1 type |
| 211 | # $2 description |
| 212 | # $3 payload |
| 213 | # $4 keyring |
| 214 | load_keyscip-shell shell shell-project 0.0.0 load_key().() |
| 215 | { |
| 216 | keyctl add $@ >/dev/nullscip-shell filesystem . . `/dev/null`. |
| 217 | } |
| 218 | |
| 219 | setup_luks2_envscip-shell shell shell-project 0.0.0 setup_luks2_env().() { |
| 220 | echoscip-shell system . . echo. $PWD1 | $CRYPTSETUP luksFormat --type luks2 $FAST_PBKDF_OPT $OPAL2_DEV || failscip-shell shell shell-project 0.0.0 fail(). |
| 221 | $CRYPTSETUP luksDump $OPAL2_DEV >/dev/nullscip-shell filesystem . . `/dev/null`. || failscip-shell shell shell-project 0.0.0 fail(). |
| 222 | echoscip-shell system . . echo. $PWD1 | $CRYPTSETUP open $OPAL2_DEV $DEV_NAME || failscip-shell shell shell-project 0.0.0 fail(). |
| 223 | HAVE_KEYRING=$($CRYPTSETUP status $DEV_NAME | grepscip-shell system . . grep. "keyring") |
| 224 | if [scip-shell system . . `[`. -n "$HAVE_KEYRING" ]; then |
| 225 | HAVE_KEYRING=1 |
| 226 | else |
| 227 | HAVE_KEYRING=0 |
| 228 | fi |
| 229 | if $($CRYPTSETUP --version | grepscip-shell system . . grep. -q "BLKID"); then |
| 230 | HAVE_BLKID=1 |
| 231 | else |
| 232 | HAVE_BLKID=0 |
| 233 | fi |
| 234 | $CRYPTSETUP close $DEV_NAME || failscip-shell shell shell-project 0.0.0 fail(). |
| 235 | } |
| 236 | |
| 237 | # $1 key name |
| 238 | # $2 keyring to link VK to |
| 239 | # $3 key type (optional) |
| 240 | test_vk_link_with_passphrase_checkscip-shell shell shell-project 0.0.0 test_vk_link_with_passphrase_check().() { |
| 241 | KEY_TYPE=${3:-user} |
| 242 | if [scip-shell system . . `[`. -z "$3" ]; then |
| 243 | KEY_DESC=$1 |
| 244 | else |
| 245 | KEY_DESC="%$3:$1" |
| 246 | fi |
| 247 | |
| 248 | KEYCTL_KEY_NAME="%$KEY_TYPE:$1" |
| 249 | |
| 250 | echoscip-shell system . . echo. $PWD1 | $CRYPTSETUP open --test-passphrase $OPAL2_DEV --link-vk-to-keyring "$2"::"$KEY_DESC" || failscip-shell shell shell-project 0.0.0 fail(). |
| 251 | keyctl search "$2" $KEY_TYPE $1 > /dev/nullscip-shell filesystem . . `/dev/null`. 2>&1 || failscip-shell shell shell-project 0.0.0 fail(). "VK is not linked to the specified keyring after --test-passphrase." |
| 252 | if [scip-shell system . . `[`. $KEY_TYPE = "user" ]; then |
| 253 | $CRYPTSETUP open $OPAL2_DEV --test-passphrase --volume-key-keyring $KEY_DESC <&-|| failscip-shell shell shell-project 0.0.0 fail(). "Failed to check volume passed via kernel keyring." |
| 254 | fi |
| 255 | keyctl unlink "$KEYCTL_KEY_NAME" "$2" || failscip-shell shell shell-project 0.0.0 fail(). |
| 256 | |
| 257 | echoscip-shell system . . echo. $PWD1 | $CRYPTSETUP open --test-passphrase $OPAL2_DEV || failscip-shell shell shell-project 0.0.0 fail(). |
| 258 | keyctl search "$2" $KEY_TYPE $1 > /dev/nullscip-shell filesystem . . `/dev/null`. 2>&1 && failscip-shell shell shell-project 0.0.0 fail(). "VK is unexpectedly linked to the specified keyring." |
| 259 | } |
| 260 | |
| 261 | # $1 key name |
| 262 | # $2 keyring to link VK to |
| 263 | # $3 key type (optional) |
| 264 | test_vk_linkscip-shell shell shell-project 0.0.0 test_vk_link().() { |
| 265 | KEY_TYPE=${3:-user} |
| 266 | if [scip-shell system . . `[`. -z "$3" ]; then |
| 267 | KEY_DESC=$1 |
| 268 | else |
| 269 | KEY_DESC="%$3:$1" |
| 270 | fi |
| 271 | |
| 272 | KEYCTL_KEY_NAME="%$KEY_TYPE:$1" |
| 273 | |
| 274 | echoscip-shell system . . echo. $PWD1 | $CRYPTSETUP open $OPAL2_DEV $DEV_NAME --link-vk-to-keyring "$2"::"$KEY_DESC" || failscip-shell shell shell-project 0.0.0 fail(). |
| 275 | keyctl search "$2" $KEY_TYPE $1 > /dev/nullscip-shell filesystem . . `/dev/null`. 2>&1 || failscip-shell shell shell-project 0.0.0 fail(). "VK is not linked to the specified keyring after activation." |
| 276 | $CRYPTSETUP close $DEV_NAME |
| 277 | keyctl search "$2" $KEY_TYPE $1 > /dev/nullscip-shell filesystem . . `/dev/null`. 2>&1 || failscip-shell shell shell-project 0.0.0 fail(). "VK is not linked to the specified keyring after deactivation." |
| 278 | keyctl unlink "$KEYCTL_KEY_NAME" "$2" || failscip-shell shell shell-project 0.0.0 fail(). |
| 279 | } |
| 280 | |
| 281 | # $1 key name |
| 282 | # $2 keyring to link VK to |
| 283 | # $3 key type (optional) |
| 284 | test_vk_link_and_reactivatescip-shell shell shell-project 0.0.0 test_vk_link_and_reactivate().() { |
| 285 | KEY_TYPE=${3:-user} |
| 286 | if [scip-shell system . . `[`. -z "$3" ]; then |
| 287 | KEY_DESC=$1 |
| 288 | else |
| 289 | KEY_DESC="%$3:$1" |
| 290 | fi |
| 291 | |
| 292 | KEYCTL_KEY_NAME="%$KEY_TYPE:$1" |
| 293 | |
| 294 | echoscip-shell system . . echo. $PWD1 | $CRYPTSETUP open $OPAL2_DEV $DEV_NAME --link-vk-to-keyring "$2"::"$KEY_DESC" || failscip-shell shell shell-project 0.0.0 fail(). |
| 295 | keyctl search "$2" $KEY_TYPE $1 > /dev/nullscip-shell filesystem . . `/dev/null`. 2>&1 || failscip-shell shell shell-project 0.0.0 fail(). "VK is not linked to the specified keyring after activation." |
| 296 | $CRYPTSETUP close $DEV_NAME || failscip-shell shell shell-project 0.0.0 fail(). |
| 297 | keyctl search "$2" $KEY_TYPE $1 > /dev/nullscip-shell filesystem . . `/dev/null`. 2>&1 || failscip-shell shell shell-project 0.0.0 fail(). "VK is not linked to the specified keyring after deactivation." |
| 298 | $CRYPTSETUP open $OPAL2_DEV $DEV_NAME --volume-key-keyring $KEY_DESC <&-|| failscip-shell shell shell-project 0.0.0 fail(). "Failed to unlock volume via a VK in keyring." |
| 299 | $CRYPTSETUP luksSuspend $DEV_NAME || failscip-shell shell shell-project 0.0.0 fail(). "Failed to suspend device." |
| 300 | $CRYPTSETUP luksResume $DEV_NAME --volume-key-keyring $KEY_DESC <&- || failscip-shell shell shell-project 0.0.0 fail(). "Failed to resume via a VK in keyring." |
| 301 | |
| 302 | echoscip-shell system . . echo. $PWD1 | $CRYPTSETUP luksOpen $OPAL2_DEV --test-passphrase 2>/dev/nullscip-shell filesystem . . `/dev/null`. || failscip-shell shell shell-project 0.0.0 fail(). |
| 303 | echoscip-shell system . . echo. $PWD2 | $CRYPTSETUP luksOpen $OPAL2_DEV --test-passphrase 2>/dev/nullscip-shell filesystem . . `/dev/null`. && failscip-shell shell shell-project 0.0.0 fail(). |
| 304 | echoscip-shell system . . echo. $PWD2 | $CRYPTSETUP luksAddKey $FAST_PBKDF_OPT --volume-key-keyring $KEY_DESC $OPAL2_DEV --new-key-slot 1 || failscip-shell shell shell-project 0.0.0 fail(). "Failed to add passphrase by VK in keyring." |
| 305 | echoscip-shell system . . echo. $PWD2 | $CRYPTSETUP luksOpen $OPAL2_DEV --test-passphrase 2>/dev/nullscip-shell filesystem . . `/dev/null`. || failscip-shell shell shell-project 0.0.0 fail(). |
| 306 | $CRYPTSETUP luksKillSlot -q $OPAL2_DEV 1 2>/dev/nullscip-shell filesystem . . `/dev/null`. || failscip-shell shell shell-project 0.0.0 fail(). |
| 307 | |
| 308 | $CRYPTSETUP close $DEV_NAME || failscip-shell shell shell-project 0.0.0 fail(). |
| 309 | # zero-out the key in keyring |
| 310 | keyctl pipe $KEYCTL_KEY_NAME | trscip-shell system . . tr. -c '\0' '\0' | keyctl pupdate $KEYCTL_KEY_NAME |
| 311 | $CRYPTSETUP open $OPAL2_DEV $DEV_NAME --volume-key-keyring $KEY_DESC <&- > /dev/nullscip-shell filesystem . . `/dev/null`. 2>&1 && failscip-shell shell shell-project 0.0.0 fail(). "Unlocked volume via a bad VK in keyring." |
| 312 | keyctl search "$2" $KEY_TYPE $1 > /dev/nullscip-shell filesystem . . `/dev/null`. 2>&1 || failscip-shell shell shell-project 0.0.0 fail(). "VK is not linked to the specified keyring after bad activation." |
| 313 | keyctl unlink $KEYCTL_KEY_NAME "$2" || failscip-shell shell shell-project 0.0.0 fail(). |
| 314 | } |
| 315 | |
| 316 | test_reencryption_does_not_initscip-shell shell shell-project 0.0.0 test_reencryption_does_not_init().() |
| 317 | { |
| 318 | local _hdr="" |
| 319 | local _hdrdev=$NO_HEADER_IMG |
| 320 | if [scip-shell system . . `[`. -n "$1" ]; then |
| 321 | _hdr="--header $1" |
| 322 | _hdrdev=$1 |
| 323 | fi |
| 324 | local _dumpdev=${1:-$OPAL2_DEV} |
| 325 | |
| 326 | # store sequence id to check if reencryption was aborted without metadata modifications |
| 327 | OLD_SEQID=0"$($CRYPTSETUP luksDump $_dumpdev | grepscip-shell system . . grep. "Epoch:" | cutscip-shell system . . cut. -d: -f 2 | sedscip-shell system . . sed. -e 's/[[:space:]]*//g')" |
| 328 | [scip-shell system . . `[`. 0$OLD_SEQID -gt 0 ] || failscip-shell shell shell-project 0.0.0 fail(). |
| 329 | |
| 330 | echoscip-shell system . . echo. $PWD1 | $CRYPTSETUP reencrypt $_hdr -q --init-only $OPAL2_DEV 2>/dev/nullscip-shell filesystem . . `/dev/null`. && failscip-shell shell shell-project 0.0.0 fail(). |
| 331 | NEW_SEQID=0"$($CRYPTSETUP luksDump $_dumpdev | grepscip-shell system . . grep. "Epoch:" | cutscip-shell system . . cut. -d: -f 2 | sedscip-shell system . . sed. -e 's/[[:space:]]*//g')" |
| 332 | [scip-shell system . . `[`. 0$NEW_SEQID -gt 0 ] || failscip-shell shell shell-project 0.0.0 fail(). |
| 333 | testscip-shell system . . test. $OLD_SEQID -eq $NEW_SEQID || failscip-shell shell shell-project 0.0.0 fail(). "LUKS2 metadata was modified." |
| 334 | |
| 335 | echoscip-shell system . . echo. $PWD1 | $CRYPTSETUP reencrypt $_hdr -q $OPAL2_DEV 2>/dev/nullscip-shell filesystem . . `/dev/null`. && failscip-shell shell shell-project 0.0.0 fail(). |
| 336 | NEW_SEQID=0"$($CRYPTSETUP luksDump $_dumpdev | grepscip-shell system . . grep. "Epoch:" | cutscip-shell system . . cut. -d: -f 2 | sedscip-shell system . . sed. -e 's/[[:space:]]*//g')" |
| 337 | [scip-shell system . . `[`. 0$NEW_SEQID -gt 0 ] || failscip-shell shell shell-project 0.0.0 fail(). |
| 338 | testscip-shell system . . test. $OLD_SEQID -eq $NEW_SEQID || failscip-shell shell shell-project 0.0.0 fail(). "LUKS2 metadata was modified." |
| 339 | |
| 340 | echoscip-shell system . . echo. $PWD1 |$CRYPTSETUP reencrypt -q --decrypt --header $_hdrdev --init-only $OPAL2_DEV 2>/dev/nullscip-shell filesystem . . `/dev/null`. && failscip-shell shell shell-project 0.0.0 fail(). |
| 341 | if [scip-shell system . . `[`. $_hdrdev = $NO_HEADER_IMG ]; then |
| 342 | testscip-shell system . . test. -e $_hdrdev && failscip-shell shell shell-project 0.0.0 fail(). "Decryption header was created." |
| 343 | fi |
| 344 | NEW_SEQID=0"$($CRYPTSETUP luksDump $_dumpdev | grepscip-shell system . . grep. "Epoch:" | cutscip-shell system . . cut. -d: -f 2 | sedscip-shell system . . sed. -e 's/[[:space:]]*//g')" |
| 345 | [scip-shell system . . `[`. 0$NEW_SEQID -gt 0 ] || failscip-shell shell shell-project 0.0.0 fail(). |
| 346 | testscip-shell system . . test. $OLD_SEQID -eq $NEW_SEQID || failscip-shell shell shell-project 0.0.0 fail(). "LUKS2 metadata was modified." |
| 347 | |
| 348 | echoscip-shell system . . echo. $PWD1 |$CRYPTSETUP reencrypt -q --decrypt --header $_hdrdev $OPAL2_DEV 2>/dev/nullscip-shell filesystem . . `/dev/null`. && failscip-shell shell shell-project 0.0.0 fail(). |
| 349 | if [scip-shell system . . `[`. $_hdrdev = $NO_HEADER_IMG ]; then |
| 350 | testscip-shell system . . test. -e $_hdrdev && failscip-shell shell shell-project 0.0.0 fail(). "Decryption header was created." |
| 351 | fi |
| 352 | NEW_SEQID=0"$($CRYPTSETUP luksDump $_dumpdev | grepscip-shell system . . grep. "Epoch:" | cutscip-shell system . . cut. -d: -f 2 | sedscip-shell system . . sed. -e 's/[[:space:]]*//g')" |
| 353 | [scip-shell system . . `[`. 0$NEW_SEQID -gt 0 ] || failscip-shell shell shell-project 0.0.0 fail(). |
| 354 | testscip-shell system . . test. $OLD_SEQID -eq $NEW_SEQID || failscip-shell shell shell-project 0.0.0 fail(). "LUKS2 metadata was modified." |
| 355 | |
| 356 | # repeat the test with active device |
| 357 | echoscip-shell system . . echo. $PWD1 | $CRYPTSETUP open $_hdr $OPAL2_DEV $DEV_NAME -q || failscip-shell shell shell-project 0.0.0 fail(). |
| 358 | |
| 359 | echoscip-shell system . . echo. $PWD1 | $CRYPTSETUP reencrypt $_hdr -q --init-only --active-name $DEV_NAME 2>/dev/nullscip-shell filesystem . . `/dev/null`. && failscip-shell shell shell-project 0.0.0 fail(). |
| 360 | NEW_SEQID=0"$($CRYPTSETUP luksDump $_dumpdev | grepscip-shell system . . grep. "Epoch:" | cutscip-shell system . . cut. -d: -f 2 | sedscip-shell system . . sed. -e 's/[[:space:]]*//g')" |
| 361 | [scip-shell system . . `[`. 0$NEW_SEQID -gt 0 ] || failscip-shell shell shell-project 0.0.0 fail(). |
| 362 | testscip-shell system . . test. $OLD_SEQID -eq $NEW_SEQID || failscip-shell shell shell-project 0.0.0 fail(). "LUKS2 metadata was modified." |
| 363 | |
| 364 | echoscip-shell system . . echo. $PWD1 | $CRYPTSETUP reencrypt $_hdr -q --active-name $DEV_NAME 2>/dev/nullscip-shell filesystem . . `/dev/null`. && failscip-shell shell shell-project 0.0.0 fail(). |
| 365 | NEW_SEQID=0"$($CRYPTSETUP luksDump $_dumpdev | grepscip-shell system . . grep. "Epoch:" | cutscip-shell system . . cut. -d: -f 2 | sedscip-shell system . . sed. -e 's/[[:space:]]*//g')" |
| 366 | [scip-shell system . . `[`. 0$NEW_SEQID -gt 0 ] || failscip-shell shell shell-project 0.0.0 fail(). |
| 367 | testscip-shell system . . test. $OLD_SEQID -eq $NEW_SEQID || failscip-shell shell shell-project 0.0.0 fail(). "LUKS2 metadata was modified." |
| 368 | |
| 369 | echoscip-shell system . . echo. $PWD1 |$CRYPTSETUP reencrypt -q --decrypt --header $_hdrdev --init-only --active-name $DEV_NAME 2>/dev/nullscip-shell filesystem . . `/dev/null`. && failscip-shell shell shell-project 0.0.0 fail(). |
| 370 | if [scip-shell system . . `[`. $_hdrdev = $NO_HEADER_IMG ]; then |
| 371 | testscip-shell system . . test. -e $_hdrdev && failscip-shell shell shell-project 0.0.0 fail(). "Decryption header was created." |
| 372 | fi |
| 373 | NEW_SEQID=0"$($CRYPTSETUP luksDump $_dumpdev | grepscip-shell system . . grep. "Epoch:" | cutscip-shell system . . cut. -d: -f 2 | sedscip-shell system . . sed. -e 's/[[:space:]]*//g')" |
| 374 | [scip-shell system . . `[`. 0$NEW_SEQID -gt 0 ] || failscip-shell shell shell-project 0.0.0 fail(). |
| 375 | testscip-shell system . . test. $OLD_SEQID -eq $NEW_SEQID || failscip-shell shell shell-project 0.0.0 fail(). "LUKS2 metadata was modified." |
| 376 | |
| 377 | echoscip-shell system . . echo. $PWD1 |$CRYPTSETUP reencrypt -q --decrypt --header $_hdrdev --active-name $DEV_NAME 2>/dev/nullscip-shell filesystem . . `/dev/null`. && failscip-shell shell shell-project 0.0.0 fail(). |
| 378 | if [scip-shell system . . `[`. $_hdrdev = $NO_HEADER_IMG ]; then |
| 379 | testscip-shell system . . test. -e $_hdrdev && failscip-shell shell shell-project 0.0.0 fail(). "Decryption header was created." |
| 380 | fi |
| 381 | NEW_SEQID=0"$($CRYPTSETUP luksDump $_dumpdev | grepscip-shell system . . grep. "Epoch:" | cutscip-shell system . . cut. -d: -f 2 | sedscip-shell system . . sed. -e 's/[[:space:]]*//g')" |
| 382 | [scip-shell system . . `[`. 0$NEW_SEQID -gt 0 ] || failscip-shell shell shell-project 0.0.0 fail(). |
| 383 | testscip-shell system . . test. $OLD_SEQID -eq $NEW_SEQID || failscip-shell shell shell-project 0.0.0 fail(). "LUKS2 metadata was modified." |
| 384 | |
| 385 | $CRYPTSETUP close $DEV_NAME || failscip-shell shell shell-project 0.0.0 fail(). |
| 386 | } |
| 387 | |
| 388 | test_devicescip-shell shell shell-project 0.0.0 test_device().() #opal_mode, #format_params, #--integrity-no-wipe |
| 389 | { |
| 390 | echoscip-shell system . . echo. -e "$PWD1\n$OPAL2_ADMIN_PIN" | $CRYPTSETUP luksFormat --type luks2 $1 $2 $3 -q $FAST_PBKDF_OPT $OPAL2_DEV || failscip-shell shell shell-project 0.0.0 fail(). |
| 391 | echoscip-shell system . . echo. $PWD1 | $CRYPTSETUP open $OPAL2_DEV $DEV_NAME || failscip-shell shell shell-project 0.0.0 fail(). |
| 392 | testscip-shell system . . test. -z "$3" || ddscip-shell system . . dd. if=/dev/zeroscip-shell filesystem . . `/dev/zero`. of=/dev/mapper/$DEV_NAME bs=1M count=1 oflag=direct >/dev/nullscip-shell filesystem . . `/dev/null`. 2>&1 || failscip-shell shell shell-project 0.0.0 fail(). |
| 393 | $CRYPTSETUP luksSuspend $DEV_NAME || failscip-shell shell shell-project 0.0.0 fail(). |
| 394 | ddscip-shell system . . dd. if=$OPAL2_DEV of=/dev/zeroscip-shell filesystem . . `/dev/zero`. bs=1M skip=16 count=1 iflag=direct >/dev/nullscip-shell filesystem . . `/dev/null`. 2>&1 && failscip-shell shell shell-project 0.0.0 fail(). |
| 395 | echoscip-shell system . . echo. $PWD1 | $CRYPTSETUP luksResume $DEV_NAME || failscip-shell shell shell-project 0.0.0 fail(). |
| 396 | ddscip-shell system . . dd. if=/dev/mapper/$DEV_NAME of=/dev/zeroscip-shell filesystem . . `/dev/zero`. bs=1M count=1 iflag=direct >/dev/nullscip-shell filesystem . . `/dev/null`. 2>&1 || failscip-shell shell shell-project 0.0.0 fail(). |
| 397 | $CRYPTSETUP close --cancel-deferred $DEV_NAME 2>/dev/nullscip-shell filesystem . . `/dev/null`. && failscip-shell shell shell-project 0.0.0 fail(). |
| 398 | $CRYPTSETUP close --deferred $DEV_NAME 2>/dev/nullscip-shell filesystem . . `/dev/null`. && failscip-shell shell shell-project 0.0.0 fail(). |
| 399 | $CRYPTSETUP close $DEV_NAME || failscip-shell shell shell-project 0.0.0 fail(). |
| 400 | ddscip-shell system . . dd. if=$OPAL2_DEV of=/dev/zeroscip-shell filesystem . . `/dev/zero`. bs=1M skip=16 count=1 iflag=direct >/dev/nullscip-shell filesystem . . `/dev/null`. 2>&1 && failscip-shell shell shell-project 0.0.0 fail(). |
| 401 | echoscip-shell system . . echo. $OPAL2_ADMIN_PIN | $CRYPTSETUP luksErase $OPAL2_DEV -q || failscip-shell shell shell-project 0.0.0 fail(). |
| 402 | } |
| 403 | |
| 404 | test_device_detached_headerscip-shell shell shell-project 0.0.0 test_device_detached_header().() #hdr, #opal_mode, #format_params, #--integrity-no-wipe |
| 405 | { |
| 406 | echoscip-shell system . . echo. -e "$PWD1\n$OPAL2_ADMIN_PIN" | $CRYPTSETUP luksFormat --type luks2 --header $1 $2 $3 $4 -q $FAST_PBKDF_OPT $OPAL2_DEV || failscip-shell shell shell-project 0.0.0 fail(). |
| 407 | echoscip-shell system . . echo. $PWD1 | $CRYPTSETUP open $OPAL2_DEV $DEV_NAME --header $1 || failscip-shell shell shell-project 0.0.0 fail(). |
| 408 | testscip-shell system . . test. -z "$4" || ddscip-shell system . . dd. if=/dev/zeroscip-shell filesystem . . `/dev/zero`. of=/dev/mapper/$DEV_NAME bs=1M count=1 oflag=direct >/dev/nullscip-shell filesystem . . `/dev/null`. 2>&1 || failscip-shell shell shell-project 0.0.0 fail(). |
| 409 | $CRYPTSETUP luksSuspend $DEV_NAME || failscip-shell shell shell-project 0.0.0 fail(). |
| 410 | ddscip-shell system . . dd. if=$OPAL2_DEV of=/dev/zeroscip-shell filesystem . . `/dev/zero`. bs=1M count=1 iflag=direct >/dev/nullscip-shell filesystem . . `/dev/null`. 2>&1 && failscip-shell shell shell-project 0.0.0 fail(). |
| 411 | echoscip-shell system . . echo. $PWD1 | $CRYPTSETUP luksResume $DEV_NAME 2>/dev/nullscip-shell filesystem . . `/dev/null`. && failscip-shell shell shell-project 0.0.0 fail(). |
| 412 | echoscip-shell system . . echo. $PWD1 | $CRYPTSETUP luksResume $DEV_NAME --header $1 || failscip-shell shell shell-project 0.0.0 fail(). |
| 413 | ddscip-shell system . . dd. if=/dev/mapper/$DEV_NAME of=/dev/zeroscip-shell filesystem . . `/dev/zero`. bs=1M count=1 iflag=direct >/dev/nullscip-shell filesystem . . `/dev/null`. 2>&1 || failscip-shell shell shell-project 0.0.0 fail(). |
| 414 | $CRYPTSETUP close --cancel-deferred $DEV_NAME 2>/dev/nullscip-shell filesystem . . `/dev/null`. && failscip-shell shell shell-project 0.0.0 fail(). |
| 415 | $CRYPTSETUP close --deferred $DEV_NAME 2>/dev/nullscip-shell filesystem . . `/dev/null`. && failscip-shell shell shell-project 0.0.0 fail(). |
| 416 | $CRYPTSETUP close $DEV_NAME || failscip-shell shell shell-project 0.0.0 fail(). |
| 417 | ddscip-shell system . . dd. if=$OPAL2_DEV of=/dev/zeroscip-shell filesystem . . `/dev/zero`. bs=1M count=1 iflag=direct >/dev/nullscip-shell filesystem . . `/dev/null`. 2>&1 && failscip-shell shell shell-project 0.0.0 fail(). |
| 418 | echoscip-shell system . . echo. $PWD1 | $CRYPTSETUP open $OPAL2_DEV $DEV_NAME --header $1 || failscip-shell shell shell-project 0.0.0 fail(). |
| 419 | $CRYPTSETUP close $DEV_NAME --header $1 --cancel-deferred 2>/dev/nullscip-shell filesystem . . `/dev/null`. && failscip-shell shell shell-project 0.0.0 fail(). |
| 420 | $CRYPTSETUP close $DEV_NAME --header $1 --deferred 2>/dev/nullscip-shell filesystem . . `/dev/null`. && failscip-shell shell shell-project 0.0.0 fail(). |
| 421 | $CRYPTSETUP close $DEV_NAME --header $1 || failscip-shell shell shell-project 0.0.0 fail(). |
| 422 | ddscip-shell system . . dd. if=$OPAL2_DEV of=/dev/zeroscip-shell filesystem . . `/dev/zero`. bs=1M count=1 iflag=direct >/dev/nullscip-shell filesystem . . `/dev/null`. 2>&1 && failscip-shell shell shell-project 0.0.0 fail(). |
| 423 | echoscip-shell system . . echo. $OPAL2_ADMIN_PIN | $CRYPTSETUP luksErase $OPAL2_DEV -q --header $1 || failscip-shell shell shell-project 0.0.0 fail(). |
| 424 | $CRYPTSETUP isLuks --type luks2 $1 && failscip-shell shell shell-project 0.0.0 fail(). |
| 425 | rmscip-shell system . . rm. -f $1 |
| 426 | } |
| 427 | |
| 428 | run_token_testsscip-shell shell shell-project 0.0.0 run_token_tests().() { |
| 429 | $CRYPTSETUP token add $OPAL2_DEV --key-description $TEST_TOKEN0 --token-id 3 || failscip-shell shell shell-project 0.0.0 fail(). |
| 430 | $CRYPTSETUP luksDump $OPAL2_DEV | grepscip-shell system . . grep. -q -e "3: luks2-keyring" || failscip-shell shell shell-project 0.0.0 fail(). |
| 431 | # keyslot 5 is inactive |
| 432 | $CRYPTSETUP token add $OPAL2_DEV --key-description $TEST_TOKEN1 --key-slot 5 2> /dev/nullscip-shell filesystem . . `/dev/null`. && failscip-shell shell shell-project 0.0.0 fail(). |
| 433 | # key description is not reachable |
| 434 | $CRYPTSETUP open --token-only $OPAL2_DEV --test-passphrase && failscip-shell shell shell-project 0.0.0 fail(). |
| 435 | # wrong passphrase |
| 436 | load_keyscip-shell shell shell-project 0.0.0 load_key(). user $TEST_TOKEN0 "blabla" "$TEST_KEYRING" || failscip-shell shell shell-project 0.0.0 fail(). "Cannot load 32 byte user key type" |
| 437 | $CRYPTSETUP open --token-only $OPAL2_DEV --test-passphrase 2>/dev/nullscip-shell filesystem . . `/dev/null`. && failscip-shell shell shell-project 0.0.0 fail(). |
| 438 | load_keyscip-shell shell shell-project 0.0.0 load_key(). user $TEST_TOKEN0 $PWD1 "$TEST_KEYRING" || failscip-shell shell shell-project 0.0.0 fail(). "Cannot load 32 byte user key type" |
| 439 | $CRYPTSETUP open --token-only $OPAL2_DEV --test-passphrase || failscip-shell shell shell-project 0.0.0 fail(). |
| 440 | $CRYPTSETUP open --token-only $OPAL2_DEV $DEV_NAME || failscip-shell shell shell-project 0.0.0 fail(). |
| 441 | $CRYPTSETUP status $DEV_NAME > /dev/nullscip-shell filesystem . . `/dev/null`. || failscip-shell shell shell-project 0.0.0 fail(). |
| 442 | $CRYPTSETUP luksSuspend $DEV_NAME || failscip-shell shell shell-project 0.0.0 fail(). |
| 443 | $CRYPTSETUP luksResume $DEV_NAME <&- || failscip-shell shell shell-project 0.0.0 fail(). |
| 444 | $CRYPTSETUP -q status $DEV_NAME | grepscip-shell system . . grep. -q "(suspended)" && failscip-shell shell shell-project 0.0.0 fail(). |
| 445 | $CRYPTSETUP luksSuspend $DEV_NAME || failscip-shell shell shell-project 0.0.0 fail(). |
| 446 | $CRYPTSETUP luksResume $DEV_NAME --token-type luks2-keyring <&- || failscip-shell shell shell-project 0.0.0 fail(). |
| 447 | $CRYPTSETUP close $DEV_NAME || failscip-shell shell shell-project 0.0.0 fail(). |
| 448 | |
| 449 | # check --token-type sort of works (TODO: extend tests when native systemd tokens are available) |
| 450 | echoscip-shell system . . echo. -n "$IMPORT_TOKEN" | $CRYPTSETUP token import $OPAL2_DEV --token-id 22 || failscip-shell shell shell-project 0.0.0 fail(). |
| 451 | # this excludes keyring tokens from unlocking device |
| 452 | $CRYPTSETUP open --token-only --token-type some_type $OPAL2_DEV --test-passphrase && failscip-shell shell shell-project 0.0.0 fail(). |
| 453 | $CRYPTSETUP open --token-only --token-type some_type $OPAL2_DEV $DEV_NAME && failscip-shell shell shell-project 0.0.0 fail(). |
| 454 | $CRYPTSETUP status $DEV_NAME > /dev/nullscip-shell filesystem . . `/dev/null`. && failscip-shell shell shell-project 0.0.0 fail(). |
| 455 | |
| 456 | $CRYPTSETUP token remove --token-id 3 $OPAL2_DEV || failscip-shell shell shell-project 0.0.0 fail(). |
| 457 | $CRYPTSETUP luksDump $OPAL2_DEV | grepscip-shell system . . grep. -q -e "3: luks2-keyring" && failscip-shell shell shell-project 0.0.0 fail(). |
| 458 | |
| 459 | # test we can remove keyslot with token |
| 460 | echoscip-shell system . . echo. -e "$PWD1\n$PWD2" | $CRYPTSETUP luksAddKey -q -S4 $FAST_PBKDF_OPT $OPAL2_DEV || failscip-shell shell shell-project 0.0.0 fail(). |
| 461 | $CRYPTSETUP token add $OPAL2_DEV --key-description $TEST_TOKEN1 --key-slot 4 --token-id 0 || failscip-shell shell shell-project 0.0.0 fail(). |
| 462 | $CRYPTSETUP -q luksKillSlot $OPAL2_DEV 4 || failscip-shell shell shell-project 0.0.0 fail(). |
| 463 | $CRYPTSETUP token remove --token-id 0 $OPAL2_DEV || failscip-shell shell shell-project 0.0.0 fail(). |
| 464 | |
| 465 | # test we can add unassigned token |
| 466 | $CRYPTSETUP token add $OPAL2_DEV --key-description $TEST_TOKEN0 --unbound --token-id 0 || failscip-shell shell shell-project 0.0.0 fail(). |
| 467 | $CRYPTSETUP open --token-only --token-id 0 --test-passphrase $OPAL2_DEV && failscip-shell shell shell-project 0.0.0 fail(). |
| 468 | $CRYPTSETUP token remove --token-id 0 $OPAL2_DEV || failscip-shell shell shell-project 0.0.0 fail(). |
| 469 | |
| 470 | # test token unassign works |
| 471 | $CRYPTSETUP token add $OPAL2_DEV --key-description $TEST_TOKEN0 -S0 --token-id 0 || failscip-shell shell shell-project 0.0.0 fail(). |
| 472 | $CRYPTSETUP open --token-only --token-id 0 --test-passphrase $OPAL2_DEV || failscip-shell shell shell-project 0.0.0 fail(). |
| 473 | $CRYPTSETUP token unassign --token-id 0 $OPAL2_DEV 2>/dev/nullscip-shell filesystem . . `/dev/null`. && failscip-shell shell shell-project 0.0.0 fail(). |
| 474 | $CRYPTSETUP token unassign -S0 $OPAL2_DEV 2>/dev/nullscip-shell filesystem . . `/dev/null`. && failscip-shell shell shell-project 0.0.0 fail(). |
| 475 | $CRYPTSETUP token unassign --token-id 0 -S0 $OPAL2_DEV || failscip-shell shell shell-project 0.0.0 fail(). |
| 476 | $CRYPTSETUP open --token-only --token-id 0 --test-passphrase $OPAL2_DEV && failscip-shell shell shell-project 0.0.0 fail(). |
| 477 | $CRYPTSETUP token unassign --token-id 0 -S0 $OPAL2_DEV 2>/dev/nullscip-shell filesystem . . `/dev/null`. && failscip-shell shell shell-project 0.0.0 fail(). |
| 478 | $CRYPTSETUP token unassign --token-id 0 -S44 $OPAL2_DEV 2>/dev/nullscip-shell filesystem . . `/dev/null`. && failscip-shell shell shell-project 0.0.0 fail(). |
| 479 | $CRYPTSETUP token unassign --token-id 44 -S0 $OPAL2_DEV 2>/dev/nullscip-shell filesystem . . `/dev/null`. && failscip-shell shell shell-project 0.0.0 fail(). |
| 480 | } |
| 481 | |
| 482 | export LANG=C |
| 483 | |
| 484 | [scip-shell system . . `[`. ! -x "$CRYPTSETUP" ] && skipscip-shell shell shell-project 0.0.0 skip(). "Cannot find $CRYPTSETUP, test skipped." |
| 485 | [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." |
| 486 | |
| 487 | # Do not run automatically. |
| 488 | [scip-shell system . . `[`. -z "$OPAL2_DEV" ] && skipscip-shell shell shell-project 0.0.0 skip(). "WARNING: Variable OPAL2_DEV must be defined (partition or block dev), test skipped." |
| 489 | [scip-shell system . . `[`. -z "$OPAL2_PSID_FILE" ] && skipscip-shell shell shell-project 0.0.0 skip(). "WARNING: Variable OPAL2_PSID_FILE must be defined, test skipped." |
| 490 | [scip-shell system . . `[`. -f "$OPAL2_PSID_FILE" ] || skipscip-shell shell shell-project 0.0.0 skip(). "WARNING: $OPAL2_PSID_FILE is not reachable, test skipped." |
| 491 | |
| 492 | preparescip-shell shell shell-project 0.0.0 prepare(). "[0] Detect LUKS2 environment" reset |
| 493 | setup_luks2_envscip-shell shell shell-project 0.0.0 setup_luks2_env(). |
| 494 | |
| 495 | [scip-shell system . . `[`. -n "$VALG" ] && valgrind_setupscip-shell shell shell-project 0.0.0 valgrind_setup(). && CRYPTSETUP=valgrind_run |
| 496 | |
| 497 | preparescip-shell shell shell-project 0.0.0 prepare(). "[1] Data offset" |
| 498 | echoscip-shell system . . echo. $PWD1 | $CRYPTSETUP luksFormat $FAST_PBKDF_OPT --type luks2 --hw-opal $OPAL2_DEV -q --offset 1 2>/dev/nullscip-shell filesystem . . `/dev/null`. && failscip-shell shell shell-project 0.0.0 fail(). |
| 499 | |
| 500 | preparescip-shell shell shell-project 0.0.0 prepare(). "[2] Sector size and old payload alignment" wipe |
| 501 | echoscip-shell system . . echo. -e "$PWD1\n$OPAL2_ADMIN_PIN" | $CRYPTSETUP luksFormat $FAST_PBKDF_OPT --type luks2 --hw-opal $OPAL2_DEV -q --sector-size 511 2>/dev/nullscip-shell filesystem . . `/dev/null`. && failscip-shell shell shell-project 0.0.0 fail(). |
| 502 | echoscip-shell system . . echo. -e "$PWD1\n$OPAL2_ADMIN_PIN" | $CRYPTSETUP luksFormat $FAST_PBKDF_OPT --type luks2 --hw-opal $OPAL2_DEV -q --sector-size 256 2>/dev/nullscip-shell filesystem . . `/dev/null`. && failscip-shell shell shell-project 0.0.0 fail(). |
| 503 | echoscip-shell system . . echo. -e "$PWD1\n$OPAL2_ADMIN_PIN" | $CRYPTSETUP luksFormat $FAST_PBKDF_OPT --type luks2 --hw-opal $OPAL2_DEV -q --sector-size 8192 2>/dev/nullscip-shell filesystem . . `/dev/null`. && failscip-shell shell shell-project 0.0.0 fail(). |
| 504 | echoscip-shell system . . echo. -e "$PWD1\n$OPAL2_ADMIN_PIN" | $CRYPTSETUP luksFormat $FAST_PBKDF_OPT --type luks2 --hw-opal $OPAL2_DEV -q --sector-size 512 || failscip-shell shell shell-project 0.0.0 fail(). |
| 505 | echoscip-shell system . . echo. -e "$PWD1\n$OPAL2_ADMIN_PIN" | $CRYPTSETUP luksFormat $FAST_PBKDF_OPT --type luks2 --hw-opal $OPAL2_DEV -q --sector-size 4096 >/dev/nullscip-shell filesystem . . `/dev/null`. || failscip-shell shell shell-project 0.0.0 fail(). |
| 506 | echoscip-shell system . . echo. -e "$PWD1\n$OPAL2_ADMIN_PIN" | $CRYPTSETUP luksFormat $FAST_PBKDF_OPT --type luks2 --hw-opal $OPAL2_DEV -q --sector-size 2048 >/dev/nullscip-shell filesystem . . `/dev/null`. || failscip-shell shell shell-project 0.0.0 fail(). |
| 507 | |
| 508 | preparescip-shell shell shell-project 0.0.0 prepare(). "[3] format" wipe |
| 509 | echoscip-shell system . . echo. -e "$PWD1\n$OPAL2_ADMIN_PIN" | $CRYPTSETUP -q $FAST_PBKDF_OPT -c aes-cbc-essiv:sha256 -s 128 luksFormat --type luks2 --hw-opal $OPAL2_DEV || failscip-shell shell shell-project 0.0.0 fail(). |
| 510 | |
| 511 | preparescip-shell shell shell-project 0.0.0 prepare(). "[4] format using hash sha512" wipe |
| 512 | echoscip-shell system . . echo. -e "$PWD1\n$OPAL2_ADMIN_PIN" | $CRYPTSETUP $FAST_PBKDF_OPT -h sha512 -c aes-cbc-essiv:sha256 -s 128 luksFormat --type luks2 --hw-opal $OPAL2_DEV || failscip-shell shell shell-project 0.0.0 fail(). |
| 513 | $CRYPTSETUP -q luksDump $OPAL2_DEV | grepscip-shell system . . grep. "0: pbkdf2" -A2 | grepscip-shell system . . grep. "Hash:" | grepscip-shell system . . grep. -qe sha512 || failscip-shell shell shell-project 0.0.0 fail(). |
| 514 | # Check JSON dump for some mandatory section |
| 515 | $CRYPTSETUP -q luksDump $OPAL2_DEV --dump-json-metadata | grepscip-shell system . . grep. -q '"tokens":' || failscip-shell shell shell-project 0.0.0 fail(). |
| 516 | |
| 517 | preparescip-shell shell shell-project 0.0.0 prepare(). "[5] open" wipe |
| 518 | echoscip-shell system . . echo. -e "$PWD1\n$OPAL2_ADMIN_PIN" | $CRYPTSETUP -q $FAST_PBKDF_OPT luksFormat --type luks2 --hw-opal $OPAL2_DEV || failscip-shell shell shell-project 0.0.0 fail(). |
| 519 | echoscip-shell system . . echo. $PWD1 | $CRYPTSETUP luksOpen $OPAL2_DEV $DEV_NAME --test-passphrase || failscip-shell shell shell-project 0.0.0 fail(). |
| 520 | echoscip-shell system . . echo. $PWDW | $CRYPTSETUP luksOpen $OPAL2_DEV $DEV_NAME --test-passphrase 2>/dev/nullscip-shell filesystem . . `/dev/null`. && failscip-shell shell shell-project 0.0.0 fail(). |
| 521 | [scip-shell system . . `[`. $? -ne 2 ] && failscip-shell shell shell-project 0.0.0 fail(). "luksOpen should return EPERM exit code" |
| 522 | echoscip-shell system . . echo. $PWD1 | $CRYPTSETUP luksOpen $OPAL2_DEV $DEV_NAME || failscip-shell shell shell-project 0.0.0 fail(). |
| 523 | check_existsscip-shell shell shell-project 0.0.0 check_exists(). |
| 524 | |
| 525 | preparescip-shell shell shell-project 0.0.0 prepare(). "" wipe |
| 526 | echoscip-shell system . . echo. -e "$PWD1\n$OPAL2_ADMIN_PIN" | $CRYPTSETUP -q $FAST_PBKDF_OPT luksFormat --type luks2 --hw-opal-only $OPAL2_DEV || failscip-shell shell shell-project 0.0.0 fail(). |
| 527 | echoscip-shell system . . echo. $PWD1 | $CRYPTSETUP luksOpen $OPAL2_DEV $DEV_NAME --test-passphrase || failscip-shell shell shell-project 0.0.0 fail(). |
| 528 | echoscip-shell system . . echo. $PWDW | $CRYPTSETUP luksOpen $OPAL2_DEV $DEV_NAME --test-passphrase 2>/dev/nullscip-shell filesystem . . `/dev/null`. && failscip-shell shell shell-project 0.0.0 fail(). |
| 529 | [scip-shell system . . `[`. $? -ne 2 ] && failscip-shell shell shell-project 0.0.0 fail(). "luksOpen should return EPERM exit code" |
| 530 | echoscip-shell system . . echo. $PWD1 | $CRYPTSETUP luksOpen $OPAL2_DEV $DEV_NAME || failscip-shell shell shell-project 0.0.0 fail(). |
| 531 | check_existsscip-shell shell shell-project 0.0.0 check_exists(). |
| 532 | |
| 533 | # Key Slot 1 and key material section 1 must change, the rest must not. |
| 534 | preparescip-shell shell shell-project 0.0.0 prepare(). "[6] add key" wipe |
| 535 | echoscip-shell system . . echo. -e "$PWD1\n$OPAL2_ADMIN_PIN" | $CRYPTSETUP -q $FAST_PBKDF_OPT luksFormat --type luks2 --hw-opal $OPAL2_DEV || failscip-shell shell shell-project 0.0.0 fail(). |
| 536 | echoscip-shell system . . echo. -e "$PWD1\n$PWD2" | $CRYPTSETUP luksAddKey $OPAL2_DEV $FAST_PBKDF_OPT || failscip-shell shell shell-project 0.0.0 fail(). |
| 537 | echoscip-shell system . . echo. $PWD2 | $CRYPTSETUP luksOpen $OPAL2_DEV $DEV_NAME || failscip-shell shell shell-project 0.0.0 fail(). |
| 538 | $CRYPTSETUP close $DEV_NAME || failscip-shell shell shell-project 0.0.0 fail(). |
| 539 | |
| 540 | # Unsuccessful Key Delete - nothing may change |
| 541 | preparescip-shell shell shell-project 0.0.0 prepare(). "[7] unsuccessful delete" new |
| 542 | echoscip-shell system . . echo. $PWDW | $CRYPTSETUP luksKillSlot $OPAL2_DEV 1 2>/dev/nullscip-shell filesystem . . `/dev/null`. && failscip-shell shell shell-project 0.0.0 fail(). |
| 543 | [scip-shell system . . `[`. $? -ne 2 ] && failscip-shell shell shell-project 0.0.0 fail(). "luksKillSlot should return EPERM exit code" |
| 544 | |
| 545 | # Delete Key Test |
| 546 | # Key Slot 1 and key material section 1 must change, the rest must not |
| 547 | preparescip-shell shell shell-project 0.0.0 prepare(). "[8] successful delete" |
| 548 | $CRYPTSETUP -q luksKillSlot $OPAL2_DEV 1 || failscip-shell shell shell-project 0.0.0 fail(). |
| 549 | echoscip-shell system . . echo. $PWD2 | $CRYPTSETUP luksOpen $OPAL2_DEV $DEV_NAME 2> /dev/nullscip-shell filesystem . . `/dev/null`. && failscip-shell shell shell-project 0.0.0 fail(). |
| 550 | [scip-shell system . . `[`. $? -ne 2 ] && failscip-shell shell shell-project 0.0.0 fail(). "luksOpen should return EPERM exit code" |
| 551 | echoscip-shell system . . echo. $PWD1 | $CRYPTSETUP luksOpen $OPAL2_DEV $DEV_NAME || failscip-shell shell shell-project 0.0.0 fail(). |
| 552 | $CRYPTSETUP close $DEV_NAME || failscip-shell shell shell-project 0.0.0 fail(). |
| 553 | |
| 554 | # Key Slot 1 and key material section 1 must change, the rest must not |
| 555 | preparescip-shell shell shell-project 0.0.0 prepare(). "[9] add key test for key files" new |
| 556 | echoscip-shell system . . echo. $PWD1 | $CRYPTSETUP luksAddKey $FAST_PBKDF_OPT $OPAL2_DEV $KEY1 || failscip-shell shell shell-project 0.0.0 fail(). |
| 557 | $CRYPTSETUP -d $KEY1 luksOpen $OPAL2_DEV $DEV_NAME || failscip-shell shell shell-project 0.0.0 fail(). |
| 558 | $CRYPTSETUP close $DEV_NAME || failscip-shell shell shell-project 0.0.0 fail(). |
| 559 | |
| 560 | # Key Slot 1 and key material section 1 must change, the rest must not |
| 561 | preparescip-shell shell shell-project 0.0.0 prepare(). "[10] delete key test with key1 as remaining key" new |
| 562 | $CRYPTSETUP -d $KEY1 luksKillSlot $OPAL2_DEV 0 || failscip-shell shell shell-project 0.0.0 fail(). |
| 563 | echoscip-shell system . . echo. $PWD1 | $CRYPTSETUP luksOpen $OPAL2_DEV $DEV_NAME 2>/dev/nullscip-shell filesystem . . `/dev/null`. && failscip-shell shell shell-project 0.0.0 fail(). |
| 564 | $CRYPTSETUP luksOpen -d $KEY1 $OPAL2_DEV $DEV_NAME || failscip-shell shell shell-project 0.0.0 fail(). |
| 565 | |
| 566 | # Delete last slot |
| 567 | preparescip-shell shell shell-project 0.0.0 prepare(). "[11] delete last key" wipe |
| 568 | echoscip-shell system . . echo. -e "$PWD1\n$OPAL2_ADMIN_PIN" | $CRYPTSETUP luksFormat --type luks2 --hw-opal $OPAL2_DEV $FAST_PBKDF_OPT || failscip-shell shell shell-project 0.0.0 fail(). |
| 569 | echoscip-shell system . . echo. $PWD1 | $CRYPTSETUP luksKillSlot $OPAL2_DEV 0 || failscip-shell shell shell-project 0.0.0 fail(). |
| 570 | echoscip-shell system . . echo. $PWD1 | $CRYPTSETUP luksOpen $OPAL2_DEV $DEV_NAME 2>/dev/nullscip-shell filesystem . . `/dev/null`. && failscip-shell shell shell-project 0.0.0 fail(). |
| 571 | |
| 572 | preparescip-shell shell shell-project 0.0.0 prepare(). "[12] open/close - stacked devices" wipe |
| 573 | echoscip-shell system . . echo. -e "$PWD1\n$OPAL2_ADMIN_PIN" | $CRYPTSETUP -q luksFormat --type luks2 --hw-opal $OPAL2_DEV $FAST_PBKDF_OPT || failscip-shell shell shell-project 0.0.0 fail(). |
| 574 | echoscip-shell system . . echo. $PWD1 | $CRYPTSETUP -q luksOpen $OPAL2_DEV $DEV_NAME || failscip-shell shell shell-project 0.0.0 fail(). |
| 575 | echoscip-shell system . . echo. $PWD1 | $CRYPTSETUP -q luksFormat --type luks2 /dev/mapper/$DEV_NAME $FAST_PBKDF_OPT || failscip-shell shell shell-project 0.0.0 fail(). |
| 576 | echoscip-shell system . . echo. $PWD1 | $CRYPTSETUP -q luksOpen /dev/mapper/$DEV_NAME $DEV_NAME2 || failscip-shell shell shell-project 0.0.0 fail(). |
| 577 | $CRYPTSETUP -q luksClose $DEV_NAME2 || failscip-shell shell shell-project 0.0.0 fail(). |
| 578 | $CRYPTSETUP -q luksClose $DEV_NAME || failscip-shell shell shell-project 0.0.0 fail(). |
| 579 | |
| 580 | preparescip-shell shell shell-project 0.0.0 prepare(). "[13] UUID - use and report provided UUID" wipe |
| 581 | echoscip-shell system . . echo. -e "$PWD1\n$OPAL2_ADMIN_PIN" | $CRYPTSETUP -q luksFormat $FAST_PBKDF_OPT --uuid blah --type luks2 --hw-opal $OPAL2_DEV 2>/dev/nullscip-shell filesystem . . `/dev/null`. && failscip-shell shell shell-project 0.0.0 fail(). |
| 582 | echoscip-shell system . . echo. -e "$PWD1\n$OPAL2_ADMIN_PIN" | $CRYPTSETUP -q luksFormat $FAST_PBKDF_OPT --uuid $TEST_UUID --type luks2 --hw-opal $OPAL2_DEV || failscip-shell shell shell-project 0.0.0 fail(). |
| 583 | tst=$($CRYPTSETUP -q luksUUID $OPAL2_DEV) |
| 584 | [scip-shell system . . `[`. "$tst"x = "$TEST_UUID"x ] || failscip-shell shell shell-project 0.0.0 fail(). |
| 585 | echoscip-shell system . . echo. -e "$PWD1\n$OPAL2_ADMIN_PIN" | $CRYPTSETUP -q luksFormat $FAST_PBKDF_OPT --type luks2 --hw-opal $OPAL2_DEV || failscip-shell shell shell-project 0.0.0 fail(). |
| 586 | $CRYPTSETUP -q luksUUID --uuid $TEST_UUID $OPAL2_DEV || failscip-shell shell shell-project 0.0.0 fail(). |
| 587 | tst=$($CRYPTSETUP -q luksUUID $OPAL2_DEV) |
| 588 | [scip-shell system . . `[`. "$tst"x = "$TEST_UUID"x ] || failscip-shell shell shell-project 0.0.0 fail(). |
| 589 | |
| 590 | preparescip-shell shell shell-project 0.0.0 prepare(). "[14] luksFormat" wipe |
| 591 | echoscip-shell system . . echo. -e "$PWD1\n$OPAL2_ADMIN_PIN" | $CRYPTSETUP -q luksFormat $FAST_PBKDF_OPT --volume-key-file /dev/urandomscip-shell filesystem . . `/dev/urandom`. --type luks2 --hw-opal $OPAL2_DEV || failscip-shell shell shell-project 0.0.0 fail(). |
| 592 | echoscip-shell system . . echo. -e "$PWD1\n$OPAL2_ADMIN_PIN" | $CRYPTSETUP -q luksFormat $FAST_PBKDF_OPT --volume-key-file /dev/urandomscip-shell filesystem . . `/dev/urandom`. -s 512 --uuid $TEST_UUID --type luks2 --hw-opal $OPAL2_DEV || failscip-shell shell shell-project 0.0.0 fail(). |
| 593 | $CRYPTSETUP luksOpen -d $KEY_PWD1 $OPAL2_DEV $DEV_NAME || failscip-shell shell shell-project 0.0.0 fail(). |
| 594 | $CRYPTSETUP -q luksClose $DEV_NAME || failscip-shell shell shell-project 0.0.0 fail(). |
| 595 | # open by UUID |
| 596 | if [scip-shell system . . `[`. -d /dev/disk/by-uuidscip-shell filesystem . . `/dev/disk/by-uuid`. ] ; then |
| 597 | $CRYPTSETUP luksOpen -d $KEY_PWD1 UUID=X$TEST_UUID $DEV_NAME 2>/dev/nullscip-shell filesystem . . `/dev/null`. && failscip-shell shell shell-project 0.0.0 fail(). |
| 598 | $CRYPTSETUP luksOpen -d $KEY_PWD1 UUID=$TEST_UUID $DEV_NAME || failscip-shell shell shell-project 0.0.0 fail(). |
| 599 | $CRYPTSETUP -q luksClose $DEV_NAME || failscip-shell shell shell-project 0.0.0 fail(). |
| 600 | fi |
| 601 | # skip tests using empty passphrases |
| 602 | if ! fips_modescip-shell shell shell-project 0.0.0 fips_mode().; then |
| 603 | # empty passphrase (OPAL admin pin cannot be empty) |
| 604 | echoscip-shell system . . echo. -e "\n$OPAL2_ADMIN_PIN" | $CRYPTSETUP -q luksFormat $FAST_PBKDF_OPT --type luks2 --hw-opal $OPAL2_DEV --force-password || failscip-shell shell shell-project 0.0.0 fail(). |
| 605 | $CRYPTSETUP luksOpen -d $KEYE $OPAL2_DEV $DEV_NAME || failscip-shell shell shell-project 0.0.0 fail(). |
| 606 | $CRYPTSETUP -q luksClose $DEV_NAME || failscip-shell shell shell-project 0.0.0 fail(). |
| 607 | fi |
| 608 | |
| 609 | # format hw-opal-only |
| 610 | echoscip-shell system . . echo. -e "$PWD1\n$OPAL2_ADMIN_PIN" | $CRYPTSETUP -q luksFormat $FAST_PBKDF_OPT --volume-key-file /dev/urandomscip-shell filesystem . . `/dev/urandom`. --type luks2 --hw-opal-only $OPAL2_DEV || failscip-shell shell shell-project 0.0.0 fail(). |
| 611 | echoscip-shell system . . echo. -e "$PWD1\n$OPAL2_ADMIN_PIN" | $CRYPTSETUP -q luksFormat $FAST_PBKDF_OPT --volume-key-file /dev/urandomscip-shell filesystem . . `/dev/urandom`. --uuid $TEST_UUID --type luks2 --hw-opal-only $OPAL2_DEV || failscip-shell shell shell-project 0.0.0 fail(). |
| 612 | $CRYPTSETUP luksOpen -d $KEY_PWD1 $OPAL2_DEV $DEV_NAME || failscip-shell shell shell-project 0.0.0 fail(). |
| 613 | $CRYPTSETUP -q luksClose $DEV_NAME || failscip-shell shell shell-project 0.0.0 fail(). |
| 614 | # open by UUID |
| 615 | if [scip-shell system . . `[`. -d /dev/disk/by-uuidscip-shell filesystem . . `/dev/disk/by-uuid`. ] ; then |
| 616 | $CRYPTSETUP luksOpen -d $KEY_PWD1 UUID=X$TEST_UUID $DEV_NAME 2>/dev/nullscip-shell filesystem . . `/dev/null`. && failscip-shell shell shell-project 0.0.0 fail(). |
| 617 | $CRYPTSETUP luksOpen -d $KEY_PWD1 UUID=$TEST_UUID $DEV_NAME || failscip-shell shell shell-project 0.0.0 fail(). |
| 618 | $CRYPTSETUP -q luksClose $DEV_NAME || failscip-shell shell shell-project 0.0.0 fail(). |
| 619 | fi |
| 620 | # skip tests using empty passphrases |
| 621 | if ! fips_modescip-shell shell shell-project 0.0.0 fips_mode().; then |
| 622 | # empty passphrase (OPAL admin pin cannot be empty) |
| 623 | echoscip-shell system . . echo. -e "\n$OPAL2_ADMIN_PIN" | $CRYPTSETUP -q luksFormat $FAST_PBKDF_OPT --type luks2 --hw-opal-only $OPAL2_DEV --force-password || failscip-shell shell shell-project 0.0.0 fail(). |
| 624 | $CRYPTSETUP luksOpen -d $KEYE $OPAL2_DEV $DEV_NAME || failscip-shell shell shell-project 0.0.0 fail(). |
| 625 | $CRYPTSETUP -q luksClose $DEV_NAME || failscip-shell shell shell-project 0.0.0 fail(). |
| 626 | fi |
| 627 | |
| 628 | # open by volume key |
| 629 | echoscip-shell system . . echo. -e "$PWD1\n$OPAL2_ADMIN_PIN" | $CRYPTSETUP -q luksFormat $FAST_PBKDF_OPT -s 256 --volume-key-file $KEY2 --type luks2 --hw-opal $OPAL2_DEV || failscip-shell shell shell-project 0.0.0 fail(). |
| 630 | $CRYPTSETUP luksOpen --volume-key-file /dev/urandomscip-shell filesystem . . `/dev/urandom`. $OPAL2_DEV $DEV_NAME 2>/dev/nullscip-shell filesystem . . `/dev/null`. && failscip-shell shell shell-project 0.0.0 fail(). |
| 631 | $CRYPTSETUP luksOpen --volume-key-file $KEY2 $OPAL2_DEV $DEV_NAME || failscip-shell shell shell-project 0.0.0 fail(). |
| 632 | $CRYPTSETUP -q luksClose $DEV_NAME || failscip-shell shell shell-project 0.0.0 fail(). |
| 633 | |
| 634 | preparescip-shell shell shell-project 0.0.0 prepare(). "[15] AddKey volume key, passphrase and keyfile" wipe |
| 635 | # volumekey |
| 636 | echoscip-shell system . . echo. -e "$PWD1\n$OPAL2_ADMIN_PIN" | $CRYPTSETUP -q luksFormat $FAST_PBKDF_OPT --type luks2 --hw-opal $OPAL2_DEV --volume-key-file /dev/zeroscip-shell filesystem . . `/dev/zero`. --key-slot 3 || failscip-shell shell shell-project 0.0.0 fail(). |
| 637 | echoscip-shell system . . echo. $PWD1 | $CRYPTSETUP luksOpen $OPAL2_DEV --test-passphrase || failscip-shell shell shell-project 0.0.0 fail(). |
| 638 | $CRYPTSETUP luksDump $OPAL2_DEV | grepscip-shell system . . grep. -q "3: luks2" || failscip-shell shell shell-project 0.0.0 fail(). |
| 639 | echoscip-shell system . . echo. $PWD2 | $CRYPTSETUP luksAddKey -q $FAST_PBKDF_OPT $OPAL2_DEV --volume-key-file /dev/zeroscip-shell filesystem . . `/dev/zero`. --key-slot 4 || failscip-shell shell shell-project 0.0.0 fail(). |
| 640 | echoscip-shell system . . echo. $PWD2 | $CRYPTSETUP luksOpen $OPAL2_DEV --test-passphrase --key-slot 4 || failscip-shell shell shell-project 0.0.0 fail(). |
| 641 | $CRYPTSETUP luksDump $OPAL2_DEV | grepscip-shell system . . grep. -q "4: luks2" || failscip-shell shell shell-project 0.0.0 fail(). |
| 642 | echoscip-shell system . . echo. $PWD3 | $CRYPTSETUP luksAddKey -q $FAST_PBKDF_OPT $OPAL2_DEV --volume-key-file /dev/nullscip-shell filesystem . . `/dev/null`. --key-slot 5 2>/dev/nullscip-shell filesystem . . `/dev/null`. && failscip-shell shell shell-project 0.0.0 fail(). |
| 643 | $CRYPTSETUP luksAddKey -q $FAST_PBKDF_OPT $OPAL2_DEV --volume-key-file /dev/zeroscip-shell filesystem . . `/dev/zero`. --key-slot 5 $KEY1 || failscip-shell shell shell-project 0.0.0 fail(). |
| 644 | $CRYPTSETUP luksOpen $OPAL2_DEV --test-passphrase --key-slot 5 -d $KEY1 || failscip-shell shell shell-project 0.0.0 fail(). |
| 645 | $CRYPTSETUP luksDump $OPAL2_DEV | grepscip-shell system . . grep. -q "5: luks2" || failscip-shell shell shell-project 0.0.0 fail(). |
| 646 | |
| 647 | # special "-" handling |
| 648 | echoscip-shell system . . echo. -e "$PWD1\n$OPAL2_ADMIN_PIN" | $CRYPTSETUP -q luksFormat $FAST_PBKDF_OPT --type luks2 --hw-opal $OPAL2_DEV --key-slot 3 || failscip-shell shell shell-project 0.0.0 fail(). |
| 649 | echoscip-shell system . . echo. $PWD2 | $CRYPTSETUP luksAddKey $FAST_PBKDF_OPT $OPAL2_DEV -d $KEY_PWD1 - || failscip-shell shell shell-project 0.0.0 fail(). |
| 650 | echoscip-shell system . . echo. $PWD2 | $CRYPTSETUP luksOpen $OPAL2_DEV --test-passphrase 2>/dev/nullscip-shell filesystem . . `/dev/null`. && failscip-shell shell shell-project 0.0.0 fail(). |
| 651 | echoscip-shell system . . echo. $PWD2 | $CRYPTSETUP luksOpen $OPAL2_DEV -d - --test-passphrase || failscip-shell shell shell-project 0.0.0 fail(). |
| 652 | echoscip-shell system . . echo. $PWD2 | $CRYPTSETUP luksAddKey $FAST_PBKDF_OPT $OPAL2_DEV -d - $KEY2 || failscip-shell shell shell-project 0.0.0 fail(). |
| 653 | $CRYPTSETUP luksOpen $OPAL2_DEV -d $KEY2 --test-passphrase || failscip-shell shell shell-project 0.0.0 fail(). |
| 654 | echoscip-shell system . . echo. $PWD2 | $CRYPTSETUP luksOpen $OPAL2_DEV -d - -d $KEY1 --test-passphrase 2>/dev/nullscip-shell filesystem . . `/dev/null`. && failscip-shell shell shell-project 0.0.0 fail(). |
| 655 | echoscip-shell system . . echo. $PWD2 | $CRYPTSETUP luksOpen $OPAL2_DEV -d $KEY1 -d $KEY1 --test-passphrase 2>/dev/nullscip-shell filesystem . . `/dev/null`. && failscip-shell shell shell-project 0.0.0 fail(). |
| 656 | |
| 657 | # [0]PWD3 [1]PWD2 [3]PWD1 [4]KEY2 |
| 658 | echoscip-shell system . . echo. -e "$PWD1\n$OPAL2_ADMIN_PIN" | $CRYPTSETUP -q luksFormat $FAST_PBKDF_OPT --type luks2 --hw-opal $OPAL2_DEV --key-slot 3 || failscip-shell shell shell-project 0.0.0 fail(). |
| 659 | $CRYPTSETUP luksDump $OPAL2_DEV | grepscip-shell system . . grep. -q "3: luks2" || failscip-shell shell shell-project 0.0.0 fail(). |
| 660 | $CRYPTSETUP luksAddKey -q $OPAL2_DEV $FAST_PBKDF_OPT -d $KEY_PWD1 $KEY2 --key-slot 3 2>/dev/nullscip-shell filesystem . . `/dev/null`. && failscip-shell shell shell-project 0.0.0 fail(). |
| 661 | # keyfile/keyfile |
| 662 | $CRYPTSETUP luksAddKey -q $OPAL2_DEV $FAST_PBKDF_OPT -d $KEY_PWD1 $KEY2 --key-slot 4 || failscip-shell shell shell-project 0.0.0 fail(). |
| 663 | $CRYPTSETUP luksOpen $OPAL2_DEV -d $KEY2 --test-passphrase --key-slot 4 || failscip-shell shell shell-project 0.0.0 fail(). |
| 664 | $CRYPTSETUP luksDump $OPAL2_DEV | grepscip-shell system . . grep. -q "4: luks2" || failscip-shell shell shell-project 0.0.0 fail(). |
| 665 | # passphrase/keyfile |
| 666 | echoscip-shell system . . echo. $PWD3 | $CRYPTSETUP luksAddKey -q $FAST_PBKDF_OPT $OPAL2_DEV -d $KEY_PWD1 --key-slot 0 || failscip-shell shell shell-project 0.0.0 fail(). |
| 667 | $CRYPTSETUP luksDump $OPAL2_DEV | grepscip-shell system . . grep. -q "0: luks2" || failscip-shell shell shell-project 0.0.0 fail(). |
| 668 | echoscip-shell system . . echo. $PWD3 | $CRYPTSETUP luksOpen $OPAL2_DEV --test-passphrase --key-slot 0 || failscip-shell shell shell-project 0.0.0 fail(). |
| 669 | # passphrase/passphrase |
| 670 | echoscip-shell system . . echo. -e "$PWD1\n$PWD2\n" | $CRYPTSETUP luksAddKey -q $FAST_PBKDF_OPT $OPAL2_DEV --key-slot 1 || failscip-shell shell shell-project 0.0.0 fail(). |
| 671 | echoscip-shell system . . echo. $PWD2 | $CRYPTSETUP luksOpen $OPAL2_DEV --test-passphrase --key-slot 1 || failscip-shell shell shell-project 0.0.0 fail(). |
| 672 | $CRYPTSETUP luksDump $OPAL2_DEV | grepscip-shell system . . grep. -q "1: luks2" || failscip-shell shell shell-project 0.0.0 fail(). |
| 673 | # keyfile/passphrase |
| 674 | echoscip-shell system . . echo. -e "$PWD2\n" | $CRYPTSETUP luksAddKey -q $FAST_PBKDF_OPT $OPAL2_DEV $KEY_PWD1 --key-slot 2 --new-keyfile-size 8 || failscip-shell shell shell-project 0.0.0 fail(). |
| 675 | $CRYPTSETUP luksDump $OPAL2_DEV | grepscip-shell system . . grep. -q "2: luks2" || failscip-shell shell shell-project 0.0.0 fail(). |
| 676 | |
| 677 | preparescip-shell shell shell-project 0.0.0 prepare(). "[16] RemoveKey passphrase and keyfile" reuse |
| 678 | $CRYPTSETUP luksDump $OPAL2_DEV | grepscip-shell system . . grep. -q "3: luks2" || failscip-shell shell shell-project 0.0.0 fail(). |
| 679 | $CRYPTSETUP luksRemoveKey $OPAL2_DEV $KEY_PWD1 || failscip-shell shell shell-project 0.0.0 fail(). |
| 680 | $CRYPTSETUP luksDump $OPAL2_DEV | grepscip-shell system . . grep. -q "3: luks2" && failscip-shell shell shell-project 0.0.0 fail(). |
| 681 | $CRYPTSETUP luksRemoveKey $OPAL2_DEV $KEY_PWD1 2>/dev/nullscip-shell filesystem . . `/dev/null`. && failscip-shell shell shell-project 0.0.0 fail(). |
| 682 | [scip-shell system . . `[`. $? -ne 2 ] && failscip-shell shell shell-project 0.0.0 fail(). "luksRemoveKey should return EPERM exit code" |
| 683 | $CRYPTSETUP luksRemoveKey $OPAL2_DEV $KEY2 --keyfile-size 1 2>/dev/nullscip-shell filesystem . . `/dev/null`. && failscip-shell shell shell-project 0.0.0 fail(). |
| 684 | $CRYPTSETUP luksDump $OPAL2_DEV | grepscip-shell system . . grep. -q "4: luks2" || failscip-shell shell shell-project 0.0.0 fail(). |
| 685 | $CRYPTSETUP luksRemoveKey $OPAL2_DEV $KEY2 || failscip-shell shell shell-project 0.0.0 fail(). |
| 686 | $CRYPTSETUP luksDump $OPAL2_DEV | grepscip-shell system . . grep. -q "4: luks2" && failscip-shell shell shell-project 0.0.0 fail(). |
| 687 | # if password or keyfile is provided, batch mode must not suppress it |
| 688 | echoscip-shell system . . echo. "badpw" | $CRYPTSETUP luksKillSlot $OPAL2_DEV 2 2>/dev/nullscip-shell filesystem . . `/dev/null`. && failscip-shell shell shell-project 0.0.0 fail(). |
| 689 | echoscip-shell system . . echo. "badpw" | $CRYPTSETUP luksKillSlot $OPAL2_DEV 2 -q 2>/dev/nullscip-shell filesystem . . `/dev/null`. && failscip-shell shell shell-project 0.0.0 fail(). |
| 690 | echoscip-shell system . . echo. "badpw" | $CRYPTSETUP luksKillSlot $OPAL2_DEV 2 --key-file=- 2>/dev/nullscip-shell filesystem . . `/dev/null`. && failscip-shell shell shell-project 0.0.0 fail(). |
| 691 | echoscip-shell system . . echo. "badpw" | $CRYPTSETUP luksKillSlot $OPAL2_DEV 2 --key-file=- -q 2>/dev/nullscip-shell filesystem . . `/dev/null`. && failscip-shell shell shell-project 0.0.0 fail(). |
| 692 | $CRYPTSETUP luksDump $OPAL2_DEV | grepscip-shell system . . grep. -q "2: luks2" || failscip-shell shell shell-project 0.0.0 fail(). |
| 693 | # kill slot using passphrase from 1 |
| 694 | echoscip-shell system . . echo. $PWD2 | $CRYPTSETUP luksKillSlot $OPAL2_DEV 2 2>/dev/nullscip-shell filesystem . . `/dev/null`. || failscip-shell shell shell-project 0.0.0 fail(). |
| 695 | $CRYPTSETUP luksDump $OPAL2_DEV | grepscip-shell system . . grep. -q "2: luks2" && failscip-shell shell shell-project 0.0.0 fail(). |
| 696 | # remove key0 / slot 0 |
| 697 | echoscip-shell system . . echo. $PWD3 | $CRYPTSETUP luksRemoveKey $OPAL2_DEV || failscip-shell shell shell-project 0.0.0 fail(). |
| 698 | $CRYPTSETUP luksDump $OPAL2_DEV | grepscip-shell system . . grep. -q "0: luks2" && failscip-shell shell shell-project 0.0.0 fail(). |
| 699 | # last keyslot, in batch mode no passphrase needed... |
| 700 | $CRYPTSETUP luksKillSlot -q $OPAL2_DEV 1 || failscip-shell shell shell-project 0.0.0 fail(). |
| 701 | $CRYPTSETUP luksDump $OPAL2_DEV | grepscip-shell system . . grep. -q "1: luks2" && failscip-shell shell shell-project 0.0.0 fail(). |
| 702 | |
| 703 | preparescip-shell shell shell-project 0.0.0 prepare(). "[17] create & resize" wipe |
| 704 | echoscip-shell system . . echo. -e "$PWD1\n$OPAL2_ADMIN_PIN" | $CRYPTSETUP luksFormat $FAST_PBKDF_OPT --type luks2 --hw-opal $OPAL2_DEV || failscip-shell shell shell-project 0.0.0 fail(). |
| 705 | echoscip-shell system . . echo. $PWD1 | $CRYPTSETUP luksOpen $OPAL2_DEV $DEV_NAME || failscip-shell shell shell-project 0.0.0 fail(). |
| 706 | # OPAL2 devices cannot be resized |
| 707 | $CRYPTSETUP -q resize --size 99 $DEV_NAME <&- 2>/dev/nullscip-shell filesystem . . `/dev/null`. && failscip-shell shell shell-project 0.0.0 fail(). |
| 708 | echoscip-shell system . . echo. $PWD1 | $CRYPTSETUP -q resize --size 99 $DEV_NAME 2>/dev/nullscip-shell filesystem . . `/dev/null`. && failscip-shell shell shell-project 0.0.0 fail(). |
| 709 | $CRYPTSETUP close $DEV_NAME || failscip-shell shell shell-project 0.0.0 fail(). |
| 710 | echoscip-shell system . . echo. -e "$PWD1\n$OPAL2_ADMIN_PIN" | $CRYPTSETUP luksFormat $FAST_PBKDF_OPT -q --type luks2 --hw-opal-only $OPAL2_DEV || failscip-shell shell shell-project 0.0.0 fail(). |
| 711 | echoscip-shell system . . echo. $PWD1 | $CRYPTSETUP luksOpen $OPAL2_DEV $DEV_NAME || failscip-shell shell shell-project 0.0.0 fail(). |
| 712 | # OPAL2 devices cannot be resized |
| 713 | $CRYPTSETUP -q resize --size 99 $DEV_NAME <&- 2>/dev/nullscip-shell filesystem . . `/dev/null`. && failscip-shell shell shell-project 0.0.0 fail(). |
| 714 | echoscip-shell system . . echo. $PWD1 | $CRYPTSETUP -q resize --size 99 $DEV_NAME 2>/dev/nullscip-shell filesystem . . `/dev/null`. && failscip-shell shell shell-project 0.0.0 fail(). |
| 715 | $CRYPTSETUP close $DEV_NAME || failscip-shell shell shell-project 0.0.0 fail(). |
| 716 | echoscip-shell system . . echo. $OPAL2_ADMIN_PIN | $CRYPTSETUP luksErase $OPAL2_DEV -q || failscip-shell shell shell-project 0.0.0 fail(). |
| 717 | |
| 718 | preparescip-shell shell shell-project 0.0.0 prepare(). "[18] Disallow open/create if already mapped." wipe |
| 719 | $CRYPTSETUP create -q $DEV_NAME $OPAL2_DEV -d $KEY1 2>/dev/nullscip-shell filesystem . . `/dev/null`. || failscip-shell shell shell-project 0.0.0 fail(). |
| 720 | echoscip-shell system . . echo. -e "$PWD1\n$OPAL2_ADMIN_PIN" | $CRYPTSETUP -q luksFormat $FAST_PBKDF_OPT --type luks2 --hw-opal $OPAL2_DEV 2>/dev/nullscip-shell filesystem . . `/dev/null`. && failscip-shell shell shell-project 0.0.0 fail(). |
| 721 | $CRYPTSETUP remove $DEV_NAME || failscip-shell shell shell-project 0.0.0 fail(). |
| 722 | echoscip-shell system . . echo. -e "$PWD1\n$OPAL2_ADMIN_PIN" | $CRYPTSETUP -q luksFormat $FAST_PBKDF_OPT --type luks2 --hw-opal $OPAL2_DEV || failscip-shell shell shell-project 0.0.0 fail(). |
| 723 | echoscip-shell system . . echo. $PWD1 | $CRYPTSETUP luksOpen $OPAL2_DEV $DEV_NAME || failscip-shell shell shell-project 0.0.0 fail(). |
| 724 | echoscip-shell system . . echo. $PWD1 | $CRYPTSETUP luksOpen -q $OPAL2_DEV $DEV_NAME2 >/dev/nullscip-shell filesystem . . `/dev/null`. 2>&1 && failscip-shell shell shell-project 0.0.0 fail(). |
| 725 | ddscip-shell system . . dd. if=$OPAL2_DEV of=/dev/zeroscip-shell filesystem . . `/dev/zero`. bs=1M skip=16 count=1 iflag=direct >/dev/nullscip-shell filesystem . . `/dev/null`. 2>&1 || failscip-shell shell shell-project 0.0.0 fail(). "OPAL segment perhaps locked after failed activation over already active device." |
| 726 | $CRYPTSETUP luksClose $DEV_NAME || failscip-shell shell shell-project 0.0.0 fail(). |
| 727 | |
| 728 | preparescip-shell shell shell-project 0.0.0 prepare(). "[19] luksDump" wipe |
| 729 | echoscip-shell system . . echo. -e "$PWD1\n$OPAL2_ADMIN_PIN" | $CRYPTSETUP -q luksFormat --key-size 256 $FAST_PBKDF_OPT --uuid $TEST_UUID --type luks2 --hw-opal $OPAL2_DEV || failscip-shell shell shell-project 0.0.0 fail(). |
| 730 | echoscip-shell system . . echo. $PWD1 | $CRYPTSETUP luksAddKey $FAST_PBKDF_OPT $OPAL2_DEV -d $KEY_PWD1 || failscip-shell shell shell-project 0.0.0 fail(). |
| 731 | $CRYPTSETUP luksDump $OPAL2_DEV | grepscip-shell system . . grep. -q "0: luks2" || failscip-shell shell shell-project 0.0.0 fail(). |
| 732 | $CRYPTSETUP luksDump $OPAL2_DEV | grepscip-shell system . . grep. -q $TEST_UUID || failscip-shell shell shell-project 0.0.0 fail(). |
| 733 | echoscip-shell system . . echo. $PWDW | $CRYPTSETUP luksDump $OPAL2_DEV --dump-volume-key 2>/dev/nullscip-shell filesystem . . `/dev/null`. && failscip-shell shell shell-project 0.0.0 fail(). |
| 734 | echoscip-shell system . . echo. $PWD1 | $CRYPTSETUP luksDump $OPAL2_DEV --dump-volume-key | grepscip-shell system . . grep. -q "MK dump:" || failscip-shell shell shell-project 0.0.0 fail(). |
| 735 | $CRYPTSETUP luksDump -q $OPAL2_DEV --dump-volume-key -d $KEY_PWD1 | grepscip-shell system . . grep. -q "MK dump:" || failscip-shell shell shell-project 0.0.0 fail(). |
| 736 | echoscip-shell system . . echo. $PWD1 | $CRYPTSETUP luksDump -q $OPAL2_DEV --dump-master-key --master-key-file $VK_FILE >/dev/nullscip-shell filesystem . . `/dev/null`. || failscip-shell shell shell-project 0.0.0 fail(). |
| 737 | rmscip-shell system . . rm. -f $VK_FILE |
| 738 | echoscip-shell system . . echo. $PWD1 | $CRYPTSETUP luksDump -q $OPAL2_DEV --dump-volume-key --volume-key-file $VK_FILE >/dev/nullscip-shell filesystem . . `/dev/null`. || failscip-shell shell shell-project 0.0.0 fail(). |
| 739 | echoscip-shell system . . echo. $PWD1 | $CRYPTSETUP luksDump -q $OPAL2_DEV --dump-volume-key --volume-key-file $VK_FILE 2>/dev/nullscip-shell filesystem . . `/dev/null`. && failscip-shell shell shell-project 0.0.0 fail(). |
| 740 | echoscip-shell system . . echo. $PWD1 | $CRYPTSETUP luksAddKey $FAST_PBKDF_OPT --volume-key-file $VK_FILE $OPAL2_DEV || failscip-shell shell shell-project 0.0.0 fail(). |
| 741 | # Use volume key file without keyslots |
| 742 | echoscip-shell system . . echo. $PWD1 | $CRYPTSETUP luksRemoveKey -q $OPAL2_DEV || failscip-shell shell shell-project 0.0.0 fail(). |
| 743 | echoscip-shell system . . echo. $PWD1 | $CRYPTSETUP luksRemoveKey -q $OPAL2_DEV || failscip-shell shell shell-project 0.0.0 fail(). |
| 744 | echoscip-shell system . . echo. $PWD1 | $CRYPTSETUP luksRemoveKey -q $OPAL2_DEV || failscip-shell shell shell-project 0.0.0 fail(). |
| 745 | $CRYPTSETUP luksOpen --volume-key-file $VK_FILE --key-size 512 --test-passphrase $OPAL2_DEV || failscip-shell shell shell-project 0.0.0 fail(). |
| 746 | echoscip-shell system . . echo. $PWD1 | $CRYPTSETUP luksAddKey $FAST_PBKDF_OPT --volume-key-file $VK_FILE --key-size 512 $OPAL2_DEV || failscip-shell shell shell-project 0.0.0 fail(). |
| 747 | echoscip-shell system . . echo. $PWD1 | $CRYPTSETUP luksOpen --test-passphrase $OPAL2_DEV || failscip-shell shell shell-project 0.0.0 fail(). |
| 748 | |
| 749 | preparescip-shell shell shell-project 0.0.0 prepare(). "[20] ChangeKey passphrase and keyfile" wipe |
| 750 | # [0]PWD1 [1]PWD2 |
| 751 | echoscip-shell system . . echo. -e "$PWD1\n$OPAL2_ADMIN_PIN" | $CRYPTSETUP -q luksFormat --type luks2 --hw-opal $OPAL2_DEV $FAST_PBKDF_OPT --key-slot 0 --key-size 256 --luks2-keyslots-size 756k >/dev/nullscip-shell filesystem . . `/dev/null`. || failscip-shell shell shell-project 0.0.0 fail(). |
| 752 | echoscip-shell system . . echo. $PWD2 | $CRYPTSETUP luksAddKey -q $OPAL2_DEV $FAST_PBKDF_OPT -d $KEY_PWD1 --key-slot 1 || failscip-shell shell shell-project 0.0.0 fail(). |
| 753 | # [0]KEY2 [1]PWD2 |
| 754 | $CRYPTSETUP luksChangeKey $OPAL2_DEV $FAST_PBKDF_OPT -d $KEY_PWD1 $KEY2 --key-slot 0 || failscip-shell shell shell-project 0.0.0 fail(). |
| 755 | # [0]KEY2 [1]PWD1 |
| 756 | echoscip-shell system . . echo. -e "$PWD2\n$PWD1" | $CRYPTSETUP luksChangeKey $OPAL2_DEV $FAST_PBKDF_OPT --key-slot 1 || failscip-shell shell shell-project 0.0.0 fail(). |
| 757 | # [0]KEY1 [1]PWD1 - with LUKS2 it should stay |
| 758 | $CRYPTSETUP luksChangeKey $OPAL2_DEV $FAST_PBKDF_OPT -d $KEY2 $KEY1 || failscip-shell shell shell-project 0.0.0 fail(). |
| 759 | $CRYPTSETUP luksDump $OPAL2_DEV | grepscip-shell system . . grep. -q "0: luks2" || failscip-shell shell shell-project 0.0.0 fail(). |
| 760 | $CRYPTSETUP luksDump $OPAL2_DEV | grepscip-shell system . . grep. -q "2: luks2" && failscip-shell shell shell-project 0.0.0 fail(). |
| 761 | # [0]KEY1 [1]PWD2 |
| 762 | echoscip-shell system . . echo. -e "$PWD1\n$PWD2" | $CRYPTSETUP luksChangeKey $FAST_PBKDF_OPT $OPAL2_DEV || failscip-shell shell shell-project 0.0.0 fail(). |
| 763 | $CRYPTSETUP luksDump $OPAL2_DEV | grepscip-shell system . . grep. -q "1: luks2" || failscip-shell shell shell-project 0.0.0 fail(). |
| 764 | $CRYPTSETUP luksDump $OPAL2_DEV | grepscip-shell system . . grep. -q "2: luks2" && failscip-shell shell shell-project 0.0.0 fail(). |
| 765 | # test out of raw area, change in-place (space only for 2 keyslots) |
| 766 | $CRYPTSETUP luksChangeKey $OPAL2_DEV $FAST_PBKDF_OPT -d $KEY1 $KEY2 || failscip-shell shell shell-project 0.0.0 fail(). |
| 767 | $CRYPTSETUP luksDump $OPAL2_DEV | grepscip-shell system . . grep. -q "0: luks2" || failscip-shell shell shell-project 0.0.0 fail(). |
| 768 | $CRYPTSETUP luksChangeKey $OPAL2_DEV $FAST_PBKDF_OPT -d $KEY1 $KEY2 2>/dev/nullscip-shell filesystem . . `/dev/null`. && failscip-shell shell shell-project 0.0.0 fail(). |
| 769 | # make a free space in keyslot area |
| 770 | echoscip-shell system . . echo. $PWD2 | $CRYPTSETUP luksKillSlot -q $OPAL2_DEV 0 || failscip-shell shell shell-project 0.0.0 fail(). |
| 771 | |
| 772 | # assert LUKS2 does not overwrite existing area with specific keyslot id |
| 773 | AREA_OFFSET_OLD=$($CRYPTSETUP luksDump $OPAL2_DEV | grepscip-shell system . . grep. -e "1: luks2" -A12 | grepscip-shell system . . grep. -e "Area offset:" | cutscip-shell system . . cut. -d: -f 2 | sedscip-shell system . . sed. -e 's/[[:space:]]*\[bytes\]//g') |
| 774 | [scip-shell system . . `[`. 0$AREA_OFFSET_OLD -gt 0 ] || failscip-shell shell shell-project 0.0.0 fail(). |
| 775 | echoscip-shell system . . echo. -e "$PWD2\n$PWD1\n" | $CRYPTSETUP luksChangeKey --key-slot 1 $OPAL2_DEV $FAST_PBKDF_OPT || failscip-shell shell shell-project 0.0.0 fail(). |
| 776 | AREA_OFFSET_NEW=$($CRYPTSETUP luksDump $OPAL2_DEV | grepscip-shell system . . grep. -e "1: luks2" -A12 | grepscip-shell system . . grep. -e "Area offset:" | cutscip-shell system . . cut. -d: -f 2 | sedscip-shell system . . sed. -e 's/[[:space:]]*\[bytes\]//g') |
| 777 | [scip-shell system . . `[`. 0$AREA_OFFSET_NEW -gt 0 ] || failscip-shell shell shell-project 0.0.0 fail(). |
| 778 | [scip-shell system . . `[`. $AREA_OFFSET_OLD -ne $AREA_OFFSET_NEW ] || failscip-shell shell shell-project 0.0.0 fail(). "Area offsets remained same: old area $AREA_OFFSET_OLD, new area $AREA_OFFSET_NEW" |
| 779 | |
| 780 | # assert LUKS2 does not overwrite existing area with any sklot |
| 781 | AREA_OFFSET_OLD=$($CRYPTSETUP luksDump $OPAL2_DEV | grepscip-shell system . . grep. -e "1: luks2" -A12 | grepscip-shell system . . grep. -e "Area offset:" | cutscip-shell system . . cut. -d: -f 2 | sedscip-shell system . . sed. -e 's/[[:space:]]*\[bytes\]//g') |
| 782 | [scip-shell system . . `[`. 0$AREA_OFFSET_OLD -gt 0 ] || failscip-shell shell shell-project 0.0.0 fail(). |
| 783 | echoscip-shell system . . echo. -e "$PWD1\n$PWD2\n" | $CRYPTSETUP luksChangeKey $OPAL2_DEV $FAST_PBKDF_OPT || failscip-shell shell shell-project 0.0.0 fail(). |
| 784 | AREA_OFFSET_NEW=$($CRYPTSETUP luksDump $OPAL2_DEV | grepscip-shell system . . grep. -e "1: luks2" -A12 | grepscip-shell system . . grep. -e "Area offset:" | cutscip-shell system . . cut. -d: -f 2 | sedscip-shell system . . sed. -e 's/[[:space:]]*\[bytes\]//g') |
| 785 | [scip-shell system . . `[`. 0$AREA_OFFSET_NEW -gt 0 ] || failscip-shell shell shell-project 0.0.0 fail(). |
| 786 | [scip-shell system . . `[`. $AREA_OFFSET_OLD -ne $AREA_OFFSET_NEW ] || failscip-shell shell shell-project 0.0.0 fail(). "Area offsets remained same: old area $AREA_OFFSET_OLD, new area $AREA_OFFSET_NEW" |
| 787 | |
| 788 | preparescip-shell shell shell-project 0.0.0 prepare(). "[21] Keyfile limit" wipe |
| 789 | echoscip-shell system . . echo. -e "$PWD1\n$OPAL2_ADMIN_PIN" | $CRYPTSETUP -q luksFormat $FAST_PBKDF_OPT --type luks2 --hw-opal $OPAL2_DEV --key-slot 0 || failscip-shell shell shell-project 0.0.0 fail(). |
| 790 | echoscip-shell system . . echo. $PWD1 | $CRYPTSETUP luksChangeKey $OPAL2_DEV $KEY1 --new-keyfile-size 13 $FAST_PBKDF_OPT || failscip-shell shell shell-project 0.0.0 fail(). |
| 791 | echoscip-shell system . . echo. $PWD1 | $CRYPTSETUP open --test-passphrase $OPAL2_DEV -q 2>/dev/nullscip-shell filesystem . . `/dev/null`. && failscip-shell shell shell-project 0.0.0 fail(). |
| 792 | $CRYPTSETUP --key-file=$KEY1 luksOpen $OPAL2_DEV $DEV_NAME 2>/dev/nullscip-shell filesystem . . `/dev/null`. && failscip-shell shell shell-project 0.0.0 fail(). |
| 793 | $CRYPTSETUP --key-file=$KEY1 -l 0 luksOpen $OPAL2_DEV $DEV_NAME 2>/dev/nullscip-shell filesystem . . `/dev/null`. && failscip-shell shell shell-project 0.0.0 fail(). |
| 794 | $CRYPTSETUP --key-file=$KEY1 -l -1 luksOpen $OPAL2_DEV $DEV_NAME 2>/dev/nullscip-shell filesystem . . `/dev/null`. && failscip-shell shell shell-project 0.0.0 fail(). |
| 795 | $CRYPTSETUP --key-file=$KEY1 -l 14 luksOpen $OPAL2_DEV $DEV_NAME 2>/dev/nullscip-shell filesystem . . `/dev/null`. && failscip-shell shell shell-project 0.0.0 fail(). |
| 796 | $CRYPTSETUP --key-file=$KEY1 -l 13 --keyfile-offset 1 luksOpen $OPAL2_DEV $DEV_NAME 2>/dev/nullscip-shell filesystem . . `/dev/null`. && failscip-shell shell shell-project 0.0.0 fail(). |
| 797 | $CRYPTSETUP --key-file=$KEY1 -l 13 --keyfile-offset -1 luksOpen $OPAL2_DEV $DEV_NAME 2>/dev/nullscip-shell filesystem . . `/dev/null`. && failscip-shell shell shell-project 0.0.0 fail(). |
| 798 | $CRYPTSETUP --key-file=$KEY1 -l 13 luksOpen $OPAL2_DEV $DEV_NAME || failscip-shell shell shell-project 0.0.0 fail(). |
| 799 | $CRYPTSETUP luksClose $DEV_NAME || failscip-shell shell shell-project 0.0.0 fail(). |
| 800 | $CRYPTSETUP luksAddKey $OPAL2_DEV -d $KEY1 $KEY2 2>/dev/nullscip-shell filesystem . . `/dev/null`. && failscip-shell shell shell-project 0.0.0 fail(). |
| 801 | $CRYPTSETUP luksAddKey $OPAL2_DEV -d $KEY1 $KEY2 -l 14 2>/dev/nullscip-shell filesystem . . `/dev/null`. && failscip-shell shell shell-project 0.0.0 fail(). |
| 802 | $CRYPTSETUP luksAddKey $OPAL2_DEV -d $KEY1 $KEY2 -l -1 2>/dev/nullscip-shell filesystem . . `/dev/null`. && failscip-shell shell shell-project 0.0.0 fail(). |
| 803 | $CRYPTSETUP luksAddKey $OPAL2_DEV -d $KEY1 $KEY2 $FAST_PBKDF_OPT -l 13 --new-keyfile-size 12 || failscip-shell shell shell-project 0.0.0 fail(). |
| 804 | $CRYPTSETUP luksRemoveKey $OPAL2_DEV $KEY2 2>/dev/nullscip-shell filesystem . . `/dev/null`. && failscip-shell shell shell-project 0.0.0 fail(). |
| 805 | $CRYPTSETUP luksRemoveKey $OPAL2_DEV $KEY2 -l 12 || failscip-shell shell shell-project 0.0.0 fail(). |
| 806 | $CRYPTSETUP luksChangeKey $OPAL2_DEV -d $KEY1 $KEY2 2>/dev/nullscip-shell filesystem . . `/dev/null`. && failscip-shell shell shell-project 0.0.0 fail(). |
| 807 | [scip-shell system . . `[`. $? -ne 2 ] && failscip-shell shell shell-project 0.0.0 fail(). "luksChangeKey should return EPERM exit code" |
| 808 | $CRYPTSETUP luksChangeKey $OPAL2_DEV -d $KEY1 $KEY2 -l 14 2>/dev/nullscip-shell filesystem . . `/dev/null`. && failscip-shell shell shell-project 0.0.0 fail(). |
| 809 | $CRYPTSETUP luksChangeKey $OPAL2_DEV -d $KEY1 $KEY2 $FAST_PBKDF_OPT -l 13 || failscip-shell shell shell-project 0.0.0 fail(). |
| 810 | # -l is ignored for stdin if _only_ passphrase is used |
| 811 | echoscip-shell system . . echo. $PWD1 | $CRYPTSETUP luksAddKey $OPAL2_DEV -d $KEY2 $FAST_PBKDF_OPT || failscip-shell shell shell-project 0.0.0 fail(). |
| 812 | # this is stupid, but expected |
| 813 | echoscip-shell system . . echo. $PWD1 | $CRYPTSETUP luksRemoveKey $OPAL2_DEV -l 11 2>/dev/nullscip-shell filesystem . . `/dev/null`. && failscip-shell shell shell-project 0.0.0 fail(). |
| 814 | echoscip-shell system . . echo. $PWDW"0" | $CRYPTSETUP luksRemoveKey $OPAL2_DEV -l 12 2>/dev/nullscip-shell filesystem . . `/dev/null`. && failscip-shell shell shell-project 0.0.0 fail(). |
| 815 | echoscip-shell system . . echo. -e "$PWD1\n" | $CRYPTSETUP luksRemoveKey $OPAL2_DEV -d- -l 12 || failscip-shell shell shell-project 0.0.0 fail(). |
| 816 | # offset |
| 817 | echoscip-shell system . . echo. -e "$PWD1\n$OPAL2_ADMIN_PIN" | $CRYPTSETUP -q luksFormat $FAST_PBKDF_OPT --type luks2 --hw-opal $OPAL2_DEV --key-slot 0 || failscip-shell shell shell-project 0.0.0 fail(). |
| 818 | echoscip-shell system . . echo. $PWD1 | $CRYPTSETUP luksChangeKey $OPAL2_DEV $KEY1 --new-keyfile-offset 16 --new-keyfile-size 13 $FAST_PBKDF_OPT || failscip-shell shell shell-project 0.0.0 fail(). |
| 819 | $CRYPTSETUP --key-file=$KEY1 -l 13 --keyfile-offset 15 luksOpen $OPAL2_DEV $DEV_NAME 2>/dev/nullscip-shell filesystem . . `/dev/null`. && failscip-shell shell shell-project 0.0.0 fail(). |
| 820 | $CRYPTSETUP --key-file=$KEY1 -l 13 --keyfile-offset 16 luksOpen $OPAL2_DEV $DEV_NAME || failscip-shell shell shell-project 0.0.0 fail(). |
| 821 | $CRYPTSETUP luksClose $DEV_NAME || failscip-shell shell shell-project 0.0.0 fail(). |
| 822 | $CRYPTSETUP luksAddKey $OPAL2_DEV $FAST_PBKDF_OPT -d $KEY1 -l 13 --keyfile-offset 16 $KEY2 --new-keyfile-offset 1 || failscip-shell shell shell-project 0.0.0 fail(). |
| 823 | $CRYPTSETUP --key-file=$KEY2 --keyfile-offset 11 luksOpen $OPAL2_DEV $DEV_NAME 2>/dev/nullscip-shell filesystem . . `/dev/null`. && failscip-shell shell shell-project 0.0.0 fail(). |
| 824 | $CRYPTSETUP --key-file=$KEY2 --keyfile-offset 1 luksOpen $OPAL2_DEV $DEV_NAME || failscip-shell shell shell-project 0.0.0 fail(). |
| 825 | $CRYPTSETUP luksClose $DEV_NAME || failscip-shell shell shell-project 0.0.0 fail(). |
| 826 | $CRYPTSETUP luksChangeKey $OPAL2_DEV $FAST_PBKDF_OPT -d $KEY2 --keyfile-offset 1 $KEY2 --new-keyfile-offset 0 || failscip-shell shell shell-project 0.0.0 fail(). |
| 827 | $CRYPTSETUP luksOpen -d $KEY2 $OPAL2_DEV $DEV_NAME || failscip-shell shell shell-project 0.0.0 fail(). |
| 828 | $CRYPTSETUP luksClose $DEV_NAME || failscip-shell shell shell-project 0.0.0 fail(). |
| 829 | |
| 830 | preparescip-shell shell shell-project 0.0.0 prepare(). "[22] Suspend/Resume" wipe |
| 831 | # OPAL+dm-crypt |
| 832 | echoscip-shell system . . echo. -e "$PWD1\n$OPAL2_ADMIN_PIN" | $CRYPTSETUP -q luksFormat $FAST_PBKDF_OPT --type luks2 --hw-opal $OPAL2_DEV || failscip-shell shell shell-project 0.0.0 fail(). |
| 833 | echoscip-shell system . . echo. $PWD1 | $CRYPTSETUP -q luksOpen $OPAL2_DEV $DEV_NAME || failscip-shell shell shell-project 0.0.0 fail(). |
| 834 | $CRYPTSETUP luksSuspend $DEV_NAME || failscip-shell shell shell-project 0.0.0 fail(). |
| 835 | $CRYPTSETUP -q status $DEV_NAME | grepscip-shell system . . grep. -q "(suspended)" || failscip-shell shell shell-project 0.0.0 fail(). |
| 836 | ddscip-shell system . . dd. if=$OPAL2_DEV of=/dev/zeroscip-shell filesystem . . `/dev/zero`. bs=1M skip=16 count=1 iflag=direct >/dev/nullscip-shell filesystem . . `/dev/null`. 2>&1 && failscip-shell shell shell-project 0.0.0 fail(). |
| 837 | $CRYPTSETUP -q resize $DEV_NAME 2>/dev/nullscip-shell filesystem . . `/dev/null`. && failscip-shell shell shell-project 0.0.0 fail(). |
| 838 | echoscip-shell system . . echo. $PWDW | $CRYPTSETUP luksResume $DEV_NAME 2>/dev/nullscip-shell filesystem . . `/dev/null`. && failscip-shell shell shell-project 0.0.0 fail(). |
| 839 | [scip-shell system . . `[`. $? -ne 2 ] && failscip-shell shell shell-project 0.0.0 fail(). "luksResume should return EPERM exit code" |
| 840 | echoscip-shell system . . echo. $PWD1 | $CRYPTSETUP luksResume $DEV_NAME || failscip-shell shell shell-project 0.0.0 fail(). |
| 841 | ddscip-shell system . . dd. if=/dev/mapper/$DEV_NAME of=/dev/zeroscip-shell filesystem . . `/dev/zero`. bs=4K count=1 iflag=direct >/dev/nullscip-shell filesystem . . `/dev/null`. 2>&1 || failscip-shell shell shell-project 0.0.0 fail(). |
| 842 | $CRYPTSETUP -q luksClose $DEV_NAME || failscip-shell shell shell-project 0.0.0 fail(). |
| 843 | echoscip-shell system . . echo. -e "$PWD1\n$OPAL2_ADMIN_PIN" | $CRYPTSETUP -q luksFormat -c null $FAST_PBKDF_OPT --type luks2 --hw-opal $OPAL2_DEV || failscip-shell shell shell-project 0.0.0 fail(). |
| 844 | echoscip-shell system . . echo. $PWD1 | $CRYPTSETUP -q luksOpen $OPAL2_DEV $DEV_NAME || failscip-shell shell shell-project 0.0.0 fail(). |
| 845 | $CRYPTSETUP luksSuspend $DEV_NAME || failscip-shell shell shell-project 0.0.0 fail(). |
| 846 | $CRYPTSETUP -q status $DEV_NAME | grepscip-shell system . . grep. -q "(suspended)" || failscip-shell shell shell-project 0.0.0 fail(). |
| 847 | ddscip-shell system . . dd. if=$OPAL2_DEV of=/dev/zeroscip-shell filesystem . . `/dev/zero`. bs=1M skip=16 count=1 iflag=direct >/dev/nullscip-shell filesystem . . `/dev/null`. 2>&1 && failscip-shell shell shell-project 0.0.0 fail(). |
| 848 | echoscip-shell system . . echo. $PWD1 | $CRYPTSETUP luksResume $DEV_NAME || failscip-shell shell shell-project 0.0.0 fail(). |
| 849 | ddscip-shell system . . dd. if=/dev/mapper/$DEV_NAME of=/dev/zeroscip-shell filesystem . . `/dev/zero`. bs=4K count=1 iflag=direct >/dev/nullscip-shell filesystem . . `/dev/null`. 2>&1 || failscip-shell shell shell-project 0.0.0 fail(). |
| 850 | $CRYPTSETUP -q luksClose $DEV_NAME || failscip-shell shell shell-project 0.0.0 fail(). |
| 851 | |
| 852 | # OPAL only |
| 853 | echoscip-shell system . . echo. -e "$PWD1\n$OPAL2_ADMIN_PIN" | $CRYPTSETUP -q luksFormat $FAST_PBKDF_OPT --type luks2 --hw-opal-only $OPAL2_DEV || failscip-shell shell shell-project 0.0.0 fail(). |
| 854 | echoscip-shell system . . echo. $PWD1 | $CRYPTSETUP -q luksOpen $OPAL2_DEV $DEV_NAME || failscip-shell shell shell-project 0.0.0 fail(). |
| 855 | $CRYPTSETUP luksSuspend $DEV_NAME || failscip-shell shell shell-project 0.0.0 fail(). |
| 856 | $CRYPTSETUP -q status $DEV_NAME | grepscip-shell system . . grep. -q "(suspended)" || failscip-shell shell shell-project 0.0.0 fail(). |
| 857 | ddscip-shell system . . dd. if=$OPAL2_DEV of=/dev/zeroscip-shell filesystem . . `/dev/zero`. bs=1M skip=16 count=1 iflag=direct >/dev/nullscip-shell filesystem . . `/dev/null`. 2>&1 && failscip-shell shell shell-project 0.0.0 fail(). |
| 858 | $CRYPTSETUP -q resize $DEV_NAME 2>/dev/nullscip-shell filesystem . . `/dev/null`. && failscip-shell shell shell-project 0.0.0 fail(). |
| 859 | echoscip-shell system . . echo. $PWDW | $CRYPTSETUP luksResume $DEV_NAME 2>/dev/nullscip-shell filesystem . . `/dev/null`. && failscip-shell shell shell-project 0.0.0 fail(). |
| 860 | [scip-shell system . . `[`. $? -ne 2 ] && failscip-shell shell shell-project 0.0.0 fail(). "luksResume should return EPERM exit code" |
| 861 | echoscip-shell system . . echo. $PWD1 | $CRYPTSETUP luksResume $DEV_NAME || failscip-shell shell shell-project 0.0.0 fail(). |
| 862 | ddscip-shell system . . dd. if=/dev/mapper/$DEV_NAME of=/dev/zeroscip-shell filesystem . . `/dev/zero`. bs=4K count=1 iflag=direct >/dev/nullscip-shell filesystem . . `/dev/null`. 2>&1 || failscip-shell shell shell-project 0.0.0 fail(). |
| 863 | $CRYPTSETUP -q luksClose $DEV_NAME || failscip-shell shell shell-project 0.0.0 fail(). |
| 864 | |
| 865 | preparescip-shell shell shell-project 0.0.0 prepare(). "[23] luksOpen/Resume with specified key slot number" wipe |
| 866 | # first, let's try passphrase option |
| 867 | echoscip-shell system . . echo. -e "$PWD3\n$OPAL2_ADMIN_PIN" | $CRYPTSETUP -q luksFormat $FAST_PBKDF_OPT -S 5 --type luks2 --hw-opal $OPAL2_DEV || failscip-shell shell shell-project 0.0.0 fail(). |
| 868 | echoscip-shell system . . echo. $PWD3 | $CRYPTSETUP luksOpen -S 4 $OPAL2_DEV $DEV_NAME 2>/dev/nullscip-shell filesystem . . `/dev/null`. && failscip-shell shell shell-project 0.0.0 fail(). |
| 869 | [scip-shell system . . `[`. -b /dev/mapper/$DEV_NAME ] && failscip-shell shell shell-project 0.0.0 fail(). |
| 870 | echoscip-shell system . . echo. $PWD3 | $CRYPTSETUP luksOpen -S 5 $OPAL2_DEV $DEV_NAME || failscip-shell shell shell-project 0.0.0 fail(). |
| 871 | check_existsscip-shell shell shell-project 0.0.0 check_exists(). |
| 872 | $CRYPTSETUP luksSuspend $DEV_NAME || failscip-shell shell shell-project 0.0.0 fail(). |
| 873 | echoscip-shell system . . echo. $PWD3 | $CRYPTSETUP luksResume -S 4 $DEV_NAME 2>/dev/nullscip-shell filesystem . . `/dev/null`. && failscip-shell shell shell-project 0.0.0 fail(). |
| 874 | $CRYPTSETUP -q status $DEV_NAME | grepscip-shell system . . grep. -q "(suspended)" || failscip-shell shell shell-project 0.0.0 fail(). |
| 875 | ddscip-shell system . . dd. if=$OPAL2_DEV of=/dev/zeroscip-shell filesystem . . `/dev/zero`. bs=1M skip=16 count=1 iflag=direct >/dev/nullscip-shell filesystem . . `/dev/null`. 2>&1 && failscip-shell shell shell-project 0.0.0 fail(). |
| 876 | echoscip-shell system . . echo. $PWD3 | $CRYPTSETUP luksResume -S 5 $DEV_NAME || failscip-shell shell shell-project 0.0.0 fail(). |
| 877 | ddscip-shell system . . dd. if=/dev/mapper/$DEV_NAME of=/dev/zeroscip-shell filesystem . . `/dev/zero`. bs=4K count=1 iflag=direct >/dev/nullscip-shell filesystem . . `/dev/null`. 2>&1 || failscip-shell shell shell-project 0.0.0 fail(). |
| 878 | $CRYPTSETUP luksClose $DEV_NAME || failscip-shell shell shell-project 0.0.0 fail(). |
| 879 | echoscip-shell system . . echo. -e "$PWD3\n$PWD1" | $CRYPTSETUP luksAddKey -q $FAST_PBKDF_OPT -S 0 $OPAL2_DEV || failscip-shell shell shell-project 0.0.0 fail(). |
| 880 | echoscip-shell system . . echo. $PWD3 | $CRYPTSETUP luksOpen -S 0 $OPAL2_DEV $DEV_NAME 2>/dev/nullscip-shell filesystem . . `/dev/null`. && failscip-shell shell shell-project 0.0.0 fail(). |
| 881 | [scip-shell system . . `[`. -b /dev/mapper/$DEV_NAME ] && failscip-shell shell shell-project 0.0.0 fail(). |
| 882 | echoscip-shell system . . echo. $PWD1 | $CRYPTSETUP luksOpen -S 5 $OPAL2_DEV $DEV_NAME 2>/dev/nullscip-shell filesystem . . `/dev/null`. && failscip-shell shell shell-project 0.0.0 fail(). |
| 883 | [scip-shell system . . `[`. -b /dev/mapper/$DEV_NAME ] && failscip-shell shell shell-project 0.0.0 fail(). |
| 884 | # second, try it with keyfiles |
| 885 | echoscip-shell system . . echo. -e "$PWD1\n$OPAL2_ADMIN_PIN" | $CRYPTSETUP luksFormat -q -S 5 $FAST_PBKDF_OPT --type luks2 --hw-opal $OPAL2_DEV || failscip-shell shell shell-project 0.0.0 fail(). |
| 886 | echoscip-shell system . . echo. "$PWD1" | $CRYPTSETUP luksChangeKey -q -S 5 $FAST_PBKDF_OPT $OPAL2_DEV $KEY5 || failscip-shell shell shell-project 0.0.0 fail(). |
| 887 | $CRYPTSETUP luksAddKey -q $FAST_PBKDF_OPT -S 1 -d $KEY5 $OPAL2_DEV $KEY1 || failscip-shell shell shell-project 0.0.0 fail(). |
| 888 | $CRYPTSETUP luksOpen -S 5 -d $KEY5 $OPAL2_DEV $DEV_NAME || failscip-shell shell shell-project 0.0.0 fail(). |
| 889 | check_existsscip-shell shell shell-project 0.0.0 check_exists(). |
| 890 | $CRYPTSETUP luksSuspend $DEV_NAME || failscip-shell shell shell-project 0.0.0 fail(). |
| 891 | ddscip-shell system . . dd. if=$OPAL2_DEV of=/dev/zeroscip-shell filesystem . . `/dev/zero`. bs=1M skip=16 count=1 iflag=direct >/dev/nullscip-shell filesystem . . `/dev/null`. 2>&1 && failscip-shell shell shell-project 0.0.0 fail(). |
| 892 | $CRYPTSETUP luksResume -S 1 -d $KEY5 $DEV_NAME 2>/dev/nullscip-shell filesystem . . `/dev/null`. && failscip-shell shell shell-project 0.0.0 fail(). |
| 893 | $CRYPTSETUP -q status $DEV_NAME | grepscip-shell system . . grep. -q "(suspended)" || failscip-shell shell shell-project 0.0.0 fail(). |
| 894 | $CRYPTSETUP luksResume -S 5 -d $KEY5 $DEV_NAME || failscip-shell shell shell-project 0.0.0 fail(). |
| 895 | ddscip-shell system . . dd. if=/dev/mapper/$DEV_NAME of=/dev/zeroscip-shell filesystem . . `/dev/zero`. bs=4K count=1 iflag=direct >/dev/nullscip-shell filesystem . . `/dev/null`. 2>&1 || failscip-shell shell shell-project 0.0.0 fail(). |
| 896 | $CRYPTSETUP luksClose $DEV_NAME || failscip-shell shell shell-project 0.0.0 fail(). |
| 897 | $CRYPTSETUP luksOpen -S 1 -d $KEY5 $OPAL2_DEV $DEV_NAME 2>/dev/nullscip-shell filesystem . . `/dev/null`. && failscip-shell shell shell-project 0.0.0 fail(). |
| 898 | [scip-shell system . . `[`. -b /dev/mapper/$DEV_NAME ] && failscip-shell shell shell-project 0.0.0 fail(). |
| 899 | $CRYPTSETUP luksOpen -S 5 -d $KEY1 $OPAL2_DEV $DEV_NAME 2>/dev/nullscip-shell filesystem . . `/dev/null`. && failscip-shell shell shell-project 0.0.0 fail(). |
| 900 | [scip-shell system . . `[`. -b /dev/mapper/$DEV_NAME ] && failscip-shell shell shell-project 0.0.0 fail(). |
| 901 | |
| 902 | preparescip-shell shell shell-project 0.0.0 prepare(). "[24] Detached LUKS header" wipe |
| 903 | echoscip-shell system . . echo. -e "$PWD1\n$OPAL2_ADMIN_PIN" | $CRYPTSETUP luksFormat $FAST_PBKDF_OPT --type luks2 --hw-opal $OPAL2_DEV --header $HEADER_IMG || failscip-shell shell shell-project 0.0.0 fail(). |
| 904 | echoscip-shell system . . echo. -e "$PWD1\n$OPAL2_ADMIN_PIN" | $CRYPTSETUP luksFormat $FAST_PBKDF_OPT --type luks2 --hw-opal $OPAL2_DEV --header $HEADER_IMG --align-payload 1 >/dev/nullscip-shell filesystem . . `/dev/null`. 2>&1 && failscip-shell shell shell-project 0.0.0 fail(). |
| 905 | echoscip-shell system . . echo. -e "$PWD1\n$OPAL2_ADMIN_PIN" | $CRYPTSETUP -q luksFormat $FAST_PBKDF_OPT --type luks2 --hw-opal $OPAL2_DEV --header $HEADER_IMG --align-payload 8192 || failscip-shell shell shell-project 0.0.0 fail(). |
| 906 | echoscip-shell system . . echo. -e "$PWD1\n$OPAL2_ADMIN_PIN" | $CRYPTSETUP -q luksFormat $FAST_PBKDF_OPT --type luks2 --hw-opal $OPAL2_DEV --header $HEADER_IMG --align-payload 4096 >/dev/nullscip-shell filesystem . . `/dev/null`. || failscip-shell shell shell-project 0.0.0 fail(). |
| 907 | $CRYPTSETUP luksDump $HEADER_IMG | grepscip-shell system . . grep. -e "0: hw-opal-crypt" -A1 | grepscip-shell system . . grep. -qe $((4096*512)) || failscip-shell shell shell-project 0.0.0 fail(). |
| 908 | echoscip-shell system . . echo. -e "$PWD1\n$OPAL2_ADMIN_PIN" | $CRYPTSETUP -q luksFormat $FAST_PBKDF_OPT --type luks2 --hw-opal $OPAL2_DEV --header $HEADER_IMG --align-payload 0 --sector-size 512 || failscip-shell shell shell-project 0.0.0 fail(). |
| 909 | echoscip-shell system . . echo. $PWD1 | $CRYPTSETUP luksOpen $OPAL2_DEV-missing --header $HEADER_IMG $DEV_NAME 2>/dev/nullscip-shell filesystem . . `/dev/null`. && failscip-shell shell shell-project 0.0.0 fail(). |
| 910 | echoscip-shell system . . echo. $PWD1 | $CRYPTSETUP luksOpen $OPAL2_DEV --header $HEADER_IMG $DEV_NAME || failscip-shell shell shell-project 0.0.0 fail(). |
| 911 | $CRYPTSETUP -q status $DEV_NAME | grepscip-shell system . . grep. "type:" | grepscip-shell system . . grep. -q "n/a" || failscip-shell shell shell-project 0.0.0 fail(). |
| 912 | $CRYPTSETUP luksSuspend $DEV_NAME --header $HEADER_IMG || failscip-shell shell shell-project 0.0.0 fail(). |
| 913 | ddscip-shell system . . dd. if=$OPAL2_DEV of=/dev/zeroscip-shell filesystem . . `/dev/zero`. bs=4K count=1 iflag=direct >/dev/nullscip-shell filesystem . . `/dev/null`. 2>&1 && failscip-shell shell shell-project 0.0.0 fail(). |
| 914 | echoscip-shell system . . echo. $PWD1 | $CRYPTSETUP luksResume $DEV_NAME --header $HEADER_IMG || failscip-shell shell shell-project 0.0.0 fail(). |
| 915 | ddscip-shell system . . dd. if=/dev/mapper/$DEV_NAME of=/dev/zeroscip-shell filesystem . . `/dev/zero`. bs=4K count=1 iflag=direct >/dev/nullscip-shell filesystem . . `/dev/null`. 2>&1 || failscip-shell shell shell-project 0.0.0 fail(). |
| 916 | $CRYPTSETUP luksSuspend $DEV_NAME || failscip-shell shell shell-project 0.0.0 fail(). |
| 917 | ddscip-shell system . . dd. if=$OPAL2_DEV of=/dev/zeroscip-shell filesystem . . `/dev/zero`. bs=4K count=1 iflag=direct >/dev/nullscip-shell filesystem . . `/dev/null`. 2>&1 && failscip-shell shell shell-project 0.0.0 fail(). |
| 918 | echoscip-shell system . . echo. $PWD1 | $CRYPTSETUP luksResume $DEV_NAME 2>/dev/nullscip-shell filesystem . . `/dev/null`. && failscip-shell shell shell-project 0.0.0 fail(). |
| 919 | echoscip-shell system . . echo. $PWD1 | $CRYPTSETUP luksResume $DEV_NAME --header $HEADER_IMG || failscip-shell shell shell-project 0.0.0 fail(). |
| 920 | ddscip-shell system . . dd. if=/dev/mapper/$DEV_NAME of=/dev/zeroscip-shell filesystem . . `/dev/zero`. bs=4K count=1 iflag=direct >/dev/nullscip-shell filesystem . . `/dev/null`. 2>&1 || failscip-shell shell shell-project 0.0.0 fail(). |
| 921 | $CRYPTSETUP luksClose $DEV_NAME || failscip-shell shell shell-project 0.0.0 fail(). |
| 922 | echoscip-shell system . . echo. $PWD1 | $CRYPTSETUP luksAddKey -q $FAST_PBKDF_OPT -S 5 _fakedev_ --header $HEADER_IMG $KEY5 || failscip-shell shell shell-project 0.0.0 fail(). |
| 923 | $CRYPTSETUP luksDump _fakedev_ --header $HEADER_IMG | grepscip-shell system . . grep. -q "5: luks2" || failscip-shell shell shell-project 0.0.0 fail(). |
| 924 | $CRYPTSETUP luksKillSlot -q _fakedev_ --header $HEADER_IMG 5 || failscip-shell shell shell-project 0.0.0 fail(). |
| 925 | $CRYPTSETUP luksDump _fakedev_ --header $HEADER_IMG | grepscip-shell system . . grep. -q "5: luks2" && failscip-shell shell shell-project 0.0.0 fail(). |
| 926 | echoscip-shell system . . echo. $PWD1 | $CRYPTSETUP open --test-passphrase $HEADER_IMG || failscip-shell shell shell-project 0.0.0 fail(). |
| 927 | rmscip-shell system . . rm. $HEADER_IMG || failscip-shell shell shell-project 0.0.0 fail(). |
| 928 | # create exactly 16 MiBs LUKS2 header |
| 929 | echoscip-shell system . . echo. -e "$PWD1\n$OPAL2_ADMIN_PIN" | $CRYPTSETUP -q luksFormat $FAST_PBKDF_OPT --type luks2 --hw-opal $OPAL2_DEV --header $HEADER_IMG --luks2-keyslots-size 16352k --luks2-metadata-size 16k --offset 131072 >/dev/nullscip-shell filesystem . . `/dev/null`. || failscip-shell shell shell-project 0.0.0 fail(). |
| 930 | SIZE=$(statscip-shell system . . stat. --printf=%s $HEADER_IMG) |
| 931 | testscip-shell system . . test. $SIZE -eq 16777216 || failscip-shell shell shell-project 0.0.0 fail(). |
| 932 | $CRYPTSETUP -q luksDump $HEADER_IMG | grepscip-shell system . . grep. -q "offset: $((512 * 131072)) \[bytes\]" || failscip-shell shell shell-project 0.0.0 fail(). |
| 933 | |
| 934 | preparescip-shell shell shell-project 0.0.0 prepare(). "[25] LUKS erase" wipe |
| 935 | echoscip-shell system . . echo. -e "$PWD1\n$OPAL2_ADMIN_PIN" | $CRYPTSETUP -q luksFormat $FAST_PBKDF_OPT --type luks2 --hw-opal $OPAL2_DEV || failscip-shell shell shell-project 0.0.0 fail(). |
| 936 | echoscip-shell system . . echo. $OPAL2_ADMIN_PIN | $CRYPTSETUP luksErase -q $OPAL2_DEV || failscip-shell shell shell-project 0.0.0 fail(). |
| 937 | $CRYPTSETUP isLuks -q $OPAL2_DEV && failscip-shell shell shell-project 0.0.0 fail(). |
| 938 | echoscip-shell system . . echo. -e "$PWD1\n$OPAL2_ADMIN_PIN" | $CRYPTSETUP -q luksFormat $FAST_PBKDF_OPT --type luks2 --hw-opal-only $OPAL2_DEV || failscip-shell shell shell-project 0.0.0 fail(). |
| 939 | echoscip-shell system . . echo. $OPAL2_ADMIN_PIN | $CRYPTSETUP luksErase -q $OPAL2_DEV || failscip-shell shell shell-project 0.0.0 fail(). |
| 940 | $CRYPTSETUP isLuks -q $OPAL2_DEV && failscip-shell shell shell-project 0.0.0 fail(). |
| 941 | echoscip-shell system . . echo. -e "$PWD1\n$OPAL2_ADMIN_PIN" | $CRYPTSETUP -q luksFormat $FAST_PBKDF_OPT --type luks2 --hw-opal $OPAL2_DEV || failscip-shell shell shell-project 0.0.0 fail(). |
| 942 | # test psid reset once with valgrind |
| 943 | $CRYPTSETUP luksErase --hw-opal-factory-reset --key-file $OPAL2_PSID_FILE $OPAL2_DEV -q || failscip-shell shell shell-project 0.0.0 fail(). |
| 944 | |
| 945 | preparescip-shell shell shell-project 0.0.0 prepare(). "[26] LUKS convert" wipe |
| 946 | # create almost compatible LUKS2 device except OPAL segment |
| 947 | echoscip-shell system . . echo. -e "$PWD1\n$OPAL2_ADMIN_PIN" | $CRYPTSETUP -q luksFormat $FAST_PBKDF_OPT --type luks2 --sector-size 512 -s256 --hw-opal $OPAL2_DEV || failscip-shell shell shell-project 0.0.0 fail(). |
| 948 | $CRYPTSETUP -q convert --type luks1 $OPAL2_DEV >/dev/nullscip-shell filesystem . . `/dev/null`. 2>&1 && failscip-shell shell shell-project 0.0.0 fail(). |
| 949 | $CRYPTSETUP isLuks --type luks2 $OPAL2_DEV || failscip-shell shell shell-project 0.0.0 fail(). |
| 950 | echoscip-shell system . . echo. -e "$PWD1\n$OPAL2_ADMIN_PIN" | $CRYPTSETUP -q luksFormat $FAST_PBKDF_OPT --type luks2 --sector-size 512 --hw-opal-only $OPAL2_DEV || failscip-shell shell shell-project 0.0.0 fail(). |
| 951 | $CRYPTSETUP -q convert --type luks1 $OPAL2_DEV >/dev/nullscip-shell filesystem . . `/dev/null`. 2>&1 && failscip-shell shell shell-project 0.0.0 fail(). |
| 952 | $CRYPTSETUP isLuks --type luks2 $OPAL2_DEV || failscip-shell shell shell-project 0.0.0 fail(). |
| 953 | |
| 954 | if dm_crypt_keyring_supportscip-shell shell shell-project 0.0.0 dm_crypt_keyring_support(). && dm_crypt_keyring_new_kernelscip-shell shell shell-project 0.0.0 dm_crypt_keyring_new_kernel().; then |
| 955 | preparescip-shell shell shell-project 0.0.0 prepare(). "[27] LUKS2 key in keyring" wipe |
| 956 | echoscip-shell system . . echo. -e "$PWD1\n$OPAL2_ADMIN_PIN" | $CRYPTSETUP luksFormat $FAST_PBKDF_OPT --type luks2 --hw-opal $OPAL2_DEV --header $HEADER_IMG || failscip-shell shell shell-project 0.0.0 fail(). |
| 957 | |
| 958 | # check keyring support detection works as expected |
| 959 | rmmod dm-crypt >/dev/nullscip-shell filesystem . . `/dev/null`. 2>&1 || truescip-shell system . . true. |
| 960 | echoscip-shell system . . echo. $PWD1 | $CRYPTSETUP open $OPAL2_DEV --header $HEADER_IMG $DEV_NAME || failscip-shell shell shell-project 0.0.0 fail(). |
| 961 | $CRYPTSETUP -q status $DEV_NAME | grepscip-shell system . . grep. "key location:" | grepscip-shell system . . grep. -q "keyring" || failscip-shell shell shell-project 0.0.0 fail(). |
| 962 | $CRYPTSETUP close $DEV_NAME || failscip-shell shell shell-project 0.0.0 fail(). |
| 963 | |
| 964 | echoscip-shell system . . echo. $PWD1 | $CRYPTSETUP open $OPAL2_DEV --disable-keyring --header $HEADER_IMG $DEV_NAME || failscip-shell shell shell-project 0.0.0 fail(). |
| 965 | $CRYPTSETUP -q status $DEV_NAME | grepscip-shell system . . grep. "key location:" | grepscip-shell system . . grep. -q "dm-crypt" || failscip-shell shell shell-project 0.0.0 fail(). |
| 966 | $CRYPTSETUP close $DEV_NAME || failscip-shell shell shell-project 0.0.0 fail(). |
| 967 | |
| 968 | echoscip-shell system . . echo. $PWD1 | $CRYPTSETUP open $OPAL2_DEV --disable-keyring --header $HEADER_IMG $DEV_NAME || failscip-shell shell shell-project 0.0.0 fail(). |
| 969 | $CRYPTSETUP luksSuspend $DEV_NAME || failscip-shell shell shell-project 0.0.0 fail(). |
| 970 | echoscip-shell system . . echo. $PWD1 | $CRYPTSETUP luksResume $DEV_NAME --header $HEADER_IMG || failscip-shell shell shell-project 0.0.0 fail(). |
| 971 | $CRYPTSETUP -q status $DEV_NAME | grepscip-shell system . . grep. "key location:" | grepscip-shell system . . grep. -q "keyring" || failscip-shell shell shell-project 0.0.0 fail(). |
| 972 | $CRYPTSETUP close $DEV_NAME || failscip-shell shell shell-project 0.0.0 fail(). |
| 973 | |
| 974 | echoscip-shell system . . echo. $PWD1 | $CRYPTSETUP open $OPAL2_DEV --header $HEADER_IMG $DEV_NAME || failscip-shell shell shell-project 0.0.0 fail(). |
| 975 | $CRYPTSETUP luksSuspend $DEV_NAME || failscip-shell shell shell-project 0.0.0 fail(). |
| 976 | echoscip-shell system . . echo. $PWD1 | $CRYPTSETUP luksResume --disable-keyring $DEV_NAME --header $HEADER_IMG || failscip-shell shell shell-project 0.0.0 fail(). |
| 977 | $CRYPTSETUP -q status $DEV_NAME | grepscip-shell system . . grep. "key location:" | grepscip-shell system . . grep. -q "dm-crypt" || failscip-shell shell shell-project 0.0.0 fail(). |
| 978 | $CRYPTSETUP close $DEV_NAME || failscip-shell shell shell-project 0.0.0 fail(). |
| 979 | fi |
| 980 | |
| 981 | preparescip-shell shell shell-project 0.0.0 prepare(). "[28] tokens" wipe |
| 982 | if [scip-shell system . . `[`. $HAVE_KEYRING -gt 0 -a -d /proc/sys/kernel/keysscip-shell filesystem . . `/proc/sys/kernel/keys`. ]; then |
| 983 | test_and_prepare_keyringscip-shell shell shell-project 0.0.0 test_and_prepare_keyring(). |
| 984 | echoscip-shell system . . echo. -e "$PWD1\n$OPAL2_ADMIN_PIN" | $CRYPTSETUP luksFormat $FAST_PBKDF_OPT --type luks2 --hw-opal $OPAL2_DEV -q || failscip-shell shell shell-project 0.0.0 fail(). |
| 985 | run_token_testsscip-shell shell shell-project 0.0.0 run_token_tests(). |
| 986 | keyctl unlink "%user:$TEST_TOKEN0" $TEST_KEYRING || failscip-shell shell shell-project 0.0.0 fail(). |
| 987 | |
| 988 | echoscip-shell system . . echo. -e "$PWD1\n$OPAL2_ADMIN_PIN" | $CRYPTSETUP luksFormat $FAST_PBKDF_OPT --type luks2 --hw-opal-only $OPAL2_DEV -q || failscip-shell shell shell-project 0.0.0 fail(). |
| 989 | run_token_testsscip-shell shell shell-project 0.0.0 run_token_tests(). |
| 990 | fi |
| 991 | echoscip-shell system . . echo. -n "$IMPORT_TOKEN" | $CRYPTSETUP token import $OPAL2_DEV --token-id 10 || failscip-shell shell shell-project 0.0.0 fail(). |
| 992 | echoscip-shell system . . echo. -n "$IMPORT_TOKEN" | $CRYPTSETUP token import $OPAL2_DEV --token-id 11 --json-file - || failscip-shell shell shell-project 0.0.0 fail(). |
| 993 | echoscip-shell system . . echo. -n "$IMPORT_TOKEN" > $TOKEN_FILE0 |
| 994 | $CRYPTSETUP token import $OPAL2_DEV --token-id 12 --json-file $TOKEN_FILE0 || failscip-shell shell shell-project 0.0.0 fail(). |
| 995 | $CRYPTSETUP token import $OPAL2_DEV --token-id 12 --json-file $TOKEN_FILE0 2>/dev/nullscip-shell filesystem . . `/dev/null`. && failscip-shell shell shell-project 0.0.0 fail(). |
| 996 | $CRYPTSETUP token export $OPAL2_DEV --token-id 10 >$TOKEN_FILE1 || failscip-shell shell shell-project 0.0.0 fail(). |
| 997 | diffscip-shell system . . diff. $TOKEN_FILE0 $TOKEN_FILE1 || failscip-shell shell shell-project 0.0.0 fail(). |
| 998 | $CRYPTSETUP token export $OPAL2_DEV --token-id 11 >$TOKEN_FILE1 || failscip-shell shell shell-project 0.0.0 fail(). |
| 999 | diffscip-shell system . . diff. $TOKEN_FILE0 $TOKEN_FILE1 || failscip-shell shell shell-project 0.0.0 fail(). |
| 1000 | $CRYPTSETUP token export $OPAL2_DEV --token-id 12 >$TOKEN_FILE1 || failscip-shell shell shell-project 0.0.0 fail(). |
| 1001 | diffscip-shell system . . diff. $TOKEN_FILE0 $TOKEN_FILE1 || failscip-shell shell shell-project 0.0.0 fail(). |
| 1002 | $CRYPTSETUP token export $OPAL2_DEV --token-id 12 --json-file $TOKEN_FILE1 || failscip-shell shell shell-project 0.0.0 fail(). |
| 1003 | diffscip-shell system . . diff. $TOKEN_FILE0 $TOKEN_FILE1 || failscip-shell shell shell-project 0.0.0 fail(). |
| 1004 | $CRYPTSETUP token export $OPAL2_DEV --token-id 12 > $TOKEN_FILE1 || failscip-shell shell shell-project 0.0.0 fail(). |
| 1005 | diffscip-shell system . . diff. $TOKEN_FILE0 $TOKEN_FILE1 || failscip-shell shell shell-project 0.0.0 fail(). |
| 1006 | |
| 1007 | preparescip-shell shell shell-project 0.0.0 prepare(). "[29] LUKS keyslot priority" wipe |
| 1008 | echoscip-shell system . . echo. -e "$PWD1\n$OPAL2_ADMIN_PIN" | $CRYPTSETUP luksFormat $FAST_PBKDF_OPT --type luks2 --hw-opal $OPAL2_DEV -S 1 || failscip-shell shell shell-project 0.0.0 fail(). |
| 1009 | echoscip-shell system . . echo. -e "$PWD1\n$PWD2" | $CRYPTSETUP luksAddKey -q $OPAL2_DEV $FAST_PBKDF_OPT -S 5 || failscip-shell shell shell-project 0.0.0 fail(). |
| 1010 | $CRYPTSETUP config $OPAL2_DEV -S 0 --priority prefer && failscip-shell shell shell-project 0.0.0 fail(). |
| 1011 | $CRYPTSETUP config $OPAL2_DEV -S 1 --priority bla >/dev/nullscip-shell filesystem . . `/dev/null`. 2>&1 && failscip-shell shell shell-project 0.0.0 fail(). |
| 1012 | $CRYPTSETUP config $OPAL2_DEV -S 1 --priority ignore || failscip-shell shell shell-project 0.0.0 fail(). |
| 1013 | echoscip-shell system . . echo. $PWD1 | $CRYPTSETUP open $OPAL2_DEV --test-passphrase 2>/dev/nullscip-shell filesystem . . `/dev/null`. && failscip-shell shell shell-project 0.0.0 fail(). |
| 1014 | echoscip-shell system . . echo. $PWD1 | $CRYPTSETUP open $OPAL2_DEV --test-passphrase -S 1 || failscip-shell shell shell-project 0.0.0 fail(). |
| 1015 | echoscip-shell system . . echo. $PWD2 | $CRYPTSETUP open $OPAL2_DEV --test-passphrase || failscip-shell shell shell-project 0.0.0 fail(). |
| 1016 | $CRYPTSETUP config $OPAL2_DEV -S 1 --priority normal || failscip-shell shell shell-project 0.0.0 fail(). |
| 1017 | echoscip-shell system . . echo. $PWD1 | $CRYPTSETUP open $OPAL2_DEV --test-passphrase || failscip-shell shell shell-project 0.0.0 fail(). |
| 1018 | $CRYPTSETUP config $OPAL2_DEV -S 1 --priority ignore || failscip-shell shell shell-project 0.0.0 fail(). |
| 1019 | echoscip-shell system . . echo. $PWD1 | $CRYPTSETUP open $OPAL2_DEV --test-passphrase 2>/dev/nullscip-shell filesystem . . `/dev/null`. && failscip-shell shell shell-project 0.0.0 fail(). |
| 1020 | |
| 1021 | preparescip-shell shell shell-project 0.0.0 prepare(). "[30] LUKS label and subsystem" wipe |
| 1022 | echoscip-shell system . . echo. -e "$PWD1\n$OPAL2_ADMIN_PIN" | $CRYPTSETUP luksFormat $FAST_PBKDF_OPT --type luks2 --hw-opal $OPAL2_DEV || failscip-shell shell shell-project 0.0.0 fail(). |
| 1023 | $CRYPTSETUP luksDump $OPAL2_DEV | grepscip-shell system . . grep. "Subsystem:" | grepscip-shell system . . grep. -q "HW-OPAL" || failscip-shell shell shell-project 0.0.0 fail(). |
| 1024 | $CRYPTSETUP luksDump $OPAL2_DEV | grepscip-shell system . . grep. "Label:" | grepscip-shell system . . grep. -q "(no label)" || failscip-shell shell shell-project 0.0.0 fail(). |
| 1025 | echoscip-shell system . . echo. -e "$PWD1\n$OPAL2_ADMIN_PIN" | $CRYPTSETUP -q luksFormat $FAST_PBKDF_OPT --type luks2 --hw-opal $OPAL2_DEV --subsystem SatelliteTwo --label TheLabel || failscip-shell shell shell-project 0.0.0 fail(). |
| 1026 | $CRYPTSETUP luksDump $OPAL2_DEV | grepscip-shell system . . grep. "Subsystem:" | grepscip-shell system . . grep. -q "SatelliteTwo" || failscip-shell shell shell-project 0.0.0 fail(). |
| 1027 | $CRYPTSETUP luksDump $OPAL2_DEV | grepscip-shell system . . grep. "Label:" | grepscip-shell system . . grep. -q "TheLabel" || failscip-shell shell shell-project 0.0.0 fail(). |
| 1028 | $CRYPTSETUP config $OPAL2_DEV --subsystem SatelliteThree |
| 1029 | $CRYPTSETUP luksDump $OPAL2_DEV | grepscip-shell system . . grep. "Subsystem:" | grepscip-shell system . . grep. -q "SatelliteThree" || failscip-shell shell shell-project 0.0.0 fail(). |
| 1030 | $CRYPTSETUP luksDump $OPAL2_DEV | grepscip-shell system . . grep. "Label:" | grepscip-shell system . . grep. -q "(no label)" || failscip-shell shell shell-project 0.0.0 fail(). |
| 1031 | $CRYPTSETUP config $OPAL2_DEV --subsystem SatelliteThree --label TheLabel |
| 1032 | $CRYPTSETUP luksDump $OPAL2_DEV | grepscip-shell system . . grep. "Subsystem:" | grepscip-shell system . . grep. -q "SatelliteThree" || failscip-shell shell shell-project 0.0.0 fail(). |
| 1033 | $CRYPTSETUP luksDump $OPAL2_DEV | grepscip-shell system . . grep. "Label:" | grepscip-shell system . . grep. -q "TheLabel" || failscip-shell shell shell-project 0.0.0 fail(). |
| 1034 | |
| 1035 | preparescip-shell shell shell-project 0.0.0 prepare(). "[31] LUKS PBKDF setting" wipe |
| 1036 | echoscip-shell system . . echo. -e "$PWD1\n$OPAL2_ADMIN_PIN" | $CRYPTSETUP luksFormat --type luks2 --hw-opal --pbkdf bla $OPAL2_DEV >/dev/nullscip-shell filesystem . . `/dev/null`. 2>&1 && failscip-shell shell shell-project 0.0.0 fail(). |
| 1037 | # Force setting, no benchmark. PBKDF2 has 1000 iterations as a minimum |
| 1038 | echoscip-shell system . . echo. -e "$PWD1\n$OPAL2_ADMIN_PIN" |$CRYPTSETUP luksFormat --type luks2 --hw-opal --pbkdf pbkdf2 --pbkdf-force-iterations 999 $OPAL2_DEV 2>/dev/nullscip-shell filesystem . . `/dev/null`. && failscip-shell shell shell-project 0.0.0 fail(). |
| 1039 | echoscip-shell system . . echo. -e "$PWD1\n$OPAL2_ADMIN_PIN" | $CRYPTSETUP -q luksFormat --type luks2 --hw-opal --pbkdf pbkdf2 --pbkdf-force-iterations 1234 $OPAL2_DEV || failscip-shell shell shell-project 0.0.0 fail(). |
| 1040 | $CRYPTSETUP luksDump $OPAL2_DEV | grepscip-shell system . . grep. "Iterations:" | grepscip-shell system . . grep. -q "1234" || failscip-shell shell shell-project 0.0.0 fail(). |
| 1041 | echoscip-shell system . . echo. -e "$PWD1\n$OPAL2_ADMIN_PIN" | $CRYPTSETUP -q luksFormat --type luks2 --hw-opal --pbkdf argon2id --pbkdf-force-iterations 3 $OPAL2_DEV 2>/dev/nullscip-shell filesystem . . `/dev/null`. && failscip-shell shell shell-project 0.0.0 fail(). |
| 1042 | echoscip-shell system . . echo. -e "$PWD1\n$OPAL2_ADMIN_PIN" | $CRYPTSETUP -q luksFormat --type luks2 --hw-opal --pbkdf argon2id --pbkdf-force-iterations 4 --pbkdf-memory 100000 $OPAL2_DEV || can_fail_fipsscip-shell shell shell-project 0.0.0 can_fail_fips(). |
| 1043 | $CRYPTSETUP luksDump $OPAL2_DEV | grepscip-shell system . . grep. "PBKDF:" | grepscip-shell system . . grep. -q "argon2id" || can_fail_fipsscip-shell shell shell-project 0.0.0 can_fail_fips(). |
| 1044 | echoscip-shell system . . echo. -e "$PWD1\n$OPAL2_ADMIN_PIN" | $CRYPTSETUP -q luksFormat --type luks2 --hw-opal --pbkdf argon2i --pbkdf-force-iterations 4 \ |
| 1045 | --pbkdf-memory 1234 --pbkdf-parallel 1 $OPAL2_DEV || can_fail_fipsscip-shell shell shell-project 0.0.0 can_fail_fips(). |
| 1046 | $CRYPTSETUP luksDump $OPAL2_DEV | grepscip-shell system . . grep. "PBKDF:" | grepscip-shell system . . grep. -q "argon2i" || can_fail_fipsscip-shell shell shell-project 0.0.0 can_fail_fips(). |
| 1047 | $CRYPTSETUP luksDump $OPAL2_DEV | grepscip-shell system . . grep. "Time cost:" | grepscip-shell system . . grep. -q "4" || can_fail_fipsscip-shell shell shell-project 0.0.0 can_fail_fips(). |
| 1048 | $CRYPTSETUP luksDump $OPAL2_DEV | grepscip-shell system . . grep. "Memory:" | grepscip-shell system . . grep. -q "1234" || can_fail_fipsscip-shell shell shell-project 0.0.0 can_fail_fips(). |
| 1049 | $CRYPTSETUP luksDump $OPAL2_DEV | grepscip-shell system . . grep. "Threads:" | grepscip-shell system . . grep. -q "1" || can_fail_fipsscip-shell shell shell-project 0.0.0 can_fail_fips(). |
| 1050 | # Benchmark |
| 1051 | echoscip-shell system . . echo. -e "$PWD1\n$OPAL2_ADMIN_PIN" | $CRYPTSETUP -q luksFormat --type luks2 --hw-opal --pbkdf argon2i -i 500 --pbkdf-memory 1234 --pbkdf-parallel 1 $OPAL2_DEV || can_fail_fipsscip-shell shell shell-project 0.0.0 can_fail_fips(). |
| 1052 | [scip-shell system . . `[`. 0"$($CRYPTSETUP luksDump $OPAL2_DEV | grepscip-shell system . . grep. "Time cost:" | cutscip-shell system . . cut. -d: -f 2 | sedscip-shell system . . sed. -e 's/\ //g')" -gt 0 ] || can_fail_fipsscip-shell shell shell-project 0.0.0 can_fail_fips(). |
| 1053 | [scip-shell system . . `[`. 0"$($CRYPTSETUP luksDump $OPAL2_DEV | grepscip-shell system . . grep. "Memory:" | cutscip-shell system . . cut. -d: -f 2 | sedscip-shell system . . sed. -e 's/\ //g')" -gt 0 ] || can_fail_fipsscip-shell shell shell-project 0.0.0 can_fail_fips(). |
| 1054 | echoscip-shell system . . echo. -e "$PWD1\n$OPAL2_ADMIN_PIN" | $CRYPTSETUP -q luksFormat --type luks2 --hw-opal --pbkdf pbkdf2 -i 500 $OPAL2_DEV || failscip-shell shell shell-project 0.0.0 fail(). |
| 1055 | [scip-shell system . . `[`. 0"$($CRYPTSETUP luksDump $OPAL2_DEV | grepscip-shell system . . grep. -m1 "Iterations:" | cutscip-shell system . . cut. -d' ' -f 2 | sedscip-shell system . . sed. -e 's/\ //g')" -gt 1000 ] || failscip-shell shell shell-project 0.0.0 fail(). |
| 1056 | |
| 1057 | preparescip-shell shell shell-project 0.0.0 prepare(). "[32] LUKS Keyslot convert" wipe |
| 1058 | echoscip-shell system . . echo. -e "$PWD1\n$OPAL2_ADMIN_PIN" | $CRYPTSETUP -q luksFormat $FAST_PBKDF_OPT --type luks2 --hw-opal $OPAL2_DEV --key-slot 0 || failscip-shell shell shell-project 0.0.0 fail(). |
| 1059 | echoscip-shell system . . echo. "$PWD1" | $CRYPTSETUP luksAddKey -q $FAST_PBKDF_OPT -S0 --new-key-slot 5 $OPAL2_DEV $KEY5 || failscip-shell shell shell-project 0.0.0 fail(). |
| 1060 | $CRYPTSETUP -q luksKillSlot $OPAL2_DEV 0 || failscip-shell shell shell-project 0.0.0 fail(). |
| 1061 | $CRYPTSETUP luksDump $OPAL2_DEV | grepscip-shell system . . grep. -q "5: luks2" || failscip-shell shell shell-project 0.0.0 fail(). |
| 1062 | $CRYPTSETUP luksDump $OPAL2_DEV | grepscip-shell system . . grep. "PBKDF:" | grepscip-shell system . . grep. -q "pbkdf2" || failscip-shell shell shell-project 0.0.0 fail(). |
| 1063 | $CRYPTSETUP -q luksConvertKey $OPAL2_DEV -S 5 --key-file $KEY5 --pbkdf argon2i -i1 --pbkdf-memory 32 || can_fail_fipsscip-shell shell shell-project 0.0.0 can_fail_fips(). |
| 1064 | $CRYPTSETUP luksDump $OPAL2_DEV | grepscip-shell system . . grep. -q "5: luks2" || can_fail_fipsscip-shell shell shell-project 0.0.0 can_fail_fips(). |
| 1065 | echoscip-shell system . . echo. $PWD1 | $CRYPTSETUP luksAddKey -q $FAST_PBKDF_OPT $OPAL2_DEV -S 1 --key-file $KEY5 || failscip-shell shell shell-project 0.0.0 fail(). |
| 1066 | $CRYPTSETUP -q luksKillSlot $OPAL2_DEV 5 || failscip-shell shell shell-project 0.0.0 fail(). |
| 1067 | $CRYPTSETUP luksDump $OPAL2_DEV | grepscip-shell system . . grep. -q "1: luks2" || failscip-shell shell shell-project 0.0.0 fail(). |
| 1068 | $CRYPTSETUP luksDump $OPAL2_DEV | grepscip-shell system . . grep. "PBKDF:" | grepscip-shell system . . grep. -q "pbkdf2" || failscip-shell shell shell-project 0.0.0 fail(). |
| 1069 | echoscip-shell system . . echo. $PWD1 | $CRYPTSETUP -q luksConvertKey $OPAL2_DEV -S 1 --pbkdf argon2i -i1 --pbkdf-memory 32 || can_fail_fipsscip-shell shell shell-project 0.0.0 can_fail_fips(). |
| 1070 | $CRYPTSETUP luksDump $OPAL2_DEV | grepscip-shell system . . grep. -q "1: luks2" || can_fail_fipsscip-shell shell shell-project 0.0.0 can_fail_fips(). |
| 1071 | echoscip-shell system . . echo. $PWD3 | $CRYPTSETUP luksAddKey -q $FAST_PBKDF_OPT -S 21 --unbound -s 72 $OPAL2_DEV || failscip-shell shell shell-project 0.0.0 fail(). |
| 1072 | echoscip-shell system . . echo. $PWD3 | $CRYPTSETUP luksConvertKey --pbkdf-force-iterations 1001 --pbkdf pbkdf2 -S 21 $OPAL2_DEV || failscip-shell shell shell-project 0.0.0 fail(). |
| 1073 | |
| 1074 | preparescip-shell shell shell-project 0.0.0 prepare(). "[33] luksAddKey unbound tests" wipe |
| 1075 | echoscip-shell system . . echo. -e "$PWD1\n$OPAL2_ADMIN_PIN" | $CRYPTSETUP -q luksFormat $FAST_PBKDF_OPT --type luks2 --hw-opal $OPAL2_DEV --key-slot 5 || failscip-shell shell shell-project 0.0.0 fail(). |
| 1076 | # unbound key may have arbitrary size |
| 1077 | echoscip-shell system . . echo. $PWD1 | $CRYPTSETUP luksChangeKey -q $OPAL2_DEV $FAST_PBKDF_OPT -S5 $KEY5 || failscip-shell shell shell-project 0.0.0 fail(). |
| 1078 | echoscip-shell system . . echo. $PWD1 | $CRYPTSETUP luksAddKey $FAST_PBKDF_OPT --unbound -s 72 $OPAL2_DEV || failscip-shell shell shell-project 0.0.0 fail(). |
| 1079 | echoscip-shell system . . echo. $PWD2 | $CRYPTSETUP luksAddKey -q $FAST_PBKDF_OPT --unbound -s 72 -S 2 $OPAL2_DEV || failscip-shell shell shell-project 0.0.0 fail(). |
| 1080 | $CRYPTSETUP luksDump $OPAL2_DEV | grepscip-shell system . . grep. -q "2: luks2 (unbound)" || failscip-shell shell shell-project 0.0.0 fail(). |
| 1081 | ddscip-shell system . . dd. if=/dev/urandomscip-shell filesystem . . `/dev/urandom`. of=$KEY_FILE0 bs=64 count=1 > /dev/nullscip-shell filesystem . . `/dev/null`. 2>&1 || failscip-shell shell shell-project 0.0.0 fail(). |
| 1082 | echoscip-shell system . . echo. $PWD3 | $CRYPTSETUP luksAddKey -q $FAST_PBKDF_OPT --unbound -s 512 -S 3 --volume-key-file $KEY_FILE0 $OPAL2_DEV || failscip-shell shell shell-project 0.0.0 fail(). |
| 1083 | $CRYPTSETUP luksDump $OPAL2_DEV | grepscip-shell system . . grep. -q "3: luks2 (unbound)" || failscip-shell shell shell-project 0.0.0 fail(). |
| 1084 | # unbound key size is required |
| 1085 | echoscip-shell system . . echo. $PWD1 | $CRYPTSETUP -q luksAddKey --unbound $OPAL2_DEV 2>/dev/nullscip-shell filesystem . . `/dev/null`. && failscip-shell shell shell-project 0.0.0 fail(). |
| 1086 | echoscip-shell system . . echo. $PWD3 | $CRYPTSETUP -q luksAddKey --unbound --volume-key-file /dev/urandomscip-shell filesystem . . `/dev/urandom`. $OPAL2_DEV 2> /dev/nullscip-shell filesystem . . `/dev/null`. && failscip-shell shell shell-project 0.0.0 fail(). |
| 1087 | # do not allow one to replace keyslot by unbound slot |
| 1088 | echoscip-shell system . . echo. $PWD1 | $CRYPTSETUP -q luksAddKey -S5 --unbound -s 32 $OPAL2_DEV 2>/dev/nullscip-shell filesystem . . `/dev/null`. && failscip-shell shell shell-project 0.0.0 fail(). |
| 1089 | echoscip-shell system . . echo. $PWD2 | $CRYPTSETUP -q open $OPAL2_DEV $DEV_NAME 2> /dev/nullscip-shell filesystem . . `/dev/null`. && failscip-shell shell shell-project 0.0.0 fail(). |
| 1090 | echoscip-shell system . . echo. $PWD2 | $CRYPTSETUP -q open -S2 $OPAL2_DEV $DEV_NAME 2> /dev/nullscip-shell filesystem . . `/dev/null`. && failscip-shell shell shell-project 0.0.0 fail(). |
| 1091 | echoscip-shell system . . echo. $PWD2 | $CRYPTSETUP -q open -S2 $OPAL2_DEV --test-passphrase || failscip-shell shell shell-project 0.0.0 fail(). |
| 1092 | echoscip-shell system . . echo. $PWD1 | $CRYPTSETUP -q open $OPAL2_DEV $DEV_NAME 2> /dev/nullscip-shell filesystem . . `/dev/null`. && failscip-shell shell shell-project 0.0.0 fail(). |
| 1093 | # check we're able to change passphrase for unbound keyslot |
| 1094 | echoscip-shell system . . echo. -e "$PWD2\n$PWD3" | $CRYPTSETUP luksChangeKey $FAST_PBKDF_OPT -S 2 $OPAL2_DEV || failscip-shell shell shell-project 0.0.0 fail(). |
| 1095 | echoscip-shell system . . echo. $PWD3 | $CRYPTSETUP open --test-passphrase -S 2 $OPAL2_DEV || failscip-shell shell shell-project 0.0.0 fail(). |
| 1096 | echoscip-shell system . . echo. $PWD3 | $CRYPTSETUP -q open -S 2 $OPAL2_DEV $DEV_NAME 2> /dev/nullscip-shell filesystem . . `/dev/null`. && failscip-shell shell shell-project 0.0.0 fail(). |
| 1097 | # do not allow adding keyslot by unbound keyslot |
| 1098 | echoscip-shell system . . echo. -e "$PWD3\n$PWD1" | $CRYPTSETUP -q luksAddKey $OPAL2_DEV 2> /dev/nullscip-shell filesystem . . `/dev/null`. && failscip-shell shell shell-project 0.0.0 fail(). |
| 1099 | # check adding keyslot works when there's unbound keyslot |
| 1100 | echoscip-shell system . . echo. $PWD1 | $CRYPTSETUP luksAddKey -q $FAST_PBKDF_OPT $OPAL2_DEV --key-file $KEY5 -S8 || failscip-shell shell shell-project 0.0.0 fail(). |
| 1101 | echoscip-shell system . . echo. $PWD1 | $CRYPTSETUP open $OPAL2_DEV $DEV_NAME || failscip-shell shell shell-project 0.0.0 fail(). |
| 1102 | $CRYPTSETUP close $DEV_NAME || failscip-shell shell shell-project 0.0.0 fail(). |
| 1103 | $CRYPTSETUP luksKillSlot -q $OPAL2_DEV 2 |
| 1104 | $CRYPTSETUP luksDump $OPAL2_DEV | grepscip-shell system . . grep. -q "2: luks2 (unbound)" && failscip-shell shell shell-project 0.0.0 fail(). |
| 1105 | echoscip-shell system . . echo. $PWD3 | $CRYPTSETUP luksDump --unbound --volume-key-file $KEY_FILE1 $OPAL2_DEV 2> /dev/nullscip-shell filesystem . . `/dev/null`. && failscip-shell shell shell-project 0.0.0 fail(). |
| 1106 | echoscip-shell system . . echo. $PWD3 | $CRYPTSETUP luksDump --unbound 2> /dev/nullscip-shell filesystem . . `/dev/null`. $OPAL2_DEV 2> /dev/nullscip-shell filesystem . . `/dev/null`. && failscip-shell shell shell-project 0.0.0 fail(). |
| 1107 | echoscip-shell system . . echo. $PWD3 | $CRYPTSETUP luksDump --unbound --volume-key-file $KEY_FILE1 -S3 $OPAL2_DEV > /dev/nullscip-shell filesystem . . `/dev/null`. || failscip-shell shell shell-project 0.0.0 fail(). |
| 1108 | diffscip-shell system . . diff. $KEY_FILE0 $KEY_FILE1 || failscip-shell shell shell-project 0.0.0 fail(). |
| 1109 | echoscip-shell system . . echo. $PWD3 | $CRYPTSETUP luksDump --unbound --volume-key-file $KEY_FILE1 -S3 $OPAL2_DEV 2> /dev/nullscip-shell filesystem . . `/dev/null`. && failscip-shell shell shell-project 0.0.0 fail(). |
| 1110 | diffscip-shell system . . diff. $KEY_FILE0 $KEY_FILE1 || failscip-shell shell shell-project 0.0.0 fail(). |
| 1111 | rmscip-shell system . . rm. $KEY_FILE1 || failscip-shell shell shell-project 0.0.0 fail(). |
| 1112 | echoscip-shell system . . echo. $PWD3 | $CRYPTSETUP luksDump --unbound --volume-key-file $KEY_FILE1 -S3 $OPAL2_DEV | grepscip-shell system . . grep. -q "Unbound Key:" && failscip-shell shell shell-project 0.0.0 fail(). |
| 1113 | echoscip-shell system . . echo. $PWD3 | $CRYPTSETUP luksDump --unbound -S3 $OPAL2_DEV | grepscip-shell system . . grep. -q "Unbound Key:" || failscip-shell shell shell-project 0.0.0 fail(). |
| 1114 | $CRYPTSETUP luksKillSlot -q $OPAL2_DEV 3 || failscip-shell shell shell-project 0.0.0 fail(). |
| 1115 | $CRYPTSETUP luksDump $OPAL2_DEV | grepscip-shell system . . grep. -q "3: luks2 (unbound)" && failscip-shell shell shell-project 0.0.0 fail(). |
| 1116 | |
| 1117 | preparescip-shell shell shell-project 0.0.0 prepare(). "[34] LUKS2 metadata areas" wipe |
| 1118 | echoscip-shell system . . echo. -e "$PWD1\n$OPAL2_ADMIN_PIN" | $CRYPTSETUP -q luksFormat $FAST_PBKDF_OPT --type luks2 --hw-opal $OPAL2_DEV 2> /dev/nullscip-shell filesystem . . `/dev/null`. || failscip-shell shell shell-project 0.0.0 fail(). |
| 1119 | DEFAULT_OFFSET=$($CRYPTSETUP luksDump $OPAL2_DEV | grepscip-shell system . . grep. "offset: " | cutscip-shell system . . cut. -f 2 -d ' ') |
| 1120 | echoscip-shell system . . echo. -e "$PWD1\n$OPAL2_ADMIN_PIN" | $CRYPTSETUP -q luksFormat $FAST_PBKDF_OPT --type luks2 --hw-opal-only $OPAL2_DEV --luks2-metadata-size=128k --luks2-keyslots-size=127k 2> /dev/nullscip-shell filesystem . . `/dev/null`. && failscip-shell shell shell-project 0.0.0 fail(). |
| 1121 | echoscip-shell system . . echo. -e "$PWD1\n$OPAL2_ADMIN_PIN" | $CRYPTSETUP -q luksFormat $FAST_PBKDF_OPT --type luks2 --hw-opal-only $OPAL2_DEV --luks2-metadata-size=127k --luks2-keyslots-size=128k 2> /dev/nullscip-shell filesystem . . `/dev/null`. && failscip-shell shell shell-project 0.0.0 fail(). |
| 1122 | echoscip-shell system . . echo. -e "$PWD1\n$OPAL2_ADMIN_PIN" | $CRYPTSETUP -q luksFormat $FAST_PBKDF_OPT --type luks2 --hw-opal-only $OPAL2_DEV --luks2-metadata-size=128k --luks2-keyslots-size=129M >/dev/nullscip-shell filesystem . . `/dev/null`. 2>&1 && failscip-shell shell shell-project 0.0.0 fail(). |
| 1123 | echoscip-shell system . . echo. -e "$PWD1\n$OPAL2_ADMIN_PIN" | $CRYPTSETUP -q luksFormat $FAST_PBKDF_OPT --type luks2 --hw-opal-only $OPAL2_DEV --luks2-metadata-size=128k --luks2-keyslots-size=128k >/dev/nullscip-shell filesystem . . `/dev/null`. || failscip-shell shell shell-project 0.0.0 fail(). |
| 1124 | $CRYPTSETUP luksDump $OPAL2_DEV | grepscip-shell system . . grep. "Metadata area:" | grepscip-shell system . . grep. -q "131072 \[bytes\]" || failscip-shell shell shell-project 0.0.0 fail(). |
| 1125 | $CRYPTSETUP luksDump $OPAL2_DEV | grepscip-shell system . . grep. "Keyslots area:" | grepscip-shell system . . grep. -q "131072 \[bytes\]" || failscip-shell shell shell-project 0.0.0 fail(). |
| 1126 | echoscip-shell system . . echo. $OPAL2_ADMIN_PIN | $CRYPTSETUP luksErase $OPAL2_DEV -q || failscip-shell shell shell-project 0.0.0 fail(). |
| 1127 | echoscip-shell system . . echo. -e "$PWD1\n$OPAL2_ADMIN_PIN" | $CRYPTSETUP -q luksFormat $FAST_PBKDF_OPT --type luks2 --hw-opal $OPAL2_DEV --key-size 256 --luks2-metadata-size=128k || failscip-shell shell shell-project 0.0.0 fail(). |
| 1128 | $CRYPTSETUP luksDump $OPAL2_DEV | grepscip-shell system . . grep. "Metadata area:" | grepscip-shell system . . grep. -q "131072 \[bytes\]" || failscip-shell shell shell-project 0.0.0 fail(). |
| 1129 | $CRYPTSETUP luksDump $OPAL2_DEV | grepscip-shell system . . grep. "Keyslots area:" | grepscip-shell system . . grep. -q "$((DEFAULT_OFFSET-2*131072)) \[bytes\]" || failscip-shell shell shell-project 0.0.0 fail(). |
| 1130 | echoscip-shell system . . echo. $OPAL2_ADMIN_PIN | $CRYPTSETUP luksErase $OPAL2_DEV -q || failscip-shell shell shell-project 0.0.0 fail(). |
| 1131 | echoscip-shell system . . echo. -e "$PWD1\n$OPAL2_ADMIN_PIN" | $CRYPTSETUP -q luksFormat $FAST_PBKDF_OPT --type luks2 --hw-opal-only $OPAL2_DEV --luks2-keyslots-size=128k >/dev/nullscip-shell filesystem . . `/dev/null`. || failscip-shell shell shell-project 0.0.0 fail(). |
| 1132 | $CRYPTSETUP luksDump $OPAL2_DEV | grepscip-shell system . . grep. "Metadata area:" | grepscip-shell system . . grep. -q "16384 \[bytes\]" || failscip-shell shell shell-project 0.0.0 fail(). |
| 1133 | $CRYPTSETUP luksDump $OPAL2_DEV | grepscip-shell system . . grep. "Keyslots area:" | grepscip-shell system . . grep. -q "131072 \[bytes\]" || failscip-shell shell shell-project 0.0.0 fail(). |
| 1134 | echoscip-shell system . . echo. $OPAL2_ADMIN_PIN | $CRYPTSETUP luksErase $OPAL2_DEV -q || failscip-shell shell shell-project 0.0.0 fail(). |
| 1135 | echoscip-shell system . . echo. -e "$PWD1\n$OPAL2_ADMIN_PIN" | $CRYPTSETUP -q luksFormat $FAST_PBKDF_OPT --type luks2 --hw-opal-only $OPAL2_DEV --offset 16384 || failscip-shell shell shell-project 0.0.0 fail(). |
| 1136 | $CRYPTSETUP luksDump $OPAL2_DEV | grepscip-shell system . . grep. "Metadata area:" | grepscip-shell system . . grep. -q "16384 \[bytes\]" || failscip-shell shell shell-project 0.0.0 fail(). |
| 1137 | $CRYPTSETUP luksDump $OPAL2_DEV | grepscip-shell system . . grep. "Keyslots area:" | grepscip-shell system . . grep. -q "8355840 \[bytes\]" || failscip-shell shell shell-project 0.0.0 fail(). |
| 1138 | echoscip-shell system . . echo. $OPAL2_ADMIN_PIN | $CRYPTSETUP luksErase $OPAL2_DEV -q || failscip-shell shell shell-project 0.0.0 fail(). |
| 1139 | # data offset vs area size |
| 1140 | echoscip-shell system . . echo. -e "$PWD1\n$OPAL2_ADMIN_PIN" | $CRYPTSETUP -q luksFormat $FAST_PBKDF_OPT --type luks2 --hw-opal-only $OPAL2_DEV --offset 64 --luks2-keyslots-size=8192 >/dev/nullscip-shell filesystem . . `/dev/null`. 2>&1 && failscip-shell shell shell-project 0.0.0 fail(). |
| 1141 | echoscip-shell system . . echo. -e "$PWD1\n$OPAL2_ADMIN_PIN" | $CRYPTSETUP -q luksFormat $FAST_PBKDF_OPT --type luks2 --hw-opal-only $OPAL2_DEV --offset $((256+56)) >/dev/nullscip-shell filesystem . . `/dev/null`. 2>&1 && failscip-shell shell shell-project 0.0.0 fail(). |
| 1142 | echoscip-shell system . . echo. -e "$PWD1\n$OPAL2_ADMIN_PIN" | $CRYPTSETUP -q luksFormat $FAST_PBKDF_OPT --type luks2 --hw-opal-only $OPAL2_DEV --offset $((256+64)) >/dev/nullscip-shell filesystem . . `/dev/null`. || failscip-shell shell shell-project 0.0.0 fail(). |
| 1143 | |
| 1144 | preparescip-shell shell shell-project 0.0.0 prepare(). "[35] Per-keyslot encryption parameters" wipe |
| 1145 | KEYSLOT_CIPHER="aes-cbc-plain64" |
| 1146 | echoscip-shell system . . echo. -e "$PWD1\n$OPAL2_ADMIN_PIN" | $CRYPTSETUP -q luksFormat --type luks2 --hw-opal-only $OPAL2_DEV $FAST_PBKDF_OPT --key-slot 0 --keyslot-cipher $KEYSLOT_CIPHER --keyslot-key-size 128 || failscip-shell shell shell-project 0.0.0 fail(). |
| 1147 | echoscip-shell system . . echo. $PWD1 | $CRYPTSETUP luksChangeKey $OPAL2_DEV $FAST_PBKDF_OPT --key-slot 0 --keyslot-cipher $KEYSLOT_CIPHER --keyslot-key-size 128 $KEY1 || failscip-shell shell shell-project 0.0.0 fail(). |
| 1148 | [scip-shell system . . `[`. "$($CRYPTSETUP luksDump $OPAL2_DEV | grepscip-shell system . . grep. -A8 -m1 "0: luks2" | grepscip-shell system . . grep. "Cipher:" | sedscip-shell system . . sed. -e 's/[[:space:]]\+Cipher:\ \+//g')" = $KEYSLOT_CIPHER ] || failscip-shell shell shell-project 0.0.0 fail(). |
| 1149 | [scip-shell system . . `[`. "$($CRYPTSETUP luksDump $OPAL2_DEV | grepscip-shell system . . grep. -A8 -m1 "0: luks2" | grepscip-shell system . . grep. "Cipher key:"| sedscip-shell system . . sed. -e 's/[[:space:]]\+Cipher\ key:\ \+//g')" = "128 bits" ] || failscip-shell shell shell-project 0.0.0 fail(). |
| 1150 | $CRYPTSETUP luksAddKey -q $OPAL2_DEV -d $KEY1 $KEY2 $FAST_PBKDF_OPT --key-slot 1 --keyslot-cipher $KEYSLOT_CIPHER --keyslot-key-size 128 || failscip-shell shell shell-project 0.0.0 fail(). |
| 1151 | [scip-shell system . . `[`. "$($CRYPTSETUP luksDump $OPAL2_DEV | grepscip-shell system . . grep. -A8 -m1 "1: luks2" | grepscip-shell system . . grep. "Cipher:" | sedscip-shell system . . sed. -e 's/[[:space:]]\+Cipher:\ \+//g')" = $KEYSLOT_CIPHER ] || failscip-shell shell shell-project 0.0.0 fail(). |
| 1152 | [scip-shell system . . `[`. "$($CRYPTSETUP luksDump $OPAL2_DEV | grepscip-shell system . . grep. -A8 -m1 "1: luks2" | grepscip-shell system . . grep. "Cipher key:"| sedscip-shell system . . sed. -e 's/[[:space:]]\+Cipher\ key:\ \+//g')" = "128 bits" ] || failscip-shell shell shell-project 0.0.0 fail(). |
| 1153 | $CRYPTSETUP luksAddKey -q $OPAL2_DEV -d $KEY1 $KEY2 $FAST_PBKDF_OPT --key-slot 2 || failscip-shell shell shell-project 0.0.0 fail(). |
| 1154 | $CRYPTSETUP luksChangeKey $OPAL2_DEV $FAST_PBKDF_OPT -d $KEY2 $KEY1 --key-slot 2 --keyslot-cipher $KEYSLOT_CIPHER --keyslot-key-size 128 || failscip-shell shell shell-project 0.0.0 fail(). |
| 1155 | [scip-shell system . . `[`. "$($CRYPTSETUP luksDump $OPAL2_DEV | grepscip-shell system . . grep. -A8 -m1 "2: luks2" | grepscip-shell system . . grep. "Cipher:" | sedscip-shell system . . sed. -e 's/[[:space:]]\+Cipher:\ \+//g')" = $KEYSLOT_CIPHER ] || failscip-shell shell shell-project 0.0.0 fail(). |
| 1156 | [scip-shell system . . `[`. "$($CRYPTSETUP luksDump $OPAL2_DEV | grepscip-shell system . . grep. -A8 -m1 "2: luks2" | grepscip-shell system . . grep. "Cipher key:"| sedscip-shell system . . sed. -e 's/[[:space:]]\+Cipher\ key:\ \+//g')" = "128 bits" ] || failscip-shell shell shell-project 0.0.0 fail(). |
| 1157 | # unbound keyslot |
| 1158 | echoscip-shell system . . echo. $PWD3 | $CRYPTSETUP luksAddKey -q $FAST_PBKDF_OPT --key-slot 21 --unbound -s 72 --keyslot-cipher $KEYSLOT_CIPHER --keyslot-key-size 128 $OPAL2_DEV || failscip-shell shell shell-project 0.0.0 fail(). |
| 1159 | [scip-shell system . . `[`. "$($CRYPTSETUP luksDump $OPAL2_DEV | grepscip-shell system . . grep. -A8 -m1 "21: luks2" | grepscip-shell system . . grep. "Cipher:" | sedscip-shell system . . sed. -e 's/[[:space:]]\+Cipher:\ \+//g')" = $KEYSLOT_CIPHER ] || failscip-shell shell shell-project 0.0.0 fail(). |
| 1160 | [scip-shell system . . `[`. "$($CRYPTSETUP luksDump $OPAL2_DEV | grepscip-shell system . . grep. -A8 -m1 "21: luks2" | grepscip-shell system . . grep. "Cipher key:"| sedscip-shell system . . sed. -e 's/[[:space:]]\+Cipher\ key:\ \+//g')" = "128 bits" ] || failscip-shell shell shell-project 0.0.0 fail(). |
| 1161 | echoscip-shell system . . echo. $PWD3 | $CRYPTSETUP luksAddKey -q $FAST_PBKDF_OPT --key-slot 22 --unbound -s 72 $OPAL2_DEV || failscip-shell shell shell-project 0.0.0 fail(). |
| 1162 | echoscip-shell system . . echo. $PWD3 | $CRYPTSETUP luksConvertKey --key-slot 22 $OPAL2_DEV --keyslot-cipher $KEYSLOT_CIPHER --keyslot-key-size 128 $OPAL2_DEV || failscip-shell shell shell-project 0.0.0 fail(). |
| 1163 | [scip-shell system . . `[`. "$($CRYPTSETUP luksDump $OPAL2_DEV | grepscip-shell system . . grep. -A8 -m1 "22: luks2" | grepscip-shell system . . grep. "Cipher:" | sedscip-shell system . . sed. -e 's/[[:space:]]\+Cipher:\ \+//g')" = $KEYSLOT_CIPHER ] || failscip-shell shell shell-project 0.0.0 fail(). |
| 1164 | [scip-shell system . . `[`. "$($CRYPTSETUP luksDump $OPAL2_DEV | grepscip-shell system . . grep. -A8 -m1 "22: luks2" | grepscip-shell system . . grep. "Cipher key:"| sedscip-shell system . . sed. -e 's/[[:space:]]\+Cipher\ key:\ \+//g')" = "128 bits" ] || failscip-shell shell shell-project 0.0.0 fail(). |
| 1165 | |
| 1166 | preparescip-shell shell shell-project 0.0.0 prepare(). "[36] Some encryption compatibility mode tests" wipe |
| 1167 | CIPHERS="aes-ecb aes-cbc-null aes-cbc-plain64 aes-cbc-essiv:sha256 aes-xts-plain64" |
| 1168 | key_size=256 |
| 1169 | for cipher in $CIPHERS ; do |
| 1170 | echoscip-shell system . . echo. -n "[$cipher/$key_size]" |
| 1171 | echoscip-shell system . . echo. -e "$PWD1\n$OPAL2_ADMIN_PIN" | $CRYPTSETUP -q luksFormat --type luks2 --hw-opal $OPAL2_DEV $FAST_PBKDF_OPT --cipher $cipher --key-size $key_size || failscip-shell shell shell-project 0.0.0 fail(). |
| 1172 | done |
| 1173 | echoscip-shell system . . echo. |
| 1174 | |
| 1175 | preparescip-shell shell shell-project 0.0.0 prepare(). "[37] New luksAddKey options." wipe |
| 1176 | rmscip-shell system . . rm. -f $VK_FILE |
| 1177 | echoscip-shell system . . echo. -e "$PWD1\n$OPAL2_ADMIN_PIN" | $CRYPTSETUP luksFormat -q --type luks2 --hw-opal-only $FAST_PBKDF_OPT $OPAL2_DEV || failscip-shell shell shell-project 0.0.0 fail(). |
| 1178 | echoscip-shell system . . echo. $PWD1 | $CRYPTSETUP luksDump -q $OPAL2_DEV --dump-volume-key --volume-key-file $VK_FILE >/dev/nullscip-shell filesystem . . `/dev/null`. || failscip-shell shell shell-project 0.0.0 fail(). |
| 1179 | |
| 1180 | # pass pass |
| 1181 | echoscip-shell system . . echo. -e "$PWD1\n$PWD2" | $CRYPTSETUP luksAddKey -q -S1 $FAST_PBKDF_OPT $OPAL2_DEV || failscip-shell shell shell-project 0.0.0 fail(). |
| 1182 | echoscip-shell system . . echo. $PWD2 | $CRYPTSETUP open -q --test-passphrase -S1 $OPAL2_DEV || failscip-shell shell shell-project 0.0.0 fail(). |
| 1183 | |
| 1184 | # pass file |
| 1185 | echoscip-shell system . . echo. "$PWD2" | $CRYPTSETUP luksAddKey -q $FAST_PBKDF_OPT -S1 --new-key-slot 2 $OPAL2_DEV $KEY1 || failscip-shell shell shell-project 0.0.0 fail(). |
| 1186 | $CRYPTSETUP open --test-passphrase -q -S2 -d $KEY1 $OPAL2_DEV || failscip-shell shell shell-project 0.0.0 fail(). |
| 1187 | |
| 1188 | # file pass |
| 1189 | echoscip-shell system . . echo. "$PWD3" | $CRYPTSETUP luksAddKey -q $FAST_PBKDF_OPT -S2 -d $KEY1 --new-key-slot 3 $OPAL2_DEV || failscip-shell shell shell-project 0.0.0 fail(). |
| 1190 | echoscip-shell system . . echo. $PWD3 | $CRYPTSETUP open -q --test-passphrase -S3 $OPAL2_DEV || failscip-shell shell shell-project 0.0.0 fail(). |
| 1191 | |
| 1192 | # file file |
| 1193 | $CRYPTSETUP luksAddKey -q $FAST_PBKDF_OPT -S2 --new-key-slot 4 -d $KEY1 --new-keyfile $KEY2 $OPAL2_DEV || failscip-shell shell shell-project 0.0.0 fail(). |
| 1194 | $CRYPTSETUP open --test-passphrase -q -S4 -d $KEY2 $OPAL2_DEV || failscip-shell shell shell-project 0.0.0 fail(). |
| 1195 | |
| 1196 | # vk pass |
| 1197 | echoscip-shell system . . echo. $PWD4 | $CRYPTSETUP luksAddKey -q $FAST_PBKDF_OPT -S5 --volume-key-file $VK_FILE $OPAL2_DEV || failscip-shell shell shell-project 0.0.0 fail(). |
| 1198 | echoscip-shell system . . echo. $PWD4 | $CRYPTSETUP open -q --test-passphrase -S5 $OPAL2_DEV || failscip-shell shell shell-project 0.0.0 fail(). |
| 1199 | |
| 1200 | # vk file |
| 1201 | $CRYPTSETUP luksAddKey -q $FAST_PBKDF_OPT -S6 --volume-key-file $VK_FILE --new-keyfile $KEY5 $OPAL2_DEV || failscip-shell shell shell-project 0.0.0 fail(). |
| 1202 | $CRYPTSETUP open --test-passphrase -q -S6 -d $KEY5 $OPAL2_DEV || failscip-shell shell shell-project 0.0.0 fail(). |
| 1203 | |
| 1204 | if [scip-shell system . . `[`. $HAVE_KEYRING -gt 0 -a -d /proc/sys/kernel/keysscip-shell filesystem . . `/proc/sys/kernel/keys`. ]; then |
| 1205 | test_and_prepare_keyringscip-shell shell shell-project 0.0.0 test_and_prepare_keyring(). |
| 1206 | load_keyscip-shell shell shell-project 0.0.0 load_key(). user $TEST_TOKEN0 $PWD1 "$TEST_KEYRING" || failscip-shell shell shell-project 0.0.0 fail(). "Cannot load 32 byte user key type" |
| 1207 | load_keyscip-shell shell shell-project 0.0.0 load_key(). user $TEST_TOKEN1 $PWDW "$TEST_KEYRING" || failscip-shell shell shell-project 0.0.0 fail(). "Cannot load 32 byte user key type" |
| 1208 | $CRYPTSETUP token add $OPAL2_DEV --key-description $TEST_TOKEN0 --token-id 0 -S0 || failscip-shell shell shell-project 0.0.0 fail(). |
| 1209 | $CRYPTSETUP token add $OPAL2_DEV --key-description $TEST_TOKEN1 --token-id 1 --unbound || failscip-shell shell shell-project 0.0.0 fail(). |
| 1210 | |
| 1211 | # pass token |
| 1212 | echoscip-shell system . . echo. -e "$PWD1" | $CRYPTSETUP luksAddKey -q -S7 --new-token-id 1 $FAST_PBKDF_OPT $OPAL2_DEV || failscip-shell shell shell-project 0.0.0 fail(). |
| 1213 | $CRYPTSETUP open -q --test-passphrase --token-only --token-id 1 -q $OPAL2_DEV || failscip-shell shell shell-project 0.0.0 fail(). |
| 1214 | echoscip-shell system . . echo. $PWD1 | $CRYPTSETUP luksKillSlot $OPAL2_DEV 7 || failscip-shell shell shell-project 0.0.0 fail(). |
| 1215 | $CRYPTSETUP open -q --test-passphrase --token-only --token-id 1 -q $OPAL2_DEV && failscip-shell shell shell-project 0.0.0 fail(). |
| 1216 | |
| 1217 | # file token |
| 1218 | $CRYPTSETUP luksAddKey -q $FAST_PBKDF_OPT -S2 --new-key-slot 7 --new-token-id 1 -d $KEY1 $OPAL2_DEV || failscip-shell shell shell-project 0.0.0 fail(). |
| 1219 | $CRYPTSETUP open -q --test-passphrase --token-only --token-id 1 -q $OPAL2_DEV || failscip-shell shell shell-project 0.0.0 fail(). |
| 1220 | echoscip-shell system . . echo. $PWD1 | $CRYPTSETUP luksKillSlot $OPAL2_DEV 7 || failscip-shell shell shell-project 0.0.0 fail(). |
| 1221 | $CRYPTSETUP open -q --test-passphrase --token-only --token-id 1 -q $OPAL2_DEV && failscip-shell shell shell-project 0.0.0 fail(). |
| 1222 | |
| 1223 | # vk token |
| 1224 | $CRYPTSETUP luksAddKey -q $FAST_PBKDF_OPT -S7 --volume-key-file $VK_FILE --new-token-id 1 $OPAL2_DEV || failscip-shell shell shell-project 0.0.0 fail(). |
| 1225 | $CRYPTSETUP open -q --test-passphrase --token-only --token-id 1 -q $OPAL2_DEV || failscip-shell shell shell-project 0.0.0 fail(). |
| 1226 | echoscip-shell system . . echo. $PWD1 | $CRYPTSETUP luksKillSlot $OPAL2_DEV 7 || failscip-shell shell shell-project 0.0.0 fail(). |
| 1227 | $CRYPTSETUP open -q --test-passphrase --token-only --token-id 1 -q $OPAL2_DEV && failscip-shell shell shell-project 0.0.0 fail(). |
| 1228 | |
| 1229 | # token pass |
| 1230 | echoscip-shell system . . echo. $PWD4 | $CRYPTSETUP luksAddKey -q $FAST_PBKDF_OPT -S7 --token-id 0 $OPAL2_DEV || failscip-shell shell shell-project 0.0.0 fail(). |
| 1231 | echoscip-shell system . . echo. $PWD4 | $CRYPTSETUP open -q --test-passphrase -S7 $OPAL2_DEV || failscip-shell shell shell-project 0.0.0 fail(). |
| 1232 | |
| 1233 | # token file |
| 1234 | echoscip-shell system . . echo. $PWD4 | $CRYPTSETUP luksAddKey -q $FAST_PBKDF_OPT -S8 --token-id 0 $OPAL2_DEV $KEY2 || failscip-shell shell shell-project 0.0.0 fail(). |
| 1235 | $CRYPTSETUP open -q --test-passphrase -S8 --key-file $KEY2 $OPAL2_DEV || failscip-shell shell shell-project 0.0.0 fail(). |
| 1236 | |
| 1237 | # token token |
| 1238 | $CRYPTSETUP luksAddKey -q $FAST_PBKDF_OPT -S9 --token-id 0 --new-token-id 1 $OPAL2_DEV || failscip-shell shell shell-project 0.0.0 fail(). |
| 1239 | $CRYPTSETUP open -q --test-passphrase --token-only --token-id 1 -q $OPAL2_DEV || failscip-shell shell shell-project 0.0.0 fail(). |
| 1240 | echoscip-shell system . . echo. $PWD1 | $CRYPTSETUP luksKillSlot $OPAL2_DEV 9 || failscip-shell shell shell-project 0.0.0 fail(). |
| 1241 | $CRYPTSETUP open -q --test-passphrase --token-only --token-id 1 -q $OPAL2_DEV && failscip-shell shell shell-project 0.0.0 fail(). |
| 1242 | |
| 1243 | # reuse same token |
| 1244 | $CRYPTSETUP luksAddKey -q $FAST_PBKDF_OPT -S0 --new-key-slot 9 --token-id 0 --new-token-id 0 $OPAL2_DEV || failscip-shell shell shell-project 0.0.0 fail(). |
| 1245 | $CRYPTSETUP open -q --test-passphrase --token-only --token-id 0 -q $OPAL2_DEV || failscip-shell shell shell-project 0.0.0 fail(). |
| 1246 | echoscip-shell system . . echo. $PWD1 | $CRYPTSETUP luksKillSlot $OPAL2_DEV 9 || failscip-shell shell shell-project 0.0.0 fail(). |
| 1247 | |
| 1248 | # reuse same token |
| 1249 | $CRYPTSETUP luksAddKey -q $FAST_PBKDF_OPT --token-id 0 --new-token-id 0 $OPAL2_DEV || failscip-shell shell shell-project 0.0.0 fail(). |
| 1250 | echoscip-shell system . . echo. $PWD1 | $CRYPTSETUP luksKillSlot $OPAL2_DEV 9 || failscip-shell shell shell-project 0.0.0 fail(). |
| 1251 | $CRYPTSETUP open -q --test-passphrase --token-only --token-id 0 -q $OPAL2_DEV || failscip-shell shell shell-project 0.0.0 fail(). |
| 1252 | fi |
| 1253 | |
| 1254 | if [scip-shell system . . `[`. $HAVE_KEYRING -gt 0 -a -d /proc/sys/kernel/keysscip-shell filesystem . . `/proc/sys/kernel/keys`. ]; then |
| 1255 | preparescip-shell shell shell-project 0.0.0 prepare(). "[38] Link VK to a keyring and use custom VK type." wipe |
| 1256 | |
| 1257 | echoscip-shell system . . echo. $PWD1 | $CRYPTSETUP -q luksFormat $FAST_PBKDF_OPT --type luks2 $OPAL2_DEV 2> /dev/nullscip-shell filesystem . . `/dev/null`. || failscip-shell shell shell-project 0.0.0 fail(). |
| 1258 | KEY_NAME="cryptsetup:test_volume_key_id" |
| 1259 | test_and_prepare_keyringscip-shell shell shell-project 0.0.0 test_and_prepare_keyring(). |
| 1260 | KID=$(echoscip-shell system . . echo. -n test | keyctl padd user my_token @s) |
| 1261 | keyctl unlink $KID >/dev/nullscip-shell filesystem . . `/dev/null`. 2>&1 @s && SESSION_KEYRING_WORKS=1 |
| 1262 | KID=$(echoscip-shell system . . echo. -n test | keyctl padd user my_token @us) |
| 1263 | keyctl unlink $KID >/dev/nullscip-shell filesystem . . `/dev/null`. 2>&1 @us && USER_SESSION_KEYRING_WORKS=1 |
| 1264 | |
| 1265 | test_vk_linkscip-shell shell shell-project 0.0.0 test_vk_link(). $KEY_NAME "@u" |
| 1266 | test_vk_linkscip-shell shell shell-project 0.0.0 test_vk_link(). $KEY_NAME "@u" "user" |
| 1267 | [[ ! -z "$SESSION_KEYRING_WORKS" ]] && test_vk_linkscip-shell shell shell-project 0.0.0 test_vk_link(). $KEY_NAME "@s" |
| 1268 | [[ ! -z "$SESSION_KEYRING_WORKS" ]] && test_vk_linkscip-shell shell shell-project 0.0.0 test_vk_link(). $KEY_NAME "@s" "logon" |
| 1269 | [[ ! -z "$SESSION_KEYRING_WORKS" ]] && test_vk_linkscip-shell shell shell-project 0.0.0 test_vk_link(). $KEY_NAME "@s" "user" |
| 1270 | test_vk_linkscip-shell shell shell-project 0.0.0 test_vk_link(). $KEY_NAME "%:$TEST_KEYRING_NAME" |
| 1271 | test_vk_linkscip-shell shell shell-project 0.0.0 test_vk_link(). $KEY_NAME "%:$TEST_KEYRING_NAME" "user" |
| 1272 | test_vk_linkscip-shell shell shell-project 0.0.0 test_vk_link(). $KEY_NAME "%:$TEST_KEYRING_NAME" "logon" |
| 1273 | # explicitly specify keyring key type |
| 1274 | test_vk_linkscip-shell shell shell-project 0.0.0 test_vk_link(). $KEY_NAME "%keyring:$TEST_KEYRING_NAME" |
| 1275 | |
| 1276 | test_vk_link_with_passphrase_checkscip-shell shell shell-project 0.0.0 test_vk_link_with_passphrase_check(). $KEY_NAME "%:$TEST_KEYRING_NAME" |
| 1277 | test_vk_link_with_passphrase_checkscip-shell shell shell-project 0.0.0 test_vk_link_with_passphrase_check(). $KEY_NAME "%:$TEST_KEYRING_NAME" "user" |
| 1278 | test_vk_link_with_passphrase_checkscip-shell shell shell-project 0.0.0 test_vk_link_with_passphrase_check(). $KEY_NAME "%:$TEST_KEYRING_NAME" "logon" |
| 1279 | |
| 1280 | test_vk_link_and_reactivatescip-shell shell shell-project 0.0.0 test_vk_link_and_reactivate(). $KEY_NAME "@u" "user" |
| 1281 | test_vk_link_and_reactivatescip-shell shell shell-project 0.0.0 test_vk_link_and_reactivate(). $KEY_NAME "@u" |
| 1282 | [[ ! -z "$SESSION_KEYRING_WORKS" ]] && test_vk_link_and_reactivatescip-shell shell shell-project 0.0.0 test_vk_link_and_reactivate(). $KEY_NAME "@s" "user" |
| 1283 | test_vk_link_and_reactivatescip-shell shell shell-project 0.0.0 test_vk_link_and_reactivate(). $KEY_NAME "%:$TEST_KEYRING_NAME" "user" |
| 1284 | # explicitly specify keyring key type |
| 1285 | test_vk_link_and_reactivatescip-shell shell shell-project 0.0.0 test_vk_link_and_reactivate(). $KEY_NAME "%keyring:$TEST_KEYRING_NAME" "user" |
| 1286 | test_vk_link_and_reactivatescip-shell shell shell-project 0.0.0 test_vk_link_and_reactivate(). $KEY_NAME "%keyring:$TEST_KEYRING_NAME" |
| 1287 | |
| 1288 | # test numeric keyring name -5 is user session (@us) keyring |
| 1289 | echoscip-shell system . . echo. $PWD1 | $CRYPTSETUP open $OPAL2_DEV $DEV_NAME --link-vk-to-keyring -5::%logon:$KEY_NAME || failscip-shell shell shell-project 0.0.0 fail(). |
| 1290 | keyctl search @us logon $KEY_NAME > /dev/nullscip-shell filesystem . . `/dev/null`. 2>&1 || failscip-shell shell shell-project 0.0.0 fail(). "VK is not linked to the specified keyring after activation." |
| 1291 | $CRYPTSETUP close $DEV_NAME |
| 1292 | keyctl search @us logon $KEY_NAME > /dev/nullscip-shell filesystem . . `/dev/null`. 2>&1 || failscip-shell shell shell-project 0.0.0 fail(). "VK is not linked to the specified keyring after deactivation." |
| 1293 | keyctl unlink "%logon:$KEY_NAME" @us || failscip-shell shell shell-project 0.0.0 fail(). |
| 1294 | |
| 1295 | # test malformed keyring descriptions and key types |
| 1296 | # missing key description |
| 1297 | echoscip-shell system . . echo. $PWD1 | $CRYPTSETUP open $OPAL2_DEV $DEV_NAME --link-vk-to-keyring "%$TEST_KEYRING_NAME::" > /dev/nullscip-shell filesystem . . `/dev/null`. 2>&1 && failscip-shell shell shell-project 0.0.0 fail(). |
| 1298 | # malformed keyring description |
| 1299 | echoscip-shell system . . echo. $PWD1 | $CRYPTSETUP open $OPAL2_DEV $DEV_NAME --link-vk-to-keyring ":$TEST_KEYRING_NAME::$KEY_NAME" > /dev/nullscip-shell filesystem . . `/dev/null`. 2>&1 && failscip-shell shell shell-project 0.0.0 fail(). |
| 1300 | echoscip-shell system . . echo. $PWD1 | $CRYPTSETUP open $OPAL2_DEV $DEV_NAME --link-vk-to-keyring "@uuu::$KEY_NAME" > /dev/nullscip-shell filesystem . . `/dev/null`. 2>&1 && failscip-shell shell shell-project 0.0.0 fail(). |
| 1301 | echoscip-shell system . . echo. $PWD1 | $CRYPTSETUP open $OPAL2_DEV $DEV_NAME --link-vk-to-keyring "@usu::$KEY_NAME" > /dev/nullscip-shell filesystem . . `/dev/null`. 2>&1 && failscip-shell shell shell-project 0.0.0 fail(). |
| 1302 | |
| 1303 | echoscip-shell system . . echo. $PWD1 | $CRYPTSETUP open $OPAL2_DEV $DEV_NAME --link-vk-to-keyring "$TEST_KEYRING_NAME::%user" > /dev/nullscip-shell filesystem . . `/dev/null`. 2>&1 && failscip-shell shell shell-project 0.0.0 fail(). |
| 1304 | echoscip-shell system . . echo. $PWD1 | $CRYPTSETUP open $OPAL2_DEV $DEV_NAME --link-vk-to-keyring "$TEST_KEYRING_NAME::%user:" > /dev/nullscip-shell filesystem . . `/dev/null`. 2>&1 && failscip-shell shell shell-project 0.0.0 fail(). |
| 1305 | echoscip-shell system . . echo. $PWD1 | $CRYPTSETUP open $OPAL2_DEV $DEV_NAME --link-vk-to-keyring "%user:$KEY_NAME" > /dev/nullscip-shell filesystem . . `/dev/null`. 2>&1 && failscip-shell shell shell-project 0.0.0 fail(). |
| 1306 | |
| 1307 | echoscip-shell system . . echo. $PWD1 | $CRYPTSETUP open $OPAL2_DEV $DEV_NAME --link-vk-to-keyring "@t::%0:$KEY_NAME" > /dev/nullscip-shell filesystem . . `/dev/null`. 2>&1 && failscip-shell shell shell-project 0.0.0 fail(). |
| 1308 | echoscip-shell system . . echo. $PWD1 | $CRYPTSETUP open $OPAL2_DEV $DEV_NAME --link-vk-to-keyring "@t::%blah:$KEY_NAME" > /dev/nullscip-shell filesystem . . `/dev/null`. 2>&1 && failscip-shell shell shell-project 0.0.0 fail(). |
| 1309 | echoscip-shell system . . echo. $PWD1 | $CRYPTSETUP open $OPAL2_DEV $DEV_NAME --link-vk-to-keyring "@t::%userlogon:$KEY_NAME" > /dev/nullscip-shell filesystem . . `/dev/null`. 2>&1 && failscip-shell shell shell-project 0.0.0 fail(). |
| 1310 | |
| 1311 | fi |
| 1312 | |
| 1313 | if ! fips_modescip-shell shell shell-project 0.0.0 fips_mode().; then |
| 1314 | preparescip-shell shell shell-project 0.0.0 prepare(). "[39] LUKS2 reencryption/decryption blocked" wipe |
| 1315 | |
| 1316 | echoscip-shell system . . echo. -e "$PWD1\n$OPAL2_ADMIN_PIN" | $CRYPTSETUP -q luksFormat $FAST_PBKDF_OPT --type luks2 -s256 --hw-opal $OPAL2_DEV || failscip-shell shell shell-project 0.0.0 fail(). |
| 1317 | test_reencryption_does_not_initscip-shell shell shell-project 0.0.0 test_reencryption_does_not_init(). |
| 1318 | |
| 1319 | echoscip-shell system . . echo. -e "$PWD1\n$OPAL2_ADMIN_PIN" | $CRYPTSETUP -q luksFormat $FAST_PBKDF_OPT --type luks2 --hw-opal-only $OPAL2_DEV || failscip-shell shell shell-project 0.0.0 fail(). |
| 1320 | test_reencryption_does_not_initscip-shell shell shell-project 0.0.0 test_reencryption_does_not_init(). |
| 1321 | |
| 1322 | preparescip-shell shell shell-project 0.0.0 prepare(). "[40] LUKS2 reencryption/decryption blocked (detached header)" wipe |
| 1323 | |
| 1324 | echoscip-shell system . . echo. -e "$PWD1\n$OPAL2_ADMIN_PIN" | $CRYPTSETUP -q luksFormat $FAST_PBKDF_OPT --header $HEADER_IMG --type luks2 -s256 --hw-opal $OPAL2_DEV || failscip-shell shell shell-project 0.0.0 fail(). |
| 1325 | test_reencryption_does_not_initscip-shell shell shell-project 0.0.0 test_reencryption_does_not_init(). $HEADER_IMG |
| 1326 | |
| 1327 | echoscip-shell system . . echo. -e "$PWD1\n$OPAL2_ADMIN_PIN" | $CRYPTSETUP -q luksFormat $FAST_PBKDF_OPT --header $HEADER_IMG --type luks2 --hw-opal-only $OPAL2_DEV || failscip-shell shell shell-project 0.0.0 fail(). |
| 1328 | test_reencryption_does_not_initscip-shell shell shell-project 0.0.0 test_reencryption_does_not_init(). $HEADER_IMG |
| 1329 | |
| 1330 | preparescip-shell shell shell-project 0.0.0 prepare(). "[41] LUKS2 encryption blocked" wipe |
| 1331 | |
| 1332 | echoscip-shell system . . echo. -e "$PWD1\n$OPAL2_ADMIN_PIN" | $CRYPTSETUP reencrypt --encrypt --init-only --reduce-device-size 32m $FAST_PBKDF_OPT --type luks2 -s256 --hw-opal $OPAL2_DEV 2>/dev/nullscip-shell filesystem . . `/dev/null`. && failscip-shell shell shell-project 0.0.0 fail(). |
| 1333 | $CRYPTSETUP isLuks $OPAL2_DEV && failscip-shell shell shell-project 0.0.0 fail(). |
| 1334 | echoscip-shell system . . echo. -e "$PWD1\n$OPAL2_ADMIN_PIN" | $CRYPTSETUP reencrypt --encrypt --init-only --reduce-device-size 32m $FAST_PBKDF_OPT --type luks2 -s256 --hw-opal $OPAL2_DEV $DEV_NAME 2>/dev/nullscip-shell filesystem . . `/dev/null`. && failscip-shell shell shell-project 0.0.0 fail(). |
| 1335 | $CRYPTSETUP isLuks $OPAL2_DEV && failscip-shell shell shell-project 0.0.0 fail(). |
| 1336 | testscip-shell system . . test. -b $DEV_NAME && failscip-shell shell shell-project 0.0.0 fail(). |
| 1337 | echoscip-shell system . . echo. -e "$PWD1\n$OPAL2_ADMIN_PIN" | $CRYPTSETUP reencrypt --encrypt --reduce-device-size 32m $FAST_PBKDF_OPT --type luks2 -s256 --hw-opal $OPAL2_DEV 2>/dev/nullscip-shell filesystem . . `/dev/null`. && failscip-shell shell shell-project 0.0.0 fail(). |
| 1338 | $CRYPTSETUP isLuks $OPAL2_DEV && failscip-shell shell shell-project 0.0.0 fail(). |
| 1339 | echoscip-shell system . . echo. -e "$PWD1\n$OPAL2_ADMIN_PIN" | $CRYPTSETUP reencrypt --encrypt --init-only --reduce-device-size 32m $FAST_PBKDF_OPT --type luks2 --hw-opal-only $OPAL2_DEV 2>/dev/nullscip-shell filesystem . . `/dev/null`. && failscip-shell shell shell-project 0.0.0 fail(). |
| 1340 | $CRYPTSETUP isLuks $OPAL2_DEV && failscip-shell shell shell-project 0.0.0 fail(). |
| 1341 | echoscip-shell system . . echo. -e "$PWD1\n$OPAL2_ADMIN_PIN" | $CRYPTSETUP reencrypt --encrypt --init-only --reduce-device-size 32m $FAST_PBKDF_OPT --type luks2 --hw-opal-only $OPAL2_DEV $DEV_NAME 2>/dev/nullscip-shell filesystem . . `/dev/null`. && failscip-shell shell shell-project 0.0.0 fail(). |
| 1342 | $CRYPTSETUP isLuks $OPAL2_DEV && failscip-shell shell shell-project 0.0.0 fail(). |
| 1343 | testscip-shell system . . test. -b $DEV_NAME && failscip-shell shell shell-project 0.0.0 fail(). |
| 1344 | echoscip-shell system . . echo. -e "$PWD1\n$OPAL2_ADMIN_PIN" | $CRYPTSETUP reencrypt --encrypt --reduce-device-size 32m $FAST_PBKDF_OPT --type luks2 --hw-opal-only $OPAL2_DEV 2>/dev/nullscip-shell filesystem . . `/dev/null`. && failscip-shell shell shell-project 0.0.0 fail(). |
| 1345 | $CRYPTSETUP isLuks $OPAL2_DEV && failscip-shell shell shell-project 0.0.0 fail(). |
| 1346 | fi |
| 1347 | |
| 1348 | preparescip-shell shell shell-project 0.0.0 prepare(). "[42] OPAL2 HW only test." wipe |
| 1349 | test_devicescip-shell shell shell-project 0.0.0 test_device(). --hw-opal-only |
| 1350 | |
| 1351 | preparescip-shell shell shell-project 0.0.0 prepare(). "[43] OPAL2 + dmcrypt test." wipe |
| 1352 | test_devicescip-shell shell shell-project 0.0.0 test_device(). --hw-opal |
| 1353 | |
| 1354 | preparescip-shell shell shell-project 0.0.0 prepare(). "[44] OPAL2 + auth encryption" wipe |
| 1355 | test_devicescip-shell shell shell-project 0.0.0 test_device(). --hw-opal "-c aes-gcm-random --integrity aead" --integrity-no-wipe |
| 1356 | test_devicescip-shell shell shell-project 0.0.0 test_device(). --hw-opal "-s 280 -c aes-ccm-random --integrity aead" --integrity-no-wipe |
| 1357 | |
| 1358 | preparescip-shell shell shell-project 0.0.0 prepare(). "[45] OPAL2 HW only test (detached header)" wipe |
| 1359 | test_device_detached_headerscip-shell shell shell-project 0.0.0 test_device_detached_header(). $HEADER_IMG --hw-opal-only |
| 1360 | |
| 1361 | preparescip-shell shell shell-project 0.0.0 prepare(). "[46] OPAL2 + dmcrypt test (detached header)" wipe |
| 1362 | test_device_detached_headerscip-shell shell shell-project 0.0.0 test_device_detached_header(). $HEADER_IMG --hw-opal |
| 1363 | |
| 1364 | preparescip-shell shell shell-project 0.0.0 prepare(). "[47] OPAL2 + auth encryption test (detached header)" wipe |
| 1365 | test_device_detached_headerscip-shell shell shell-project 0.0.0 test_device_detached_header(). $HEADER_IMG --hw-opal "-c aes-gcm-random --integrity aead" --integrity-no-wipe |
| 1366 | test_device_detached_headerscip-shell shell shell-project 0.0.0 test_device_detached_header(). $HEADER_IMG --hw-opal "-s 280 -c aes-ccm-random --integrity aead" --integrity-no-wipe |
| 1367 | |
| 1368 | # FIXME: Add partition based tests |
| 1369 | |
| 1370 | remove_mappingscip-shell shell shell-project 0.0.0 remove_mapping(). |
| 1371 | reset_device_psid_nofailscip-shell shell shell-project 0.0.0 reset_device_psid_nofail(). |
| 1372 | exit 0 |