3 # check hash processing in create command
5 CRYPTSETUP=../src/cryptsetup
12 udevadm settle >/dev/null 2>&1
13 dmsetup remove $1 >/dev/null 2>&1
17 [ -b /dev/mapper/$DEV2 ] && dmremove $DEV2
18 [ -b /dev/mapper/$DEV_NAME ] && dmremove $DEV_NAME
23 crypt_key() # hash keysize pwd/file name outkey
26 MODE=aes-cbc-essiv:sha256
27 [ $2 -gt 256 ] && MODE=aes-xts-plain
29 echo -n "HASH: $1 KSIZE: $2 / $3"
32 echo -e -n "$4" | $CRYPTSETUP create -c $MODE -h $1 -s $2 $DEV2 /dev/mapper/$DEV_NAME 2>/dev/null
36 echo -e -n "$4" | $CRYPTSETUP create -c $MODE -d "-" -h $1 -s $2 $DEV2 /dev/mapper/$DEV_NAME 2>/dev/null
40 $CRYPTSETUP create -c $MODE -d $4 -h $1 -s $2 $DEV2 /dev/mapper/$DEV_NAME 2>/dev/null
48 if [ $ret -ne 0 ] ; then
53 VKEY=$(dmsetup table $DEV2 --showkeys 2>/dev/null | cut -d' ' -f 5)
54 if [ "$VKEY" != "$5" ] ; then
57 echo "real key: $VKEY"
66 if [ $(id -u) != 0 ]; then
67 echo "WARNING: You must be root to run this test, test skipped."
71 dmsetup create $DEV_NAME --table "0 10240 zero" >/dev/null 2>&1
73 crypt_key ripemd160 0 pwd "xxx" aeb26d1f69eb6dddfb9381eed4d7299f091e99aa5d3ff06866d4ce9f620f7aca
74 crypt_key ripemd160 256 pwd "xxx" aeb26d1f69eb6dddfb9381eed4d7299f091e99aa5d3ff06866d4ce9f620f7aca
75 crypt_key ripemd160 128 pwd "xxx" aeb26d1f69eb6dddfb9381eed4d7299f
76 crypt_key sha1 256 pwd "xxx" b60d121b438a380c343d5ec3c2037564b82ffef30b1e0a6ad9af7a73aa91c197
77 crypt_key sha1 128 pwd "xxx" b60d121b438a380c343d5ec3c2037564
78 crypt_key sha256 256 pwd "xxx" cd2eb0837c9b4c962c22d2ff8b5441b7b45805887f051d39bf133b583baf6860
79 crypt_key sha256 128 pwd "xxx" cd2eb0837c9b4c962c22d2ff8b5441b7
81 crypt_key ripemd160 0 stdin "xxx" aeb26d1f69eb6dddfb9381eed4d7299f091e99aa5d3ff06866d4ce9f620f7aca
82 crypt_key ripemd160 256 stdin "xxx\n" 625ce2a8dbdf08f1de400dba7ab9fab246f2a55ad6136e6cafd6703732dab8cf
84 # with keyfile, hash is ignored
85 crypt_key ripemd160 256 file /dev/zero 0000000000000000000000000000000000000000000000000000000000000000
86 crypt_key sha256 256 file /dev/zero 0000000000000000000000000000000000000000000000000000000000000000
89 crypt_key sha256:20 256 pwd "xxx" cd2eb0837c9b4c962c22d2ff8b5441b7b4580588000000000000000000000000
90 crypt_key sha256:32 256 pwd "xxx" cd2eb0837c9b4c962c22d2ff8b5441b7b45805887f051d39bf133b583baf6860
93 echo -n -e "0123456789abcdef\n\x01\x00\x03\xff\xff\r\xff\xff\n\r" \
94 "2352j3rkjhadcfasc823rqaw7e1 3dq sdq3d 2dkjqw3h2=====" >$KEY_FILE
95 KEY_FILE_HEX="303132333435363738396162636465660a010003ffff0dffff0a0d20323335326a33726b6a686164636661736338323372716177376531203364712073647133"
97 crypt_key ripemd160 256 file $KEY_FILE ${KEY_FILE_HEX:0:64}
98 crypt_key sha256 256 file $KEY_FILE ${KEY_FILE_HEX:0:64}
99 crypt_key sha256 128 file $KEY_FILE ${KEY_FILE_HEX:0:32}
100 crypt_key sha256 512 file $KEY_FILE $KEY_FILE_HEX