1#!/bin/sh 2# $FreeBSD$ 3 4class="eli" 5base=$(atf_get ident) 6MAX_SECSIZE=8192 7TEST_MDS_FILE=md.devs 8 9attach_md() 10{ 11 local test_md 12 13 test_md=$(mdconfig -a "$@") || atf_fail "failed to allocate md(4)" 14 echo $test_md >> $TEST_MDS_FILE || exit 15 echo $test_md 16} 17 18# Execute `func` for each combination of cipher, sectorsize, and hmac algo 19# `func` usage should be: 20# func <cipher> <aalgo> <secsize> 21for_each_geli_config() { 22 func=$1 23 backing_filename=$2 24 25 # Double the sector size to allow for the HMACs' storage space. 26 osecsize=$(( $MAX_SECSIZE * 2 )) 27 # geli needs 512B for the label. 28 bytes=`expr $osecsize \* $sectors + 512`b 29 30 if [ -n "$backing_filename" ]; then 31 # Use a file-backed md(4) device, so we can deliberatly corrupt 32 # it without detaching the geli device first. 33 truncate -s $bytes backing_file 34 md=$(attach_md -t vnode -f backing_file) 35 else 36 md=$(attach_md -t malloc -s $bytes) 37 fi 38 39 for cipher in aes-xts:128 aes-xts:256 \ 40 aes-cbc:128 aes-cbc:192 aes-cbc:256 \ 41 3des-cbc:192 \ 42 blowfish-cbc:128 blowfish-cbc:160 blowfish-cbc:192 \ 43 blowfish-cbc:224 blowfish-cbc:256 blowfish-cbc:288 \ 44 blowfish-cbc:320 blowfish-cbc:352 blowfish-cbc:384 \ 45 blowfish-cbc:416 blowfish-cbc:448 \ 46 camellia-cbc:128 camellia-cbc:192 camellia-cbc:256; do 47 ealgo=${cipher%%:*} 48 keylen=${cipher##*:} 49 for aalgo in hmac/md5 hmac/sha1 hmac/ripemd160 hmac/sha256 \ 50 hmac/sha384 hmac/sha512; do 51 for secsize in 512 1024 2048 4096 $MAX_SECSIZE; do 52 ${func} $cipher $aalgo $secsize 53 geli detach ${md} 2>/dev/null 54 done 55 done 56 done 57} 58 59# Execute `func` for each combination of cipher, and sectorsize, with no hmac 60# `func` usage should be: 61# func <cipher> <secsize> 62for_each_geli_config_nointegrity() { 63 func=$1 64 65 # geli needs 512B for the label. 66 bytes=`expr $MAX_SECSIZE \* $sectors + 512`b 67 md=$(attach_md -t malloc -s $bytes) 68 for cipher in aes-xts:128 aes-xts:256 \ 69 aes-cbc:128 aes-cbc:192 aes-cbc:256 \ 70 3des-cbc:192 \ 71 blowfish-cbc:128 blowfish-cbc:160 blowfish-cbc:192 \ 72 blowfish-cbc:224 blowfish-cbc:256 blowfish-cbc:288 \ 73 blowfish-cbc:320 blowfish-cbc:352 blowfish-cbc:384 \ 74 blowfish-cbc:416 blowfish-cbc:448 \ 75 camellia-cbc:128 camellia-cbc:192 camellia-cbc:256; do 76 ealgo=${cipher%%:*} 77 keylen=${cipher##*:} 78 for secsize in 512 1024 2048 4096 $MAX_SECSIZE; do 79 ${func} $cipher $secsize 80 geli detach ${md} 2>/dev/null 81 done 82 done 83} 84 85 86geli_test_cleanup() 87{ 88 if [ -f "$TEST_MDS_FILE" ]; then 89 while read md; do 90 [ -c /dev/${md}.eli ] && \ 91 geli detach $md.eli 2>/dev/null 92 mdconfig -d -u $md 2>/dev/null 93 done < $TEST_MDS_FILE 94 fi 95 true 96} 97 98. `dirname $0`/../geom_subr.sh 99