psa: Fix builds without MBEDTLS_PLATFORM_C

When `MBEDTLS_PLATFORM_C` is not enabled, our PSA Crypto implementation
depends on the standard C library for functions like snprintf() and
exit(). However, our implementation was not including the proper header
files nor redefining all `mbedtls_*` symbols properly to ensure
successful builds without MBEDTLS_PLATFORM_C. Add the necessary header
files and macro definitions to our PSA Crypto implementation.
This commit is contained in:
Jaeden Amero 2019-02-12 16:40:27 +00:00
parent 44a59ab3f5
commit db29ab528a
4 changed files with 6 additions and 0 deletions

View file

@ -38,6 +38,7 @@
#if defined(MBEDTLS_PLATFORM_C)
#include "mbedtls/platform.h"
#else
#include <stdlib.h>
#define mbedtls_calloc calloc
#define mbedtls_free free
#endif

View file

@ -36,6 +36,7 @@
#if defined(MBEDTLS_PLATFORM_C)
#include "mbedtls/platform.h"
#else
#include <stdio.h>
#define mbedtls_snprintf snprintf
#endif

View file

@ -5,7 +5,10 @@
#include "mbedtls/platform.h"
#else
#include <stdio.h>
#include <stdlib.h>
#define MBEDTLS_EXIT_FAILURE EXIT_FAILURE
#define mbedtls_printf printf
#define mbedtls_exit exit
#endif
#define ASSERT( predicate ) \

View file

@ -66,6 +66,7 @@
#define mbedtls_calloc calloc
#define mbedtls_free free
#define mbedtls_printf printf
#define mbedtls_exit exit
#endif
#include <stdio.h>
#include <string.h>