xref: /freebsd/tests/sys/geom/class/eli/conf.sh (revision d8a0fe102c0cfdfcd5b818f850eff09d8536c9bc)
1#!/bin/sh
2# $FreeBSD$
3
4class="eli"
5base=`basename $0`
6
7# Execute `func` for each combination of cipher, sectorsize, and hmac algo
8# `func` usage should be:
9# func <cipher> <aalgo> <secsize>
10for_each_geli_config() {
11	func=$1
12
13	for cipher in aes-xts:128 aes-xts:256 \
14	    aes-cbc:128 aes-cbc:192 aes-cbc:256 \
15	    3des-cbc:192 \
16	    blowfish-cbc:128 blowfish-cbc:160 blowfish-cbc:192 \
17	    blowfish-cbc:224 blowfish-cbc:256 blowfish-cbc:288 \
18	    blowfish-cbc:320 blowfish-cbc:352 blowfish-cbc:384 \
19	    blowfish-cbc:416 blowfish-cbc:448 \
20	    camellia-cbc:128 camellia-cbc:192 camellia-cbc:256; do
21		ealgo=${cipher%%:*}
22		keylen=${cipher##*:}
23		for aalgo in hmac/md5 hmac/sha1 hmac/ripemd160 hmac/sha256 \
24		    hmac/sha384 hmac/sha512; do
25			for secsize in 512 1024 2048 4096 8192; do
26				bytes=`expr $secsize \* $sectors + 512`b
27				md=$(attach_md -t malloc -s $bytes)
28				${func} $cipher $aalgo $secsize
29				geli detach ${md} 2>/dev/null
30				mdconfig -d -u ${md} 2>/dev/null
31			done
32		done
33	done
34}
35
36# Execute `func` for each combination of cipher, and sectorsize, with no hmac
37# `func` usage should be:
38# func <cipher> <secsize>
39for_each_geli_config_nointegrity() {
40	func=$1
41
42	for cipher in aes-xts:128 aes-xts:256 \
43	    aes-cbc:128 aes-cbc:192 aes-cbc:256 \
44	    3des-cbc:192 \
45	    blowfish-cbc:128 blowfish-cbc:160 blowfish-cbc:192 \
46	    blowfish-cbc:224 blowfish-cbc:256 blowfish-cbc:288 \
47	    blowfish-cbc:320 blowfish-cbc:352 blowfish-cbc:384 \
48	    blowfish-cbc:416 blowfish-cbc:448 \
49	    camellia-cbc:128 camellia-cbc:192 camellia-cbc:256; do
50		ealgo=${cipher%%:*}
51		keylen=${cipher##*:}
52		for secsize in 512 1024 2048 4096 8192; do
53			bytes=`expr $secsize \* $sectors + 512`b
54			md=$(attach_md -t malloc -s $bytes)
55			${func} $cipher $secsize
56			geli detach ${md} 2>/dev/null
57			mdconfig -d -u ${md} 2>/dev/null
58		done
59	done
60}
61
62
63geli_test_cleanup()
64{
65	if [ -f "$TEST_MDS_FILE" ]; then
66		while read md; do
67			[ -c /dev/${md}.eli ] && \
68				geli detach $md.eli 2>/dev/null
69			mdconfig -d -u $md 2>/dev/null
70		done < $TEST_MDS_FILE
71	fi
72	rm -f "$TEST_MDS_FILE"
73}
74trap geli_test_cleanup ABRT EXIT INT TERM
75
76. `dirname $0`/../geom_subr.sh
77