Example program to test AES-GCM functionality. Used for a workshop

Dependencies:   mbed

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers platform.h Source File

platform.h

Go to the documentation of this file.
00001 /**
00002  * \file platform.h
00003  *
00004  * \brief PolarSSL Platform abstraction layer
00005  *
00006  *  Copyright (C) 2006-2014, Brainspark B.V.
00007  *
00008  *  This file is part of PolarSSL (http://www.polarssl.org)
00009  *  Lead Maintainer: Paul Bakker <polarssl_maintainer at polarssl.org>
00010  *
00011  *  All rights reserved.
00012  *
00013  *  This program is free software; you can redistribute it and/or modify
00014  *  it under the terms of the GNU General Public License as published by
00015  *  the Free Software Foundation; either version 2 of the License, or
00016  *  (at your option) any later version.
00017  *
00018  *  This program is distributed in the hope that it will be useful,
00019  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
00020  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00021  *  GNU General Public License for more details.
00022  *
00023  *  You should have received a copy of the GNU General Public License along
00024  *  with this program; if not, write to the Free Software Foundation, Inc.,
00025  *  51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
00026  */
00027 #ifndef POLARSSL_PLATFORM_H
00028 #define POLARSSL_PLATFORM_H
00029 
00030 #if !defined(POLARSSL_CONFIG_FILE)
00031 #include "config.h"
00032 #else
00033 #include POLARSSL_CONFIG_FILE
00034 #endif
00035 
00036 #include <stdio.h>
00037 
00038 #ifdef __cplusplus
00039 extern "C" {
00040 #endif
00041 
00042 /**
00043  * \name SECTION: Module settings
00044  *
00045  * The configuration options you can set for this module are in this section.
00046  * Either change them in config.h or define them on the compiler command line.
00047  * \{
00048  */
00049 
00050 #if !defined(POLARSSL_PLATFORM_NO_STD_FUNCTIONS)
00051 #include <stdlib.h>
00052 #if !defined(POLARSSL_PLATFORM_STD_PRINTF)
00053 #define POLARSSL_PLATFORM_STD_PRINTF   printf /**< Default printf to use  */
00054 #endif
00055 #if !defined(POLARSSL_PLATFORM_STD_FPRINTF)
00056 #define POLARSSL_PLATFORM_STD_FPRINTF fprintf /**< Default fprintf to use */
00057 #endif
00058 #if !defined(POLARSSL_PLATFORM_STD_MALLOC)
00059 #define POLARSSL_PLATFORM_STD_MALLOC   malloc /**< Default allocator to use */
00060 #endif
00061 #if !defined(POLARSSL_PLATFORM_STD_FREE)
00062 #define POLARSSL_PLATFORM_STD_FREE       free /**< Default free to use */
00063 #endif
00064 #else /* POLARSSL_PLATFORM_NO_STD_FUNCTIONS */
00065 #if defined(POLARSSL_PLATFORM_STD_MEM_HDR)
00066 #include POLARSSL_PLATFORM_STD_MEM_HDR
00067 #endif
00068 #endif /* POLARSSL_PLATFORM_NO_STD_FUNCTIONS */
00069 
00070 /* \} name SECTION: Module settings */
00071 
00072 /*
00073  * The function pointers for malloc and free
00074  */
00075 #if defined(POLARSSL_PLATFORM_MEMORY)
00076 extern void * (*polarssl_malloc)( size_t len );
00077 extern void (*polarssl_free)( void *ptr );
00078 
00079 /**
00080  * \brief   Set your own memory implementation function pointers
00081  *
00082  * \param malloc_func   the malloc function implementation
00083  * \param free_func     the free function implementation
00084  *
00085  * \return              0 if successful
00086  */
00087 int platform_set_malloc_free( void * (*malloc_func)( size_t ),
00088                               void (*free_func)( void * ) );
00089 #else /* POLARSSL_PLATFORM_ENTROPY */
00090 #define polarssl_malloc     malloc
00091 #define polarssl_free       free
00092 #endif /* POLARSSL_PLATFORM_ENTROPY */
00093 
00094 /*
00095  * The function pointers for printf
00096  */
00097 #if defined(POLARSSL_PLATFORM_PRINTF_ALT)
00098 extern int (*polarssl_printf)( const char *format, ... );
00099 
00100 /**
00101  * \brief   Set your own printf function pointer
00102  *
00103  * \param printf_func   the printf function implementation
00104  *
00105  * \return              0
00106  */
00107 int platform_set_printf( int (*printf_func)( const char *, ... ) );
00108 #else /* POLARSSL_PLATFORM_PRINTF_ALT */
00109 #define polarssl_printf     printf
00110 #endif /* POLARSSL_PLATFORM_PRINTF_ALT */
00111 
00112 /*
00113  * The function pointers for fprintf
00114  */
00115 #if defined(POLARSSL_PLATFORM_FPRINTF_ALT)
00116 extern int (*polarssl_fprintf)( FILE *stream, const char *format, ... );
00117 
00118 int platform_set_fprintf( int (*fprintf_func)( FILE *stream, const char *,
00119                                                ... ) );
00120 #else
00121 #define polarssl_fprintf    fprintf
00122 #endif
00123 
00124 #ifdef __cplusplus
00125 }
00126 #endif
00127 
00128 #endif /* platform.h */
00129 
00130