consistent test-start logging
[openssl.git] / test / testssl
1 #!/bin/sh
2
3 if [ "$1" = "" ]; then
4   key=../apps/server.pem
5 else
6   key="$1"
7 fi
8 if [ "$2" = "" ]; then
9   cert=../apps/server.pem
10 else
11   cert="$2"
12 fi
13 OPENSSL_CONF=/dev/null ; export OPENSSL_CONF
14 ssltest="../util/shlib_wrap.sh ./ssltest -key $key -cert $cert -c_key $key -c_cert $cert"
15
16 if ../util/shlib_wrap.sh ../apps/openssl x509 -in $cert -text -noout | fgrep 'DSA Public Key' >/dev/null; then
17   dsa_cert=YES
18 else
19   dsa_cert=NO
20 fi
21
22 if [ "$3" = "" ]; then
23   CA="-CApath ../certs"
24 else
25   CA="-CAfile $3"
26 fi
27
28 if [ "$4" = "" ]; then
29   extra=""
30 else
31   extra="$4"
32 fi
33
34 serverinfo="./serverinfo.pem"
35
36 #############################################################################
37
38 echo test sslv3
39 $ssltest -ssl3 $extra || exit 1
40
41 echo test sslv3 with server authentication
42 $ssltest -ssl3 -server_auth $CA $extra || exit 1
43
44 echo test sslv3 with client authentication
45 $ssltest -ssl3 -client_auth $CA $extra || exit 1
46
47 echo test sslv3 with both client and server authentication
48 $ssltest -ssl3 -server_auth -client_auth $CA $extra || exit 1
49
50 echo test sslv2/sslv3
51 $ssltest $extra || exit 1
52
53 echo test sslv2/sslv3 with server authentication
54 $ssltest -server_auth $CA $extra || exit 1
55
56 echo test sslv2/sslv3 with client authentication
57 $ssltest -client_auth $CA $extra || exit 1
58
59 echo test sslv2/sslv3 with both client and server authentication
60 $ssltest -server_auth -client_auth $CA $extra || exit 1
61
62 echo test sslv3 via BIO pair
63 $ssltest -bio_pair -ssl3 $extra || exit 1
64
65 echo test sslv3 with server authentication via BIO pair
66 $ssltest -bio_pair -ssl3 -server_auth $CA $extra || exit 1
67
68 echo test sslv3 with client authentication via BIO pair
69 $ssltest -bio_pair -ssl3 -client_auth $CA $extra || exit 1
70
71 echo test sslv3 with both client and server authentication via BIO pair
72 $ssltest -bio_pair -ssl3 -server_auth -client_auth $CA $extra || exit 1
73
74 echo test sslv2/sslv3 via BIO pair
75 $ssltest $extra || exit 1
76
77 echo test dtlsv1
78 $ssltest -dtls1 $extra || exit 1
79
80 echo test dtlsv1 with server authentication
81 $ssltest -dtls1 -server_auth $CA $extra || exit 1
82
83 echo test dtlsv1 with client authentication
84 $ssltest -dtls1 -client_auth $CA $extra || exit 1
85
86 echo test dtlsv1 with both client and server authentication
87 $ssltest -dtls1 -server_auth -client_auth $CA $extra || exit 1
88
89 echo test dtlsv1.2
90 $ssltest -dtls12 $extra || exit 1
91
92 echo test dtlsv1.2 with server authentication
93 $ssltest -dtls12 -server_auth $CA $extra || exit 1
94
95 echo test dtlsv1.2 with client authentication
96 $ssltest -dtls12 -client_auth $CA $extra || exit 1
97
98 echo test dtlsv1.2 with both client and server authentication
99 $ssltest -dtls12 -server_auth -client_auth $CA $extra || exit 1
100
101 if [ $dsa_cert = NO ]; then
102   echo 'test sslv2/sslv3 w/o (EC)DHE via BIO pair'
103   $ssltest -bio_pair -no_dhe -no_ecdhe $extra || exit 1
104 fi
105
106 echo test sslv2/sslv3 with 1024bit DHE via BIO pair
107 $ssltest -bio_pair -dhe1024dsa -v $extra || exit 1
108
109 echo test sslv2/sslv3 with server authentication
110 $ssltest -bio_pair -server_auth $CA $extra || exit 1
111
112 echo test sslv2/sslv3 with client authentication via BIO pair
113 $ssltest -bio_pair -client_auth $CA $extra || exit 1
114
115 echo test sslv2/sslv3 with both client and server authentication via BIO pair
116 $ssltest -bio_pair -server_auth -client_auth $CA $extra || exit 1
117
118 echo test sslv2/sslv3 with both client and server authentication via BIO pair and app verify
119 $ssltest -bio_pair -server_auth -client_auth -app_verify $CA $extra || exit 1
120
121 echo "Testing ciphersuites"
122 for protocol in TLSv1.2 SSLv3; do
123   echo "Testing ciphersuites for $protocol"
124   for cipher in `../util/shlib_wrap.sh ../apps/openssl ciphers "RSA+$protocol" | tr ':' ' '`; do
125     echo "Testing $cipher"
126     prot=""
127     if [ $protocol = "SSLv3" ] ; then
128       prot="-ssl3"
129     fi
130     $ssltest -cipher $cipher $prot
131     if [ $? -ne 0 ] ; then
132           echo "Failed $cipher"
133           exit 1
134     fi
135   done
136 done
137
138 #############################################################################
139
140 if ../util/shlib_wrap.sh ../apps/openssl no-dh; then
141   echo skipping anonymous DH tests
142 else
143   echo test tls1 with 1024bit anonymous DH, multiple handshakes
144   $ssltest -v -bio_pair -tls1 -cipher ADH -dhe1024dsa -num 10 -f -time $extra || exit 1
145 fi
146
147 if ../util/shlib_wrap.sh ../apps/openssl no-rsa; then
148   echo skipping RSA tests
149 else
150   echo 'test tls1 with 1024bit RSA, no (EC)DHE, multiple handshakes'
151   ../util/shlib_wrap.sh ./ssltest -v -bio_pair -tls1 -cert ../apps/server2.pem -no_dhe -no_ecdhe -num 10 -f -time $extra || exit 1
152
153   if ../util/shlib_wrap.sh ../apps/openssl no-dh; then
154     echo skipping RSA+DHE tests
155   else
156     echo test tls1 with 1024bit RSA, 1024bit DHE, multiple handshakes
157     ../util/shlib_wrap.sh ./ssltest -v -bio_pair -tls1 -cert ../apps/server2.pem -dhe1024dsa -num 10 -f -time $extra || exit 1
158   fi
159 fi
160
161 echo test tls1 with PSK
162 $ssltest -tls1 -cipher PSK -psk abc123 $extra || exit 1
163
164 echo test tls1 with PSK via BIO pair
165 $ssltest -bio_pair -tls1 -cipher PSK -psk abc123 $extra || exit 1
166
167 #############################################################################
168 # Next Protocol Negotiation Tests
169
170 $ssltest -bio_pair -tls1 -npn_client || exit 1
171 $ssltest -bio_pair -tls1 -npn_server || exit 1
172 $ssltest -bio_pair -tls1 -npn_server_reject || exit 1
173 $ssltest -bio_pair -tls1 -npn_client -npn_server_reject || exit 1
174 $ssltest -bio_pair -tls1 -npn_client -npn_server || exit 1
175 $ssltest -bio_pair -tls1 -npn_client -npn_server -num 2 || exit 1
176 $ssltest -bio_pair -tls1 -npn_client -npn_server -num 2 -reuse || exit 1
177
178 #############################################################################
179 # Custom Extension tests
180
181 echo test tls1 with custom extensions
182 $ssltest -bio_pair -tls1 -custom_ext || exit 1
183
184 #############################################################################
185 # Serverinfo tests
186
187 echo test tls1 with serverinfo
188 $ssltest -bio_pair -tls1 -serverinfo_file $serverinfo || exit 1
189 $ssltest -bio_pair -tls1 -serverinfo_file $serverinfo -serverinfo_sct || exit 1
190 $ssltest -bio_pair -tls1 -serverinfo_file $serverinfo -serverinfo_tack || exit 1
191 $ssltest -bio_pair -tls1 -serverinfo_file $serverinfo -serverinfo_sct -serverinfo_tack || exit 1
192 $ssltest -bio_pair -tls1 -custom_ext -serverinfo_file $serverinfo -serverinfo_sct -serverinfo_tack || exit 1
193
194
195 #############################################################################
196 # ALPN tests
197
198 $ssltest -bio_pair -tls1 -alpn_client foo -alpn_server bar || exit 1
199 $ssltest -bio_pair -tls1 -alpn_client foo -alpn_server foo -alpn_expected foo || exit 1
200 $ssltest -bio_pair -tls1 -alpn_client foo,bar -alpn_server foo -alpn_expected foo || exit 1
201 $ssltest -bio_pair -tls1 -alpn_client bar,foo -alpn_server foo -alpn_expected foo || exit 1
202 $ssltest -bio_pair -tls1 -alpn_client bar,foo -alpn_server foo,bar -alpn_expected foo || exit 1
203 $ssltest -bio_pair -tls1 -alpn_client bar,foo -alpn_server bar,foo -alpn_expected bar || exit 1
204 $ssltest -bio_pair -tls1 -alpn_client foo,bar -alpn_server bar,foo -alpn_expected bar || exit 1
205 $ssltest -bio_pair -tls1 -alpn_client baz -alpn_server bar,foo || exit 1
206
207 if ../util/shlib_wrap.sh ../apps/openssl no-srp; then
208   echo skipping SRP tests
209 else
210   echo test tls1 with SRP
211   $ssltest -tls1 -cipher SRP -srpuser test -srppass abc123
212
213   echo test tls1 with SRP via BIO pair
214   $ssltest -bio_pair -tls1 -cipher SRP -srpuser test -srppass abc123
215
216   echo test tls1 with SRP auth
217   $ssltest -tls1 -cipher aSRP -srpuser test -srppass abc123
218
219   echo test tls1 with SRP auth via BIO pair
220   $ssltest -bio_pair -tls1 -cipher aSRP -srpuser test -srppass abc123
221 fi
222
223 #############################################################################
224 # Multi-buffer tests
225
226 if [ -z "$extra" -a `uname -m` = "x86_64" ]; then
227   $ssltest -cipher AES128-SHA    -bytes 8m      || exit 1
228   $ssltest -cipher AES128-SHA256 -bytes 8m      || exit 1
229 fi
230
231 exit 0