Fix const-ness in mbedtls_param_failed()

The previous prototype gave warnings are the strings produced by #cond and
__FILE__ are const, so we shouldn't implicitly cast them to non-const.

While at it modifying most example programs:
- include the header that has the function declaration, so that the definition
  can be checked to match by the compiler
- fix whitespace
- make it work even if PLATFORM_C is not defined:
    - CHECK_PARAMS is not documented as depending on PLATFORM_C and there is
      no reason why it should
    - so, remove the corresponding #if defined in each program...
    - and add missing #defines for mbedtls_exit when needed

The result has been tested (make all test with -Werror) with the following
configurations:

- full with    CHECK_PARAMS with    PLATFORM_C
- full with    CHECK_PARAMS without PLATFORM_C
- full without CHECK_PARAMS without PLATFORM_C
- full without CHECK_PARAMS with    PLATFORM_C

Additionally, it has been manually tested that adding

    mbedtls_aes_init( NULL );

near the normal call to mbedtls_aes_init() in programs/aes/aescrypt2.c has the
expected effect when running the program.
This commit is contained in:
Manuel Pégourié-Gonnard 2018-12-10 14:31:45 +01:00
parent 8e661bf6a8
commit 3ef6a6dc5c
48 changed files with 447 additions and 128 deletions

View File

@ -64,7 +64,9 @@ extern "C" {
* alternatively, through use of setjmp()/longjmp() can resume * alternatively, through use of setjmp()/longjmp() can resume
* execution in the application code. * execution in the application code.
*/ */
void mbedtls_param_failed( char* failure_condition, char* file, int line ); void mbedtls_param_failed( const char* failure_condition,
const char* file,
int line );
#endif /* MBEDTLS_CHECK_PARAMS && !MBEDTLS_PARAM_FAILED */ #endif /* MBEDTLS_CHECK_PARAMS && !MBEDTLS_PARAM_FAILED */
/** /**

View File

@ -37,6 +37,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 */
@ -79,11 +80,14 @@ int main( void )
} }
#else #else
#if defined( MBEDTLS_CHECK_PARAMS ) && defined(MBEDTLS_PLATFORM_C) #if defined(MBEDTLS_CHECK_PARAMS)
void mbedtls_param_failed( char* failure_condition, char* file, int line ) #include "mbedtls/platform_util.h"
void mbedtls_param_failed( const char *failure_condition,
const char *file,
int line )
{ {
mbedtls_printf("%s:%i: Input param failed - %s\n", file, line, mbedtls_printf( "%s:%i: Input param failed - %s\n",
failure_condition ); file, line, failure_condition );
mbedtls_exit( MBEDTLS_EXIT_FAILURE ); mbedtls_exit( MBEDTLS_EXIT_FAILURE );
} }
#endif #endif

View File

