1 # $NetBSD: t_opencrypto.sh,v 1.6 2015/12/26 07:10:03 pgoyette Exp $
3 # Copyright (c) 2014 The NetBSD Foundation, Inc.
6 # Redistribution and use in source and binary forms, with or without
7 # modification, are permitted provided that the following conditions
9 # 1. Redistributions of source code must retain the above copyright
10 # notice, this list of conditions and the following disclaimer.
11 # 2. Redistributions in binary form must reproduce the above copyright
12 # notice, this list of conditions and the following disclaimer in the
13 # documentation and/or other materials provided with the distribution.
15 # THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
16 # ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
17 # TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
18 # PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
19 # BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
20 # CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
21 # SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
22 # INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
23 # CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
24 # ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
25 # POSSIBILITY OF SUCH DAMAGE.
28 # Start a rumpserver, load required modules, and set requires sysctl vars
31 rump_libs="-l rumpvfs -l rumpdev -l rumpdev_opencrypto"
32 rump_libs="${rump_libs} -l rumpkern_z -l rumpkern_crypto"
34 rump_server ${rump_libs} ${RUMP_SERVER} || \
37 rump.sysctl -w kern.cryptodevallowsoft=-1 && \
48 atf_set require.progs rump_server rump.sysctl rump.halt
54 start_rump || atf_skip "Cannot set-up rump environment"
55 LD_PRELOAD="/usr/lib/librumphijack.so" ; export LD_PRELOAD
56 RUMPHIJACK="blanket=/dev/crypto" ; export RUMPHIJACK
61 if [ $status -ne 0 ] ; then
62 atf_fail "$1 returned non-zero status, check output/error"
72 atf_test_case arc4 cleanup
74 common_head "Test ARC4 crypto"
78 atf_skip "ARC4 not implemented by swcrypto"
83 # No cleanup required since test is skipped. Trying to run rump.halt
84 # at this point fails, causing the ATF environment to erroneously
85 # report a failed test!
90 atf_test_case camellia cleanup
92 common_head "Test CAMELLIA_CBC crypto"
96 common_body h_camellia
103 atf_test_case cbcdes cleanup
105 common_head "Test DES_CBC crypto"
116 atf_test_case comp cleanup
118 common_head "Test GZIP_COMP Compression"
129 atf_test_case comp_deflate cleanup
130 comp_deflate_head() {
131 common_head "Test DEFLATE_COMP Compression"
134 comp_deflate_body() {
135 common_body h_comp_zlib
138 comp_deflate_cleanup() {
142 atf_test_case comp_zlib_rnd cleanup
143 comp_zlib_rnd_head() {
144 common_head "Test DEFLATE_COMP Compression with random data"
147 comp_zlib_rnd_body() {
148 common_body h_comp_zlib_rnd
151 comp_zlib_rnd_cleanup() {
155 atf_test_case aesctr1 cleanup
157 common_head "Test AES_CTR crypto"
161 common_body h_aesctr1
168 atf_test_case aesctr2 cleanup
170 common_head "Test AES_CTR crypto"
174 common_body h_aesctr2
181 atf_test_case gcm cleanup
183 common_head "Test AES_GCM_16 crypto"
194 atf_test_case md5 cleanup
196 common_head "Test MD5 crypto"
207 atf_test_case md5_hmac cleanup
209 common_head "Test MD5_HMAC crypto"
213 common_body h_md5hmac
220 atf_test_case null cleanup
222 common_head "Test NULL_CBC crypto"
233 atf_test_case sha1_hmac cleanup
235 common_head "Test SHA1_HMAC crypto"
239 common_body h_sha1hmac
242 sha1_hmac_cleanup() {
246 atf_test_case xcbcmac cleanup
248 common_head "Test XCBC_MAC_96 crypto"
252 common_body h_xcbcmac
259 atf_init_test_cases() {
260 RUMP_SERVER="unix://t_opencrypto_socket" ; export RUMP_SERVER
262 atf_add_test_case arc4
263 atf_add_test_case camellia
264 atf_add_test_case cbcdes
265 atf_add_test_case comp
266 atf_add_test_case comp_deflate
267 atf_add_test_case comp_zlib_rnd
268 atf_add_test_case aesctr1
269 atf_add_test_case aesctr2
270 atf_add_test_case gcm
271 atf_add_test_case md5
272 atf_add_test_case md5_hmac
273 atf_add_test_case null
274 atf_add_test_case sha1_hmac
275 atf_add_test_case xcbcmac