Skip to content

Commit 44a59ab

Browse files
committed
psa: Enable use of PSA examples with CHECK_PARAMS
When MBEDTLS_CHECK_PARAMS is enabled, it's required to have an implementation of mbedtls_param_failed() present. Without it in the PSA examples, building the PSA examples will result in linker errors like the following. ../../library/libmbedcrypto.a(rsa.c.o): In function `mbedtls_rsa_import': rsa.c:(.text+0x9fd): undefined reference to `mbedtls_param_failed' ../../library/libmbedcrypto.a(rsa.c.o): In function `mbedtls_rsa_import_raw': rsa.c:(.text+0xb0b): undefined reference to `mbedtls_param_failed' ../../library/libmbedcrypto.a(rsa.c.o): In function `mbedtls_rsa_complete': rsa.c:(.text+0xe63): undefined reference to `mbedtls_param_failed' ../../library/libmbedcrypto.a(rsa.c.o): In function `mbedtls_rsa_export_raw': rsa.c:(.text+0xfee): undefined reference to `mbedtls_param_failed' ../../library/libmbedcrypto.a(rsa.c.o): In function `mbedtls_rsa_export': rsa.c:(.text+0x116f): undefined reference to `mbedtls_param_failed' ../../library/libmbedcrypto.a(rsa.c.o):rsa.c:(.text+0x1304): more undefined references to `mbedtls_param_failed' follow collect2: error: ld returned 1 exit status programs/psa/CMakeFiles/crypto_examples.dir/build.make:97: recipe for target 'programs/psa/crypto_examples' failed make[2]: *** [programs/psa/crypto_examples] Error 1 Add an implementation of mbedtls_param_failed() to the PSA Crypto examples to avoid getting this error on the PSA examples.
1 parent 892cd6d commit 44a59ab

File tree

2 files changed

+24
-0
lines changed

2 files changed

+24
-0
lines changed

programs/psa/crypto_examples.c

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -324,6 +324,18 @@ static void cipher_examples( void )
324324
mbedtls_printf( "\tsuccess!\r\n" );
325325
}
326326

327+
#if defined(MBEDTLS_CHECK_PARAMS)
328+
#include "mbedtls/platform_util.h"
329+
void mbedtls_param_failed( const char *failure_condition,
330+
const char *file,
331+
int line )
332+
{
333+
mbedtls_printf( "%s:%i: Input param failed - %s\n",
334+
file, line, failure_condition );
335+
mbedtls_exit( MBEDTLS_EXIT_FAILURE );
336+
}
337+
#endif
338+
327339
int main( void )
328340
{
329341
ASSERT( psa_crypto_init( ) == PSA_SUCCESS );

programs/psa/key_ladder_demo.c

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -618,6 +618,18 @@ static void usage( void )
618618
mbedtls_printf( " and the same sequence of labels.\n" );
619619
}
620620

621+
#if defined(MBEDTLS_CHECK_PARAMS)
622+
#include "mbedtls/platform_util.h"
623+
void mbedtls_param_failed( const char *failure_condition,
624+
const char *file,
625+
int line )
626+
{
627+
mbedtls_printf( "%s:%i: Input param failed - %s\n",
628+
file, line, failure_condition );
629+
mbedtls_exit( MBEDTLS_EXIT_FAILURE );
630+
}
631+
#endif
632+
621633
int main( int argc, char *argv[] )
622634
{
623635
const char *key_file_name = "master.key";

0 commit comments

Comments
 (0)