@ -38,6 +38,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 */
@ -81,11 +82,14 @@ int main( void )
} }
#else #else
#if defined( MBEDTLS_CHECK_PARAMS ) && defined(MBEDTLS_PLATFORM_C) #if defined(MBEDTLS_CHECK_PARAMS)
void mbedtls_param_failed( char* failure_condition, char* file, int line ) #include "mbedtls/platform_util.h"
void mbedtls_param_failed( const char *failure_condition,
const char *file,
int line )
{ {
mbedtls_printf("%s:%i: Input param failed - %s\n", file, line, mbedtls_printf( "%s:%i: Input param failed - %s\n",
failure_condition ); file, line, failure_condition );
mbedtls_exit( MBEDTLS_EXIT_FAILURE ); mbedtls_exit( MBEDTLS_EXIT_FAILURE );
} }
#endif #endif

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 */
@ -50,6 +51,19 @@ int main( void )
return( 0 ); return( 0 );
} }
#else #else
#if defined(MBEDTLS_CHECK_PARAMS)
#include "mbedtls/platform_util.h"
void mbedtls_param_failed( const char *failure_condition,
const char *file,
int line )
{
mbedtls_printf( "%s:%i: Input param failed - %s\n",
file, line, failure_condition );
mbedtls_exit( MBEDTLS_EXIT_FAILURE );
}
#endif
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 )
{ {
int ret = mbedtls_md_file( md_info, filename, sum ); int ret = mbedtls_md_file( md_info, filename, sum );

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
@ -46,6 +47,19 @@ int main( void )
return( 0 ); return( 0 );
} }
#else #else
#if defined(MBEDTLS_CHECK_PARAMS)
#include "mbedtls/platform_util.h"
void mbedtls_param_failed( const char *failure_condition,
const char *file,
int line )
{
mbedtls_printf( "%s:%i: Input param failed - %s\n",
file, line, failure_condition );
mbedtls_exit( MBEDTLS_EXIT_FAILURE );
}
#endif
int main( void ) int main( void )
{ {
int i, ret; int i, ret;

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 */
@ -71,10 +72,14 @@ int main( void )
} }
#else #else
#if defined( MBEDTLS_CHECK_PARAMS ) && defined(MBEDTLS_PLATFORM_C) #if defined(MBEDTLS_CHECK_PARAMS)
void mbedtls_param_failed( char* failure_condition, char* file, int line ) #include "mbedtls/platform_util.h"
void mbedtls_param_failed( const char *failure_condition,
const char *file,
int line )
{ {
mbedtls_printf("%s:%i: Input param failed - %sn", file, line, failure_condition ); mbedtls_printf( "%s:%i: Input param failed - %s\n",
file, line, failure_condition );
mbedtls_exit( MBEDTLS_EXIT_FAILURE ); mbedtls_exit( MBEDTLS_EXIT_FAILURE );
} }
#endif #endif

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 */
@ -68,10 +69,14 @@ int main( void )
*/ */
#define GENERATOR "4" #define GENERATOR "4"
#if defined( MBEDTLS_CHECK_PARAMS ) && defined(MBEDTLS_PLATFORM_C) #if defined(MBEDTLS_CHECK_PARAMS)
void mbedtls_param_failed( char* failure_condition, char* file, int line ) #include "mbedtls/platform_util.h"
void mbedtls_param_failed( const char *failure_condition,
const char *file,
int line )
{ {
mbedtls_printf("%s:%i: Input param failed - %sn", file, line, failure_condition ); mbedtls_printf( "%s:%i: Input param failed - %s\n",
file, line, failure_condition );
mbedtls_exit( MBEDTLS_EXIT_FAILURE ); mbedtls_exit( MBEDTLS_EXIT_FAILURE );
} }
#endif #endif

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 */
@ -71,10 +72,14 @@ int main( void )
} }
#else #else
#if defined( MBEDTLS_CHECK_PARAMS ) && defined(MBEDTLS_PLATFORM_C) #if defined(MBEDTLS_CHECK_PARAMS)
void mbedtls_param_failed( char* failure_condition, char* file, int line ) #include "mbedtls/platform_util.h"
void mbedtls_param_failed( const char *failure_condition,
const char *file,
int line )
{ {
mbedtls_printf("%s:%i: Input param failed - %sn", file, line, failure_condition ); mbedtls_printf( "%s:%i: Input param failed - %s\n",
file, line, failure_condition );
mbedtls_exit( MBEDTLS_EXIT_FAILURE ); mbedtls_exit( MBEDTLS_EXIT_FAILURE );
} }
#endif #endif

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 */
@ -52,10 +53,14 @@ int main( void )
#include "mbedtls/ctr_drbg.h" #include "mbedtls/ctr_drbg.h"
#include "mbedtls/ecdh.h" #include "mbedtls/ecdh.h"
#if defined( MBEDTLS_CHECK_PARAMS ) && defined(MBEDTLS_PLATFORM_C) #if defined(MBEDTLS_CHECK_PARAMS)
void mbedtls_param_failed( char* failure_condition, char* file, int line ) #include "mbedtls/platform_util.h"
void mbedtls_param_failed( const char *failure_condition,
const char *file,
int line )
{ {
mbedtls_printf("%s:%i: Input param failed - %sn", file, line, failure_condition ); mbedtls_printf( "%s:%i: Input param failed - %s\n",
file, line, failure_condition );
mbedtls_exit( MBEDTLS_EXIT_FAILURE ); mbedtls_exit( MBEDTLS_EXIT_FAILURE );
} }
#endif #endif

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 */
@ -99,10 +100,14 @@ static void dump_pubkey( const char *title, mbedtls_ecdsa_context *key )
#define dump_pubkey( a, b ) #define dump_pubkey( a, b )
#endif #endif
#if defined( MBEDTLS_CHECK_PARAMS ) && defined(MBEDTLS_PLATFORM_C) #if defined(MBEDTLS_CHECK_PARAMS)
void mbedtls_param_failed( char* failure_condition, char* file, int line ) #include "mbedtls/platform_util.h"
void mbedtls_param_failed( const char *failure_condition,
const char *file,
int line )
{ {
mbedtls_printf("%s:%i: Input param failed - %sn", file, line, failure_condition ); mbedtls_printf( "%s:%i: Input param failed - %s\n",
file, line, failure_condition );
mbedtls_exit( MBEDTLS_EXIT_FAILURE ); mbedtls_exit( MBEDTLS_EXIT_FAILURE );
} }
#endif #endif

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 */
@ -136,10 +137,14 @@ int main( void )
} }
#else #else
#if defined( MBEDTLS_CHECK_PARAMS ) && defined(MBEDTLS_PLATFORM_C) #if defined(MBEDTLS_CHECK_PARAMS)
void mbedtls_param_failed( char* failure_condition, char* file, int line ) #include "mbedtls/platform_util.h"
void mbedtls_param_failed( const char *failure_condition,
const char *file,
int line )
{ {
mbedtls_printf("%s:%i: Input param failed - %sn", file, line, failure_condition ); mbedtls_printf( "%s:%i: Input param failed - %s\n",
file, line, failure_condition );
mbedtls_exit( MBEDTLS_EXIT_FAILURE ); mbedtls_exit( MBEDTLS_EXIT_FAILURE );
} }
#endif #endif

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 */
@ -74,10 +75,14 @@ int main( void )
} }
#else #else
#if defined( MBEDTLS_CHECK_PARAMS ) && defined(MBEDTLS_PLATFORM_C) #if defined(MBEDTLS_CHECK_PARAMS)
void mbedtls_param_failed( char* failure_condition, char* file, int line ) #include "mbedtls/platform_util.h"
void mbedtls_param_failed( const char *failure_condition,
const char *file,
int line )
{ {
mbedtls_printf("%s:%i: Input param failed - %sn", file, line, failure_condition ); mbedtls_printf( "%s:%i: Input param failed - %s\n",
file, line, failure_condition );
mbedtls_exit( MBEDTLS_EXIT_FAILURE ); mbedtls_exit( MBEDTLS_EXIT_FAILURE );
} }
#endif #endif

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 */
@ -97,10 +98,14 @@ int main( void )
} }
#else #else
#if defined( MBEDTLS_CHECK_PARAMS ) && defined(MBEDTLS_PLATFORM_C) #if defined(MBEDTLS_CHECK_PARAMS)
void mbedtls_param_failed( char* failure_condition, char* file, int line ) #include "mbedtls/platform_util.h"
void mbedtls_param_failed( const char *failure_condition,
const char *file,
int line )
{ {
mbedtls_printf("%s:%i: Input param failed - %sn", file, line, failure_condition ); mbedtls_printf( "%s:%i: Input param failed - %s\n",
file, line, failure_condition );
mbedtls_exit( MBEDTLS_EXIT_FAILURE ); mbedtls_exit( MBEDTLS_EXIT_FAILURE );
} }
#endif #endif

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 */
@ -48,6 +49,19 @@ int main( void )
return( 0 ); return( 0 );
} }
#else #else
#if defined(MBEDTLS_CHECK_PARAMS)
#include "mbedtls/platform_util.h"
void mbedtls_param_failed( const char *failure_condition,
const char *file,
int line )
{
mbedtls_printf( "%s:%i: Input param failed - %s\n",
file, line, failure_condition );
mbedtls_exit( MBEDTLS_EXIT_FAILURE );
}
#endif
int main( void ) int main( void )
{ {
int ret = 1; int ret = 1;

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 */
@ -60,10 +61,14 @@ int main( void )
} }
#else #else
#if defined( MBEDTLS_CHECK_PARAMS ) && defined(MBEDTLS_PLATFORM_C) #if defined(MBEDTLS_CHECK_PARAMS)
void mbedtls_param_failed( char* failure_condition, char* file, int line ) #include "mbedtls/platform_util.h"
void mbedtls_param_failed( const char *failure_condition,
const char *file,
int line )
{ {
mbedtls_printf("%s:%i: Input param failed - %sn", file, line, failure_condition ); mbedtls_printf( "%s:%i: Input param failed - %s\n",
file, line, failure_condition );
mbedtls_exit( MBEDTLS_EXIT_FAILURE ); mbedtls_exit( MBEDTLS_EXIT_FAILURE );
} }
#endif #endif

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 */
@ -60,10 +61,14 @@ int main( void )
} }
#else #else
#if defined( MBEDTLS_CHECK_PARAMS ) && defined(MBEDTLS_PLATFORM_C) #if defined(MBEDTLS_CHECK_PARAMS)
void mbedtls_param_failed( char* failure_condition, char* file, int line ) #include "mbedtls/platform_util.h"
void mbedtls_param_failed( const char *failure_condition,
const char *file,
int line )
{ {
mbedtls_printf("%s:%i: Input param failed - %sn", file, line, failure_condition ); mbedtls_printf( "%s:%i: Input param failed - %s\n",
file, line, failure_condition );
mbedtls_exit( MBEDTLS_EXIT_FAILURE ); mbedtls_exit( MBEDTLS_EXIT_FAILURE );
} }
#endif #endif

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 */
@ -59,10 +60,14 @@ int main( void )
#include <stdio.h> #include <stdio.h>
#include <string.h> #include <string.h>
#if defined( MBEDTLS_CHECK_PARAMS ) && defined(MBEDTLS_PLATFORM_C) #if defined(MBEDTLS_CHECK_PARAMS)
void mbedtls_param_failed( char* failure_condition, char* file, int line ) #include "mbedtls/platform_util.h"
void mbedtls_param_failed( const char *failure_condition,
const char *file,
int line )
{ {
mbedtls_printf("%s:%i: Input param failed - %sn", file, line, failure_condition ); mbedtls_printf( "%s:%i: Input param failed - %s\n",
file, line, failure_condition );
mbedtls_exit( MBEDTLS_EXIT_FAILURE ); mbedtls_exit( MBEDTLS_EXIT_FAILURE );
} }
#endif #endif

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 */
@ -55,10 +56,14 @@ int main( void )
#include <stdio.h> #include <stdio.h>
#include <string.h> #include <string.h>
#if defined( MBEDTLS_CHECK_PARAMS ) && defined(MBEDTLS_PLATFORM_C) #if defined(MBEDTLS_CHECK_PARAMS)
void mbedtls_param_failed( char* failure_condition, char* file, int line ) #include "mbedtls/platform_util.h"
void mbedtls_param_failed( const char *failure_condition,
const char *file,
int line )
{ {
mbedtls_printf("%s:%i: Input param failed - %sn", file, line, failure_condition ); mbedtls_printf( "%s:%i: Input param failed - %s\n",
file, line, failure_condition );
mbedtls_exit( MBEDTLS_EXIT_FAILURE ); mbedtls_exit( MBEDTLS_EXIT_FAILURE );
} }
#endif #endif

