Merge pull request #2705 from k-stachowiak/unified-exit-in-examples-2.7

Backport 2.7: Unify the example programs' termination
This commit is contained in:
Gilles Peskine 2020-05-12 10:47:04 +02:00 committed by GitHub
commit 087bb4c5b1
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
48 changed files with 168 additions and 123 deletions

View file

@ -0,0 +1,4 @@
Changes
* Unify the example programs termination to call mbedtls_exit() instead of
using a return command. This has been done to enable customization of the
behavior in bare metal environments.

View file

@ -32,6 +32,7 @@
#include <stdlib.h> #include <stdlib.h>
#define mbedtls_fprintf fprintf #define mbedtls_fprintf fprintf
#define mbedtls_printf printf #define mbedtls_printf printf
#define mbedtls_exit exit
#define MBEDTLS_EXIT_SUCCESS EXIT_SUCCESS #define MBEDTLS_EXIT_SUCCESS EXIT_SUCCESS
#define MBEDTLS_EXIT_FAILURE EXIT_FAILURE #define MBEDTLS_EXIT_FAILURE EXIT_FAILURE
#endif /* MBEDTLS_PLATFORM_C */ #endif /* MBEDTLS_PLATFORM_C */
@ -69,7 +70,7 @@ int main( void )
mbedtls_printf("MBEDTLS_AES_C and/or MBEDTLS_SHA256_C " mbedtls_printf("MBEDTLS_AES_C and/or MBEDTLS_SHA256_C "
"and/or MBEDTLS_FS_IO and/or MBEDTLS_MD_C " "and/or MBEDTLS_FS_IO and/or MBEDTLS_MD_C "
"not defined.\n"); "not defined.\n");
return( 0 ); mbedtls_exit( 0 );
} }
#else #else
@ -462,6 +463,6 @@ exit:
mbedtls_aes_free( &aes_ctx ); mbedtls_aes_free( &aes_ctx );
mbedtls_md_free( &sha_ctx ); mbedtls_md_free( &sha_ctx );
return( exit_code ); mbedtls_exit( exit_code );
} }
#endif /* MBEDTLS_AES_C && MBEDTLS_SHA256_C && MBEDTLS_FS_IO */ #endif /* MBEDTLS_AES_C && MBEDTLS_SHA256_C && MBEDTLS_FS_IO */

View file

@ -33,6 +33,7 @@
#include <stdlib.h> #include <stdlib.h>
#define mbedtls_fprintf fprintf #define mbedtls_fprintf fprintf
#define mbedtls_printf printf #define mbedtls_printf printf
#define mbedtls_exit exit
#define MBEDTLS_EXIT_SUCCESS EXIT_SUCCESS #define MBEDTLS_EXIT_SUCCESS EXIT_SUCCESS
#define MBEDTLS_EXIT_FAILURE EXIT_FAILURE #define MBEDTLS_EXIT_FAILURE EXIT_FAILURE
#endif /* MBEDTLS_PLATFORM_C */ #endif /* MBEDTLS_PLATFORM_C */
@ -71,7 +72,7 @@
int main( void ) int main( void )
{ {
mbedtls_printf("MBEDTLS_CIPHER_C and/or MBEDTLS_MD_C and/or MBEDTLS_FS_IO not defined.\n"); mbedtls_printf("MBEDTLS_CIPHER_C and/or MBEDTLS_MD_C and/or MBEDTLS_FS_IO not defined.\n");
return( 0 ); mbedtls_exit( 0 );
} }
#else #else
@ -560,6 +561,6 @@ exit:
mbedtls_cipher_free( &cipher_ctx ); mbedtls_cipher_free( &cipher_ctx );
mbedtls_md_free( &md_ctx ); mbedtls_md_free( &md_ctx );
return( exit_code ); mbedtls_exit( exit_code );
} }
#endif /* MBEDTLS_CIPHER_C && MBEDTLS_MD_C && MBEDTLS_FS_IO */ #endif /* MBEDTLS_CIPHER_C && MBEDTLS_MD_C && MBEDTLS_FS_IO */

View file

@ -32,6 +32,7 @@
#include <stdlib.h> #include <stdlib.h>
#define mbedtls_fprintf fprintf #define mbedtls_fprintf fprintf
#define mbedtls_printf printf #define mbedtls_printf printf
#define mbedtls_exit exit
#define MBEDTLS_EXIT_SUCCESS EXIT_SUCCESS #define MBEDTLS_EXIT_SUCCESS EXIT_SUCCESS
#define MBEDTLS_EXIT_FAILURE EXIT_FAILURE #define MBEDTLS_EXIT_FAILURE EXIT_FAILURE
#endif /* MBEDTLS_PLATFORM_C */ #endif /* MBEDTLS_PLATFORM_C */
@ -47,7 +48,7 @@
int main( void ) int main( void )
{ {
mbedtls_printf("MBEDTLS_MD_C and/or MBEDTLS_FS_IO not defined.\n"); mbedtls_printf("MBEDTLS_MD_C and/or MBEDTLS_FS_IO not defined.\n");
return( 0 ); mbedtls_exit( 0 );
} }
#else #else
static int generic_wrapper( const mbedtls_md_info_t *md_info, char *filename, unsigned char *sum ) static int generic_wrapper( const mbedtls_md_info_t *md_info, char *filename, unsigned char *sum )
@ -200,7 +201,7 @@ int main( int argc, char *argv[] )
fflush( stdout ); getchar(); fflush( stdout ); getchar();
#endif #endif
return( exit_code ); mbedtls_exit( exit_code );
} }
/* /*
@ -210,12 +211,12 @@ int main( int argc, char *argv[] )
if( md_info == NULL ) if( md_info == NULL )
{ {
mbedtls_fprintf( stderr, "Message Digest '%s' not found\n", argv[1] ); mbedtls_fprintf( stderr, "Message Digest '%s' not found\n", argv[1] );
return( exit_code ); mbedtls_exit( exit_code );
} }
if( mbedtls_md_setup( &md_ctx, md_info, 0 ) ) if( mbedtls_md_setup( &md_ctx, md_info, 0 ) )
{ {
mbedtls_fprintf( stderr, "Failed to initialize context.\n" ); mbedtls_fprintf( stderr, "Failed to initialize context.\n" );
return( exit_code ); mbedtls_exit( exit_code );
} }
ret = 0; ret = 0;
@ -234,6 +235,6 @@ int main( int argc, char *argv[] )
exit: exit:
mbedtls_md_free( &md_ctx ); mbedtls_md_free( &md_ctx );
return( exit_code ); mbedtls_exit( exit_code );
} }
#endif /* MBEDTLS_MD_C && MBEDTLS_FS_IO */ #endif /* MBEDTLS_MD_C && MBEDTLS_FS_IO */

View file

@ -31,6 +31,7 @@
#include <stdlib.h> #include <stdlib.h>
#include <stdio.h> #include <stdio.h>
#define mbedtls_printf printf #define mbedtls_printf printf
#define mbedtls_exit exit
#define MBEDTLS_EXIT_SUCCESS EXIT_SUCCESS #define MBEDTLS_EXIT_SUCCESS EXIT_SUCCESS
#define MBEDTLS_EXIT_FAILURE EXIT_FAILURE #define MBEDTLS_EXIT_FAILURE EXIT_FAILURE
#endif #endif
@ -43,7 +44,7 @@
int main( void ) int main( void )
{ {
mbedtls_printf("MBEDTLS_MD5_C not defined.\n"); mbedtls_printf("MBEDTLS_MD5_C not defined.\n");
return( 0 ); mbedtls_exit( 0 );
} }
#else #else
int main( void ) int main( void )
@ -55,7 +56,7 @@ int main( void )
mbedtls_printf( "\n MD5('%s') = ", str ); mbedtls_printf( "\n MD5('%s') = ", str );
if( ( ret = mbedtls_md5_ret( (unsigned char *) str, 13, digest ) ) != 0 ) if( ( ret = mbedtls_md5_ret( (unsigned char *) str, 13, digest ) ) != 0 )
return( MBEDTLS_EXIT_FAILURE ); mbedtls_exit( MBEDTLS_EXIT_FAILURE );
for( i = 0; i < 16; i++ ) for( i = 0; i < 16; i++ )
mbedtls_printf( "%02x", digest[i] ); mbedtls_printf( "%02x", digest[i] );
@ -67,6 +68,6 @@ int main( void )
fflush( stdout ); getchar(); fflush( stdout ); getchar();
#endif #endif
return( MBEDTLS_EXIT_SUCCESS ); mbedtls_exit( MBEDTLS_EXIT_SUCCESS );
} }
#endif /* MBEDTLS_MD5_C */ #endif /* MBEDTLS_MD5_C */

View file

@ -32,6 +32,7 @@
#include <stdlib.h> #include <stdlib.h>
#define mbedtls_printf printf #define mbedtls_printf printf
#define mbedtls_time_t time_t #define mbedtls_time_t time_t
#define mbedtls_exit exit
#define MBEDTLS_EXIT_SUCCESS EXIT_SUCCESS #define MBEDTLS_EXIT_SUCCESS EXIT_SUCCESS
#define MBEDTLS_EXIT_FAILURE EXIT_FAILURE #define MBEDTLS_EXIT_FAILURE EXIT_FAILURE
#endif /* MBEDTLS_PLATFORM_C */ #endif /* MBEDTLS_PLATFORM_C */
@ -67,7 +68,7 @@ int main( void )
"and/or MBEDTLS_NET_C and/or MBEDTLS_RSA_C and/or " "and/or MBEDTLS_NET_C and/or MBEDTLS_RSA_C and/or "
"MBEDTLS_SHA256_C and/or MBEDTLS_FS_IO and/or " "MBEDTLS_SHA256_C and/or MBEDTLS_FS_IO and/or "
"MBEDTLS_CTR_DRBG_C not defined.\n"); "MBEDTLS_CTR_DRBG_C not defined.\n");
return( 0 ); mbedtls_exit( 0 );
} }
#else #else
int main( void ) int main( void )
@ -304,7 +305,7 @@ exit:
fflush( stdout ); getchar(); fflush( stdout ); getchar();
#endif #endif
return( exit_code ); mbedtls_exit( exit_code );
} }
#endif /* MBEDTLS_AES_C && MBEDTLS_DHM_C && MBEDTLS_ENTROPY_C && #endif /* MBEDTLS_AES_C && MBEDTLS_DHM_C && MBEDTLS_ENTROPY_C &&
MBEDTLS_NET_C && MBEDTLS_RSA_C && MBEDTLS_SHA256_C && MBEDTLS_NET_C && MBEDTLS_RSA_C && MBEDTLS_SHA256_C &&

View file

