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 threading.h
HannesTschofenig 0:796d0f61a05b 3 *
HannesTschofenig 0:796d0f61a05b 4 * \brief Threading abstraction layer
HannesTschofenig 0:796d0f61a05b 5 *
HannesTschofenig 0:796d0f61a05b 6 * Copyright (C) 2006-2013, 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_THREADING_H
HannesTschofenig 0:796d0f61a05b 28 #define POLARSSL_THREADING_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 <stdlib.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 #define POLARSSL_ERR_THREADING_FEATURE_UNAVAILABLE -0x001A /**< The selected feature is not available. */
HannesTschofenig 0:796d0f61a05b 43 #define POLARSSL_ERR_THREADING_BAD_INPUT_DATA -0x001C /**< Bad input parameters to function. */
HannesTschofenig 0:796d0f61a05b 44 #define POLARSSL_ERR_THREADING_MUTEX_ERROR -0x001E /**< Locking / unlocking / free failed with error code. */
HannesTschofenig 0:796d0f61a05b 45
HannesTschofenig 0:796d0f61a05b 46 #if defined(POLARSSL_THREADING_PTHREAD)
HannesTschofenig 0:796d0f61a05b 47 #include <pthread.h>
HannesTschofenig 0:796d0f61a05b 48 typedef pthread_mutex_t threading_mutex_t;
HannesTschofenig 0:796d0f61a05b 49 #endif
HannesTschofenig 0:796d0f61a05b 50
HannesTschofenig 0:796d0f61a05b 51 #if defined(POLARSSL_THREADING_ALT)
HannesTschofenig 0:796d0f61a05b 52 /* You should define the threading_mutex_t type in your header */
HannesTschofenig 0:796d0f61a05b 53 #include "threading_alt.h"
HannesTschofenig 0:796d0f61a05b 54
HannesTschofenig 0:796d0f61a05b 55 /**
HannesTschofenig 0:796d0f61a05b 56 * \brief Set your alternate threading implementation function
HannesTschofenig 0:796d0f61a05b 57 * pointers
HannesTschofenig 0:796d0f61a05b 58 *
HannesTschofenig 0:796d0f61a05b 59 * \param mutex_init the init function implementation
HannesTschofenig 0:796d0f61a05b 60 * \param mutex_free the free function implementation
HannesTschofenig 0:796d0f61a05b 61 * \param mutex_lock the lock function implementation
HannesTschofenig 0:796d0f61a05b 62 * \param mutex_unlock the unlock function implementation
HannesTschofenig 0:796d0f61a05b 63 *
HannesTschofenig 0:796d0f61a05b 64 * \return 0 if successful
HannesTschofenig 0:796d0f61a05b 65 */
HannesTschofenig 0:796d0f61a05b 66 int threading_set_alt( int (*mutex_init)( threading_mutex_t * ),
HannesTschofenig 0:796d0f61a05b 67 int (*mutex_free)( threading_mutex_t * ),
HannesTschofenig 0:796d0f61a05b 68 int (*mutex_lock)( threading_mutex_t * ),
HannesTschofenig 0:796d0f61a05b 69 int (*mutex_unlock)( threading_mutex_t * ) );
HannesTschofenig 0:796d0f61a05b 70 #endif /* POLARSSL_THREADING_ALT_C */
HannesTschofenig 0:796d0f61a05b 71
HannesTschofenig 0:796d0f61a05b 72 /*
HannesTschofenig 0:796d0f61a05b 73 * The function pointers for mutex_init, mutex_free, mutex_ and mutex_unlock
HannesTschofenig 0:796d0f61a05b 74 *
HannesTschofenig 0:796d0f61a05b 75 * All these functions are expected to work or the result will be undefined.
HannesTschofenig 0:796d0f61a05b 76 */
HannesTschofenig 0:796d0f61a05b 77 extern int (*polarssl_mutex_init)( threading_mutex_t *mutex );
HannesTschofenig 0:796d0f61a05b 78 extern int (*polarssl_mutex_free)( threading_mutex_t *mutex );
HannesTschofenig 0:796d0f61a05b 79 extern int (*polarssl_mutex_lock)( threading_mutex_t *mutex );
HannesTschofenig 0:796d0f61a05b 80 extern int (*polarssl_mutex_unlock)( threading_mutex_t *mutex );
HannesTschofenig 0:796d0f61a05b 81
HannesTschofenig 0:796d0f61a05b 82 #ifdef __cplusplus
HannesTschofenig 0:796d0f61a05b 83 }
HannesTschofenig 0:796d0f61a05b 84 #endif
HannesTschofenig 0:796d0f61a05b 85
HannesTschofenig 0:796d0f61a05b 86 #endif /* threading.h */
HannesTschofenig 0:796d0f61a05b 87
HannesTschofenig 0:796d0f61a05b 88