View File

@ -59,10 +59,14 @@ int main( void )
} }
#else #else
#if defined( MBEDTLS_CHECK_PARAMS ) && defined(MBEDTLS_PLATFORM_C) #if defined(MBEDTLS_CHECK_PARAMS)
void mbedtls_param_failed( char* failure_condition, char* file, int line ) #include "mbedtls/platform_util.h"
void mbedtls_param_failed( const char *failure_condition,
const char *file,
int line )
{ {
mbedtls_printf("%s:%i: Input param failed - %sn", file, line, failure_condition ); mbedtls_printf( "%s:%i: Input param failed - %s\n",
file, line, failure_condition );
mbedtls_exit( MBEDTLS_EXIT_FAILURE ); mbedtls_exit( MBEDTLS_EXIT_FAILURE );
} }
#endif #endif

View File

@ -59,10 +59,14 @@ int main( void )
} }
#else #else
#if defined( MBEDTLS_CHECK_PARAMS ) && defined(MBEDTLS_PLATFORM_C) #if defined(MBEDTLS_CHECK_PARAMS)
void mbedtls_param_failed( char* failure_condition, char* file, int line ) #include "mbedtls/platform_util.h"
void mbedtls_param_failed( const char *failure_condition,
const char *file,
int line )
{ {
mbedtls_printf("%s:%i: Input param failed - %sn", file, line, failure_condition ); mbedtls_printf( "%s:%i: Input param failed - %s\n",
file, line, failure_condition );
mbedtls_exit( MBEDTLS_EXIT_FAILURE ); mbedtls_exit( MBEDTLS_EXIT_FAILURE );
} }
#endif #endif

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 */
@ -63,10 +64,14 @@ int main( void )
} }
#else #else
#if defined( MBEDTLS_CHECK_PARAMS ) && defined(MBEDTLS_PLATFORM_C) #if defined(MBEDTLS_CHECK_PARAMS)
void mbedtls_param_failed( char* failure_condition, char* file, int line ) #include "mbedtls/platform_util.h"
void mbedtls_param_failed( const char *failure_condition,
const char *file,
int line )
{ {
mbedtls_printf("%s:%i: Input param failed - %sn", file, line, failure_condition ); mbedtls_printf( "%s:%i: Input param failed - %s\n",
file, line, failure_condition );
mbedtls_exit( MBEDTLS_EXIT_FAILURE ); mbedtls_exit( MBEDTLS_EXIT_FAILURE );
} }
#endif #endif

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 */
@ -55,6 +56,18 @@ int main( void )
#include <stdio.h> #include <stdio.h>
#include <string.h> #include <string.h>
#if defined(MBEDTLS_CHECK_PARAMS)
#include "mbedtls/platform_util.h"
void mbedtls_param_failed( const char *failure_condition,
const char *file,
int line )
{
mbedtls_printf( "%s:%i: Input param failed - %s\n",
file, line, failure_condition );
mbedtls_exit( MBEDTLS_EXIT_FAILURE );
}
#endif
int main( int argc, char *argv[] ) int main( int argc, char *argv[] )
{ {
FILE *f; FILE *f;

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 */
@ -60,10 +61,14 @@ int main( void )
#include <stdio.h> #include <stdio.h>
#include <string.h> #include <string.h>
#if defined( MBEDTLS_CHECK_PARAMS ) && defined(MBEDTLS_PLATFORM_C) #if defined(MBEDTLS_CHECK_PARAMS)
void mbedtls_param_failed( char* failure_condition, char* file, int line ) #include "mbedtls/platform_util.h"
void mbedtls_param_failed( const char *failure_condition,
const char *file,
int line )
{ {
mbedtls_printf("%s:%i: Input param failed - %sn", file, line, failure_condition ); mbedtls_printf( "%s:%i: Input param failed - %s\n",
file, line, failure_condition );
mbedtls_exit( MBEDTLS_EXIT_FAILURE ); mbedtls_exit( MBEDTLS_EXIT_FAILURE );
} }
#endif #endif

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 */
@ -54,6 +55,18 @@ int main( void )
#include <stdio.h> #include <stdio.h>
#include <string.h> #include <string.h>
#if defined(MBEDTLS_CHECK_PARAMS)
#include "mbedtls/platform_util.h"
void mbedtls_param_failed( const char *failure_condition,
const char *file,
int line )
{
mbedtls_printf( "%s:%i: Input param failed - %s\n",
file, line, failure_condition );
mbedtls_exit( MBEDTLS_EXIT_FAILURE );
}
#endif
int main( int argc, char *argv[] ) int main( int argc, char *argv[] )
{ {
FILE *f; FILE *f;

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 */
@ -59,10 +60,14 @@ int main( void )
#include <stdio.h> #include <stdio.h>
#include <string.h> #include <string.h>
#if defined( MBEDTLS_CHECK_PARAMS ) && defined(MBEDTLS_PLATFORM_C) #if defined(MBEDTLS_CHECK_PARAMS)
void mbedtls_param_failed( char* failure_condition, char* file, int line ) #include "mbedtls/platform_util.h"
void mbedtls_param_failed( const char *failure_condition,
const char *file,
int line )
{ {
mbedtls_printf("%s:%i: Input param failed - %sn", file, line, failure_condition ); mbedtls_printf( "%s:%i: Input param failed - %s\n",
file, line, failure_condition );
mbedtls_exit( MBEDTLS_EXIT_FAILURE ); mbedtls_exit( MBEDTLS_EXIT_FAILURE );
} }
#endif #endif

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,6 +50,19 @@ int main( void )
return( 0 ); return( 0 );
} }
#else #else
#if defined(MBEDTLS_CHECK_PARAMS)
#include "mbedtls/platform_util.h"
void mbedtls_param_failed( const char *failure_condition,
const char *file,
int line )
{
mbedtls_printf( "%s:%i: Input param failed - %s\n",
file, line, failure_condition );
mbedtls_exit( MBEDTLS_EXIT_FAILURE );
}
#endif
int main( int argc, char *argv[] ) int main( int argc, char *argv[] )
{ {
FILE *f; FILE *f;

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 */
@ -53,10 +54,14 @@ int main( void )
} }
#else #else
#if defined( MBEDTLS_CHECK_PARAMS ) && defined(MBEDTLS_PLATFORM_C) #if defined(MBEDTLS_CHECK_PARAMS)
void mbedtls_param_failed( char* failure_condition, char* file, int line ) #include "mbedtls/platform_util.h"
void mbedtls_param_failed( const char *failure_condition,
const char *file,
int line )
{ {
mbedtls_printf("%s:%i: Input param failed - %sn", file, line, failure_condition ); mbedtls_printf( "%s:%i: Input param failed - %s\n",
file, line, failure_condition );
mbedtls_exit( MBEDTLS_EXIT_FAILURE ); mbedtls_exit( MBEDTLS_EXIT_FAILURE );
} }
#endif #endif

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 */
@ -50,6 +51,19 @@ int main( void )
return( 0 ); return( 0 );
} }
#else #else
#if defined(MBEDTLS_CHECK_PARAMS)
#include "mbedtls/platform_util.h"
void mbedtls_param_failed( const char *failure_condition,
const char *file,
int line )
{
mbedtls_printf( "%s:%i: Input param failed - %s\n",
file, line, failure_condition );
mbedtls_exit( MBEDTLS_EXIT_FAILURE );
}
#endif
int main( int argc, char *argv[] ) int main( int argc, char *argv[] )
{ {
FILE *f; FILE *f;

View File

@ -31,6 +31,9 @@
#include <stdio.h> #include <stdio.h>
#define mbedtls_printf printf #define mbedtls_printf printf
#define mbedtls_fprintf fprintf #define mbedtls_fprintf fprintf
#define mbedtls_exit exit
#define MBEDTLS_EXIT_SUCCESS EXIT_SUCCESS
#define MBEDTLS_EXIT_FAILURE EXIT_FAILURE
#endif #endif
#if !defined(MBEDTLS_SSL_CLI_C) || !defined(MBEDTLS_SSL_PROTO_DTLS) || \ #if !defined(MBEDTLS_SSL_CLI_C) || !defined(MBEDTLS_SSL_PROTO_DTLS) || \
@ -79,10 +82,14 @@ int main( void )
#define DEBUG_LEVEL 0 #define DEBUG_LEVEL 0
#if defined( MBEDTLS_CHECK_PARAMS ) && defined(MBEDTLS_PLATFORM_C) #if defined(MBEDTLS_CHECK_PARAMS)
void mbedtls_param_failed( char* failure_condition, char* file, int line ) #include "mbedtls/platform_util.h"
void mbedtls_param_failed( const char *failure_condition,
const char *file,
int line )
{ {
mbedtls_printf("%s:%i: Input param failed - %sn", file, line, failure_condition ); mbedtls_printf( "%s:%i: Input param failed - %s\n",
file, line, failure_condition );
mbedtls_exit( MBEDTLS_EXIT_FAILURE ); mbedtls_exit( MBEDTLS_EXIT_FAILURE );
} }
#endif #endif

View File

@ -32,6 +32,9 @@
#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
#define MBEDTLS_EXIT_SUCCESS EXIT_SUCCESS
#define MBEDTLS_EXIT_FAILURE EXIT_FAILURE
#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 */
@ -88,10 +91,14 @@ int main( void )
#define READ_TIMEOUT_MS 10000 /* 5 seconds */ #define READ_TIMEOUT_MS 10000 /* 5 seconds */
#define DEBUG_LEVEL 0 #define DEBUG_LEVEL 0
#if defined( MBEDTLS_CHECK_PARAMS ) && defined(MBEDTLS_PLATFORM_C) #if defined(MBEDTLS_CHECK_PARAMS)
void mbedtls_param_failed( char* failure_condition, char* file, int line ) #include "mbedtls/platform_util.h"
void mbedtls_param_failed( const char *failure_condition,
const char *file,
int line )
{ {
mbedtls_printf("%s:%i: Input param failed - %sn", file, line, failure_condition ); mbedtls_printf( "%s:%i: Input param failed - %s\n",
file, line, failure_condition );
mbedtls_exit( MBEDTLS_EXIT_FAILURE ); mbedtls_exit( MBEDTLS_EXIT_FAILURE );
} }
#endif #endif

View File

@ -26,6 +26,17 @@
#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
#define MBEDTLS_EXIT_SUCCESS EXIT_SUCCESS
#define MBEDTLS_EXIT_FAILURE EXIT_FAILURE
#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,13 +55,6 @@
!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 "
@ -60,12 +64,6 @@ int main( void )
} }
#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"
@ -168,10 +166,14 @@ enum exit_codes
ssl_write_failed, ssl_write_failed,
}; };
#if defined( MBEDTLS_CHECK_PARAMS ) && defined(MBEDTLS_PLATFORM_C) #if defined(MBEDTLS_CHECK_PARAMS)
void mbedtls_param_failed( char* failure_condition, char* file, int line ) #include "mbedtls/platform_util.h"
void mbedtls_param_failed( const char *failure_condition,
const char *file,
int line )
{ {
mbedtls_printf("%s:%i: Input param failed - %sn", file, line, failure_condition ); mbedtls_printf( "%s:%i: Input param failed - %s\n",
file, line, failure_condition );
mbedtls_exit( MBEDTLS_EXIT_FAILURE ); mbedtls_exit( MBEDTLS_EXIT_FAILURE );
} }
#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 */
@ -70,10 +71,14 @@ int main( void )
#define DEBUG_LEVEL 1 #define DEBUG_LEVEL 1
#if defined( MBEDTLS_CHECK_PARAMS ) && defined(MBEDTLS_PLATFORM_C) #if defined(MBEDTLS_CHECK_PARAMS)
void mbedtls_param_failed( char* failure_condition, char* file, int line ) #include "mbedtls/platform_util.h"
void mbedtls_param_failed( const char *failure_condition,
const char *file,
int line )
{ {
mbedtls_printf("%s:%i: Input param failed - %sn", file, line, failure_condition ); mbedtls_printf( "%s:%i: Input param failed - %s\n",
file, line, failure_condition );
mbedtls_exit( MBEDTLS_EXIT_FAILURE ); mbedtls_exit( MBEDTLS_EXIT_FAILURE );
} }
#endif #endif