@ -32,6 +32,7 @@
#include <stdlib.h> #include <stdlib.h>
#define mbedtls_printf printf #define mbedtls_printf printf
#define mbedtls_time_t time_t #define mbedtls_time_t time_t
#define mbedtls_exit exit
#define MBEDTLS_EXIT_SUCCESS EXIT_SUCCESS #define MBEDTLS_EXIT_SUCCESS EXIT_SUCCESS
#define MBEDTLS_EXIT_FAILURE EXIT_FAILURE #define MBEDTLS_EXIT_FAILURE EXIT_FAILURE
#endif /* MBEDTLS_PLATFORM_C */ #endif /* MBEDTLS_PLATFORM_C */
@ -44,7 +45,7 @@ int main( void )
mbedtls_printf("MBEDTLS_BIGNUM_C and/or MBEDTLS_ENTROPY_C and/or " mbedtls_printf("MBEDTLS_BIGNUM_C and/or MBEDTLS_ENTROPY_C and/or "
"MBEDTLS_FS_IO and/or MBEDTLS_CTR_DRBG_C and/or " "MBEDTLS_FS_IO and/or MBEDTLS_CTR_DRBG_C and/or "
"MBEDTLS_GENPRIME not defined.\n"); "MBEDTLS_GENPRIME not defined.\n");
return( 0 ); mbedtls_exit( 0 );
} }
#else #else
@ -89,7 +90,7 @@ int main( int argc, char **argv )
{ {
usage: usage:
mbedtls_printf( USAGE ); mbedtls_printf( USAGE );
return( exit_code ); mbedtls_exit( exit_code );
} }
for( i = 1; i < argc; i++ ) for( i = 1; i < argc; i++ )
@ -195,7 +196,7 @@ exit:
fflush( stdout ); getchar(); fflush( stdout ); getchar();
#endif #endif
return( exit_code ); mbedtls_exit( exit_code );
} }
#endif /* MBEDTLS_BIGNUM_C && MBEDTLS_ENTROPY_C && MBEDTLS_FS_IO && #endif /* MBEDTLS_BIGNUM_C && MBEDTLS_ENTROPY_C && MBEDTLS_FS_IO &&
MBEDTLS_CTR_DRBG_C && MBEDTLS_GENPRIME */ MBEDTLS_CTR_DRBG_C && MBEDTLS_GENPRIME */

View file

@ -32,6 +32,7 @@
#include <stdlib.h> #include <stdlib.h>
#define mbedtls_printf printf #define mbedtls_printf printf
#define mbedtls_time_t time_t #define mbedtls_time_t time_t
#define mbedtls_exit exit
#define MBEDTLS_EXIT_SUCCESS EXIT_SUCCESS #define MBEDTLS_EXIT_SUCCESS EXIT_SUCCESS
#define MBEDTLS_EXIT_FAILURE EXIT_FAILURE #define MBEDTLS_EXIT_FAILURE EXIT_FAILURE
#endif /* MBEDTLS_PLATFORM_C */ #endif /* MBEDTLS_PLATFORM_C */
@ -67,7 +68,7 @@ int main( void )
"and/or MBEDTLS_NET_C and/or MBEDTLS_RSA_C and/or " "and/or MBEDTLS_NET_C and/or MBEDTLS_RSA_C and/or "
"MBEDTLS_SHA256_C and/or MBEDTLS_FS_IO and/or " "MBEDTLS_SHA256_C and/or MBEDTLS_FS_IO and/or "
"MBEDTLS_CTR_DRBG_C not defined.\n"); "MBEDTLS_CTR_DRBG_C not defined.\n");
return( 0 ); mbedtls_exit( 0 );
} }
#else #else
int main( void ) int main( void )
@ -327,7 +328,7 @@ exit:
fflush( stdout ); getchar(); fflush( stdout ); getchar();
#endif #endif
return( exit_code ); mbedtls_exit( exit_code );
} }
#endif /* MBEDTLS_AES_C && MBEDTLS_DHM_C && MBEDTLS_ENTROPY_C && #endif /* MBEDTLS_AES_C && MBEDTLS_DHM_C && MBEDTLS_ENTROPY_C &&
MBEDTLS_NET_C && MBEDTLS_RSA_C && MBEDTLS_SHA256_C && MBEDTLS_NET_C && MBEDTLS_RSA_C && MBEDTLS_SHA256_C &&

View file

@ -31,6 +31,7 @@
#include <stdio.h> #include <stdio.h>
#include <stdlib.h> #include <stdlib.h>
#define mbedtls_printf printf #define mbedtls_printf printf
#define mbedtls_exit exit
#define MBEDTLS_EXIT_SUCCESS EXIT_SUCCESS #define MBEDTLS_EXIT_SUCCESS EXIT_SUCCESS
#define MBEDTLS_EXIT_FAILURE EXIT_FAILURE #define MBEDTLS_EXIT_FAILURE EXIT_FAILURE
#endif /* MBEDTLS_PLATFORM_C */ #endif /* MBEDTLS_PLATFORM_C */
@ -44,7 +45,7 @@ int main( void )
"MBEDTLS_ECP_DP_CURVE25519_ENABLED and/or " "MBEDTLS_ECP_DP_CURVE25519_ENABLED and/or "
"MBEDTLS_ENTROPY_C and/or MBEDTLS_CTR_DRBG_C " "MBEDTLS_ENTROPY_C and/or MBEDTLS_CTR_DRBG_C "
"not defined\n" ); "not defined\n" );
return( 0 ); mbedtls_exit( 0 );
} }
#else #else
@ -236,7 +237,7 @@ exit:
mbedtls_ctr_drbg_free( &ctr_drbg ); mbedtls_ctr_drbg_free( &ctr_drbg );
mbedtls_entropy_free( &entropy ); mbedtls_entropy_free( &entropy );
return( exit_code ); mbedtls_exit( exit_code );
} }
#endif /* MBEDTLS_ECDH_C && MBEDTLS_ECP_DP_CURVE25519_ENABLED && #endif /* MBEDTLS_ECDH_C && MBEDTLS_ECP_DP_CURVE25519_ENABLED &&
MBEDTLS_ENTROPY_C && MBEDTLS_CTR_DRBG_C */ MBEDTLS_ENTROPY_C && MBEDTLS_CTR_DRBG_C */

View file

@ -31,6 +31,7 @@
#include <stdio.h> #include <stdio.h>
#include <stdlib.h> #include <stdlib.h>
#define mbedtls_printf printf #define mbedtls_printf printf
#define mbedtls_exit exit
#define MBEDTLS_EXIT_SUCCESS EXIT_SUCCESS #define MBEDTLS_EXIT_SUCCESS EXIT_SUCCESS
#define MBEDTLS_EXIT_FAILURE EXIT_FAILURE #define MBEDTLS_EXIT_FAILURE EXIT_FAILURE
#endif /* MBEDTLS_PLATFORM_C */ #endif /* MBEDTLS_PLATFORM_C */
@ -65,7 +66,7 @@ int main( void )
{ {
mbedtls_printf("MBEDTLS_ECDSA_C and/or MBEDTLS_SHA256_C and/or " mbedtls_printf("MBEDTLS_ECDSA_C and/or MBEDTLS_SHA256_C and/or "
"MBEDTLS_ENTROPY_C and/or MBEDTLS_CTR_DRBG_C not defined\n"); "MBEDTLS_ENTROPY_C and/or MBEDTLS_CTR_DRBG_C not defined\n");
return( 0 ); mbedtls_exit( 0 );
} }
#else #else
#if defined(VERBOSE) #if defined(VERBOSE)
@ -246,7 +247,7 @@ exit:
mbedtls_ctr_drbg_free( &ctr_drbg ); mbedtls_ctr_drbg_free( &ctr_drbg );
mbedtls_entropy_free( &entropy ); mbedtls_entropy_free( &entropy );
return( exit_code ); mbedtls_exit( exit_code );
} }
#endif /* MBEDTLS_ECDSA_C && MBEDTLS_ENTROPY_C && MBEDTLS_CTR_DRBG_C && #endif /* MBEDTLS_ECDSA_C && MBEDTLS_ENTROPY_C && MBEDTLS_CTR_DRBG_C &&
ECPARAMS */ ECPARAMS */

View file

@ -31,6 +31,7 @@
#include <stdio.h> #include <stdio.h>
#include <stdlib.h> #include <stdlib.h>
#define mbedtls_printf printf #define mbedtls_printf printf
#define mbedtls_exit exit
#define MBEDTLS_EXIT_SUCCESS EXIT_SUCCESS #define MBEDTLS_EXIT_SUCCESS EXIT_SUCCESS
#define MBEDTLS_EXIT_FAILURE EXIT_FAILURE #define MBEDTLS_EXIT_FAILURE EXIT_FAILURE
#endif /* MBEDTLS_PLATFORM_C */ #endif /* MBEDTLS_PLATFORM_C */
@ -132,7 +133,7 @@ int main( void )
"MBEDTLS_ENTROPY_C and/or MBEDTLS_CTR_DRBG_C and/or " "MBEDTLS_ENTROPY_C and/or MBEDTLS_CTR_DRBG_C and/or "
"MBEDTLS_PEM_WRITE_C" "MBEDTLS_PEM_WRITE_C"
"not defined.\n" ); "not defined.\n" );
return( 0 ); mbedtls_exit( 0 );
} }
#else #else
/* /*
@ -443,7 +444,7 @@ exit:
fflush( stdout ); getchar(); fflush( stdout ); getchar();
#endif #endif
return( exit_code ); mbedtls_exit( exit_code );
} }
#endif /* MBEDTLS_PK_WRITE_C && MBEDTLS_PEM_WRITE_C && MBEDTLS_FS_IO && #endif /* MBEDTLS_PK_WRITE_C && MBEDTLS_PEM_WRITE_C && MBEDTLS_FS_IO &&
* MBEDTLS_ENTROPY_C && MBEDTLS_CTR_DRBG_C */ * MBEDTLS_ENTROPY_C && MBEDTLS_CTR_DRBG_C */

View file

@ -31,6 +31,7 @@
#include <stdio.h> #include <stdio.h>
#include <stdlib.h> #include <stdlib.h>
#define mbedtls_printf printf #define mbedtls_printf printf
#define mbedtls_exit exit
#define MBEDTLS_EXIT_SUCCESS EXIT_SUCCESS #define MBEDTLS_EXIT_SUCCESS EXIT_SUCCESS
#define MBEDTLS_EXIT_FAILURE EXIT_FAILURE #define MBEDTLS_EXIT_FAILURE EXIT_FAILURE
#endif /* MBEDTLS_PLATFORM_C */ #endif /* MBEDTLS_PLATFORM_C */
@ -70,7 +71,7 @@ int main( void )
{ {
mbedtls_printf("MBEDTLS_BIGNUM_C and/or " mbedtls_printf("MBEDTLS_BIGNUM_C and/or "
"MBEDTLS_PK_PARSE_C and/or MBEDTLS_FS_IO not defined.\n"); "MBEDTLS_PK_PARSE_C and/or MBEDTLS_FS_IO not defined.\n");
return( 0 ); mbedtls_exit( 0 );
} }
#else #else
/* /*
@ -309,6 +310,6 @@ cleanup:
fflush( stdout ); getchar(); fflush( stdout ); getchar();
#endif #endif
return( exit_code ); mbedtls_exit( exit_code );
} }
#endif /* MBEDTLS_BIGNUM_C && MBEDTLS_PK_PARSE_C && MBEDTLS_FS_IO */ #endif /* MBEDTLS_BIGNUM_C && MBEDTLS_PK_PARSE_C && MBEDTLS_FS_IO */

View file

