blob: 4ac71a8deba28cdf26927c5fcbfd41d10fd0b4f5 [file] [log] [blame]
Paul Bakker5121ce52009-01-03 21:22:43 +00001/*
2 * Self-test demonstration program
3 *
Bence Szépkúti44bfbe32020-08-19 16:54:51 +02004 * Copyright The Mbed TLS Contributors
Bence Szépkúti4e9f7122020-06-05 13:02:18 +02005 * SPDX-License-Identifier: Apache-2.0 OR GPL-2.0-or-later
6 *
7 * This file is provided under the Apache License 2.0, or the
8 * GNU General Public License v2.0 or later.
9 *
10 * **********
11 * Apache License 2.0:
Manuel Pégourié-Gonnard37ff1402015-09-04 14:21:07 +020012 *
13 * Licensed under the Apache License, Version 2.0 (the "License"); you may
14 * not use this file except in compliance with the License.
15 * You may obtain a copy of the License at
16 *
17 * http://www.apache.org/licenses/LICENSE-2.0
18 *
19 * Unless required by applicable law or agreed to in writing, software
20 * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
21 * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
22 * See the License for the specific language governing permissions and
23 * limitations under the License.
Paul Bakkerb96f1542010-07-18 20:36:00 +000024 *
Bence Szépkúti4e9f7122020-06-05 13:02:18 +020025 * **********
26 *
27 * **********
28 * GNU General Public License v2.0 or later:
29 *
30 * This program is free software; you can redistribute it and/or modify
31 * it under the terms of the GNU General Public License as published by
32 * the Free Software Foundation; either version 2 of the License, or
33 * (at your option) any later version.
34 *
35 * This program is distributed in the hope that it will be useful,
36 * but WITHOUT ANY WARRANTY; without even the implied warranty of
37 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
38 * GNU General Public License for more details.
39 *
40 * You should have received a copy of the GNU General Public License along
41 * with this program; if not, write to the Free Software Foundation, Inc.,
42 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
43 *
44 * **********
Paul Bakker5121ce52009-01-03 21:22:43 +000045 */
46
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +020047#if !defined(MBEDTLS_CONFIG_FILE)
Manuel Pégourié-Gonnard7f809972015-03-09 17:05:11 +000048#include "mbedtls/config.h"
Manuel Pégourié-Gonnardcef4ad22014-04-29 12:39:06 +020049#else
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +020050#include MBEDTLS_CONFIG_FILE
Manuel Pégourié-Gonnardcef4ad22014-04-29 12:39:06 +020051#endif
Paul Bakker5121ce52009-01-03 21:22:43 +000052
Manuel Pégourié-Gonnard7f809972015-03-09 17:05:11 +000053#include "mbedtls/entropy.h"
Simon Butcherb6a73c92016-06-18 22:45:37 +010054#include "mbedtls/entropy_poll.h"
Manuel Pégourié-Gonnard7f809972015-03-09 17:05:11 +000055#include "mbedtls/hmac_drbg.h"
56#include "mbedtls/ctr_drbg.h"
57#include "mbedtls/dhm.h"
58#include "mbedtls/gcm.h"
59#include "mbedtls/ccm.h"
Robert Cragiedc5c7b92015-12-11 15:49:45 +000060#include "mbedtls/cmac.h"
Manuel Pégourié-Gonnard7f809972015-03-09 17:05:11 +000061#include "mbedtls/md2.h"
62#include "mbedtls/md4.h"
63#include "mbedtls/md5.h"
64#include "mbedtls/ripemd160.h"
65#include "mbedtls/sha1.h"
66#include "mbedtls/sha256.h"
67#include "mbedtls/sha512.h"
68#include "mbedtls/arc4.h"
69#include "mbedtls/des.h"
70#include "mbedtls/aes.h"
71#include "mbedtls/camellia.h"
72#include "mbedtls/base64.h"
73#include "mbedtls/bignum.h"
74#include "mbedtls/rsa.h"
75#include "mbedtls/x509.h"
76#include "mbedtls/xtea.h"
77#include "mbedtls/pkcs5.h"
Manuel Pégourié-Gonnard7f809972015-03-09 17:05:11 +000078#include "mbedtls/ecp.h"
Manuel Pégourié-Gonnard4d8685b2015-08-05 15:44:42 +020079#include "mbedtls/ecjpake.h"
Manuel Pégourié-Gonnard7f809972015-03-09 17:05:11 +000080#include "mbedtls/timing.h"
Paul Bakker5121ce52009-01-03 21:22:43 +000081
Rich Evans18b78c72015-02-11 14:06:19 +000082#include <string.h>
83
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +020084#if defined(MBEDTLS_PLATFORM_C)
Manuel Pégourié-Gonnard7f809972015-03-09 17:05:11 +000085#include "mbedtls/platform.h"
Rich Evans18b78c72015-02-11 14:06:19 +000086#else
87#include <stdio.h>
Janos Follath2e3aca22016-03-18 16:25:52 +000088#include <stdlib.h>
Gilles Peskineea5d3572019-09-17 18:18:58 +020089#define mbedtls_calloc calloc
90#define mbedtls_free free
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +020091#define mbedtls_printf printf
Manuel Pégourié-Gonnard7b6dcbe2015-06-22 10:48:01 +020092#define mbedtls_snprintf snprintf
Janos Follath2e3aca22016-03-18 16:25:52 +000093#define mbedtls_exit exit
94#define MBEDTLS_EXIT_SUCCESS EXIT_SUCCESS
95#define MBEDTLS_EXIT_FAILURE EXIT_FAILURE
Rich Evans18b78c72015-02-11 14:06:19 +000096#endif
97
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +020098#if defined(MBEDTLS_MEMORY_BUFFER_ALLOC_C)
Manuel Pégourié-Gonnard7f809972015-03-09 17:05:11 +000099#include "mbedtls/memory_buffer_alloc.h"
Paul Bakker6e339b52013-07-03 13:37:05 +0200100#endif
101
Gilles Peskineea5d3572019-09-17 18:18:58 +0200102
103#if defined MBEDTLS_SELF_TEST
104/* Sanity check for malloc. This is not expected to fail, and is rather
105 * intended to display potentially useful information about the platform,
106 * in particular the behavior of malloc(0). */
107static int calloc_self_test( int verbose )
108{
109 int failures = 0;
110 void *empty1 = mbedtls_calloc( 0, 1 );
111 void *empty2 = mbedtls_calloc( 0, 1 );
112 void *buffer1 = mbedtls_calloc( 1, 1 );
113 void *buffer2 = mbedtls_calloc( 1, 1 );
114 uintptr_t old_buffer1;
115
116 if( empty1 == NULL && empty2 == NULL )
117 {
118 if( verbose )
119 mbedtls_printf( " CALLOC(0): passed (NULL)\n" );
120 }
121 else if( empty1 == NULL || empty2 == NULL )
122 {
123 if( verbose )
124 mbedtls_printf( " CALLOC(0): failed (mix of NULL and non-NULL)\n" );
125 ++failures;
126 }
127 else if( empty1 == empty2 )
128 {
129 if( verbose )
130 mbedtls_printf( " CALLOC(0): passed (same non-null)\n" );
131 }
132 else
133 {
134 if( verbose )
135 mbedtls_printf( " CALLOC(0): passed (distinct non-null)\n" );
136 }
137
138 if( buffer1 == NULL || buffer2 == NULL )
139 {
140 if( verbose )
141 mbedtls_printf( " CALLOC(1): failed (NULL)\n" );
142 ++failures;
143 }
144 else if( buffer1 == buffer2 )
145 {
146 if( verbose )
147 mbedtls_printf( " CALLOC(1): failed (same buffer twice)\n" );
148 ++failures;
149 }
150 else
151 {
152 if( verbose )
153 mbedtls_printf( " CALLOC(1): passed\n" );
154 }
155
156 old_buffer1 = (uintptr_t) buffer1;
157 mbedtls_free( buffer1 );
158 buffer1 = mbedtls_calloc( 1, 1 );
159 if( buffer1 == NULL )
160 {
161 if( verbose )
162 mbedtls_printf( " CALLOC(1 again): failed (NULL)\n" );
163 ++failures;
164 }
165 else
166 {
167 if( verbose )
168 mbedtls_printf( " CALLOC(1 again): passed (%s address)\n",
169 (uintptr_t) old_buffer1 == (uintptr_t) buffer1 ?
170 "same" : "different" );
171 }
172
173 if( verbose )
174 mbedtls_printf( "\n" );
175 mbedtls_free( empty1 );
176 mbedtls_free( empty2 );
177 mbedtls_free( buffer1 );
178 mbedtls_free( buffer2 );
179 return( failures );
180}
181#endif /* MBEDTLS_SELF_TEST */
182
Manuel Pégourié-Gonnard7b6dcbe2015-06-22 10:48:01 +0200183static int test_snprintf( size_t n, const char ref_buf[10], int ref_ret )
184{
185 int ret;
186 char buf[10] = "xxxxxxxxx";
Manuel Pégourié-Gonnard4b00f082015-06-26 11:24:32 +0200187 const char ref[10] = "xxxxxxxxx";
Manuel Pégourié-Gonnard7b6dcbe2015-06-22 10:48:01 +0200188
189 ret = mbedtls_snprintf( buf, n, "%s", "123" );
190 if( ret < 0 || (size_t) ret >= n )
191 ret = -1;
192
Manuel Pégourié-Gonnard4b00f082015-06-26 11:24:32 +0200193 if( strncmp( ref_buf, buf, sizeof( buf ) ) != 0 ||
194 ref_ret != ret ||
195 memcmp( buf + n, ref + n, sizeof( buf ) - n ) != 0 )
Manuel Pégourié-Gonnard7b6dcbe2015-06-22 10:48:01 +0200196 {
197 return( 1 );
198 }
199
200 return( 0 );
201}
202
203static int run_test_snprintf( void )
204{
205 return( test_snprintf( 0, "xxxxxxxxx", -1 ) != 0 ||
Manuel Pégourié-Gonnard4b00f082015-06-26 11:24:32 +0200206 test_snprintf( 1, "", -1 ) != 0 ||
207 test_snprintf( 2, "1", -1 ) != 0 ||
208 test_snprintf( 3, "12", -1 ) != 0 ||
209 test_snprintf( 4, "123", 3 ) != 0 ||
210 test_snprintf( 5, "123", 3 ) != 0 );
Manuel Pégourié-Gonnard7b6dcbe2015-06-22 10:48:01 +0200211}
212
Simon Butcherb6a73c92016-06-18 22:45:37 +0100213/*
214 * Check if a seed file is present, and if not create one for the entropy
215 * self-test. If this fails, we attempt the test anyway, so no error is passed
216 * back.
217 */
Gilles Peskine319ac802017-12-15 14:57:18 +0100218#if defined(MBEDTLS_SELF_TEST) && defined(MBEDTLS_ENTROPY_C)
219#if defined(MBEDTLS_ENTROPY_NV_SEED) && !defined(MBEDTLS_NO_PLATFORM_ENTROPY)
Simon Butcherb6a73c92016-06-18 22:45:37 +0100220static void create_entropy_seed_file( void )
221{
222 int result;
223 size_t output_len = 0;
224 unsigned char seed_value[MBEDTLS_ENTROPY_BLOCK_SIZE];
225
226 /* Attempt to read the entropy seed file. If this fails - attempt to write
227 * to the file to ensure one is present. */
228 result = mbedtls_platform_std_nv_seed_read( seed_value,
229 MBEDTLS_ENTROPY_BLOCK_SIZE );
230 if( 0 == result )
231 return;
232
233 result = mbedtls_platform_entropy_poll( NULL,
234 seed_value,
235 MBEDTLS_ENTROPY_BLOCK_SIZE,
236 &output_len );
237 if( 0 != result )
238 return;
239
240 if( MBEDTLS_ENTROPY_BLOCK_SIZE != output_len )
241 return;
242
243 mbedtls_platform_std_nv_seed_write( seed_value, MBEDTLS_ENTROPY_BLOCK_SIZE );
244}
245#endif
246
Gilles Peskine319ac802017-12-15 14:57:18 +0100247int mbedtls_entropy_self_test_wrapper( int verbose )
248{
249#if defined(MBEDTLS_ENTROPY_NV_SEED) && !defined(MBEDTLS_NO_PLATFORM_ENTROPY)
250 create_entropy_seed_file( );
251#endif
252 return( mbedtls_entropy_self_test( verbose ) );
253}
254#endif
255
256#if defined(MBEDTLS_SELF_TEST)
257#if defined(MBEDTLS_MEMORY_BUFFER_ALLOC_C)
258int mbedtls_memory_buffer_alloc_free_and_self_test( int verbose )
259{
260 if( verbose != 0 )
261 {
262#if defined(MBEDTLS_MEMORY_DEBUG)
263 mbedtls_memory_buffer_alloc_status( );
264#endif
265 }
266 mbedtls_memory_buffer_alloc_free( );
267 return( mbedtls_memory_buffer_alloc_self_test( verbose ) );
268}
269#endif
270
271typedef struct
272{
273 const char *name;
274 int ( *function )( int );
275} selftest_t;
276
277const selftest_t selftests[] =
278{
Gilles Peskineea5d3572019-09-17 18:18:58 +0200279 {"calloc", calloc_self_test},
Gilles Peskine319ac802017-12-15 14:57:18 +0100280#if defined(MBEDTLS_MD2_C)
281 {"md2", mbedtls_md2_self_test},
282#endif
283#if defined(MBEDTLS_MD4_C)
284 {"md4", mbedtls_md4_self_test},
285#endif
286#if defined(MBEDTLS_MD5_C)
287 {"md5", mbedtls_md5_self_test},
288#endif
289#if defined(MBEDTLS_RIPEMD160_C)
290 {"ripemd160", mbedtls_ripemd160_self_test},
291#endif
292#if defined(MBEDTLS_SHA1_C)
293 {"sha1", mbedtls_sha1_self_test},
294#endif
295#if defined(MBEDTLS_SHA256_C)
296 {"sha256", mbedtls_sha256_self_test},
297#endif
298#if defined(MBEDTLS_SHA512_C)
299 {"sha512", mbedtls_sha512_self_test},
300#endif
301#if defined(MBEDTLS_ARC4_C)
302 {"arc4", mbedtls_arc4_self_test},
303#endif
304#if defined(MBEDTLS_DES_C)
305 {"des", mbedtls_des_self_test},
306#endif
307#if defined(MBEDTLS_AES_C)
308 {"aes", mbedtls_aes_self_test},
309#endif
310#if defined(MBEDTLS_GCM_C) && defined(MBEDTLS_AES_C)
311 {"gcm", mbedtls_gcm_self_test},
312#endif
313#if defined(MBEDTLS_CCM_C) && defined(MBEDTLS_AES_C)
314 {"ccm", mbedtls_ccm_self_test},
315#endif
316#if defined(MBEDTLS_CMAC_C)
317 {"cmac", mbedtls_cmac_self_test},
318#endif
319#if defined(MBEDTLS_BASE64_C)
320 {"base64", mbedtls_base64_self_test},
321#endif
322#if defined(MBEDTLS_BIGNUM_C)
323 {"mpi", mbedtls_mpi_self_test},
324#endif
325#if defined(MBEDTLS_RSA_C)
326 {"rsa", mbedtls_rsa_self_test},
327#endif
328#if defined(MBEDTLS_X509_USE_C)
329 {"x509", mbedtls_x509_self_test},
330#endif
331#if defined(MBEDTLS_XTEA_C)
332 {"xtea", mbedtls_xtea_self_test},
333#endif
334#if defined(MBEDTLS_CAMELLIA_C)
335 {"camellia", mbedtls_camellia_self_test},
336#endif
337#if defined(MBEDTLS_CTR_DRBG_C)
338 {"ctr_drbg", mbedtls_ctr_drbg_self_test},
339#endif
340#if defined(MBEDTLS_HMAC_DRBG_C)
341 {"hmac_drbg", mbedtls_hmac_drbg_self_test},
342#endif
343#if defined(MBEDTLS_ECP_C)
344 {"ecp", mbedtls_ecp_self_test},
345#endif
346#if defined(MBEDTLS_ECJPAKE_C)
347 {"ecjpake", mbedtls_ecjpake_self_test},
348#endif
349#if defined(MBEDTLS_DHM_C)
350 {"dhm", mbedtls_dhm_self_test},
351#endif
352#if defined(MBEDTLS_ENTROPY_C)
353 {"entropy", mbedtls_entropy_self_test_wrapper},
354#endif
355#if defined(MBEDTLS_PKCS5_C)
356 {"pkcs5", mbedtls_pkcs5_self_test},
357#endif
358/* Slower test after the faster ones */
359#if defined(MBEDTLS_TIMING_C)
360 {"timing", mbedtls_timing_self_test},
361#endif
362/* Heap test comes last */
363#if defined(MBEDTLS_MEMORY_BUFFER_ALLOC_C)
364 {"memory_buffer_alloc", mbedtls_memory_buffer_alloc_free_and_self_test},
365#endif
366 {NULL, NULL}
367};
Gilles Peskinec82fbb42017-12-15 15:01:27 +0100368#endif /* MBEDTLS_SELF_TEST */
Gilles Peskine319ac802017-12-15 14:57:18 +0100369
Paul Bakker5121ce52009-01-03 21:22:43 +0000370int main( int argc, char *argv[] )
371{
Gilles Peskinec82fbb42017-12-15 15:01:27 +0100372#if defined(MBEDTLS_SELF_TEST)
Gilles Peskine319ac802017-12-15 14:57:18 +0100373 const selftest_t *test;
Gilles Peskinec82fbb42017-12-15 15:01:27 +0100374#endif /* MBEDTLS_SELF_TEST */
Gilles Peskineff79d272017-12-20 18:09:27 +0100375 char **argp;
376 int v = 1; /* v=1 for verbose mode */
377 int exclude_mode = 0;
378 int suites_tested = 0, suites_failed = 0;
Paul Bakker70940ca2016-07-14 14:30:45 +0100379#if defined(MBEDTLS_MEMORY_BUFFER_ALLOC_C) && defined(MBEDTLS_SELF_TEST)
Paul Bakker6e339b52013-07-03 13:37:05 +0200380 unsigned char buf[1000000];
381#endif
Manuel Pégourié-Gonnardd14acbc2015-05-29 11:26:37 +0200382 void *pointer;
383
384 /*
385 * The C standard doesn't guarantee that all-bits-0 is the representation
386 * of a NULL pointer. We do however use that in our code for initializing
387 * structures, which should work on every modern platform. Let's be sure.
388 */
389 memset( &pointer, 0, sizeof( void * ) );
390 if( pointer != NULL )
391 {
392 mbedtls_printf( "all-bits-zero is not a NULL pointer\n" );
Janos Follath2e3aca22016-03-18 16:25:52 +0000393 mbedtls_exit( MBEDTLS_EXIT_FAILURE );
Manuel Pégourié-Gonnardd14acbc2015-05-29 11:26:37 +0200394 }
Paul Bakker5121ce52009-01-03 21:22:43 +0000395
Manuel Pégourié-Gonnard7b6dcbe2015-06-22 10:48:01 +0200396 /*
397 * Make sure we have a snprintf that correctly zero-terminates
398 */
399 if( run_test_snprintf() != 0 )
400 {
401 mbedtls_printf( "the snprintf implementation is broken\n" );
Janos Follath2e3aca22016-03-18 16:25:52 +0000402 mbedtls_exit( MBEDTLS_EXIT_FAILURE );
Manuel Pégourié-Gonnard7b6dcbe2015-06-22 10:48:01 +0200403 }
404
Gilles Peskineff79d272017-12-20 18:09:27 +0100405 for( argp = argv + ( argc >= 1 ? 1 : argc ); *argp != NULL; ++argp )
SimonB5a8afb82016-03-11 00:40:54 +0000406 {
Gilles Peskineff79d272017-12-20 18:09:27 +0100407 if( strcmp( *argp, "--quiet" ) == 0 ||
408 strcmp( *argp, "-q" ) == 0 )
409 {
410 v = 0;
411 }
412 else if( strcmp( *argp, "--exclude" ) == 0 ||
413 strcmp( *argp, "-x" ) == 0 )
414 {
415 exclude_mode = 1;
416 }
417 else
418 break;
SimonB5a8afb82016-03-11 00:40:54 +0000419 }
Gilles Peskineff79d272017-12-20 18:09:27 +0100420
421 if( v != 0 )
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200422 mbedtls_printf( "\n" );
Paul Bakker5121ce52009-01-03 21:22:43 +0000423
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200424#if defined(MBEDTLS_SELF_TEST)
Paul Bakker135b98e2011-05-25 11:13:47 +0000425
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200426#if defined(MBEDTLS_MEMORY_BUFFER_ALLOC_C)
427 mbedtls_memory_buffer_alloc_init( buf, sizeof(buf) );
Paul Bakker6e339b52013-07-03 13:37:05 +0200428#endif
429
Gilles Peskineff79d272017-12-20 18:09:27 +0100430 if( *argp != NULL && exclude_mode == 0 )
SimonB5a8afb82016-03-11 00:40:54 +0000431 {
Gilles Peskinec82fbb42017-12-15 15:01:27 +0100432 /* Run the specified tests */
433 for( ; *argp != NULL; argp++ )
Gilles Peskine319ac802017-12-15 14:57:18 +0100434 {
Gilles Peskinec82fbb42017-12-15 15:01:27 +0100435 for( test = selftests; test->name != NULL; test++ )
436 {
437 if( !strcmp( *argp, test->name ) )
438 {
439 if( test->function( v ) != 0 )
440 {
441 suites_failed++;
442 }
443 suites_tested++;
444 break;
445 }
446 }
447 if( test->name == NULL )
448 {
449 mbedtls_printf( " Test suite %s not available -> failed\n\n", *argp );
450 suites_failed++;
451 }
Gilles Peskine319ac802017-12-15 14:57:18 +0100452 }
Gilles Peskinec82fbb42017-12-15 15:01:27 +0100453 }
454 else
455 {
Gilles Peskineff79d272017-12-20 18:09:27 +0100456 /* Run all the tests except excluded ones */
Gilles Peskinec82fbb42017-12-15 15:01:27 +0100457 for( test = selftests; test->name != NULL; test++ )
458 {
Gilles Peskineff79d272017-12-20 18:09:27 +0100459 if( exclude_mode )
460 {
461 char **excluded;
462 for( excluded = argp; *excluded != NULL; ++excluded )
463 {
464 if( !strcmp( *excluded, test->name ) )
465 break;
466 }
467 if( *excluded )
468 {
469 if( v )
470 mbedtls_printf( " Skip: %s\n", test->name );
471 continue;
472 }
473 }
Gilles Peskinec82fbb42017-12-15 15:01:27 +0100474 if( test->function( v ) != 0 )
475 {
476 suites_failed++;
477 }
478 suites_tested++;
479 }
SimonB5a8afb82016-03-11 00:40:54 +0000480 }
Manuel Pégourié-Gonnard5ba1d522014-11-27 11:33:55 +0100481
Paul Bakker70940ca2016-07-14 14:30:45 +0100482#else
Gilles Peskineff79d272017-12-20 18:09:27 +0100483 (void) exclude_mode;
Paul Bakker70940ca2016-07-14 14:30:45 +0100484 mbedtls_printf( " MBEDTLS_SELF_TEST not defined.\n" );
485#endif
486
Manuel Pégourié-Gonnard5ba1d522014-11-27 11:33:55 +0100487 if( v != 0 )
488 {
Simon Butcherf1547632016-03-14 23:09:39 +0000489 mbedtls_printf( " Executed %d test suites\n\n", suites_tested );
SimonB5a8afb82016-03-11 00:40:54 +0000490
491 if( suites_failed > 0)
492 {
493 mbedtls_printf( " [ %d tests FAIL ]\n\n", suites_failed );
494 }
495 else
496 {
497 mbedtls_printf( " [ All tests PASS ]\n\n" );
498 }
Paul Bakkercce9d772011-11-18 14:26:47 +0000499#if defined(_WIN32)
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200500 mbedtls_printf( " Press Enter to exit this program.\n" );
Paul Bakker5121ce52009-01-03 21:22:43 +0000501 fflush( stdout ); getchar();
502#endif
503 }
Paul Bakker5121ce52009-01-03 21:22:43 +0000504
SimonB5a8afb82016-03-11 00:40:54 +0000505 if( suites_failed > 0)
Janos Follath2e3aca22016-03-18 16:25:52 +0000506 mbedtls_exit( MBEDTLS_EXIT_FAILURE );
SimonB5a8afb82016-03-11 00:40:54 +0000507
Krzysztof Stachowiaka0865222019-04-24 14:24:46 +0200508 mbedtls_exit( MBEDTLS_EXIT_SUCCESS );
Paul Bakker5121ce52009-01-03 21:22:43 +0000509}