blob: 420484b415ceafb9a48990774f12f9fc019fc19d [file] [log] [blame]
Paul Bakker5121ce52009-01-03 21:22:43 +00001/*
2 * SSL/TLS stress testing program
3 *
Paul Bakker68884e32013-01-07 18:20:04 +01004 * Copyright (C) 2006-2013, Brainspark B.V.
Paul Bakkerb96f1542010-07-18 20:36:00 +00005 *
6 * This file is part of PolarSSL (http://www.polarssl.org)
Paul Bakker84f12b72010-07-18 10:13:04 +00007 * Lead Maintainer: Paul Bakker <polarssl_maintainer at polarssl.org>
Paul Bakkerb96f1542010-07-18 20:36:00 +00008 *
Paul Bakker77b385e2009-07-28 17:23:11 +00009 * All rights reserved.
Paul Bakkere0ccd0a2009-01-04 16:27:10 +000010 *
Paul Bakker5121ce52009-01-03 21:22:43 +000011 * This program is free software; you can redistribute it and/or modify
12 * it under the terms of the GNU General Public License as published by
13 * the Free Software Foundation; either version 2 of the License, or
14 * (at your option) any later version.
15 *
16 * This program is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 * GNU General Public License for more details.
20 *
21 * You should have received a copy of the GNU General Public License along
22 * with this program; if not, write to the Free Software Foundation, Inc.,
23 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
24 */
25
26#ifndef _CRT_SECURE_NO_DEPRECATE
27#define _CRT_SECURE_NO_DEPRECATE 1
28#endif
29
30#include <string.h>
31#include <stdlib.h>
32#include <stdio.h>
33
Paul Bakker5690efc2011-05-26 13:16:06 +000034#include "polarssl/config.h"
35
Paul Bakker40e46942009-01-03 21:51:57 +000036#include "polarssl/net.h"
37#include "polarssl/ssl.h"
Paul Bakker508ad5a2011-12-04 17:09:26 +000038#include "polarssl/entropy.h"
39#include "polarssl/ctr_drbg.h"
Paul Bakker40e46942009-01-03 21:51:57 +000040#include "polarssl/timing.h"
41#include "polarssl/certs.h"
Paul Bakker5121ce52009-01-03 21:22:43 +000042
43#define OPMODE_NONE 0
44#define OPMODE_CLIENT 1
45#define OPMODE_SERVER 2
46
47#define IOMODE_BLOCK 0
48#define IOMODE_NONBLOCK 1
49
50#define COMMAND_READ 1
51#define COMMAND_WRITE 2
52#define COMMAND_BOTH 3
53
54#define DFL_OPMODE OPMODE_NONE
55#define DFL_IOMODE IOMODE_BLOCK
56#define DFL_SERVER_NAME "localhost"
57#define DFL_SERVER_PORT 4433
58#define DFL_COMMAND COMMAND_READ
59#define DFL_BUFFER_SIZE 1024
60#define DFL_MAX_BYTES 0
61#define DFL_DEBUG_LEVEL 0
62#define DFL_CONN_TIMEOUT 0
63#define DFL_MAX_CONNECTIONS 0
64#define DFL_SESSION_REUSE 1
65#define DFL_SESSION_LIFETIME 86400
66#define DFL_FORCE_CIPHER 0
67
Paul Bakker5121ce52009-01-03 21:22:43 +000068int server_fd = -1;
69
70/*
71 * global options
72 */
73struct options
74{
75 int opmode; /* operation mode (client or server) */
76 int iomode; /* I/O mode (blocking or non-blocking) */
Paul Bakkeref3f8c72013-06-24 13:01:08 +020077 const char *server_name; /* hostname of the server (client only) */
Paul Bakker5121ce52009-01-03 21:22:43 +000078 int server_port; /* port on which the ssl service runs */
79 int command; /* what to do: read or write operation */
80 int buffer_size; /* size of the send/receive buffer */
81 int max_bytes; /* max. # of bytes before a reconnect */
82 int debug_level; /* level of debugging */
83 int conn_timeout; /* max. delay before a reconnect */
84 int max_connections; /* max. number of reconnections */
85 int session_reuse; /* flag to reuse the keying material */
86 int session_lifetime; /* if reached, session data is expired */
Paul Bakkere3166ce2011-01-27 17:40:50 +000087 int force_ciphersuite[2]; /* protocol/ciphersuite to use, or all */
Paul Bakker5121ce52009-01-03 21:22:43 +000088};
89
90/*
91 * Although this PRNG has good statistical properties (eg. passes
92 * DIEHARD), it is not cryptographically secure.
93 */
Paul Bakker3c5ef712013-06-25 16:37:45 +020094static unsigned long int lcppm5( unsigned long int *state )
Paul Bakker5121ce52009-01-03 21:22:43 +000095{
96 unsigned long int u, v;
97
98 u = v = state[4] ^ 1;
99 state[u & 3] ^= u;
100 u ^= (v << 12) ^ (v >> 12);
101 u ^= v * state[0]; v >>= 8;
102 u ^= v * state[1]; v >>= 8;
103 u ^= v * state[2]; v >>= 8;
104 u ^= v * state[3];
105 u &= 0xFFFFFFFF;
106 state[4] = u;
107
108 return( u );
109}
110
Paul Bakker3c5ef712013-06-25 16:37:45 +0200111static void my_debug( void *ctx, int level, const char *str )
Paul Bakker5121ce52009-01-03 21:22:43 +0000112{
113 if( level < ((struct options *) ctx)->debug_level )
114 fprintf( stderr, "%s", str );
115}
116
Paul Bakker508ad5a2011-12-04 17:09:26 +0000117#if !defined(POLARSSL_BIGNUM_C) || !defined(POLARSSL_ENTROPY_C) || \
Paul Bakker5690efc2011-05-26 13:16:06 +0000118 !defined(POLARSSL_SSL_TLS_C) || !defined(POLARSSL_SSL_SRV_C) || \
119 !defined(POLARSSL_SSL_CLI_C) || !defined(POLARSSL_NET_C) || \
Paul Bakkered27a042013-04-18 22:46:23 +0200120 !defined(POLARSSL_RSA_C) || !defined(POLARSSL_CTR_DRBG_C) || \
121 !defined(POLARSSL_X509_PARSE_C)
Paul Bakkercce9d772011-11-18 14:26:47 +0000122int main( int argc, char *argv[] )
Paul Bakker5690efc2011-05-26 13:16:06 +0000123{
Paul Bakkercce9d772011-11-18 14:26:47 +0000124 ((void) argc);
125 ((void) argv);
126
Paul Bakker508ad5a2011-12-04 17:09:26 +0000127 printf("POLARSSL_BIGNUM_C and/or POLARSSL_ENTROPY_C and/or "
Paul Bakker5690efc2011-05-26 13:16:06 +0000128 "POLARSSL_SSL_TLS_C and/or POLARSSL_SSL_SRV_C and/or "
129 "POLARSSL_SSL_CLI_C and/or POLARSSL_NET_C and/or "
Paul Bakkered27a042013-04-18 22:46:23 +0200130 "POLARSSL_RSA_C and/or POLARSSL_CTR_DRBG_C and/or "
131 "POLARSSL_X509_PARSE_C not defined.\n");
Paul Bakker5690efc2011-05-26 13:16:06 +0000132 return( 0 );
133}
134#else
Paul Bakker5121ce52009-01-03 21:22:43 +0000135/*
136 * perform a single SSL connection
137 */
138static int ssl_test( struct options *opt )
139{
140 int ret, i;
141 int client_fd;
142 int bytes_to_read;
143 int bytes_to_write;
Paul Bakker026c03b2009-03-28 17:53:03 +0000144 int offset_to_read = 0;
145 int offset_to_write = 0;
Paul Bakker5121ce52009-01-03 21:22:43 +0000146
147 long int nb_read;
148 long int nb_written;
149
150 unsigned long read_state[5];
151 unsigned long write_state[5];
152
Paul Bakker026c03b2009-03-28 17:53:03 +0000153 unsigned char *read_buf = NULL;
154 unsigned char *write_buf = NULL;
Paul Bakker5121ce52009-01-03 21:22:43 +0000155
Paul Bakkeref3f8c72013-06-24 13:01:08 +0200156 const char *pers = "ssl_test";
Paul Bakker508ad5a2011-12-04 17:09:26 +0000157
Paul Bakker5121ce52009-01-03 21:22:43 +0000158 struct hr_time t;
Paul Bakker508ad5a2011-12-04 17:09:26 +0000159 entropy_context entropy;
160 ctr_drbg_context ctr_drbg;
Paul Bakker5121ce52009-01-03 21:22:43 +0000161 ssl_context ssl;
Paul Bakker5121ce52009-01-03 21:22:43 +0000162 x509_cert srvcert;
163 rsa_context rsa;
164
165 ret = 1;
166
Paul Bakker508ad5a2011-12-04 17:09:26 +0000167 entropy_init( &entropy );
168 if( ( ret = ctr_drbg_init( &ctr_drbg, entropy_func, &entropy,
Paul Bakkeref3f8c72013-06-24 13:01:08 +0200169 (const unsigned char *) pers,
170 strlen( pers ) ) ) != 0 )
Paul Bakker508ad5a2011-12-04 17:09:26 +0000171 {
172 printf( " ! ctr_drbg_init returned %d\n", ret );
173 goto exit;
174 }
175
Paul Bakker5121ce52009-01-03 21:22:43 +0000176 get_timer( &t, 1 );
177
178 memset( read_state, 0, sizeof( read_state ) );
179 memset( write_state, 0, sizeof( write_state ) );
180
181 memset( &srvcert, 0, sizeof( x509_cert ) );
182 memset( &rsa, 0, sizeof( rsa_context ) );
183
184 if( opt->opmode == OPMODE_CLIENT )
185 {
186 if( ( ret = net_connect( &client_fd, opt->server_name,
187 opt->server_port ) ) != 0 )
188 {
189 printf( " ! net_connect returned %d\n\n", ret );
190 return( ret );
191 }
192
193 if( ( ret = ssl_init( &ssl ) ) != 0 )
194 {
195 printf( " ! ssl_init returned %d\n\n", ret );
196 return( ret );
197 }
198
199 ssl_set_endpoint( &ssl, SSL_IS_CLIENT );
200 }
201
202 if( opt->opmode == OPMODE_SERVER )
203 {
Paul Bakker5690efc2011-05-26 13:16:06 +0000204#if !defined(POLARSSL_CERTS_C)
205 printf("POLARSSL_CERTS_C not defined.\n");
206 goto exit;
207#else
Paul Bakkeref3f8c72013-06-24 13:01:08 +0200208 ret = x509parse_crt( &srvcert, (const unsigned char *) test_srv_crt,
Paul Bakker69e095c2011-12-10 21:55:01 +0000209 strlen( test_srv_crt ) );
Paul Bakker5121ce52009-01-03 21:22:43 +0000210 if( ret != 0 )
211 {
212 printf( " ! x509parse_crt returned %d\n\n", ret );
213 goto exit;
214 }
215
Paul Bakkeref3f8c72013-06-24 13:01:08 +0200216 ret = x509parse_crt( &srvcert, (const unsigned char *) test_ca_crt,
Paul Bakker69e095c2011-12-10 21:55:01 +0000217 strlen( test_ca_crt ) );
Paul Bakker5121ce52009-01-03 21:22:43 +0000218 if( ret != 0 )
219 {
220 printf( " ! x509parse_crt returned %d\n\n", ret );
221 goto exit;
222 }
223
Paul Bakkeref3f8c72013-06-24 13:01:08 +0200224 ret = x509parse_key( &rsa, (const unsigned char *) test_srv_key,
Paul Bakker5121ce52009-01-03 21:22:43 +0000225 strlen( test_srv_key ), NULL, 0 );
226 if( ret != 0 )
227 {
228 printf( " ! x509parse_key returned %d\n\n", ret );
229 goto exit;
230 }
Paul Bakker5690efc2011-05-26 13:16:06 +0000231#endif
Paul Bakker5121ce52009-01-03 21:22:43 +0000232
233 if( server_fd < 0 )
234 {
235 if( ( ret = net_bind( &server_fd, NULL,
236 opt->server_port ) ) != 0 )
237 {
238 printf( " ! net_bind returned %d\n\n", ret );
239 return( ret );
240 }
241 }
242
243 if( ( ret = net_accept( server_fd, &client_fd, NULL ) ) != 0 )
244 {
245 printf( " ! net_accept returned %d\n\n", ret );
246 return( ret );
247 }
248
249 if( ( ret = ssl_init( &ssl ) ) != 0 )
250 {
251 printf( " ! ssl_init returned %d\n\n", ret );
252 return( ret );
253 }
254
255 ssl_set_endpoint( &ssl, SSL_IS_SERVER );
Paul Bakker40ea7de2009-05-03 10:18:48 +0000256 ssl_set_ca_chain( &ssl, srvcert.next, NULL, NULL );
Paul Bakker5121ce52009-01-03 21:22:43 +0000257 ssl_set_own_cert( &ssl, &srvcert, &rsa );
258 }
259
260 ssl_set_authmode( &ssl, SSL_VERIFY_NONE );
261
Paul Bakker508ad5a2011-12-04 17:09:26 +0000262 ssl_set_rng( &ssl, ctr_drbg_random, &ctr_drbg );
Paul Bakker5121ce52009-01-03 21:22:43 +0000263 ssl_set_dbg( &ssl, my_debug, opt );
264 ssl_set_bio( &ssl, net_recv, &client_fd,
265 net_send, &client_fd );
266
Paul Bakker68884e32013-01-07 18:20:04 +0100267 if( opt->force_ciphersuite[0] != DFL_FORCE_CIPHER )
268 ssl_set_ciphersuites( &ssl, opt->force_ciphersuite );
Paul Bakker5121ce52009-01-03 21:22:43 +0000269
270 if( opt->iomode == IOMODE_NONBLOCK )
271 net_set_nonblock( client_fd );
272
273 read_buf = (unsigned char *) malloc( opt->buffer_size );
274 write_buf = (unsigned char *) malloc( opt->buffer_size );
275
276 if( read_buf == NULL || write_buf == NULL )
277 {
278 printf( " ! malloc(%d bytes) failed\n\n", opt->buffer_size );
279 goto exit;
280 }
281
282 nb_read = bytes_to_read = 0;
283 nb_written = bytes_to_write = 0;
284
285 while( 1 )
286 {
287 if( opt->command & COMMAND_WRITE )
288 {
289 if( bytes_to_write == 0 )
290 {
291 while( bytes_to_write == 0 )
292 bytes_to_write = rand() % opt->buffer_size;
293
294 for( i = 0; i < bytes_to_write; i++ )
295 write_buf[i] = (unsigned char) lcppm5( write_state );
296
297 offset_to_write = 0;
298 }
299
300 ret = ssl_write( &ssl, write_buf + offset_to_write,
301 bytes_to_write );
302
303 if( ret >= 0 )
304 {
305 nb_written += ret;
306 bytes_to_write -= ret;
307 offset_to_write += ret;
308 }
309
Paul Bakker40e46942009-01-03 21:51:57 +0000310 if( ret == POLARSSL_ERR_SSL_PEER_CLOSE_NOTIFY ||
311 ret == POLARSSL_ERR_NET_CONN_RESET )
Paul Bakker5121ce52009-01-03 21:22:43 +0000312 {
313 ret = 0;
314 goto exit;
315 }
316
Paul Bakker831a7552011-05-18 13:32:51 +0000317 if( ret < 0 && ret != POLARSSL_ERR_NET_WANT_READ &&
318 ret != POLARSSL_ERR_NET_WANT_WRITE )
Paul Bakker5121ce52009-01-03 21:22:43 +0000319 {
320 printf( " ! ssl_write returned %d\n\n", ret );
321 break;
322 }
323 }
324
325 if( opt->command & COMMAND_READ )
326 {
327 if( bytes_to_read == 0 )
328 {
329 bytes_to_read = rand() % opt->buffer_size;
330 offset_to_read = 0;
331 }
332
333 ret = ssl_read( &ssl, read_buf + offset_to_read,
334 bytes_to_read );
335
336 if( ret >= 0 )
337 {
338 for( i = 0; i < ret; i++ )
339 {
340 if( read_buf[offset_to_read + i] !=
341 (unsigned char) lcppm5( read_state ) )
342 {
343 ret = 1;
344 printf( " ! plaintext mismatch\n\n" );
345 goto exit;
346 }
347 }
348
349 nb_read += ret;
350 bytes_to_read -= ret;
351 offset_to_read += ret;
352 }
353
Paul Bakker40e46942009-01-03 21:51:57 +0000354 if( ret == POLARSSL_ERR_SSL_PEER_CLOSE_NOTIFY ||
355 ret == POLARSSL_ERR_NET_CONN_RESET )
Paul Bakker5121ce52009-01-03 21:22:43 +0000356 {
357 ret = 0;
358 goto exit;
359 }
360
Paul Bakker831a7552011-05-18 13:32:51 +0000361 if( ret < 0 && ret != POLARSSL_ERR_NET_WANT_READ &&
362 ret != POLARSSL_ERR_NET_WANT_WRITE )
Paul Bakker5121ce52009-01-03 21:22:43 +0000363 {
364 printf( " ! ssl_read returned %d\n\n", ret );
365 break;
366 }
367 }
368
369 ret = 0;
370
371 if( opt->max_bytes != 0 &&
372 ( opt->max_bytes <= nb_read ||
373 opt->max_bytes <= nb_written ) )
374 break;
375
376 if( opt->conn_timeout != 0 &&
377 opt->conn_timeout <= (int) get_timer( &t, 0 ) )
378 break;
379 }
380
381exit:
382
383 fflush( stdout );
384
385 if( read_buf != NULL )
386 free( read_buf );
387
388 if( write_buf != NULL )
389 free( write_buf );
390
391 ssl_close_notify( &ssl );
392 x509_free( &srvcert );
393 rsa_free( &rsa );
394 ssl_free( &ssl );
395 net_close( client_fd );
396
397 return( ret );
398}
399
400#define USAGE \
401 "\n usage: ssl_test opmode=<> command=<>...\n" \
402 "\n acceptable parameters:\n" \
403 " opmode=client/server default: <none>\n" \
404 " iomode=block/nonblock default: block\n" \
405 " server_name=%%s default: localhost\n" \
406 " server_port=%%d default: 4433\n" \
407 " command=read/write/both default: read\n" \
408 " buffer_size=%%d (bytes) default: 1024\n" \
409 " max_bytes=%%d (bytes) default: 0 (no limit)\n" \
410 " debug_level=%%d default: 0 (disabled)\n" \
411 " conn_timeout=%%d (ms) default: 0 (no timeout)\n" \
412 " max_connections=%%d default: 0 (no limit)\n" \
413 " session_reuse=on/off default: on (enabled)\n" \
414 " session_lifetime=%%d (s) default: 86400\n" \
Paul Bakkere3166ce2011-01-27 17:40:50 +0000415 " force_ciphersuite=<name> default: all enabled\n" \
416 " acceptable ciphersuite names:\n"
Paul Bakker5121ce52009-01-03 21:22:43 +0000417
418int main( int argc, char *argv[] )
419{
420 int i, j, n;
Paul Bakkere3166ce2011-01-27 17:40:50 +0000421 const int *list;
Paul Bakker5121ce52009-01-03 21:22:43 +0000422 int ret = 1;
423 int nb_conn;
424 char *p, *q;
425 struct options opt;
426
427 if( argc == 1 )
428 {
429 usage:
430 printf( USAGE );
Paul Bakkere3166ce2011-01-27 17:40:50 +0000431
432 list = ssl_list_ciphersuites();
433 while( *list )
434 {
435 printf(" %s\n", ssl_get_ciphersuite_name( *list ) );
436 list++;
437 }
438 printf("\n");
Paul Bakker5121ce52009-01-03 21:22:43 +0000439 goto exit;
440 }
441
442 opt.opmode = DFL_OPMODE;
443 opt.iomode = DFL_IOMODE;
444 opt.server_name = DFL_SERVER_NAME;
445 opt.server_port = DFL_SERVER_PORT;
446 opt.command = DFL_COMMAND;
447 opt.buffer_size = DFL_BUFFER_SIZE;
448 opt.max_bytes = DFL_MAX_BYTES;
449 opt.debug_level = DFL_DEBUG_LEVEL;
450 opt.conn_timeout = DFL_CONN_TIMEOUT;
451 opt.max_connections = DFL_MAX_CONNECTIONS;
452 opt.session_reuse = DFL_SESSION_REUSE;
453 opt.session_lifetime = DFL_SESSION_LIFETIME;
Paul Bakkere3166ce2011-01-27 17:40:50 +0000454 opt.force_ciphersuite[0] = DFL_FORCE_CIPHER;
Paul Bakker5121ce52009-01-03 21:22:43 +0000455
456 for( i = 1; i < argc; i++ )
457 {
458 n = strlen( argv[i] );
459
460 for( j = 0; j < n; j++ )
461 {
462 if( argv[i][j] >= 'A' && argv[i][j] <= 'Z' )
463 argv[i][j] |= 0x20;
464 }
465
466 p = argv[i];
467 if( ( q = strchr( p, '=' ) ) == NULL )
468 continue;
469 *q++ = '\0';
470
471 if( strcmp( p, "opmode" ) == 0 )
472 {
473 if( strcmp( q, "client" ) == 0 )
474 opt.opmode = OPMODE_CLIENT;
475 else
476 if( strcmp( q, "server" ) == 0 )
477 opt.opmode = OPMODE_SERVER;
478 else goto usage;
479 }
480
481 if( strcmp( p, "iomode" ) == 0 )
482 {
483 if( strcmp( q, "block" ) == 0 )
484 opt.iomode = IOMODE_BLOCK;
485 else
486 if( strcmp( q, "nonblock" ) == 0 )
487 opt.iomode = IOMODE_NONBLOCK;
488 else goto usage;
489 }
490
491 if( strcmp( p, "server_name" ) == 0 )
492 opt.server_name = q;
493
494 if( strcmp( p, "server_port" ) == 0 )
495 {
496 opt.server_port = atoi( q );
497 if( opt.server_port < 1 || opt.server_port > 65535 )
498 goto usage;
499 }
500
501 if( strcmp( p, "command" ) == 0 )
502 {
503 if( strcmp( q, "read" ) == 0 )
504 opt.command = COMMAND_READ;
505 else
506 if( strcmp( q, "write" ) == 0 )
507 opt.command = COMMAND_WRITE;
508 else
509 if( strcmp( q, "both" ) == 0 )
510 {
511 opt.iomode = IOMODE_NONBLOCK;
512 opt.command = COMMAND_BOTH;
513 }
514 else goto usage;
515 }
516
517 if( strcmp( p, "buffer_size" ) == 0 )
518 {
519 opt.buffer_size = atoi( q );
520 if( opt.buffer_size < 1 || opt.buffer_size > 1048576 )
521 goto usage;
522 }
523
524 if( strcmp( p, "max_bytes" ) == 0 )
525 opt.max_bytes = atoi( q );
526
527 if( strcmp( p, "debug_level" ) == 0 )
528 opt.debug_level = atoi( q );
529
530 if( strcmp( p, "conn_timeout" ) == 0 )
531 opt.conn_timeout = atoi( q );
532
533 if( strcmp( p, "max_connections" ) == 0 )
534 opt.max_connections = atoi( q );
535
536 if( strcmp( p, "session_reuse" ) == 0 )
537 {
538 if( strcmp( q, "on" ) == 0 )
539 opt.session_reuse = 1;
540 else
541 if( strcmp( q, "off" ) == 0 )
542 opt.session_reuse = 0;
543 else
544 goto usage;
545 }
546
547 if( strcmp( p, "session_lifetime" ) == 0 )
548 opt.session_lifetime = atoi( q );
549
Paul Bakkere3166ce2011-01-27 17:40:50 +0000550 if( strcmp( p, "force_ciphersuite" ) == 0 )
Paul Bakker5121ce52009-01-03 21:22:43 +0000551 {
Paul Bakkere3166ce2011-01-27 17:40:50 +0000552 opt.force_ciphersuite[0] = -1;
Paul Bakker5121ce52009-01-03 21:22:43 +0000553
Paul Bakkere3166ce2011-01-27 17:40:50 +0000554 opt.force_ciphersuite[0] = ssl_get_ciphersuite_id( q );
Paul Bakker5121ce52009-01-03 21:22:43 +0000555
Paul Bakkere3166ce2011-01-27 17:40:50 +0000556 if( opt.force_ciphersuite[0] <= 0 )
Paul Bakker5121ce52009-01-03 21:22:43 +0000557 goto usage;
558
Paul Bakkere3166ce2011-01-27 17:40:50 +0000559 opt.force_ciphersuite[1] = 0;
Paul Bakker5121ce52009-01-03 21:22:43 +0000560 }
561 }
562
563 switch( opt.opmode )
564 {
565 case OPMODE_CLIENT:
566 break;
567
568 case OPMODE_SERVER:
569 break;
570
571 default:
572 goto usage;
573 }
574
575 nb_conn = 0;
576
577 do {
578 nb_conn++;
579 ret = ssl_test( &opt );
580 if( opt.max_connections != 0 &&
581 opt.max_connections <= nb_conn )
582 break;
583 }
584 while( ret == 0 );
585
586exit:
587
Paul Bakkercce9d772011-11-18 14:26:47 +0000588#if defined(_WIN32)
Paul Bakker5121ce52009-01-03 21:22:43 +0000589 printf( " Press Enter to exit this program.\n" );
590 fflush( stdout ); getchar();
591#endif
592
593 return( ret );
594}
Paul Bakker508ad5a2011-12-04 17:09:26 +0000595#endif /* POLARSSL_BIGNUM_C && POLARSSL_ENTROPY_C && POLARSSL_SSL_TLS_C &&
Paul Bakker5690efc2011-05-26 13:16:06 +0000596 POLARSSL_SSL_SRV_C && POLARSSL_SSL_CLI_C && POLARSSL_NET_C &&
Paul Bakker508ad5a2011-12-04 17:09:26 +0000597 POLARSSL_RSA_C && POLARSSL_CTR_DRBG_C */