summaryrefslogtreecommitdiff
path: root/tests/suite/testcompat-main
blob: 557a39a5e378441849497f33201f3bbcfa7fb583 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
#!/bin/sh

# Copyright (C) 2010-2011 Free Software Foundation, Inc.
#
# Author: Nikos Mavrogiannopoulos
#
# This file is part of GnuTLS.
#
# GnuTLS is free software; you can redistribute it and/or modify it
# under the terms of the GNU General Public License as published by the
# Free Software Foundation; either version 3 of the License, or (at
# your option) any later version.
#
# GnuTLS is distributed in the hope that it will be useful, but
# WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
# General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with GnuTLS; if not, write to the Free Software Foundation,
# Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.

srcdir="${srcdir:-.}"
CLI="${CLI:-../../src/gnutls-cli$EXEEXT}"
PORT="${PORT:-5558}"
unset RETCODE

if test "${WINDIR}" != "";then
  exit 77
fi 

. $srcdir/../scripts/common.sh

SERV=openssl
OPENSSL_CLI="openssl"

echo "Compatibility checks using "`$SERV version`
$SERV version|grep -e 1\.0 >/dev/null 2>&1
SV=$?
if test $SV != 0;then
  echo "OpenSSL 1.0.0 is required for ECDH and DTLS tests"
fi

DSA_CERT=$srcdir/../dsa/cert.dsa.1024.pem
DSA_KEY=$srcdir/../dsa/dsa.1024.pem

RSA_CERT=$srcdir/../certs/cert-rsa-2432.pem
RSA_KEY=$srcdir/../certs/rsa-2432.pem

CA_CERT=$srcdir/../../doc/credentials/x509/ca.pem
CLI_CERT=$srcdir/../../doc/credentials/x509/clicert.pem
CLI_KEY=$srcdir/../../doc/credentials/x509/clikey.pem

CA_ECC_CERT=$srcdir/../certs/ca-cert-ecc.pem
ECC_CERT=$srcdir/../certs/cert-ecc.pem
ECC_KEY=$srcdir/../certs/ecc.pem

SERV_CERT=$srcdir/../../doc/credentials/x509/cert-rsa.pem
SERV_KEY=$srcdir/../../doc/credentials/x509/key-rsa.pem
SERV_DSA_CERT=$srcdir/../../doc/credentials/x509/cert-dsa.pem
SERV_DSA_KEY=$srcdir/../../doc/credentials/x509/key-dsa.pem

echo "#####################"
echo "# Client mode tests #"
echo "#####################"


launch_bare_server $$ s_server -quiet -www -accept $PORT -keyform pem -certform pem -ssl3 -dhparam params.dh -key $RSA_KEY -cert $RSA_CERT -dkey $DSA_KEY -dcert $DSA_CERT -Verify 1 -CAfile $CA_CERT &
PID=$!
wait_server $PID

# Test SSL 3.0 with RSA ciphersuite
echo "Checking SSL 3.0 with RSA..." 
$CLI $DEBUG -p $PORT 127.0.0.1 --priority "NONE:+CIPHER-ALL:+SIGN-ALL:+COMP-NULL:+MAC-ALL:+VERS-SSL3.0:+RSA" --insecure --x509certfile $CLI_CERT --x509keyfile $CLI_KEY </dev/null >/dev/null || \
  fail $PID "Failed"

# Test SSL 3.0 with DHE-RSA ciphersuite
echo "Checking SSL 3.0 with DHE-RSA..." 
$CLI $DEBUG -p $PORT 127.0.0.1 --priority "NONE:+CIPHER-ALL:+SIGN-ALL:+COMP-NULL:+MAC-ALL:+VERS-SSL3.0:+DHE-RSA" --insecure --x509certfile $CLI_CERT --x509keyfile $CLI_KEY </dev/null >/dev/null || \
  fail $PID "Failed"