@ -31,6 +31,7 @@
#include <stdio.h> #include <stdio.h>
#include <stdlib.h> #include <stdlib.h>
#define mbedtls_printf printf #define mbedtls_printf printf
#define mbedtls_exit exit
#define MBEDTLS_EXIT_SUCCESS EXIT_SUCCESS #define MBEDTLS_EXIT_SUCCESS EXIT_SUCCESS
#define MBEDTLS_EXIT_FAILURE EXIT_FAILURE #define MBEDTLS_EXIT_FAILURE EXIT_FAILURE
#endif /* MBEDTLS_PLATFORM_C */ #endif /* MBEDTLS_PLATFORM_C */
@ -93,7 +94,7 @@
int main( void ) int main( void )
{ {
mbedtls_printf( "MBEDTLS_PK_PARSE_C and/or MBEDTLS_PK_WRITE_C and/or MBEDTLS_FS_IO not defined.\n" ); mbedtls_printf( "MBEDTLS_PK_PARSE_C and/or MBEDTLS_PK_WRITE_C and/or MBEDTLS_FS_IO not defined.\n" );
return( 0 ); mbedtls_exit( 0 );
} }
#else #else
/* /*
@ -433,6 +434,6 @@ exit:
fflush( stdout ); getchar(); fflush( stdout ); getchar();
#endif #endif
return( exit_code ); mbedtls_exit( exit_code );
} }
#endif /* MBEDTLS_PK_PARSE_C && MBEDTLS_PK_WRITE_C && MBEDTLS_FS_IO */ #endif /* MBEDTLS_PK_PARSE_C && MBEDTLS_PK_WRITE_C && MBEDTLS_FS_IO */

View file

@ -31,6 +31,7 @@
#include <stdio.h> #include <stdio.h>
#include <stdlib.h> #include <stdlib.h>
#define mbedtls_printf printf #define mbedtls_printf printf
#define mbedtls_exit exit
#define MBEDTLS_EXIT_SUCCESS EXIT_SUCCESS #define MBEDTLS_EXIT_SUCCESS EXIT_SUCCESS
#define MBEDTLS_EXIT_FAILURE EXIT_FAILURE #define MBEDTLS_EXIT_FAILURE EXIT_FAILURE
#endif /* MBEDTLS_PLATFORM_C */ #endif /* MBEDTLS_PLATFORM_C */
@ -45,7 +46,7 @@
int main( void ) int main( void )
{ {
mbedtls_printf("MBEDTLS_BIGNUM_C and/or MBEDTLS_FS_IO not defined.\n"); mbedtls_printf("MBEDTLS_BIGNUM_C and/or MBEDTLS_FS_IO not defined.\n");
return( 0 ); mbedtls_exit( 0 );
} }
#else #else
int main( void ) int main( void )
@ -109,6 +110,6 @@ cleanup:
fflush( stdout ); getchar(); fflush( stdout ); getchar();
#endif #endif
return( exit_code ); mbedtls_exit( exit_code );
} }
#endif /* MBEDTLS_BIGNUM_C && MBEDTLS_FS_IO */ #endif /* MBEDTLS_BIGNUM_C && MBEDTLS_FS_IO */

View file

@ -31,6 +31,7 @@
#include <stdio.h> #include <stdio.h>
#include <stdlib.h> #include <stdlib.h>
#define mbedtls_printf printf #define mbedtls_printf printf
#define mbedtls_exit exit
#define MBEDTLS_EXIT_SUCCESS EXIT_SUCCESS #define MBEDTLS_EXIT_SUCCESS EXIT_SUCCESS
#define MBEDTLS_EXIT_FAILURE EXIT_FAILURE #define MBEDTLS_EXIT_FAILURE EXIT_FAILURE
#endif /* MBEDTLS_PLATFORM_C */ #endif /* MBEDTLS_PLATFORM_C */
@ -56,7 +57,7 @@ int main( void )
mbedtls_printf("MBEDTLS_BIGNUM_C and/or MBEDTLS_PK_PARSE_C and/or " mbedtls_printf("MBEDTLS_BIGNUM_C and/or MBEDTLS_PK_PARSE_C and/or "
"MBEDTLS_FS_IO and/or MBEDTLS_ENTROPY_C and/or " "MBEDTLS_FS_IO and/or MBEDTLS_ENTROPY_C and/or "
"MBEDTLS_CTR_DRBG_C not defined.\n"); "MBEDTLS_CTR_DRBG_C not defined.\n");
return( 0 ); mbedtls_exit( 0 );
} }
#else #else
int main( int argc, char *argv[] ) int main( int argc, char *argv[] )
@ -170,7 +171,7 @@ exit:
fflush( stdout ); getchar(); fflush( stdout ); getchar();
#endif #endif
return( exit_code ); mbedtls_exit( exit_code );
} }
#endif /* MBEDTLS_BIGNUM_C && MBEDTLS_PK_PARSE_C && MBEDTLS_FS_IO && #endif /* MBEDTLS_BIGNUM_C && MBEDTLS_PK_PARSE_C && MBEDTLS_FS_IO &&
MBEDTLS_ENTROPY_C && MBEDTLS_CTR_DRBG_C */ MBEDTLS_ENTROPY_C && MBEDTLS_CTR_DRBG_C */

View file

@ -32,6 +32,7 @@
#include <stdlib.h> #include <stdlib.h>
#define mbedtls_fprintf fprintf #define mbedtls_fprintf fprintf
#define mbedtls_printf printf #define mbedtls_printf printf
#define mbedtls_exit exit
#define MBEDTLS_EXIT_SUCCESS EXIT_SUCCESS #define MBEDTLS_EXIT_SUCCESS EXIT_SUCCESS
#define MBEDTLS_EXIT_FAILURE EXIT_FAILURE #define MBEDTLS_EXIT_FAILURE EXIT_FAILURE
#endif /* MBEDTLS_PLATFORM_C */ #endif /* MBEDTLS_PLATFORM_C */
@ -56,7 +57,7 @@ int main( void )
mbedtls_printf("MBEDTLS_BIGNUM_C and/or MBEDTLS_PK_PARSE_C and/or " mbedtls_printf("MBEDTLS_BIGNUM_C and/or MBEDTLS_PK_PARSE_C and/or "
"MBEDTLS_ENTROPY_C and/or MBEDTLS_FS_IO and/or " "MBEDTLS_ENTROPY_C and/or MBEDTLS_FS_IO and/or "
"MBEDTLS_CTR_DRBG_C not defined.\n"); "MBEDTLS_CTR_DRBG_C not defined.\n");
return( 0 ); mbedtls_exit( 0 );
} }
#else #else
int main( int argc, char *argv[] ) int main( int argc, char *argv[] )
@ -173,7 +174,7 @@ exit:
fflush( stdout ); getchar(); fflush( stdout ); getchar();
#endif #endif
return( exit_code ); mbedtls_exit( exit_code );
} }
#endif /* MBEDTLS_BIGNUM_C && MBEDTLS_PK_PARSE_C && MBEDTLS_ENTROPY_C && #endif /* MBEDTLS_BIGNUM_C && MBEDTLS_PK_PARSE_C && MBEDTLS_ENTROPY_C &&
MBEDTLS_FS_IO && MBEDTLS_CTR_DRBG_C */ MBEDTLS_FS_IO && MBEDTLS_CTR_DRBG_C */

View file

@ -32,6 +32,7 @@
#include <stdlib.h> #include <stdlib.h>
#define mbedtls_snprintf snprintf #define mbedtls_snprintf snprintf
#define mbedtls_printf printf #define mbedtls_printf printf
#define mbedtls_exit exit
#define MBEDTLS_EXIT_SUCCESS EXIT_SUCCESS #define MBEDTLS_EXIT_SUCCESS EXIT_SUCCESS
#define MBEDTLS_EXIT_FAILURE EXIT_FAILURE #define MBEDTLS_EXIT_FAILURE EXIT_FAILURE
#endif /* MBEDTLS_PLATFORM_C */ #endif /* MBEDTLS_PLATFORM_C */
@ -46,7 +47,7 @@ int main( void )
"MBEDTLS_SHA256_C and/or MBEDTLS_MD_C and/or " "MBEDTLS_SHA256_C and/or MBEDTLS_MD_C and/or "
"MBEDTLS_PK_PARSE_C and/or MBEDTLS_FS_IO and/or " "MBEDTLS_PK_PARSE_C and/or MBEDTLS_FS_IO and/or "
"MBEDTLS_CTR_DRBG_C not defined.\n"); "MBEDTLS_CTR_DRBG_C not defined.\n");
return( 0 ); mbedtls_exit( 0 );
} }
#else #else
@ -182,7 +183,7 @@ exit:
fflush( stdout ); getchar(); fflush( stdout ); getchar();
#endif #endif
return( exit_code ); mbedtls_exit( exit_code );
} }
#endif /* MBEDTLS_BIGNUM_C && MBEDTLS_ENTROPY_C && #endif /* MBEDTLS_BIGNUM_C && MBEDTLS_ENTROPY_C &&
MBEDTLS_SHA256_C && MBEDTLS_PK_PARSE_C && MBEDTLS_FS_IO && MBEDTLS_SHA256_C && MBEDTLS_PK_PARSE_C && MBEDTLS_FS_IO &&

View file

@ -32,6 +32,7 @@
#include <stdlib.h> #include <stdlib.h>
#define mbedtls_snprintf snprintf #define mbedtls_snprintf snprintf
#define mbedtls_printf printf #define mbedtls_printf printf
#define mbedtls_exit exit
#define MBEDTLS_EXIT_SUCCESS EXIT_SUCCESS #define MBEDTLS_EXIT_SUCCESS EXIT_SUCCESS
#define MBEDTLS_EXIT_FAILURE EXIT_FAILURE #define MBEDTLS_EXIT_FAILURE EXIT_FAILURE
#endif /* MBEDTLS_PLATFORM_C */ #endif /* MBEDTLS_PLATFORM_C */
@ -44,7 +45,7 @@ int main( void )
mbedtls_printf("MBEDTLS_BIGNUM_C and/or MBEDTLS_MD_C and/or " mbedtls_printf("MBEDTLS_BIGNUM_C and/or MBEDTLS_MD_C and/or "
"MBEDTLS_SHA256_C and/or MBEDTLS_PK_PARSE_C and/or " "MBEDTLS_SHA256_C and/or MBEDTLS_PK_PARSE_C and/or "
"MBEDTLS_FS_IO not defined.\n"); "MBEDTLS_FS_IO not defined.\n");
return( 0 ); mbedtls_exit( 0 );
} }
#else #else
@ -146,7 +147,7 @@ exit:
fflush( stdout ); getchar(); fflush( stdout ); getchar();
#endif #endif
return( exit_code ); mbedtls_exit( exit_code );
} }
#endif /* MBEDTLS_BIGNUM_C && MBEDTLS_SHA256_C && #endif /* MBEDTLS_BIGNUM_C && MBEDTLS_SHA256_C &&
MBEDTLS_PK_PARSE_C && MBEDTLS_FS_IO */ MBEDTLS_PK_PARSE_C && MBEDTLS_FS_IO */

View file

