1c2c66affSColin Finck /*
2c2c66affSColin Finck * Platform abstraction layer
3c2c66affSColin Finck *
4218e2596SThomas Faber * Copyright The Mbed TLS Contributors
5e57126f5SThomas Faber * SPDX-License-Identifier: Apache-2.0 OR GPL-2.0-or-later
6e57126f5SThomas Faber *
7e57126f5SThomas Faber * This file is provided under the Apache License 2.0, or the
8e57126f5SThomas Faber * GNU General Public License v2.0 or later.
9e57126f5SThomas Faber *
10e57126f5SThomas Faber * **********
11e57126f5SThomas Faber * Apache License 2.0:
12e57126f5SThomas Faber *
13e57126f5SThomas Faber * Licensed under the Apache License, Version 2.0 (the "License"); you may
14e57126f5SThomas Faber * not use this file except in compliance with the License.
15e57126f5SThomas Faber * You may obtain a copy of the License at
16e57126f5SThomas Faber *
17e57126f5SThomas Faber * http://www.apache.org/licenses/LICENSE-2.0
18e57126f5SThomas Faber *
19e57126f5SThomas Faber * Unless required by applicable law or agreed to in writing, software
20e57126f5SThomas Faber * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
21e57126f5SThomas Faber * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
22e57126f5SThomas Faber * See the License for the specific language governing permissions and
23e57126f5SThomas Faber * limitations under the License.
24e57126f5SThomas Faber *
25e57126f5SThomas Faber * **********
26e57126f5SThomas Faber *
27e57126f5SThomas Faber * **********
28e57126f5SThomas Faber * GNU General Public License v2.0 or later:
29c2c66affSColin Finck *
30c2c66affSColin Finck * This program is free software; you can redistribute it and/or modify
31c2c66affSColin Finck * it under the terms of the GNU General Public License as published by
32c2c66affSColin Finck * the Free Software Foundation; either version 2 of the License, or
33c2c66affSColin Finck * (at your option) any later version.
34c2c66affSColin Finck *
35c2c66affSColin Finck * This program is distributed in the hope that it will be useful,
36c2c66affSColin Finck * but WITHOUT ANY WARRANTY; without even the implied warranty of
37c2c66affSColin Finck * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
38c2c66affSColin Finck * GNU General Public License for more details.
39c2c66affSColin Finck *
40c2c66affSColin Finck * You should have received a copy of the GNU General Public License along
41c2c66affSColin Finck * with this program; if not, write to the Free Software Foundation, Inc.,
42c2c66affSColin Finck * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
43c2c66affSColin Finck *
44e57126f5SThomas Faber * **********
45c2c66affSColin Finck */
46c2c66affSColin Finck
47c2c66affSColin Finck #if !defined(MBEDTLS_CONFIG_FILE)
48c2c66affSColin Finck #include "mbedtls/config.h"
49c2c66affSColin Finck #else
50c2c66affSColin Finck #include MBEDTLS_CONFIG_FILE
51c2c66affSColin Finck #endif
52c2c66affSColin Finck
53c2c66affSColin Finck #if defined(MBEDTLS_PLATFORM_C)
54c2c66affSColin Finck
55c2c66affSColin Finck #include "mbedtls/platform.h"
56*cbda039fSThomas Faber #include "mbedtls/platform_util.h"
57d9e6c9b5SThomas Faber
580ba5bc40SThomas Faber /* The compile time configuration of memory allocation via the macros
590ba5bc40SThomas Faber * MBEDTLS_PLATFORM_{FREE/CALLOC}_MACRO takes precedence over the runtime
600ba5bc40SThomas Faber * configuration via mbedtls_platform_set_calloc_free(). So, omit everything
610ba5bc40SThomas Faber * related to the latter if MBEDTLS_PLATFORM_{FREE/CALLOC}_MACRO are defined. */
620ba5bc40SThomas Faber #if defined(MBEDTLS_PLATFORM_MEMORY) && \
630ba5bc40SThomas Faber !( defined(MBEDTLS_PLATFORM_CALLOC_MACRO) && \
640ba5bc40SThomas Faber defined(MBEDTLS_PLATFORM_FREE_MACRO) )
650ba5bc40SThomas Faber
66c2c66affSColin Finck #if !defined(MBEDTLS_PLATFORM_STD_CALLOC)
platform_calloc_uninit(size_t n,size_t size)67c2c66affSColin Finck static void *platform_calloc_uninit( size_t n, size_t size )
68c2c66affSColin Finck {
69c2c66affSColin Finck ((void) n);
70c2c66affSColin Finck ((void) size);
71c2c66affSColin Finck return( NULL );
72c2c66affSColin Finck }
73c2c66affSColin Finck
74c2c66affSColin Finck #define MBEDTLS_PLATFORM_STD_CALLOC platform_calloc_uninit
75c2c66affSColin Finck #endif /* !MBEDTLS_PLATFORM_STD_CALLOC */
76c2c66affSColin Finck
77c2c66affSColin Finck #if !defined(MBEDTLS_PLATFORM_STD_FREE)
platform_free_uninit(void * ptr)78c2c66affSColin Finck static void platform_free_uninit( void *ptr )
79c2c66affSColin Finck {
80c2c66affSColin Finck ((void) ptr);
81c2c66affSColin Finck }
82c2c66affSColin Finck
83c2c66affSColin Finck #define MBEDTLS_PLATFORM_STD_FREE platform_free_uninit
84c2c66affSColin Finck #endif /* !MBEDTLS_PLATFORM_STD_FREE */
85c2c66affSColin Finck
86*cbda039fSThomas Faber static void * (*mbedtls_calloc_func)( size_t, size_t ) = MBEDTLS_PLATFORM_STD_CALLOC;
87*cbda039fSThomas Faber static void (*mbedtls_free_func)( void * ) = MBEDTLS_PLATFORM_STD_FREE;
88*cbda039fSThomas Faber
mbedtls_calloc(size_t nmemb,size_t size)89*cbda039fSThomas Faber void * mbedtls_calloc( size_t nmemb, size_t size )
90*cbda039fSThomas Faber {
91*cbda039fSThomas Faber return (*mbedtls_calloc_func)( nmemb, size );
92*cbda039fSThomas Faber }
93*cbda039fSThomas Faber
mbedtls_free(void * ptr)94*cbda039fSThomas Faber void mbedtls_free( void * ptr )
95*cbda039fSThomas Faber {
96*cbda039fSThomas Faber (*mbedtls_free_func)( ptr );
97*cbda039fSThomas Faber }
98c2c66affSColin Finck
mbedtls_platform_set_calloc_free(void * (* calloc_func)(size_t,size_t),void (* free_func)(void *))99c2c66affSColin Finck int mbedtls_platform_set_calloc_free( void * (*calloc_func)( size_t, size_t ),
100c2c66affSColin Finck void (*free_func)( void * ) )
101c2c66affSColin Finck {
102*cbda039fSThomas Faber mbedtls_calloc_func = calloc_func;
103*cbda039fSThomas Faber mbedtls_free_func = free_func;
104c2c66affSColin Finck return( 0 );
105c2c66affSColin Finck }
1060ba5bc40SThomas Faber #endif /* MBEDTLS_PLATFORM_MEMORY &&
1070ba5bc40SThomas Faber !( defined(MBEDTLS_PLATFORM_CALLOC_MACRO) &&
1080ba5bc40SThomas Faber defined(MBEDTLS_PLATFORM_FREE_MACRO) ) */
109c2c66affSColin Finck
110c2c66affSColin Finck #if defined(_WIN32)
111c2c66affSColin Finck #include <stdarg.h>
mbedtls_platform_win32_snprintf(char * s,size_t n,const char * fmt,...)112c2c66affSColin Finck int mbedtls_platform_win32_snprintf( char *s, size_t n, const char *fmt, ... )
113c2c66affSColin Finck {
114c2c66affSColin Finck int ret;
115c2c66affSColin Finck va_list argp;
116c2c66affSColin Finck
117c2c66affSColin Finck /* Avoid calling the invalid parameter handler by checking ourselves */
118c2c66affSColin Finck if( s == NULL || n == 0 || fmt == NULL )
119c2c66affSColin Finck return( -1 );
120c2c66affSColin Finck
121c2c66affSColin Finck va_start( argp, fmt );
122d9e6c9b5SThomas Faber #if defined(_TRUNCATE) && !defined(__MINGW32__)
123c2c66affSColin Finck ret = _vsnprintf_s( s, n, _TRUNCATE, fmt, argp );
124c2c66affSColin Finck #else
125c2c66affSColin Finck ret = _vsnprintf( s, n, fmt, argp );
126c2c66affSColin Finck if( ret < 0 || (size_t) ret == n )
127c2c66affSColin Finck {
128c2c66affSColin Finck s[n-1] = '\0';
129c2c66affSColin Finck ret = -1;
130c2c66affSColin Finck }
131c2c66affSColin Finck #endif
132c2c66affSColin Finck va_end( argp );
133c2c66affSColin Finck
134c2c66affSColin Finck return( ret );
135c2c66affSColin Finck }
136c2c66affSColin Finck #endif
137c2c66affSColin Finck
138c2c66affSColin Finck #if defined(MBEDTLS_PLATFORM_SNPRINTF_ALT)
139c2c66affSColin Finck #if !defined(MBEDTLS_PLATFORM_STD_SNPRINTF)
140c2c66affSColin Finck /*
141c2c66affSColin Finck * Make dummy function to prevent NULL pointer dereferences
142c2c66affSColin Finck */
platform_snprintf_uninit(char * s,size_t n,const char * format,...)143c2c66affSColin Finck static int platform_snprintf_uninit( char * s, size_t n,
144c2c66affSColin Finck const char * format, ... )
145c2c66affSColin Finck {
146c2c66affSColin Finck ((void) s);
147c2c66affSColin Finck ((void) n);
148c2c66affSColin Finck ((void) format);
149c2c66affSColin Finck return( 0 );
150c2c66affSColin Finck }
151c2c66affSColin Finck
152c2c66affSColin Finck #define MBEDTLS_PLATFORM_STD_SNPRINTF platform_snprintf_uninit
153c2c66affSColin Finck #endif /* !MBEDTLS_PLATFORM_STD_SNPRINTF */
154c2c66affSColin Finck
155c2c66affSColin Finck int (*mbedtls_snprintf)( char * s, size_t n,
156c2c66affSColin Finck const char * format,
157c2c66affSColin Finck ... ) = MBEDTLS_PLATFORM_STD_SNPRINTF;
158c2c66affSColin Finck
mbedtls_platform_set_snprintf(int (* snprintf_func)(char * s,size_t n,const char * format,...))159c2c66affSColin Finck int mbedtls_platform_set_snprintf( int (*snprintf_func)( char * s, size_t n,
160c2c66affSColin Finck const char * format,
161c2c66affSColin Finck ... ) )
162c2c66affSColin Finck {
163c2c66affSColin Finck mbedtls_snprintf = snprintf_func;
164c2c66affSColin Finck return( 0 );
165c2c66affSColin Finck }
166c2c66affSColin Finck #endif /* MBEDTLS_PLATFORM_SNPRINTF_ALT */
167c2c66affSColin Finck
168c2c66affSColin Finck #if defined(MBEDTLS_PLATFORM_PRINTF_ALT)
169c2c66affSColin Finck #if !defined(MBEDTLS_PLATFORM_STD_PRINTF)
170c2c66affSColin Finck /*
171c2c66affSColin Finck * Make dummy function to prevent NULL pointer dereferences
172c2c66affSColin Finck */
platform_printf_uninit(const char * format,...)173c2c66affSColin Finck static int platform_printf_uninit( const char *format, ... )
174c2c66affSColin Finck {
175c2c66affSColin Finck ((void) format);
176c2c66affSColin Finck return( 0 );
177c2c66affSColin Finck }
178c2c66affSColin Finck
179c2c66affSColin Finck #define MBEDTLS_PLATFORM_STD_PRINTF platform_printf_uninit
180c2c66affSColin Finck #endif /* !MBEDTLS_PLATFORM_STD_PRINTF */
181c2c66affSColin Finck
182c2c66affSColin Finck int (*mbedtls_printf)( const char *, ... ) = MBEDTLS_PLATFORM_STD_PRINTF;
183c2c66affSColin Finck
mbedtls_platform_set_printf(int (* printf_func)(const char *,...))184c2c66affSColin Finck int mbedtls_platform_set_printf( int (*printf_func)( const char *, ... ) )
185c2c66affSColin Finck {
186c2c66affSColin Finck mbedtls_printf = printf_func;
187c2c66affSColin Finck return( 0 );
188c2c66affSColin Finck }
189c2c66affSColin Finck #endif /* MBEDTLS_PLATFORM_PRINTF_ALT */
190c2c66affSColin Finck
191c2c66affSColin Finck #if defined(MBEDTLS_PLATFORM_FPRINTF_ALT)
192c2c66affSColin Finck #if !defined(MBEDTLS_PLATFORM_STD_FPRINTF)
193c2c66affSColin Finck /*
194c2c66affSColin Finck * Make dummy function to prevent NULL pointer dereferences
195c2c66affSColin Finck */
platform_fprintf_uninit(FILE * stream,const char * format,...)196c2c66affSColin Finck static int platform_fprintf_uninit( FILE *stream, const char *format, ... )
197c2c66affSColin Finck {
198c2c66affSColin Finck ((void) stream);
199c2c66affSColin Finck ((void) format);
200c2c66affSColin Finck return( 0 );
201c2c66affSColin Finck }
202c2c66affSColin Finck
203c2c66affSColin Finck #define MBEDTLS_PLATFORM_STD_FPRINTF platform_fprintf_uninit
204c2c66affSColin Finck #endif /* !MBEDTLS_PLATFORM_STD_FPRINTF */
205c2c66affSColin Finck
206c2c66affSColin Finck int (*mbedtls_fprintf)( FILE *, const char *, ... ) =
207c2c66affSColin Finck MBEDTLS_PLATFORM_STD_FPRINTF;
208c2c66affSColin Finck
mbedtls_platform_set_fprintf(int (* fprintf_func)(FILE *,const char *,...))209c2c66affSColin Finck int mbedtls_platform_set_fprintf( int (*fprintf_func)( FILE *, const char *, ... ) )
210c2c66affSColin Finck {
211c2c66affSColin Finck mbedtls_fprintf = fprintf_func;
212c2c66affSColin Finck return( 0 );
213c2c66affSColin Finck }
214c2c66affSColin Finck #endif /* MBEDTLS_PLATFORM_FPRINTF_ALT */
215c2c66affSColin Finck
216c2c66affSColin Finck #if defined(MBEDTLS_PLATFORM_EXIT_ALT)
217c2c66affSColin Finck #if !defined(MBEDTLS_PLATFORM_STD_EXIT)
218c2c66affSColin Finck /*
219c2c66affSColin Finck * Make dummy function to prevent NULL pointer dereferences
220c2c66affSColin Finck */
platform_exit_uninit(int status)221c2c66affSColin Finck static void platform_exit_uninit( int status )
222c2c66affSColin Finck {
223c2c66affSColin Finck ((void) status);
224c2c66affSColin Finck }
225c2c66affSColin Finck
226c2c66affSColin Finck #define MBEDTLS_PLATFORM_STD_EXIT platform_exit_uninit
227c2c66affSColin Finck #endif /* !MBEDTLS_PLATFORM_STD_EXIT */
228c2c66affSColin Finck
229c2c66affSColin Finck void (*mbedtls_exit)( int status ) = MBEDTLS_PLATFORM_STD_EXIT;
230c2c66affSColin Finck
mbedtls_platform_set_exit(void (* exit_func)(int status))231c2c66affSColin Finck int mbedtls_platform_set_exit( void (*exit_func)( int status ) )
232c2c66affSColin Finck {
233c2c66affSColin Finck mbedtls_exit = exit_func;
234c2c66affSColin Finck return( 0 );
235c2c66affSColin Finck }
236c2c66affSColin Finck #endif /* MBEDTLS_PLATFORM_EXIT_ALT */
237c2c66affSColin Finck
238c2c66affSColin Finck #if defined(MBEDTLS_HAVE_TIME)
239c2c66affSColin Finck
240c2c66affSColin Finck #if defined(MBEDTLS_PLATFORM_TIME_ALT)
241c2c66affSColin Finck #if !defined(MBEDTLS_PLATFORM_STD_TIME)
242c2c66affSColin Finck /*
243c2c66affSColin Finck * Make dummy function to prevent NULL pointer dereferences
244c2c66affSColin Finck */
platform_time_uninit(mbedtls_time_t * timer)245c2c66affSColin Finck static mbedtls_time_t platform_time_uninit( mbedtls_time_t* timer )
246c2c66affSColin Finck {
247c2c66affSColin Finck ((void) timer);
248c2c66affSColin Finck return( 0 );
249c2c66affSColin Finck }
250c2c66affSColin Finck
251c2c66affSColin Finck #define MBEDTLS_PLATFORM_STD_TIME platform_time_uninit
252c2c66affSColin Finck #endif /* !MBEDTLS_PLATFORM_STD_TIME */
253c2c66affSColin Finck
254c2c66affSColin Finck mbedtls_time_t (*mbedtls_time)( mbedtls_time_t* timer ) = MBEDTLS_PLATFORM_STD_TIME;
255c2c66affSColin Finck
mbedtls_platform_set_time(mbedtls_time_t (* time_func)(mbedtls_time_t * timer))256c2c66affSColin Finck int mbedtls_platform_set_time( mbedtls_time_t (*time_func)( mbedtls_time_t* timer ) )
257c2c66affSColin Finck {
258c2c66affSColin Finck mbedtls_time = time_func;
259c2c66affSColin Finck return( 0 );
260c2c66affSColin Finck }
261c2c66affSColin Finck #endif /* MBEDTLS_PLATFORM_TIME_ALT */
262c2c66affSColin Finck
263c2c66affSColin Finck #endif /* MBEDTLS_HAVE_TIME */
264c2c66affSColin Finck
265c2c66affSColin Finck #if defined(MBEDTLS_ENTROPY_NV_SEED)
266c2c66affSColin Finck #if !defined(MBEDTLS_PLATFORM_NO_STD_FUNCTIONS) && defined(MBEDTLS_FS_IO)
267c2c66affSColin Finck /* Default implementations for the platform independent seed functions use
268c2c66affSColin Finck * standard libc file functions to read from and write to a pre-defined filename
269c2c66affSColin Finck */
mbedtls_platform_std_nv_seed_read(unsigned char * buf,size_t buf_len)270c2c66affSColin Finck int mbedtls_platform_std_nv_seed_read( unsigned char *buf, size_t buf_len )
271c2c66affSColin Finck {
272c2c66affSColin Finck FILE *file;
273c2c66affSColin Finck size_t n;
274c2c66affSColin Finck
275c2c66affSColin Finck if( ( file = fopen( MBEDTLS_PLATFORM_STD_NV_SEED_FILE, "rb" ) ) == NULL )
276d9e6c9b5SThomas Faber return( -1 );
277c2c66affSColin Finck
278c2c66affSColin Finck if( ( n = fread( buf, 1, buf_len, file ) ) != buf_len )
279c2c66affSColin Finck {
280c2c66affSColin Finck fclose( file );
281*cbda039fSThomas Faber mbedtls_platform_zeroize( buf, buf_len );
282d9e6c9b5SThomas Faber return( -1 );
283c2c66affSColin Finck }
284c2c66affSColin Finck
285c2c66affSColin Finck fclose( file );
286c2c66affSColin Finck return( (int)n );
287c2c66affSColin Finck }
288c2c66affSColin Finck
mbedtls_platform_std_nv_seed_write(unsigned char * buf,size_t buf_len)289c2c66affSColin Finck int mbedtls_platform_std_nv_seed_write( unsigned char *buf, size_t buf_len )
290c2c66affSColin Finck {
291c2c66affSColin Finck FILE *file;
292c2c66affSColin Finck size_t n;
293c2c66affSColin Finck
294c2c66affSColin Finck if( ( file = fopen( MBEDTLS_PLATFORM_STD_NV_SEED_FILE, "w" ) ) == NULL )
295c2c66affSColin Finck return -1;
296c2c66affSColin Finck
297c2c66affSColin Finck if( ( n = fwrite( buf, 1, buf_len, file ) ) != buf_len )
298c2c66affSColin Finck {
299c2c66affSColin Finck fclose( file );
300c2c66affSColin Finck return -1;
301c2c66affSColin Finck }
302c2c66affSColin Finck
303c2c66affSColin Finck fclose( file );
304c2c66affSColin Finck return( (int)n );
305c2c66affSColin Finck }
306c2c66affSColin Finck #endif /* MBEDTLS_PLATFORM_NO_STD_FUNCTIONS */
307c2c66affSColin Finck
308c2c66affSColin Finck #if defined(MBEDTLS_PLATFORM_NV_SEED_ALT)
309c2c66affSColin Finck #if !defined(MBEDTLS_PLATFORM_STD_NV_SEED_READ)
310c2c66affSColin Finck /*
311c2c66affSColin Finck * Make dummy function to prevent NULL pointer dereferences
312c2c66affSColin Finck */
platform_nv_seed_read_uninit(unsigned char * buf,size_t buf_len)313c2c66affSColin Finck static int platform_nv_seed_read_uninit( unsigned char *buf, size_t buf_len )
314c2c66affSColin Finck {
315c2c66affSColin Finck ((void) buf);
316c2c66affSColin Finck ((void) buf_len);
317c2c66affSColin Finck return( -1 );
318c2c66affSColin Finck }
319c2c66affSColin Finck
320c2c66affSColin Finck #define MBEDTLS_PLATFORM_STD_NV_SEED_READ platform_nv_seed_read_uninit
321c2c66affSColin Finck #endif /* !MBEDTLS_PLATFORM_STD_NV_SEED_READ */
322c2c66affSColin Finck
323c2c66affSColin Finck #if !defined(MBEDTLS_PLATFORM_STD_NV_SEED_WRITE)
324c2c66affSColin Finck /*
325c2c66affSColin Finck * Make dummy function to prevent NULL pointer dereferences
326c2c66affSColin Finck */
platform_nv_seed_write_uninit(unsigned char * buf,size_t buf_len)327c2c66affSColin Finck static int platform_nv_seed_write_uninit( unsigned char *buf, size_t buf_len )
328c2c66affSColin Finck {
329c2c66affSColin Finck ((void) buf);
330c2c66affSColin Finck ((void) buf_len);
331c2c66affSColin Finck return( -1 );
332c2c66affSColin Finck }
333c2c66affSColin Finck
334c2c66affSColin Finck #define MBEDTLS_PLATFORM_STD_NV_SEED_WRITE platform_nv_seed_write_uninit
335c2c66affSColin Finck #endif /* !MBEDTLS_PLATFORM_STD_NV_SEED_WRITE */
336c2c66affSColin Finck
337c2c66affSColin Finck int (*mbedtls_nv_seed_read)( unsigned char *buf, size_t buf_len ) =
338c2c66affSColin Finck MBEDTLS_PLATFORM_STD_NV_SEED_READ;
339c2c66affSColin Finck int (*mbedtls_nv_seed_write)( unsigned char *buf, size_t buf_len ) =
340c2c66affSColin Finck MBEDTLS_PLATFORM_STD_NV_SEED_WRITE;
341c2c66affSColin Finck
mbedtls_platform_set_nv_seed(int (* nv_seed_read_func)(unsigned char * buf,size_t buf_len),int (* nv_seed_write_func)(unsigned char * buf,size_t buf_len))342c2c66affSColin Finck int mbedtls_platform_set_nv_seed(
343c2c66affSColin Finck int (*nv_seed_read_func)( unsigned char *buf, size_t buf_len ),
344c2c66affSColin Finck int (*nv_seed_write_func)( unsigned char *buf, size_t buf_len ) )
345c2c66affSColin Finck {
346c2c66affSColin Finck mbedtls_nv_seed_read = nv_seed_read_func;
347c2c66affSColin Finck mbedtls_nv_seed_write = nv_seed_write_func;
348c2c66affSColin Finck return( 0 );
349c2c66affSColin Finck }
350c2c66affSColin Finck #endif /* MBEDTLS_PLATFORM_NV_SEED_ALT */
351c2c66affSColin Finck #endif /* MBEDTLS_ENTROPY_NV_SEED */
352c2c66affSColin Finck
353c2c66affSColin Finck #if !defined(MBEDTLS_PLATFORM_SETUP_TEARDOWN_ALT)
354c2c66affSColin Finck /*
355c2c66affSColin Finck * Placeholder platform setup that does nothing by default
356c2c66affSColin Finck */
mbedtls_platform_setup(mbedtls_platform_context * ctx)357c2c66affSColin Finck int mbedtls_platform_setup( mbedtls_platform_context *ctx )
358c2c66affSColin Finck {
359c2c66affSColin Finck (void)ctx;
360c2c66affSColin Finck
361c2c66affSColin Finck return( 0 );
362c2c66affSColin Finck }
363c2c66affSColin Finck
364c2c66affSColin Finck /*
365c2c66affSColin Finck * Placeholder platform teardown that does nothing by default
366c2c66affSColin Finck */
mbedtls_platform_teardown(mbedtls_platform_context * ctx)367c2c66affSColin Finck void mbedtls_platform_teardown( mbedtls_platform_context *ctx )
368c2c66affSColin Finck {
369c2c66affSColin Finck (void)ctx;
370c2c66affSColin Finck }
371c2c66affSColin Finck #endif /* MBEDTLS_PLATFORM_SETUP_TEARDOWN_ALT */
372c2c66affSColin Finck
373c2c66affSColin Finck #endif /* MBEDTLS_PLATFORM_C */
374