1
0
mirror of https://git.FreeBSD.org/src.git synced 2024-12-23 11:18:54 +00:00

geli: factor out some common code in the geli tests

No functional change.

MFC after:	2 weeks
Sponsored by:	Spectra Logic Corp
This commit is contained in:
Alan Somers 2017-12-29 16:13:06 +00:00
parent 041999e3d0
commit 2e23c41122
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=327347
8 changed files with 12 additions and 31 deletions

View File

@ -23,7 +23,11 @@ for_each_geli_config() {
for aalgo in hmac/md5 hmac/sha1 hmac/ripemd160 hmac/sha256 \ for aalgo in hmac/md5 hmac/sha1 hmac/ripemd160 hmac/sha256 \
hmac/sha384 hmac/sha512; do hmac/sha384 hmac/sha512; do
for secsize in 512 1024 2048 4096 8192; do for secsize in 512 1024 2048 4096 8192; do
bytes=`expr $secsize \* $sectors + 512`b
md=$(attach_md -t malloc -s $bytes)
${func} $cipher $aalgo $secsize ${func} $cipher $aalgo $secsize
geli detach ${md} 2>/dev/null
mdconfig -d -u ${md} 2>/dev/null
done done
done done
done done
@ -46,7 +50,11 @@ for_each_geli_config_nointegrity() {
ealgo=${cipher%%:*} ealgo=${cipher%%:*}
keylen=${cipher##*:} keylen=${cipher##*:}
for secsize in 512 1024 2048 4096 8192; do for secsize in 512 1024 2048 4096 8192; do
bytes=`expr $secsize \* $sectors + 512`b
md=$(attach_md -t malloc -s $bytes)
${func} $cipher $aalgo $secsize ${func} $cipher $aalgo $secsize
geli detach ${md} 2>/dev/null
mdconfig -d -u ${md} 2>/dev/null
done done
done done
} }

View File

@ -15,7 +15,6 @@ do_test() {
ealgo=${cipher%%:*} ealgo=${cipher%%:*}
keylen=${cipher##*:} keylen=${cipher##*:}
md=$(attach_md -t malloc -s `expr $secsize \* $sectors + 512`b)
geli init -B none -a $aalgo -e $ealgo -l $keylen -P -K $keyfile -s $secsize ${md} 2>/dev/null geli init -B none -a $aalgo -e $ealgo -l $keylen -P -K $keyfile -s $secsize ${md} 2>/dev/null
geli attach -p -k $keyfile ${md} geli attach -p -k $keyfile ${md}
@ -32,9 +31,6 @@ do_test() {
echo "not ok $i - aalgo=${aalgo} ealgo=${ealgo} keylen=${keylen} sec=${secsize}" echo "not ok $i - aalgo=${aalgo} ealgo=${ealgo} keylen=${keylen} sec=${secsize}"
fi fi
i=$((i+1)) i=$((i+1))
geli detach ${md}
mdconfig -d -u ${md}
} }
echo "1..600" echo "1..600"

View File

@ -16,8 +16,6 @@ do_test() {
ealgo=${cipher%%:*} ealgo=${cipher%%:*}
keylen=${cipher##*:} keylen=${cipher##*:}
md=$(attach_md -t malloc -s `expr $secsize \* $sectors + 512`b)
geli init -B none -e $ealgo -l $keylen -P -K $keyfile -s $secsize ${md} 2>/dev/null geli init -B none -e $ealgo -l $keylen -P -K $keyfile -s $secsize ${md} 2>/dev/null
geli attach -p -k $keyfile ${md} geli attach -p -k $keyfile ${md}
@ -42,9 +40,6 @@ do_test() {
echo "not ok $i - ealgo=${ealgo} keylen=${keylen} sec=${secsize}" echo "not ok $i - ealgo=${ealgo} keylen=${keylen} sec=${secsize}"
fi fi
i=$((i+1)) i=$((i+1))
geli detach ${md}
mdconfig -d -u ${md}
} }
i=1 i=1

View File

@ -4,6 +4,7 @@
. $(dirname $0)/conf.sh . $(dirname $0)/conf.sh
base=`basename $0` base=`basename $0`
sectors=2
keyfile=`mktemp $base.XXXXXX` || exit 1 keyfile=`mktemp $base.XXXXXX` || exit 1
sector=`mktemp $base.XXXXXX` || exit 1 sector=`mktemp $base.XXXXXX` || exit 1
@ -16,7 +17,6 @@ do_test() {
ealgo=${cipher%%:*} ealgo=${cipher%%:*}
keylen=${cipher##*:} keylen=${cipher##*:}
md=$(attach_md -t malloc -s `expr $secsize \* 2 + 512`b)
geli init -B none -a $aalgo -e $ealgo -l $keylen -P -K $keyfile -s $secsize ${md} 2>/dev/null geli init -B none -a $aalgo -e $ealgo -l $keylen -P -K $keyfile -s $secsize ${md} 2>/dev/null
geli attach -p -k $keyfile ${md} geli attach -p -k $keyfile ${md}
@ -65,18 +65,13 @@ do_test() {
# This should be detected as corruption. # This should be detected as corruption.
dd if=/dev/${md} of=${sector} bs=${usecsize} count=1 >/dev/null 2>&1 dd if=/dev/${md} of=${sector} bs=${usecsize} count=1 >/dev/null 2>&1
dd if=${sector} of=/dev/${md} bs=${usecsize} count=1 seek=1 >/dev/null 2>&1 dd if=${sector} of=/dev/${md} bs=${usecsize} count=1 seek=1 >/dev/null 2>&1
geli attach -p -k $keyfile ${md} geli attach -p -k $keyfile ${md} 2>/dev/null
dd if=/dev/${md}.eli of=/dev/null bs=${secsize} count=2 >/dev/null 2>&1
if [ $? -ne 0 ]; then if [ $? -ne 0 ]; then
echo "ok $i - big 2 aalgo=${aalgo} ealgo=${ealgo} keylen=${keylen} sec=${secsize}" echo "ok $i - big 2 aalgo=${aalgo} ealgo=${ealgo} keylen=${keylen} sec=${secsize}"
else else
echo "not ok $i - big 2 aalgo=${aalgo} ealgo=${ealgo} keylen=${keylen} sec=${secsize}" echo "not ok $i - big 2 aalgo=${aalgo} ealgo=${ealgo} keylen=${keylen} sec=${secsize}"
fi fi
i=$((i+1)) i=$((i+1))
geli detach ${md}
mdconfig -d -u ${md}
} }

View File

@ -4,6 +4,7 @@
. $(dirname $0)/conf.sh . $(dirname $0)/conf.sh
base=`basename $0` base=`basename $0`
sectors=2
keyfile=`mktemp $base.XXXXXX` || exit 1 keyfile=`mktemp $base.XXXXXX` || exit 1
sector=`mktemp $base.XXXXXX` || exit 1 sector=`mktemp $base.XXXXXX` || exit 1
@ -16,7 +17,6 @@ do_test() {
ealgo=${cipher%%:*} ealgo=${cipher%%:*}
keylen=${cipher##*:} keylen=${cipher##*:}
md=$(attach_md -t malloc -s `expr $secsize \* 2 + 512`b)
geli init -B none -a $aalgo -e $ealgo -l $keylen -P -K $keyfile -s $secsize ${md} 2>/dev/null geli init -B none -a $aalgo -e $ealgo -l $keylen -P -K $keyfile -s $secsize ${md} 2>/dev/null
# Corrupt 8 bytes of data. # Corrupt 8 bytes of data.
@ -32,9 +32,6 @@ do_test() {
echo "not ok $i - aalgo=${aalgo} ealgo=${ealgo} keylen=${keylen} sec=${secsize}" echo "not ok $i - aalgo=${aalgo} ealgo=${ealgo} keylen=${keylen} sec=${secsize}"
fi fi
i=$((i+1)) i=$((i+1))
geli detach ${md}
mdconfig -d -u ${md}
} }
i=1 i=1

View File

@ -4,6 +4,7 @@
. $(dirname $0)/conf.sh . $(dirname $0)/conf.sh
base=`basename $0` base=`basename $0`
sectors=2
keyfile=`mktemp $base.XXXXXX` || exit 1 keyfile=`mktemp $base.XXXXXX` || exit 1
sector=`mktemp $base.XXXXXX` || exit 1 sector=`mktemp $base.XXXXXX` || exit 1
@ -16,7 +17,6 @@ do_test() {
ealgo=${cipher%%:*} ealgo=${cipher%%:*}
keylen=${cipher##*:} keylen=${cipher##*:}
md=$(attach_md -t malloc -s `expr $secsize \* 2 + 512`b)
geli init -B none -a $aalgo -e $ealgo -l $keylen -P -K $keyfile -s $secsize ${md} 2>/dev/null geli init -B none -a $aalgo -e $ealgo -l $keylen -P -K $keyfile -s $secsize ${md} 2>/dev/null
# Corrupt 8 bytes of HMAC. # Corrupt 8 bytes of HMAC.
@ -32,9 +32,6 @@ do_test() {
echo "not ok $i - aalgo=${aalgo} ealgo=${ealgo} keylen=${keylen} sec=${secsize}" echo "not ok $i - aalgo=${aalgo} ealgo=${ealgo} keylen=${keylen} sec=${secsize}"
fi fi
i=$((i+1)) i=$((i+1))
geli detach ${md}
mdconfig -d -u ${md}
} }

View File

@ -16,7 +16,6 @@ do_test() {
ealgo=${cipher%%:*} ealgo=${cipher%%:*}
keylen=${cipher##*:} keylen=${cipher##*:}
md=$(attach_md -t malloc -s `expr $secsize \* $sectors + 512`b)
geli onetime -a $aalgo -e $ealgo -l $keylen -s $secsize ${md} 2>/dev/null geli onetime -a $aalgo -e $ealgo -l $keylen -s $secsize ${md} 2>/dev/null
secs=`diskinfo /dev/${md}.eli | awk '{print $4}'` secs=`diskinfo /dev/${md}.eli | awk '{print $4}'`
@ -32,9 +31,6 @@ do_test() {
echo "not ok $i - aalgo=${aalgo} ealgo=${ealgo} keylen=${keylen} sec=${secsize}" echo "not ok $i - aalgo=${aalgo} ealgo=${ealgo} keylen=${keylen} sec=${secsize}"
fi fi
i=$((i+1)) i=$((i+1))
geli detach ${md}
mdconfig -d -u ${md}
} }
i=1 i=1

View File

@ -15,7 +15,6 @@ do_test() {
keylen=${cipher##*:} keylen=${cipher##*:}
rnd=`mktemp $base.XXXXXX` || exit 1 rnd=`mktemp $base.XXXXXX` || exit 1
md=$(attach_md -t malloc -s `expr $secsize \* $sectors`b)
geli onetime -e $ealgo -l $keylen -s $secsize ${md} 2>/dev/null geli onetime -e $ealgo -l $keylen -s $secsize ${md} 2>/dev/null
@ -41,9 +40,7 @@ do_test() {
fi fi
i=$((i+1)) i=$((i+1))
geli detach ${md}
rm -f $rnd rm -f $rnd
mdconfig -d -u ${md}
} }
i=1 i=1