@ -55,7 +55,7 @@ int main( void )
mbedtls_printf("MBEDTLS_BIGNUM_C and/or MBEDTLS_RSA_C and/or " mbedtls_printf("MBEDTLS_BIGNUM_C and/or MBEDTLS_RSA_C and/or "
"MBEDTLS_FS_IO and/or MBEDTLS_ENTROPY_C and/or " "MBEDTLS_FS_IO and/or MBEDTLS_ENTROPY_C and/or "
"MBEDTLS_CTR_DRBG_C not defined.\n"); "MBEDTLS_CTR_DRBG_C not defined.\n");
return( 0 ); mbedtls_exit( 0 );
} }
#else #else
int main( int argc, char *argv[] ) int main( int argc, char *argv[] )
@ -205,6 +205,6 @@ exit:
fflush( stdout ); getchar(); fflush( stdout ); getchar();
#endif #endif
return( exit_code ); mbedtls_exit( exit_code );
} }
#endif /* MBEDTLS_BIGNUM_C && MBEDTLS_RSA_C && MBEDTLS_FS_IO */ #endif /* MBEDTLS_BIGNUM_C && MBEDTLS_RSA_C && MBEDTLS_FS_IO */

View file

@ -55,7 +55,7 @@ int main( void )
mbedtls_printf("MBEDTLS_BIGNUM_C and/or MBEDTLS_RSA_C and/or " mbedtls_printf("MBEDTLS_BIGNUM_C and/or MBEDTLS_RSA_C and/or "
"MBEDTLS_ENTROPY_C and/or MBEDTLS_FS_IO and/or " "MBEDTLS_ENTROPY_C and/or MBEDTLS_FS_IO and/or "
"MBEDTLS_CTR_DRBG_C not defined.\n"); "MBEDTLS_CTR_DRBG_C not defined.\n");
return( 0 ); mbedtls_exit( 0 );
} }
#else #else
int main( int argc, char *argv[] ) int main( int argc, char *argv[] )
@ -182,7 +182,7 @@ exit:
fflush( stdout ); getchar(); fflush( stdout ); getchar();
#endif #endif
return( exit_code ); mbedtls_exit( exit_code );
} }
#endif /* MBEDTLS_BIGNUM_C && MBEDTLS_RSA_C && MBEDTLS_ENTROPY_C && #endif /* MBEDTLS_BIGNUM_C && MBEDTLS_RSA_C && MBEDTLS_ENTROPY_C &&
MBEDTLS_FS_IO && MBEDTLS_CTR_DRBG_C */ MBEDTLS_FS_IO && MBEDTLS_CTR_DRBG_C */

View file

@ -31,6 +31,7 @@
#include <stdio.h> #include <stdio.h>
#include <stdlib.h> #include <stdlib.h>
#define mbedtls_printf printf #define mbedtls_printf printf
#define mbedtls_exit exit
#define MBEDTLS_EXIT_SUCCESS EXIT_SUCCESS #define MBEDTLS_EXIT_SUCCESS EXIT_SUCCESS
#define MBEDTLS_EXIT_FAILURE EXIT_FAILURE #define MBEDTLS_EXIT_FAILURE EXIT_FAILURE
#endif /* MBEDTLS_PLATFORM_C */ #endif /* MBEDTLS_PLATFORM_C */
@ -59,7 +60,7 @@ int main( void )
mbedtls_printf("MBEDTLS_BIGNUM_C and/or MBEDTLS_ENTROPY_C and/or " mbedtls_printf("MBEDTLS_BIGNUM_C and/or MBEDTLS_ENTROPY_C and/or "
"MBEDTLS_RSA_C and/or MBEDTLS_GENPRIME and/or " "MBEDTLS_RSA_C and/or MBEDTLS_GENPRIME and/or "
"MBEDTLS_FS_IO and/or MBEDTLS_CTR_DRBG_C not defined.\n"); "MBEDTLS_FS_IO and/or MBEDTLS_CTR_DRBG_C not defined.\n");
return( 0 ); mbedtls_exit( 0 );
} }
#else #else
int main( void ) int main( void )
@ -183,7 +184,7 @@ exit:
fflush( stdout ); getchar(); fflush( stdout ); getchar();
#endif #endif
return( exit_code ); mbedtls_exit( exit_code );
} }
#endif /* MBEDTLS_BIGNUM_C && MBEDTLS_ENTROPY_C && MBEDTLS_RSA_C && #endif /* MBEDTLS_BIGNUM_C && MBEDTLS_ENTROPY_C && MBEDTLS_RSA_C &&
MBEDTLS_GENPRIME && MBEDTLS_FS_IO && MBEDTLS_CTR_DRBG_C */ MBEDTLS_GENPRIME && MBEDTLS_FS_IO && MBEDTLS_CTR_DRBG_C */

View file

@ -33,6 +33,7 @@
#define mbedtls_fprintf fprintf #define mbedtls_fprintf fprintf
#define mbedtls_printf printf #define mbedtls_printf printf
#define mbedtls_snprintf snprintf #define mbedtls_snprintf snprintf
#define mbedtls_exit exit
#define MBEDTLS_EXIT_SUCCESS EXIT_SUCCESS #define MBEDTLS_EXIT_SUCCESS EXIT_SUCCESS
#define MBEDTLS_EXIT_FAILURE EXIT_FAILURE #define MBEDTLS_EXIT_FAILURE EXIT_FAILURE
#endif /* MBEDTLS_PLATFORM_C */ #endif /* MBEDTLS_PLATFORM_C */
@ -45,7 +46,7 @@ int main( void )
mbedtls_printf("MBEDTLS_BIGNUM_C and/or MBEDTLS_RSA_C and/or " mbedtls_printf("MBEDTLS_BIGNUM_C and/or MBEDTLS_RSA_C and/or "
"MBEDTLS_MD_C and/or " "MBEDTLS_MD_C and/or "
"MBEDTLS_SHA256_C and/or MBEDTLS_FS_IO not defined.\n"); "MBEDTLS_SHA256_C and/or MBEDTLS_FS_IO not defined.\n");
return( 0 ); mbedtls_exit( 0 );
} }
#else #else
@ -186,7 +187,7 @@ exit:
fflush( stdout ); getchar(); fflush( stdout ); getchar();
#endif #endif
return( exit_code ); mbedtls_exit( exit_code );
} }
#endif /* MBEDTLS_BIGNUM_C && MBEDTLS_RSA_C && MBEDTLS_SHA256_C && #endif /* MBEDTLS_BIGNUM_C && MBEDTLS_RSA_C && MBEDTLS_SHA256_C &&
MBEDTLS_FS_IO */ MBEDTLS_FS_IO */

View file

@ -32,6 +32,7 @@
#include <stdlib.h> #include <stdlib.h>
#define mbedtls_snprintf snprintf #define mbedtls_snprintf snprintf
#define mbedtls_printf printf #define mbedtls_printf printf
#define mbedtls_exit exit
#define MBEDTLS_EXIT_SUCCESS EXIT_SUCCESS #define MBEDTLS_EXIT_SUCCESS EXIT_SUCCESS
#define MBEDTLS_EXIT_FAILURE EXIT_FAILURE #define MBEDTLS_EXIT_FAILURE EXIT_FAILURE
#endif /* MBEDTLS_PLATFORM_C */ #endif /* MBEDTLS_PLATFORM_C */
@ -46,7 +47,7 @@ int main( void )
"MBEDTLS_RSA_C and/or MBEDTLS_SHA256_C and/or " "MBEDTLS_RSA_C and/or MBEDTLS_SHA256_C and/or "
"MBEDTLS_PK_PARSE_C and/or MBEDTLS_FS_IO and/or " "MBEDTLS_PK_PARSE_C and/or MBEDTLS_FS_IO and/or "
"MBEDTLS_CTR_DRBG_C not defined.\n"); "MBEDTLS_CTR_DRBG_C not defined.\n");
return( 0 ); mbedtls_exit( 0 );
} }
#else #else
@ -173,7 +174,7 @@ exit:
fflush( stdout ); getchar(); fflush( stdout ); getchar();
#endif #endif
return( exit_code ); mbedtls_exit( exit_code );
} }
#endif /* MBEDTLS_BIGNUM_C && MBEDTLS_ENTROPY_C && MBEDTLS_RSA_C && #endif /* MBEDTLS_BIGNUM_C && MBEDTLS_ENTROPY_C && MBEDTLS_RSA_C &&
MBEDTLS_SHA256_C && MBEDTLS_PK_PARSE_C && MBEDTLS_FS_IO && MBEDTLS_SHA256_C && MBEDTLS_PK_PARSE_C && MBEDTLS_FS_IO &&

View file

@ -32,6 +32,7 @@
#include <stdlib.h> #include <stdlib.h>
#define mbedtls_printf printf #define mbedtls_printf printf
#define mbedtls_snprintf snprintf #define mbedtls_snprintf snprintf
#define mbedtls_exit exit
#define MBEDTLS_EXIT_SUCCESS EXIT_SUCCESS #define MBEDTLS_EXIT_SUCCESS EXIT_SUCCESS
#define MBEDTLS_EXIT_FAILURE EXIT_FAILURE #define MBEDTLS_EXIT_FAILURE EXIT_FAILURE
#endif /* MBEDTLS_PLATFORM_C */ #endif /* MBEDTLS_PLATFORM_C */
@ -44,7 +45,7 @@ int main( void )
mbedtls_printf("MBEDTLS_BIGNUM_C and/or MBEDTLS_RSA_C and/or " mbedtls_printf("MBEDTLS_BIGNUM_C and/or MBEDTLS_RSA_C and/or "
"MBEDTLS_MD_C and/or " "MBEDTLS_MD_C and/or "
"MBEDTLS_SHA256_C and/or MBEDTLS_FS_IO not defined.\n"); "MBEDTLS_SHA256_C and/or MBEDTLS_FS_IO not defined.\n");
return( 0 ); mbedtls_exit( 0 );
} }
#else #else
@ -160,7 +161,7 @@ exit:
fflush( stdout ); getchar(); fflush( stdout ); getchar();
#endif #endif
return( exit_code ); mbedtls_exit( exit_code );
} }
#endif /* MBEDTLS_BIGNUM_C && MBEDTLS_RSA_C && MBEDTLS_SHA256_C && #endif /* MBEDTLS_BIGNUM_C && MBEDTLS_RSA_C && MBEDTLS_SHA256_C &&
MBEDTLS_FS_IO */ MBEDTLS_FS_IO */

View file

