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