1# $FreeBSD$ 2 3onetime_test() 4{ 5 cipher=$1 6 secsize=$2 7 ealgo=${cipher%%:*} 8 keylen=${cipher##*:} 9 10 atf_check -s exit:0 -o ignore -e ignore \ 11 geli onetime -e $ealgo -l $keylen -s $secsize ${md} 12 13 atf_check dd if=rnd of=/dev/${md}.eli bs=${secsize} count=${sectors} status=none 14 15 md_rnd=`dd if=rnd bs=${secsize} count=${sectors} status=none | md5` 16 atf_check_equal 0 $? 17 md_ddev=`dd if=/dev/${md}.eli bs=${secsize} count=${sectors} status=none | md5` 18 atf_check_equal 0 $? 19 md_edev=`dd if=/dev/${md} bs=${secsize} count=${sectors} status=none | md5` 20 atf_check_equal 0 $? 21 22 if [ ${md_rnd} != ${md_ddev} ]; then 23 atf_fail "geli did not return the original data" 24 fi 25 if [ ${md_rnd} == ${md_edev} ]; then 26 atf_fail "geli did not encrypt the data" 27 fi 28} 29atf_test_case onetime cleanup 30onetime_head() 31{ 32 atf_set "descr" "geli onetime can create temporary providers" 33 atf_set "require.user" "root" 34 atf_set "timeout" 1800 35} 36onetime_body() 37{ 38 . $(atf_get_srcdir)/conf.sh 39 sectors=100 40 41 dd if=/dev/random of=rnd bs=${MAX_SECSIZE} count=${sectors} status=none 42 for_each_geli_config_nointegrity onetime_test 43} 44onetime_cleanup() 45{ 46 . $(atf_get_srcdir)/conf.sh 47 geli_test_cleanup 48} 49 50onetime_a_test() 51{ 52 cipher=$1 53 aalgo=$2 54 secsize=$3 55 ealgo=${cipher%%:*} 56 keylen=${cipher##*:} 57 58 atf_check -s exit:0 -o ignore -e ignore \ 59 geli onetime -a $aalgo -e $ealgo -l $keylen -s $secsize ${md} 60 61 atf_check dd if=rnd of=/dev/${md}.eli bs=${secsize} count=${sectors} status=none 62 63 md_rnd=`dd if=rnd bs=${secsize} count=${sectors} status=none | md5` 64 atf_check_equal 0 $? 65 md_ddev=`dd if=/dev/${md}.eli bs=${secsize} count=${sectors} status=none | md5` 66 atf_check_equal 0 $? 67 68 if [ ${md_rnd} != ${md_ddev} ]; then 69 atf_fail "Miscompare for aalgo=${aalgo} ealgo=${ealgo} keylen=${keylen} sec=${secsize}" 70 fi 71} 72atf_test_case onetime_a cleanup 73onetime_a_head() 74{ 75 atf_set "descr" "geli onetime with HMACs" 76 atf_set "require.user" "root" 77 atf_set "timeout" 1800 78} 79onetime_a_body() 80{ 81 . $(atf_get_srcdir)/conf.sh 82 sectors=8 83 84 atf_check dd if=/dev/random of=rnd bs=$MAX_SECSIZE count=$sectors \ 85 status=none 86 for_each_geli_config onetime_a_test 87} 88onetime_a_cleanup() 89{ 90 . $(atf_get_srcdir)/conf.sh 91 geli_test_cleanup 92} 93 94atf_test_case onetime_d cleanup 95onetime_d_head() 96{ 97 atf_set "descr" "geli onetime -d will create providers that detach on last close" 98 atf_set "require.user" "root" 99} 100onetime_d_body() 101{ 102 . $(atf_get_srcdir)/conf.sh 103 104 sectors=100 105 md=$(attach_md -t malloc -s $sectors) 106 107 atf_check geli onetime -d ${md} 108 if [ ! -c /dev/${md}.eli ]; then 109 atf_fail "Provider not created, or immediately detached" 110 fi 111 112 # Be sure it doesn't detach on read. 113 atf_check dd if=/dev/${md}.eli of=/dev/null status=none 114 sleep 1 115 if [ ! -c /dev/${md}.eli ]; then 116 atf_fail "Provider detached when a reader closed" 117 fi 118 119 # It should detach when a writer closes 120 true > /dev/${md}.eli 121 sleep 1 122 if [ -c /dev/${md}.eli ]; then 123 atf_fail "Provider didn't detach on last close of a writer" 124 fi 125} 126onetime_d_cleanup() 127{ 128 . $(atf_get_srcdir)/conf.sh 129 geli_test_cleanup 130} 131 132atf_init_test_cases() 133{ 134 atf_add_test_case onetime 135 atf_add_test_case onetime_a 136 atf_add_test_case onetime_d 137} 138