@ -32,6 +32,7 @@
#include <stdlib.h> #include <stdlib.h>
#define mbedtls_snprintf snprintf #define mbedtls_snprintf snprintf
#define mbedtls_printf printf #define mbedtls_printf printf
#define mbedtls_exit exit
#define MBEDTLS_EXIT_SUCCESS EXIT_SUCCESS #define MBEDTLS_EXIT_SUCCESS EXIT_SUCCESS
#define MBEDTLS_EXIT_FAILURE EXIT_FAILURE #define MBEDTLS_EXIT_FAILURE EXIT_FAILURE
#endif /* MBEDTLS_PLATFORM_C */ #endif /* MBEDTLS_PLATFORM_C */
@ -46,7 +47,7 @@ int main( void )
"MBEDTLS_RSA_C and/or MBEDTLS_SHA256_C and/or " "MBEDTLS_RSA_C and/or MBEDTLS_SHA256_C and/or "
"MBEDTLS_PK_PARSE_C and/or MBEDTLS_FS_IO and/or " "MBEDTLS_PK_PARSE_C and/or MBEDTLS_FS_IO and/or "
"MBEDTLS_CTR_DRBG_C not defined.\n"); "MBEDTLS_CTR_DRBG_C not defined.\n");
return( 0 ); mbedtls_exit( 0 );
} }
#else #else
@ -151,7 +152,7 @@ exit:
fflush( stdout ); getchar(); fflush( stdout ); getchar();
#endif #endif
return( exit_code ); mbedtls_exit( exit_code );
} }
#endif /* MBEDTLS_BIGNUM_C && MBEDTLS_RSA_C && MBEDTLS_SHA256_C && #endif /* MBEDTLS_BIGNUM_C && MBEDTLS_RSA_C && MBEDTLS_SHA256_C &&
MBEDTLS_PK_PARSE_C && MBEDTLS_FS_IO */ MBEDTLS_PK_PARSE_C && MBEDTLS_FS_IO */

View file

@ -32,6 +32,7 @@
#include <stdlib.h> #include <stdlib.h>
#define mbedtls_fprintf fprintf #define mbedtls_fprintf fprintf
#define mbedtls_printf printf #define mbedtls_printf printf
#define mbedtls_exit exit
#define MBEDTLS_EXIT_SUCCESS EXIT_SUCCESS #define MBEDTLS_EXIT_SUCCESS EXIT_SUCCESS
#define MBEDTLS_EXIT_FAILURE EXIT_FAILURE #define MBEDTLS_EXIT_FAILURE EXIT_FAILURE
#endif /* MBEDTLS_PLATFORM_C */ #endif /* MBEDTLS_PLATFORM_C */
@ -46,7 +47,7 @@
int main( void ) int main( void )
{ {
mbedtls_printf("MBEDTLS_ENTROPY_C and/or MBEDTLS_FS_IO not defined.\n"); mbedtls_printf("MBEDTLS_ENTROPY_C and/or MBEDTLS_FS_IO not defined.\n");
return( 0 ); mbedtls_exit( 0 );
} }
#else #else
int main( int argc, char *argv[] ) int main( int argc, char *argv[] )
@ -60,13 +61,13 @@ int main( int argc, char *argv[] )
if( argc < 2 ) if( argc < 2 )
{ {
mbedtls_fprintf( stderr, "usage: %s <output filename>\n", argv[0] ); mbedtls_fprintf( stderr, "usage: %s <output filename>\n", argv[0] );
return( exit_code ); mbedtls_exit( exit_code );
} }
if( ( f = fopen( argv[1], "wb+" ) ) == NULL ) if( ( f = fopen( argv[1], "wb+" ) ) == NULL )
{ {
mbedtls_printf( "failed to open '%s' for writing.\n", argv[1] ); mbedtls_printf( "failed to open '%s' for writing.\n", argv[1] );
return( exit_code ); mbedtls_exit( exit_code );
} }
mbedtls_entropy_init( &entropy ); mbedtls_entropy_init( &entropy );
@ -96,6 +97,6 @@ cleanup:
fclose( f ); fclose( f );
mbedtls_entropy_free( &entropy ); mbedtls_entropy_free( &entropy );
return( exit_code ); mbedtls_exit( exit_code );
} }
#endif /* MBEDTLS_ENTROPY_C */ #endif /* MBEDTLS_ENTROPY_C */

View file

@ -32,6 +32,7 @@
#include <stdlib.h> #include <stdlib.h>
#define mbedtls_fprintf fprintf #define mbedtls_fprintf fprintf
#define mbedtls_printf printf #define mbedtls_printf printf
#define mbedtls_exit exit
#define MBEDTLS_EXIT_SUCCESS EXIT_SUCCESS #define MBEDTLS_EXIT_SUCCESS EXIT_SUCCESS
#define MBEDTLS_EXIT_FAILURE EXIT_FAILURE #define MBEDTLS_EXIT_FAILURE EXIT_FAILURE
#endif /* MBEDTLS_PLATFORM_C */ #endif /* MBEDTLS_PLATFORM_C */
@ -49,7 +50,7 @@
int main( void ) int main( void )
{ {
mbedtls_printf("MBEDTLS_CTR_DRBG_C and/or MBEDTLS_ENTROPY_C and/or MBEDTLS_FS_IO not defined.\n"); mbedtls_printf("MBEDTLS_CTR_DRBG_C and/or MBEDTLS_ENTROPY_C and/or MBEDTLS_FS_IO not defined.\n");
return( 0 ); mbedtls_exit( 0 );
} }
#else #else
int main( int argc, char *argv[] ) int main( int argc, char *argv[] )
@ -66,13 +67,13 @@ int main( int argc, char *argv[] )
if( argc < 2 ) if( argc < 2 )
{ {
mbedtls_fprintf( stderr, "usage: %s <output filename>\n", argv[0] ); mbedtls_fprintf( stderr, "usage: %s <output filename>\n", argv[0] );
return( exit_code ); mbedtls_exit( exit_code );
} }
if( ( f = fopen( argv[1], "wb+" ) ) == NULL ) if( ( f = fopen( argv[1], "wb+" ) ) == NULL )
{ {
mbedtls_printf( "failed to open '%s' for writing.\n", argv[1] ); mbedtls_printf( "failed to open '%s' for writing.\n", argv[1] );
return( exit_code ); mbedtls_exit( exit_code );
} }
mbedtls_entropy_init( &entropy ); mbedtls_entropy_init( &entropy );
@ -129,6 +130,6 @@ cleanup:
mbedtls_ctr_drbg_free( &ctr_drbg ); mbedtls_ctr_drbg_free( &ctr_drbg );
mbedtls_entropy_free( &entropy ); mbedtls_entropy_free( &entropy );
return( exit_code ); mbedtls_exit( exit_code );
} }
#endif /* MBEDTLS_CTR_DRBG_C && MBEDTLS_ENTROPY_C */ #endif /* MBEDTLS_CTR_DRBG_C && MBEDTLS_ENTROPY_C */

View file

@ -32,6 +32,7 @@
#include <stdlib.h> #include <stdlib.h>
#define mbedtls_fprintf fprintf #define mbedtls_fprintf fprintf
#define mbedtls_printf printf #define mbedtls_printf printf
#define mbedtls_exit exit
#define MBEDTLS_EXIT_SUCCESS EXIT_SUCCESS #define MBEDTLS_EXIT_SUCCESS EXIT_SUCCESS
#define MBEDTLS_EXIT_FAILURE EXIT_FAILURE #define MBEDTLS_EXIT_FAILURE EXIT_FAILURE
#endif /* MBEDTLS_PLATFORM_C */ #endif /* MBEDTLS_PLATFORM_C */
@ -47,7 +48,7 @@
int main( void ) int main( void )
{ {
mbedtls_printf("MBEDTLS_HAVEGE_C not defined.\n"); mbedtls_printf("MBEDTLS_HAVEGE_C not defined.\n");
return( 0 ); mbedtls_exit( 0 );
} }
#else #else
int main( int argc, char *argv[] ) int main( int argc, char *argv[] )
@ -62,13 +63,13 @@ int main( int argc, char *argv[] )
if( argc < 2 ) if( argc < 2 )
{ {
mbedtls_fprintf( stderr, "usage: %s <output filename>\n", argv[0] ); mbedtls_fprintf( stderr, "usage: %s <output filename>\n", argv[0] );
return( exit_code ); mbedtls_exit( exit_code );
} }
if( ( f = fopen( argv[1], "wb+" ) ) == NULL ) if( ( f = fopen( argv[1], "wb+" ) ) == NULL )
{ {
mbedtls_printf( "failed to open '%s' for writing.\n", argv[1] ); mbedtls_printf( "failed to open '%s' for writing.\n", argv[1] );
return( exit_code ); mbedtls_exit( exit_code );
} }
mbedtls_havege_init( &hs ); mbedtls_havege_init( &hs );
@ -101,6 +102,6 @@ int main( int argc, char *argv[] )
exit: exit:
mbedtls_havege_free( &hs ); mbedtls_havege_free( &hs );
fclose( f ); fclose( f );
return( exit_code ); mbedtls_exit( exit_code );
} }
#endif /* MBEDTLS_HAVEGE_C */ #endif /* MBEDTLS_HAVEGE_C */

View file

@ -29,8 +29,10 @@
#include "mbedtls/platform.h" #include "mbedtls/platform.h"
#else #else
#include <stdio.h> #include <stdio.h>
#include <stdlib.h>
#define mbedtls_printf printf #define mbedtls_printf printf
#define mbedtls_fprintf fprintf #define mbedtls_fprintf fprintf
#define mbedtls_exit exit
#endif #endif
#if !defined(MBEDTLS_SSL_CLI_C) || !defined(MBEDTLS_SSL_PROTO_DTLS) || \ #if !defined(MBEDTLS_SSL_CLI_C) || !defined(MBEDTLS_SSL_PROTO_DTLS) || \
@ -45,7 +47,7 @@ int main( void )
"MBEDTLS_ENTROPY_C and/or MBEDTLS_CTR_DRBG_C and/or " "MBEDTLS_ENTROPY_C and/or MBEDTLS_CTR_DRBG_C and/or "
"MBEDTLS_X509_CRT_PARSE_C and/or MBEDTLS_RSA_C and/or " "MBEDTLS_X509_CRT_PARSE_C and/or MBEDTLS_RSA_C and/or "
"MBEDTLS_CERTS_C and/or MBEDTLS_PEM_PARSE_C not defined.\n" ); "MBEDTLS_CERTS_C and/or MBEDTLS_PEM_PARSE_C not defined.\n" );
return( 0 ); mbedtls_exit( 0 );
} }
#else #else
@ -351,7 +353,7 @@ exit:
if( ret < 0 ) if( ret < 0 )
ret = 1; ret = 1;
return( ret ); mbedtls_exit( ret );
} }
#endif /* MBEDTLS_SSL_CLI_C && MBEDTLS_SSL_PROTO_DTLS && MBEDTLS_NET_C && #endif /* MBEDTLS_SSL_CLI_C && MBEDTLS_SSL_PROTO_DTLS && MBEDTLS_NET_C &&
MBEDTLD_TIMING_C && MBEDTLS_ENTROPY_C && MBEDTLS_CTR_DRBG_C && MBEDTLD_TIMING_C && MBEDTLS_ENTROPY_C && MBEDTLS_CTR_DRBG_C &&

View file