# Test SSL 3.0 with DHE-DSS ciphersuite
echo "Checking SSL 3.0 with DHE-DSS..." 
$CLI $DEBUG -p $PORT 127.0.0.1 --priority "NONE:+CIPHER-ALL:+SIGN-ALL:+COMP-NULL:+MAC-ALL:+VERS-SSL3.0:+DHE-DSS" --insecure --x509certfile $CLI_CERT --x509keyfile $CLI_KEY </dev/null >/dev/null || \
  fail $PID "Failed"

kill $PID
wait

#-cipher RSA-NULL
launch_bare_server $$ s_server -cipher NULL -quiet -www -accept $PORT -keyform pem -certform pem -tls1 -dhparam params.dh -key $RSA_KEY -cert $RSA_CERT -Verify 1 -CAfile $CA_CERT &
PID=$!
wait_server $PID

# Test TLS 1.0 with RSA-NULL ciphersuite
echo "Checking TLS 1.0 with RSA-NULL..." 
$CLI $DEBUG -p $PORT 127.0.0.1 --priority "NONE:+NULL:+SIGN-ALL:+COMP-NULL:+MAC-ALL:+VERS-TLS1.0:+RSA" --insecure --x509certfile $CLI_CERT --x509keyfile $CLI_KEY </dev/null >/dev/null || \
  fail $PID "Failed"

kill $PID
wait

#-cipher RSA-AES128-SHA:DHE-DSS-AES128-SHA:DHE-RSA-AES128-SHA:ECDHE-RSA-AES128-SHA 
launch_bare_server $$ s_server -quiet -www -accept $PORT -keyform pem -certform pem -tls1 -dhparam params.dh -key $RSA_KEY -cert $RSA_CERT -dkey $DSA_KEY -dcert $DSA_CERT -Verify 1 -CAfile $CA_CERT &
PID=$!
wait_server $PID

# Test TLS 1.0 with RSA ciphersuite
echo "Checking TLS 1.0 with RSA..." 
$CLI $DEBUG -p $PORT 127.0.0.1 --priority "NONE:+CIPHER-ALL:+SIGN-ALL:+COMP-NULL:+MAC-ALL:+VERS-TLS1.0:+RSA" --insecure --x509certfile $CLI_CERT --x509keyfile $CLI_KEY </dev/null >/dev/null || \
  fail $PID "Failed"

# Test TLS 1.0 with DHE-RSA ciphersuite
echo "Checking TLS 1.0 with DHE-RSA..." 
$CLI $DEBUG -p $PORT 127.0.0.1 --priority "NONE:+CIPHER-ALL:+SIGN-ALL:+COMP-NULL:+MAC-ALL:+VERS-TLS1.0:+DHE-RSA" --insecure --x509certfile $CLI_CERT --x509keyfile $CLI_KEY </dev/null >/dev/null || \
  fail $PID "Failed"

if test $SV = 0;then

# Test TLS 1.0 with DHE-RSA ciphersuite
echo "Checking TLS 1.0 with ECDHE-RSA..." 
$CLI $DEBUG -p $PORT 127.0.0.1 --priority "NONE:+CIPHER-ALL:+SIGN-ALL:+COMP-NULL:+MAC-ALL:+VERS-TLS1.0:+ECDHE-RSA:+CURVE-ALL" --insecure --x509certfile $CLI_CERT --x509keyfile $CLI_KEY </dev/null >/dev/null || \
  fail $PID "Failed"

fi

# Test TLS 1.0 with DHE-DSS ciphersuite
echo "Checking TLS 1.0 with DHE-DSS..." 
$CLI $DEBUG -p $PORT 127.0.0.1 --priority "NONE:+CIPHER-ALL:+SIGN-ALL:+COMP-NULL:+MAC-ALL:+VERS-TLS1.0:+DHE-DSS" --insecure --x509certfile $CLI_CERT --x509keyfile $CLI_KEY </dev/null >/dev/null || \
  fail $PID "Failed"

kill $PID
wait

if test $SV = 0;then

#-cipher ECDHE-ECDSA-AES128-SHA
launch_bare_server $$ s_server -quiet -www -accept $PORT -keyform pem -certform pem -tls1 -key $ECC_KEY -cert $ECC_CERT -Verify 1 -named_curve secp224r1 -CAfile $CA_ECC_CERT &
PID=$!
wait_server $PID

