1ebfedea0SLionel Sambuc#!/bin/sh 2ebfedea0SLionel Sambuc# 3ebfedea0SLionel Sambuc# Copyright (c) 2006 - 2007 Kungliga Tekniska Högskolan 4ebfedea0SLionel Sambuc# (Royal Institute of Technology, Stockholm, Sweden). 5ebfedea0SLionel Sambuc# All rights reserved. 6ebfedea0SLionel Sambuc# 7ebfedea0SLionel Sambuc# Redistribution and use in source and binary forms, with or without 8ebfedea0SLionel Sambuc# modification, are permitted provided that the following conditions 9ebfedea0SLionel Sambuc# are met: 10ebfedea0SLionel Sambuc# 11ebfedea0SLionel Sambuc# 1. Redistributions of source code must retain the above copyright 12ebfedea0SLionel Sambuc# notice, this list of conditions and the following disclaimer. 13ebfedea0SLionel Sambuc# 14ebfedea0SLionel Sambuc# 2. Redistributions in binary form must reproduce the above copyright 15ebfedea0SLionel Sambuc# notice, this list of conditions and the following disclaimer in the 16ebfedea0SLionel Sambuc# documentation and/or other materials provided with the distribution. 17ebfedea0SLionel Sambuc# 18ebfedea0SLionel Sambuc# 3. Neither the name of the Institute nor the names of its contributors 19ebfedea0SLionel Sambuc# may be used to endorse or promote products derived from this software 20ebfedea0SLionel Sambuc# without specific prior written permission. 21ebfedea0SLionel Sambuc# 22ebfedea0SLionel Sambuc# THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND 23ebfedea0SLionel Sambuc# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 24ebfedea0SLionel Sambuc# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 25ebfedea0SLionel Sambuc# ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE 26ebfedea0SLionel Sambuc# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 27ebfedea0SLionel Sambuc# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 28ebfedea0SLionel Sambuc# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 29ebfedea0SLionel Sambuc# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 30ebfedea0SLionel Sambuc# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 31ebfedea0SLionel Sambuc# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 32ebfedea0SLionel Sambuc# SUCH DAMAGE. 33ebfedea0SLionel Sambuc# 34ebfedea0SLionel Sambuc# Id 35ebfedea0SLionel Sambuc# 36ebfedea0SLionel Sambuc 37ebfedea0SLionel Sambucsrcdir="@srcdir@" 38ebfedea0SLionel Sambuc 39ebfedea0SLionel Sambucrsa="${TESTS_ENVIRONMENT} ./test_rsa@exeext@" 40ebfedea0SLionel Sambucengine="${TESTS_ENVIRONMENT} ./test_engine_dso@exeext@" 41ebfedea0SLionel Sambucrand="${TESTS_ENVIRONMENT} ./test_rand@exeext@" 42ebfedea0SLionel Sambuc 43ebfedea0SLionel Sambuc${engine} --test-random > /dev/null || { echo "missing random"; exit 77; } 44ebfedea0SLionel Sambuc 45ebfedea0SLionel Sambuc${rsa} --key=${srcdir}/rsakey.der || \ 46ebfedea0SLionel Sambuc { echo "rsa test failed" ; exit 1; } 47ebfedea0SLionel Sambuc 48ebfedea0SLionel Sambuc${rsa} --time-key=${srcdir}/rsakey.der || \ 49ebfedea0SLionel Sambuc { echo "rsa test failed" ; exit 1; } 50ebfedea0SLionel Sambuc 51ebfedea0SLionel Sambuc${rsa} --time-key=${srcdir}/rsakey2048.der || \ 52ebfedea0SLionel Sambuc { echo "rsa test failed" ; exit 1; } 53ebfedea0SLionel Sambuc 54ebfedea0SLionel Sambuc${rsa} --time-key=generate || \ 55ebfedea0SLionel Sambuc { echo "rsa test failed" ; exit 1; } 56ebfedea0SLionel Sambuc 57ebfedea0SLionel Sambuc${engine} --rsa=${srcdir}/rsakey.der || \ 58ebfedea0SLionel Sambuc { echo "engine test failed" ; exit 1; } 59ebfedea0SLionel Sambuc 60ebfedea0SLionel Sambuc${rsa} --loops=4 || { echo "rsa test for 4 loops failed" ; exit 1; } 61ebfedea0SLionel Sambuc 62ebfedea0SLionel Sambucfor a in unix fortuna egd w32crypto ;do 63ebfedea0SLionel Sambuc ${rand} --method=${a} --file=crypto-test 2>error 64ebfedea0SLionel Sambuc res=$? 65ebfedea0SLionel Sambuc if test "X$res" != X0 ; then 66ebfedea0SLionel Sambuc grep "unknown method" error && \ 67ebfedea0SLionel Sambuc { echo "random $a is not available" ; continue; } 68ebfedea0SLionel Sambuc grep "random not ready yet" error || \ 69ebfedea0SLionel Sambuc { echo "random $a ready failing" ; cat error; exit 1; } 70ebfedea0SLionel Sambuc echo "random method $a out for lunch" 71ebfedea0SLionel Sambuc continue 72ebfedea0SLionel Sambuc fi 73ebfedea0SLionel Sambuc ${rand} --method=${a} --file=crypto-test2 2>error 74ebfedea0SLionel Sambuc res=$? 75ebfedea0SLionel Sambuc if test "X$res" != X0 ; then 76ebfedea0SLionel Sambuc grep "random not ready yet" error || \ 77ebfedea0SLionel Sambuc { echo "random $a ready failing" ; cat error; exit 1; } 78ebfedea0SLionel Sambuc echo "random metod $a out for dinner" 79ebfedea0SLionel Sambuc continue 80ebfedea0SLionel Sambuc fi 81*0a6a1f1dSLionel Sambuc cmp crypto-test crypto-test2 >/dev/null 2>/dev/null && \ 82*0a6a1f1dSLionel Sambuc { echo "rand output same!" ; exit 1; } 83ebfedea0SLionel Sambucdone 84ebfedea0SLionel Sambuc 85ebfedea0SLionel Sambuc./example_evp_cipher 1 ${srcdir}/test_crypto.in test-out-1 || \ 86ebfedea0SLionel Sambuc { echo "1 failed" ; exit 1; } 87ebfedea0SLionel Sambuc 88ebfedea0SLionel Sambucfor a in 7 15 16 17 31 32 33 ; do 89ebfedea0SLionel Sambuc ./example_evp_cipher $a ${srcdir}/test_crypto.in test-out-$a 90ebfedea0SLionel Sambuc cmp test-out-1 test-out-$a || { echo "cmp $a failed" ; exit 1; } 91ebfedea0SLionel Sambucdone 92ebfedea0SLionel Sambuc 93ebfedea0SLionel Sambuc# 94ebfedea0SLionel Sambuc# Last time we run is w/o HOME and RANDFILE to make sure we can do 95ebfedea0SLionel Sambuc# RAND_file_name() when the enviroment is lacking those. 96ebfedea0SLionel Sambuc# 97ebfedea0SLionel Sambuc 98*0a6a1f1dSLionel Sambucif [ -r /dev/random -o -r /dev/urandom -o -r /dev/srandom -o -r /dev/arandom ] ; then 99ebfedea0SLionel Sambuc 100ebfedea0SLionel Sambuc # try hard to unset HOME and RANDFILE 101ebfedea0SLionel Sambuc HOME= 102ebfedea0SLionel Sambuc RANDFILE= 103ebfedea0SLionel Sambuc 104ebfedea0SLionel Sambuc unset HOME 105ebfedea0SLionel Sambuc unset RANDFILE 106ebfedea0SLionel Sambuc 107ebfedea0SLionel Sambuc ${rand} --method=unix --file=unix 2>error 108ebfedea0SLionel Sambuc res=$? 109ebfedea0SLionel Sambuc if test "X$res" != X0 ; then 110ebfedea0SLionel Sambuc grep "unknown method" error && \ 111ebfedea0SLionel Sambuc { echo "random unix is not available"; exit 0; } 112ebfedea0SLionel Sambuc grep "random not ready yet" error || \ 113ebfedea0SLionel Sambuc { echo "random unix ready failing" ; cat error; exit 1; } 114ebfedea0SLionel Sambuc echo "random method unix out for lunch" 115ebfedea0SLionel Sambuc continue 116ebfedea0SLionel Sambuc fi 117ebfedea0SLionel Sambuc 118ebfedea0SLionel Sambucfi 119ebfedea0SLionel Sambuc 120ebfedea0SLionel Sambucexit 0 121