33 #ifndef MBEDTLS_PLATFORM_H 34 #define MBEDTLS_PLATFORM_H 36 #if !defined(MBEDTLS_CONFIG_FILE) 37 #include "mbedtls/config.h" 39 #include MBEDTLS_CONFIG_FILE 42 #if defined(MBEDTLS_HAVE_TIME) 43 #include "mbedtls/platform_time.h" 46 #define MBEDTLS_ERR_PLATFORM_HW_ACCEL_FAILED -0x0070 47 #define MBEDTLS_ERR_PLATFORM_FEATURE_UNSUPPORTED -0x0072 65 #if defined(__MINGW32__) || (defined(_MSC_VER) && _MSC_VER <= 1900) 66 #define MBEDTLS_PLATFORM_HAS_NON_CONFORMING_SNPRINTF 67 #define MBEDTLS_PLATFORM_HAS_NON_CONFORMING_VSNPRINTF 70 #if !defined(MBEDTLS_PLATFORM_NO_STD_FUNCTIONS) 74 #if !defined(MBEDTLS_PLATFORM_STD_SNPRINTF) 75 #if defined(MBEDTLS_PLATFORM_HAS_NON_CONFORMING_SNPRINTF) 76 #define MBEDTLS_PLATFORM_STD_SNPRINTF mbedtls_platform_win32_snprintf 78 #define MBEDTLS_PLATFORM_STD_SNPRINTF snprintf 81 #if !defined(MBEDTLS_PLATFORM_STD_VSNPRINTF) 82 #if defined(MBEDTLS_PLATFORM_HAS_NON_CONFORMING_VSNPRINTF) 83 #define MBEDTLS_PLATFORM_STD_VSNPRINTF mbedtls_platform_win32_vsnprintf 85 #define MBEDTLS_PLATFORM_STD_VSNPRINTF vsnprintf 88 #if !defined(MBEDTLS_PLATFORM_STD_PRINTF) 89 #define MBEDTLS_PLATFORM_STD_PRINTF printf 91 #if !defined(MBEDTLS_PLATFORM_STD_FPRINTF) 92 #define MBEDTLS_PLATFORM_STD_FPRINTF fprintf 94 #if !defined(MBEDTLS_PLATFORM_STD_CALLOC) 95 #define MBEDTLS_PLATFORM_STD_CALLOC calloc 97 #if !defined(MBEDTLS_PLATFORM_STD_FREE) 98 #define MBEDTLS_PLATFORM_STD_FREE free 100 #if !defined(MBEDTLS_PLATFORM_STD_EXIT) 101 #define MBEDTLS_PLATFORM_STD_EXIT exit 103 #if !defined(MBEDTLS_PLATFORM_STD_TIME) 104 #define MBEDTLS_PLATFORM_STD_TIME time 106 #if !defined(MBEDTLS_PLATFORM_STD_EXIT_SUCCESS) 107 #define MBEDTLS_PLATFORM_STD_EXIT_SUCCESS EXIT_SUCCESS 109 #if !defined(MBEDTLS_PLATFORM_STD_EXIT_FAILURE) 110 #define MBEDTLS_PLATFORM_STD_EXIT_FAILURE EXIT_FAILURE 112 #if defined(MBEDTLS_FS_IO) 113 #if !defined(MBEDTLS_PLATFORM_STD_NV_SEED_READ) 114 #define MBEDTLS_PLATFORM_STD_NV_SEED_READ mbedtls_platform_std_nv_seed_read 116 #if !defined(MBEDTLS_PLATFORM_STD_NV_SEED_WRITE) 117 #define MBEDTLS_PLATFORM_STD_NV_SEED_WRITE mbedtls_platform_std_nv_seed_write 119 #if !defined(MBEDTLS_PLATFORM_STD_NV_SEED_FILE) 120 #define MBEDTLS_PLATFORM_STD_NV_SEED_FILE "seedfile" 124 #if defined(MBEDTLS_PLATFORM_STD_MEM_HDR) 125 #include MBEDTLS_PLATFORM_STD_MEM_HDR 135 #if defined(MBEDTLS_PLATFORM_MEMORY) 136 #if defined(MBEDTLS_PLATFORM_FREE_MACRO) && \ 137 defined(MBEDTLS_PLATFORM_CALLOC_MACRO) 138 #define mbedtls_free MBEDTLS_PLATFORM_FREE_MACRO 139 #define mbedtls_calloc MBEDTLS_PLATFORM_CALLOC_MACRO 143 extern void *mbedtls_calloc(
size_t n,
size_t size );
144 extern void mbedtls_free(
void *ptr );
155 int mbedtls_platform_set_calloc_free(
void * (*calloc_func)(
size_t,
size_t ),
156 void (*free_func)(
void * ) );
159 #define mbedtls_free free 160 #define mbedtls_calloc calloc 166 #if defined(MBEDTLS_PLATFORM_FPRINTF_ALT) 169 extern int (*mbedtls_fprintf)( FILE *stream,
const char *format, ... );
180 int mbedtls_platform_set_fprintf(
int (*fprintf_func)( FILE *stream,
const char *,
183 #if defined(MBEDTLS_PLATFORM_FPRINTF_MACRO) 184 #define mbedtls_fprintf MBEDTLS_PLATFORM_FPRINTF_MACRO 186 #define mbedtls_fprintf fprintf 193 #if defined(MBEDTLS_PLATFORM_PRINTF_ALT) 194 extern int (*mbedtls_printf)(
const char *format, ... );
205 int mbedtls_platform_set_printf(
int (*printf_func)(
const char *, ... ) );
207 #if defined(MBEDTLS_PLATFORM_PRINTF_MACRO) 208 #define mbedtls_printf MBEDTLS_PLATFORM_PRINTF_MACRO 210 #define mbedtls_printf printf 223 #if defined(MBEDTLS_PLATFORM_HAS_NON_CONFORMING_SNPRINTF) 225 int mbedtls_platform_win32_snprintf(
char *s,
size_t n,
const char *fmt, ... );
228 #if defined(MBEDTLS_PLATFORM_SNPRINTF_ALT) 229 extern int (*mbedtls_snprintf)(
char * s,
size_t n,
const char * format, ... );
239 int mbedtls_platform_set_snprintf(
int (*snprintf_func)(
char * s,
size_t n,
240 const char * format, ... ) );
242 #if defined(MBEDTLS_PLATFORM_SNPRINTF_MACRO) 243 #define mbedtls_snprintf MBEDTLS_PLATFORM_SNPRINTF_MACRO 245 #define mbedtls_snprintf MBEDTLS_PLATFORM_STD_SNPRINTF 258 #if defined(MBEDTLS_PLATFORM_HAS_NON_CONFORMING_VSNPRINTF) 261 int mbedtls_platform_win32_vsnprintf(
char *s,
size_t n,
const char *fmt, va_list arg );
264 #if defined(MBEDTLS_PLATFORM_VSNPRINTF_ALT) 266 extern int (*mbedtls_vsnprintf)(
char * s,
size_t n,
const char * format, va_list arg );
275 int mbedtls_platform_set_vsnprintf(
int (*vsnprintf_func)(
char * s,
size_t n,
276 const char * format, va_list arg ) );
278 #if defined(MBEDTLS_PLATFORM_VSNPRINTF_MACRO) 279 #define mbedtls_vsnprintf MBEDTLS_PLATFORM_VSNPRINTF_MACRO 281 #define mbedtls_vsnprintf vsnprintf 288 #if defined(MBEDTLS_PLATFORM_EXIT_ALT) 289 extern void (*mbedtls_exit)(
int status );
300 int mbedtls_platform_set_exit(
void (*exit_func)(
int status ) );
302 #if defined(MBEDTLS_PLATFORM_EXIT_MACRO) 303 #define mbedtls_exit MBEDTLS_PLATFORM_EXIT_MACRO 305 #define mbedtls_exit exit 312 #if defined(MBEDTLS_PLATFORM_STD_EXIT_SUCCESS) 313 #define MBEDTLS_EXIT_SUCCESS MBEDTLS_PLATFORM_STD_EXIT_SUCCESS 315 #define MBEDTLS_EXIT_SUCCESS 0 317 #if defined(MBEDTLS_PLATFORM_STD_EXIT_FAILURE) 318 #define MBEDTLS_EXIT_FAILURE MBEDTLS_PLATFORM_STD_EXIT_FAILURE 320 #define MBEDTLS_EXIT_FAILURE 1 329 #if defined(MBEDTLS_ENTROPY_NV_SEED) 330 #if !defined(MBEDTLS_PLATFORM_NO_STD_FUNCTIONS) && defined(MBEDTLS_FS_IO) 332 int mbedtls_platform_std_nv_seed_read(
unsigned char *buf,
size_t buf_len );
333 int mbedtls_platform_std_nv_seed_write(
unsigned char *buf,
size_t buf_len );
336 #if defined(MBEDTLS_PLATFORM_NV_SEED_ALT) 337 extern int (*mbedtls_nv_seed_read)(
unsigned char *buf,
size_t buf_len );
338 extern int (*mbedtls_nv_seed_write)(
unsigned char *buf,
size_t buf_len );
349 int mbedtls_platform_set_nv_seed(
350 int (*nv_seed_read_func)(
unsigned char *buf,
size_t buf_len ),
351 int (*nv_seed_write_func)(
unsigned char *buf,
size_t buf_len )
354 #if defined(MBEDTLS_PLATFORM_NV_SEED_READ_MACRO) && \ 355 defined(MBEDTLS_PLATFORM_NV_SEED_WRITE_MACRO) 356 #define mbedtls_nv_seed_read MBEDTLS_PLATFORM_NV_SEED_READ_MACRO 357 #define mbedtls_nv_seed_write MBEDTLS_PLATFORM_NV_SEED_WRITE_MACRO 359 #define mbedtls_nv_seed_read mbedtls_platform_std_nv_seed_read 360 #define mbedtls_nv_seed_write mbedtls_platform_std_nv_seed_write 365 #if !defined(MBEDTLS_PLATFORM_SETUP_TEARDOWN_ALT) 380 #include "platform_alt.h"
The platform context structure.
Definition: platform.h:373
char dummy
A placeholder member, as empty structs are not portable.
Definition: platform.h:375