View File

@ -35,6 +35,9 @@
#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
#define MBEDTLS_EXIT_SUCCESS EXIT_SUCCESS
#define MBEDTLS_EXIT_FAILURE EXIT_FAILURE
#endif #endif
#if !defined(MBEDTLS_ENTROPY_C) || \ #if !defined(MBEDTLS_ENTROPY_C) || \
@ -314,10 +317,14 @@ int main( void )
#define ALPN_LIST_SIZE 10 #define ALPN_LIST_SIZE 10
#define CURVE_LIST_SIZE 20 #define CURVE_LIST_SIZE 20
#if defined( MBEDTLS_CHECK_PARAMS ) && defined(MBEDTLS_PLATFORM_C) #if defined(MBEDTLS_CHECK_PARAMS)
void mbedtls_param_failed( char* failure_condition, char* file, int line ) #include "mbedtls/platform_util.h"
void mbedtls_param_failed( const char *failure_condition,
const char *file,
int line )
{ {
mbedtls_printf("%s:%i: Input param failed - %sn", file, line, failure_condition ); mbedtls_printf( "%s:%i: Input param failed - %s\n",
file, line, failure_condition );
mbedtls_exit( MBEDTLS_EXIT_FAILURE ); mbedtls_exit( MBEDTLS_EXIT_FAILURE );
} }
#endif #endif

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 */
@ -86,10 +87,14 @@ int main( void )
#define DEBUG_LEVEL 0 #define DEBUG_LEVEL 0
#if defined( MBEDTLS_CHECK_PARAMS ) && defined(MBEDTLS_PLATFORM_C) #if defined(MBEDTLS_CHECK_PARAMS)
void mbedtls_param_failed( char* failure_condition, char* file, int line ) #include "mbedtls/platform_util.h"
void mbedtls_param_failed( const char *failure_condition,
const char *file,
int line )
{ {
mbedtls_printf("%s:%i: Input param failed - %sn", file, line, failure_condition ); mbedtls_printf( "%s:%i: Input param failed - %s\n",
file, line, failure_condition );
mbedtls_exit( MBEDTLS_EXIT_FAILURE ); mbedtls_exit( MBEDTLS_EXIT_FAILURE );
} }
#endif #endif

