mbed TLS Build
include/mbedtls/platform.h@0:cdf462088d13, 2017-01-05 (annotated)
- Committer:
- markrad
- Date:
- Thu Jan 05 00:18:44 2017 +0000
- Revision:
- 0:cdf462088d13
Initial commit
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
markrad | 0:cdf462088d13 | 1 | /** |
markrad | 0:cdf462088d13 | 2 | * \file platform.h |
markrad | 0:cdf462088d13 | 3 | * |
markrad | 0:cdf462088d13 | 4 | * \brief mbed TLS Platform abstraction layer |
markrad | 0:cdf462088d13 | 5 | * |
markrad | 0:cdf462088d13 | 6 | * Copyright (C) 2006-2016, ARM Limited, All Rights Reserved |
markrad | 0:cdf462088d13 | 7 | * SPDX-License-Identifier: Apache-2.0 |
markrad | 0:cdf462088d13 | 8 | * |
markrad | 0:cdf462088d13 | 9 | * Licensed under the Apache License, Version 2.0 (the "License"); you may |
markrad | 0:cdf462088d13 | 10 | * not use this file except in compliance with the License. |
markrad | 0:cdf462088d13 | 11 | * You may obtain a copy of the License at |
markrad | 0:cdf462088d13 | 12 | * |
markrad | 0:cdf462088d13 | 13 | * http://www.apache.org/licenses/LICENSE-2.0 |
markrad | 0:cdf462088d13 | 14 | * |
markrad | 0:cdf462088d13 | 15 | * Unless required by applicable law or agreed to in writing, software |
markrad | 0:cdf462088d13 | 16 | * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT |
markrad | 0:cdf462088d13 | 17 | * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
markrad | 0:cdf462088d13 | 18 | * See the License for the specific language governing permissions and |
markrad | 0:cdf462088d13 | 19 | * limitations under the License. |
markrad | 0:cdf462088d13 | 20 | * |
markrad | 0:cdf462088d13 | 21 | * This file is part of mbed TLS (https://tls.mbed.org) |
markrad | 0:cdf462088d13 | 22 | */ |
markrad | 0:cdf462088d13 | 23 | #ifndef MBEDTLS_PLATFORM_H |
markrad | 0:cdf462088d13 | 24 | #define MBEDTLS_PLATFORM_H |
markrad | 0:cdf462088d13 | 25 | |
markrad | 0:cdf462088d13 | 26 | #if !defined(MBEDTLS_CONFIG_FILE) |
markrad | 0:cdf462088d13 | 27 | #include "config.h" |
markrad | 0:cdf462088d13 | 28 | #else |
markrad | 0:cdf462088d13 | 29 | #include MBEDTLS_CONFIG_FILE |
markrad | 0:cdf462088d13 | 30 | #endif |
markrad | 0:cdf462088d13 | 31 | |
markrad | 0:cdf462088d13 | 32 | #if defined(MBEDTLS_HAVE_TIME) |
markrad | 0:cdf462088d13 | 33 | #include "mbedtls/platform_time.h" |
markrad | 0:cdf462088d13 | 34 | #endif |
markrad | 0:cdf462088d13 | 35 | |
markrad | 0:cdf462088d13 | 36 | #ifdef __cplusplus |
markrad | 0:cdf462088d13 | 37 | extern "C" { |
markrad | 0:cdf462088d13 | 38 | #endif |
markrad | 0:cdf462088d13 | 39 | |
markrad | 0:cdf462088d13 | 40 | /** |
markrad | 0:cdf462088d13 | 41 | * \name SECTION: Module settings |
markrad | 0:cdf462088d13 | 42 | * |
markrad | 0:cdf462088d13 | 43 | * The configuration options you can set for this module are in this section. |
markrad | 0:cdf462088d13 | 44 | * Either change them in config.h or define them on the compiler command line. |
markrad | 0:cdf462088d13 | 45 | * \{ |
markrad | 0:cdf462088d13 | 46 | */ |
markrad | 0:cdf462088d13 | 47 | |
markrad | 0:cdf462088d13 | 48 | #if !defined(MBEDTLS_PLATFORM_NO_STD_FUNCTIONS) |
markrad | 0:cdf462088d13 | 49 | #include <stdio.h> |
markrad | 0:cdf462088d13 | 50 | #include <stdlib.h> |
markrad | 0:cdf462088d13 | 51 | #include <time.h> |
markrad | 0:cdf462088d13 | 52 | #if !defined(MBEDTLS_PLATFORM_STD_SNPRINTF) |
markrad | 0:cdf462088d13 | 53 | #if defined(_WIN32) |
markrad | 0:cdf462088d13 | 54 | #define MBEDTLS_PLATFORM_STD_SNPRINTF mbedtls_platform_win32_snprintf /**< Default snprintf to use */ |
markrad | 0:cdf462088d13 | 55 | #else |
markrad | 0:cdf462088d13 | 56 | #define MBEDTLS_PLATFORM_STD_SNPRINTF snprintf /**< Default snprintf to use */ |
markrad | 0:cdf462088d13 | 57 | #endif |
markrad | 0:cdf462088d13 | 58 | #endif |
markrad | 0:cdf462088d13 | 59 | #if !defined(MBEDTLS_PLATFORM_STD_PRINTF) |
markrad | 0:cdf462088d13 | 60 | #define MBEDTLS_PLATFORM_STD_PRINTF printf /**< Default printf to use */ |
markrad | 0:cdf462088d13 | 61 | #endif |
markrad | 0:cdf462088d13 | 62 | #if !defined(MBEDTLS_PLATFORM_STD_FPRINTF) |
markrad | 0:cdf462088d13 | 63 | #define MBEDTLS_PLATFORM_STD_FPRINTF fprintf /**< Default fprintf to use */ |
markrad | 0:cdf462088d13 | 64 | #endif |
markrad | 0:cdf462088d13 | 65 | #if !defined(MBEDTLS_PLATFORM_STD_CALLOC) |
markrad | 0:cdf462088d13 | 66 | #define MBEDTLS_PLATFORM_STD_CALLOC calloc /**< Default allocator to use */ |
markrad | 0:cdf462088d13 | 67 | #endif |
markrad | 0:cdf462088d13 | 68 | #if !defined(MBEDTLS_PLATFORM_STD_FREE) |
markrad | 0:cdf462088d13 | 69 | #define MBEDTLS_PLATFORM_STD_FREE free /**< Default free to use */ |
markrad | 0:cdf462088d13 | 70 | #endif |
markrad | 0:cdf462088d13 | 71 | #if !defined(MBEDTLS_PLATFORM_STD_EXIT) |
markrad | 0:cdf462088d13 | 72 | #define MBEDTLS_PLATFORM_STD_EXIT exit /**< Default exit to use */ |
markrad | 0:cdf462088d13 | 73 | #endif |
markrad | 0:cdf462088d13 | 74 | #if !defined(MBEDTLS_PLATFORM_STD_TIME) |
markrad | 0:cdf462088d13 | 75 | #define MBEDTLS_PLATFORM_STD_TIME time /**< Default time to use */ |
markrad | 0:cdf462088d13 | 76 | #endif |
markrad | 0:cdf462088d13 | 77 | #if !defined(MBEDTLS_PLATFORM_STD_EXIT_SUCCESS) |
markrad | 0:cdf462088d13 | 78 | #define MBEDTLS_PLATFORM_STD_EXIT_SUCCESS EXIT_SUCCESS /**< Default exit value to use */ |
markrad | 0:cdf462088d13 | 79 | #endif |
markrad | 0:cdf462088d13 | 80 | #if !defined(MBEDTLS_PLATFORM_STD_EXIT_FAILURE) |
markrad | 0:cdf462088d13 | 81 | #define MBEDTLS_PLATFORM_STD_EXIT_FAILURE EXIT_FAILURE /**< Default exit value to use */ |
markrad | 0:cdf462088d13 | 82 | #endif |
markrad | 0:cdf462088d13 | 83 | #if defined(MBEDTLS_FS_IO) |
markrad | 0:cdf462088d13 | 84 | #if !defined(MBEDTLS_PLATFORM_STD_NV_SEED_READ) |
markrad | 0:cdf462088d13 | 85 | #define MBEDTLS_PLATFORM_STD_NV_SEED_READ mbedtls_platform_std_nv_seed_read |
markrad | 0:cdf462088d13 | 86 | #endif |
markrad | 0:cdf462088d13 | 87 | #if !defined(MBEDTLS_PLATFORM_STD_NV_SEED_WRITE) |
markrad | 0:cdf462088d13 | 88 | #define MBEDTLS_PLATFORM_STD_NV_SEED_WRITE mbedtls_platform_std_nv_seed_write |
markrad | 0:cdf462088d13 | 89 | #endif |
markrad | 0:cdf462088d13 | 90 | #if !defined(MBEDTLS_PLATFORM_STD_NV_SEED_FILE) |
markrad | 0:cdf462088d13 | 91 | #define MBEDTLS_PLATFORM_STD_NV_SEED_FILE "seedfile" |
markrad | 0:cdf462088d13 | 92 | #endif |
markrad | 0:cdf462088d13 | 93 | #endif /* MBEDTLS_FS_IO */ |
markrad | 0:cdf462088d13 | 94 | #else /* MBEDTLS_PLATFORM_NO_STD_FUNCTIONS */ |
markrad | 0:cdf462088d13 | 95 | #if defined(MBEDTLS_PLATFORM_STD_MEM_HDR) |
markrad | 0:cdf462088d13 | 96 | #include MBEDTLS_PLATFORM_STD_MEM_HDR |
markrad | 0:cdf462088d13 | 97 | #endif |
markrad | 0:cdf462088d13 | 98 | #endif /* MBEDTLS_PLATFORM_NO_STD_FUNCTIONS */ |
markrad | 0:cdf462088d13 | 99 | |
markrad | 0:cdf462088d13 | 100 | |
markrad | 0:cdf462088d13 | 101 | /* \} name SECTION: Module settings */ |
markrad | 0:cdf462088d13 | 102 | |
markrad | 0:cdf462088d13 | 103 | /* |
markrad | 0:cdf462088d13 | 104 | * The function pointers for calloc and free |
markrad | 0:cdf462088d13 | 105 | */ |
markrad | 0:cdf462088d13 | 106 | #if defined(MBEDTLS_PLATFORM_MEMORY) |
markrad | 0:cdf462088d13 | 107 | #if defined(MBEDTLS_PLATFORM_FREE_MACRO) && \ |
markrad | 0:cdf462088d13 | 108 | defined(MBEDTLS_PLATFORM_CALLOC_MACRO) |
markrad | 0:cdf462088d13 | 109 | #define mbedtls_free MBEDTLS_PLATFORM_FREE_MACRO |
markrad | 0:cdf462088d13 | 110 | #define mbedtls_calloc MBEDTLS_PLATFORM_CALLOC_MACRO |
markrad | 0:cdf462088d13 | 111 | #else |
markrad | 0:cdf462088d13 | 112 | /* For size_t */ |
markrad | 0:cdf462088d13 | 113 | #include <stddef.h> |
markrad | 0:cdf462088d13 | 114 | extern void * (*mbedtls_calloc)( size_t n, size_t size ); |
markrad | 0:cdf462088d13 | 115 | extern void (*mbedtls_free)( void *ptr ); |
markrad | 0:cdf462088d13 | 116 | |
markrad | 0:cdf462088d13 | 117 | /** |
markrad | 0:cdf462088d13 | 118 | * \brief Set your own memory implementation function pointers |
markrad | 0:cdf462088d13 | 119 | * |
markrad | 0:cdf462088d13 | 120 | * \param calloc_func the calloc function implementation |
markrad | 0:cdf462088d13 | 121 | * \param free_func the free function implementation |
markrad | 0:cdf462088d13 | 122 | * |
markrad | 0:cdf462088d13 | 123 | * \return 0 if successful |
markrad | 0:cdf462088d13 | 124 | */ |
markrad | 0:cdf462088d13 | 125 | int mbedtls_platform_set_calloc_free( void * (*calloc_func)( size_t, size_t ), |
markrad | 0:cdf462088d13 | 126 | void (*free_func)( void * ) ); |
markrad | 0:cdf462088d13 | 127 | #endif /* MBEDTLS_PLATFORM_FREE_MACRO && MBEDTLS_PLATFORM_CALLOC_MACRO */ |
markrad | 0:cdf462088d13 | 128 | #else /* !MBEDTLS_PLATFORM_MEMORY */ |
markrad | 0:cdf462088d13 | 129 | #define mbedtls_free free |
markrad | 0:cdf462088d13 | 130 | #define mbedtls_calloc calloc |
markrad | 0:cdf462088d13 | 131 | #endif /* MBEDTLS_PLATFORM_MEMORY && !MBEDTLS_PLATFORM_{FREE,CALLOC}_MACRO */ |
markrad | 0:cdf462088d13 | 132 | |
markrad | 0:cdf462088d13 | 133 | /* |
markrad | 0:cdf462088d13 | 134 | * The function pointers for fprintf |
markrad | 0:cdf462088d13 | 135 | */ |
markrad | 0:cdf462088d13 | 136 | #if defined(MBEDTLS_PLATFORM_FPRINTF_ALT) |
markrad | 0:cdf462088d13 | 137 | /* We need FILE * */ |
markrad | 0:cdf462088d13 | 138 | #include <stdio.h> |
markrad | 0:cdf462088d13 | 139 | extern int (*mbedtls_fprintf)( FILE *stream, const char *format, ... ); |
markrad | 0:cdf462088d13 | 140 | |
markrad | 0:cdf462088d13 | 141 | /** |
markrad | 0:cdf462088d13 | 142 | * \brief Set your own fprintf function pointer |
markrad | 0:cdf462088d13 | 143 | * |
markrad | 0:cdf462088d13 | 144 | * \param fprintf_func the fprintf function implementation |
markrad | 0:cdf462088d13 | 145 | * |
markrad | 0:cdf462088d13 | 146 | * \return 0 |
markrad | 0:cdf462088d13 | 147 | */ |
markrad | 0:cdf462088d13 | 148 | int mbedtls_platform_set_fprintf( int (*fprintf_func)( FILE *stream, const char *, |
markrad | 0:cdf462088d13 | 149 | ... ) ); |
markrad | 0:cdf462088d13 | 150 | #else |
markrad | 0:cdf462088d13 | 151 | #if defined(MBEDTLS_PLATFORM_FPRINTF_MACRO) |
markrad | 0:cdf462088d13 | 152 | #define mbedtls_fprintf MBEDTLS_PLATFORM_FPRINTF_MACRO |
markrad | 0:cdf462088d13 | 153 | #else |
markrad | 0:cdf462088d13 | 154 | #define mbedtls_fprintf fprintf |
markrad | 0:cdf462088d13 | 155 | #endif /* MBEDTLS_PLATFORM_FPRINTF_MACRO */ |
markrad | 0:cdf462088d13 | 156 | #endif /* MBEDTLS_PLATFORM_FPRINTF_ALT */ |
markrad | 0:cdf462088d13 | 157 | |
markrad | 0:cdf462088d13 | 158 | /* |
markrad | 0:cdf462088d13 | 159 | * The function pointers for printf |
markrad | 0:cdf462088d13 | 160 | */ |
markrad | 0:cdf462088d13 | 161 | #if defined(MBEDTLS_PLATFORM_PRINTF_ALT) |
markrad | 0:cdf462088d13 | 162 | extern int (*mbedtls_printf)( const char *format, ... ); |
markrad | 0:cdf462088d13 | 163 | |
markrad | 0:cdf462088d13 | 164 | /** |
markrad | 0:cdf462088d13 | 165 | * \brief Set your own printf function pointer |
markrad | 0:cdf462088d13 | 166 | * |
markrad | 0:cdf462088d13 | 167 | * \param printf_func the printf function implementation |
markrad | 0:cdf462088d13 | 168 | * |
markrad | 0:cdf462088d13 | 169 | * \return 0 |
markrad | 0:cdf462088d13 | 170 | */ |
markrad | 0:cdf462088d13 | 171 | int mbedtls_platform_set_printf( int (*printf_func)( const char *, ... ) ); |
markrad | 0:cdf462088d13 | 172 | #else /* !MBEDTLS_PLATFORM_PRINTF_ALT */ |
markrad | 0:cdf462088d13 | 173 | #if defined(MBEDTLS_PLATFORM_PRINTF_MACRO) |
markrad | 0:cdf462088d13 | 174 | #define mbedtls_printf MBEDTLS_PLATFORM_PRINTF_MACRO |
markrad | 0:cdf462088d13 | 175 | #else |
markrad | 0:cdf462088d13 | 176 | #define mbedtls_printf printf |
markrad | 0:cdf462088d13 | 177 | #endif /* MBEDTLS_PLATFORM_PRINTF_MACRO */ |
markrad | 0:cdf462088d13 | 178 | #endif /* MBEDTLS_PLATFORM_PRINTF_ALT */ |
markrad | 0:cdf462088d13 | 179 | |
markrad | 0:cdf462088d13 | 180 | /* |
markrad | 0:cdf462088d13 | 181 | * The function pointers for snprintf |
markrad | 0:cdf462088d13 | 182 | * |
markrad | 0:cdf462088d13 | 183 | * The snprintf implementation should conform to C99: |
markrad | 0:cdf462088d13 | 184 | * - it *must* always correctly zero-terminate the buffer |
markrad | 0:cdf462088d13 | 185 | * (except when n == 0, then it must leave the buffer untouched) |
markrad | 0:cdf462088d13 | 186 | * - however it is acceptable to return -1 instead of the required length when |
markrad | 0:cdf462088d13 | 187 | * the destination buffer is too short. |
markrad | 0:cdf462088d13 | 188 | */ |
markrad | 0:cdf462088d13 | 189 | #if defined(_WIN32) |
markrad | 0:cdf462088d13 | 190 | /* For Windows (inc. MSYS2), we provide our own fixed implementation */ |
markrad | 0:cdf462088d13 | 191 | int mbedtls_platform_win32_snprintf( char *s, size_t n, const char *fmt, ... ); |
markrad | 0:cdf462088d13 | 192 | #endif |
markrad | 0:cdf462088d13 | 193 | |
markrad | 0:cdf462088d13 | 194 | #if defined(MBEDTLS_PLATFORM_SNPRINTF_ALT) |
markrad | 0:cdf462088d13 | 195 | extern int (*mbedtls_snprintf)( char * s, size_t n, const char * format, ... ); |
markrad | 0:cdf462088d13 | 196 | |
markrad | 0:cdf462088d13 | 197 | /** |
markrad | 0:cdf462088d13 | 198 | * \brief Set your own snprintf function pointer |
markrad | 0:cdf462088d13 | 199 | * |
markrad | 0:cdf462088d13 | 200 | * \param snprintf_func the snprintf function implementation |
markrad | 0:cdf462088d13 | 201 | * |
markrad | 0:cdf462088d13 | 202 | * \return 0 |
markrad | 0:cdf462088d13 | 203 | */ |
markrad | 0:cdf462088d13 | 204 | int mbedtls_platform_set_snprintf( int (*snprintf_func)( char * s, size_t n, |
markrad | 0:cdf462088d13 | 205 | const char * format, ... ) ); |
markrad | 0:cdf462088d13 | 206 | #else /* MBEDTLS_PLATFORM_SNPRINTF_ALT */ |
markrad | 0:cdf462088d13 | 207 | #if defined(MBEDTLS_PLATFORM_SNPRINTF_MACRO) |
markrad | 0:cdf462088d13 | 208 | #define mbedtls_snprintf MBEDTLS_PLATFORM_SNPRINTF_MACRO |
markrad | 0:cdf462088d13 | 209 | #else |
markrad | 0:cdf462088d13 | 210 | #define mbedtls_snprintf snprintf |
markrad | 0:cdf462088d13 | 211 | #endif /* MBEDTLS_PLATFORM_SNPRINTF_MACRO */ |
markrad | 0:cdf462088d13 | 212 | #endif /* MBEDTLS_PLATFORM_SNPRINTF_ALT */ |
markrad | 0:cdf462088d13 | 213 | |
markrad | 0:cdf462088d13 | 214 | /* |
markrad | 0:cdf462088d13 | 215 | * The function pointers for exit |
markrad | 0:cdf462088d13 | 216 | */ |
markrad | 0:cdf462088d13 | 217 | #if defined(MBEDTLS_PLATFORM_EXIT_ALT) |
markrad | 0:cdf462088d13 | 218 | extern void (*mbedtls_exit)( int status ); |
markrad | 0:cdf462088d13 | 219 | |
markrad | 0:cdf462088d13 | 220 | /** |
markrad | 0:cdf462088d13 | 221 | * \brief Set your own exit function pointer |
markrad | 0:cdf462088d13 | 222 | * |
markrad | 0:cdf462088d13 | 223 | * \param exit_func the exit function implementation |
markrad | 0:cdf462088d13 | 224 | * |
markrad | 0:cdf462088d13 | 225 | * \return 0 |
markrad | 0:cdf462088d13 | 226 | */ |
markrad | 0:cdf462088d13 | 227 | int mbedtls_platform_set_exit( void (*exit_func)( int status ) ); |
markrad | 0:cdf462088d13 | 228 | #else |
markrad | 0:cdf462088d13 | 229 | #if defined(MBEDTLS_PLATFORM_EXIT_MACRO) |
markrad | 0:cdf462088d13 | 230 | #define mbedtls_exit MBEDTLS_PLATFORM_EXIT_MACRO |
markrad | 0:cdf462088d13 | 231 | #else |
markrad | 0:cdf462088d13 | 232 | #define mbedtls_exit exit |
markrad | 0:cdf462088d13 | 233 | #endif /* MBEDTLS_PLATFORM_EXIT_MACRO */ |
markrad | 0:cdf462088d13 | 234 | #endif /* MBEDTLS_PLATFORM_EXIT_ALT */ |
markrad | 0:cdf462088d13 | 235 | |
markrad | 0:cdf462088d13 | 236 | /* |
markrad | 0:cdf462088d13 | 237 | * The default exit values |
markrad | 0:cdf462088d13 | 238 | */ |
markrad | 0:cdf462088d13 | 239 | #if defined(MBEDTLS_PLATFORM_STD_EXIT_SUCCESS) |
markrad | 0:cdf462088d13 | 240 | #define MBEDTLS_EXIT_SUCCESS MBEDTLS_PLATFORM_STD_EXIT_SUCCESS |
markrad | 0:cdf462088d13 | 241 | #else |
markrad | 0:cdf462088d13 | 242 | #define MBEDTLS_EXIT_SUCCESS 0 |
markrad | 0:cdf462088d13 | 243 | #endif |
markrad | 0:cdf462088d13 | 244 | #if defined(MBEDTLS_PLATFORM_STD_EXIT_FAILURE) |
markrad | 0:cdf462088d13 | 245 | #define MBEDTLS_EXIT_FAILURE MBEDTLS_PLATFORM_STD_EXIT_FAILURE |
markrad | 0:cdf462088d13 | 246 | #else |
markrad | 0:cdf462088d13 | 247 | #define MBEDTLS_EXIT_FAILURE 1 |
markrad | 0:cdf462088d13 | 248 | #endif |
markrad | 0:cdf462088d13 | 249 | |
markrad | 0:cdf462088d13 | 250 | /* |
markrad | 0:cdf462088d13 | 251 | * The function pointers for reading from and writing a seed file to |
markrad | 0:cdf462088d13 | 252 | * Non-Volatile storage (NV) in a platform-independent way |
markrad | 0:cdf462088d13 | 253 | * |
markrad | 0:cdf462088d13 | 254 | * Only enabled when the NV seed entropy source is enabled |
markrad | 0:cdf462088d13 | 255 | */ |
markrad | 0:cdf462088d13 | 256 | #if defined(MBEDTLS_ENTROPY_NV_SEED) |
markrad | 0:cdf462088d13 | 257 | #if !defined(MBEDTLS_PLATFORM_NO_STD_FUNCTIONS) && defined(MBEDTLS_FS_IO) |
markrad | 0:cdf462088d13 | 258 | /* Internal standard platform definitions */ |
markrad | 0:cdf462088d13 | 259 | int mbedtls_platform_std_nv_seed_read( unsigned char *buf, size_t buf_len ); |
markrad | 0:cdf462088d13 | 260 | int mbedtls_platform_std_nv_seed_write( unsigned char *buf, size_t buf_len ); |
markrad | 0:cdf462088d13 | 261 | #endif |
markrad | 0:cdf462088d13 | 262 | |
markrad | 0:cdf462088d13 | 263 | #if defined(MBEDTLS_PLATFORM_NV_SEED_ALT) |
markrad | 0:cdf462088d13 | 264 | extern int (*mbedtls_nv_seed_read)( unsigned char *buf, size_t buf_len ); |
markrad | 0:cdf462088d13 | 265 | extern int (*mbedtls_nv_seed_write)( unsigned char *buf, size_t buf_len ); |
markrad | 0:cdf462088d13 | 266 | |
markrad | 0:cdf462088d13 | 267 | /** |
markrad | 0:cdf462088d13 | 268 | * \brief Set your own seed file writing/reading functions |
markrad | 0:cdf462088d13 | 269 | * |
markrad | 0:cdf462088d13 | 270 | * \param nv_seed_read_func the seed reading function implementation |
markrad | 0:cdf462088d13 | 271 | * \param nv_seed_write_func the seed writing function implementation |
markrad | 0:cdf462088d13 | 272 | * |
markrad | 0:cdf462088d13 | 273 | * \return 0 |
markrad | 0:cdf462088d13 | 274 | */ |
markrad | 0:cdf462088d13 | 275 | int mbedtls_platform_set_nv_seed( |
markrad | 0:cdf462088d13 | 276 | int (*nv_seed_read_func)( unsigned char *buf, size_t buf_len ), |
markrad | 0:cdf462088d13 | 277 | int (*nv_seed_write_func)( unsigned char *buf, size_t buf_len ) |
markrad | 0:cdf462088d13 | 278 | ); |
markrad | 0:cdf462088d13 | 279 | #else |
markrad | 0:cdf462088d13 | 280 | #if defined(MBEDTLS_PLATFORM_NV_SEED_READ_MACRO) && \ |
markrad | 0:cdf462088d13 | 281 | defined(MBEDTLS_PLATFORM_NV_SEED_WRITE_MACRO) |
markrad | 0:cdf462088d13 | 282 | #define mbedtls_nv_seed_read MBEDTLS_PLATFORM_NV_SEED_READ_MACRO |
markrad | 0:cdf462088d13 | 283 | #define mbedtls_nv_seed_write MBEDTLS_PLATFORM_NV_SEED_WRITE_MACRO |
markrad | 0:cdf462088d13 | 284 | #else |
markrad | 0:cdf462088d13 | 285 | #define mbedtls_nv_seed_read mbedtls_platform_std_nv_seed_read |
markrad | 0:cdf462088d13 | 286 | #define mbedtls_nv_seed_write mbedtls_platform_std_nv_seed_write |
markrad | 0:cdf462088d13 | 287 | #endif |
markrad | 0:cdf462088d13 | 288 | #endif /* MBEDTLS_PLATFORM_NV_SEED_ALT */ |
markrad | 0:cdf462088d13 | 289 | #endif /* MBEDTLS_ENTROPY_NV_SEED */ |
markrad | 0:cdf462088d13 | 290 | |
markrad | 0:cdf462088d13 | 291 | #ifdef __cplusplus |
markrad | 0:cdf462088d13 | 292 | } |
markrad | 0:cdf462088d13 | 293 | #endif |
markrad | 0:cdf462088d13 | 294 | |
markrad | 0:cdf462088d13 | 295 | #endif /* platform.h */ |