@ -29,9 +29,11 @@
#include "mbedtls/platform.h" #include "mbedtls/platform.h"
#else #else
#include <stdio.h> #include <stdio.h>
#include <stdlib.h>
#define mbedtls_printf printf #define mbedtls_printf printf
#define mbedtls_fprintf fprintf #define mbedtls_fprintf fprintf
#define mbedtls_time_t time_t #define mbedtls_time_t time_t
#define mbedtls_exit exit
#endif #endif
/* Uncomment out the following line to default to IPv4 and disable IPv6 */ /* Uncomment out the following line to default to IPv4 and disable IPv6 */
@ -58,7 +60,7 @@ int main( void )
"MBEDTLS_X509_CRT_PARSE_C and/or MBEDTLS_RSA_C and/or " "MBEDTLS_X509_CRT_PARSE_C and/or MBEDTLS_RSA_C and/or "
"MBEDTLS_CERTS_C and/or MBEDTLS_PEM_PARSE_C and/or " "MBEDTLS_CERTS_C and/or MBEDTLS_PEM_PARSE_C and/or "
"MBEDTLS_TIMING_C not defined.\n" ); "MBEDTLS_TIMING_C not defined.\n" );
return( 0 ); mbedtls_exit( 0 );
} }
#else #else
@ -426,7 +428,7 @@ exit:
if( ret < 0 ) if( ret < 0 )
ret = 1; ret = 1;
return( ret ); mbedtls_exit( ret );
} }
#endif /* MBEDTLS_SSL_SRV_C && MBEDTLS_SSL_PROTO_DTLS && #endif /* MBEDTLS_SSL_SRV_C && MBEDTLS_SSL_PROTO_DTLS &&
MBEDTLS_SSL_COOKIE_C && MBEDTLS_NET_C && MBEDTLS_ENTROPY_C && MBEDTLS_SSL_COOKIE_C && MBEDTLS_NET_C && MBEDTLS_ENTROPY_C &&

View file

@ -26,6 +26,15 @@
#include MBEDTLS_CONFIG_FILE #include MBEDTLS_CONFIG_FILE
#endif #endif
#if defined(MBEDTLS_PLATFORM_C)
#include "mbedtls/platform.h"
#else
#include <stdio.h>
#include <stdlib.h>
#define mbedtls_printf printf
#define mbedtls_exit exit
#endif
/* /*
* We're creating and connecting the socket "manually" rather than using the * We're creating and connecting the socket "manually" rather than using the
* NET module, in order to avoid the overhead of getaddrinfo() which tends to * NET module, in order to avoid the overhead of getaddrinfo() which tends to
@ -44,28 +53,15 @@
!defined(MBEDTLS_NET_C) || !defined(MBEDTLS_SSL_CLI_C) || \ !defined(MBEDTLS_NET_C) || !defined(MBEDTLS_SSL_CLI_C) || \
!defined(UNIX) !defined(UNIX)
#if defined(MBEDTLS_PLATFORM_C)
#include "mbedtls/platform.h"
#else
#include <stdio.h>
#define mbedtls_printf printf
#endif
int main( void ) int main( void )
{ {
mbedtls_printf( "MBEDTLS_CTR_DRBG_C and/or MBEDTLS_ENTROPY_C and/or " mbedtls_printf( "MBEDTLS_CTR_DRBG_C and/or MBEDTLS_ENTROPY_C and/or "
"MBEDTLS_NET_C and/or MBEDTLS_SSL_CLI_C and/or UNIX " "MBEDTLS_NET_C and/or MBEDTLS_SSL_CLI_C and/or UNIX "
"not defined.\n"); "not defined.\n");
return( 0 ); mbedtls_exit( 0 );
} }
#else #else
#if defined(MBEDTLS_PLATFORM_C)
#include "mbedtls/platform.h"
#else
#include <stdlib.h>
#endif
#include <string.h> #include <string.h>
#include "mbedtls/net_sockets.h" #include "mbedtls/net_sockets.h"
@ -297,6 +293,6 @@ exit:
mbedtls_x509_crt_free( &ca ); mbedtls_x509_crt_free( &ca );
#endif #endif
return( ret ); mbedtls_exit( ret );
} }
#endif #endif

View file

@ -34,6 +34,7 @@
#define mbedtls_time_t time_t #define mbedtls_time_t time_t
#define mbedtls_fprintf fprintf #define mbedtls_fprintf fprintf
#define mbedtls_printf printf #define mbedtls_printf printf
#define mbedtls_exit exit
#define MBEDTLS_EXIT_SUCCESS EXIT_SUCCESS #define MBEDTLS_EXIT_SUCCESS EXIT_SUCCESS
#define MBEDTLS_EXIT_FAILURE EXIT_FAILURE #define MBEDTLS_EXIT_FAILURE EXIT_FAILURE
#endif /* MBEDTLS_PLATFORM_C */ #endif /* MBEDTLS_PLATFORM_C */
@ -50,7 +51,7 @@ int main( void )
"MBEDTLS_NET_C and/or MBEDTLS_RSA_C and/or " "MBEDTLS_NET_C and/or MBEDTLS_RSA_C and/or "
"MBEDTLS_CTR_DRBG_C and/or MBEDTLS_X509_CRT_PARSE_C " "MBEDTLS_CTR_DRBG_C and/or MBEDTLS_X509_CRT_PARSE_C "
"not defined.\n"); "not defined.\n");
return( 0 ); mbedtls_exit( 0 );
} }
#else #else
@ -310,7 +311,7 @@ exit:
fflush( stdout ); getchar(); fflush( stdout ); getchar();
#endif #endif
return( exit_code ); mbedtls_exit( exit_code );
} }
#endif /* MBEDTLS_BIGNUM_C && MBEDTLS_ENTROPY_C && MBEDTLS_SSL_TLS_C && #endif /* MBEDTLS_BIGNUM_C && MBEDTLS_ENTROPY_C && MBEDTLS_SSL_TLS_C &&
MBEDTLS_SSL_CLI_C && MBEDTLS_NET_C && MBEDTLS_RSA_C && MBEDTLS_SSL_CLI_C && MBEDTLS_NET_C && MBEDTLS_RSA_C &&

View file

@ -35,6 +35,7 @@
#define mbedtls_printf printf #define mbedtls_printf printf
#define mbedtls_fprintf fprintf #define mbedtls_fprintf fprintf
#define mbedtls_snprintf snprintf #define mbedtls_snprintf snprintf
#define mbedtls_exit exit
#endif #endif
#if !defined(MBEDTLS_ENTROPY_C) || \ #if !defined(MBEDTLS_ENTROPY_C) || \
@ -45,7 +46,7 @@ int main( void )
mbedtls_printf("MBEDTLS_ENTROPY_C and/or " mbedtls_printf("MBEDTLS_ENTROPY_C and/or "
"MBEDTLS_SSL_TLS_C and/or MBEDTLS_SSL_CLI_C and/or " "MBEDTLS_SSL_TLS_C and/or MBEDTLS_SSL_CLI_C and/or "
"MBEDTLS_NET_C and/or MBEDTLS_CTR_DRBG_C and/or not defined.\n"); "MBEDTLS_NET_C and/or MBEDTLS_CTR_DRBG_C and/or not defined.\n");
return( 0 ); mbedtls_exit( 0 );
} }
#else #else
@ -1871,7 +1872,7 @@ exit:
if( ret < 0 ) if( ret < 0 )
ret = 1; ret = 1;
return( ret ); mbedtls_exit( ret );
} }
#endif /* MBEDTLS_BIGNUM_C && MBEDTLS_ENTROPY_C && MBEDTLS_SSL_TLS_C && #endif /* MBEDTLS_BIGNUM_C && MBEDTLS_ENTROPY_C && MBEDTLS_SSL_TLS_C &&
MBEDTLS_SSL_CLI_C && MBEDTLS_NET_C && MBEDTLS_RSA_C && MBEDTLS_SSL_CLI_C && MBEDTLS_NET_C && MBEDTLS_RSA_C &&

View file

@ -33,6 +33,7 @@
#define mbedtls_fprintf fprintf #define mbedtls_fprintf fprintf
#define mbedtls_printf printf #define mbedtls_printf printf
#define mbedtls_time_t time_t #define mbedtls_time_t time_t
#define mbedtls_exit exit
#define MBEDTLS_EXIT_SUCCESS EXIT_SUCCESS #define MBEDTLS_EXIT_SUCCESS EXIT_SUCCESS
#define MBEDTLS_EXIT_FAILURE EXIT_FAILURE #define MBEDTLS_EXIT_FAILURE EXIT_FAILURE
#endif /* MBEDTLS_PLATFORM_C */ #endif /* MBEDTLS_PLATFORM_C */
@ -53,14 +54,14 @@ int main( int argc, char *argv[] )
"MBEDTLS_NET_C and/or MBEDTLS_RSA_C and/or " "MBEDTLS_NET_C and/or MBEDTLS_RSA_C and/or "
"MBEDTLS_CTR_DRBG_C and/or MBEDTLS_X509_CRT_PARSE_C and/or " "MBEDTLS_CTR_DRBG_C and/or MBEDTLS_X509_CRT_PARSE_C and/or "
"MBEDTLS_TIMING_C and/or MBEDTLS_PEM_PARSE_C not defined.\n"); "MBEDTLS_TIMING_C and/or MBEDTLS_PEM_PARSE_C not defined.\n");
return( 0 ); mbedtls_exit( 0 );
} }
#elif defined(_WIN32) #elif defined(_WIN32)
int main( void ) int main( void )
{ {
mbedtls_printf("_WIN32 defined. This application requires fork() and signals " mbedtls_printf("_WIN32 defined. This application requires fork() and signals "
"to work correctly.\n"); "to work correctly.\n");
return( 0 ); mbedtls_exit( 0 );
} }
#else #else
@ -414,7 +415,7 @@ exit:
fflush( stdout ); getchar(); fflush( stdout ); getchar();
#endif #endif
return( exit_code ); mbedtls_exit( exit_code );
} }
#endif /* MBEDTLS_BIGNUM_C && MBEDTLS_CERTS_C && MBEDTLS_ENTROPY_C && #endif /* MBEDTLS_BIGNUM_C && MBEDTLS_CERTS_C && MBEDTLS_ENTROPY_C &&
MBEDTLS_SSL_TLS_C && MBEDTLS_SSL_SRV_C && MBEDTLS_NET_C && MBEDTLS_SSL_TLS_C && MBEDTLS_SSL_SRV_C && MBEDTLS_NET_C &&

View file

@ -34,6 +34,7 @@
#define mbedtls_time_t time_t #define mbedtls_time_t time_t
#define mbedtls_fprintf fprintf #define mbedtls_fprintf fprintf
#define mbedtls_printf printf #define mbedtls_printf printf
#define mbedtls_exit exit
#define MBEDTLS_EXIT_SUCCESS EXIT_SUCCESS #define MBEDTLS_EXIT_SUCCESS EXIT_SUCCESS
#define MBEDTLS_EXIT_FAILURE EXIT_FAILURE #define MBEDTLS_EXIT_FAILURE EXIT_FAILURE
#endif /* MBEDTLS_PLATFORM_C */ #endif /* MBEDTLS_PLATFORM_C */
@ -50,7 +51,7 @@ int main( void )
"MBEDTLS_NET_C and/or MBEDTLS_RSA_C and/or " "MBEDTLS_NET_C and/or MBEDTLS_RSA_C and/or "
"MBEDTLS_CTR_DRBG_C and/or MBEDTLS_X509_CRT_PARSE_C " "MBEDTLS_CTR_DRBG_C and/or MBEDTLS_X509_CRT_PARSE_C "
"not defined.\n"); "not defined.\n");
return( 0 ); mbedtls_exit( 0 );
} }
#else #else
@ -846,7 +847,7 @@ exit:
fflush( stdout ); getchar(); fflush( stdout ); getchar();
#endif #endif
return( exit_code ); mbedtls_exit( exit_code );
} }
#endif /* MBEDTLS_BIGNUM_C && MBEDTLS_ENTROPY_C && MBEDTLS_SSL_TLS_C && #endif /* MBEDTLS_BIGNUM_C && MBEDTLS_ENTROPY_C && MBEDTLS_SSL_TLS_C &&
MBEDTLS_SSL_CLI_C && MBEDTLS_NET_C && MBEDTLS_RSA_C ** MBEDTLS_SSL_CLI_C && MBEDTLS_NET_C && MBEDTLS_RSA_C **

