"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "tests/integrity-compat-test" between
cryptsetup-2.0.6.tar.xz and cryptsetup-2.1.0.tar.xz

About: cryptsetup is a utility used to conveniently setup disk encryption based on the dm-crypt kernel module. These include plain dm-crypt volumes, LUKS volumes, loop-AES and TrueCrypt compatible format.

integrity-compat-test  (cryptsetup-2.0.6.tar.xz):integrity-compat-test  (cryptsetup-2.1.0.tar.xz)
#!/bin/bash #!/bin/bash
# #
# Test integritysetup compatibility. # Test integritysetup compatibility.
# #
INTSETUP=../integritysetup INTSETUP=../integritysetup
INTSETUP_VALGRIND=../.libs/integritysetup INTSETUP_VALGRIND=../.libs/integritysetup
INTSETUP_LIB_VALGRIND=../.libs INTSETUP_LIB_VALGRIND=../.libs
DEV_NAME=dmc_test DEV_NAME=dmc_test
DEV=test123.img DEV=test123.img
DEV2=test124.img
KEY_FILE=key.img KEY_FILE=key.img
dmremove() { # device dmremove() { # device
udevadm settle >/dev/null 2>&1 udevadm settle >/dev/null 2>&1
dmsetup remove $1 >/dev/null 2>&1 dmsetup remove $1 >/dev/null 2>&1
} }
cleanup() { cleanup() {
[ -b /dev/mapper/$DEV_NAME ] && dmremove $DEV_NAME [ -b /dev/mapper/$DEV_NAME ] && dmremove $DEV_NAME
rm -f $DEV $KEY_FILE >/dev/null 2>&1 rm -f $DEV $DEV2 $KEY_FILE >/dev/null 2>&1
} }
fail() fail()
{ {
echo echo
[ -n "$1" ] && echo "FAILED at line $(caller)" echo "FAILED at line $(caller)"
cleanup cleanup
exit 100 exit 100
} }
skip() skip()
{ {
[ -n "$1" ] && echo "$1" [ -n "$1" ] && echo "$1"
exit 77 exit 77
} }
function dm_integrity_features()
{
VER_STR=$(dmsetup targets | grep integrity | cut -f2 -dv)
[ -z "$VER_STR" ] && skip "Cannot find dm-integrity target, test skipped.
"
VER_MAJ=$(echo $VER_STR | cut -f 1 -d.)
VER_MIN=$(echo $VER_STR | cut -f 2 -d.)
VER_PTC=$(echo $VER_STR | cut -f 3 -d.)
[ $VER_MAJ -lt 1 ] && return
[ $VER_MIN -gt 1 ] && {
DM_INTEGRITY_META=1
DM_INTEGRITY_RECALC=1
}
}
add_device() { add_device() {
cleanup cleanup
dd if=/dev/urandom of=$KEY_FILE bs=1 count=512 >/dev/null 2>&1 dd if=/dev/urandom of=$KEY_FILE bs=1 count=512 >/dev/null 2>&1
dd if=/dev/zero of=$DEV bs=1M count=32 >/dev/null 2>&1 dd if=/dev/zero of=$DEV bs=1M count=32 >/dev/null 2>&1
dd if=/dev/zero of=$DEV2 bs=1M count=32 >/dev/null 2>&1
sync sync
} }
status_check() # name value status_check() # name value
{ {
X=$($INTSETUP status $DEV_NAME | grep "$1" | sed 's/.*: //' | sed 's/^[[: space:]]*//') X=$($INTSETUP status $DEV_NAME | grep "$1" | sed 's/.*: //' | sed 's/^[[: space:]]*//')
if [ "$X" != "$2" ] ; then if [ "$X" != "$2" ] ; then
echo "[status FAIL]" echo "[status FAIL]"
echo " Expecting $1:$2 got \"$X\"." echo " Expecting $1:$2 got \"$X\"."
fail fail
skipping to change at line 86 skipping to change at line 104
which valgrind >/dev/null 2>&1 || fail "Cannot find valgrind." which valgrind >/dev/null 2>&1 || fail "Cannot find valgrind."
[ ! -f $INTSETUP_VALGRIND ] && fail "Unable to get location of cryptsetup ex ecutable." [ ! -f $INTSETUP_VALGRIND ] && fail "Unable to get location of cryptsetup ex ecutable."
export LD_LIBRARY_PATH="$INTSETUP_LIB_VALGRIND:$LD_LIBRARY_PATH" export LD_LIBRARY_PATH="$INTSETUP_LIB_VALGRIND:$LD_LIBRARY_PATH"
} }
function valgrind_run() function valgrind_run()
{ {
INFOSTRING="$(basename ${BASH_SOURCE[1]})-line-${BASH_LINENO[0]}" ./valg.sh ${INTSETUP_VALGRIND} "$@" INFOSTRING="$(basename ${BASH_SOURCE[1]})-line-${BASH_LINENO[0]}" ./valg.sh ${INTSETUP_VALGRIND} "$@"
} }
int_check_sum_only() # checksum
{
VSUM=$(sha256sum /dev/mapper/$DEV_NAME | cut -d' ' -f 1)
if [ "$VSUM" = "$1" ] ; then
echo -n "[CHECKSUM OK]"
else
echo "[FAIL]"
echo " Expecting $1 got $VSUM."
fail
fi
}
int_check_sum() # alg checksum [keyfile keysize] int_check_sum() # alg checksum [keyfile keysize]
{ {
if [ -n "$4" ] ; then if [ -n "$4" ] ; then
KEY_PARAMS="--integrity-key-file $3 --integrity-key-size $4" KEY_PARAMS="--integrity-key-file $3 --integrity-key-size $4"
else else
KEY_PARAMS="" KEY_PARAMS=""
fi fi
# Fill device with zeroes and reopen it # Fill device with zeroes and reopen it
dd if=/dev/zero of=/dev/mapper/$DEV_NAME bs=1M oflag=direct >/dev/null 2> &1 dd if=/dev/zero of=/dev/mapper/$DEV_NAME bs=1M oflag=direct >/dev/null 2> &1
dmremove $DEV_NAME dmremove $DEV_NAME
$INTSETUP open $DEV $DEV_NAME --integrity $1 $KEY_PARAMS || fail "Cannot activate device." $INTSETUP open $DEV $DEV_NAME --integrity $1 $KEY_PARAMS || fail "Cannot activate device."
VSUM=$(sha256sum /dev/mapper/$DEV_NAME | cut -d' ' -f 1) int_check_sum_only $2
if [ "$VSUM" = "$2" ] ; then
echo -n "[CHECKSUM OK]"
else
echo "[FAIL]"
echo " Expecting $2 got $VSUM."
fail
fi
} }
intformat() # alg alg_out tagsize sector_size csum [keyfile keysize] intformat() # alg alg_out tagsize sector_size csum [keyfile keysize]
{ {
if [ -n "$7" ] ; then if [ -n "$7" ] ; then
KEY_PARAMS="--integrity-key-file $6 --integrity-key-size $7" KEY_PARAMS="--integrity-key-file $6 --integrity-key-size $7"
else else
KEY_PARAMS="" KEY_PARAMS=""
fi fi
skipping to change at line 265 skipping to change at line 288
echo "[OK]" echo "[OK]"
} }
[ $(id -u) != 0 ] && skip "WARNING: You must be root to run this test, test skip ped." [ $(id -u) != 0 ] && skip "WARNING: You must be root to run this test, test skip ped."
[ ! -x "$INTSETUP" ] && skip "Cannot find $INTSETUP, test skipped." [ ! -x "$INTSETUP" ] && skip "Cannot find $INTSETUP, test skipped."
[ -n "$VALG" ] && valgrind_setup && INTSETUP=valgrind_run [ -n "$VALG" ] && valgrind_setup && INTSETUP=valgrind_run
which hexdump >/dev/null 2>&1 || skip "WARNING: hexdump tool required." which hexdump >/dev/null 2>&1 || skip "WARNING: hexdump tool required."
modprobe dm-integrity >/dev/null 2>&1 modprobe dm-integrity >/dev/null 2>&1
dmsetup targets | grep integrity >/dev/null 2>&1 || skip "Cannot find dm-integri ty target, test skipped." dm_integrity_features
add_device add_device
intformat crc32c crc32c 4 512 08f63eb27fb9ce2ce903b0a56429c68ce5e 209253ba42154841ef045a53839d7 intformat crc32c crc32c 4 512 08f63eb27fb9ce2ce903b0a56429c68ce5e 209253ba42154841ef045a53839d7
intformat crc32 crc32 4 512 08f63eb27fb9ce2ce903b0a56429c68ce5e 209253ba42154841ef045a53839d7 intformat crc32 crc32 4 512 08f63eb27fb9ce2ce903b0a56429c68ce5e 209253ba42154841ef045a53839d7
intformat sha1 sha1 20 512 6eedd6344dab8875cd185fcd6565dfc869a b36bc57e577f40c685290b1fa7fe7 intformat sha1 sha1 20 512 6eedd6344dab8875cd185fcd6565dfc869a b36bc57e577f40c685290b1fa7fe7
intformat sha1 sha1 16 4096 e152ec88227b539cd9cafd8bdb587a1072d 720cd6bcebe1398d4136c9e7f337b intformat sha1 sha1 16 4096 e152ec88227b539cd9cafd8bdb587a1072d 720cd6bcebe1398d4136c9e7f337b
intformat sha256 sha256 32 512 8e5fe4119558e117bfc40e3b0f13ade3abe 497b52604d4c7cca0cfd6c7f4cf11 intformat sha256 sha256 32 512 8e5fe4119558e117bfc40e3b0f13ade3abe 497b52604d4c7cca0cfd6c7f4cf11
intformat hmac-sha256 hmac\(sha256\) 32 512 8e5fe4119558e117bfc40e3b0f13ade3abe 497b52604d4c7cca0cfd6c7f4cf11 $KEY_FILE 32 intformat hmac-sha256 hmac\(sha256\) 32 512 8e5fe4119558e117bfc40e3b0f13ade3abe 497b52604d4c7cca0cfd6c7f4cf11 $KEY_FILE 32
intformat sha256 sha256 32 4096 33f7dfa5163ca9f740383fb8b0919574e38 a7b20a94a4170fde4238196b7c4b4 intformat sha256 sha256 32 4096 33f7dfa5163ca9f740383fb8b0919574e38 a7b20a94a4170fde4238196b7c4b4
intformat hmac-sha256 hmac\(sha256\) 32 4096 33f7dfa5163ca9f740383fb8b0919574e38 a7b20a94a4170fde4238196b7c4b4 $KEY_FILE 32 intformat hmac-sha256 hmac\(sha256\) 32 4096 33f7dfa5163ca9f740383fb8b0919574e38 a7b20a94a4170fde4238196b7c4b4 $KEY_FILE 32
skipping to change at line 313 skipping to change at line 336
int_journal_crypt ctr-aes ctr\(aes\) $KEY_FILE 16 int_journal_crypt ctr-aes ctr\(aes\) $KEY_FILE 16
echo "Mode tests:" echo "Mode tests:"
int_mode crc32c 4 512 int_mode crc32c 4 512
int_mode crc32 4 512 int_mode crc32 4 512
int_mode sha1 20 512 int_mode sha1 20 512
int_mode sha256 32 512 int_mode sha256 32 512
int_mode hmac-sha256 32 512 $KEY_FILE 32 int_mode hmac-sha256 32 512 $KEY_FILE 32
int_mode hmac-sha256 32 4096 $KEY_FILE 32 int_mode hmac-sha256 32 4096 $KEY_FILE 32
echo -n "Recalculate tags in-kernel:"
add_device
if [ -n "$DM_INTEGRITY_RECALC" ] ; then
$INTSETUP format -q $DEV --no-wipe || fail "Cannot format device."
$INTSETUP open $DEV $DEV_NAME --integrity-recalculate || fail "Cannot act
ivate device."
dd if=/dev/mapper/$DEV_NAME of=/dev/null bs=1M 2>/dev/null || fail "Canno
t recalculate tags in-kernel"
int_check_sum_only 08f63eb27fb9ce2ce903b0a56429c68ce5e209253ba42154841ef0
45a53839d7
$INTSETUP close $DEV_NAME fail "Cannot deactivate device."
echo "[OK]"
else
echo "[N/A]"
fi
echo -n "Separate metadata device:"
if [ -n "$DM_INTEGRITY_META" ] ; then
add_device
$INTSETUP format -q $DEV --data-device $DEV2 || fail "Cannot format devic
e."
$INTSETUP open $DEV --data-device $DEV2 $DEV_NAME || fail "Cannot activat
e device."
int_check_sum_only 83ee47245398adee79bd9c0a8bc57b821e92aba10f5f9ade8a5d1f
ae4d8c4302
$INTSETUP status $DEV_NAME | grep -q 'metadata device:' || fail
$INTSETUP close $DEV_NAME fail "Cannot deactivate device."
echo "[OK]"
else
echo "[N/A]"
fi
cleanup cleanup
 End of changes. 9 change blocks. 
11 lines changed or deleted 67 lines changed or added

Home  |  About  |  Features  |  All  |  Newest  |  Dox  |  Diffs  |  RSS Feeds  |  Screenshots  |  Comments  |  Imprint  |  Privacy  |  HTTP(S)