View File

@ -39,6 +39,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 */
@ -141,10 +142,14 @@ int main( void )
" force_ciphersuite=<name> default: all enabled\n"\ " force_ciphersuite=<name> default: all enabled\n"\
" acceptable ciphersuite names:\n" " acceptable ciphersuite names:\n"
#if defined( MBEDTLS_CHECK_PARAMS ) && defined(MBEDTLS_PLATFORM_C) #if defined(MBEDTLS_CHECK_PARAMS)
void mbedtls_param_failed( char* failure_condition, char* file, int line ) #include "mbedtls/platform_util.h"
void mbedtls_param_failed( const char *failure_condition,
const char *file,
int line )
{ {
mbedtls_printf("%s:%i: Input param failed - %sn", file, line, failure_condition ); mbedtls_printf( "%s:%i: Input param failed - %s\n",
file, line, failure_condition );
mbedtls_exit( MBEDTLS_EXIT_FAILURE ); mbedtls_exit( MBEDTLS_EXIT_FAILURE );
} }
#endif #endif

View File

@ -30,9 +30,13 @@
#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
#define MBEDTLS_EXIT_SUCCESS EXIT_SUCCESS
#define MBEDTLS_EXIT_FAILURE EXIT_FAILURE
#endif #endif
#if !defined(MBEDTLS_BIGNUM_C) || !defined(MBEDTLS_CERTS_C) || \ #if !defined(MBEDTLS_BIGNUM_C) || !defined(MBEDTLS_CERTS_C) || \
@ -77,6 +81,18 @@ int main( void )
#include "mbedtls/memory_buffer_alloc.h" #include "mbedtls/memory_buffer_alloc.h"
#endif #endif
#if defined(MBEDTLS_CHECK_PARAMS)
#include "mbedtls/platform_util.h"
void mbedtls_param_failed( const char *failure_condition,
const char *file,
int line )
{
mbedtls_printf( "%s:%i: Input param failed - %s\n",
file, line, failure_condition );
mbedtls_exit( MBEDTLS_EXIT_FAILURE );
}
#endif
#define HTTP_RESPONSE \ #define HTTP_RESPONSE \
"HTTP/1.0 200 OK\r\nContent-Type: text/html\r\n\r\n" \ "HTTP/1.0 200 OK\r\nContent-Type: text/html\r\n\r\n" \
"<h2>mbed TLS Test Server</h2>\r\n" \ "<h2>mbed TLS Test Server</h2>\r\n" \

