Preliminary main mbed library for nexpaq development

Committer:
nexpaq
Date:
Fri Nov 04 20:54:50 2016 +0000
Revision:
1:d96dbedaebdb
Parent:
0:6c56fb4bc5f0
Removed extra directories for other platforms

Who changed what in which revision?

UserRevisionLine numberNew contents of line
nexpaq 0:6c56fb4bc5f0 1 /*
nexpaq 0:6c56fb4bc5f0 2 * Platform abstraction layer
nexpaq 0:6c56fb4bc5f0 3 *
nexpaq 0:6c56fb4bc5f0 4 * Copyright (C) 2006-2016, ARM Limited, All Rights Reserved
nexpaq 0:6c56fb4bc5f0 5 * SPDX-License-Identifier: Apache-2.0
nexpaq 0:6c56fb4bc5f0 6 *
nexpaq 0:6c56fb4bc5f0 7 * Licensed under the Apache License, Version 2.0 (the "License"); you may
nexpaq 0:6c56fb4bc5f0 8 * not use this file except in compliance with the License.
nexpaq 0:6c56fb4bc5f0 9 * You may obtain a copy of the License at
nexpaq 0:6c56fb4bc5f0 10 *
nexpaq 0:6c56fb4bc5f0 11 * http://www.apache.org/licenses/LICENSE-2.0
nexpaq 0:6c56fb4bc5f0 12 *
nexpaq 0:6c56fb4bc5f0 13 * Unless required by applicable law or agreed to in writing, software
nexpaq 0:6c56fb4bc5f0 14 * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
nexpaq 0:6c56fb4bc5f0 15 * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
nexpaq 0:6c56fb4bc5f0 16 * See the License for the specific language governing permissions and
nexpaq 0:6c56fb4bc5f0 17 * limitations under the License.
nexpaq 0:6c56fb4bc5f0 18 *
nexpaq 0:6c56fb4bc5f0 19 * This file is part of mbed TLS (https://tls.mbed.org)
nexpaq 0:6c56fb4bc5f0 20 */
nexpaq 0:6c56fb4bc5f0 21
nexpaq 0:6c56fb4bc5f0 22 #if !defined(MBEDTLS_CONFIG_FILE)
nexpaq 0:6c56fb4bc5f0 23 #include "mbedtls/config.h"
nexpaq 0:6c56fb4bc5f0 24 #else
nexpaq 0:6c56fb4bc5f0 25 #include MBEDTLS_CONFIG_FILE
nexpaq 0:6c56fb4bc5f0 26 #endif
nexpaq 0:6c56fb4bc5f0 27
nexpaq 0:6c56fb4bc5f0 28 #if defined(MBEDTLS_PLATFORM_C)
nexpaq 0:6c56fb4bc5f0 29
nexpaq 0:6c56fb4bc5f0 30 #include "mbedtls/platform.h"
nexpaq 0:6c56fb4bc5f0 31
nexpaq 0:6c56fb4bc5f0 32 #if defined(MBEDTLS_PLATFORM_MEMORY)
nexpaq 0:6c56fb4bc5f0 33 #if !defined(MBEDTLS_PLATFORM_STD_CALLOC)
nexpaq 0:6c56fb4bc5f0 34 static void *platform_calloc_uninit( size_t n, size_t size )
nexpaq 0:6c56fb4bc5f0 35 {
nexpaq 0:6c56fb4bc5f0 36 ((void) n);
nexpaq 0:6c56fb4bc5f0 37 ((void) size);
nexpaq 0:6c56fb4bc5f0 38 return( NULL );
nexpaq 0:6c56fb4bc5f0 39 }
nexpaq 0:6c56fb4bc5f0 40
nexpaq 0:6c56fb4bc5f0 41 #define MBEDTLS_PLATFORM_STD_CALLOC platform_calloc_uninit
nexpaq 0:6c56fb4bc5f0 42 #endif /* !MBEDTLS_PLATFORM_STD_CALLOC */
nexpaq 0:6c56fb4bc5f0 43
nexpaq 0:6c56fb4bc5f0 44 #if !defined(MBEDTLS_PLATFORM_STD_FREE)
nexpaq 0:6c56fb4bc5f0 45 static void platform_free_uninit( void *ptr )
nexpaq 0:6c56fb4bc5f0 46 {
nexpaq 0:6c56fb4bc5f0 47 ((void) ptr);
nexpaq 0:6c56fb4bc5f0 48 }
nexpaq 0:6c56fb4bc5f0 49
nexpaq 0:6c56fb4bc5f0 50 #define MBEDTLS_PLATFORM_STD_FREE platform_free_uninit
nexpaq 0:6c56fb4bc5f0 51 #endif /* !MBEDTLS_PLATFORM_STD_FREE */
nexpaq 0:6c56fb4bc5f0 52
nexpaq 0:6c56fb4bc5f0 53 void * (*mbedtls_calloc)( size_t, size_t ) = MBEDTLS_PLATFORM_STD_CALLOC;
nexpaq 0:6c56fb4bc5f0 54 void (*mbedtls_free)( void * ) = MBEDTLS_PLATFORM_STD_FREE;
nexpaq 0:6c56fb4bc5f0 55
nexpaq 0:6c56fb4bc5f0 56 int mbedtls_platform_set_calloc_free( void * (*calloc_func)( size_t, size_t ),
nexpaq 0:6c56fb4bc5f0 57 void (*free_func)( void * ) )
nexpaq 0:6c56fb4bc5f0 58 {
nexpaq 0:6c56fb4bc5f0 59 mbedtls_calloc = calloc_func;
nexpaq 0:6c56fb4bc5f0 60 mbedtls_free = free_func;
nexpaq 0:6c56fb4bc5f0 61 return( 0 );
nexpaq 0:6c56fb4bc5f0 62 }
nexpaq 0:6c56fb4bc5f0 63 #endif /* MBEDTLS_PLATFORM_MEMORY */
nexpaq 0:6c56fb4bc5f0 64
nexpaq 0:6c56fb4bc5f0 65 #if defined(_WIN32)
nexpaq 0:6c56fb4bc5f0 66 #include <stdarg.h>
nexpaq 0:6c56fb4bc5f0 67 int mbedtls_platform_win32_snprintf( char *s, size_t n, const char *fmt, ... )
nexpaq 0:6c56fb4bc5f0 68 {
nexpaq 0:6c56fb4bc5f0 69 int ret;
nexpaq 0:6c56fb4bc5f0 70 va_list argp;
nexpaq 0:6c56fb4bc5f0 71
nexpaq 0:6c56fb4bc5f0 72 /* Avoid calling the invalid parameter handler by checking ourselves */
nexpaq 0:6c56fb4bc5f0 73 if( s == NULL || n == 0 || fmt == NULL )
nexpaq 0:6c56fb4bc5f0 74 return( -1 );
nexpaq 0:6c56fb4bc5f0 75
nexpaq 0:6c56fb4bc5f0 76 va_start( argp, fmt );
nexpaq 0:6c56fb4bc5f0 77 #if defined(_TRUNCATE)
nexpaq 0:6c56fb4bc5f0 78 ret = _vsnprintf_s( s, n, _TRUNCATE, fmt, argp );
nexpaq 0:6c56fb4bc5f0 79 #else
nexpaq 0:6c56fb4bc5f0 80 ret = _vsnprintf( s, n, fmt, argp );
nexpaq 0:6c56fb4bc5f0 81 if( ret < 0 || (size_t) ret == n )
nexpaq 0:6c56fb4bc5f0 82 {
nexpaq 0:6c56fb4bc5f0 83 s[n-1] = '\0';
nexpaq 0:6c56fb4bc5f0 84 ret = -1;
nexpaq 0:6c56fb4bc5f0 85 }
nexpaq 0:6c56fb4bc5f0 86 #endif
nexpaq 0:6c56fb4bc5f0 87 va_end( argp );
nexpaq 0:6c56fb4bc5f0 88
nexpaq 0:6c56fb4bc5f0 89 return( ret );
nexpaq 0:6c56fb4bc5f0 90 }
nexpaq 0:6c56fb4bc5f0 91 #endif
nexpaq 0:6c56fb4bc5f0 92
nexpaq 0:6c56fb4bc5f0 93 #if defined(MBEDTLS_PLATFORM_SNPRINTF_ALT)
nexpaq 0:6c56fb4bc5f0 94 #if !defined(MBEDTLS_PLATFORM_STD_SNPRINTF)
nexpaq 0:6c56fb4bc5f0 95 /*
nexpaq 0:6c56fb4bc5f0 96 * Make dummy function to prevent NULL pointer dereferences
nexpaq 0:6c56fb4bc5f0 97 */
nexpaq 0:6c56fb4bc5f0 98 static int platform_snprintf_uninit( char * s, size_t n,
nexpaq 0:6c56fb4bc5f0 99 const char * format, ... )
nexpaq 0:6c56fb4bc5f0 100 {
nexpaq 0:6c56fb4bc5f0 101 ((void) s);
nexpaq 0:6c56fb4bc5f0 102 ((void) n);
nexpaq 0:6c56fb4bc5f0 103 ((void) format);
nexpaq 0:6c56fb4bc5f0 104 return( 0 );
nexpaq 0:6c56fb4bc5f0 105 }
nexpaq 0:6c56fb4bc5f0 106
nexpaq 0:6c56fb4bc5f0 107 #define MBEDTLS_PLATFORM_STD_SNPRINTF platform_snprintf_uninit
nexpaq 0:6c56fb4bc5f0 108 #endif /* !MBEDTLS_PLATFORM_STD_SNPRINTF */
nexpaq 0:6c56fb4bc5f0 109
nexpaq 0:6c56fb4bc5f0 110 int (*mbedtls_snprintf)( char * s, size_t n,
nexpaq 0:6c56fb4bc5f0 111 const char * format,
nexpaq 0:6c56fb4bc5f0 112 ... ) = MBEDTLS_PLATFORM_STD_SNPRINTF;
nexpaq 0:6c56fb4bc5f0 113
nexpaq 0:6c56fb4bc5f0 114 int mbedtls_platform_set_snprintf( int (*snprintf_func)( char * s, size_t n,
nexpaq 0:6c56fb4bc5f0 115 const char * format,
nexpaq 0:6c56fb4bc5f0 116 ... ) )
nexpaq 0:6c56fb4bc5f0 117 {
nexpaq 0:6c56fb4bc5f0 118 mbedtls_snprintf = snprintf_func;
nexpaq 0:6c56fb4bc5f0 119 return( 0 );
nexpaq 0:6c56fb4bc5f0 120 }
nexpaq 0:6c56fb4bc5f0 121 #endif /* MBEDTLS_PLATFORM_SNPRINTF_ALT */
nexpaq 0:6c56fb4bc5f0 122
nexpaq 0:6c56fb4bc5f0 123 #if defined(MBEDTLS_PLATFORM_PRINTF_ALT)
nexpaq 0:6c56fb4bc5f0 124 #if !defined(MBEDTLS_PLATFORM_STD_PRINTF)
nexpaq 0:6c56fb4bc5f0 125 /*
nexpaq 0:6c56fb4bc5f0 126 * Make dummy function to prevent NULL pointer dereferences
nexpaq 0:6c56fb4bc5f0 127 */
nexpaq 0:6c56fb4bc5f0 128 static int platform_printf_uninit( const char *format, ... )
nexpaq 0:6c56fb4bc5f0 129 {
nexpaq 0:6c56fb4bc5f0 130 ((void) format);
nexpaq 0:6c56fb4bc5f0 131 return( 0 );
nexpaq 0:6c56fb4bc5f0 132 }
nexpaq 0:6c56fb4bc5f0 133
nexpaq 0:6c56fb4bc5f0 134 #define MBEDTLS_PLATFORM_STD_PRINTF platform_printf_uninit
nexpaq 0:6c56fb4bc5f0 135 #endif /* !MBEDTLS_PLATFORM_STD_PRINTF */
nexpaq 0:6c56fb4bc5f0 136
nexpaq 0:6c56fb4bc5f0 137 int (*mbedtls_printf)( const char *, ... ) = MBEDTLS_PLATFORM_STD_PRINTF;
nexpaq 0:6c56fb4bc5f0 138
nexpaq 0:6c56fb4bc5f0 139 int mbedtls_platform_set_printf( int (*printf_func)( const char *, ... ) )
nexpaq 0:6c56fb4bc5f0 140 {
nexpaq 0:6c56fb4bc5f0 141 mbedtls_printf = printf_func;
nexpaq 0:6c56fb4bc5f0 142 return( 0 );
nexpaq 0:6c56fb4bc5f0 143 }
nexpaq 0:6c56fb4bc5f0 144 #endif /* MBEDTLS_PLATFORM_PRINTF_ALT */
nexpaq 0:6c56fb4bc5f0 145
nexpaq 0:6c56fb4bc5f0 146 #if defined(MBEDTLS_PLATFORM_FPRINTF_ALT)
nexpaq 0:6c56fb4bc5f0 147 #if !defined(MBEDTLS_PLATFORM_STD_FPRINTF)
nexpaq 0:6c56fb4bc5f0 148 /*
nexpaq 0:6c56fb4bc5f0 149 * Make dummy function to prevent NULL pointer dereferences
nexpaq 0:6c56fb4bc5f0 150 */
nexpaq 0:6c56fb4bc5f0 151 static int platform_fprintf_uninit( FILE *stream, const char *format, ... )
nexpaq 0:6c56fb4bc5f0 152 {
nexpaq 0:6c56fb4bc5f0 153 ((void) stream);
nexpaq 0:6c56fb4bc5f0 154 ((void) format);
nexpaq 0:6c56fb4bc5f0 155 return( 0 );
nexpaq 0:6c56fb4bc5f0 156 }
nexpaq 0:6c56fb4bc5f0 157
nexpaq 0:6c56fb4bc5f0 158 #define MBEDTLS_PLATFORM_STD_FPRINTF platform_fprintf_uninit
nexpaq 0:6c56fb4bc5f0 159 #endif /* !MBEDTLS_PLATFORM_STD_FPRINTF */
nexpaq 0:6c56fb4bc5f0 160
nexpaq 0:6c56fb4bc5f0 161 int (*mbedtls_fprintf)( FILE *, const char *, ... ) =
nexpaq 0:6c56fb4bc5f0 162 MBEDTLS_PLATFORM_STD_FPRINTF;
nexpaq 0:6c56fb4bc5f0 163
nexpaq 0:6c56fb4bc5f0 164 int mbedtls_platform_set_fprintf( int (*fprintf_func)( FILE *, const char *, ... ) )
nexpaq 0:6c56fb4bc5f0 165 {
nexpaq 0:6c56fb4bc5f0 166 mbedtls_fprintf = fprintf_func;
nexpaq 0:6c56fb4bc5f0 167 return( 0 );
nexpaq 0:6c56fb4bc5f0 168 }
nexpaq 0:6c56fb4bc5f0 169 #endif /* MBEDTLS_PLATFORM_FPRINTF_ALT */
nexpaq 0:6c56fb4bc5f0 170
nexpaq 0:6c56fb4bc5f0 171 #if defined(MBEDTLS_PLATFORM_EXIT_ALT)
nexpaq 0:6c56fb4bc5f0 172 #if !defined(MBEDTLS_PLATFORM_STD_EXIT)
nexpaq 0:6c56fb4bc5f0 173 /*
nexpaq 0:6c56fb4bc5f0 174 * Make dummy function to prevent NULL pointer dereferences
nexpaq 0:6c56fb4bc5f0 175 */
nexpaq 0:6c56fb4bc5f0 176 static void platform_exit_uninit( int status )
nexpaq 0:6c56fb4bc5f0 177 {
nexpaq 0:6c56fb4bc5f0 178 ((void) status);
nexpaq 0:6c56fb4bc5f0 179 }
nexpaq 0:6c56fb4bc5f0 180
nexpaq 0:6c56fb4bc5f0 181 #define MBEDTLS_PLATFORM_STD_EXIT platform_exit_uninit
nexpaq 0:6c56fb4bc5f0 182 #endif /* !MBEDTLS_PLATFORM_STD_EXIT */
nexpaq 0:6c56fb4bc5f0 183
nexpaq 0:6c56fb4bc5f0 184 void (*mbedtls_exit)( int status ) = MBEDTLS_PLATFORM_STD_EXIT;
nexpaq 0:6c56fb4bc5f0 185
nexpaq 0:6c56fb4bc5f0 186 int mbedtls_platform_set_exit( void (*exit_func)( int status ) )
nexpaq 0:6c56fb4bc5f0 187 {
nexpaq 0:6c56fb4bc5f0 188 mbedtls_exit = exit_func;
nexpaq 0:6c56fb4bc5f0 189 return( 0 );
nexpaq 0:6c56fb4bc5f0 190 }
nexpaq 0:6c56fb4bc5f0 191 #endif /* MBEDTLS_PLATFORM_EXIT_ALT */
nexpaq 0:6c56fb4bc5f0 192
nexpaq 0:6c56fb4bc5f0 193 #if defined(MBEDTLS_PLATFORM_TIME_ALT)
nexpaq 0:6c56fb4bc5f0 194 #if !defined(MBEDTLS_PLATFORM_STD_TIME)
nexpaq 0:6c56fb4bc5f0 195 /*
nexpaq 0:6c56fb4bc5f0 196 * Make dummy function to prevent NULL pointer dereferences
nexpaq 0:6c56fb4bc5f0 197 */
nexpaq 0:6c56fb4bc5f0 198 static mbedtls_time_t platform_time_uninit( mbedtls_time_t* timer )
nexpaq 0:6c56fb4bc5f0 199 {
nexpaq 0:6c56fb4bc5f0 200 ((void) timer);
nexpaq 0:6c56fb4bc5f0 201 return( 0 );
nexpaq 0:6c56fb4bc5f0 202 }
nexpaq 0:6c56fb4bc5f0 203
nexpaq 0:6c56fb4bc5f0 204 #define MBEDTLS_PLATFORM_STD_TIME platform_time_uninit
nexpaq 0:6c56fb4bc5f0 205 #endif /* !MBEDTLS_PLATFORM_STD_TIME */
nexpaq 0:6c56fb4bc5f0 206
nexpaq 0:6c56fb4bc5f0 207 mbedtls_time_t (*mbedtls_time)( mbedtls_time_t* timer ) = MBEDTLS_PLATFORM_STD_TIME;
nexpaq 0:6c56fb4bc5f0 208
nexpaq 0:6c56fb4bc5f0 209 int mbedtls_platform_set_time( mbedtls_time_t (*time_func)( mbedtls_time_t* timer ) )
nexpaq 0:6c56fb4bc5f0 210 {
nexpaq 0:6c56fb4bc5f0 211 mbedtls_time = time_func;
nexpaq 0:6c56fb4bc5f0 212 return( 0 );
nexpaq 0:6c56fb4bc5f0 213 }
nexpaq 0:6c56fb4bc5f0 214 #endif /* MBEDTLS_PLATFORM_TIME_ALT */
nexpaq 0:6c56fb4bc5f0 215
nexpaq 0:6c56fb4bc5f0 216 #if defined(MBEDTLS_ENTROPY_NV_SEED)
nexpaq 0:6c56fb4bc5f0 217 #if !defined(MBEDTLS_PLATFORM_NO_STD_FUNCTIONS) && defined(MBEDTLS_FS_IO)
nexpaq 0:6c56fb4bc5f0 218 /* Default implementations for the platform independent seed functions use
nexpaq 0:6c56fb4bc5f0 219 * standard libc file functions to read from and write to a pre-defined filename
nexpaq 0:6c56fb4bc5f0 220 */
nexpaq 0:6c56fb4bc5f0 221 int mbedtls_platform_std_nv_seed_read( unsigned char *buf, size_t buf_len )
nexpaq 0:6c56fb4bc5f0 222 {
nexpaq 0:6c56fb4bc5f0 223 FILE *file;
nexpaq 0:6c56fb4bc5f0 224 size_t n;
nexpaq 0:6c56fb4bc5f0 225
nexpaq 0:6c56fb4bc5f0 226 if( ( file = fopen( MBEDTLS_PLATFORM_STD_NV_SEED_FILE, "rb" ) ) == NULL )
nexpaq 0:6c56fb4bc5f0 227 return -1;
nexpaq 0:6c56fb4bc5f0 228
nexpaq 0:6c56fb4bc5f0 229 if( ( n = fread( buf, 1, buf_len, file ) ) != buf_len )
nexpaq 0:6c56fb4bc5f0 230 {
nexpaq 0:6c56fb4bc5f0 231 fclose( file );
nexpaq 0:6c56fb4bc5f0 232 return -1;
nexpaq 0:6c56fb4bc5f0 233 }
nexpaq 0:6c56fb4bc5f0 234
nexpaq 0:6c56fb4bc5f0 235 fclose( file );
nexpaq 0:6c56fb4bc5f0 236 return( n );
nexpaq 0:6c56fb4bc5f0 237 }
nexpaq 0:6c56fb4bc5f0 238
nexpaq 0:6c56fb4bc5f0 239 int mbedtls_platform_std_nv_seed_write( unsigned char *buf, size_t buf_len )
nexpaq 0:6c56fb4bc5f0 240 {
nexpaq 0:6c56fb4bc5f0 241 FILE *file;
nexpaq 0:6c56fb4bc5f0 242 size_t n;
nexpaq 0:6c56fb4bc5f0 243
nexpaq 0:6c56fb4bc5f0 244 if( ( file = fopen( MBEDTLS_PLATFORM_STD_NV_SEED_FILE, "w" ) ) == NULL )
nexpaq 0:6c56fb4bc5f0 245 return -1;
nexpaq 0:6c56fb4bc5f0 246
nexpaq 0:6c56fb4bc5f0 247 if( ( n = fwrite( buf, 1, buf_len, file ) ) != buf_len )
nexpaq 0:6c56fb4bc5f0 248 {
nexpaq 0:6c56fb4bc5f0 249 fclose( file );
nexpaq 0:6c56fb4bc5f0 250 return -1;
nexpaq 0:6c56fb4bc5f0 251 }
nexpaq 0:6c56fb4bc5f0 252
nexpaq 0:6c56fb4bc5f0 253 fclose( file );
nexpaq 0:6c56fb4bc5f0 254 return( n );
nexpaq 0:6c56fb4bc5f0 255 }
nexpaq 0:6c56fb4bc5f0 256 #endif /* MBEDTLS_PLATFORM_NO_STD_FUNCTIONS */
nexpaq 0:6c56fb4bc5f0 257
nexpaq 0:6c56fb4bc5f0 258 #if defined(MBEDTLS_PLATFORM_NV_SEED_ALT)
nexpaq 0:6c56fb4bc5f0 259 #if !defined(MBEDTLS_PLATFORM_STD_NV_SEED_READ)
nexpaq 0:6c56fb4bc5f0 260 /*
nexpaq 0:6c56fb4bc5f0 261 * Make dummy function to prevent NULL pointer dereferences
nexpaq 0:6c56fb4bc5f0 262 */
nexpaq 0:6c56fb4bc5f0 263 static int platform_nv_seed_read_uninit( unsigned char *buf, size_t buf_len )
nexpaq 0:6c56fb4bc5f0 264 {
nexpaq 0:6c56fb4bc5f0 265 ((void) buf);
nexpaq 0:6c56fb4bc5f0 266 ((void) buf_len);
nexpaq 0:6c56fb4bc5f0 267 return( -1 );
nexpaq 0:6c56fb4bc5f0 268 }
nexpaq 0:6c56fb4bc5f0 269
nexpaq 0:6c56fb4bc5f0 270 #define MBEDTLS_PLATFORM_STD_NV_SEED_READ platform_nv_seed_read_uninit
nexpaq 0:6c56fb4bc5f0 271 #endif /* !MBEDTLS_PLATFORM_STD_NV_SEED_READ */
nexpaq 0:6c56fb4bc5f0 272
nexpaq 0:6c56fb4bc5f0 273 #if !defined(MBEDTLS_PLATFORM_STD_NV_SEED_WRITE)
nexpaq 0:6c56fb4bc5f0 274 /*
nexpaq 0:6c56fb4bc5f0 275 * Make dummy function to prevent NULL pointer dereferences
nexpaq 0:6c56fb4bc5f0 276 */
nexpaq 0:6c56fb4bc5f0 277 static int platform_nv_seed_write_uninit( unsigned char *buf, size_t buf_len )
nexpaq 0:6c56fb4bc5f0 278 {
nexpaq 0:6c56fb4bc5f0 279 ((void) buf);
nexpaq 0:6c56fb4bc5f0 280 ((void) buf_len);
nexpaq 0:6c56fb4bc5f0 281 return( -1 );
nexpaq 0:6c56fb4bc5f0 282 }
nexpaq 0:6c56fb4bc5f0 283
nexpaq 0:6c56fb4bc5f0 284 #define MBEDTLS_PLATFORM_STD_NV_SEED_WRITE platform_nv_seed_write_uninit
nexpaq 0:6c56fb4bc5f0 285 #endif /* !MBEDTLS_PLATFORM_STD_NV_SEED_WRITE */
nexpaq 0:6c56fb4bc5f0 286
nexpaq 0:6c56fb4bc5f0 287 int (*mbedtls_nv_seed_read)( unsigned char *buf, size_t buf_len ) =
nexpaq 0:6c56fb4bc5f0 288 MBEDTLS_PLATFORM_STD_NV_SEED_READ;
nexpaq 0:6c56fb4bc5f0 289 int (*mbedtls_nv_seed_write)( unsigned char *buf, size_t buf_len ) =
nexpaq 0:6c56fb4bc5f0 290 MBEDTLS_PLATFORM_STD_NV_SEED_WRITE;
nexpaq 0:6c56fb4bc5f0 291
nexpaq 0:6c56fb4bc5f0 292 int mbedtls_platform_set_nv_seed(
nexpaq 0:6c56fb4bc5f0 293 int (*nv_seed_read_func)( unsigned char *buf, size_t buf_len ),
nexpaq 0:6c56fb4bc5f0 294 int (*nv_seed_write_func)( unsigned char *buf, size_t buf_len ) )
nexpaq 0:6c56fb4bc5f0 295 {
nexpaq 0:6c56fb4bc5f0 296 mbedtls_nv_seed_read = nv_seed_read_func;
nexpaq 0:6c56fb4bc5f0 297 mbedtls_nv_seed_write = nv_seed_write_func;
nexpaq 0:6c56fb4bc5f0 298 return( 0 );
nexpaq 0:6c56fb4bc5f0 299 }
nexpaq 0:6c56fb4bc5f0 300 #endif /* MBEDTLS_PLATFORM_NV_SEED_ALT */
nexpaq 0:6c56fb4bc5f0 301 #endif /* MBEDTLS_ENTROPY_NV_SEED */
nexpaq 0:6c56fb4bc5f0 302
nexpaq 0:6c56fb4bc5f0 303 #endif /* MBEDTLS_PLATFORM_C */