blob: e57a78e5a0e5cb03ba582bfab810008532a6333d [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
Rich Evans18b78c72015-02-11 14:06:19 +000055#include <string.h>
56
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +020057#if defined(MBEDTLS_PLATFORM_C)
Manuel Pégourié-Gonnard7f809972015-03-09 17:05:11 +000058#include "mbedtls/platform.h"
Rich Evans18b78c72015-02-11 14:06:19 +000059#else
60#include <stdio.h>
Janos Follath2e3aca22016-03-18 16:25:52 +000061#include <stdlib.h>
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +020062#define mbedtls_printf printf
Manuel Pégourié-Gonnard7b6dcbe2015-06-22 10:48:01 +020063#define mbedtls_snprintf snprintf
Janos Follath2e3aca22016-03-18 16:25:52 +000064#define mbedtls_exit exit
65#define MBEDTLS_EXIT_SUCCESS EXIT_SUCCESS
66#define MBEDTLS_EXIT_FAILURE EXIT_FAILURE
Rich Evans18b78c72015-02-11 14:06:19 +000067#endif
68
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +020069#if defined(MBEDTLS_MEMORY_BUFFER_ALLOC_C)
Manuel Pégourié-Gonnard7f809972015-03-09 17:05:11 +000070#include "mbedtls/memory_buffer_alloc.h"
Paul Bakker6e339b52013-07-03 13:37:05 +020071#endif
72
Manuel Pégourié-Gonnard7b6dcbe2015-06-22 10:48:01 +020073static int test_snprintf( size_t n, const char ref_buf[10], int ref_ret )
74{
75 int ret;
76 char buf[10] = "xxxxxxxxx";
Manuel Pégourié-Gonnard4b00f082015-06-26 11:24:32 +020077 const char ref[10] = "xxxxxxxxx";
Manuel Pégourié-Gonnard7b6dcbe2015-06-22 10:48:01 +020078
79 ret = mbedtls_snprintf( buf, n, "%s", "123" );
80 if( ret < 0 || (size_t) ret >= n )
81 ret = -1;
82
Manuel Pégourié-Gonnard4b00f082015-06-26 11:24:32 +020083 if( strncmp( ref_buf, buf, sizeof( buf ) ) != 0 ||
84 ref_ret != ret ||
85 memcmp( buf + n, ref + n, sizeof( buf ) - n ) != 0 )
Manuel Pégourié-Gonnard7b6dcbe2015-06-22 10:48:01 +020086 {
87 return( 1 );
88 }
89
90 return( 0 );
91}
92
93static int run_test_snprintf( void )
94{
95 return( test_snprintf( 0, "xxxxxxxxx", -1 ) != 0 ||
Manuel Pégourié-Gonnard4b00f082015-06-26 11:24:32 +020096 test_snprintf( 1, "", -1 ) != 0 ||
97 test_snprintf( 2, "1", -1 ) != 0 ||
98 test_snprintf( 3, "12", -1 ) != 0 ||
99 test_snprintf( 4, "123", 3 ) != 0 ||
100 test_snprintf( 5, "123", 3 ) != 0 );
Manuel Pégourié-Gonnard7b6dcbe2015-06-22 10:48:01 +0200101}
102
Paul Bakker5121ce52009-01-03 21:22:43 +0000103int main( int argc, char *argv[] )
104{
Janos Follath2e3aca22016-03-18 16:25:52 +0000105 int v, suites_tested = 0, suites_failed = 0;
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200106#if defined(MBEDTLS_MEMORY_BUFFER_ALLOC_C)
Paul Bakker6e339b52013-07-03 13:37:05 +0200107 unsigned char buf[1000000];
108#endif
Manuel Pégourié-Gonnardd14acbc2015-05-29 11:26:37 +0200109 void *pointer;
110
111 /*
112 * The C standard doesn't guarantee that all-bits-0 is the representation
113 * of a NULL pointer. We do however use that in our code for initializing
114 * structures, which should work on every modern platform. Let's be sure.
115 */
116 memset( &pointer, 0, sizeof( void * ) );
117 if( pointer != NULL )
118 {
119 mbedtls_printf( "all-bits-zero is not a NULL pointer\n" );
Janos Follath2e3aca22016-03-18 16:25:52 +0000120 mbedtls_exit( MBEDTLS_EXIT_FAILURE );
Manuel Pégourié-Gonnardd14acbc2015-05-29 11:26:37 +0200121 }
Paul Bakker5121ce52009-01-03 21:22:43 +0000122
Manuel Pégourié-Gonnard7b6dcbe2015-06-22 10:48:01 +0200123 /*
124 * Make sure we have a snprintf that correctly zero-terminates
125 */
126 if( run_test_snprintf() != 0 )
127 {
128 mbedtls_printf( "the snprintf implementation is broken\n" );
Janos Follath2e3aca22016-03-18 16:25:52 +0000129 mbedtls_exit( MBEDTLS_EXIT_FAILURE );
Manuel Pégourié-Gonnard7b6dcbe2015-06-22 10:48:01 +0200130 }
131
SimonB5a8afb82016-03-11 00:40:54 +0000132 if( argc == 2 && ( strcmp( argv[1], "--quiet" ) == 0 ||
133 strcmp( argv[1], "-q" ) == 0 ) )
134 {
Paul Bakker5121ce52009-01-03 21:22:43 +0000135 v = 0;
SimonB5a8afb82016-03-11 00:40:54 +0000136 }
Paul Bakker5121ce52009-01-03 21:22:43 +0000137 else
138 {
139 v = 1;
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200140 mbedtls_printf( "\n" );
Paul Bakker5121ce52009-01-03 21:22:43 +0000141 }
142
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200143#if defined(MBEDTLS_SELF_TEST)
Paul Bakker135b98e2011-05-25 11:13:47 +0000144
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200145#if defined(MBEDTLS_MEMORY_BUFFER_ALLOC_C)
146 mbedtls_memory_buffer_alloc_init( buf, sizeof(buf) );
Paul Bakker6e339b52013-07-03 13:37:05 +0200147#endif
148
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200149#if defined(MBEDTLS_MD2_C)
Janos Follath2e3aca22016-03-18 16:25:52 +0000150 if( mbedtls_md2_self_test( v ) != 0 )
SimonB5a8afb82016-03-11 00:40:54 +0000151 {
152 suites_failed++;
153 }
154 suites_tested++;
Paul Bakker5121ce52009-01-03 21:22:43 +0000155#endif
156
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200157#if defined(MBEDTLS_MD4_C)
Janos Follath2e3aca22016-03-18 16:25:52 +0000158 if( mbedtls_md4_self_test( v ) != 0 )
SimonB5a8afb82016-03-11 00:40:54 +0000159 {
160 suites_failed++;
161 }
162 suites_tested++;
Paul Bakker5121ce52009-01-03 21:22:43 +0000163#endif
164
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200165#if defined(MBEDTLS_MD5_C)
Janos Follath2e3aca22016-03-18 16:25:52 +0000166 if( mbedtls_md5_self_test( v ) != 0 )
SimonB5a8afb82016-03-11 00:40:54 +0000167 {
168 suites_failed++;
169 }
170 suites_tested++;
Paul Bakker5121ce52009-01-03 21:22:43 +0000171#endif
172
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200173#if defined(MBEDTLS_RIPEMD160_C)
Janos Follath2e3aca22016-03-18 16:25:52 +0000174 if( mbedtls_ripemd160_self_test( v ) != 0 )
SimonB5a8afb82016-03-11 00:40:54 +0000175 {
176 suites_failed++;
177 }
178 suites_tested++;
Manuel Pégourié-Gonnard1744d722014-01-17 14:44:38 +0100179#endif
180
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200181#if defined(MBEDTLS_SHA1_C)
Janos Follath2e3aca22016-03-18 16:25:52 +0000182 if( mbedtls_sha1_self_test( v ) != 0 )
SimonB5a8afb82016-03-11 00:40:54 +0000183 {
184 suites_failed++;
185 }
186 suites_tested++;
Paul Bakker5121ce52009-01-03 21:22:43 +0000187#endif
188
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200189#if defined(MBEDTLS_SHA256_C)
Janos Follath2e3aca22016-03-18 16:25:52 +0000190 if( mbedtls_sha256_self_test( v ) != 0 )
SimonB5a8afb82016-03-11 00:40:54 +0000191 {
192 suites_failed++;
193 }
194 suites_tested++;
Paul Bakker5121ce52009-01-03 21:22:43 +0000195#endif
196
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200197#if defined(MBEDTLS_SHA512_C)
Janos Follath2e3aca22016-03-18 16:25:52 +0000198 if( mbedtls_sha512_self_test( v ) != 0 )
SimonB5a8afb82016-03-11 00:40:54 +0000199 {
200 suites_failed++;
201 }
202 suites_tested++;
Paul Bakker5121ce52009-01-03 21:22:43 +0000203#endif
204
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200205#if defined(MBEDTLS_ARC4_C)
Janos Follath2e3aca22016-03-18 16:25:52 +0000206 if( mbedtls_arc4_self_test( v ) != 0 )
SimonB5a8afb82016-03-11 00:40:54 +0000207 {
208 suites_failed++;
209 }
210 suites_tested++;
Paul Bakker5121ce52009-01-03 21:22:43 +0000211#endif
212
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200213#if defined(MBEDTLS_DES_C)
Janos Follath2e3aca22016-03-18 16:25:52 +0000214 if( mbedtls_des_self_test( v ) != 0 )
SimonB5a8afb82016-03-11 00:40:54 +0000215 {
216 suites_failed++;
217 }
218 suites_tested++;
Paul Bakker5121ce52009-01-03 21:22:43 +0000219#endif
220
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200221#if defined(MBEDTLS_AES_C)
Janos Follath2e3aca22016-03-18 16:25:52 +0000222 if( mbedtls_aes_self_test( v ) != 0 )
SimonB5a8afb82016-03-11 00:40:54 +0000223 {
224 suites_failed++;
225 }
226 suites_tested++;
Paul Bakker5121ce52009-01-03 21:22:43 +0000227#endif
228
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200229#if defined(MBEDTLS_GCM_C) && defined(MBEDTLS_AES_C)
Janos Follath2e3aca22016-03-18 16:25:52 +0000230 if( mbedtls_gcm_self_test( v ) != 0 )
SimonB5a8afb82016-03-11 00:40:54 +0000231 {
232 suites_failed++;
233 }
234 suites_tested++;
Paul Bakker89e80c92012-03-20 13:50:09 +0000235#endif
236
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200237#if defined(MBEDTLS_CCM_C) && defined(MBEDTLS_AES_C)
Janos Follath2e3aca22016-03-18 16:25:52 +0000238 if( mbedtls_ccm_self_test( v ) != 0 )
SimonB5a8afb82016-03-11 00:40:54 +0000239 {
240 suites_failed++;
241 }
242 suites_tested++;
Manuel Pégourié-Gonnarda6916fa2014-05-02 15:17:29 +0200243#endif
244
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200245#if defined(MBEDTLS_BASE64_C)
Janos Follath2e3aca22016-03-18 16:25:52 +0000246 if( mbedtls_base64_self_test( v ) != 0 )
SimonB5a8afb82016-03-11 00:40:54 +0000247 {
248 suites_failed++;
249 }
250 suites_tested++;
Paul Bakker5121ce52009-01-03 21:22:43 +0000251#endif
252
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200253#if defined(MBEDTLS_BIGNUM_C)
Janos Follath2e3aca22016-03-18 16:25:52 +0000254 if( mbedtls_mpi_self_test( v ) != 0 )
SimonB5a8afb82016-03-11 00:40:54 +0000255 {
256 suites_failed++;
257 }
258 suites_tested++;
Paul Bakker5121ce52009-01-03 21:22:43 +0000259#endif
260
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200261#if defined(MBEDTLS_RSA_C)
Janos Follath2e3aca22016-03-18 16:25:52 +0000262 if( mbedtls_rsa_self_test( v ) != 0 )
SimonB5a8afb82016-03-11 00:40:54 +0000263 {
264 suites_failed++;
265 }
266 suites_tested++;
Paul Bakker5121ce52009-01-03 21:22:43 +0000267#endif
268
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200269#if defined(MBEDTLS_X509_USE_C)
Janos Follath2e3aca22016-03-18 16:25:52 +0000270 if( mbedtls_x509_self_test( v ) != 0 )
SimonB5a8afb82016-03-11 00:40:54 +0000271 {
272 suites_failed++;
273 }
274 suites_tested++;
Paul Bakker5121ce52009-01-03 21:22:43 +0000275#endif
276
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200277#if defined(MBEDTLS_XTEA_C)
Janos Follath2e3aca22016-03-18 16:25:52 +0000278 if( mbedtls_xtea_self_test( v ) != 0 )
SimonB5a8afb82016-03-11 00:40:54 +0000279 {
280 suites_failed++;
281 }
282 suites_tested++;
Paul Bakker7a7c78f2009-01-04 18:15:48 +0000283#endif
284
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200285#if defined(MBEDTLS_CAMELLIA_C)
Janos Follath2e3aca22016-03-18 16:25:52 +0000286 if( mbedtls_camellia_self_test( v ) != 0 )
SimonB5a8afb82016-03-11 00:40:54 +0000287 {
288 suites_failed++;
289 }
290 suites_tested++;
Paul Bakker38119b12009-01-10 23:31:23 +0000291#endif
292
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200293#if defined(MBEDTLS_CTR_DRBG_C)
Janos Follath2e3aca22016-03-18 16:25:52 +0000294 if( mbedtls_ctr_drbg_self_test( v ) != 0 )
SimonB5a8afb82016-03-11 00:40:54 +0000295 {
296 suites_failed++;
297 }
298 suites_tested++;
Paul Bakker0e04d0e2011-11-27 14:46:59 +0000299#endif
300
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200301#if defined(MBEDTLS_HMAC_DRBG_C)
Janos Follath2e3aca22016-03-18 16:25:52 +0000302 if( mbedtls_hmac_drbg_self_test( v ) != 0 )
SimonB5a8afb82016-03-11 00:40:54 +0000303 {
304 suites_failed++;
305 }
306 suites_tested++;
Manuel Pégourié-Gonnard79afaa02014-01-31 11:12:09 +0100307#endif
308
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200309#if defined(MBEDTLS_ECP_C)
Janos Follath2e3aca22016-03-18 16:25:52 +0000310 if( mbedtls_ecp_self_test( v ) != 0 )
SimonB5a8afb82016-03-11 00:40:54 +0000311 {
312 suites_failed++;
313 }
314 suites_tested++;
Manuel Pégourié-Gonnardb4a310b2012-11-13 20:57:00 +0100315#endif
316
Manuel Pégourié-Gonnard4d8685b2015-08-05 15:44:42 +0200317#if defined(MBEDTLS_ECJPAKE_C)
Janos Follath2e3aca22016-03-18 16:25:52 +0000318 if( mbedtls_ecjpake_self_test( v ) != 0 )
SimonB5a8afb82016-03-11 00:40:54 +0000319 {
320 suites_failed++;
321 }
322 suites_tested++;
Manuel Pégourié-Gonnard4d8685b2015-08-05 15:44:42 +0200323#endif
324
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200325#if defined(MBEDTLS_DHM_C)
Janos Follath2e3aca22016-03-18 16:25:52 +0000326 if( mbedtls_dhm_self_test( v ) != 0 )
SimonB5a8afb82016-03-11 00:40:54 +0000327 {
328 suites_failed++;
329 }
330 suites_tested++;
Paul Bakker40ce79f2013-09-15 17:43:54 +0200331#endif
332
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200333#if defined(MBEDTLS_ENTROPY_C)
Janos Follath2e3aca22016-03-18 16:25:52 +0000334 if( mbedtls_entropy_self_test( v ) != 0 )
SimonB5a8afb82016-03-11 00:40:54 +0000335 {
336 suites_failed++;
337 }
338 suites_tested++;
Manuel Pégourié-Gonnard4dd73922014-05-30 10:34:15 +0200339#endif
340
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200341#if defined(MBEDTLS_PKCS5_C)
Janos Follath2e3aca22016-03-18 16:25:52 +0000342 if( mbedtls_pkcs5_self_test( v ) != 0 )
SimonB5a8afb82016-03-11 00:40:54 +0000343 {
344 suites_failed++;
345 }
346 suites_tested++;
Manuel Pégourié-Gonnard13a1ef82014-03-27 20:12:44 +0100347#endif
Manuel Pégourié-Gonnardb6b16bd2015-03-11 11:20:43 +0000348
349/* Slow tests last */
Manuel Pégourié-Gonnard13a1ef82014-03-27 20:12:44 +0100350
Manuel Pégourié-Gonnard633c6b62015-06-26 16:17:30 +0200351#if defined(MBEDTLS_TIMING_C)
Janos Follath2e3aca22016-03-18 16:25:52 +0000352 if( mbedtls_timing_self_test( v ) != 0 )
SimonB5a8afb82016-03-11 00:40:54 +0000353 {
354 suites_failed++;
355 }
356 suites_tested++;
Manuel Pégourié-Gonnard470fc932014-03-27 20:07:08 +0100357#endif
358
Paul Bakker135b98e2011-05-25 11:13:47 +0000359#else
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200360 mbedtls_printf( " MBEDTLS_SELF_TEST not defined.\n" );
Paul Bakker135b98e2011-05-25 11:13:47 +0000361#endif
362
Paul Bakker5121ce52009-01-03 21:22:43 +0000363 if( v != 0 )
364 {
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200365#if defined(MBEDTLS_MEMORY_BUFFER_ALLOC_C) && defined(MBEDTLS_MEMORY_DEBUG)
366 mbedtls_memory_buffer_alloc_status();
Paul Bakker6e339b52013-07-03 13:37:05 +0200367#endif
Manuel Pégourié-Gonnard5ba1d522014-11-27 11:33:55 +0100368 }
Paul Bakker6e339b52013-07-03 13:37:05 +0200369
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200370#if defined(MBEDTLS_MEMORY_BUFFER_ALLOC_C)
371 mbedtls_memory_buffer_alloc_free();
Janos Follath2e3aca22016-03-18 16:25:52 +0000372 if( mbedtls_memory_buffer_alloc_self_test( v ) != 0 )
SimonB5a8afb82016-03-11 00:40:54 +0000373 {
374 suites_failed++;
375 }
376 suites_tested++;
Manuel Pégourié-Gonnard5ba1d522014-11-27 11:33:55 +0100377#endif
378
379 if( v != 0 )
380 {
Simon Butcherf1547632016-03-14 23:09:39 +0000381 mbedtls_printf( " Executed %d test suites\n\n", suites_tested );
SimonB5a8afb82016-03-11 00:40:54 +0000382
383 if( suites_failed > 0)
384 {
385 mbedtls_printf( " [ %d tests FAIL ]\n\n", suites_failed );
386 }
387 else
388 {
389 mbedtls_printf( " [ All tests PASS ]\n\n" );
390 }
Paul Bakkercce9d772011-11-18 14:26:47 +0000391#if defined(_WIN32)
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200392 mbedtls_printf( " Press Enter to exit this program.\n" );
Paul Bakker5121ce52009-01-03 21:22:43 +0000393 fflush( stdout ); getchar();
394#endif
395 }
Paul Bakker5121ce52009-01-03 21:22:43 +0000396
SimonB5a8afb82016-03-11 00:40:54 +0000397 if( suites_failed > 0)
Janos Follath2e3aca22016-03-18 16:25:52 +0000398 mbedtls_exit( MBEDTLS_EXIT_FAILURE );
SimonB5a8afb82016-03-11 00:40:54 +0000399
Janos Follath0c539442016-04-18 09:59:16 +0100400 return( MBEDTLS_EXIT_SUCCESS );
Paul Bakker5121ce52009-01-03 21:22:43 +0000401}
SimonB5a8afb82016-03-11 00:40:54 +0000402