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

Dependencies:   mbed

Committer:
HannesTschofenig
Date:
Thu Sep 27 06:34:22 2018 +0000
Revision:
0:796d0f61a05b
Example AES-GCM test program

Who changed what in which revision?

UserRevisionLine numberNew contents of line
HannesTschofenig 0:796d0f61a05b 1 /**
HannesTschofenig 0:796d0f61a05b 2 * \file platform.h
HannesTschofenig 0:796d0f61a05b 3 *
HannesTschofenig 0:796d0f61a05b 4 * \brief PolarSSL Platform abstraction layer
HannesTschofenig 0:796d0f61a05b 5 *
HannesTschofenig 0:796d0f61a05b 6 * Copyright (C) 2006-2014, Brainspark B.V.
HannesTschofenig 0:796d0f61a05b 7 *
HannesTschofenig 0:796d0f61a05b 8 * This file is part of PolarSSL (http://www.polarssl.org)
HannesTschofenig 0:796d0f61a05b 9 * Lead Maintainer: Paul Bakker <polarssl_maintainer at polarssl.org>
HannesTschofenig 0:796d0f61a05b 10 *
HannesTschofenig 0:796d0f61a05b 11 * All rights reserved.
HannesTschofenig 0:796d0f61a05b 12 *
HannesTschofenig 0:796d0f61a05b 13 * This program is free software; you can redistribute it and/or modify
HannesTschofenig 0:796d0f61a05b 14 * it under the terms of the GNU General Public License as published by
HannesTschofenig 0:796d0f61a05b 15 * the Free Software Foundation; either version 2 of the License, or
HannesTschofenig 0:796d0f61a05b 16 * (at your option) any later version.
HannesTschofenig 0:796d0f61a05b 17 *
HannesTschofenig 0:796d0f61a05b 18 * This program is distributed in the hope that it will be useful,
HannesTschofenig 0:796d0f61a05b 19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
HannesTschofenig 0:796d0f61a05b 20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
HannesTschofenig 0:796d0f61a05b 21 * GNU General Public License for more details.
HannesTschofenig 0:796d0f61a05b 22 *
HannesTschofenig 0:796d0f61a05b 23 * You should have received a copy of the GNU General Public License along
HannesTschofenig 0:796d0f61a05b 24 * with this program; if not, write to the Free Software Foundation, Inc.,
HannesTschofenig 0:796d0f61a05b 25 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
HannesTschofenig 0:796d0f61a05b 26 */
HannesTschofenig 0:796d0f61a05b 27 #ifndef POLARSSL_PLATFORM_H
HannesTschofenig 0:796d0f61a05b 28 #define POLARSSL_PLATFORM_H
HannesTschofenig 0:796d0f61a05b 29
HannesTschofenig 0:796d0f61a05b 30 #if !defined(POLARSSL_CONFIG_FILE)
HannesTschofenig 0:796d0f61a05b 31 #include "config.h"
HannesTschofenig 0:796d0f61a05b 32 #else
HannesTschofenig 0:796d0f61a05b 33 #include POLARSSL_CONFIG_FILE
HannesTschofenig 0:796d0f61a05b 34 #endif
HannesTschofenig 0:796d0f61a05b 35
HannesTschofenig 0:796d0f61a05b 36 #include <stdio.h>
HannesTschofenig 0:796d0f61a05b 37
HannesTschofenig 0:796d0f61a05b 38 #ifdef __cplusplus
HannesTschofenig 0:796d0f61a05b 39 extern "C" {
HannesTschofenig 0:796d0f61a05b 40 #endif
HannesTschofenig 0:796d0f61a05b 41
HannesTschofenig 0:796d0f61a05b 42 /**
HannesTschofenig 0:796d0f61a05b 43 * \name SECTION: Module settings
HannesTschofenig 0:796d0f61a05b 44 *
HannesTschofenig 0:796d0f61a05b 45 * The configuration options you can set for this module are in this section.
HannesTschofenig 0:796d0f61a05b 46 * Either change them in config.h or define them on the compiler command line.
HannesTschofenig 0:796d0f61a05b 47 * \{
HannesTschofenig 0:796d0f61a05b 48 */
HannesTschofenig 0:796d0f61a05b 49
HannesTschofenig 0:796d0f61a05b 50 #if !defined(POLARSSL_PLATFORM_NO_STD_FUNCTIONS)
HannesTschofenig 0:796d0f61a05b 51 #include <stdlib.h>
HannesTschofenig 0:796d0f61a05b 52 #if !defined(POLARSSL_PLATFORM_STD_PRINTF)
HannesTschofenig 0:796d0f61a05b 53 #define POLARSSL_PLATFORM_STD_PRINTF printf /**< Default printf to use */
HannesTschofenig 0:796d0f61a05b 54 #endif
HannesTschofenig 0:796d0f61a05b 55 #if !defined(POLARSSL_PLATFORM_STD_FPRINTF)
HannesTschofenig 0:796d0f61a05b 56 #define POLARSSL_PLATFORM_STD_FPRINTF fprintf /**< Default fprintf to use */
HannesTschofenig 0:796d0f61a05b 57 #endif
HannesTschofenig 0:796d0f61a05b 58 #if !defined(POLARSSL_PLATFORM_STD_MALLOC)
HannesTschofenig 0:796d0f61a05b 59 #define POLARSSL_PLATFORM_STD_MALLOC malloc /**< Default allocator to use */
HannesTschofenig 0:796d0f61a05b 60 #endif
HannesTschofenig 0:796d0f61a05b 61 #if !defined(POLARSSL_PLATFORM_STD_FREE)
HannesTschofenig 0:796d0f61a05b 62 #define POLARSSL_PLATFORM_STD_FREE free /**< Default free to use */
HannesTschofenig 0:796d0f61a05b 63 #endif
HannesTschofenig 0:796d0f61a05b 64 #else /* POLARSSL_PLATFORM_NO_STD_FUNCTIONS */
HannesTschofenig 0:796d0f61a05b 65 #if defined(POLARSSL_PLATFORM_STD_MEM_HDR)
HannesTschofenig 0:796d0f61a05b 66 #include POLARSSL_PLATFORM_STD_MEM_HDR
HannesTschofenig 0:796d0f61a05b 67 #endif
HannesTschofenig 0:796d0f61a05b 68 #endif /* POLARSSL_PLATFORM_NO_STD_FUNCTIONS */
HannesTschofenig 0:796d0f61a05b 69
HannesTschofenig 0:796d0f61a05b 70 /* \} name SECTION: Module settings */
HannesTschofenig 0:796d0f61a05b 71
HannesTschofenig 0:796d0f61a05b 72 /*
HannesTschofenig 0:796d0f61a05b 73 * The function pointers for malloc and free
HannesTschofenig 0:796d0f61a05b 74 */
HannesTschofenig 0:796d0f61a05b 75 #if defined(POLARSSL_PLATFORM_MEMORY)
HannesTschofenig 0:796d0f61a05b 76 extern void * (*polarssl_malloc)( size_t len );
HannesTschofenig 0:796d0f61a05b 77 extern void (*polarssl_free)( void *ptr );
HannesTschofenig 0:796d0f61a05b 78
HannesTschofenig 0:796d0f61a05b 79 /**
HannesTschofenig 0:796d0f61a05b 80 * \brief Set your own memory implementation function pointers
HannesTschofenig 0:796d0f61a05b 81 *
HannesTschofenig 0:796d0f61a05b 82 * \param malloc_func the malloc function implementation
HannesTschofenig 0:796d0f61a05b 83 * \param free_func the free function implementation
HannesTschofenig 0:796d0f61a05b 84 *
HannesTschofenig 0:796d0f61a05b 85 * \return 0 if successful
HannesTschofenig 0:796d0f61a05b 86 */
HannesTschofenig 0:796d0f61a05b 87 int platform_set_malloc_free( void * (*malloc_func)( size_t ),
HannesTschofenig 0:796d0f61a05b 88 void (*free_func)( void * ) );
HannesTschofenig 0:796d0f61a05b 89 #else /* POLARSSL_PLATFORM_ENTROPY */
HannesTschofenig 0:796d0f61a05b 90 #define polarssl_malloc malloc
HannesTschofenig 0:796d0f61a05b 91 #define polarssl_free free
HannesTschofenig 0:796d0f61a05b 92 #endif /* POLARSSL_PLATFORM_ENTROPY */
HannesTschofenig 0:796d0f61a05b 93
HannesTschofenig 0:796d0f61a05b 94 /*
HannesTschofenig 0:796d0f61a05b 95 * The function pointers for printf
HannesTschofenig 0:796d0f61a05b 96 */
HannesTschofenig 0:796d0f61a05b 97 #if defined(POLARSSL_PLATFORM_PRINTF_ALT)
HannesTschofenig 0:796d0f61a05b 98 extern int (*polarssl_printf)( const char *format, ... );
HannesTschofenig 0:796d0f61a05b 99
HannesTschofenig 0:796d0f61a05b 100 /**
HannesTschofenig 0:796d0f61a05b 101 * \brief Set your own printf function pointer
HannesTschofenig 0:796d0f61a05b 102 *
HannesTschofenig 0:796d0f61a05b 103 * \param printf_func the printf function implementation
HannesTschofenig 0:796d0f61a05b 104 *
HannesTschofenig 0:796d0f61a05b 105 * \return 0
HannesTschofenig 0:796d0f61a05b 106 */
HannesTschofenig 0:796d0f61a05b 107 int platform_set_printf( int (*printf_func)( const char *, ... ) );
HannesTschofenig 0:796d0f61a05b 108 #else /* POLARSSL_PLATFORM_PRINTF_ALT */
HannesTschofenig 0:796d0f61a05b 109 #define polarssl_printf printf
HannesTschofenig 0:796d0f61a05b 110 #endif /* POLARSSL_PLATFORM_PRINTF_ALT */
HannesTschofenig 0:796d0f61a05b 111
HannesTschofenig 0:796d0f61a05b 112 /*
HannesTschofenig 0:796d0f61a05b 113 * The function pointers for fprintf
HannesTschofenig 0:796d0f61a05b 114 */
HannesTschofenig 0:796d0f61a05b 115 #if defined(POLARSSL_PLATFORM_FPRINTF_ALT)
HannesTschofenig 0:796d0f61a05b 116 extern int (*polarssl_fprintf)( FILE *stream, const char *format, ... );
HannesTschofenig 0:796d0f61a05b 117
HannesTschofenig 0:796d0f61a05b 118 int platform_set_fprintf( int (*fprintf_func)( FILE *stream, const char *,
HannesTschofenig 0:796d0f61a05b 119 ... ) );
HannesTschofenig 0:796d0f61a05b 120 #else
HannesTschofenig 0:796d0f61a05b 121 #define polarssl_fprintf fprintf
HannesTschofenig 0:796d0f61a05b 122 #endif
HannesTschofenig 0:796d0f61a05b 123
HannesTschofenig 0:796d0f61a05b 124 #ifdef __cplusplus
HannesTschofenig 0:796d0f61a05b 125 }
HannesTschofenig 0:796d0f61a05b 126 #endif
HannesTschofenig 0:796d0f61a05b 127
HannesTschofenig 0:796d0f61a05b 128 #endif /* platform.h */
HannesTschofenig 0:796d0f61a05b 129
HannesTschofenig 0:796d0f61a05b 130