blob: 8a4a9e3f0387c05d5d8d779a6bf48b5eb4a05235 [file] [log] [blame]
Paul Bakker5121ce52009-01-03 21:22:43 +00001/*
2 * Self-test demonstration program
3 *
Manuel Pégourié-Gonnard6fb81872015-07-27 11:11:48 +02004 * Copyright (C) 2006-2015, ARM Limited, All Rights Reserved
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 * **********
45 *
Manuel Pégourié-Gonnardfe446432015-03-06 13:17:10 +000046 * This file is part of mbed TLS (https://tls.mbed.org)
Paul Bakker5121ce52009-01-03 21:22:43 +000047 */
48
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +020049#if !defined(MBEDTLS_CONFIG_FILE)
Manuel Pégourié-Gonnard7f809972015-03-09 17:05:11 +000050#include "mbedtls/config.h"
Manuel Pégourié-Gonnardcef4ad22014-04-29 12:39:06 +020051#else
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +020052#include MBEDTLS_CONFIG_FILE
Manuel Pégourié-Gonnardcef4ad22014-04-29 12:39:06 +020053#endif
Paul Bakker5121ce52009-01-03 21:22:43 +000054
Manuel Pégourié-Gonnard7f809972015-03-09 17:05:11 +000055#include "mbedtls/entropy.h"
Simon Butcherb6a73c92016-06-18 22:45:37 +010056#include "mbedtls/entropy_poll.h"
Manuel Pégourié-Gonnard7f809972015-03-09 17:05:11 +000057#include "mbedtls/hmac_drbg.h"
58#include "mbedtls/ctr_drbg.h"
59#include "mbedtls/dhm.h"
60#include "mbedtls/gcm.h"
61#include "mbedtls/ccm.h"
Robert Cragiedc5c7b92015-12-11 15:49:45 +000062#include "mbedtls/cmac.h"
Manuel Pégourié-Gonnard7f809972015-03-09 17:05:11 +000063#include "mbedtls/md2.h"
64#include "mbedtls/md4.h"
65#include "mbedtls/md5.h"
66#include "mbedtls/ripemd160.h"
67#include "mbedtls/sha1.h"
68#include "mbedtls/sha256.h"
69#include "mbedtls/sha512.h"
70#include "mbedtls/arc4.h"
71#include "mbedtls/des.h"
72#include "mbedtls/aes.h"
73#include "mbedtls/camellia.h"
74#include "mbedtls/base64.h"
75#include "mbedtls/bignum.h"
76#include "mbedtls/rsa.h"
77#include "mbedtls/x509.h"
78#include "mbedtls/xtea.h"
79#include "mbedtls/pkcs5.h"
Manuel Pégourié-Gonnard7f809972015-03-09 17:05:11 +000080#include "mbedtls/ecp.h"
Manuel Pégourié-Gonnard4d8685b2015-08-05 15:44:42 +020081#include "mbedtls/ecjpake.h"
Manuel Pégourié-Gonnard7f809972015-03-09 17:05:11 +000082#include "mbedtls/timing.h"
Paul Bakker5121ce52009-01-03 21:22:43 +000083
Rich Evans18b78c72015-02-11 14:06:19 +000084#include <string.h>
85
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +020086#if defined(MBEDTLS_PLATFORM_C)
Manuel Pégourié-Gonnard7f809972015-03-09 17:05:11 +000087#include "mbedtls/platform.h"
Rich Evans18b78c72015-02-11 14:06:19 +000088#else
89#include <stdio.h>
Janos Follath2e3aca22016-03-18 16:25:52 +000090#include <stdlib.h>
Gilles Peskineea5d3572019-09-17 18:18:58 +020091#define mbedtls_calloc calloc
92#define mbedtls_free free
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +020093#define mbedtls_printf printf
Manuel Pégourié-Gonnard7b6dcbe2015-06-22 10:48:01 +020094#define mbedtls_snprintf snprintf
Janos Follath2e3aca22016-03-18 16:25:52 +000095#define mbedtls_exit exit
96#define MBEDTLS_EXIT_SUCCESS EXIT_SUCCESS
97#define MBEDTLS_EXIT_FAILURE EXIT_FAILURE
Rich Evans18b78c72015-02-11 14:06:19 +000098#endif
99
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200100#if defined(MBEDTLS_MEMORY_BUFFER_ALLOC_C)
Manuel Pégourié-Gonnard7f809972015-03-09 17:05:11 +0000101#include "mbedtls/memory_buffer_alloc.h"
Paul Bakker6e339b52013-07-03 13:37:05 +0200102#endif
103
Gilles Peskineea5d3572019-09-17 18:18:58 +0200104
105#if defined MBEDTLS_SELF_TEST
106/* Sanity check for malloc. This is not expected to fail, and is rather
107 * intended to display potentially useful information about the platform,
108 * in particular the behavior of malloc(0). */
109static int calloc_self_test( int verbose )
110{
111 int failures = 0;
112 void *empty1 = mbedtls_calloc( 0, 1 );
113 void *empty2 = mbedtls_calloc( 0, 1 );
114 void *buffer1 = mbedtls_calloc( 1, 1 );
115 void *buffer2 = mbedtls_calloc( 1, 1 );
116 uintptr_t old_buffer1;
117
118 if( empty1 == NULL && empty2 == NULL )
119 {
120 if( verbose )
121 mbedtls_printf( " CALLOC(0): passed (NULL)\n" );
122 }
123 else if( empty1 == NULL || empty2 == NULL )
124 {
125 if( verbose )
126 mbedtls_printf( " CALLOC(0): failed (mix of NULL and non-NULL)\n" );
127 ++failures;
128 }
129 else if( empty1 == empty2 )
130 {
131 if( verbose )
132 mbedtls_printf( " CALLOC(0): passed (same non-null)\n" );
133 }
134 else
135 {
136 if( verbose )
137 mbedtls_printf( " CALLOC(0): passed (distinct non-null)\n" );
138 }
139
140 if( buffer1 == NULL || buffer2 == NULL )
141 {
142 if( verbose )
143 mbedtls_printf( " CALLOC(1): failed (NULL)\n" );
144 ++failures;
145 }
146 else if( buffer1 == buffer2 )
147 {
148 if( verbose )
149 mbedtls_printf( " CALLOC(1): failed (same buffer twice)\n" );
150 ++failures;
151 }
152 else
153 {
154 if( verbose )
155 mbedtls_printf( " CALLOC(1): passed\n" );
156 }
157
158 old_buffer1 = (uintptr_t) buffer1;
159 mbedtls_free( buffer1 );
160 buffer1 = mbedtls_calloc( 1, 1 );
161 if( buffer1 == NULL )
162 {
163 if( verbose )
164 mbedtls_printf( " CALLOC(1 again): failed (NULL)\n" );
165 ++failures;
166 }
167 else
168 {
169 if( verbose )
170 mbedtls_printf( " CALLOC(1 again): passed (%s address)\n",
171 (uintptr_t) old_buffer1 == (uintptr_t) buffer1 ?
172 "same" : "different" );
173 }
174
175 if( verbose )
176 mbedtls_printf( "\n" );
177 mbedtls_free( empty1 );
178 mbedtls_free( empty2 );
179 mbedtls_free( buffer1 );
180 mbedtls_free( buffer2 );
181 return( failures );
182}
183#endif /* MBEDTLS_SELF_TEST */
184
Manuel Pégourié-Gonnard7b6dcbe2015-06-22 10:48:01 +0200185static int test_snprintf( size_t n, const char ref_buf[10], int ref_ret )
186{
187 int ret;
188 char buf[10] = "xxxxxxxxx";
Manuel Pégourié-Gonnard4b00f082015-06-26 11:24:32 +0200189 const char ref[10] = "xxxxxxxxx";
Manuel Pégourié-Gonnard7b6dcbe2015-06-22 10:48:01 +0200190
191 ret = mbedtls_snprintf( buf, n, "%s", "123" );
192 if( ret < 0 || (size_t) ret >= n )
193 ret = -1;
194
Manuel Pégourié-Gonnard4b00f082015-06-26 11:24:32 +0200195 if( strncmp( ref_buf, buf, sizeof( buf ) ) != 0 ||
196 ref_ret != ret ||
197 memcmp( buf + n, ref + n, sizeof( buf ) - n ) != 0 )
Manuel Pégourié-Gonnard7b6dcbe2015-06-22 10:48:01 +0200198 {
199 return( 1 );
200 }
201
202 return( 0 );
203}
204
205static int run_test_snprintf( void )
206{
207 return( test_snprintf( 0, "xxxxxxxxx", -1 ) != 0 ||
Manuel Pégourié-Gonnard4b00f082015-06-26 11:24:32 +0200208 test_snprintf( 1, "", -1 ) != 0 ||
209 test_snprintf( 2, "1", -1 ) != 0 ||
210 test_snprintf( 3, "12", -1 ) != 0 ||
211 test_snprintf( 4, "123", 3 ) != 0 ||
212 test_snprintf( 5, "123", 3 ) != 0 );
Manuel Pégourié-Gonnard7b6dcbe2015-06-22 10:48:01 +0200213}
214
Simon Butcherb6a73c92016-06-18 22:45:37 +0100215/*
216 * Check if a seed file is present, and if not create one for the entropy
217 * self-test. If this fails, we attempt the test anyway, so no error is passed
218 * back.
219 */
Gilles Peskine319ac802017-12-15 14:57:18 +0100220#if defined(MBEDTLS_SELF_TEST) && defined(MBEDTLS_ENTROPY_C)
221#if defined(MBEDTLS_ENTROPY_NV_SEED) && !defined(MBEDTLS_NO_PLATFORM_ENTROPY)
Simon Butcherb6a73c92016-06-18 22:45:37 +0100222static void create_entropy_seed_file( void )
223{
224 int result;
225 size_t output_len = 0;
226 unsigned char seed_value[MBEDTLS_ENTROPY_BLOCK_SIZE];
227
228 /* Attempt to read the entropy seed file. If this fails - attempt to write
229 * to the file to ensure one is present. */
230 result = mbedtls_platform_std_nv_seed_read( seed_value,
231 MBEDTLS_ENTROPY_BLOCK_SIZE );
232 if( 0 == result )
233 return;
234
235 result = mbedtls_platform_entropy_poll( NULL,
236 seed_value,
237 MBEDTLS_ENTROPY_BLOCK_SIZE,
238 &output_len );
239 if( 0 != result )
240 return;
241
242 if( MBEDTLS_ENTROPY_BLOCK_SIZE != output_len )
243 return;
244
245 mbedtls_platform_std_nv_seed_write( seed_value, MBEDTLS_ENTROPY_BLOCK_SIZE );
246}
247#endif
248
Gilles Peskine319ac802017-12-15 14:57:18 +0100249int mbedtls_entropy_self_test_wrapper( int verbose )
250{
251#if defined(MBEDTLS_ENTROPY_NV_SEED) && !defined(MBEDTLS_NO_PLATFORM_ENTROPY)
252 create_entropy_seed_file( );
253#endif
254 return( mbedtls_entropy_self_test( verbose ) );
255}
256#endif
257
258#if defined(MBEDTLS_SELF_TEST)
259#if defined(MBEDTLS_MEMORY_BUFFER_ALLOC_C)
260int mbedtls_memory_buffer_alloc_free_and_self_test( int verbose )
261{
262 if( verbose != 0 )
263 {
264#if defined(MBEDTLS_MEMORY_DEBUG)
265 mbedtls_memory_buffer_alloc_status( );
266#endif
267 }
268 mbedtls_memory_buffer_alloc_free( );
269 return( mbedtls_memory_buffer_alloc_self_test( verbose ) );
270}
271#endif
272
273typedef struct
274{
275 const char *name;
276 int ( *function )( int );
277} selftest_t;
278
279const selftest_t selftests[] =
280{
Gilles Peskineea5d3572019-09-17 18:18:58 +0200281 {"calloc", calloc_self_test},
Gilles Peskine319ac802017-12-15 14:57:18 +0100282#if defined(MBEDTLS_MD2_C)
283 {"md2", mbedtls_md2_self_test},
284#endif
285#if defined(MBEDTLS_MD4_C)
286 {"md4", mbedtls_md4_self_test},
287#endif
288#if defined(MBEDTLS_MD5_C)
289 {"md5", mbedtls_md5_self_test},
290#endif
291#if defined(MBEDTLS_RIPEMD160_C)
292 {"ripemd160", mbedtls_ripemd160_self_test},
293#endif
294#if defined(MBEDTLS_SHA1_C)
295 {"sha1", mbedtls_sha1_self_test},
296#endif
297#if defined(MBEDTLS_SHA256_C)
298 {"sha256", mbedtls_sha256_self_test},
299#endif
300#if defined(MBEDTLS_SHA512_C)
301 {"sha512", mbedtls_sha512_self_test},
302#endif
303#if defined(MBEDTLS_ARC4_C)
304 {"arc4", mbedtls_arc4_self_test},
305#endif
306#if defined(MBEDTLS_DES_C)
307 {"des", mbedtls_des_self_test},
308#endif
309#if defined(MBEDTLS_AES_C)
310 {"aes", mbedtls_aes_self_test},
311#endif
312#if defined(MBEDTLS_GCM_C) && defined(MBEDTLS_AES_C)
313 {"gcm", mbedtls_gcm_self_test},
314#endif
315#if defined(MBEDTLS_CCM_C) && defined(MBEDTLS_AES_C)
316 {"ccm", mbedtls_ccm_self_test},
317#endif
318#if defined(MBEDTLS_CMAC_C)
319 {"cmac", mbedtls_cmac_self_test},
320#endif
321#if defined(MBEDTLS_BASE64_C)
322 {"base64", mbedtls_base64_self_test},
323#endif
324#if defined(MBEDTLS_BIGNUM_C)
325 {"mpi", mbedtls_mpi_self_test},
326#endif
327#if defined(MBEDTLS_RSA_C)
328 {"rsa", mbedtls_rsa_self_test},
329#endif
330#if defined(MBEDTLS_X509_USE_C)
331 {"x509", mbedtls_x509_self_test},
332#endif
333#if defined(MBEDTLS_XTEA_C)
334 {"xtea", mbedtls_xtea_self_test},
335#endif
336#if defined(MBEDTLS_CAMELLIA_C)
337 {"camellia", mbedtls_camellia_self_test},
338#endif
339#if defined(MBEDTLS_CTR_DRBG_C)
340 {"ctr_drbg", mbedtls_ctr_drbg_self_test},
341#endif
342#if defined(MBEDTLS_HMAC_DRBG_C)
343 {"hmac_drbg", mbedtls_hmac_drbg_self_test},
344#endif
345#if defined(MBEDTLS_ECP_C)
346 {"ecp", mbedtls_ecp_self_test},
347#endif
348#if defined(MBEDTLS_ECJPAKE_C)
349 {"ecjpake", mbedtls_ecjpake_self_test},
350#endif
351#if defined(MBEDTLS_DHM_C)
352 {"dhm", mbedtls_dhm_self_test},
353#endif
354#if defined(MBEDTLS_ENTROPY_C)
355 {"entropy", mbedtls_entropy_self_test_wrapper},
356#endif
357#if defined(MBEDTLS_PKCS5_C)
358 {"pkcs5", mbedtls_pkcs5_self_test},
359#endif
360/* Slower test after the faster ones */
361#if defined(MBEDTLS_TIMING_C)
362 {"timing", mbedtls_timing_self_test},
363#endif
364/* Heap test comes last */
365#if defined(MBEDTLS_MEMORY_BUFFER_ALLOC_C)
366 {"memory_buffer_alloc", mbedtls_memory_buffer_alloc_free_and_self_test},
367#endif
368 {NULL, NULL}
369};
Gilles Peskinec82fbb42017-12-15 15:01:27 +0100370#endif /* MBEDTLS_SELF_TEST */
Gilles Peskine319ac802017-12-15 14:57:18 +0100371
Paul Bakker5121ce52009-01-03 21:22:43 +0000372int main( int argc, char *argv[] )
373{
Gilles Peskinec82fbb42017-12-15 15:01:27 +0100374#if defined(MBEDTLS_SELF_TEST)
Gilles Peskine319ac802017-12-15 14:57:18 +0100375 const selftest_t *test;
Gilles Peskinec82fbb42017-12-15 15:01:27 +0100376#endif /* MBEDTLS_SELF_TEST */
Gilles Peskineff79d272017-12-20 18:09:27 +0100377 char **argp;
378 int v = 1; /* v=1 for verbose mode */
379 int exclude_mode = 0;
380 int suites_tested = 0, suites_failed = 0;
Paul Bakker70940ca2016-07-14 14:30:45 +0100381#if defined(MBEDTLS_MEMORY_BUFFER_ALLOC_C) && defined(MBEDTLS_SELF_TEST)
Paul Bakker6e339b52013-07-03 13:37:05 +0200382 unsigned char buf[1000000];
383#endif
Manuel Pégourié-Gonnardd14acbc2015-05-29 11:26:37 +0200384 void *pointer;
385
386 /*
387 * The C standard doesn't guarantee that all-bits-0 is the representation
388 * of a NULL pointer. We do however use that in our code for initializing
389 * structures, which should work on every modern platform. Let's be sure.
390 */
391 memset( &pointer, 0, sizeof( void * ) );
392 if( pointer != NULL )
393 {
394 mbedtls_printf( "all-bits-zero is not a NULL pointer\n" );
Janos Follath2e3aca22016-03-18 16:25:52 +0000395 mbedtls_exit( MBEDTLS_EXIT_FAILURE );
Manuel Pégourié-Gonnardd14acbc2015-05-29 11:26:37 +0200396 }
Paul Bakker5121ce52009-01-03 21:22:43 +0000397
Manuel Pégourié-Gonnard7b6dcbe2015-06-22 10:48:01 +0200398 /*
399 * Make sure we have a snprintf that correctly zero-terminates
400 */
401 if( run_test_snprintf() != 0 )
402 {
403 mbedtls_printf( "the snprintf implementation is broken\n" );
Janos Follath2e3aca22016-03-18 16:25:52 +0000404 mbedtls_exit( MBEDTLS_EXIT_FAILURE );
Manuel Pégourié-Gonnard7b6dcbe2015-06-22 10:48:01 +0200405 }
406
Gilles Peskineff79d272017-12-20 18:09:27 +0100407 for( argp = argv + ( argc >= 1 ? 1 : argc ); *argp != NULL; ++argp )
SimonB5a8afb82016-03-11 00:40:54 +0000408 {
Gilles Peskineff79d272017-12-20 18:09:27 +0100409 if( strcmp( *argp, "--quiet" ) == 0 ||
410 strcmp( *argp, "-q" ) == 0 )
411 {
412 v = 0;
413 }
414 else if( strcmp( *argp, "--exclude" ) == 0 ||
415 strcmp( *argp, "-x" ) == 0 )
416 {
417 exclude_mode = 1;
418 }
419 else
420 break;
SimonB5a8afb82016-03-11 00:40:54 +0000421 }
Gilles Peskineff79d272017-12-20 18:09:27 +0100422
423 if( v != 0 )
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200424 mbedtls_printf( "\n" );
Paul Bakker5121ce52009-01-03 21:22:43 +0000425
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200426#if defined(MBEDTLS_SELF_TEST)
Paul Bakker135b98e2011-05-25 11:13:47 +0000427
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200428#if defined(MBEDTLS_MEMORY_BUFFER_ALLOC_C)
429 mbedtls_memory_buffer_alloc_init( buf, sizeof(buf) );
Paul Bakker6e339b52013-07-03 13:37:05 +0200430#endif
431
Gilles Peskineff79d272017-12-20 18:09:27 +0100432 if( *argp != NULL && exclude_mode == 0 )
SimonB5a8afb82016-03-11 00:40:54 +0000433 {
Gilles Peskinec82fbb42017-12-15 15:01:27 +0100434 /* Run the specified tests */
435 for( ; *argp != NULL; argp++ )
Gilles Peskine319ac802017-12-15 14:57:18 +0100436 {
Gilles Peskinec82fbb42017-12-15 15:01:27 +0100437 for( test = selftests; test->name != NULL; test++ )
438 {
439 if( !strcmp( *argp, test->name ) )
440 {
441 if( test->function( v ) != 0 )
442 {
443 suites_failed++;
444 }
445 suites_tested++;
446 break;
447 }
448 }
449 if( test->name == NULL )
450 {
451 mbedtls_printf( " Test suite %s not available -> failed\n\n", *argp );
452 suites_failed++;
453 }
Gilles Peskine319ac802017-12-15 14:57:18 +0100454 }
Gilles Peskinec82fbb42017-12-15 15:01:27 +0100455 }
456 else
457 {
Gilles Peskineff79d272017-12-20 18:09:27 +0100458 /* Run all the tests except excluded ones */
Gilles Peskinec82fbb42017-12-15 15:01:27 +0100459 for( test = selftests; test->name != NULL; test++ )
460 {
Gilles Peskineff79d272017-12-20 18:09:27 +0100461 if( exclude_mode )
462 {
463 char **excluded;
464 for( excluded = argp; *excluded != NULL; ++excluded )
465 {
466 if( !strcmp( *excluded, test->name ) )
467 break;
468 }
469 if( *excluded )
470 {
471 if( v )
472 mbedtls_printf( " Skip: %s\n", test->name );
473 continue;
474 }
475 }
Gilles Peskinec82fbb42017-12-15 15:01:27 +0100476 if( test->function( v ) != 0 )
477 {
478 suites_failed++;
479 }
480 suites_tested++;
481 }
SimonB5a8afb82016-03-11 00:40:54 +0000482 }
Manuel Pégourié-Gonnard5ba1d522014-11-27 11:33:55 +0100483
Paul Bakker70940ca2016-07-14 14:30:45 +0100484#else
Gilles Peskineff79d272017-12-20 18:09:27 +0100485 (void) exclude_mode;
Paul Bakker70940ca2016-07-14 14:30:45 +0100486 mbedtls_printf( " MBEDTLS_SELF_TEST not defined.\n" );
487#endif
488
Manuel Pégourié-Gonnard5ba1d522014-11-27 11:33:55 +0100489 if( v != 0 )
490 {
Simon Butcherf1547632016-03-14 23:09:39 +0000491 mbedtls_printf( " Executed %d test suites\n\n", suites_tested );
SimonB5a8afb82016-03-11 00:40:54 +0000492
493 if( suites_failed > 0)
494 {
495 mbedtls_printf( " [ %d tests FAIL ]\n\n", suites_failed );
496 }
497 else
498 {
499 mbedtls_printf( " [ All tests PASS ]\n\n" );
500 }
Paul Bakkercce9d772011-11-18 14:26:47 +0000501#if defined(_WIN32)
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200502 mbedtls_printf( " Press Enter to exit this program.\n" );
Paul Bakker5121ce52009-01-03 21:22:43 +0000503 fflush( stdout ); getchar();
504#endif
505 }
Paul Bakker5121ce52009-01-03 21:22:43 +0000506
SimonB5a8afb82016-03-11 00:40:54 +0000507 if( suites_failed > 0)
Janos Follath2e3aca22016-03-18 16:25:52 +0000508 mbedtls_exit( MBEDTLS_EXIT_FAILURE );
SimonB5a8afb82016-03-11 00:40:54 +0000509
Krzysztof Stachowiaka0865222019-04-24 14:24:46 +0200510 mbedtls_exit( MBEDTLS_EXIT_SUCCESS );
Paul Bakker5121ce52009-01-03 21:22:43 +0000511}