blob: 3765a0ae063a3b2bed45582cfaebe4a375e29c83 [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
Manuel Pégourié-Gonnard37ff1402015-09-04 14:21:07 +02005 * SPDX-License-Identifier: Apache-2.0
6 *
7 * Licensed under the Apache License, Version 2.0 (the "License"); you may
8 * not use this file except in compliance with the License.
9 * You may obtain a copy of the License at
10 *
11 * http://www.apache.org/licenses/LICENSE-2.0
12 *
13 * Unless required by applicable law or agreed to in writing, software
14 * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
15 * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 * See the License for the specific language governing permissions and
17 * limitations under the License.
Paul Bakkerb96f1542010-07-18 20:36:00 +000018 *
Manuel Pégourié-Gonnardfe446432015-03-06 13:17:10 +000019 * This file is part of mbed TLS (https://tls.mbed.org)
Paul Bakker5121ce52009-01-03 21:22:43 +000020 */
21
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +020022#if !defined(MBEDTLS_CONFIG_FILE)
Manuel Pégourié-Gonnard7f809972015-03-09 17:05:11 +000023#include "mbedtls/config.h"
Manuel Pégourié-Gonnardcef4ad22014-04-29 12:39:06 +020024#else
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +020025#include MBEDTLS_CONFIG_FILE
Manuel Pégourié-Gonnardcef4ad22014-04-29 12:39:06 +020026#endif
Paul Bakker5121ce52009-01-03 21:22:43 +000027
Manuel Pégourié-Gonnard7f809972015-03-09 17:05:11 +000028#include "mbedtls/entropy.h"
29#include "mbedtls/hmac_drbg.h"
30#include "mbedtls/ctr_drbg.h"
31#include "mbedtls/dhm.h"
32#include "mbedtls/gcm.h"
33#include "mbedtls/ccm.h"
34#include "mbedtls/md2.h"
35#include "mbedtls/md4.h"
36#include "mbedtls/md5.h"
37#include "mbedtls/ripemd160.h"
38#include "mbedtls/sha1.h"
39#include "mbedtls/sha256.h"
40#include "mbedtls/sha512.h"
41#include "mbedtls/arc4.h"
42#include "mbedtls/des.h"
43#include "mbedtls/aes.h"
44#include "mbedtls/camellia.h"
45#include "mbedtls/base64.h"
46#include "mbedtls/bignum.h"
47#include "mbedtls/rsa.h"
48#include "mbedtls/x509.h"
49#include "mbedtls/xtea.h"
50#include "mbedtls/pkcs5.h"
Manuel Pégourié-Gonnard7f809972015-03-09 17:05:11 +000051#include "mbedtls/ecp.h"
Manuel Pégourié-Gonnard4d8685b2015-08-05 15:44:42 +020052#include "mbedtls/ecjpake.h"
Manuel Pégourié-Gonnard7f809972015-03-09 17:05:11 +000053#include "mbedtls/timing.h"
Paul Bakker5121ce52009-01-03 21:22:43 +000054
Janos Follath2e3aca22016-03-18 16:25:52 +000055//#include <stdio.h>
Rich Evans18b78c72015-02-11 14:06:19 +000056#include <string.h>
57
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +020058#if defined(MBEDTLS_PLATFORM_C)
Manuel Pégourié-Gonnard7f809972015-03-09 17:05:11 +000059#include "mbedtls/platform.h"
Rich Evans18b78c72015-02-11 14:06:19 +000060#else
61#include <stdio.h>
Janos Follath2e3aca22016-03-18 16:25:52 +000062#include <stdlib.h>
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +020063#define mbedtls_printf printf
Manuel Pégourié-Gonnard7b6dcbe2015-06-22 10:48:01 +020064#define mbedtls_snprintf snprintf
Janos Follath2e3aca22016-03-18 16:25:52 +000065#define mbedtls_exit exit
66#define MBEDTLS_EXIT_SUCCESS EXIT_SUCCESS
67#define MBEDTLS_EXIT_FAILURE EXIT_FAILURE
Rich Evans18b78c72015-02-11 14:06:19 +000068#endif
69
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +020070#if defined(MBEDTLS_MEMORY_BUFFER_ALLOC_C)
Manuel Pégourié-Gonnard7f809972015-03-09 17:05:11 +000071#include "mbedtls/memory_buffer_alloc.h"
Paul Bakker6e339b52013-07-03 13:37:05 +020072#endif
73
Manuel Pégourié-Gonnard7b6dcbe2015-06-22 10:48:01 +020074static int test_snprintf( size_t n, const char ref_buf[10], int ref_ret )
75{
76 int ret;
77 char buf[10] = "xxxxxxxxx";
Manuel Pégourié-Gonnard4b00f082015-06-26 11:24:32 +020078 const char ref[10] = "xxxxxxxxx";
Manuel Pégourié-Gonnard7b6dcbe2015-06-22 10:48:01 +020079
80 ret = mbedtls_snprintf( buf, n, "%s", "123" );
81 if( ret < 0 || (size_t) ret >= n )
82 ret = -1;
83
Manuel Pégourié-Gonnard4b00f082015-06-26 11:24:32 +020084 if( strncmp( ref_buf, buf, sizeof( buf ) ) != 0 ||
85 ref_ret != ret ||
86 memcmp( buf + n, ref + n, sizeof( buf ) - n ) != 0 )
Manuel Pégourié-Gonnard7b6dcbe2015-06-22 10:48:01 +020087 {
88 return( 1 );
89 }
90
91 return( 0 );
92}
93
94static int run_test_snprintf( void )
95{
96 return( test_snprintf( 0, "xxxxxxxxx", -1 ) != 0 ||
Manuel Pégourié-Gonnard4b00f082015-06-26 11:24:32 +020097 test_snprintf( 1, "", -1 ) != 0 ||
98 test_snprintf( 2, "1", -1 ) != 0 ||
99 test_snprintf( 3, "12", -1 ) != 0 ||
100 test_snprintf( 4, "123", 3 ) != 0 ||
101 test_snprintf( 5, "123", 3 ) != 0 );
Manuel Pégourié-Gonnard7b6dcbe2015-06-22 10:48:01 +0200102}
103
Paul Bakker5121ce52009-01-03 21:22:43 +0000104int main( int argc, char *argv[] )
105{
Janos Follath2e3aca22016-03-18 16:25:52 +0000106 int v, suites_tested = 0, suites_failed = 0;
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200107#if defined(MBEDTLS_MEMORY_BUFFER_ALLOC_C)
Paul Bakker6e339b52013-07-03 13:37:05 +0200108 unsigned char buf[1000000];
109#endif
Manuel Pégourié-Gonnardd14acbc2015-05-29 11:26:37 +0200110 void *pointer;
111
112 /*
113 * The C standard doesn't guarantee that all-bits-0 is the representation
114 * of a NULL pointer. We do however use that in our code for initializing
115 * structures, which should work on every modern platform. Let's be sure.
116 */
117 memset( &pointer, 0, sizeof( void * ) );
118 if( pointer != NULL )
119 {
120 mbedtls_printf( "all-bits-zero is not a NULL pointer\n" );
Janos Follath2e3aca22016-03-18 16:25:52 +0000121 mbedtls_exit( MBEDTLS_EXIT_FAILURE );
Manuel Pégourié-Gonnardd14acbc2015-05-29 11:26:37 +0200122 }
Paul Bakker5121ce52009-01-03 21:22:43 +0000123
Manuel Pégourié-Gonnard7b6dcbe2015-06-22 10:48:01 +0200124 /*
125 * Make sure we have a snprintf that correctly zero-terminates
126 */
127 if( run_test_snprintf() != 0 )
128 {
129 mbedtls_printf( "the snprintf implementation is broken\n" );
Janos Follath2e3aca22016-03-18 16:25:52 +0000130 mbedtls_exit( MBEDTLS_EXIT_FAILURE );
Manuel Pégourié-Gonnard7b6dcbe2015-06-22 10:48:01 +0200131 }
132
SimonB5a8afb82016-03-11 00:40:54 +0000133 if( argc == 2 && ( strcmp( argv[1], "--quiet" ) == 0 ||
134 strcmp( argv[1], "-q" ) == 0 ) )
135 {
Paul Bakker5121ce52009-01-03 21:22:43 +0000136 v = 0;
SimonB5a8afb82016-03-11 00:40:54 +0000137 }
Paul Bakker5121ce52009-01-03 21:22:43 +0000138 else
139 {
140 v = 1;
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200141 mbedtls_printf( "\n" );
Paul Bakker5121ce52009-01-03 21:22:43 +0000142 }
143
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200144#if defined(MBEDTLS_SELF_TEST)
Paul Bakker135b98e2011-05-25 11:13:47 +0000145
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200146#if defined(MBEDTLS_MEMORY_BUFFER_ALLOC_C)
147 mbedtls_memory_buffer_alloc_init( buf, sizeof(buf) );
Paul Bakker6e339b52013-07-03 13:37:05 +0200148#endif
149
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200150#if defined(MBEDTLS_MD2_C)
Janos Follath2e3aca22016-03-18 16:25:52 +0000151 if( mbedtls_md2_self_test( v ) != 0 )
SimonB5a8afb82016-03-11 00:40:54 +0000152 {
153 suites_failed++;
154 }
155 suites_tested++;
Paul Bakker5121ce52009-01-03 21:22:43 +0000156#endif
157
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200158#if defined(MBEDTLS_MD4_C)
Janos Follath2e3aca22016-03-18 16:25:52 +0000159 if( mbedtls_md4_self_test( v ) != 0 )
SimonB5a8afb82016-03-11 00:40:54 +0000160 {
161 suites_failed++;
162 }
163 suites_tested++;
Paul Bakker5121ce52009-01-03 21:22:43 +0000164#endif
165
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200166#if defined(MBEDTLS_MD5_C)
Janos Follath2e3aca22016-03-18 16:25:52 +0000167 if( mbedtls_md5_self_test( v ) != 0 )
SimonB5a8afb82016-03-11 00:40:54 +0000168 {
169 suites_failed++;
170 }
171 suites_tested++;
Paul Bakker5121ce52009-01-03 21:22:43 +0000172#endif
173
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200174#if defined(MBEDTLS_RIPEMD160_C)
Janos Follath2e3aca22016-03-18 16:25:52 +0000175 if( mbedtls_ripemd160_self_test( v ) != 0 )
SimonB5a8afb82016-03-11 00:40:54 +0000176 {
177 suites_failed++;
178 }
179 suites_tested++;
Manuel Pégourié-Gonnard1744d722014-01-17 14:44:38 +0100180#endif
181
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200182#if defined(MBEDTLS_SHA1_C)
Janos Follath2e3aca22016-03-18 16:25:52 +0000183 if( mbedtls_sha1_self_test( v ) != 0 )
SimonB5a8afb82016-03-11 00:40:54 +0000184 {
185 suites_failed++;
186 }
187 suites_tested++;
Paul Bakker5121ce52009-01-03 21:22:43 +0000188#endif
189
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200190#if defined(MBEDTLS_SHA256_C)
Janos Follath2e3aca22016-03-18 16:25:52 +0000191 if( mbedtls_sha256_self_test( v ) != 0 )
SimonB5a8afb82016-03-11 00:40:54 +0000192 {
193 suites_failed++;
194 }
195 suites_tested++;
Paul Bakker5121ce52009-01-03 21:22:43 +0000196#endif
197
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200198#if defined(MBEDTLS_SHA512_C)
Janos Follath2e3aca22016-03-18 16:25:52 +0000199 if( mbedtls_sha512_self_test( v ) != 0 )
SimonB5a8afb82016-03-11 00:40:54 +0000200 {
201 suites_failed++;
202 }
203 suites_tested++;
Paul Bakker5121ce52009-01-03 21:22:43 +0000204#endif
205
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200206#if defined(MBEDTLS_ARC4_C)
Janos Follath2e3aca22016-03-18 16:25:52 +0000207 if( mbedtls_arc4_self_test( v ) != 0 )
SimonB5a8afb82016-03-11 00:40:54 +0000208 {
209 suites_failed++;
210 }
211 suites_tested++;
Paul Bakker5121ce52009-01-03 21:22:43 +0000212#endif
213
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200214#if defined(MBEDTLS_DES_C)
Janos Follath2e3aca22016-03-18 16:25:52 +0000215 if( mbedtls_des_self_test( v ) != 0 )
SimonB5a8afb82016-03-11 00:40:54 +0000216 {
217 suites_failed++;
218 }
219 suites_tested++;
Paul Bakker5121ce52009-01-03 21:22:43 +0000220#endif
221
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200222#if defined(MBEDTLS_AES_C)
Janos Follath2e3aca22016-03-18 16:25:52 +0000223 if( mbedtls_aes_self_test( v ) != 0 )
SimonB5a8afb82016-03-11 00:40:54 +0000224 {
225 suites_failed++;
226 }
227 suites_tested++;
Paul Bakker5121ce52009-01-03 21:22:43 +0000228#endif
229
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200230#if defined(MBEDTLS_GCM_C) && defined(MBEDTLS_AES_C)
Janos Follath2e3aca22016-03-18 16:25:52 +0000231 if( mbedtls_gcm_self_test( v ) != 0 )
SimonB5a8afb82016-03-11 00:40:54 +0000232 {
233 suites_failed++;
234 }
235 suites_tested++;
Paul Bakker89e80c92012-03-20 13:50:09 +0000236#endif
237
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200238#if defined(MBEDTLS_CCM_C) && defined(MBEDTLS_AES_C)
Janos Follath2e3aca22016-03-18 16:25:52 +0000239 if( mbedtls_ccm_self_test( v ) != 0 )
SimonB5a8afb82016-03-11 00:40:54 +0000240 {
241 suites_failed++;
242 }
243 suites_tested++;
Manuel Pégourié-Gonnarda6916fa2014-05-02 15:17:29 +0200244#endif
245
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200246#if defined(MBEDTLS_BASE64_C)
Janos Follath2e3aca22016-03-18 16:25:52 +0000247 if( mbedtls_base64_self_test( v ) != 0 )
SimonB5a8afb82016-03-11 00:40:54 +0000248 {
249 suites_failed++;
250 }
251 suites_tested++;
Paul Bakker5121ce52009-01-03 21:22:43 +0000252#endif
253
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200254#if defined(MBEDTLS_BIGNUM_C)
Janos Follath2e3aca22016-03-18 16:25:52 +0000255 if( mbedtls_mpi_self_test( v ) != 0 )
SimonB5a8afb82016-03-11 00:40:54 +0000256 {
257 suites_failed++;
258 }
259 suites_tested++;
Paul Bakker5121ce52009-01-03 21:22:43 +0000260#endif
261
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200262#if defined(MBEDTLS_RSA_C)
Janos Follath2e3aca22016-03-18 16:25:52 +0000263 if( mbedtls_rsa_self_test( v ) != 0 )
SimonB5a8afb82016-03-11 00:40:54 +0000264 {
265 suites_failed++;
266 }
267 suites_tested++;
Paul Bakker5121ce52009-01-03 21:22:43 +0000268#endif
269
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200270#if defined(MBEDTLS_X509_USE_C)
Janos Follath2e3aca22016-03-18 16:25:52 +0000271 if( mbedtls_x509_self_test( v ) != 0 )
SimonB5a8afb82016-03-11 00:40:54 +0000272 {
273 suites_failed++;
274 }
275 suites_tested++;
Paul Bakker5121ce52009-01-03 21:22:43 +0000276#endif
277
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200278#if defined(MBEDTLS_XTEA_C)
Janos Follath2e3aca22016-03-18 16:25:52 +0000279 if( mbedtls_xtea_self_test( v ) != 0 )
SimonB5a8afb82016-03-11 00:40:54 +0000280 {
281 suites_failed++;
282 }
283 suites_tested++;
Paul Bakker7a7c78f2009-01-04 18:15:48 +0000284#endif
285
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200286#if defined(MBEDTLS_CAMELLIA_C)
Janos Follath2e3aca22016-03-18 16:25:52 +0000287 if( mbedtls_camellia_self_test( v ) != 0 )
SimonB5a8afb82016-03-11 00:40:54 +0000288 {
289 suites_failed++;
290 }
291 suites_tested++;
Paul Bakker38119b12009-01-10 23:31:23 +0000292#endif
293
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200294#if defined(MBEDTLS_CTR_DRBG_C)
Janos Follath2e3aca22016-03-18 16:25:52 +0000295 if( mbedtls_ctr_drbg_self_test( v ) != 0 )
SimonB5a8afb82016-03-11 00:40:54 +0000296 {
297 suites_failed++;
298 }
299 suites_tested++;
Paul Bakker0e04d0e2011-11-27 14:46:59 +0000300#endif
301
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200302#if defined(MBEDTLS_HMAC_DRBG_C)
Janos Follath2e3aca22016-03-18 16:25:52 +0000303 if( mbedtls_hmac_drbg_self_test( v ) != 0 )
SimonB5a8afb82016-03-11 00:40:54 +0000304 {
305 suites_failed++;
306 }
307 suites_tested++;
Manuel Pégourié-Gonnard79afaa02014-01-31 11:12:09 +0100308#endif
309
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200310#if defined(MBEDTLS_ECP_C)
Janos Follath2e3aca22016-03-18 16:25:52 +0000311 if( mbedtls_ecp_self_test( v ) != 0 )
SimonB5a8afb82016-03-11 00:40:54 +0000312 {
313 suites_failed++;
314 }
315 suites_tested++;
Manuel Pégourié-Gonnardb4a310b2012-11-13 20:57:00 +0100316#endif
317
Manuel Pégourié-Gonnard4d8685b2015-08-05 15:44:42 +0200318#if defined(MBEDTLS_ECJPAKE_C)
Janos Follath2e3aca22016-03-18 16:25:52 +0000319 if( mbedtls_ecjpake_self_test( v ) != 0 )
SimonB5a8afb82016-03-11 00:40:54 +0000320 {
321 suites_failed++;
322 }
323 suites_tested++;
Manuel Pégourié-Gonnard4d8685b2015-08-05 15:44:42 +0200324#endif
325
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200326#if defined(MBEDTLS_DHM_C)
Janos Follath2e3aca22016-03-18 16:25:52 +0000327 if( mbedtls_dhm_self_test( v ) != 0 )
SimonB5a8afb82016-03-11 00:40:54 +0000328 {
329 suites_failed++;
330 }
331 suites_tested++;
Paul Bakker40ce79f2013-09-15 17:43:54 +0200332#endif
333
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200334#if defined(MBEDTLS_ENTROPY_C)
Janos Follath2e3aca22016-03-18 16:25:52 +0000335 if( mbedtls_entropy_self_test( v ) != 0 )
SimonB5a8afb82016-03-11 00:40:54 +0000336 {
337 suites_failed++;
338 }
339 suites_tested++;
Manuel Pégourié-Gonnard4dd73922014-05-30 10:34:15 +0200340#endif
341
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200342#if defined(MBEDTLS_PKCS5_C)
Janos Follath2e3aca22016-03-18 16:25:52 +0000343 if( mbedtls_pkcs5_self_test( v ) != 0 )
SimonB5a8afb82016-03-11 00:40:54 +0000344 {
345 suites_failed++;
346 }
347 suites_tested++;
Manuel Pégourié-Gonnard13a1ef82014-03-27 20:12:44 +0100348#endif
Manuel Pégourié-Gonnardb6b16bd2015-03-11 11:20:43 +0000349
350/* Slow tests last */
Manuel Pégourié-Gonnard13a1ef82014-03-27 20:12:44 +0100351
Manuel Pégourié-Gonnard633c6b62015-06-26 16:17:30 +0200352#if defined(MBEDTLS_TIMING_C)
Janos Follath2e3aca22016-03-18 16:25:52 +0000353 if( mbedtls_timing_self_test( v ) != 0 )
SimonB5a8afb82016-03-11 00:40:54 +0000354 {
355 suites_failed++;
356 }
357 suites_tested++;
Manuel Pégourié-Gonnard470fc932014-03-27 20:07:08 +0100358#endif
359
Paul Bakker135b98e2011-05-25 11:13:47 +0000360#else
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200361 mbedtls_printf( " MBEDTLS_SELF_TEST not defined.\n" );
Paul Bakker135b98e2011-05-25 11:13:47 +0000362#endif
363
Paul Bakker5121ce52009-01-03 21:22:43 +0000364 if( v != 0 )
365 {
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200366#if defined(MBEDTLS_MEMORY_BUFFER_ALLOC_C) && defined(MBEDTLS_MEMORY_DEBUG)
367 mbedtls_memory_buffer_alloc_status();
Paul Bakker6e339b52013-07-03 13:37:05 +0200368#endif
Manuel Pégourié-Gonnard5ba1d522014-11-27 11:33:55 +0100369 }
Paul Bakker6e339b52013-07-03 13:37:05 +0200370
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200371#if defined(MBEDTLS_MEMORY_BUFFER_ALLOC_C)
372 mbedtls_memory_buffer_alloc_free();
Janos Follath2e3aca22016-03-18 16:25:52 +0000373 if( mbedtls_memory_buffer_alloc_self_test( v ) != 0 )
SimonB5a8afb82016-03-11 00:40:54 +0000374 {
375 suites_failed++;
376 }
377 suites_tested++;
Manuel Pégourié-Gonnard5ba1d522014-11-27 11:33:55 +0100378#endif
379
380 if( v != 0 )
381 {
Simon Butcherf1547632016-03-14 23:09:39 +0000382 mbedtls_printf( " Executed %d test suites\n\n", suites_tested );
SimonB5a8afb82016-03-11 00:40:54 +0000383
384 if( suites_failed > 0)
385 {
386 mbedtls_printf( " [ %d tests FAIL ]\n\n", suites_failed );
387 }
388 else
389 {
390 mbedtls_printf( " [ All tests PASS ]\n\n" );
391 }
Paul Bakkercce9d772011-11-18 14:26:47 +0000392#if defined(_WIN32)
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200393 mbedtls_printf( " Press Enter to exit this program.\n" );
Paul Bakker5121ce52009-01-03 21:22:43 +0000394 fflush( stdout ); getchar();
395#endif
396 }
Paul Bakker5121ce52009-01-03 21:22:43 +0000397
SimonB5a8afb82016-03-11 00:40:54 +0000398 if( suites_failed > 0)
Janos Follath2e3aca22016-03-18 16:25:52 +0000399 mbedtls_exit( MBEDTLS_EXIT_FAILURE );
SimonB5a8afb82016-03-11 00:40:54 +0000400
Janos Follath2e3aca22016-03-18 16:25:52 +0000401 mbedtls_exit( MBEDTLS_EXIT_SUCCESS );
Paul Bakker5121ce52009-01-03 21:22:43 +0000402}
SimonB5a8afb82016-03-11 00:40:54 +0000403