Paul Bakker | 5121ce5 | 2009-01-03 21:22:43 +0000 | [diff] [blame] | 1 | /* |
| 2 | * Benchmark demonstration program |
| 3 | * |
Manuel Pégourié-Gonnard | a658a40 | 2015-01-23 09:45:19 +0000 | [diff] [blame] | 4 | * Copyright (C) 2006-2013, ARM Limited, All Rights Reserved |
Paul Bakker | b96f154 | 2010-07-18 20:36:00 +0000 | [diff] [blame] | 5 | * |
Manuel Pégourié-Gonnard | 860b516 | 2015-01-28 17:12:07 +0000 | [diff] [blame] | 6 | * This file is part of mbed TLS (https://polarssl.org) |
Paul Bakker | b96f154 | 2010-07-18 20:36:00 +0000 | [diff] [blame] | 7 | * |
Paul Bakker | 5121ce5 | 2009-01-03 21:22:43 +0000 | [diff] [blame] | 8 | * This program is free software; you can redistribute it and/or modify |
| 9 | * it under the terms of the GNU General Public License as published by |
| 10 | * the Free Software Foundation; either version 2 of the License, or |
| 11 | * (at your option) any later version. |
| 12 | * |
| 13 | * This program is distributed in the hope that it will be useful, |
| 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 16 | * GNU General Public License for more details. |
| 17 | * |
| 18 | * You should have received a copy of the GNU General Public License along |
| 19 | * with this program; if not, write to the Free Software Foundation, Inc., |
| 20 | * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. |
| 21 | */ |
| 22 | |
Manuel Pégourié-Gonnard | cef4ad2 | 2014-04-29 12:39:06 +0200 | [diff] [blame] | 23 | #if !defined(POLARSSL_CONFIG_FILE) |
Manuel Pégourié-Gonnard | abd6e02 | 2013-09-20 13:30:43 +0200 | [diff] [blame] | 24 | #include "polarssl/config.h" |
Manuel Pégourié-Gonnard | cef4ad2 | 2014-04-29 12:39:06 +0200 | [diff] [blame] | 25 | #else |
| 26 | #include POLARSSL_CONFIG_FILE |
| 27 | #endif |
Paul Bakker | 5121ce5 | 2009-01-03 21:22:43 +0000 | [diff] [blame] | 28 | |
Rich Evans | f90016a | 2015-01-19 14:26:37 +0000 | [diff] [blame] | 29 | #if defined(POLARSSL_PLATFORM_C) |
| 30 | #include "polarssl/platform.h" |
| 31 | #else |
Rich Evans | 18b78c7 | 2015-02-11 14:06:19 +0000 | [diff] [blame] | 32 | #include <stdio.h> |
Rich Evans | 77d3638 | 2015-01-30 12:12:11 +0000 | [diff] [blame] | 33 | #define polarssl_exit exit |
Rich Evans | b92965b | 2015-01-30 11:11:57 +0000 | [diff] [blame] | 34 | #define polarssl_printf printf |
| 35 | #define polarssl_snprintf snprintf |
Rich Evans | 012acfc | 2015-01-30 12:12:11 +0000 | [diff] [blame] | 36 | #define polarssl_exit exit |
Rich Evans | f90016a | 2015-01-19 14:26:37 +0000 | [diff] [blame] | 37 | #endif |
| 38 | |
Manuel Pégourié-Gonnard | 50da048 | 2014-12-19 12:10:37 +0100 | [diff] [blame] | 39 | /* |
| 40 | * For heap usage estimates, we need an estimate of the overhead per allocated |
| 41 | * block. ptmalloc2/3 (used in gnu libc for instance) uses 2 size_t per block, |
| 42 | * so use that as our baseline. |
| 43 | */ |
| 44 | #define MEM_BLOCK_OVERHEAD ( 2 * sizeof( size_t ) ) |
| 45 | |
| 46 | /* |
| 47 | * Size to use for the malloc buffer if MEMORY_BUFFER_ALLOC_C is defined. |
| 48 | */ |
| 49 | #define HEAP_SIZE (1u << 16) // 64k |
| 50 | |
Rich Evans | 18b78c7 | 2015-02-11 14:06:19 +0000 | [diff] [blame] | 51 | #if defined(POLARSSL_TIMING_C) |
Manuel Pégourié-Gonnard | 8271f2f | 2013-09-17 14:57:55 +0200 | [diff] [blame] | 52 | #include "polarssl/timing.h" |
Paul Bakker | 5121ce5 | 2009-01-03 21:22:43 +0000 | [diff] [blame] | 53 | |
Paul Bakker | 40e4694 | 2009-01-03 21:51:57 +0000 | [diff] [blame] | 54 | #include "polarssl/md4.h" |
| 55 | #include "polarssl/md5.h" |
Paul Bakker | 61b699e | 2014-01-22 13:35:29 +0100 | [diff] [blame] | 56 | #include "polarssl/ripemd160.h" |
Paul Bakker | 40e4694 | 2009-01-03 21:51:57 +0000 | [diff] [blame] | 57 | #include "polarssl/sha1.h" |
Paul Bakker | d2681d8 | 2013-06-30 14:49:12 +0200 | [diff] [blame] | 58 | #include "polarssl/sha256.h" |
| 59 | #include "polarssl/sha512.h" |
Paul Bakker | 40e4694 | 2009-01-03 21:51:57 +0000 | [diff] [blame] | 60 | #include "polarssl/arc4.h" |
| 61 | #include "polarssl/des.h" |
| 62 | #include "polarssl/aes.h" |
Paul Bakker | 3d58fe8 | 2012-07-04 17:15:31 +0000 | [diff] [blame] | 63 | #include "polarssl/blowfish.h" |
Paul Bakker | 38119b1 | 2009-01-10 23:31:23 +0000 | [diff] [blame] | 64 | #include "polarssl/camellia.h" |
Paul Bakker | 89e80c9 | 2012-03-20 13:50:09 +0000 | [diff] [blame] | 65 | #include "polarssl/gcm.h" |
Manuel Pégourié-Gonnard | 58d78a8 | 2014-05-07 12:03:02 +0200 | [diff] [blame] | 66 | #include "polarssl/ccm.h" |
Manuel Pégourié-Gonnard | cc34f95 | 2013-09-17 16:04:08 +0200 | [diff] [blame] | 67 | #include "polarssl/havege.h" |
Manuel Pégourié-Gonnard | 8271f2f | 2013-09-17 14:57:55 +0200 | [diff] [blame] | 68 | #include "polarssl/ctr_drbg.h" |
Manuel Pégourié-Gonnard | fef0f8f | 2014-01-30 20:59:00 +0100 | [diff] [blame] | 69 | #include "polarssl/hmac_drbg.h" |
Paul Bakker | 40e4694 | 2009-01-03 21:51:57 +0000 | [diff] [blame] | 70 | #include "polarssl/rsa.h" |
Manuel Pégourié-Gonnard | e870c0a | 2012-11-08 11:31:48 +0100 | [diff] [blame] | 71 | #include "polarssl/dhm.h" |
Manuel Pégourié-Gonnard | cc34f95 | 2013-09-17 16:04:08 +0200 | [diff] [blame] | 72 | #include "polarssl/ecdsa.h" |
| 73 | #include "polarssl/ecdh.h" |
Gergely Budai | a5d336b | 2014-01-27 23:27:06 +0100 | [diff] [blame] | 74 | #include "polarssl/error.h" |
Paul Bakker | 5121ce5 | 2009-01-03 21:22:43 +0000 | [diff] [blame] | 75 | |
Manuel Pégourié-Gonnard | 128657d | 2014-12-18 16:35:52 +0000 | [diff] [blame] | 76 | #if defined(POLARSSL_MEMORY_BUFFER_ALLOC_C) |
| 77 | #include "polarssl/memory_buffer_alloc.h" |
Rich Evans | 18b78c7 | 2015-02-11 14:06:19 +0000 | [diff] [blame] | 78 | #endif |
| 79 | |
Manuel Pégourié-Gonnard | 2f77ce3 | 2013-10-03 11:59:57 +0200 | [diff] [blame] | 80 | #if defined _MSC_VER && !defined snprintf |
| 81 | #define snprintf _snprintf |
| 82 | #endif |
| 83 | |
Paul Bakker | 02faf45 | 2011-11-29 11:23:58 +0000 | [diff] [blame] | 84 | #define BUFSIZE 1024 |
Manuel Pégourié-Gonnard | fef0f8f | 2014-01-30 20:59:00 +0100 | [diff] [blame] | 85 | #define HEADER_FORMAT " %-24s : " |
Gergely Budai | a5d336b | 2014-01-27 23:27:06 +0100 | [diff] [blame] | 86 | #define TITLE_LEN 25 |
Manuel Pégourié-Gonnard | 6c5abfa | 2015-02-13 14:12:07 +0000 | [diff] [blame] | 87 | |
Rich Evans | 85b05ec | 2015-02-12 11:37:29 +0000 | [diff] [blame] | 88 | #define DHM_SIZES 3 |
| 89 | |
| 90 | #define OPTIONS \ |
| 91 | "md4, md5, ripemd160, sha1, sha256, sha512,\n" \ |
| 92 | "arc4, des3, des, aes_cbc, aes_gcm, aes_ccm, camellia, blowfish,\n" \ |
| 93 | "havege, ctr_drbg, hmac_drbg\n" \ |
| 94 | "rsa, dhm, ecdsa, ecdh.\n" |
| 95 | |
| 96 | #if defined(POLARSSL_ERROR_C) |
| 97 | #define PRINT_ERROR \ |
| 98 | polarssl_strerror( ret, ( char * )tmp, sizeof( tmp ) ); \ |
| 99 | polarssl_printf( "FAILED: %s\n", tmp ); |
| 100 | #else |
| 101 | #define PRINT_ERROR \ |
| 102 | polarssl_printf( "FAILED: -0x%04x\n", -ret ); |
| 103 | #endif |
| 104 | |
| 105 | #define TIME_AND_TSC( TITLE, CODE ) \ |
| 106 | do { \ |
| 107 | unsigned long i, j, tsc; \ |
| 108 | \ |
| 109 | polarssl_printf( HEADER_FORMAT, TITLE ); \ |
| 110 | fflush( stdout ); \ |
| 111 | \ |
| 112 | set_alarm( 1 ); \ |
| 113 | for( i = 1; ! alarmed; i++ ) \ |
| 114 | { \ |
| 115 | CODE; \ |
| 116 | } \ |
| 117 | \ |
| 118 | tsc = hardclock(); \ |
| 119 | for( j = 0; j < 1024; j++ ) \ |
| 120 | { \ |
| 121 | CODE; \ |
| 122 | } \ |
| 123 | \ |
| 124 | polarssl_printf( "%9lu Kb/s, %9lu cycles/byte\n", i * BUFSIZE / 1024, \ |
| 125 | ( hardclock() - tsc ) / ( j * BUFSIZE ) ); \ |
| 126 | } while( 0 ) |
| 127 | |
Manuel Pégourié-Gonnard | 50da048 | 2014-12-19 12:10:37 +0100 | [diff] [blame] | 128 | #if defined(POLARSSL_ERROR_C) |
| 129 | #define PRINT_ERROR \ |
| 130 | polarssl_strerror( ret, ( char * )tmp, sizeof( tmp ) ); \ |
| 131 | polarssl_printf( "FAILED: %s\n", tmp ); |
| 132 | #else |
| 133 | #define PRINT_ERROR \ |
| 134 | polarssl_printf( "FAILED: -0x%04x\n", -ret ); |
| 135 | #endif |
| 136 | |
| 137 | #if defined(POLARSSL_MEMORY_BUFFER_ALLOC_C) && defined(POLARSSL_MEMORY_DEBUG) |
| 138 | |
| 139 | #define MEMORY_MEASURE_INIT \ |
| 140 | size_t max_used, max_blocks, max_bytes; \ |
| 141 | size_t prv_used, prv_blocks; \ |
| 142 | memory_buffer_alloc_cur_get( &prv_used, &prv_blocks ); \ |
| 143 | memory_buffer_alloc_max_reset( ); |
| 144 | |
| 145 | #define MEMORY_MEASURE_PRINT( title_len ) \ |
| 146 | memory_buffer_alloc_max_get( &max_used, &max_blocks ); \ |
| 147 | for( i = 12 - title_len; i != 0; i-- ) polarssl_printf( " " ); \ |
| 148 | max_used -= prv_used; \ |
| 149 | max_blocks -= prv_blocks; \ |
| 150 | max_bytes = max_used + MEM_BLOCK_OVERHEAD * max_blocks; \ |
| 151 | polarssl_printf( "%6u heap bytes", (unsigned) max_bytes ); |
| 152 | |
| 153 | #else |
Manuel Pégourié-Gonnard | e579dab | 2015-01-29 16:28:44 +0000 | [diff] [blame^] | 154 | #define MEMORY_MEASURE_INIT |
| 155 | #define MEMORY_MEASURE_PRINT( title_len ) |
Manuel Pégourié-Gonnard | 50da048 | 2014-12-19 12:10:37 +0100 | [diff] [blame] | 156 | #endif |
| 157 | |
Rich Evans | 85b05ec | 2015-02-12 11:37:29 +0000 | [diff] [blame] | 158 | #define TIME_PUBLIC( TITLE, TYPE, CODE ) \ |
| 159 | do { \ |
| 160 | unsigned long i; \ |
| 161 | int ret; \ |
Manuel Pégourié-Gonnard | 50da048 | 2014-12-19 12:10:37 +0100 | [diff] [blame] | 162 | MEMORY_MEASURE_INIT; \ |
Rich Evans | 85b05ec | 2015-02-12 11:37:29 +0000 | [diff] [blame] | 163 | \ |
Manuel Pégourié-Gonnard | 50da048 | 2014-12-19 12:10:37 +0100 | [diff] [blame] | 164 | polarssl_printf( HEADER_FORMAT, TITLE ); \ |
Rich Evans | 85b05ec | 2015-02-12 11:37:29 +0000 | [diff] [blame] | 165 | fflush( stdout ); \ |
| 166 | set_alarm( 3 ); \ |
| 167 | \ |
| 168 | ret = 0; \ |
| 169 | for( i = 1; ! alarmed && ! ret ; i++ ) \ |
| 170 | { \ |
| 171 | CODE; \ |
| 172 | } \ |
| 173 | \ |
| 174 | if( ret != 0 ) \ |
| 175 | { \ |
Manuel Pégourié-Gonnard | 50da048 | 2014-12-19 12:10:37 +0100 | [diff] [blame] | 176 | PRINT_ERROR; \ |
Rich Evans | 85b05ec | 2015-02-12 11:37:29 +0000 | [diff] [blame] | 177 | } \ |
| 178 | else \ |
Manuel Pégourié-Gonnard | 50da048 | 2014-12-19 12:10:37 +0100 | [diff] [blame] | 179 | { \ |
| 180 | polarssl_printf( "%6lu " TYPE "/s", i / 3 ); \ |
| 181 | MEMORY_MEASURE_PRINT( sizeof( TYPE ) + 1 ); \ |
| 182 | polarssl_printf( "\n" ); \ |
| 183 | } \ |
Rich Evans | 85b05ec | 2015-02-12 11:37:29 +0000 | [diff] [blame] | 184 | } while( 0 ) |
Paul Bakker | 5121ce5 | 2009-01-03 21:22:43 +0000 | [diff] [blame] | 185 | |
Manuel Pégourié-Gonnard | 8271f2f | 2013-09-17 14:57:55 +0200 | [diff] [blame] | 186 | #if !defined(POLARSSL_TIMING_C) |
Rich Evans | 85b05ec | 2015-02-12 11:37:29 +0000 | [diff] [blame] | 187 | int main( void ) |
Manuel Pégourié-Gonnard | 8271f2f | 2013-09-17 14:57:55 +0200 | [diff] [blame] | 188 | { |
Rich Evans | f90016a | 2015-01-19 14:26:37 +0000 | [diff] [blame] | 189 | polarssl_printf("POLARSSL_TIMING_C not defined.\n"); |
Manuel Pégourié-Gonnard | 8271f2f | 2013-09-17 14:57:55 +0200 | [diff] [blame] | 190 | return( 0 ); |
| 191 | } |
| 192 | #else |
Paul Bakker | a3d195c | 2011-11-27 21:07:34 +0000 | [diff] [blame] | 193 | static int myrand( void *rng_state, unsigned char *output, size_t len ) |
Paul Bakker | 5121ce5 | 2009-01-03 21:22:43 +0000 | [diff] [blame] | 194 | { |
Paul Bakker | a3d195c | 2011-11-27 21:07:34 +0000 | [diff] [blame] | 195 | size_t use_len; |
| 196 | int rnd; |
| 197 | |
Paul Bakker | 5121ce5 | 2009-01-03 21:22:43 +0000 | [diff] [blame] | 198 | if( rng_state != NULL ) |
| 199 | rng_state = NULL; |
| 200 | |
Paul Bakker | a3d195c | 2011-11-27 21:07:34 +0000 | [diff] [blame] | 201 | while( len > 0 ) |
| 202 | { |
| 203 | use_len = len; |
| 204 | if( use_len > sizeof(int) ) |
| 205 | use_len = sizeof(int); |
| 206 | |
| 207 | rnd = rand(); |
| 208 | memcpy( output, &rnd, use_len ); |
| 209 | output += use_len; |
| 210 | len -= use_len; |
| 211 | } |
| 212 | |
| 213 | return( 0 ); |
Paul Bakker | 5121ce5 | 2009-01-03 21:22:43 +0000 | [diff] [blame] | 214 | } |
| 215 | |
Manuel Pégourié-Gonnard | 50da048 | 2014-12-19 12:10:37 +0100 | [diff] [blame] | 216 | /* |
| 217 | * Clear some memory that was used to prepare the context |
| 218 | */ |
| 219 | #if defined(POLARSSL_ECP_C) |
| 220 | void ecp_clear_precomputed( ecp_group *grp ) |
| 221 | { |
| 222 | if( grp->T != NULL ) |
| 223 | { |
| 224 | size_t i; |
| 225 | for( i = 0; i < grp->T_size; i++ ) |
| 226 | ecp_point_free( &grp->T[i] ); |
| 227 | polarssl_free( grp->T ); |
| 228 | } |
| 229 | grp->T = NULL; |
| 230 | grp->T_size = 0; |
| 231 | } |
| 232 | #else |
| 233 | #define ecp_clear_precomputed( g ) |
| 234 | #endif |
| 235 | |
Paul Bakker | 5121ce5 | 2009-01-03 21:22:43 +0000 | [diff] [blame] | 236 | unsigned char buf[BUFSIZE]; |
| 237 | |
Manuel Pégourié-Gonnard | ed7cbe9 | 2013-09-17 15:30:51 +0200 | [diff] [blame] | 238 | typedef struct { |
Paul Bakker | 61b699e | 2014-01-22 13:35:29 +0100 | [diff] [blame] | 239 | char md4, md5, ripemd160, sha1, sha256, sha512, |
Manuel Pégourié-Gonnard | 58d78a8 | 2014-05-07 12:03:02 +0200 | [diff] [blame] | 240 | arc4, des3, des, aes_cbc, aes_gcm, aes_ccm, camellia, blowfish, |
Manuel Pégourié-Gonnard | fef0f8f | 2014-01-30 20:59:00 +0100 | [diff] [blame] | 241 | havege, ctr_drbg, hmac_drbg, |
Manuel Pégourié-Gonnard | cc34f95 | 2013-09-17 16:04:08 +0200 | [diff] [blame] | 242 | rsa, dhm, ecdsa, ecdh; |
Manuel Pégourié-Gonnard | ed7cbe9 | 2013-09-17 15:30:51 +0200 | [diff] [blame] | 243 | } todo_list; |
| 244 | |
Paul Bakker | cce9d77 | 2011-11-18 14:26:47 +0000 | [diff] [blame] | 245 | int main( int argc, char *argv[] ) |
Paul Bakker | 5690efc | 2011-05-26 13:16:06 +0000 | [diff] [blame] | 246 | { |
Manuel Pégourié-Gonnard | 71e75dc | 2014-12-19 18:05:43 +0100 | [diff] [blame] | 247 | int i; |
Manuel Pégourié-Gonnard | cc34f95 | 2013-09-17 16:04:08 +0200 | [diff] [blame] | 248 | unsigned char tmp[200]; |
Manuel Pégourié-Gonnard | 8271f2f | 2013-09-17 14:57:55 +0200 | [diff] [blame] | 249 | char title[TITLE_LEN]; |
Manuel Pégourié-Gonnard | ed7cbe9 | 2013-09-17 15:30:51 +0200 | [diff] [blame] | 250 | todo_list todo; |
Manuel Pégourié-Gonnard | 128657d | 2014-12-18 16:35:52 +0000 | [diff] [blame] | 251 | #if defined(POLARSSL_MEMORY_BUFFER_ALLOC_C) |
Manuel Pégourié-Gonnard | 50da048 | 2014-12-19 12:10:37 +0100 | [diff] [blame] | 252 | unsigned char malloc_buf[HEAP_SIZE] = { 0 }; |
Manuel Pégourié-Gonnard | 128657d | 2014-12-18 16:35:52 +0000 | [diff] [blame] | 253 | #endif |
Paul Bakker | cce9d77 | 2011-11-18 14:26:47 +0000 | [diff] [blame] | 254 | |
Manuel Pégourié-Gonnard | ed7cbe9 | 2013-09-17 15:30:51 +0200 | [diff] [blame] | 255 | if( argc == 1 ) |
| 256 | memset( &todo, 1, sizeof( todo ) ); |
| 257 | else |
| 258 | { |
| 259 | memset( &todo, 0, sizeof( todo ) ); |
| 260 | |
| 261 | for( i = 1; i < argc; i++ ) |
| 262 | { |
| 263 | if( strcmp( argv[i], "md4" ) == 0 ) |
| 264 | todo.md4 = 1; |
| 265 | else if( strcmp( argv[i], "md5" ) == 0 ) |
| 266 | todo.md5 = 1; |
Paul Bakker | 61b699e | 2014-01-22 13:35:29 +0100 | [diff] [blame] | 267 | else if( strcmp( argv[i], "ripemd160" ) == 0 ) |
| 268 | todo.ripemd160 = 1; |
Manuel Pégourié-Gonnard | ed7cbe9 | 2013-09-17 15:30:51 +0200 | [diff] [blame] | 269 | else if( strcmp( argv[i], "sha1" ) == 0 ) |
| 270 | todo.sha1 = 1; |
| 271 | else if( strcmp( argv[i], "sha256" ) == 0 ) |
| 272 | todo.sha256 = 1; |
| 273 | else if( strcmp( argv[i], "sha512" ) == 0 ) |
| 274 | todo.sha512 = 1; |
| 275 | else if( strcmp( argv[i], "arc4" ) == 0 ) |
| 276 | todo.arc4 = 1; |
| 277 | else if( strcmp( argv[i], "des3" ) == 0 ) |
| 278 | todo.des3 = 1; |
| 279 | else if( strcmp( argv[i], "des" ) == 0 ) |
| 280 | todo.des = 1; |
| 281 | else if( strcmp( argv[i], "aes_cbc" ) == 0 ) |
| 282 | todo.aes_cbc = 1; |
| 283 | else if( strcmp( argv[i], "aes_gcm" ) == 0 ) |
| 284 | todo.aes_gcm = 1; |
Manuel Pégourié-Gonnard | 58d78a8 | 2014-05-07 12:03:02 +0200 | [diff] [blame] | 285 | else if( strcmp( argv[i], "aes_ccm" ) == 0 ) |
| 286 | todo.aes_ccm = 1; |
Manuel Pégourié-Gonnard | ed7cbe9 | 2013-09-17 15:30:51 +0200 | [diff] [blame] | 287 | else if( strcmp( argv[i], "camellia" ) == 0 ) |
| 288 | todo.camellia = 1; |
| 289 | else if( strcmp( argv[i], "blowfish" ) == 0 ) |
| 290 | todo.blowfish = 1; |
| 291 | else if( strcmp( argv[i], "havege" ) == 0 ) |
| 292 | todo.havege = 1; |
| 293 | else if( strcmp( argv[i], "ctr_drbg" ) == 0 ) |
| 294 | todo.ctr_drbg = 1; |
Manuel Pégourié-Gonnard | fef0f8f | 2014-01-30 20:59:00 +0100 | [diff] [blame] | 295 | else if( strcmp( argv[i], "hmac_drbg" ) == 0 ) |
| 296 | todo.hmac_drbg = 1; |
Manuel Pégourié-Gonnard | ed7cbe9 | 2013-09-17 15:30:51 +0200 | [diff] [blame] | 297 | else if( strcmp( argv[i], "rsa" ) == 0 ) |
| 298 | todo.rsa = 1; |
| 299 | else if( strcmp( argv[i], "dhm" ) == 0 ) |
| 300 | todo.dhm = 1; |
Manuel Pégourié-Gonnard | cc34f95 | 2013-09-17 16:04:08 +0200 | [diff] [blame] | 301 | else if( strcmp( argv[i], "ecdsa" ) == 0 ) |
| 302 | todo.ecdsa = 1; |
| 303 | else if( strcmp( argv[i], "ecdh" ) == 0 ) |
| 304 | todo.ecdh = 1; |
Manuel Pégourié-Gonnard | ed7cbe9 | 2013-09-17 15:30:51 +0200 | [diff] [blame] | 305 | else |
| 306 | { |
Rich Evans | f90016a | 2015-01-19 14:26:37 +0000 | [diff] [blame] | 307 | polarssl_printf( "Unrecognized option: %s\n", argv[i] ); |
| 308 | polarssl_printf( "Available options: " OPTIONS ); |
Manuel Pégourié-Gonnard | ed7cbe9 | 2013-09-17 15:30:51 +0200 | [diff] [blame] | 309 | } |
| 310 | } |
| 311 | } |
Paul Bakker | 5121ce5 | 2009-01-03 21:22:43 +0000 | [diff] [blame] | 312 | |
Rich Evans | f90016a | 2015-01-19 14:26:37 +0000 | [diff] [blame] | 313 | polarssl_printf( "\n" ); |
Paul Bakker | 5121ce5 | 2009-01-03 21:22:43 +0000 | [diff] [blame] | 314 | |
Manuel Pégourié-Gonnard | 128657d | 2014-12-18 16:35:52 +0000 | [diff] [blame] | 315 | #if defined(POLARSSL_MEMORY_BUFFER_ALLOC_C) |
| 316 | memory_buffer_alloc_init( malloc_buf, sizeof( malloc_buf ) ); |
| 317 | #endif |
Manuel Pégourié-Gonnard | ed7cbe9 | 2013-09-17 15:30:51 +0200 | [diff] [blame] | 318 | memset( buf, 0xAA, sizeof( buf ) ); |
Paul Bakker | df71dd1 | 2014-04-17 16:03:48 +0200 | [diff] [blame] | 319 | memset( tmp, 0xBB, sizeof( tmp ) ); |
Manuel Pégourié-Gonnard | ed7cbe9 | 2013-09-17 15:30:51 +0200 | [diff] [blame] | 320 | |
Paul Bakker | 40e4694 | 2009-01-03 21:51:57 +0000 | [diff] [blame] | 321 | #if defined(POLARSSL_MD4_C) |
Manuel Pégourié-Gonnard | ed7cbe9 | 2013-09-17 15:30:51 +0200 | [diff] [blame] | 322 | if( todo.md4 ) |
| 323 | TIME_AND_TSC( "MD4", md4( buf, BUFSIZE, tmp ) ); |
Paul Bakker | 5121ce5 | 2009-01-03 21:22:43 +0000 | [diff] [blame] | 324 | #endif |
| 325 | |
Paul Bakker | 40e4694 | 2009-01-03 21:51:57 +0000 | [diff] [blame] | 326 | #if defined(POLARSSL_MD5_C) |
Manuel Pégourié-Gonnard | ed7cbe9 | 2013-09-17 15:30:51 +0200 | [diff] [blame] | 327 | if( todo.md5 ) |
| 328 | TIME_AND_TSC( "MD5", md5( buf, BUFSIZE, tmp ) ); |
Paul Bakker | 5121ce5 | 2009-01-03 21:22:43 +0000 | [diff] [blame] | 329 | #endif |
| 330 | |
Paul Bakker | 61b699e | 2014-01-22 13:35:29 +0100 | [diff] [blame] | 331 | #if defined(POLARSSL_RIPEMD160_C) |
| 332 | if( todo.ripemd160 ) |
| 333 | TIME_AND_TSC( "RIPEMD160", ripemd160( buf, BUFSIZE, tmp ) ); |
Manuel Pégourié-Gonnard | 01b0b38 | 2014-01-17 14:29:46 +0100 | [diff] [blame] | 334 | #endif |
| 335 | |
Paul Bakker | 40e4694 | 2009-01-03 21:51:57 +0000 | [diff] [blame] | 336 | #if defined(POLARSSL_SHA1_C) |
Manuel Pégourié-Gonnard | ed7cbe9 | 2013-09-17 15:30:51 +0200 | [diff] [blame] | 337 | if( todo.sha1 ) |
| 338 | TIME_AND_TSC( "SHA-1", sha1( buf, BUFSIZE, tmp ) ); |
Paul Bakker | 5121ce5 | 2009-01-03 21:22:43 +0000 | [diff] [blame] | 339 | #endif |
| 340 | |
Paul Bakker | 9e36f04 | 2013-06-30 14:34:05 +0200 | [diff] [blame] | 341 | #if defined(POLARSSL_SHA256_C) |
Manuel Pégourié-Gonnard | ed7cbe9 | 2013-09-17 15:30:51 +0200 | [diff] [blame] | 342 | if( todo.sha256 ) |
| 343 | TIME_AND_TSC( "SHA-256", sha256( buf, BUFSIZE, tmp, 0 ) ); |
Paul Bakker | 5121ce5 | 2009-01-03 21:22:43 +0000 | [diff] [blame] | 344 | #endif |
| 345 | |
Paul Bakker | 9e36f04 | 2013-06-30 14:34:05 +0200 | [diff] [blame] | 346 | #if defined(POLARSSL_SHA512_C) |
Manuel Pégourié-Gonnard | ed7cbe9 | 2013-09-17 15:30:51 +0200 | [diff] [blame] | 347 | if( todo.sha512 ) |
| 348 | TIME_AND_TSC( "SHA-512", sha512( buf, BUFSIZE, tmp, 0 ) ); |
Paul Bakker | 3a3c3c2 | 2009-02-09 22:33:30 +0000 | [diff] [blame] | 349 | #endif |
| 350 | |
Paul Bakker | 40e4694 | 2009-01-03 21:51:57 +0000 | [diff] [blame] | 351 | #if defined(POLARSSL_ARC4_C) |
Manuel Pégourié-Gonnard | ed7cbe9 | 2013-09-17 15:30:51 +0200 | [diff] [blame] | 352 | if( todo.arc4 ) |
Manuel Pégourié-Gonnard | 8271f2f | 2013-09-17 14:57:55 +0200 | [diff] [blame] | 353 | { |
| 354 | arc4_context arc4; |
Paul Bakker | 8cfd9d8 | 2014-06-18 11:16:11 +0200 | [diff] [blame] | 355 | arc4_init( &arc4 ); |
Manuel Pégourié-Gonnard | 8271f2f | 2013-09-17 14:57:55 +0200 | [diff] [blame] | 356 | arc4_setup( &arc4, tmp, 32 ); |
| 357 | TIME_AND_TSC( "ARC4", arc4_crypt( &arc4, BUFSIZE, buf, buf ) ); |
Paul Bakker | 8cfd9d8 | 2014-06-18 11:16:11 +0200 | [diff] [blame] | 358 | arc4_free( &arc4 ); |
Manuel Pégourié-Gonnard | 8271f2f | 2013-09-17 14:57:55 +0200 | [diff] [blame] | 359 | } |
Paul Bakker | 5121ce5 | 2009-01-03 21:22:43 +0000 | [diff] [blame] | 360 | #endif |
| 361 | |
Manuel Pégourié-Gonnard | 92cb1d3 | 2013-09-13 16:24:20 +0200 | [diff] [blame] | 362 | #if defined(POLARSSL_DES_C) && defined(POLARSSL_CIPHER_MODE_CBC) |
Manuel Pégourié-Gonnard | ed7cbe9 | 2013-09-17 15:30:51 +0200 | [diff] [blame] | 363 | if( todo.des3 ) |
Manuel Pégourié-Gonnard | 8271f2f | 2013-09-17 14:57:55 +0200 | [diff] [blame] | 364 | { |
| 365 | des3_context des3; |
Paul Bakker | 8cfd9d8 | 2014-06-18 11:16:11 +0200 | [diff] [blame] | 366 | des3_init( &des3 ); |
Manuel Pégourié-Gonnard | 8271f2f | 2013-09-17 14:57:55 +0200 | [diff] [blame] | 367 | des3_set3key_enc( &des3, tmp ); |
| 368 | TIME_AND_TSC( "3DES", |
| 369 | des3_crypt_cbc( &des3, DES_ENCRYPT, BUFSIZE, tmp, buf, buf ) ); |
Paul Bakker | 8cfd9d8 | 2014-06-18 11:16:11 +0200 | [diff] [blame] | 370 | des3_free( &des3 ); |
Manuel Pégourié-Gonnard | 8271f2f | 2013-09-17 14:57:55 +0200 | [diff] [blame] | 371 | } |
Paul Bakker | 5121ce5 | 2009-01-03 21:22:43 +0000 | [diff] [blame] | 372 | |
Manuel Pégourié-Gonnard | ed7cbe9 | 2013-09-17 15:30:51 +0200 | [diff] [blame] | 373 | if( todo.des ) |
Manuel Pégourié-Gonnard | 8271f2f | 2013-09-17 14:57:55 +0200 | [diff] [blame] | 374 | { |
| 375 | des_context des; |
Paul Bakker | 8cfd9d8 | 2014-06-18 11:16:11 +0200 | [diff] [blame] | 376 | des_init( &des ); |
Manuel Pégourié-Gonnard | 8271f2f | 2013-09-17 14:57:55 +0200 | [diff] [blame] | 377 | des_setkey_enc( &des, tmp ); |
| 378 | TIME_AND_TSC( "DES", |
| 379 | des_crypt_cbc( &des, DES_ENCRYPT, BUFSIZE, tmp, buf, buf ) ); |
Paul Bakker | 8cfd9d8 | 2014-06-18 11:16:11 +0200 | [diff] [blame] | 380 | des_free( &des ); |
Manuel Pégourié-Gonnard | 8271f2f | 2013-09-17 14:57:55 +0200 | [diff] [blame] | 381 | } |
Paul Bakker | 5121ce5 | 2009-01-03 21:22:43 +0000 | [diff] [blame] | 382 | #endif |
| 383 | |
Paul Bakker | 40e4694 | 2009-01-03 21:51:57 +0000 | [diff] [blame] | 384 | #if defined(POLARSSL_AES_C) |
Manuel Pégourié-Gonnard | 92cb1d3 | 2013-09-13 16:24:20 +0200 | [diff] [blame] | 385 | #if defined(POLARSSL_CIPHER_MODE_CBC) |
Manuel Pégourié-Gonnard | ed7cbe9 | 2013-09-17 15:30:51 +0200 | [diff] [blame] | 386 | if( todo.aes_cbc ) |
Paul Bakker | 5121ce5 | 2009-01-03 21:22:43 +0000 | [diff] [blame] | 387 | { |
Manuel Pégourié-Gonnard | 71e75dc | 2014-12-19 18:05:43 +0100 | [diff] [blame] | 388 | int keysize; |
Manuel Pégourié-Gonnard | 8271f2f | 2013-09-17 14:57:55 +0200 | [diff] [blame] | 389 | aes_context aes; |
Paul Bakker | 8cfd9d8 | 2014-06-18 11:16:11 +0200 | [diff] [blame] | 390 | aes_init( &aes ); |
Manuel Pégourié-Gonnard | 8271f2f | 2013-09-17 14:57:55 +0200 | [diff] [blame] | 391 | for( keysize = 128; keysize <= 256; keysize += 64 ) |
| 392 | { |
Rich Evans | 783d9d1 | 2015-01-30 11:11:57 +0000 | [diff] [blame] | 393 | polarssl_snprintf( title, sizeof( title ), "AES-CBC-%d", keysize ); |
Paul Bakker | 5121ce5 | 2009-01-03 21:22:43 +0000 | [diff] [blame] | 394 | |
Manuel Pégourié-Gonnard | 8271f2f | 2013-09-17 14:57:55 +0200 | [diff] [blame] | 395 | memset( buf, 0, sizeof( buf ) ); |
| 396 | memset( tmp, 0, sizeof( tmp ) ); |
| 397 | aes_setkey_enc( &aes, tmp, keysize ); |
Paul Bakker | 5121ce5 | 2009-01-03 21:22:43 +0000 | [diff] [blame] | 398 | |
Manuel Pégourié-Gonnard | 8271f2f | 2013-09-17 14:57:55 +0200 | [diff] [blame] | 399 | TIME_AND_TSC( title, |
Manuel Pégourié-Gonnard | ed7cbe9 | 2013-09-17 15:30:51 +0200 | [diff] [blame] | 400 | aes_crypt_cbc( &aes, AES_ENCRYPT, BUFSIZE, tmp, buf, buf ) ); |
Manuel Pégourié-Gonnard | 8271f2f | 2013-09-17 14:57:55 +0200 | [diff] [blame] | 401 | } |
Paul Bakker | 8cfd9d8 | 2014-06-18 11:16:11 +0200 | [diff] [blame] | 402 | aes_free( &aes ); |
Paul Bakker | 5121ce5 | 2009-01-03 21:22:43 +0000 | [diff] [blame] | 403 | } |
Manuel Pégourié-Gonnard | 8271f2f | 2013-09-17 14:57:55 +0200 | [diff] [blame] | 404 | #endif |
Paul Bakker | 89e80c9 | 2012-03-20 13:50:09 +0000 | [diff] [blame] | 405 | #if defined(POLARSSL_GCM_C) |
Manuel Pégourié-Gonnard | ed7cbe9 | 2013-09-17 15:30:51 +0200 | [diff] [blame] | 406 | if( todo.aes_gcm ) |
Paul Bakker | 89e80c9 | 2012-03-20 13:50:09 +0000 | [diff] [blame] | 407 | { |
Manuel Pégourié-Gonnard | 71e75dc | 2014-12-19 18:05:43 +0100 | [diff] [blame] | 408 | int keysize; |
Manuel Pégourié-Gonnard | 8271f2f | 2013-09-17 14:57:55 +0200 | [diff] [blame] | 409 | gcm_context gcm; |
| 410 | for( keysize = 128; keysize <= 256; keysize += 64 ) |
| 411 | { |
Rich Evans | 783d9d1 | 2015-01-30 11:11:57 +0000 | [diff] [blame] | 412 | polarssl_snprintf( title, sizeof( title ), "AES-GCM-%d", keysize ); |
Paul Bakker | 89e80c9 | 2012-03-20 13:50:09 +0000 | [diff] [blame] | 413 | |
Manuel Pégourié-Gonnard | 8271f2f | 2013-09-17 14:57:55 +0200 | [diff] [blame] | 414 | memset( buf, 0, sizeof( buf ) ); |
| 415 | memset( tmp, 0, sizeof( tmp ) ); |
| 416 | gcm_init( &gcm, POLARSSL_CIPHER_ID_AES, tmp, keysize ); |
Paul Bakker | 89e80c9 | 2012-03-20 13:50:09 +0000 | [diff] [blame] | 417 | |
Manuel Pégourié-Gonnard | 8271f2f | 2013-09-17 14:57:55 +0200 | [diff] [blame] | 418 | TIME_AND_TSC( title, |
| 419 | gcm_crypt_and_tag( &gcm, GCM_ENCRYPT, BUFSIZE, tmp, |
| 420 | 12, NULL, 0, buf, buf, 16, tmp ) ); |
Paul Bakker | f70fe81 | 2013-12-16 16:43:10 +0100 | [diff] [blame] | 421 | |
| 422 | gcm_free( &gcm ); |
Manuel Pégourié-Gonnard | 8271f2f | 2013-09-17 14:57:55 +0200 | [diff] [blame] | 423 | } |
Paul Bakker | 89e80c9 | 2012-03-20 13:50:09 +0000 | [diff] [blame] | 424 | } |
| 425 | #endif |
Manuel Pégourié-Gonnard | 58d78a8 | 2014-05-07 12:03:02 +0200 | [diff] [blame] | 426 | #if defined(POLARSSL_CCM_C) |
| 427 | if( todo.aes_ccm ) |
| 428 | { |
Manuel Pégourié-Gonnard | 71e75dc | 2014-12-19 18:05:43 +0100 | [diff] [blame] | 429 | int keysize; |
Manuel Pégourié-Gonnard | 58d78a8 | 2014-05-07 12:03:02 +0200 | [diff] [blame] | 430 | ccm_context ccm; |
| 431 | for( keysize = 128; keysize <= 256; keysize += 64 ) |
| 432 | { |
Rich Evans | 783d9d1 | 2015-01-30 11:11:57 +0000 | [diff] [blame] | 433 | polarssl_snprintf( title, sizeof( title ), "AES-CCM-%d", keysize ); |
Manuel Pégourié-Gonnard | 58d78a8 | 2014-05-07 12:03:02 +0200 | [diff] [blame] | 434 | |
| 435 | memset( buf, 0, sizeof( buf ) ); |
| 436 | memset( tmp, 0, sizeof( tmp ) ); |
| 437 | ccm_init( &ccm, POLARSSL_CIPHER_ID_AES, tmp, keysize ); |
| 438 | |
| 439 | TIME_AND_TSC( title, |
| 440 | ccm_encrypt_and_tag( &ccm, BUFSIZE, tmp, |
| 441 | 12, NULL, 0, buf, buf, tmp, 16 ) ); |
| 442 | |
| 443 | ccm_free( &ccm ); |
| 444 | } |
| 445 | } |
| 446 | #endif |
Paul Bakker | 5121ce5 | 2009-01-03 21:22:43 +0000 | [diff] [blame] | 447 | #endif |
| 448 | |
Manuel Pégourié-Gonnard | 92cb1d3 | 2013-09-13 16:24:20 +0200 | [diff] [blame] | 449 | #if defined(POLARSSL_CAMELLIA_C) && defined(POLARSSL_CIPHER_MODE_CBC) |
Manuel Pégourié-Gonnard | ed7cbe9 | 2013-09-17 15:30:51 +0200 | [diff] [blame] | 450 | if( todo.camellia ) |
Paul Bakker | 38119b1 | 2009-01-10 23:31:23 +0000 | [diff] [blame] | 451 | { |
Manuel Pégourié-Gonnard | 71e75dc | 2014-12-19 18:05:43 +0100 | [diff] [blame] | 452 | int keysize; |
Manuel Pégourié-Gonnard | 8271f2f | 2013-09-17 14:57:55 +0200 | [diff] [blame] | 453 | camellia_context camellia; |
Paul Bakker | 8cfd9d8 | 2014-06-18 11:16:11 +0200 | [diff] [blame] | 454 | camellia_init( &camellia ); |
Manuel Pégourié-Gonnard | 8271f2f | 2013-09-17 14:57:55 +0200 | [diff] [blame] | 455 | for( keysize = 128; keysize <= 256; keysize += 64 ) |
| 456 | { |
Rich Evans | 783d9d1 | 2015-01-30 11:11:57 +0000 | [diff] [blame] | 457 | polarssl_snprintf( title, sizeof( title ), "CAMELLIA-CBC-%d", keysize ); |
Paul Bakker | 38119b1 | 2009-01-10 23:31:23 +0000 | [diff] [blame] | 458 | |
Manuel Pégourié-Gonnard | 8271f2f | 2013-09-17 14:57:55 +0200 | [diff] [blame] | 459 | memset( buf, 0, sizeof( buf ) ); |
| 460 | memset( tmp, 0, sizeof( tmp ) ); |
| 461 | camellia_setkey_enc( &camellia, tmp, keysize ); |
Paul Bakker | 38119b1 | 2009-01-10 23:31:23 +0000 | [diff] [blame] | 462 | |
Manuel Pégourié-Gonnard | 8271f2f | 2013-09-17 14:57:55 +0200 | [diff] [blame] | 463 | TIME_AND_TSC( title, |
| 464 | camellia_crypt_cbc( &camellia, CAMELLIA_ENCRYPT, |
| 465 | BUFSIZE, tmp, buf, buf ) ); |
| 466 | } |
Paul Bakker | 8cfd9d8 | 2014-06-18 11:16:11 +0200 | [diff] [blame] | 467 | camellia_free( &camellia ); |
Paul Bakker | 38119b1 | 2009-01-10 23:31:23 +0000 | [diff] [blame] | 468 | } |
| 469 | #endif |
| 470 | |
Manuel Pégourié-Gonnard | 92cb1d3 | 2013-09-13 16:24:20 +0200 | [diff] [blame] | 471 | #if defined(POLARSSL_BLOWFISH_C) && defined(POLARSSL_CIPHER_MODE_CBC) |
Manuel Pégourié-Gonnard | ed7cbe9 | 2013-09-17 15:30:51 +0200 | [diff] [blame] | 472 | if( todo.blowfish ) |
Paul Bakker | 3d58fe8 | 2012-07-04 17:15:31 +0000 | [diff] [blame] | 473 | { |
Manuel Pégourié-Gonnard | 71e75dc | 2014-12-19 18:05:43 +0100 | [diff] [blame] | 474 | int keysize; |
Manuel Pégourié-Gonnard | 8271f2f | 2013-09-17 14:57:55 +0200 | [diff] [blame] | 475 | blowfish_context blowfish; |
Paul Bakker | 8cfd9d8 | 2014-06-18 11:16:11 +0200 | [diff] [blame] | 476 | blowfish_init( &blowfish ); |
| 477 | |
Manuel Pégourié-Gonnard | 8271f2f | 2013-09-17 14:57:55 +0200 | [diff] [blame] | 478 | for( keysize = 128; keysize <= 256; keysize += 64 ) |
| 479 | { |
Rich Evans | 783d9d1 | 2015-01-30 11:11:57 +0000 | [diff] [blame] | 480 | polarssl_snprintf( title, sizeof( title ), "BLOWFISH-CBC-%d", keysize ); |
Paul Bakker | 3d58fe8 | 2012-07-04 17:15:31 +0000 | [diff] [blame] | 481 | |
Manuel Pégourié-Gonnard | 8271f2f | 2013-09-17 14:57:55 +0200 | [diff] [blame] | 482 | memset( buf, 0, sizeof( buf ) ); |
| 483 | memset( tmp, 0, sizeof( tmp ) ); |
| 484 | blowfish_setkey( &blowfish, tmp, keysize ); |
Paul Bakker | 3d58fe8 | 2012-07-04 17:15:31 +0000 | [diff] [blame] | 485 | |
Manuel Pégourié-Gonnard | 8271f2f | 2013-09-17 14:57:55 +0200 | [diff] [blame] | 486 | TIME_AND_TSC( title, |
| 487 | blowfish_crypt_cbc( &blowfish, BLOWFISH_ENCRYPT, BUFSIZE, |
| 488 | tmp, buf, buf ) ); |
| 489 | } |
Paul Bakker | 8cfd9d8 | 2014-06-18 11:16:11 +0200 | [diff] [blame] | 490 | |
| 491 | blowfish_free( &blowfish ); |
Paul Bakker | 3d58fe8 | 2012-07-04 17:15:31 +0000 | [diff] [blame] | 492 | } |
| 493 | #endif |
| 494 | |
Paul Bakker | 02faf45 | 2011-11-29 11:23:58 +0000 | [diff] [blame] | 495 | #if defined(POLARSSL_HAVEGE_C) |
Manuel Pégourié-Gonnard | ed7cbe9 | 2013-09-17 15:30:51 +0200 | [diff] [blame] | 496 | if( todo.havege ) |
Manuel Pégourié-Gonnard | 8271f2f | 2013-09-17 14:57:55 +0200 | [diff] [blame] | 497 | { |
| 498 | havege_state hs; |
| 499 | havege_init( &hs ); |
| 500 | TIME_AND_TSC( "HAVEGE", havege_random( &hs, buf, BUFSIZE ) ); |
Paul Bakker | a317a98 | 2014-06-18 16:44:11 +0200 | [diff] [blame] | 501 | havege_free( &hs ); |
Manuel Pégourié-Gonnard | 8271f2f | 2013-09-17 14:57:55 +0200 | [diff] [blame] | 502 | } |
Paul Bakker | 02faf45 | 2011-11-29 11:23:58 +0000 | [diff] [blame] | 503 | #endif |
| 504 | |
| 505 | #if defined(POLARSSL_CTR_DRBG_C) |
Manuel Pégourié-Gonnard | ed7cbe9 | 2013-09-17 15:30:51 +0200 | [diff] [blame] | 506 | if( todo.ctr_drbg ) |
Manuel Pégourié-Gonnard | 8271f2f | 2013-09-17 14:57:55 +0200 | [diff] [blame] | 507 | { |
Manuel Pégourié-Gonnard | ed7cbe9 | 2013-09-17 15:30:51 +0200 | [diff] [blame] | 508 | ctr_drbg_context ctr_drbg; |
Paul Bakker | 02faf45 | 2011-11-29 11:23:58 +0000 | [diff] [blame] | 509 | |
Manuel Pégourié-Gonnard | 8271f2f | 2013-09-17 14:57:55 +0200 | [diff] [blame] | 510 | if( ctr_drbg_init( &ctr_drbg, myrand, NULL, NULL, 0 ) != 0 ) |
Rich Evans | 77d3638 | 2015-01-30 12:12:11 +0000 | [diff] [blame] | 511 | polarssl_exit(1); |
Manuel Pégourié-Gonnard | 8271f2f | 2013-09-17 14:57:55 +0200 | [diff] [blame] | 512 | TIME_AND_TSC( "CTR_DRBG (NOPR)", |
| 513 | if( ctr_drbg_random( &ctr_drbg, buf, BUFSIZE ) != 0 ) |
Rich Evans | 77d3638 | 2015-01-30 12:12:11 +0000 | [diff] [blame] | 514 | polarssl_exit(1) ); |
Paul Bakker | 02faf45 | 2011-11-29 11:23:58 +0000 | [diff] [blame] | 515 | |
Manuel Pégourié-Gonnard | 8271f2f | 2013-09-17 14:57:55 +0200 | [diff] [blame] | 516 | if( ctr_drbg_init( &ctr_drbg, myrand, NULL, NULL, 0 ) != 0 ) |
Rich Evans | 77d3638 | 2015-01-30 12:12:11 +0000 | [diff] [blame] | 517 | polarssl_exit(1); |
Manuel Pégourié-Gonnard | 8271f2f | 2013-09-17 14:57:55 +0200 | [diff] [blame] | 518 | ctr_drbg_set_prediction_resistance( &ctr_drbg, CTR_DRBG_PR_ON ); |
| 519 | TIME_AND_TSC( "CTR_DRBG (PR)", |
| 520 | if( ctr_drbg_random( &ctr_drbg, buf, BUFSIZE ) != 0 ) |
Rich Evans | 77d3638 | 2015-01-30 12:12:11 +0000 | [diff] [blame] | 521 | polarssl_exit(1) ); |
Paul Bakker | a317a98 | 2014-06-18 16:44:11 +0200 | [diff] [blame] | 522 | ctr_drbg_free( &ctr_drbg ); |
Manuel Pégourié-Gonnard | 8271f2f | 2013-09-17 14:57:55 +0200 | [diff] [blame] | 523 | } |
Paul Bakker | 02faf45 | 2011-11-29 11:23:58 +0000 | [diff] [blame] | 524 | #endif |
| 525 | |
Manuel Pégourié-Gonnard | fef0f8f | 2014-01-30 20:59:00 +0100 | [diff] [blame] | 526 | #if defined(POLARSSL_HMAC_DRBG_C) |
| 527 | if( todo.hmac_drbg ) |
| 528 | { |
| 529 | hmac_drbg_context hmac_drbg; |
| 530 | const md_info_t *md_info; |
| 531 | |
| 532 | #if defined(POLARSSL_SHA1_C) |
| 533 | if( ( md_info = md_info_from_type( POLARSSL_MD_SHA1 ) ) == NULL ) |
Rich Evans | 77d3638 | 2015-01-30 12:12:11 +0000 | [diff] [blame] | 534 | polarssl_exit(1); |
Manuel Pégourié-Gonnard | fef0f8f | 2014-01-30 20:59:00 +0100 | [diff] [blame] | 535 | |
| 536 | if( hmac_drbg_init( &hmac_drbg, md_info, myrand, NULL, NULL, 0 ) != 0 ) |
Rich Evans | 77d3638 | 2015-01-30 12:12:11 +0000 | [diff] [blame] | 537 | polarssl_exit(1); |
Manuel Pégourié-Gonnard | fef0f8f | 2014-01-30 20:59:00 +0100 | [diff] [blame] | 538 | TIME_AND_TSC( "HMAC_DRBG SHA-1 (NOPR)", |
| 539 | if( hmac_drbg_random( &hmac_drbg, buf, BUFSIZE ) != 0 ) |
Rich Evans | 77d3638 | 2015-01-30 12:12:11 +0000 | [diff] [blame] | 540 | polarssl_exit(1) ); |
Manuel Pégourié-Gonnard | fef0f8f | 2014-01-30 20:59:00 +0100 | [diff] [blame] | 541 | hmac_drbg_free( &hmac_drbg ); |
| 542 | |
| 543 | if( hmac_drbg_init( &hmac_drbg, md_info, myrand, NULL, NULL, 0 ) != 0 ) |
Rich Evans | 77d3638 | 2015-01-30 12:12:11 +0000 | [diff] [blame] | 544 | polarssl_exit(1); |
Manuel Pégourié-Gonnard | fef0f8f | 2014-01-30 20:59:00 +0100 | [diff] [blame] | 545 | hmac_drbg_set_prediction_resistance( &hmac_drbg, |
| 546 | POLARSSL_HMAC_DRBG_PR_ON ); |
| 547 | TIME_AND_TSC( "HMAC_DRBG SHA-1 (PR)", |
| 548 | if( hmac_drbg_random( &hmac_drbg, buf, BUFSIZE ) != 0 ) |
Rich Evans | 77d3638 | 2015-01-30 12:12:11 +0000 | [diff] [blame] | 549 | polarssl_exit(1) ); |
Manuel Pégourié-Gonnard | fef0f8f | 2014-01-30 20:59:00 +0100 | [diff] [blame] | 550 | hmac_drbg_free( &hmac_drbg ); |
| 551 | #endif |
| 552 | |
| 553 | #if defined(POLARSSL_SHA256_C) |
| 554 | if( ( md_info = md_info_from_type( POLARSSL_MD_SHA256 ) ) == NULL ) |
Rich Evans | 77d3638 | 2015-01-30 12:12:11 +0000 | [diff] [blame] | 555 | polarssl_exit(1); |
Manuel Pégourié-Gonnard | fef0f8f | 2014-01-30 20:59:00 +0100 | [diff] [blame] | 556 | |
| 557 | if( hmac_drbg_init( &hmac_drbg, md_info, myrand, NULL, NULL, 0 ) != 0 ) |
Rich Evans | 77d3638 | 2015-01-30 12:12:11 +0000 | [diff] [blame] | 558 | polarssl_exit(1); |
Manuel Pégourié-Gonnard | fef0f8f | 2014-01-30 20:59:00 +0100 | [diff] [blame] | 559 | TIME_AND_TSC( "HMAC_DRBG SHA-256 (NOPR)", |
| 560 | if( hmac_drbg_random( &hmac_drbg, buf, BUFSIZE ) != 0 ) |
Rich Evans | 77d3638 | 2015-01-30 12:12:11 +0000 | [diff] [blame] | 561 | polarssl_exit(1) ); |
Manuel Pégourié-Gonnard | fef0f8f | 2014-01-30 20:59:00 +0100 | [diff] [blame] | 562 | hmac_drbg_free( &hmac_drbg ); |
| 563 | |
| 564 | if( hmac_drbg_init( &hmac_drbg, md_info, myrand, NULL, NULL, 0 ) != 0 ) |
Rich Evans | 77d3638 | 2015-01-30 12:12:11 +0000 | [diff] [blame] | 565 | polarssl_exit(1); |
Manuel Pégourié-Gonnard | fef0f8f | 2014-01-30 20:59:00 +0100 | [diff] [blame] | 566 | hmac_drbg_set_prediction_resistance( &hmac_drbg, |
| 567 | POLARSSL_HMAC_DRBG_PR_ON ); |
| 568 | TIME_AND_TSC( "HMAC_DRBG SHA-256 (PR)", |
| 569 | if( hmac_drbg_random( &hmac_drbg, buf, BUFSIZE ) != 0 ) |
Rich Evans | 77d3638 | 2015-01-30 12:12:11 +0000 | [diff] [blame] | 570 | polarssl_exit(1) ); |
Manuel Pégourié-Gonnard | fef0f8f | 2014-01-30 20:59:00 +0100 | [diff] [blame] | 571 | hmac_drbg_free( &hmac_drbg ); |
| 572 | #endif |
| 573 | } |
| 574 | #endif |
| 575 | |
Manuel Pégourié-Gonnard | 8271f2f | 2013-09-17 14:57:55 +0200 | [diff] [blame] | 576 | #if defined(POLARSSL_RSA_C) && defined(POLARSSL_GENPRIME) |
Manuel Pégourié-Gonnard | ed7cbe9 | 2013-09-17 15:30:51 +0200 | [diff] [blame] | 577 | if( todo.rsa ) |
Paul Bakker | 5121ce5 | 2009-01-03 21:22:43 +0000 | [diff] [blame] | 578 | { |
Manuel Pégourié-Gonnard | 71e75dc | 2014-12-19 18:05:43 +0100 | [diff] [blame] | 579 | int keysize; |
Manuel Pégourié-Gonnard | 8271f2f | 2013-09-17 14:57:55 +0200 | [diff] [blame] | 580 | rsa_context rsa; |
| 581 | for( keysize = 1024; keysize <= 4096; keysize *= 2 ) |
| 582 | { |
Rich Evans | 783d9d1 | 2015-01-30 11:11:57 +0000 | [diff] [blame] | 583 | polarssl_snprintf( title, sizeof( title ), "RSA-%d", keysize ); |
Manuel Pégourié-Gonnard | 8271f2f | 2013-09-17 14:57:55 +0200 | [diff] [blame] | 584 | |
| 585 | rsa_init( &rsa, RSA_PKCS_V15, 0 ); |
| 586 | rsa_gen_key( &rsa, myrand, NULL, keysize, 65537 ); |
| 587 | |
| 588 | TIME_PUBLIC( title, " public", |
| 589 | buf[0] = 0; |
| 590 | ret = rsa_public( &rsa, buf, buf ) ); |
| 591 | |
| 592 | TIME_PUBLIC( title, "private", |
| 593 | buf[0] = 0; |
| 594 | ret = rsa_private( &rsa, myrand, NULL, buf, buf ) ); |
| 595 | |
| 596 | rsa_free( &rsa ); |
| 597 | } |
Paul Bakker | 5121ce5 | 2009-01-03 21:22:43 +0000 | [diff] [blame] | 598 | } |
Paul Bakker | 5121ce5 | 2009-01-03 21:22:43 +0000 | [diff] [blame] | 599 | #endif |
| 600 | |
Manuel Pégourié-Gonnard | e870c0a | 2012-11-08 11:31:48 +0100 | [diff] [blame] | 601 | #if defined(POLARSSL_DHM_C) && defined(POLARSSL_BIGNUM_C) |
Manuel Pégourié-Gonnard | ed7cbe9 | 2013-09-17 15:30:51 +0200 | [diff] [blame] | 602 | if( todo.dhm ) |
Manuel Pégourié-Gonnard | e870c0a | 2012-11-08 11:31:48 +0100 | [diff] [blame] | 603 | { |
Manuel Pégourié-Gonnard | ed7cbe9 | 2013-09-17 15:30:51 +0200 | [diff] [blame] | 604 | int dhm_sizes[DHM_SIZES] = { 1024, 2048, 3072 }; |
Manuel Pégourié-Gonnard | 8271f2f | 2013-09-17 14:57:55 +0200 | [diff] [blame] | 605 | const char *dhm_P[DHM_SIZES] = { |
| 606 | POLARSSL_DHM_RFC5114_MODP_1024_P, |
| 607 | POLARSSL_DHM_RFC3526_MODP_2048_P, |
| 608 | POLARSSL_DHM_RFC3526_MODP_3072_P, |
| 609 | }; |
| 610 | const char *dhm_G[DHM_SIZES] = { |
| 611 | POLARSSL_DHM_RFC5114_MODP_1024_G, |
| 612 | POLARSSL_DHM_RFC3526_MODP_2048_G, |
| 613 | POLARSSL_DHM_RFC3526_MODP_3072_G, |
| 614 | }; |
| 615 | |
| 616 | dhm_context dhm; |
| 617 | size_t olen; |
Manuel Pégourié-Gonnard | ed7cbe9 | 2013-09-17 15:30:51 +0200 | [diff] [blame] | 618 | for( i = 0; i < DHM_SIZES; i++ ) |
Manuel Pégourié-Gonnard | 8271f2f | 2013-09-17 14:57:55 +0200 | [diff] [blame] | 619 | { |
Paul Bakker | a317a98 | 2014-06-18 16:44:11 +0200 | [diff] [blame] | 620 | dhm_init( &dhm ); |
Manuel Pégourié-Gonnard | 8271f2f | 2013-09-17 14:57:55 +0200 | [diff] [blame] | 621 | |
Paul Bakker | cbe3d0d | 2014-04-17 16:00:59 +0200 | [diff] [blame] | 622 | if( mpi_read_string( &dhm.P, 16, dhm_P[i] ) != 0 || |
| 623 | mpi_read_string( &dhm.G, 16, dhm_G[i] ) != 0 ) |
| 624 | { |
Rich Evans | 77d3638 | 2015-01-30 12:12:11 +0000 | [diff] [blame] | 625 | polarssl_exit( 1 ); |
Paul Bakker | cbe3d0d | 2014-04-17 16:00:59 +0200 | [diff] [blame] | 626 | } |
| 627 | |
Manuel Pégourié-Gonnard | 8271f2f | 2013-09-17 14:57:55 +0200 | [diff] [blame] | 628 | dhm.len = mpi_size( &dhm.P ); |
Paul Bakker | 840ab20 | 2013-11-30 15:14:38 +0100 | [diff] [blame] | 629 | dhm_make_public( &dhm, (int) dhm.len, buf, dhm.len, myrand, NULL ); |
Paul Bakker | cbe3d0d | 2014-04-17 16:00:59 +0200 | [diff] [blame] | 630 | if( mpi_copy( &dhm.GY, &dhm.GX ) != 0 ) |
Rich Evans | 77d3638 | 2015-01-30 12:12:11 +0000 | [diff] [blame] | 631 | polarssl_exit( 1 ); |
Manuel Pégourié-Gonnard | 8271f2f | 2013-09-17 14:57:55 +0200 | [diff] [blame] | 632 | |
Rich Evans | 783d9d1 | 2015-01-30 11:11:57 +0000 | [diff] [blame] | 633 | polarssl_snprintf( title, sizeof( title ), "DHE-%d", dhm_sizes[i] ); |
Manuel Pégourié-Gonnard | 8271f2f | 2013-09-17 14:57:55 +0200 | [diff] [blame] | 634 | TIME_PUBLIC( title, "handshake", |
| 635 | olen = sizeof( buf ); |
Paul Bakker | 840ab20 | 2013-11-30 15:14:38 +0100 | [diff] [blame] | 636 | ret |= dhm_make_public( &dhm, (int) dhm.len, buf, dhm.len, |
Manuel Pégourié-Gonnard | 8271f2f | 2013-09-17 14:57:55 +0200 | [diff] [blame] | 637 | myrand, NULL ); |
| 638 | ret |= dhm_calc_secret( &dhm, buf, &olen, myrand, NULL ) ); |
| 639 | |
Rich Evans | 783d9d1 | 2015-01-30 11:11:57 +0000 | [diff] [blame] | 640 | polarssl_snprintf( title, sizeof( title ), "DH-%d", dhm_sizes[i] ); |
Manuel Pégourié-Gonnard | 8271f2f | 2013-09-17 14:57:55 +0200 | [diff] [blame] | 641 | TIME_PUBLIC( title, "handshake", |
| 642 | olen = sizeof( buf ); |
| 643 | ret |= dhm_calc_secret( &dhm, buf, &olen, myrand, NULL ) ); |
| 644 | |
| 645 | dhm_free( &dhm ); |
| 646 | } |
Manuel Pégourié-Gonnard | e870c0a | 2012-11-08 11:31:48 +0100 | [diff] [blame] | 647 | } |
Manuel Pégourié-Gonnard | e870c0a | 2012-11-08 11:31:48 +0100 | [diff] [blame] | 648 | #endif |
| 649 | |
Manuel Pégourié-Gonnard | cc34f95 | 2013-09-17 16:04:08 +0200 | [diff] [blame] | 650 | #if defined(POLARSSL_ECDSA_C) |
| 651 | if( todo.ecdsa ) |
| 652 | { |
| 653 | ecdsa_context ecdsa; |
| 654 | const ecp_curve_info *curve_info; |
| 655 | size_t sig_len; |
| 656 | |
| 657 | memset( buf, 0x2A, sizeof( buf ) ); |
| 658 | |
Manuel Pégourié-Gonnard | da179e4 | 2013-09-18 15:31:24 +0200 | [diff] [blame] | 659 | for( curve_info = ecp_curve_list(); |
Manuel Pégourié-Gonnard | cc34f95 | 2013-09-17 16:04:08 +0200 | [diff] [blame] | 660 | curve_info->grp_id != POLARSSL_ECP_DP_NONE; |
| 661 | curve_info++ ) |
| 662 | { |
| 663 | ecdsa_init( &ecdsa ); |
| 664 | |
| 665 | if( ecdsa_genkey( &ecdsa, curve_info->grp_id, myrand, NULL ) != 0 ) |
Rich Evans | 77d3638 | 2015-01-30 12:12:11 +0000 | [diff] [blame] | 666 | polarssl_exit( 1 ); |
Manuel Pégourié-Gonnard | 50da048 | 2014-12-19 12:10:37 +0100 | [diff] [blame] | 667 | ecp_clear_precomputed( &ecdsa.grp ); |
Manuel Pégourié-Gonnard | cc34f95 | 2013-09-17 16:04:08 +0200 | [diff] [blame] | 668 | |
Rich Evans | 783d9d1 | 2015-01-30 11:11:57 +0000 | [diff] [blame] | 669 | polarssl_snprintf( title, sizeof( title ), "ECDSA-%s", |
Manuel Pégourié-Gonnard | 56cd319 | 2013-09-17 17:23:07 +0200 | [diff] [blame] | 670 | curve_info->name ); |
Manuel Pégourié-Gonnard | cc34f95 | 2013-09-17 16:04:08 +0200 | [diff] [blame] | 671 | TIME_PUBLIC( title, "sign", |
| 672 | ret = ecdsa_write_signature( &ecdsa, buf, curve_info->size, |
Manuel Pégourié-Gonnard | 56cd319 | 2013-09-17 17:23:07 +0200 | [diff] [blame] | 673 | tmp, &sig_len, myrand, NULL ) ); |
| 674 | |
Manuel Pégourié-Gonnard | 50da048 | 2014-12-19 12:10:37 +0100 | [diff] [blame] | 675 | ecdsa_free( &ecdsa ); |
| 676 | } |
| 677 | |
| 678 | for( curve_info = ecp_curve_list(); |
| 679 | curve_info->grp_id != POLARSSL_ECP_DP_NONE; |
| 680 | curve_info++ ) |
| 681 | { |
| 682 | ecdsa_init( &ecdsa ); |
| 683 | |
| 684 | if( ecdsa_genkey( &ecdsa, curve_info->grp_id, myrand, NULL ) != 0 || |
| 685 | ecdsa_write_signature( &ecdsa, buf, curve_info->size, |
| 686 | tmp, &sig_len, myrand, NULL ) != 0 ) |
| 687 | { |
| 688 | exit( 1 ); |
| 689 | } |
| 690 | ecp_clear_precomputed( &ecdsa.grp ); |
| 691 | |
| 692 | snprintf( title, sizeof( title ), "ECDSA-%s", |
| 693 | curve_info->name ); |
Manuel Pégourié-Gonnard | 56cd319 | 2013-09-17 17:23:07 +0200 | [diff] [blame] | 694 | TIME_PUBLIC( title, "verify", |
| 695 | ret = ecdsa_read_signature( &ecdsa, buf, curve_info->size, |
| 696 | tmp, sig_len ) ); |
Manuel Pégourié-Gonnard | cc34f95 | 2013-09-17 16:04:08 +0200 | [diff] [blame] | 697 | |
| 698 | ecdsa_free( &ecdsa ); |
| 699 | } |
| 700 | } |
| 701 | #endif |
| 702 | |
| 703 | #if defined(POLARSSL_ECDH_C) |
| 704 | if( todo.ecdh ) |
| 705 | { |
| 706 | ecdh_context ecdh; |
| 707 | const ecp_curve_info *curve_info; |
| 708 | size_t olen; |
| 709 | |
Manuel Pégourié-Gonnard | da179e4 | 2013-09-18 15:31:24 +0200 | [diff] [blame] | 710 | for( curve_info = ecp_curve_list(); |
Manuel Pégourié-Gonnard | cc34f95 | 2013-09-17 16:04:08 +0200 | [diff] [blame] | 711 | curve_info->grp_id != POLARSSL_ECP_DP_NONE; |
| 712 | curve_info++ ) |
| 713 | { |
| 714 | ecdh_init( &ecdh ); |
| 715 | |
| 716 | if( ecp_use_known_dp( &ecdh.grp, curve_info->grp_id ) != 0 || |
| 717 | ecdh_make_public( &ecdh, &olen, buf, sizeof( buf), |
| 718 | myrand, NULL ) != 0 || |
| 719 | ecp_copy( &ecdh.Qp, &ecdh.Q ) != 0 ) |
| 720 | { |
Rich Evans | 77d3638 | 2015-01-30 12:12:11 +0000 | [diff] [blame] | 721 | polarssl_exit( 1 ); |
Manuel Pégourié-Gonnard | cc34f95 | 2013-09-17 16:04:08 +0200 | [diff] [blame] | 722 | } |
Manuel Pégourié-Gonnard | 50da048 | 2014-12-19 12:10:37 +0100 | [diff] [blame] | 723 | ecp_clear_precomputed( &ecdh.grp ); |
Manuel Pégourié-Gonnard | cc34f95 | 2013-09-17 16:04:08 +0200 | [diff] [blame] | 724 | |
Rich Evans | 783d9d1 | 2015-01-30 11:11:57 +0000 | [diff] [blame] | 725 | polarssl_snprintf( title, sizeof( title ), "ECDHE-%s", |
Manuel Pégourié-Gonnard | 56cd319 | 2013-09-17 17:23:07 +0200 | [diff] [blame] | 726 | curve_info->name ); |
Manuel Pégourié-Gonnard | cc34f95 | 2013-09-17 16:04:08 +0200 | [diff] [blame] | 727 | TIME_PUBLIC( title, "handshake", |
| 728 | ret |= ecdh_make_public( &ecdh, &olen, buf, sizeof( buf), |
| 729 | myrand, NULL ); |
| 730 | ret |= ecdh_calc_secret( &ecdh, &olen, buf, sizeof( buf ), |
| 731 | myrand, NULL ) ); |
Manuel Pégourié-Gonnard | 50da048 | 2014-12-19 12:10:37 +0100 | [diff] [blame] | 732 | ecdh_free( &ecdh ); |
| 733 | } |
| 734 | |
| 735 | for( curve_info = ecp_curve_list(); |
| 736 | curve_info->grp_id != POLARSSL_ECP_DP_NONE; |
| 737 | curve_info++ ) |
| 738 | { |
| 739 | ecdh_init( &ecdh ); |
| 740 | |
| 741 | if( ecp_use_known_dp( &ecdh.grp, curve_info->grp_id ) != 0 || |
| 742 | ecdh_make_public( &ecdh, &olen, buf, sizeof( buf), |
| 743 | myrand, NULL ) != 0 || |
| 744 | ecp_copy( &ecdh.Qp, &ecdh.Q ) != 0 || |
| 745 | ecdh_make_public( &ecdh, &olen, buf, sizeof( buf), |
| 746 | myrand, NULL ) != 0 ) |
| 747 | { |
| 748 | exit( 1 ); |
| 749 | } |
| 750 | ecp_clear_precomputed( &ecdh.grp ); |
Manuel Pégourié-Gonnard | cc34f95 | 2013-09-17 16:04:08 +0200 | [diff] [blame] | 751 | |
Rich Evans | 783d9d1 | 2015-01-30 11:11:57 +0000 | [diff] [blame] | 752 | polarssl_snprintf( title, sizeof( title ), "ECDH-%s", |
Manuel Pégourié-Gonnard | 56cd319 | 2013-09-17 17:23:07 +0200 | [diff] [blame] | 753 | curve_info->name ); |
Manuel Pégourié-Gonnard | cc34f95 | 2013-09-17 16:04:08 +0200 | [diff] [blame] | 754 | TIME_PUBLIC( title, "handshake", |
| 755 | ret |= ecdh_calc_secret( &ecdh, &olen, buf, sizeof( buf ), |
| 756 | myrand, NULL ) ); |
| 757 | ecdh_free( &ecdh ); |
| 758 | } |
| 759 | } |
| 760 | #endif |
Manuel Pégourié-Gonnard | 50da048 | 2014-12-19 12:10:37 +0100 | [diff] [blame] | 761 | |
Rich Evans | f90016a | 2015-01-19 14:26:37 +0000 | [diff] [blame] | 762 | polarssl_printf( "\n" ); |
Paul Bakker | 1d4da2e | 2009-10-25 12:36:53 +0000 | [diff] [blame] | 763 | |
Manuel Pégourié-Gonnard | 128657d | 2014-12-18 16:35:52 +0000 | [diff] [blame] | 764 | #if defined(POLARSSL_MEMORY_BUFFER_ALLOC_C) |
Manuel Pégourié-Gonnard | 128657d | 2014-12-18 16:35:52 +0000 | [diff] [blame] | 765 | memory_buffer_alloc_free(); |
| 766 | #endif |
| 767 | |
Paul Bakker | cce9d77 | 2011-11-18 14:26:47 +0000 | [diff] [blame] | 768 | #if defined(_WIN32) |
Rich Evans | f90016a | 2015-01-19 14:26:37 +0000 | [diff] [blame] | 769 | polarssl_printf( " Press Enter to exit this program.\n" ); |
Paul Bakker | 5121ce5 | 2009-01-03 21:22:43 +0000 | [diff] [blame] | 770 | fflush( stdout ); getchar(); |
| 771 | #endif |
| 772 | |
| 773 | return( 0 ); |
| 774 | } |
Manuel Pégourié-Gonnard | 8271f2f | 2013-09-17 14:57:55 +0200 | [diff] [blame] | 775 | |
Paul Bakker | 5690efc | 2011-05-26 13:16:06 +0000 | [diff] [blame] | 776 | #endif /* POLARSSL_TIMING_C */ |