# Test TLS 1.0 with ECDHE-ECDSA ciphersuite
echo "Checking TLS 1.0 with ECDHE-ECDSA..." 
$CLI $DEBUG -p $PORT 127.0.0.1 --priority "NONE:+CIPHER-ALL:+SIGN-ALL:+COMP-NULL:+MAC-ALL:+VERS-TLS1.0:+ECDHE-ECDSA:+CURVE-ALL" --insecure --x509certfile $ECC_CERT --x509keyfile $ECC_KEY </dev/null >/dev/null || \
  fail $PID "Failed"

kill $PID
wait

fi

launch_bare_server $$ s_server -quiet -accept $PORT -keyform pem -certform pem -dtls1 -timeout -dhparam params.dh -key $RSA_KEY -cert $RSA_CERT -dkey $DSA_KEY -dcert $DSA_CERT -Verify 1 -CAfile $CA_CERT &
PID=$!
wait_server $PID

if test $SV = 0;then

# Test DTLS 1.0 with RSA ciphersuite
echo "Checking DTLS 1.0 with RSA..." 
$CLI $DEBUG -p $PORT 127.0.0.1 --priority "NONE:+CIPHER-ALL:+SIGN-ALL:+COMP-NULL:+MAC-ALL:+VERS-DTLS1.0:+RSA" --udp --insecure --x509certfile $CLI_CERT --x509keyfile $CLI_KEY </dev/null >/dev/null || \
  fail $PID "Failed"

kill $PID
wait

launch_bare_server $$ s_server -quiet -accept $PORT -keyform pem -certform pem -dtls1 -timeout -dhparam params.dh -key $RSA_KEY -cert $RSA_CERT -dkey $DSA_KEY -dcert $DSA_CERT -Verify 1 -CAfile $CA_CERT &
PID=$!
wait_server $PID

# Test DTLS 1.0 with DHE-RSA ciphersuite
echo "Checking DTLS 1.0 with DHE-RSA..." 
$CLI $DEBUG -p $PORT 127.0.0.1 --priority "NONE:+CIPHER-ALL:+SIGN-ALL:+COMP-NULL:+MAC-ALL:+VERS-DTLS1.0:+DHE-RSA" --udp --insecure --x509certfile $CLI_CERT --x509keyfile $CLI_KEY </dev/null >/dev/null || \
  fail $PID "Failed"

kill $PID
wait

launch_bare_server $$ s_server -quiet -accept $PORT -keyform pem -certform pem -dtls1 -timeout -dhparam params.dh -key $RSA_KEY -cert $RSA_CERT -dkey $DSA_KEY -dcert $DSA_CERT -Verify 1 -CAfile $CA_CERT &
PID=$!
wait_server $PID

# Test DTLS 1.0 with DHE-DSS ciphersuite
echo "Checking DTLS 1.0 with DHE-DSS..." 
$CLI $DEBUG -p $PORT 127.0.0.1 --priority "NONE:+CIPHER-ALL:+SIGN-ALL:+COMP-NULL:+MAC-ALL:+VERS-DTLS1.0:+DHE-DSS" --udp --insecure --x509certfile $CLI_CERT --x509keyfile $CLI_KEY </dev/null >/dev/null || \
  fail $PID "Failed"

fi

kill $PID
wait



echo "Client mode tests were successfully completed"
echo ""
echo "#####################"
echo "# Server mode tests #"
echo "#####################"
SERV="../../src/gnutls-serv$EXEEXT -q"
PORT="5559"

# Note that openssl s_client does not return error code on failure

echo "Check SSL 3.0 with RSA ciphersuite"
launch_server $$  --priority "NONE:+CIPHER-ALL:+SIGN-ALL:+COMP-NULL:+MAC-ALL:+VERS-SSL3.0:+RSA" --x509certfile $SERV_CERT --x509keyfile $SERV_KEY --x509cafile $CA_CERT --dhparams params.dh  & PID=$!
wait_server $PID

$OPENSSL_CLI s_client  -host localhost -port $PORT -ssl3 -cert $CLI_CERT -key $CLI_KEY -CAfile $CA_CERT </dev/null 2>&1 | grep "\:error\:" && \
  fail $PID "Failed"

