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