Update test OCSP script "tocsp" to use shell functions and to use
[openssl.git] / test / test_t4
1 #!/bin/sh
2
3 PROG=$1
4
5 if [ -x $PROG ]; then
6     if expr "x`$PROG version`" : "xOpenSSL" > /dev/null; then
7         :
8     else
9         echo "$PROG is not OpenSSL executable"
10         exit 1
11     fi
12 else
13     echo "$PROG is not executable"
14     exit 1;
15 fi
16
17 if [ 1 ]; then
18
19     HASH=`cat $PROG | $PROG dgst -hex`
20
21     AES_ALGS="  camellia-128-cbc camellia-128-cfb \
22                 camellia-192-cbc camellia-192-cfb \
23                 camellia-256-cbc camellia-256-cfb \
24                 aes-128-ctr aes-128-cbc aes-128-cfb aes-128-ofb \
25                 aes-192-ctr aes-192-cbc aes-192-cfb aes-192-ofb \
26                 aes-256-ctr aes-256-cbc aes-256-cfb aes-256-ofb"
27     BUFSIZE="16 32 48 999"
28
29     nerr=0
30
31     for alg in $AES_ALGS; do
32         echo $alg
33         for bufsize in $BUFSIZE; do
34             TEST=`(     cat $PROG | \
35                 $PROG enc -e -k "$HASH" -$alg -bufsize $bufsize | \
36                 env OPENSSL_sparcv9cap=0 $PROG enc -d -k "$HASH" -$alg | \
37                 $PROG dgst -hex ) 2>/dev/null`
38             if [ "$TEST" != "$HASH" ]; then
39                 echo "-$alg/$bufsize encrypt test failed"
40                 nerr=`expr $nerr + 1`
41             fi
42         done
43         for bufsize in $BUFSIZE; do 
44             TEST=`(     cat $PROG | \
45                 env OPENSSL_sparcv9cap=0 $PROG enc -e -k "$HASH" -$alg | \
46                 $PROG enc -d -k "$HASH" -$alg -bufsize $bufsize | \
47                 $PROG dgst -hex ) 2>/dev/null`
48             if [ "$TEST" != "$HASH" ]; then
49                 echo "-$alg/$bufsize decrypt test failed"
50                 nerr=`expr $nerr + 1`
51             fi
52         done
53         TEST=`( cat $PROG | \
54                 $PROG enc -e -k "$HASH" -$alg | \
55                 $PROG enc -d -k "$HASH" -$alg | \
56                 $PROG dgst -hex ) 2>/dev/null`
57         if [ "$TEST" != "$HASH" ]; then
58                 echo "-$alg en/decrypt test failed"
59                 nerr=`expr $nerr + 1`
60         fi
61     done
62
63     if [ $nerr -gt 0 ]; then
64         echo "SPARC T4 test failed."
65         exit 1
66     fi
67 fi
68
69 exit 0