kill $PID
wait

echo "Check SSL 3.0 with DHE-RSA ciphersuite"
launch_server $$  --priority "NONE:+CIPHER-ALL:+SIGN-ALL:+COMP-NULL:+MAC-ALL:+VERS-SSL3.0:+DHE-RSA" --x509certfile $SERV_CERT --x509keyfile $SERV_KEY --x509cafile $CA_CERT --dhparams params.dh  & PID=$!
wait_server $PID

$OPENSSL_CLI s_client  -host localhost -port $PORT -ssl3 -cert $CLI_CERT -key $CLI_KEY -CAfile $CA_CERT </dev/null 2>&1 | grep "\:error\:" && \
  fail $PID "Failed"

kill $PID
wait

echo "Check SSL 3.0 with DHE-DSS ciphersuite"
launch_server $$  --priority "NONE:+CIPHER-ALL:+SIGN-ALL:+COMP-NULL:+MAC-ALL:+VERS-SSL3.0:+DHE-DSS" --x509certfile $SERV_DSA_CERT --x509keyfile $SERV_DSA_KEY --dhparams params.dh  & PID=$!
wait_server $PID

$OPENSSL_CLI s_client  -host localhost -port $PORT -ssl3 -cert $CLI_CERT -key $CLI_KEY -CAfile $CA_CERT </dev/null 2>&1 | grep "\:error\:" && \
  fail $PID "Failed"

kill $PID
wait

#TLS 1.0

# This test was disabled because it doesn't work as expected with openssl 1.0.0d
#echo "Check TLS 1.0 with RSA ciphersuite (SSLv2 hello)"
#launch_server $$  --priority "NONE:+CIPHER-ALL:+SIGN-ALL:+COMP-NULL:+MAC-ALL:+VERS-TLS1.0:+RSA" --x509certfile $SERV_CERT --x509keyfile $SERV_KEY --x509cafile $CA_CERT --dhparams params.dh & PID=$!
#wait_server $PID
#
#$OPENSSL_CLI s_client  -host localhost -port $PORT -cert $CLI_CERT -key $CLI_KEY -CAfile $CA_CERT </dev/null 2>&1 | grep "\:error\:" && \
#  fail $PID "Failed"
#
#kill $PID
#wait

echo "Check TLS 1.0 with RSA-NULL ciphersuite"
launch_server $$  --priority "NONE:+NULL:+SIGN-ALL:+COMP-NULL:+MAC-ALL:+VERS-TLS1.0:+RSA:+DHE-RSA" --x509certfile $SERV_CERT --x509keyfile $SERV_KEY --x509cafile $CA_CERT --dhparams params.dh  & PID=$!
wait_server $PID

$OPENSSL_CLI s_client -cipher NULL-SHA -host localhost -tls1 -port $PORT -cert $CLI_CERT -key $CLI_KEY -CAfile $CA_CERT </dev/null 2>&1 | grep "\:error\:" && \
  fail $PID "Failed"

kill $PID
wait

echo "Check TLS 1.0 with DHE-RSA ciphersuite"
launch_server $$  --priority "NONE:+CIPHER-ALL:+SIGN-ALL:+COMP-NULL:+MAC-ALL:+VERS-TLS1.0:+DHE-RSA" --x509certfile $SERV_CERT --x509keyfile $SERV_KEY --x509cafile $CA_CERT --dhparams params.dh  & PID=$!
wait_server $PID

$OPENSSL_CLI s_client  -host localhost -tls1 -port $PORT -cert $CLI_CERT -key $CLI_KEY -CAfile $CA_CERT </dev/null 2>&1 | grep "\:error\:" && \
  fail $PID "Failed"

kill $PID
wait

echo "Check TLS 1.0 with DHE-DSS ciphersuite"
launch_server $$  --priority "NONE:+CIPHER-ALL:+SIGN-ALL:+COMP-NULL:+MAC-ALL:+VERS-TLS1.0:+DHE-DSS" --x509certfile $SERV_DSA_CERT --x509keyfile $SERV_DSA_KEY --dhparams params.dh  & PID=$!
wait_server $PID