View file

@ -30,9 +30,11 @@
#include "mbedtls/platform.h" #include "mbedtls/platform.h"
#else #else
#include <stdio.h> #include <stdio.h>
#include <stdlib.h>
#define mbedtls_fprintf fprintf #define mbedtls_fprintf fprintf
#define mbedtls_printf printf #define mbedtls_printf printf
#define mbedtls_snprintf snprintf #define mbedtls_snprintf snprintf
#define mbedtls_exit exit
#endif #endif
#if !defined(MBEDTLS_BIGNUM_C) || !defined(MBEDTLS_CERTS_C) || \ #if !defined(MBEDTLS_BIGNUM_C) || !defined(MBEDTLS_CERTS_C) || \
@ -50,7 +52,7 @@ int main( void )
"MBEDTLS_CTR_DRBG_C and/or MBEDTLS_X509_CRT_PARSE_C and/or " "MBEDTLS_CTR_DRBG_C and/or MBEDTLS_X509_CRT_PARSE_C and/or "
"MBEDTLS_THREADING_C and/or MBEDTLS_THREADING_PTHREAD " "MBEDTLS_THREADING_C and/or MBEDTLS_THREADING_PTHREAD "
"and/or MBEDTLS_PEM_PARSE_C not defined.\n"); "and/or MBEDTLS_PEM_PARSE_C not defined.\n");
return( 0 ); mbedtls_exit( 0 );
} }
#else #else
@ -520,7 +522,7 @@ exit:
fflush( stdout ); getchar(); fflush( stdout ); getchar();
#endif #endif
return( ret ); mbedtls_exit( ret );
} }
#endif /* MBEDTLS_BIGNUM_C && MBEDTLS_CERTS_C && MBEDTLS_ENTROPY_C && #endif /* MBEDTLS_BIGNUM_C && MBEDTLS_CERTS_C && MBEDTLS_ENTROPY_C &&

View file

@ -34,6 +34,7 @@
#define mbedtls_time_t time_t #define mbedtls_time_t time_t
#define mbedtls_fprintf fprintf #define mbedtls_fprintf fprintf
#define mbedtls_printf printf #define mbedtls_printf printf
#define mbedtls_exit exit
#endif #endif
#if !defined(MBEDTLS_BIGNUM_C) || !defined(MBEDTLS_CERTS_C) || \ #if !defined(MBEDTLS_BIGNUM_C) || !defined(MBEDTLS_CERTS_C) || \
@ -49,7 +50,7 @@ int main( void )
"MBEDTLS_NET_C and/or MBEDTLS_RSA_C and/or " "MBEDTLS_NET_C and/or MBEDTLS_RSA_C and/or "
"MBEDTLS_CTR_DRBG_C and/or MBEDTLS_X509_CRT_PARSE_C " "MBEDTLS_CTR_DRBG_C and/or MBEDTLS_X509_CRT_PARSE_C "
"and/or MBEDTLS_PEM_PARSE_C not defined.\n"); "and/or MBEDTLS_PEM_PARSE_C not defined.\n");
return( 0 ); mbedtls_exit( 0 );
} }
#else #else
@ -393,7 +394,7 @@ exit:
fflush( stdout ); getchar(); fflush( stdout ); getchar();
#endif #endif
return( ret ); mbedtls_exit( ret );
} }
#endif /* MBEDTLS_BIGNUM_C && MBEDTLS_CERTS_C && MBEDTLS_ENTROPY_C && #endif /* MBEDTLS_BIGNUM_C && MBEDTLS_CERTS_C && MBEDTLS_ENTROPY_C &&
MBEDTLS_SSL_TLS_C && MBEDTLS_SSL_SRV_C && MBEDTLS_NET_C && MBEDTLS_SSL_TLS_C && MBEDTLS_SSL_SRV_C && MBEDTLS_NET_C &&

View file

@ -36,6 +36,7 @@
#define mbedtls_calloc calloc #define mbedtls_calloc calloc
#define mbedtls_fprintf fprintf #define mbedtls_fprintf fprintf
#define mbedtls_printf printf #define mbedtls_printf printf
#define mbedtls_exit exit
#endif #endif
#if !defined(MBEDTLS_ENTROPY_C) || \ #if !defined(MBEDTLS_ENTROPY_C) || \
@ -46,7 +47,7 @@ int main( void )
mbedtls_printf("MBEDTLS_ENTROPY_C and/or " mbedtls_printf("MBEDTLS_ENTROPY_C and/or "
"MBEDTLS_SSL_TLS_C and/or MBEDTLS_SSL_SRV_C and/or " "MBEDTLS_SSL_TLS_C and/or MBEDTLS_SSL_SRV_C and/or "
"MBEDTLS_NET_C and/or MBEDTLS_CTR_DRBG_C and/or not defined.\n"); "MBEDTLS_NET_C and/or MBEDTLS_CTR_DRBG_C and/or not defined.\n");
return( 0 ); mbedtls_exit( 0 );
} }
#else #else
@ -2591,7 +2592,7 @@ exit:
if( ret < 0 ) if( ret < 0 )
ret = 1; ret = 1;
return( ret ); mbedtls_exit( ret );
} }
#endif /* MBEDTLS_BIGNUM_C && MBEDTLS_ENTROPY_C && MBEDTLS_SSL_TLS_C && #endif /* MBEDTLS_BIGNUM_C && MBEDTLS_ENTROPY_C && MBEDTLS_SSL_TLS_C &&
MBEDTLS_SSL_SRV_C && MBEDTLS_NET_C && MBEDTLS_RSA_C && MBEDTLS_SSL_SRV_C && MBEDTLS_NET_C && MBEDTLS_RSA_C &&

View file

@ -29,6 +29,7 @@
#include "mbedtls/platform.h" #include "mbedtls/platform.h"
#else #else
#include <stdio.h> #include <stdio.h>
#include <stdlib.h>
#define mbedtls_exit exit #define mbedtls_exit exit
#define mbedtls_printf printf #define mbedtls_printf printf
#define mbedtls_snprintf snprintf #define mbedtls_snprintf snprintf
@ -39,7 +40,7 @@
int main( void ) int main( void )
{ {
mbedtls_printf("MBEDTLS_TIMING_C not defined.\n"); mbedtls_printf("MBEDTLS_TIMING_C not defined.\n");
return( 0 ); mbedtls_exit( 0 );
} }
#else #else
@ -886,7 +887,7 @@ int main( int argc, char *argv[] )
fflush( stdout ); getchar(); fflush( stdout ); getchar();
#endif #endif
return( 0 ); mbedtls_exit( 0 );
} }
#endif /* MBEDTLS_TIMING_C */ #endif /* MBEDTLS_TIMING_C */

View file

@ -480,7 +480,5 @@ int main( int argc, char *argv[] )
if( suites_failed > 0) if( suites_failed > 0)
mbedtls_exit( MBEDTLS_EXIT_FAILURE ); mbedtls_exit( MBEDTLS_EXIT_FAILURE );
/* return() is here to prevent compiler warnings */ mbedtls_exit( MBEDTLS_EXIT_SUCCESS );
return( MBEDTLS_EXIT_SUCCESS );
} }

View file

@ -40,6 +40,7 @@
#define mbedtls_time time #define mbedtls_time time
#define mbedtls_time_t time_t #define mbedtls_time_t time_t
#define mbedtls_printf printf #define mbedtls_printf printf
#define mbedtls_exit exit
#define MBEDTLS_EXIT_SUCCESS EXIT_SUCCESS #define MBEDTLS_EXIT_SUCCESS EXIT_SUCCESS
#define MBEDTLS_EXIT_FAILURE EXIT_FAILURE #define MBEDTLS_EXIT_FAILURE EXIT_FAILURE
#endif /* MBEDTLS_PLATFORM_C */ #endif /* MBEDTLS_PLATFORM_C */
@ -48,7 +49,7 @@
int main( void ) int main( void )
{ {
mbedtls_printf( "MBEDTLS_NET_C not defined.\n" ); mbedtls_printf( "MBEDTLS_NET_C not defined.\n" );
return( 0 ); mbedtls_exit( 0 );
} }
#else #else
@ -143,7 +144,7 @@ static void exit_usage( const char *name, const char *value )
mbedtls_printf( " option %s: illegal value: %s\n", name, value ); mbedtls_printf( " option %s: illegal value: %s\n", name, value );
mbedtls_printf( USAGE ); mbedtls_printf( USAGE );
exit( 1 ); mbedtls_exit( 1 );
} }
static void get_options( int argc, char *argv[] ) static void get_options( int argc, char *argv[] )
@ -656,7 +657,7 @@ exit:
fflush( stdout ); getchar(); fflush( stdout ); getchar();
#endif #endif
return( exit_code ); mbedtls_exit( exit_code );
} }
#endif /* MBEDTLS_NET_C */ #endif /* MBEDTLS_NET_C */

View file

@ -33,6 +33,7 @@
#define mbedtls_free free #define mbedtls_free free
#define mbedtls_calloc calloc #define mbedtls_calloc calloc
#define mbedtls_printf printf #define mbedtls_printf printf
#define mbedtls_exit exit
#define MBEDTLS_EXIT_SUCCESS EXIT_SUCCESS #define MBEDTLS_EXIT_SUCCESS EXIT_SUCCESS
#define MBEDTLS_EXIT_FAILURE EXIT_FAILURE #define MBEDTLS_EXIT_FAILURE EXIT_FAILURE
#endif /* MBEDTLS_PLATFORM_C */ #endif /* MBEDTLS_PLATFORM_C */
@ -60,7 +61,7 @@
int main( void ) int main( void )
{ {
mbedtls_printf("MBEDTLS_BASE64_C and/or MBEDTLS_FS_IO not defined.\n"); mbedtls_printf("MBEDTLS_BASE64_C and/or MBEDTLS_FS_IO not defined.\n");
return( 0 ); mbedtls_exit( 0 );
} }
#else #else
/* /*
@ -287,6 +288,6 @@ exit:
fflush( stdout ); getchar(); fflush( stdout ); getchar();
#endif #endif
return( exit_code ); mbedtls_exit( exit_code );
} }
#endif /* MBEDTLS_BASE64_C && MBEDTLS_FS_IO */ #endif /* MBEDTLS_BASE64_C && MBEDTLS_FS_IO */

View file

