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 timing.h
HannesTschofenig 0:796d0f61a05b 3 *
HannesTschofenig 0:796d0f61a05b 4 * \brief Portable interface to the CPU cycle counter
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_TIMING_H
HannesTschofenig 0:796d0f61a05b 28 #define POLARSSL_TIMING_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 #if !defined(POLARSSL_TIMING_ALT)
HannesTschofenig 0:796d0f61a05b 37 // Regular implementation
HannesTschofenig 0:796d0f61a05b 38 //
HannesTschofenig 0:796d0f61a05b 39
HannesTschofenig 0:796d0f61a05b 40 #ifdef __cplusplus
HannesTschofenig 0:796d0f61a05b 41 extern "C" {
HannesTschofenig 0:796d0f61a05b 42 #endif
HannesTschofenig 0:796d0f61a05b 43
HannesTschofenig 0:796d0f61a05b 44 /**
HannesTschofenig 0:796d0f61a05b 45 * \brief timer structure
HannesTschofenig 0:796d0f61a05b 46 */
HannesTschofenig 0:796d0f61a05b 47 struct hr_time
HannesTschofenig 0:796d0f61a05b 48 {
HannesTschofenig 0:796d0f61a05b 49 unsigned char opaque[32];
HannesTschofenig 0:796d0f61a05b 50 };
HannesTschofenig 0:796d0f61a05b 51
HannesTschofenig 0:796d0f61a05b 52 extern volatile int alarmed;
HannesTschofenig 0:796d0f61a05b 53
HannesTschofenig 0:796d0f61a05b 54 /**
HannesTschofenig 0:796d0f61a05b 55 * \brief Return the CPU cycle counter value
HannesTschofenig 0:796d0f61a05b 56 */
HannesTschofenig 0:796d0f61a05b 57 unsigned long hardclock( void );
HannesTschofenig 0:796d0f61a05b 58
HannesTschofenig 0:796d0f61a05b 59 /**
HannesTschofenig 0:796d0f61a05b 60 * \brief Return the elapsed time in milliseconds
HannesTschofenig 0:796d0f61a05b 61 *
HannesTschofenig 0:796d0f61a05b 62 * \param val points to a timer structure
HannesTschofenig 0:796d0f61a05b 63 * \param reset if set to 1, the timer is restarted
HannesTschofenig 0:796d0f61a05b 64 */
HannesTschofenig 0:796d0f61a05b 65 unsigned long get_timer( struct hr_time *val, int reset );
HannesTschofenig 0:796d0f61a05b 66
HannesTschofenig 0:796d0f61a05b 67 /**
HannesTschofenig 0:796d0f61a05b 68 * \brief Setup an alarm clock
HannesTschofenig 0:796d0f61a05b 69 *
HannesTschofenig 0:796d0f61a05b 70 * \param seconds delay before the "alarmed" flag is set
HannesTschofenig 0:796d0f61a05b 71 */
HannesTschofenig 0:796d0f61a05b 72 void set_alarm( int seconds );
HannesTschofenig 0:796d0f61a05b 73
HannesTschofenig 0:796d0f61a05b 74 /**
HannesTschofenig 0:796d0f61a05b 75 * \brief Sleep for a certain amount of time
HannesTschofenig 0:796d0f61a05b 76 *
HannesTschofenig 0:796d0f61a05b 77 * \param milliseconds delay in milliseconds
HannesTschofenig 0:796d0f61a05b 78 */
HannesTschofenig 0:796d0f61a05b 79 void m_sleep( int milliseconds );
HannesTschofenig 0:796d0f61a05b 80
HannesTschofenig 0:796d0f61a05b 81 #if defined(POLARSSL_SELF_TEST)
HannesTschofenig 0:796d0f61a05b 82 /**
HannesTschofenig 0:796d0f61a05b 83 * \brief Checkup routine
HannesTschofenig 0:796d0f61a05b 84 *
HannesTschofenig 0:796d0f61a05b 85 * \return 0 if successful, or 1 if a test failed
HannesTschofenig 0:796d0f61a05b 86 */
HannesTschofenig 0:796d0f61a05b 87 int timing_self_test( int verbose );
HannesTschofenig 0:796d0f61a05b 88 #endif
HannesTschofenig 0:796d0f61a05b 89
HannesTschofenig 0:796d0f61a05b 90 #ifdef __cplusplus
HannesTschofenig 0:796d0f61a05b 91 }
HannesTschofenig 0:796d0f61a05b 92 #endif
HannesTschofenig 0:796d0f61a05b 93
HannesTschofenig 0:796d0f61a05b 94 #else /* POLARSSL_TIMING_ALT */
HannesTschofenig 0:796d0f61a05b 95 #include "timing_alt.h"
HannesTschofenig 0:796d0f61a05b 96 #endif /* POLARSSL_TIMING_ALT */
HannesTschofenig 0:796d0f61a05b 97
HannesTschofenig 0:796d0f61a05b 98 #endif /* timing.h */
HannesTschofenig 0:796d0f61a05b 99
HannesTschofenig 0:796d0f61a05b 100