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