$OPENSSL_CLI s_client  -host localhost -tls1 -port $PORT -cert $CLI_CERT -key $CLI_KEY -CAfile $CA_CERT </dev/null 2>&1 | grep "\:error\:" && \
  fail $PID "Failed"

kill $PID
wait

if test $SV = 0;then

echo "Check TLS 1.0 with ECDHE-RSA ciphersuite"
launch_server $$  --priority "NONE:+CIPHER-ALL:+SIGN-ALL:+COMP-NULL:+MAC-ALL:+VERS-TLS1.0:+ECDHE-RSA:+CURVE-ALL" --x509certfile $SERV_CERT --x509keyfile $SERV_KEY --x509cafile $CA_CERT & PID=$!
wait_server $PID

#-cipher ECDHE-RSA-AES128-SHA 
$OPENSSL_CLI s_client  -host localhost -tls1 -port $PORT -cert $CLI_CERT -key $CLI_KEY -CAfile $CA_CERT </dev/null 2>&1 | grep "\:error\:" && \
  fail $PID "Failed"

kill $PID
wait

echo "Check TLS 1.0 with ECDHE-ECDSA ciphersuite"
launch_server $$  --priority "NONE:+CIPHER-ALL:+SIGN-ALL:+COMP-NULL:+MAC-ALL:+VERS-TLS1.0:+ECDHE-ECDSA:+CURVE-ALL" --x509certfile $ECC_CERT --x509keyfile $ECC_KEY --x509cafile $CA_ECC_CERT & PID=$!
wait_server $PID

#-cipher ECDHE-ECDSA-AES128-SHA 
$OPENSSL_CLI s_client  -host localhost -tls1 -port $PORT -cert $ECC_CERT -key $ECC_KEY -CAfile $CA_ECC_CERT </dev/null 2>&1 | grep "\:error\:" && \
  fail $PID "Failed"

kill $PID
wait

# DTLS
echo "Check DTLS 1.0 with RSA ciphersuite"
launch_server $$  --priority "NONE:+CIPHER-ALL:+SIGN-ALL:+COMP-NULL:+MAC-ALL:+VERS-DTLS1.0:+RSA" --udp --x509certfile $SERV_CERT --x509keyfile $SERV_KEY --x509cafile $CA_CERT --dhparams params.dh  & PID=$!
wait_server $PID

$OPENSSL_CLI s_client  -host localhost -port $PORT -dtls1 -cert $CLI_CERT -key $CLI_KEY -CAfile $CA_CERT </dev/null 2>&1 | grep "\:error\:" && \
  fail $PID "Failed"

kill $PID
wait

echo "Check DTLS 1.0 with DHE-RSA ciphersuite"
launch_server $$  --priority "NONE:+CIPHER-ALL:+SIGN-ALL:+COMP-NULL:+MAC-ALL:+VERS-DTLS1.0:+DHE-RSA" --udp --x509certfile $SERV_CERT --x509keyfile $SERV_KEY --x509cafile $CA_CERT --dhparams params.dh  & PID=$!
wait_server $PID

$CLI s_client  -host localhost -port $PORT -dtls1 -cert $CLI_CERT -key $CLI_KEY -CAfile $CA_CERT </dev/null 2>&1 | grep "\:error\:" && \
  fail $PID "Failed"

kill $PID
wait

echo "Check DTLS 1.0 with DHE-DSS ciphersuite"
launch_server $$  --priority "NONE:+CIPHER-ALL:+SIGN-ALL:+COMP-NULL:+MAC-ALL:+VERS-DTLS1.0:+DHE-DSS" --udp --x509certfile $SERV_DSA_CERT --x509keyfile $SERV_DSA_KEY --dhparams params.dh  & PID=$!
wait_server $PID

$CLI s_client  -host localhost -port $PORT -dtls1 -cert $CLI_CERT -key $CLI_KEY -CAfile $CA_CERT </dev/null 2>&1 | grep "\:error\:" && \
  fail $PID "Failed"

kill $PID
wait

fi


exit 0