View File

@ -34,6 +34,9 @@
#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_FAILURE EXIT_FAILURE
#endif #endif
#if !defined(MBEDTLS_BIGNUM_C) || !defined(MBEDTLS_CERTS_C) || \ #if !defined(MBEDTLS_BIGNUM_C) || !defined(MBEDTLS_CERTS_C) || \
@ -80,10 +83,14 @@ int main( void )
#define DEBUG_LEVEL 0 #define DEBUG_LEVEL 0
#if defined( MBEDTLS_CHECK_PARAMS ) && defined(MBEDTLS_PLATFORM_C) #if defined(MBEDTLS_CHECK_PARAMS)
void mbedtls_param_failed( char* failure_condition, char* file, int line ) #include "mbedtls/platform_util.h"
void mbedtls_param_failed( const char *failure_condition,
const char *file,
int line )
{ {
mbedtls_printf("%s:%i: Input param failed - %sn", file, line, failure_condition ); mbedtls_printf( "%s:%i: Input param failed - %s\n",
file, line, failure_condition );
mbedtls_exit( MBEDTLS_EXIT_FAILURE ); mbedtls_exit( MBEDTLS_EXIT_FAILURE );
} }
#endif #endif

View File

@ -36,6 +36,9 @@
#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
#define MBEDTLS_EXIT_SUCCESS EXIT_SUCCESS
#define MBEDTLS_EXIT_FAILURE EXIT_FAILURE
#endif #endif
#if !defined(MBEDTLS_ENTROPY_C) || \ #if !defined(MBEDTLS_ENTROPY_C) || \
@ -426,10 +429,14 @@ int main( void )
(out_be)[(i) + 7] = (unsigned char)( ( (in_le) >> 0 ) & 0xFF ); \ (out_be)[(i) + 7] = (unsigned char)( ( (in_le) >> 0 ) & 0xFF ); \
} }
#if defined( MBEDTLS_CHECK_PARAMS ) && defined(MBEDTLS_PLATFORM_C) #if defined(MBEDTLS_CHECK_PARAMS)
void mbedtls_param_failed( char* failure_condition, char* file, int line ) #include "mbedtls/platform_util.h"
void mbedtls_param_failed( const char *failure_condition,
const char *file,
int line )
{ {
mbedtls_printf("%s:%i: Input param failed - %sn", file, line, failure_condition ); mbedtls_printf( "%s:%i: Input param failed - %s\n",
file, line, failure_condition );
mbedtls_exit( MBEDTLS_EXIT_FAILURE ); mbedtls_exit( MBEDTLS_EXIT_FAILURE );
} }
#endif #endif

