31 #ifndef MBEDTLS_PLATFORM_H
32 #define MBEDTLS_PLATFORM_H
37 #if defined(MBEDTLS_HAVE_TIME)
57 #if defined(__MINGW32__) || (defined(_MSC_VER) && _MSC_VER <= 1900)
58 #define MBEDTLS_PLATFORM_HAS_NON_CONFORMING_SNPRINTF
59 #define MBEDTLS_PLATFORM_HAS_NON_CONFORMING_VSNPRINTF
62 #if !defined(MBEDTLS_PLATFORM_NO_STD_FUNCTIONS)
66 #if !defined(MBEDTLS_PLATFORM_STD_SNPRINTF)
67 #if defined(MBEDTLS_PLATFORM_HAS_NON_CONFORMING_SNPRINTF)
68 #define MBEDTLS_PLATFORM_STD_SNPRINTF mbedtls_platform_win32_snprintf
70 #define MBEDTLS_PLATFORM_STD_SNPRINTF snprintf
73 #if !defined(MBEDTLS_PLATFORM_STD_VSNPRINTF)
74 #if defined(MBEDTLS_PLATFORM_HAS_NON_CONFORMING_VSNPRINTF)
75 #define MBEDTLS_PLATFORM_STD_VSNPRINTF mbedtls_platform_win32_vsnprintf
77 #define MBEDTLS_PLATFORM_STD_VSNPRINTF vsnprintf
80 #if !defined(MBEDTLS_PLATFORM_STD_PRINTF)
81 #define MBEDTLS_PLATFORM_STD_PRINTF printf
83 #if !defined(MBEDTLS_PLATFORM_STD_FPRINTF)
84 #define MBEDTLS_PLATFORM_STD_FPRINTF fprintf
86 #if !defined(MBEDTLS_PLATFORM_STD_CALLOC)
87 #define MBEDTLS_PLATFORM_STD_CALLOC calloc
89 #if !defined(MBEDTLS_PLATFORM_STD_FREE)
90 #define MBEDTLS_PLATFORM_STD_FREE free
92 #if !defined(MBEDTLS_PLATFORM_STD_EXIT)
93 #define MBEDTLS_PLATFORM_STD_EXIT exit
95 #if !defined(MBEDTLS_PLATFORM_STD_TIME)
96 #define MBEDTLS_PLATFORM_STD_TIME time
98 #if !defined(MBEDTLS_PLATFORM_STD_EXIT_SUCCESS)
99 #define MBEDTLS_PLATFORM_STD_EXIT_SUCCESS EXIT_SUCCESS
101 #if !defined(MBEDTLS_PLATFORM_STD_EXIT_FAILURE)
102 #define MBEDTLS_PLATFORM_STD_EXIT_FAILURE EXIT_FAILURE
104 #if defined(MBEDTLS_FS_IO)
105 #if !defined(MBEDTLS_PLATFORM_STD_NV_SEED_READ)
106 #define MBEDTLS_PLATFORM_STD_NV_SEED_READ mbedtls_platform_std_nv_seed_read
108 #if !defined(MBEDTLS_PLATFORM_STD_NV_SEED_WRITE)
109 #define MBEDTLS_PLATFORM_STD_NV_SEED_WRITE mbedtls_platform_std_nv_seed_write
111 #if !defined(MBEDTLS_PLATFORM_STD_NV_SEED_FILE)
112 #define MBEDTLS_PLATFORM_STD_NV_SEED_FILE "seedfile"
116 #if defined(MBEDTLS_PLATFORM_STD_MEM_HDR)
117 #include MBEDTLS_PLATFORM_STD_MEM_HDR
127 #if defined(MBEDTLS_PLATFORM_MEMORY)
128 #if defined(MBEDTLS_PLATFORM_FREE_MACRO) && \
129 defined(MBEDTLS_PLATFORM_CALLOC_MACRO)
130 #define mbedtls_free MBEDTLS_PLATFORM_FREE_MACRO
131 #define mbedtls_calloc MBEDTLS_PLATFORM_CALLOC_MACRO
148 void (*free_func)(
void * ) );
151 #define mbedtls_free free
152 #define mbedtls_calloc calloc
158 #if defined(MBEDTLS_PLATFORM_FPRINTF_ALT)
161 extern int (*
mbedtls_fprintf)( FILE *stream,
const char *format, ... );
175 #if defined(MBEDTLS_PLATFORM_FPRINTF_MACRO)
176 #define mbedtls_fprintf MBEDTLS_PLATFORM_FPRINTF_MACRO
178 #define mbedtls_fprintf fprintf
185 #if defined(MBEDTLS_PLATFORM_PRINTF_ALT)
199 #if defined(MBEDTLS_PLATFORM_PRINTF_MACRO)
200 #define mbedtls_printf MBEDTLS_PLATFORM_PRINTF_MACRO
202 #define mbedtls_printf printf
215 #if defined(MBEDTLS_PLATFORM_HAS_NON_CONFORMING_SNPRINTF)
217 int mbedtls_platform_win32_snprintf(
char *s,
size_t n,
const char *fmt, ... );
220 #if defined(MBEDTLS_PLATFORM_SNPRINTF_ALT)
221 extern int (*
mbedtls_snprintf)(
char * s,
size_t n,
const char * format, ... );
232 const char * format, ... ) );
234 #if defined(MBEDTLS_PLATFORM_SNPRINTF_MACRO)
235 #define mbedtls_snprintf MBEDTLS_PLATFORM_SNPRINTF_MACRO
237 #define mbedtls_snprintf MBEDTLS_PLATFORM_STD_SNPRINTF
250 #if defined(MBEDTLS_PLATFORM_HAS_NON_CONFORMING_VSNPRINTF)
253 int mbedtls_platform_win32_vsnprintf(
char *s,
size_t n,
const char *fmt, va_list arg );
256 #if defined(MBEDTLS_PLATFORM_VSNPRINTF_ALT)
258 extern int (*
mbedtls_vsnprintf)(
char * s,
size_t n,
const char * format, va_list arg );
268 const char * format, va_list arg ) );
270 #if defined(MBEDTLS_PLATFORM_VSNPRINTF_MACRO)
271 #define mbedtls_vsnprintf MBEDTLS_PLATFORM_VSNPRINTF_MACRO
273 #define mbedtls_vsnprintf vsnprintf
280 #if defined(MBEDTLS_PLATFORM_EXIT_ALT)
294 #if defined(MBEDTLS_PLATFORM_EXIT_MACRO)
295 #define mbedtls_exit MBEDTLS_PLATFORM_EXIT_MACRO
297 #define mbedtls_exit exit
304 #if defined(MBEDTLS_PLATFORM_STD_EXIT_SUCCESS)
305 #define MBEDTLS_EXIT_SUCCESS MBEDTLS_PLATFORM_STD_EXIT_SUCCESS
307 #define MBEDTLS_EXIT_SUCCESS 0
309 #if defined(MBEDTLS_PLATFORM_STD_EXIT_FAILURE)
310 #define MBEDTLS_EXIT_FAILURE MBEDTLS_PLATFORM_STD_EXIT_FAILURE
312 #define MBEDTLS_EXIT_FAILURE 1
321 #if defined(MBEDTLS_ENTROPY_NV_SEED)
322 #if !defined(MBEDTLS_PLATFORM_NO_STD_FUNCTIONS) && defined(MBEDTLS_FS_IO)
324 int mbedtls_platform_std_nv_seed_read(
unsigned char *buf,
size_t buf_len );
325 int mbedtls_platform_std_nv_seed_write(
unsigned char *buf,
size_t buf_len );
328 #if defined(MBEDTLS_PLATFORM_NV_SEED_ALT)
342 int (*nv_seed_read_func)(
unsigned char *buf,
size_t buf_len ),
343 int (*nv_seed_write_func)(
unsigned char *buf,
size_t buf_len )
346 #if defined(MBEDTLS_PLATFORM_NV_SEED_READ_MACRO) && \
347 defined(MBEDTLS_PLATFORM_NV_SEED_WRITE_MACRO)
348 #define mbedtls_nv_seed_read MBEDTLS_PLATFORM_NV_SEED_READ_MACRO
349 #define mbedtls_nv_seed_write MBEDTLS_PLATFORM_NV_SEED_WRITE_MACRO
351 #define mbedtls_nv_seed_read mbedtls_platform_std_nv_seed_read
352 #define mbedtls_nv_seed_write mbedtls_platform_std_nv_seed_write
357 #if !defined(MBEDTLS_PLATFORM_SETUP_TEARDOWN_ALT)
365 typedef struct mbedtls_platform_context
369 mbedtls_platform_context;
372 #include "platform_alt.h"
#define MBEDTLS_PRIVATE(member)
Macro wrapper for struct's memebrs.
Build-time configuration info.