3 . $(atf_get_srcdir)/conf.sh
12 atf_check -s exit:0 -e ignore \
13 geli init -B none -a $aalgo -e $ealgo -l $keylen -P \
14 -K keyfile -s $secsize ${md}
15 atf_check geli attach -p -k keyfile ${md}
17 atf_check dd if=rnd of=/dev/${md}.eli bs=${secsize} count=1 status=none
19 # Copy first small sector to the second small sector.
20 # This should be detected as corruption.
21 atf_check dd if=backing_file of=sector bs=512 count=1 \
22 conv=notrunc status=none
23 atf_check dd if=sector of=backing_file bs=512 count=1 seek=1 \
24 conv=notrunc status=none
26 atf_check -s not-exit:0 -e ignore \
27 dd if=/dev/${md}.eli of=/dev/null bs=${secsize} count=1
30 atf_check dd if=rnd of=/dev/${md}.eli bs=${secsize} count=2 status=none
31 atf_check dd if=/dev/${md}.eli of=/dev/null bs=${secsize} count=2 \
34 # Copy first big sector to the second big sector.
35 # This should be detected as corruption.
36 ms=`diskinfo /dev/${md} | awk '{print $3 - 512}'`
37 ns=`diskinfo /dev/${md}.eli | awk '{print $4}'`
38 usecsize=`echo "($ms / $ns) - (($ms / $ns) % 512)" | bc`
39 atf_check dd if=backing_file bs=512 count=$(( ${usecsize} / 512 )) \
40 seek=$(( $secsize / 512 )) of=sector conv=notrunc status=none
41 atf_check dd of=backing_file bs=512 count=$(( ${usecsize} / 512 )) \
42 seek=$(( $secsize / 256 )) if=sector conv=notrunc status=none
43 atf_check -s not-exit:0 -e ignore \
44 dd if=/dev/${md}.eli of=/dev/null bs=${secsize} count=$ns
47 atf_test_case copy cleanup
50 atf_set "descr" "geli will detect misdirected writes as corruption"
51 atf_set "require.user" "root"
52 atf_set "timeout" 3600
60 atf_check dd if=/dev/random of=keyfile bs=512 count=16 status=none
61 dd if=/dev/random of=rnd bs=${MAX_SECSIZE} count=${sectors} status=none
63 for_each_geli_config copy_test backing_file
78 atf_check -s exit:0 -e ignore \
79 geli init -B none -a $aalgo -e $ealgo -l $keylen -P -K keyfile \
82 # Corrupt 8 bytes of data.
83 atf_check dd if=/dev/${md} of=sector bs=512 count=1 status=none
84 atf_check dd if=rnd of=sector bs=1 count=8 seek=64 conv=notrunc status=none
85 atf_check dd if=sector of=/dev/${md} bs=512 count=1 status=none
86 atf_check geli attach -p -k keyfile ${md}
88 # Try to read from the corrupt sector
89 atf_check -s not-exit:0 -e ignore \
90 dd if=/dev/${md}.eli of=/dev/null bs=${secsize} count=1
93 atf_test_case data cleanup
96 atf_set "descr" "With HMACs, geli will detect data corruption"
97 atf_set "require.user" "root"
98 atf_set "timeout" 1800
106 atf_check dd if=/dev/random of=keyfile bs=512 count=16 status=none
107 dd if=/dev/random of=rnd bs=${MAX_SECSIZE} count=${sectors} status=none
108 for_each_geli_config data_test
122 atf_check -s exit:0 -e ignore \
123 geli init -B none -a $aalgo -e $ealgo -l $keylen -P -K keyfile \
126 # Corrupt 8 bytes of HMAC.
127 atf_check dd if=/dev/${md} of=sector bs=512 count=1 status=none
128 atf_check dd if=rnd of=sector bs=1 count=16 conv=notrunc status=none
129 atf_check dd if=sector of=/dev/${md} bs=512 count=1 status=none
130 atf_check geli attach -p -k keyfile ${md}
132 # Try to read from the corrupt sector
133 atf_check -s not-exit:0 -e ignore \
134 dd if=/dev/${md}.eli of=/dev/null bs=${secsize} count=1
137 atf_test_case hmac cleanup
140 atf_set "descr" "geli will detect corruption of HMACs"
141 atf_set "require.user" "root"
142 atf_set "timeout" 1800
150 atf_check dd if=/dev/random of=keyfile bs=512 count=16 status=none
151 dd if=/dev/random of=rnd bs=${MAX_SECSIZE} count=${sectors} status=none
152 for_each_geli_config hmac_test
159 atf_init_test_cases()
161 atf_add_test_case copy
162 atf_add_test_case data
163 atf_add_test_case hmac