View File

@ -29,10 +29,14 @@
#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
#define mbedtls_free free #define mbedtls_free free
#define mbedtls_exit exit
#define MBEDTLS_EXIT_SUCCESS EXIT_SUCCESS
#define MBEDTLS_EXIT_FAILURE EXIT_FAILURE
#endif #endif
#if !defined(MBEDTLS_TIMING_C) #if !defined(MBEDTLS_TIMING_C)
@ -254,10 +258,14 @@ typedef struct {
rsa, dhm, ecdsa, ecdh; rsa, dhm, ecdsa, ecdh;
} todo_list; } todo_list;
#if defined( MBEDTLS_CHECK_PARAMS ) && defined(MBEDTLS_PLATFORM_C) #if defined(MBEDTLS_CHECK_PARAMS)
void mbedtls_param_failed( char* failure_condition, char* file, int line ) #include "mbedtls/platform_util.h"
void mbedtls_param_failed( const char *failure_condition,
const char *file,
int line )
{ {
mbedtls_printf("%s:%i: Input param failed - %sn", file, line, failure_condition ); mbedtls_printf( "%s:%i: Input param failed - %s\n",
file, line, failure_condition );
mbedtls_exit( MBEDTLS_EXIT_FAILURE ); mbedtls_exit( MBEDTLS_EXIT_FAILURE );
} }
#endif #endif

View File