@ -29,7 +29,9 @@
#include "mbedtls/platform.h" #include "mbedtls/platform.h"
#else #else
#include <stdio.h> #include <stdio.h>
#include <stdlib.h>
#define mbedtls_printf printf #define mbedtls_printf printf
#define mbedtls_exit exit
#endif #endif
#if defined(MBEDTLS_ERROR_C) || defined(MBEDTLS_ERROR_STRERROR_DUMMY) #if defined(MBEDTLS_ERROR_C) || defined(MBEDTLS_ERROR_STRERROR_DUMMY)
@ -48,7 +50,7 @@
int main( void ) int main( void )
{ {
mbedtls_printf("MBEDTLS_ERROR_C and/or MBEDTLS_ERROR_STRERROR_DUMMY not defined.\n"); mbedtls_printf("MBEDTLS_ERROR_C and/or MBEDTLS_ERROR_STRERROR_DUMMY not defined.\n");
return( 0 ); mbedtls_exit( 0 );
} }
#else #else
int main( int argc, char *argv[] ) int main( int argc, char *argv[] )
@ -59,7 +61,7 @@ int main( int argc, char *argv[] )
if( argc != 2 ) if( argc != 2 )
{ {
mbedtls_printf( USAGE ); mbedtls_printf( USAGE );
return( 0 ); mbedtls_exit( 0 );
} }
val = strtol( argv[1], &end, 10 ); val = strtol( argv[1], &end, 10 );
@ -87,6 +89,6 @@ int main( int argc, char *argv[] )
fflush( stdout ); getchar(); fflush( stdout ); getchar();
#endif #endif
return( val ); mbedtls_exit( val );
} }
#endif /* MBEDTLS_ERROR_C */ #endif /* MBEDTLS_ERROR_C */

View file

@ -34,6 +34,7 @@
#define mbedtls_time_t time_t #define mbedtls_time_t time_t
#define mbedtls_fprintf fprintf #define mbedtls_fprintf fprintf
#define mbedtls_printf printf #define mbedtls_printf printf
#define mbedtls_exit exit
#define MBEDTLS_EXIT_SUCCESS EXIT_SUCCESS #define MBEDTLS_EXIT_SUCCESS EXIT_SUCCESS
#define MBEDTLS_EXIT_FAILURE EXIT_FAILURE #define MBEDTLS_EXIT_FAILURE EXIT_FAILURE
#endif /* MBEDTLS_PLATFORM_C */ #endif /* MBEDTLS_PLATFORM_C */
@ -50,7 +51,7 @@ int main( void )
"MBEDTLS_NET_C and/or MBEDTLS_RSA_C and/or " "MBEDTLS_NET_C and/or MBEDTLS_RSA_C and/or "
"MBEDTLS_X509_CRT_PARSE_C and/or MBEDTLS_FS_IO and/or " "MBEDTLS_X509_CRT_PARSE_C and/or MBEDTLS_FS_IO and/or "
"MBEDTLS_CTR_DRBG_C not defined.\n"); "MBEDTLS_CTR_DRBG_C not defined.\n");
return( 0 ); mbedtls_exit( 0 );
} }
#else #else
@ -491,7 +492,7 @@ exit:
fflush( stdout ); getchar(); fflush( stdout ); getchar();
#endif #endif
return( exit_code ); mbedtls_exit( exit_code );
} }
#endif /* MBEDTLS_BIGNUM_C && MBEDTLS_ENTROPY_C && MBEDTLS_SSL_TLS_C && #endif /* MBEDTLS_BIGNUM_C && MBEDTLS_ENTROPY_C && MBEDTLS_SSL_TLS_C &&
MBEDTLS_SSL_CLI_C && MBEDTLS_NET_C && MBEDTLS_RSA_C && MBEDTLS_SSL_CLI_C && MBEDTLS_NET_C && MBEDTLS_RSA_C &&

View file

@ -31,6 +31,7 @@
#include <stdio.h> #include <stdio.h>
#include <stdlib.h> #include <stdlib.h>
#define mbedtls_printf printf #define mbedtls_printf printf
#define mbedtls_exit exit
#define MBEDTLS_EXIT_SUCCESS EXIT_SUCCESS #define MBEDTLS_EXIT_SUCCESS EXIT_SUCCESS
#define MBEDTLS_EXIT_FAILURE EXIT_FAILURE #define MBEDTLS_EXIT_FAILURE EXIT_FAILURE
#endif /* MBEDTLS_PLATFORM_C */ #endif /* MBEDTLS_PLATFORM_C */
@ -45,7 +46,7 @@ int main( void )
"MBEDTLS_PK_PARSE_C and/or MBEDTLS_SHA256_C and/or " "MBEDTLS_PK_PARSE_C and/or MBEDTLS_SHA256_C and/or "
"MBEDTLS_ENTROPY_C and/or MBEDTLS_CTR_DRBG_C " "MBEDTLS_ENTROPY_C and/or MBEDTLS_CTR_DRBG_C "
"not defined.\n"); "not defined.\n");
return( 0 ); mbedtls_exit( 0 );
} }
#else #else
@ -436,7 +437,7 @@ exit:
fflush( stdout ); getchar(); fflush( stdout ); getchar();
#endif #endif
return( exit_code ); mbedtls_exit( exit_code );
} }
#endif /* MBEDTLS_X509_CSR_WRITE_C && MBEDTLS_PK_PARSE_C && MBEDTLS_FS_IO && #endif /* MBEDTLS_X509_CSR_WRITE_C && MBEDTLS_PK_PARSE_C && MBEDTLS_FS_IO &&
MBEDTLS_ENTROPY_C && MBEDTLS_CTR_DRBG_C && MBEDTLS_PEM_WRITE_C */ MBEDTLS_ENTROPY_C && MBEDTLS_CTR_DRBG_C && MBEDTLS_PEM_WRITE_C */

View file

@ -31,6 +31,7 @@
#include <stdio.h> #include <stdio.h>
#include <stdlib.h> #include <stdlib.h>
#define mbedtls_printf printf #define mbedtls_printf printf
#define mbedtls_exit exit
#define MBEDTLS_EXIT_SUCCESS EXIT_SUCCESS #define MBEDTLS_EXIT_SUCCESS EXIT_SUCCESS
#define MBEDTLS_EXIT_FAILURE EXIT_FAILURE #define MBEDTLS_EXIT_FAILURE EXIT_FAILURE
#endif /* MBEDTLS_PLATFORM_C */ #endif /* MBEDTLS_PLATFORM_C */
@ -46,7 +47,7 @@ int main( void )
"MBEDTLS_FS_IO and/or MBEDTLS_SHA256_C and/or " "MBEDTLS_FS_IO and/or MBEDTLS_SHA256_C and/or "
"MBEDTLS_ENTROPY_C and/or MBEDTLS_CTR_DRBG_C and/or " "MBEDTLS_ENTROPY_C and/or MBEDTLS_CTR_DRBG_C and/or "
"MBEDTLS_ERROR_C not defined.\n"); "MBEDTLS_ERROR_C not defined.\n");
return( 0 ); mbedtls_exit( 0 );
} }
#else #else
@ -813,7 +814,7 @@ exit:
fflush( stdout ); getchar(); fflush( stdout ); getchar();
#endif #endif
return( exit_code ); mbedtls_exit( exit_code );
} }
#endif /* MBEDTLS_X509_CRT_WRITE_C && MBEDTLS_X509_CRT_PARSE_C && #endif /* MBEDTLS_X509_CRT_WRITE_C && MBEDTLS_X509_CRT_PARSE_C &&
MBEDTLS_FS_IO && MBEDTLS_ENTROPY_C && MBEDTLS_CTR_DRBG_C && MBEDTLS_FS_IO && MBEDTLS_ENTROPY_C && MBEDTLS_CTR_DRBG_C &&

View file

@ -31,6 +31,7 @@
#include <stdio.h> #include <stdio.h>
#include <stdlib.h> #include <stdlib.h>
#define mbedtls_printf printf #define mbedtls_printf printf
#define mbedtls_exit exit
#define MBEDTLS_EXIT_SUCCESS EXIT_SUCCESS #define MBEDTLS_EXIT_SUCCESS EXIT_SUCCESS
#define MBEDTLS_EXIT_FAILURE EXIT_FAILURE #define MBEDTLS_EXIT_FAILURE EXIT_FAILURE
#endif /* MBEDTLS_PLATFORM_C */ #endif /* MBEDTLS_PLATFORM_C */
@ -41,7 +42,7 @@ int main( void )
{ {
mbedtls_printf("MBEDTLS_BIGNUM_C and/or MBEDTLS_RSA_C and/or " mbedtls_printf("MBEDTLS_BIGNUM_C and/or MBEDTLS_RSA_C and/or "
"MBEDTLS_X509_CRL_PARSE_C and/or MBEDTLS_FS_IO not defined.\n"); "MBEDTLS_X509_CRL_PARSE_C and/or MBEDTLS_FS_IO not defined.\n");
return( 0 ); mbedtls_exit( 0 );
} }
#else #else
@ -145,7 +146,7 @@ exit:
fflush( stdout ); getchar(); fflush( stdout ); getchar();
#endif #endif
return( exit_code ); mbedtls_exit( exit_code );
} }
#endif /* MBEDTLS_BIGNUM_C && MBEDTLS_RSA_C && MBEDTLS_X509_CRL_PARSE_C && #endif /* MBEDTLS_BIGNUM_C && MBEDTLS_RSA_C && MBEDTLS_X509_CRL_PARSE_C &&
MBEDTLS_FS_IO */ MBEDTLS_FS_IO */

View file

@ -31,6 +31,7 @@
#include <stdio.h> #include <stdio.h>
#include <stdlib.h> #include <stdlib.h>
#define mbedtls_printf printf #define mbedtls_printf printf
#define mbedtls_exit exit
#define MBEDTLS_EXIT_SUCCESS EXIT_SUCCESS #define MBEDTLS_EXIT_SUCCESS EXIT_SUCCESS
#define MBEDTLS_EXIT_FAILURE EXIT_FAILURE #define MBEDTLS_EXIT_FAILURE EXIT_FAILURE
#endif /* MBEDTLS_PLATFORM_C */ #endif /* MBEDTLS_PLATFORM_C */
@ -41,7 +42,7 @@ int main( void )
{ {
mbedtls_printf("MBEDTLS_BIGNUM_C and/or MBEDTLS_RSA_C and/or " mbedtls_printf("MBEDTLS_BIGNUM_C and/or MBEDTLS_RSA_C and/or "
"MBEDTLS_X509_CSR_PARSE_C and/or MBEDTLS_FS_IO not defined.\n"); "MBEDTLS_X509_CSR_PARSE_C and/or MBEDTLS_FS_IO not defined.\n");
return( 0 ); mbedtls_exit( 0 );
} }
#else #else
@ -145,7 +146,7 @@ exit:
fflush( stdout ); getchar(); fflush( stdout ); getchar();
#endif #endif
return( exit_code ); mbedtls_exit( exit_code );
} }
#endif /* MBEDTLS_BIGNUM_C && MBEDTLS_RSA_C && MBEDTLS_X509_CSR_PARSE_C && #endif /* MBEDTLS_BIGNUM_C && MBEDTLS_RSA_C && MBEDTLS_X509_CSR_PARSE_C &&
MBEDTLS_FS_IO */ MBEDTLS_FS_IO */