33 #ifndef MBEDTLS_PLATFORM_H 34 #define MBEDTLS_PLATFORM_H 36 #if !defined(MBEDTLS_CONFIG_FILE) 39 #include MBEDTLS_CONFIG_FILE 42 #if defined(MBEDTLS_HAVE_TIME) 46 #define MBEDTLS_ERR_PLATFORM_HW_ACCEL_FAILED -0x0070 47 #define MBEDTLS_ERR_PLATFORM_FEATURE_UNSUPPORTED -0x0072 61 #if !defined(MBEDTLS_PLATFORM_NO_STD_FUNCTIONS) 65 #if !defined(MBEDTLS_PLATFORM_STD_SNPRINTF) 67 #define MBEDTLS_PLATFORM_STD_SNPRINTF mbedtls_platform_win32_snprintf 69 #define MBEDTLS_PLATFORM_STD_SNPRINTF snprintf 72 #if !defined(MBEDTLS_PLATFORM_STD_PRINTF) 73 #define MBEDTLS_PLATFORM_STD_PRINTF printf 75 #if !defined(MBEDTLS_PLATFORM_STD_FPRINTF) 76 #define MBEDTLS_PLATFORM_STD_FPRINTF fprintf 78 #if !defined(MBEDTLS_PLATFORM_STD_CALLOC) 79 #define MBEDTLS_PLATFORM_STD_CALLOC calloc 81 #if !defined(MBEDTLS_PLATFORM_STD_FREE) 82 #define MBEDTLS_PLATFORM_STD_FREE free 84 #if !defined(MBEDTLS_PLATFORM_STD_EXIT) 85 #define MBEDTLS_PLATFORM_STD_EXIT exit 87 #if !defined(MBEDTLS_PLATFORM_STD_TIME) 88 #define MBEDTLS_PLATFORM_STD_TIME time 90 #if !defined(MBEDTLS_PLATFORM_STD_EXIT_SUCCESS) 91 #define MBEDTLS_PLATFORM_STD_EXIT_SUCCESS EXIT_SUCCESS 93 #if !defined(MBEDTLS_PLATFORM_STD_EXIT_FAILURE) 94 #define MBEDTLS_PLATFORM_STD_EXIT_FAILURE EXIT_FAILURE 96 #if defined(MBEDTLS_FS_IO) 97 #if !defined(MBEDTLS_PLATFORM_STD_NV_SEED_READ) 98 #define MBEDTLS_PLATFORM_STD_NV_SEED_READ mbedtls_platform_std_nv_seed_read 100 #if !defined(MBEDTLS_PLATFORM_STD_NV_SEED_WRITE) 101 #define MBEDTLS_PLATFORM_STD_NV_SEED_WRITE mbedtls_platform_std_nv_seed_write 103 #if !defined(MBEDTLS_PLATFORM_STD_NV_SEED_FILE) 104 #define MBEDTLS_PLATFORM_STD_NV_SEED_FILE "seedfile" 108 #if defined(MBEDTLS_PLATFORM_STD_MEM_HDR) 109 #include MBEDTLS_PLATFORM_STD_MEM_HDR 119 #if defined(MBEDTLS_PLATFORM_MEMORY) 120 #if defined(MBEDTLS_PLATFORM_FREE_MACRO) && \ 121 defined(MBEDTLS_PLATFORM_CALLOC_MACRO) 122 #define mbedtls_free MBEDTLS_PLATFORM_FREE_MACRO 123 #define mbedtls_calloc MBEDTLS_PLATFORM_CALLOC_MACRO 139 int mbedtls_platform_set_calloc_free(
void * (*calloc_func)(
size_t,
size_t ),
140 void (*free_func)(
void * ) );
143 #define mbedtls_free free 144 #define mbedtls_calloc calloc 150 #if defined(MBEDTLS_PLATFORM_FPRINTF_ALT) 153 extern int (*
mbedtls_fprintf)( FILE *stream,
const char *format, ... );
164 int mbedtls_platform_set_fprintf(
int (*fprintf_func)( FILE *stream,
const char *,
167 #if defined(MBEDTLS_PLATFORM_FPRINTF_MACRO) 168 #define mbedtls_fprintf MBEDTLS_PLATFORM_FPRINTF_MACRO 170 #define mbedtls_fprintf fprintf 177 #if defined(MBEDTLS_PLATFORM_PRINTF_ALT) 189 int mbedtls_platform_set_printf(
int (*printf_func)(
const char *, ... ) );
191 #if defined(MBEDTLS_PLATFORM_PRINTF_MACRO) 192 #define mbedtls_printf MBEDTLS_PLATFORM_PRINTF_MACRO 194 #define mbedtls_printf printf 209 int mbedtls_platform_win32_snprintf(
char *s,
size_t n,
const char *fmt, ... );
212 #if defined(MBEDTLS_PLATFORM_SNPRINTF_ALT) 213 extern int (*
mbedtls_snprintf)(
char * s,
size_t n,
const char * format, ... );
223 int mbedtls_platform_set_snprintf(
int (*snprintf_func)(
char * s,
size_t n,
224 const char * format, ... ) );
226 #if defined(MBEDTLS_PLATFORM_SNPRINTF_MACRO) 227 #define mbedtls_snprintf MBEDTLS_PLATFORM_SNPRINTF_MACRO 229 #define mbedtls_snprintf MBEDTLS_PLATFORM_STD_SNPRINTF 236 #if defined(MBEDTLS_PLATFORM_EXIT_ALT) 248 int mbedtls_platform_set_exit(
void (*exit_func)(
int status ) );
250 #if defined(MBEDTLS_PLATFORM_EXIT_MACRO) 251 #define mbedtls_exit MBEDTLS_PLATFORM_EXIT_MACRO 253 #define mbedtls_exit exit 260 #if defined(MBEDTLS_PLATFORM_STD_EXIT_SUCCESS) 261 #define MBEDTLS_EXIT_SUCCESS MBEDTLS_PLATFORM_STD_EXIT_SUCCESS 263 #define MBEDTLS_EXIT_SUCCESS 0 265 #if defined(MBEDTLS_PLATFORM_STD_EXIT_FAILURE) 266 #define MBEDTLS_EXIT_FAILURE MBEDTLS_PLATFORM_STD_EXIT_FAILURE 268 #define MBEDTLS_EXIT_FAILURE 1 277 #if defined(MBEDTLS_ENTROPY_NV_SEED) 278 #if !defined(MBEDTLS_PLATFORM_NO_STD_FUNCTIONS) && defined(MBEDTLS_FS_IO) 280 int mbedtls_platform_std_nv_seed_read(
unsigned char *buf,
size_t buf_len );
281 int mbedtls_platform_std_nv_seed_write(
unsigned char *buf,
size_t buf_len );
284 #if defined(MBEDTLS_PLATFORM_NV_SEED_ALT) 285 extern int (*mbedtls_nv_seed_read)(
unsigned char *buf,
size_t buf_len );
286 extern int (*mbedtls_nv_seed_write)(
unsigned char *buf,
size_t buf_len );
297 int mbedtls_platform_set_nv_seed(
298 int (*nv_seed_read_func)(
unsigned char *buf,
size_t buf_len ),
299 int (*nv_seed_write_func)(
unsigned char *buf,
size_t buf_len )
302 #if defined(MBEDTLS_PLATFORM_NV_SEED_READ_MACRO) && \ 303 defined(MBEDTLS_PLATFORM_NV_SEED_WRITE_MACRO) 304 #define mbedtls_nv_seed_read MBEDTLS_PLATFORM_NV_SEED_READ_MACRO 305 #define mbedtls_nv_seed_write MBEDTLS_PLATFORM_NV_SEED_WRITE_MACRO 307 #define mbedtls_nv_seed_read mbedtls_platform_std_nv_seed_read 308 #define mbedtls_nv_seed_write mbedtls_platform_std_nv_seed_write 313 #if !defined(MBEDTLS_PLATFORM_SETUP_TEARDOWN_ALT) 328 #include "platform_alt.h" char dummy
Definition: platform.h:323
Configuration options (set of defines)
The platform context structure.
Definition: platform.h:321