@ -77,10 +77,14 @@
#include "mbedtls/memory_buffer_alloc.h" #include "mbedtls/memory_buffer_alloc.h"
#endif #endif
#if defined( MBEDTLS_CHECK_PARAMS ) && defined(MBEDTLS_PLATFORM_C) #if defined(MBEDTLS_CHECK_PARAMS)
void mbedtls_param_failed( char* failure_condition, char* file, int line ) #include "mbedtls/platform_util.h"
void mbedtls_param_failed( const char *failure_condition,
const char *file,
int line )
{ {
mbedtls_printf("%s:%i: Input param failed - %sn", file, line, failure_condition ); mbedtls_printf( "%s:%i: Input param failed - %s\n",
file, line, failure_condition );
mbedtls_exit( MBEDTLS_EXIT_FAILURE ); mbedtls_exit( MBEDTLS_EXIT_FAILURE );
} }
#endif #endif

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 */
@ -81,10 +82,14 @@ const char *client_private_keys[MAX_CLIENT_CERTS] =
"cert_digest.key" "cert_digest.key"
}; };
#if defined( MBEDTLS_CHECK_PARAMS ) && defined(MBEDTLS_PLATFORM_C) #if defined(MBEDTLS_CHECK_PARAMS)
void mbedtls_param_failed( char* failure_condition, char* file, int line ) #include "mbedtls/platform_util.h"
void mbedtls_param_failed( const char *failure_condition,
const char *file,
int line )
{ {
mbedtls_printf("%s:%i: Input param failed - %sn", file, line, failure_condition ); mbedtls_printf( "%s:%i: Input param failed - %s\n",
file, line, failure_condition );
mbedtls_exit( MBEDTLS_EXIT_FAILURE ); mbedtls_exit( MBEDTLS_EXIT_FAILURE );
} }
#endif #endif

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 */
@ -63,6 +64,19 @@ int main( void )
return( 0 ); return( 0 );
} }
#else #else
#if defined(MBEDTLS_CHECK_PARAMS)
#define mbedtls_exit exit
void mbedtls_param_failed( const char *failure_condition,
const char *file,
int line )
{
mbedtls_printf( "%s:%i: Input param failed - %s\n",
file, line, failure_condition );
mbedtls_exit( MBEDTLS_EXIT_FAILURE );
}
#endif
/* /*
* global options * global options
*/ */

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 */
@ -99,10 +100,14 @@ int main( void )
" permissive=%%d default: 0 (disabled)\n" \ " permissive=%%d default: 0 (disabled)\n" \
"\n" "\n"
#if defined( MBEDTLS_CHECK_PARAMS ) && defined(MBEDTLS_PLATFORM_C) #if defined(MBEDTLS_CHECK_PARAMS)
void mbedtls_param_failed( char* failure_condition, char* file, int line ) #define mbedtls_exit exit
void mbedtls_param_failed( const char *failure_condition,
const char *file,
int line )
{ {
mbedtls_printf("%s:%i: Input param failed - %sn", file, line, failure_condition ); mbedtls_printf( "%s:%i: Input param failed - %s\n",
file, line, failure_condition );
mbedtls_exit( MBEDTLS_EXIT_FAILURE ); mbedtls_exit( MBEDTLS_EXIT_FAILURE );
} }
#endif #endif

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 */
@ -100,10 +101,13 @@ int main( void )
" SHA384, SHA512\n" \ " SHA384, SHA512\n" \
"\n" "\n"
#if defined( MBEDTLS_CHECK_PARAMS ) && defined(MBEDTLS_PLATFORM_C) #if defined(MBEDTLS_CHECK_PARAMS)
void mbedtls_param_failed( char* failure_condition, char* file, int line ) void mbedtls_param_failed( const char *failure_condition,
const char *file,
int line )
{ {
mbedtls_printf("%s:%i: Input param failed - %sn", file, line, failure_condition ); mbedtls_printf( "%s:%i: Input param failed - %s\n",
file, line, failure_condition );
mbedtls_exit( MBEDTLS_EXIT_FAILURE ); mbedtls_exit( MBEDTLS_EXIT_FAILURE );
} }
#endif #endif

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 */
@ -153,10 +154,14 @@ int main( void )
" object_signing_ca\n" \ " object_signing_ca\n" \
"\n" "\n"
#if defined( MBEDTLS_CHECK_PARAMS ) && defined(MBEDTLS_PLATFORM_C) #if defined(MBEDTLS_CHECK_PARAMS)
void mbedtls_param_failed( char* failure_condition, char* file, int line ) #define mbedtls_exit exit
void mbedtls_param_failed( const char *failure_condition,
const char *file,
int line )
{ {
mbedtls_printf("%s:%i: Input param failed - %sn", file, line, failure_condition ); mbedtls_printf( "%s:%i: Input param failed - %s\n",
file, line, failure_condition );
mbedtls_exit( MBEDTLS_EXIT_FAILURE ); mbedtls_exit( MBEDTLS_EXIT_FAILURE );
} }
#endif #endif

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 */
@ -60,10 +61,14 @@ int main( void )
" filename=%%s default: crl.pem\n" \ " filename=%%s default: crl.pem\n" \
"\n" "\n"
#if defined( MBEDTLS_CHECK_PARAMS ) && defined(MBEDTLS_PLATFORM_C) #if defined(MBEDTLS_CHECK_PARAMS)
void mbedtls_param_failed( char* failure_condition, char* file, int line ) #define mbedtls_exit exit
void mbedtls_param_failed( const char *failure_condition,
const char *file,
int line )
{ {
mbedtls_printf("%s:%i: Input param failed - %sn", file, line, failure_condition ); mbedtls_printf( "%s:%i: Input param failed - %s\n",
file, line, failure_condition );
mbedtls_exit( MBEDTLS_EXIT_FAILURE ); mbedtls_exit( MBEDTLS_EXIT_FAILURE );
} }
#endif #endif

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 */
@ -60,10 +61,14 @@ int main( void )
" filename=%%s default: cert.req\n" \ " filename=%%s default: cert.req\n" \
"\n" "\n"
#if defined( MBEDTLS_CHECK_PARAMS ) && defined(MBEDTLS_PLATFORM_C) #if defined(MBEDTLS_CHECK_PARAMS)
void mbedtls_param_failed( char* failure_condition, char* file, int line ) #define mbedtls_exit exit
void mbedtls_param_failed( const char *failure_condition,
const char *file,
int line )
{ {
mbedtls_printf("%s:%i: Input param failed - %sn", file, line, failure_condition ); mbedtls_printf( "%s:%i: Input param failed - %s\n",
file, line, failure_condition );
mbedtls_exit( MBEDTLS_EXIT_FAILURE ); mbedtls_exit( MBEDTLS_EXIT_FAILURE );
} }
#endif #endif

View File

@ -287,7 +287,9 @@ static void platform_teardown()
} }
#if defined(MBEDTLS_CHECK_PARAMS) #if defined(MBEDTLS_CHECK_PARAMS)
void mbedtls_param_failed( char* failure_condition, char* file, int line ) void mbedtls_param_failed( const char *failure_condition,
const char *file,
int line )
{ {
/* If we are testing the callback function... */ /* If we are testing the callback function... */
if ( test_info.paramfail_test_state == PARAMFAIL_TESTSTATE_PENDING ) if ( test_info.paramfail_test_state == PARAMFAIL_TESTSTATE_PENDING )