1
0
mirror of https://git.FreeBSD.org/src.git synced 2024-12-19 10:53:58 +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 \
hmac/sha384 hmac/sha512; 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
geli detach ${md} 2>/dev/null
mdconfig -d -u ${md} 2>/dev/null
done
done
done
@ -46,7 +50,11 @@ for_each_geli_config_nointegrity() {
ealgo=${cipher%%:*}
keylen=${cipher##*:}
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
geli detach ${md} 2>/dev/null
mdconfig -d -u ${md} 2>/dev/null
done
done
}

View File

@ -15,7 +15,6 @@ do_test() {
ealgo=${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 attach -p -k $keyfile ${md}
@ -32,9 +31,6 @@ do_test() {
echo "not ok $i - aalgo=${aalgo} ealgo=${ealgo} keylen=${keylen} sec=${secsize}"
fi
i=$((i+1))
geli detach ${md}
mdconfig -d -u ${md}
}
echo "1..600"

View File

@ -16,8 +16,6 @@ do_test() {
ealgo=${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 attach -p -k $keyfile ${md}
@ -42,9 +40,6 @@ do_test() {
echo "not ok $i - ealgo=${ealgo} keylen=${keylen} sec=${secsize}"
fi
i=$((i+1))
geli detach ${md}
mdconfig -d -u ${md}
}
i=1

View File

@ -4,6 +4,7 @@
. $(dirname $0)/conf.sh
base=`basename $0`
sectors=2
keyfile=`mktemp $base.XXXXXX` || exit 1
sector=`mktemp $base.XXXXXX` || exit 1
@ -16,7 +17,6 @@ do_test() {
ealgo=${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 attach -p -k $keyfile ${md}
@ -65,18 +65,13 @@ do_test() {
# This should be detected as corruption.
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
geli attach -p -k $keyfile ${md}
dd if=/dev/${md}.eli of=/dev/null bs=${secsize} count=2 >/dev/null 2>&1
geli attach -p -k $keyfile ${md} 2>/dev/null
if [ $? -ne 0 ]; then
echo "ok $i - big 2 aalgo=${aalgo} ealgo=${ealgo} keylen=${keylen} sec=${secsize}"
else
echo "not ok $i - big 2 aalgo=${aalgo} ealgo=${ealgo} keylen=${keylen} sec=${secsize}"
fi
i=$((i+1))
geli detach ${md}
mdconfig -d -u ${md}
}

View File

@ -4,6 +4,7 @@
. $(dirname $0)/conf.sh
base=`basename $0`
sectors=2
keyfile=`mktemp $base.XXXXXX` || exit 1
sector=`mktemp $base.XXXXXX` || exit 1
@ -16,7 +17,6 @@ do_test() {
ealgo=${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
# Corrupt 8 bytes of data.
@ -32,9 +32,6 @@ do_test() {
echo "not ok $i - aalgo=${aalgo} ealgo=${ealgo} keylen=${keylen} sec=${secsize}"
fi
i=$((i+1))
geli detach ${md}
mdconfig -d -u ${md}
}
i=1

View File

@ -4,6 +4,7 @@
. $(dirname $0)/conf.sh
base=`basename $0`
sectors=2
keyfile=`mktemp $base.XXXXXX` || exit 1
sector=`mktemp $base.XXXXXX` || exit 1
@ -16,7 +17,6 @@ do_test() {
ealgo=${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
# Corrupt 8 bytes of HMAC.
@ -32,9 +32,6 @@ do_test() {
echo "not ok $i - aalgo=${aalgo} ealgo=${ealgo} keylen=${keylen} sec=${secsize}"
fi
i=$((i+1))
geli detach ${md}
mdconfig -d -u ${md}
}

View File

@ -16,7 +16,6 @@ do_test() {
ealgo=${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
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}"
fi
i=$((i+1))
geli detach ${md}
mdconfig -d -u ${md}
}
i=1

View File

@ -15,7 +15,6 @@ do_test() {
keylen=${cipher##*:}
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
@ -41,9 +40,7 @@ do_test() {
fi
i=$((i+1))
geli detach ${md}
rm -f $rnd
mdconfig -d -u ${md}
}
i=1