Tizen 2.0 Release
[external/libgnutls26.git] / tests / dsa / testdsa
1 #!/bin/sh
2
3 # Copyright (C) 2010 Free Software Foundation, Inc.
4 #
5 # Author: Nikos Mavrogiannopoulos
6 #
7 # This file is part of GnuTLS.
8 #
9 # GnuTLS is free software; you can redistribute it and/or modify it
10 # under the terms of the GNU General Public License as published by the
11 # Free Software Foundation; either version 3 of the License, or (at
12 # your option) any later version.
13 #
14 # GnuTLS is distributed in the hope that it will be useful, but
15 # WITHOUT ANY WARRANTY; without even the implied warranty of
16 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
17 # General Public License for more details.
18 #
19 # You should have received a copy of the GNU General Public License
20 # along with GnuTLS; if not, write to the Free Software Foundation,
21 # Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
22
23 srcdir="${srcdir:-.}"
24 SERV="${SERV:-../../src/gnutls-serv} -q"
25 CLI="${CLI:-../../src/gnutls-cli}"
26 PORT="${PORT:-5559}"
27 DEBUG=""
28 unset RETCODE
29
30 if test "${WINDIR}" != "";then
31   exit 77
32 fi 
33
34 fail() {
35    echo "Failure: $1" >&2
36    exit 1
37 }
38
39 echo "Checking various DSA key sizes"
40
41 # DSA 1024 + TLS 1.0
42
43 echo "Checking DSA-1024 with TLS 1.0"
44
45 $SERV $DEBUG -p $PORT --priority "NORMAL:-VERS-TLS-ALL:+VERS-TLS1.0" --x509certfile $srcdir/cert.dsa.1024.pem --x509keyfile $srcdir/dsa.1024.pem >/dev/null 2>&1 & PID=$!
46 trap "kill $PID" 1 15 2
47
48 # give the server a chance to initialize
49 sleep 2
50
51 $CLI $DEBUG -p $PORT 127.0.0.1 --insecure </dev/null >/dev/null || \
52   fail "Failed connection to a server with DSA 1024 key and TLS 1.0!"
53
54 echo "Checking server DSA-1024 with client DSA-1024 and TLS 1.0"
55
56 #try with client key of 1024 bits (should succeed) 
57 $CLI $DEBUG -p $PORT 127.0.0.1 --insecure --x509certfile $srcdir/cert.dsa.1024.pem --x509keyfile $srcdir/dsa.1024.pem </dev/null >/dev/null || \
58   fail "Failed connection to a server with DSA 1024 key and TLS 1.0!"
59
60 echo "Checking server DSA-1024 with client DSA-2048 and TLS 1.0"
61
62 #try with client key of 2048 bits (should fail) 
63 $CLI $DEBUG -p $PORT 127.0.0.1 --insecure --x509certfile $srcdir/cert.dsa.2048.pem --x509keyfile $srcdir/dsa.2048.pem </dev/null >/dev/null 2>&1 && \
64   fail "Succeeded connection to a server with a client DSA 2048 key and TLS 1.0!"
65
66 echo "Checking server DSA-1024 with client DSA-3072 and TLS 1.0"
67
68 #try with client key of 3072 bits (should fail) 
69 $CLI $DEBUG -p $PORT 127.0.0.1 --insecure --x509certfile $srcdir/cert.dsa.3072.pem --x509keyfile $srcdir/dsa.3072.pem </dev/null >/dev/null 2>&1 && \
70   fail "Succeeded connection to a server with a client DSA 3072 key and TLS 1.0!"
71
72 kill $PID
73 wait
74
75 # DSA 1024 + TLS 1.2
76
77 echo "Checking DSA-1024 with TLS 1.2"
78
79 $SERV $DEBUG -p $PORT --priority "NORMAL:-VERS-TLS-ALL:+VERS-TLS1.2" --x509certfile $srcdir/cert.dsa.1024.pem --x509keyfile $srcdir/dsa.1024.pem >/dev/null 2>&1 & PID=$!
80 trap "kill $PID" 1 15 2
81
82 # give the server a chance to initialize
83 sleep 2
84
85 $CLI $DEBUG -p $PORT 127.0.0.1 --insecure </dev/null >/dev/null || \
86   fail "Failed connection to a server with DSA 1024 key and TLS 1.2!"
87
88 echo "Checking server DSA-1024 with client DSA-1024 and TLS 1.2"
89
90 #try with client key of 1024 bits (should succeed) 
91 $CLI $DEBUG -p $PORT 127.0.0.1 --insecure --x509certfile $srcdir/cert.dsa.1024.pem --x509keyfile $srcdir/dsa.1024.pem </dev/null >/dev/null || \
92   fail "Failed connection to a server with DSA 1024 key and TLS 1.2!"
93
94 echo "Checking server DSA-1024 with client DSA-2048 and TLS 1.2"
95
96 #try with client key of 2048 bits (should succeed) 
97 $CLI $DEBUG -p $PORT 127.0.0.1 --insecure --x509certfile $srcdir/cert.dsa.2048.pem --x509keyfile $srcdir/dsa.2048.pem </dev/null >/dev/null || \
98   fail "Failed connection to a server with a client DSA 2048 key and TLS 1.2!"
99
100 echo "Checking server DSA-1024 with client DSA-3072 and TLS 1.2"
101
102 #try with client key of 3072 bits (should succeed) 
103 $CLI $DEBUG -p $PORT 127.0.0.1 --insecure --x509certfile $srcdir/cert.dsa.3072.pem --x509keyfile $srcdir/dsa.3072.pem </dev/null >/dev/null || \
104   fail "Failed connection to a server with a client DSA 3072 key and TLS 1.2!"
105
106
107 kill $PID
108 wait
109
110 # DSA 2048 + TLS 1.0
111
112 echo "Checking DSA-2048 with TLS 1.0"
113
114 $SERV $DEBUG -p $PORT --priority "NORMAL:-VERS-TLS-ALL:+VERS-TLS1.0" --x509certfile $srcdir/cert.dsa.2048.pem --x509keyfile $srcdir/dsa.2048.pem >/dev/null 2>&1 & PID=$!
115 trap "kill $PID" 1 15 2
116
117 # give the server a chance to initialize
118 sleep 2
119
120 $CLI $DEBUG -p $PORT 127.0.0.1 --insecure </dev/null >/dev/null 2>&1 && \
121   fail "Succeeded connection to a server with DSA 2048 key and TLS 1.0. Should have failed!"
122
123 kill $PID
124 wait
125
126 # DSA 2048 + TLS 1.2
127
128 echo "Checking DSA-2048 with TLS 1.2"
129
130 $SERV $DEBUG -p $PORT --priority "NORMAL:-VERS-TLS-ALL:+VERS-TLS1.2" --x509certfile $srcdir/cert.dsa.2048.pem --x509keyfile $srcdir/dsa.2048.pem >/dev/null 2>&1 & PID=$!
131 trap "kill $PID" 1 15 2
132
133 # give the server a chance to initialize
134 sleep 2
135
136 $CLI $DEBUG -p $PORT 127.0.0.1 --insecure </dev/null >/dev/null || \
137   fail "Failed connection to a server with DSA 2048 key and TLS 1.2!"
138
139 kill $PID
140 wait
141
142 # DSA 3072 + TLS 1.0
143
144 echo "Checking DSA-3072 with TLS 1.0"
145
146 $SERV $DEBUG -p $PORT --priority "NORMAL:-VERS-TLS-ALL:+VERS-TLS1.0" --x509certfile $srcdir/cert.dsa.3072.pem --x509keyfile $srcdir/dsa.3072.pem >/dev/null 2>&1 & PID=$!
147 trap "kill $PID" 1 15 2
148
149 # give the server a chance to initialize
150 sleep 2
151
152 $CLI $DEBUG -p $PORT 127.0.0.1 --insecure </dev/null >/dev/null 2>&1 && \
153   fail "Succeeded connection to a server with DSA 3072 key and TLS 1.0. Should have failed!"
154
155 kill $PID
156 wait
157
158 # DSA 3072 + TLS 1.2
159
160 echo "Checking DSA-3072 with TLS 1.2"
161
162 $SERV $DEBUG -p $PORT --priority "NORMAL:-VERS-TLS-ALL:+VERS-TLS1.2" --x509certfile $srcdir/cert.dsa.3072.pem --x509keyfile $srcdir/dsa.3072.pem >/dev/null 2>&1 & PID=$!
163 trap "kill $PID" 1 15 2
164
165 # give the server a chance to initialize
166 sleep 2
167
168 $CLI $DEBUG -p $PORT 127.0.0.1 --insecure </dev/null >/dev/null || \
169   fail "Failed connection to a server with DSA 3072 key and TLS 1.2!"
170
171 kill $PID
172 wait
173
174 exit 0
175