Paul Bakker | 5121ce5 | 2009-01-03 21:22:43 +0000 | [diff] [blame] | 1 | /* |
| 2 | * AES-256 file encryption program |
| 3 | * |
Paul Bakker | 9e36f04 | 2013-06-30 14:34:05 +0200 | [diff] [blame] | 4 | * Copyright (C) 2006-2013, Brainspark B.V. |
Paul Bakker | b96f154 | 2010-07-18 20:36:00 +0000 | [diff] [blame] | 5 | * |
| 6 | * This file is part of PolarSSL (http://www.polarssl.org) |
Paul Bakker | 84f12b7 | 2010-07-18 10:13:04 +0000 | [diff] [blame] | 7 | * Lead Maintainer: Paul Bakker <polarssl_maintainer at polarssl.org> |
Paul Bakker | b96f154 | 2010-07-18 20:36:00 +0000 | [diff] [blame] | 8 | * |
Paul Bakker | 77b385e | 2009-07-28 17:23:11 +0000 | [diff] [blame] | 9 | * All rights reserved. |
Paul Bakker | e0ccd0a | 2009-01-04 16:27:10 +0000 | [diff] [blame] | 10 | * |
Paul Bakker | 5121ce5 | 2009-01-03 21:22:43 +0000 | [diff] [blame] | 11 | * This program is free software; you can redistribute it and/or modify |
| 12 | * it under the terms of the GNU General Public License as published by |
| 13 | * the Free Software Foundation; either version 2 of the License, or |
| 14 | * (at your option) any later version. |
| 15 | * |
| 16 | * This program is distributed in the hope that it will be useful, |
| 17 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 18 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 19 | * GNU General Public License for more details. |
| 20 | * |
| 21 | * You should have received a copy of the GNU General Public License along |
| 22 | * with this program; if not, write to the Free Software Foundation, Inc., |
| 23 | * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. |
| 24 | */ |
| 25 | |
Manuel Pégourié-Gonnard | abd6e02 | 2013-09-20 13:30:43 +0200 | [diff] [blame] | 26 | #include "polarssl/config.h" |
Paul Bakker | 5121ce5 | 2009-01-03 21:22:43 +0000 | [diff] [blame] | 27 | |
Paul Bakker | 494c0b8 | 2011-04-24 15:30:07 +0000 | [diff] [blame] | 28 | #if defined(_WIN32) |
Paul Bakker | 5121ce5 | 2009-01-03 21:22:43 +0000 | [diff] [blame] | 29 | #include <windows.h> |
Paul Bakker | cce9d77 | 2011-11-18 14:26:47 +0000 | [diff] [blame] | 30 | #if !defined(_WIN32_WCE) |
Paul Bakker | 5121ce5 | 2009-01-03 21:22:43 +0000 | [diff] [blame] | 31 | #include <io.h> |
Paul Bakker | cce9d77 | 2011-11-18 14:26:47 +0000 | [diff] [blame] | 32 | #endif |
Paul Bakker | 5121ce5 | 2009-01-03 21:22:43 +0000 | [diff] [blame] | 33 | #else |
| 34 | #include <sys/types.h> |
| 35 | #include <unistd.h> |
| 36 | #endif |
| 37 | |
| 38 | #include <string.h> |
| 39 | #include <stdlib.h> |
| 40 | #include <stdio.h> |
| 41 | #include <time.h> |
| 42 | |
Paul Bakker | 40e4694 | 2009-01-03 21:51:57 +0000 | [diff] [blame] | 43 | #include "polarssl/aes.h" |
Paul Bakker | d2681d8 | 2013-06-30 14:49:12 +0200 | [diff] [blame] | 44 | #include "polarssl/sha256.h" |
Paul Bakker | 5121ce5 | 2009-01-03 21:22:43 +0000 | [diff] [blame] | 45 | |
| 46 | #define MODE_ENCRYPT 0 |
| 47 | #define MODE_DECRYPT 1 |
| 48 | |
| 49 | #define USAGE \ |
| 50 | "\n aescrypt2 <mode> <input filename> <output filename> <key>\n" \ |
| 51 | "\n <mode>: 0 = encrypt, 1 = decrypt\n" \ |
| 52 | "\n example: aescrypt2 0 file file.aes hex:E76B2413958B00E193\n" \ |
| 53 | "\n" |
| 54 | |
Paul Bakker | 9e36f04 | 2013-06-30 14:34:05 +0200 | [diff] [blame] | 55 | #if !defined(POLARSSL_AES_C) || !defined(POLARSSL_SHA256_C) |
Paul Bakker | cce9d77 | 2011-11-18 14:26:47 +0000 | [diff] [blame] | 56 | int main( int argc, char *argv[] ) |
Paul Bakker | 5690efc | 2011-05-26 13:16:06 +0000 | [diff] [blame] | 57 | { |
Paul Bakker | cce9d77 | 2011-11-18 14:26:47 +0000 | [diff] [blame] | 58 | ((void) argc); |
| 59 | ((void) argv); |
Paul Bakker | 9e36f04 | 2013-06-30 14:34:05 +0200 | [diff] [blame] | 60 | printf("POLARSSL_AES_C and/or POLARSSL_SHA256_C not defined.\n"); |
Paul Bakker | 5690efc | 2011-05-26 13:16:06 +0000 | [diff] [blame] | 61 | return( 0 ); |
| 62 | } |
| 63 | #else |
Paul Bakker | 5121ce5 | 2009-01-03 21:22:43 +0000 | [diff] [blame] | 64 | int main( int argc, char *argv[] ) |
| 65 | { |
Paul Bakker | 5690efc | 2011-05-26 13:16:06 +0000 | [diff] [blame] | 66 | int ret = 1; |
| 67 | |
| 68 | int i, n; |
Paul Bakker | 23986e5 | 2011-04-24 08:57:21 +0000 | [diff] [blame] | 69 | int mode, lastn; |
| 70 | size_t keylen; |
Paul Bakker | 20a7808 | 2011-01-21 09:32:12 +0000 | [diff] [blame] | 71 | FILE *fkey, *fin = NULL, *fout = NULL; |
Paul Bakker | 5121ce5 | 2009-01-03 21:22:43 +0000 | [diff] [blame] | 72 | |
| 73 | char *p; |
| 74 | unsigned char IV[16]; |
| 75 | unsigned char key[512]; |
| 76 | unsigned char digest[32]; |
| 77 | unsigned char buffer[1024]; |
Manuel Pégourié-Gonnard | 291f9af | 2013-10-28 12:51:32 +0100 | [diff] [blame^] | 78 | unsigned char diff; |
Paul Bakker | 5121ce5 | 2009-01-03 21:22:43 +0000 | [diff] [blame] | 79 | |
| 80 | aes_context aes_ctx; |
Paul Bakker | 9e36f04 | 2013-06-30 14:34:05 +0200 | [diff] [blame] | 81 | sha256_context sha_ctx; |
Paul Bakker | 5121ce5 | 2009-01-03 21:22:43 +0000 | [diff] [blame] | 82 | |
Paul Bakker | cce9d77 | 2011-11-18 14:26:47 +0000 | [diff] [blame] | 83 | #if defined(_WIN32_WCE) |
| 84 | long filesize, offset; |
| 85 | #elif defined(_WIN32) |
Paul Bakker | 5121ce5 | 2009-01-03 21:22:43 +0000 | [diff] [blame] | 86 | LARGE_INTEGER li_size; |
| 87 | __int64 filesize, offset; |
| 88 | #else |
| 89 | off_t filesize, offset; |
| 90 | #endif |
| 91 | |
| 92 | /* |
| 93 | * Parse the command-line arguments. |
| 94 | */ |
| 95 | if( argc != 5 ) |
| 96 | { |
| 97 | printf( USAGE ); |
| 98 | |
Paul Bakker | cce9d77 | 2011-11-18 14:26:47 +0000 | [diff] [blame] | 99 | #if defined(_WIN32) |
Paul Bakker | 5121ce5 | 2009-01-03 21:22:43 +0000 | [diff] [blame] | 100 | printf( "\n Press Enter to exit this program.\n" ); |
| 101 | fflush( stdout ); getchar(); |
| 102 | #endif |
| 103 | |
| 104 | goto exit; |
| 105 | } |
| 106 | |
| 107 | mode = atoi( argv[1] ); |
| 108 | |
| 109 | if( mode != MODE_ENCRYPT && mode != MODE_DECRYPT ) |
| 110 | { |
| 111 | fprintf( stderr, "invalide operation mode\n" ); |
| 112 | goto exit; |
| 113 | } |
| 114 | |
| 115 | if( strcmp( argv[2], argv[3] ) == 0 ) |
| 116 | { |
| 117 | fprintf( stderr, "input and output filenames must differ\n" ); |
| 118 | goto exit; |
| 119 | } |
| 120 | |
| 121 | if( ( fin = fopen( argv[2], "rb" ) ) == NULL ) |
| 122 | { |
| 123 | fprintf( stderr, "fopen(%s,rb) failed\n", argv[2] ); |
| 124 | goto exit; |
| 125 | } |
| 126 | |
| 127 | if( ( fout = fopen( argv[3], "wb+" ) ) == NULL ) |
| 128 | { |
| 129 | fprintf( stderr, "fopen(%s,wb+) failed\n", argv[3] ); |
| 130 | goto exit; |
| 131 | } |
| 132 | |
| 133 | /* |
| 134 | * Read the secret key and clean the command line. |
| 135 | */ |
| 136 | if( ( fkey = fopen( argv[4], "rb" ) ) != NULL ) |
| 137 | { |
| 138 | keylen = fread( key, 1, sizeof( key ), fkey ); |
| 139 | fclose( fkey ); |
| 140 | } |
| 141 | else |
| 142 | { |
| 143 | if( memcmp( argv[4], "hex:", 4 ) == 0 ) |
| 144 | { |
| 145 | p = &argv[4][4]; |
| 146 | keylen = 0; |
| 147 | |
| 148 | while( sscanf( p, "%02X", &n ) > 0 && |
| 149 | keylen < (int) sizeof( key ) ) |
| 150 | { |
| 151 | key[keylen++] = (unsigned char) n; |
| 152 | p += 2; |
| 153 | } |
| 154 | } |
| 155 | else |
| 156 | { |
| 157 | keylen = strlen( argv[4] ); |
| 158 | |
| 159 | if( keylen > (int) sizeof( key ) ) |
| 160 | keylen = (int) sizeof( key ); |
| 161 | |
| 162 | memcpy( key, argv[4], keylen ); |
| 163 | } |
| 164 | } |
| 165 | |
| 166 | memset( argv[4], 0, strlen( argv[4] ) ); |
| 167 | |
Paul Bakker | cce9d77 | 2011-11-18 14:26:47 +0000 | [diff] [blame] | 168 | #if defined(_WIN32_WCE) |
| 169 | filesize = fseek( fin, 0L, SEEK_END ); |
| 170 | #else |
| 171 | #if defined(_WIN32) |
Paul Bakker | 5121ce5 | 2009-01-03 21:22:43 +0000 | [diff] [blame] | 172 | /* |
| 173 | * Support large files (> 2Gb) on Win32 |
| 174 | */ |
| 175 | li_size.QuadPart = 0; |
| 176 | li_size.LowPart = |
| 177 | SetFilePointer( (HANDLE) _get_osfhandle( _fileno( fin ) ), |
| 178 | li_size.LowPart, &li_size.HighPart, FILE_END ); |
| 179 | |
| 180 | if( li_size.LowPart == 0xFFFFFFFF && GetLastError() != NO_ERROR ) |
| 181 | { |
| 182 | fprintf( stderr, "SetFilePointer(0,FILE_END) failed\n" ); |
| 183 | goto exit; |
| 184 | } |
| 185 | |
| 186 | filesize = li_size.QuadPart; |
| 187 | #else |
| 188 | if( ( filesize = lseek( fileno( fin ), 0, SEEK_END ) ) < 0 ) |
| 189 | { |
| 190 | perror( "lseek" ); |
| 191 | goto exit; |
| 192 | } |
| 193 | #endif |
Paul Bakker | cce9d77 | 2011-11-18 14:26:47 +0000 | [diff] [blame] | 194 | #endif |
Paul Bakker | 5121ce5 | 2009-01-03 21:22:43 +0000 | [diff] [blame] | 195 | |
| 196 | if( fseek( fin, 0, SEEK_SET ) < 0 ) |
| 197 | { |
| 198 | fprintf( stderr, "fseek(0,SEEK_SET) failed\n" ); |
| 199 | goto exit; |
| 200 | } |
| 201 | |
| 202 | if( mode == MODE_ENCRYPT ) |
| 203 | { |
| 204 | /* |
| 205 | * Generate the initialization vector as: |
| 206 | * IV = SHA-256( filesize || filename )[0..15] |
| 207 | */ |
| 208 | for( i = 0; i < 8; i++ ) |
| 209 | buffer[i] = (unsigned char)( filesize >> ( i << 3 ) ); |
| 210 | |
| 211 | p = argv[2]; |
| 212 | |
Paul Bakker | 9e36f04 | 2013-06-30 14:34:05 +0200 | [diff] [blame] | 213 | sha256_starts( &sha_ctx, 0 ); |
| 214 | sha256_update( &sha_ctx, buffer, 8 ); |
| 215 | sha256_update( &sha_ctx, (unsigned char *) p, strlen( p ) ); |
| 216 | sha256_finish( &sha_ctx, digest ); |
Paul Bakker | 5121ce5 | 2009-01-03 21:22:43 +0000 | [diff] [blame] | 217 | |
| 218 | memcpy( IV, digest, 16 ); |
| 219 | |
| 220 | /* |
| 221 | * The last four bits in the IV are actually used |
| 222 | * to store the file size modulo the AES block size. |
| 223 | */ |
| 224 | lastn = (int)( filesize & 0x0F ); |
| 225 | |
| 226 | IV[15] = (unsigned char) |
| 227 | ( ( IV[15] & 0xF0 ) | lastn ); |
| 228 | |
| 229 | /* |
| 230 | * Append the IV at the beginning of the output. |
| 231 | */ |
| 232 | if( fwrite( IV, 1, 16, fout ) != 16 ) |
| 233 | { |
| 234 | fprintf( stderr, "fwrite(%d bytes) failed\n", 16 ); |
| 235 | goto exit; |
| 236 | } |
| 237 | |
| 238 | /* |
| 239 | * Hash the IV and the secret key together 8192 times |
| 240 | * using the result to setup the AES context and HMAC. |
| 241 | */ |
| 242 | memset( digest, 0, 32 ); |
| 243 | memcpy( digest, IV, 16 ); |
| 244 | |
| 245 | for( i = 0; i < 8192; i++ ) |
| 246 | { |
Paul Bakker | 9e36f04 | 2013-06-30 14:34:05 +0200 | [diff] [blame] | 247 | sha256_starts( &sha_ctx, 0 ); |
| 248 | sha256_update( &sha_ctx, digest, 32 ); |
| 249 | sha256_update( &sha_ctx, key, keylen ); |
| 250 | sha256_finish( &sha_ctx, digest ); |
Paul Bakker | 5121ce5 | 2009-01-03 21:22:43 +0000 | [diff] [blame] | 251 | } |
| 252 | |
| 253 | memset( key, 0, sizeof( key ) ); |
Paul Bakker | 9e36f04 | 2013-06-30 14:34:05 +0200 | [diff] [blame] | 254 | aes_setkey_enc( &aes_ctx, digest, 256 ); |
| 255 | sha256_hmac_starts( &sha_ctx, digest, 32, 0 ); |
Paul Bakker | 5121ce5 | 2009-01-03 21:22:43 +0000 | [diff] [blame] | 256 | |
| 257 | /* |
| 258 | * Encrypt and write the ciphertext. |
| 259 | */ |
| 260 | for( offset = 0; offset < filesize; offset += 16 ) |
| 261 | { |
| 262 | n = ( filesize - offset > 16 ) ? 16 : (int) |
| 263 | ( filesize - offset ); |
| 264 | |
| 265 | if( fread( buffer, 1, n, fin ) != (size_t) n ) |
| 266 | { |
| 267 | fprintf( stderr, "fread(%d bytes) failed\n", n ); |
| 268 | goto exit; |
| 269 | } |
| 270 | |
| 271 | for( i = 0; i < 16; i++ ) |
| 272 | buffer[i] = (unsigned char)( buffer[i] ^ IV[i] ); |
| 273 | |
| 274 | aes_crypt_ecb( &aes_ctx, AES_ENCRYPT, buffer, buffer ); |
Paul Bakker | 9e36f04 | 2013-06-30 14:34:05 +0200 | [diff] [blame] | 275 | sha256_hmac_update( &sha_ctx, buffer, 16 ); |
Paul Bakker | 5121ce5 | 2009-01-03 21:22:43 +0000 | [diff] [blame] | 276 | |
| 277 | if( fwrite( buffer, 1, 16, fout ) != 16 ) |
| 278 | { |
| 279 | fprintf( stderr, "fwrite(%d bytes) failed\n", 16 ); |
| 280 | goto exit; |
| 281 | } |
| 282 | |
| 283 | memcpy( IV, buffer, 16 ); |
| 284 | } |
| 285 | |
| 286 | /* |
| 287 | * Finally write the HMAC. |
| 288 | */ |
Paul Bakker | 9e36f04 | 2013-06-30 14:34:05 +0200 | [diff] [blame] | 289 | sha256_hmac_finish( &sha_ctx, digest ); |
Paul Bakker | 5121ce5 | 2009-01-03 21:22:43 +0000 | [diff] [blame] | 290 | |
| 291 | if( fwrite( digest, 1, 32, fout ) != 32 ) |
| 292 | { |
| 293 | fprintf( stderr, "fwrite(%d bytes) failed\n", 16 ); |
| 294 | goto exit; |
| 295 | } |
| 296 | } |
| 297 | |
| 298 | if( mode == MODE_DECRYPT ) |
| 299 | { |
| 300 | unsigned char tmp[16]; |
| 301 | |
| 302 | /* |
| 303 | * The encrypted file must be structured as follows: |
| 304 | * |
| 305 | * 00 .. 15 Initialization Vector |
| 306 | * 16 .. 31 AES Encrypted Block #1 |
| 307 | * .. |
| 308 | * N*16 .. (N+1)*16 - 1 AES Encrypted Block #N |
| 309 | * (N+1)*16 .. (N+1)*16 + 32 HMAC-SHA-256(ciphertext) |
| 310 | */ |
| 311 | if( filesize < 48 ) |
| 312 | { |
| 313 | fprintf( stderr, "File too short to be encrypted.\n" ); |
| 314 | goto exit; |
| 315 | } |
| 316 | |
| 317 | if( ( filesize & 0x0F ) != 0 ) |
| 318 | { |
| 319 | fprintf( stderr, "File size not a multiple of 16.\n" ); |
| 320 | goto exit; |
| 321 | } |
| 322 | |
| 323 | /* |
Paul Bakker | 60b1d10 | 2013-10-29 10:02:51 +0100 | [diff] [blame] | 324 | * Subtract the IV + HMAC length. |
Paul Bakker | 5121ce5 | 2009-01-03 21:22:43 +0000 | [diff] [blame] | 325 | */ |
| 326 | filesize -= ( 16 + 32 ); |
| 327 | |
| 328 | /* |
| 329 | * Read the IV and original filesize modulo 16. |
| 330 | */ |
| 331 | if( fread( buffer, 1, 16, fin ) != 16 ) |
| 332 | { |
| 333 | fprintf( stderr, "fread(%d bytes) failed\n", 16 ); |
| 334 | goto exit; |
| 335 | } |
| 336 | |
| 337 | memcpy( IV, buffer, 16 ); |
| 338 | lastn = IV[15] & 0x0F; |
| 339 | |
| 340 | /* |
| 341 | * Hash the IV and the secret key together 8192 times |
| 342 | * using the result to setup the AES context and HMAC. |
| 343 | */ |
| 344 | memset( digest, 0, 32 ); |
| 345 | memcpy( digest, IV, 16 ); |
| 346 | |
| 347 | for( i = 0; i < 8192; i++ ) |
| 348 | { |
Paul Bakker | 9e36f04 | 2013-06-30 14:34:05 +0200 | [diff] [blame] | 349 | sha256_starts( &sha_ctx, 0 ); |
| 350 | sha256_update( &sha_ctx, digest, 32 ); |
| 351 | sha256_update( &sha_ctx, key, keylen ); |
| 352 | sha256_finish( &sha_ctx, digest ); |
Paul Bakker | 5121ce5 | 2009-01-03 21:22:43 +0000 | [diff] [blame] | 353 | } |
| 354 | |
| 355 | memset( key, 0, sizeof( key ) ); |
| 356 | aes_setkey_dec( &aes_ctx, digest, 256 ); |
Paul Bakker | 9e36f04 | 2013-06-30 14:34:05 +0200 | [diff] [blame] | 357 | sha256_hmac_starts( &sha_ctx, digest, 32, 0 ); |
Paul Bakker | 5121ce5 | 2009-01-03 21:22:43 +0000 | [diff] [blame] | 358 | |
| 359 | /* |
| 360 | * Decrypt and write the plaintext. |
| 361 | */ |
| 362 | for( offset = 0; offset < filesize; offset += 16 ) |
| 363 | { |
| 364 | if( fread( buffer, 1, 16, fin ) != 16 ) |
| 365 | { |
| 366 | fprintf( stderr, "fread(%d bytes) failed\n", 16 ); |
| 367 | goto exit; |
| 368 | } |
| 369 | |
| 370 | memcpy( tmp, buffer, 16 ); |
Paul Bakker | 9e36f04 | 2013-06-30 14:34:05 +0200 | [diff] [blame] | 371 | |
| 372 | sha256_hmac_update( &sha_ctx, buffer, 16 ); |
Paul Bakker | 5121ce5 | 2009-01-03 21:22:43 +0000 | [diff] [blame] | 373 | aes_crypt_ecb( &aes_ctx, AES_DECRYPT, buffer, buffer ); |
Paul Bakker | 9e36f04 | 2013-06-30 14:34:05 +0200 | [diff] [blame] | 374 | |
Paul Bakker | 5121ce5 | 2009-01-03 21:22:43 +0000 | [diff] [blame] | 375 | for( i = 0; i < 16; i++ ) |
| 376 | buffer[i] = (unsigned char)( buffer[i] ^ IV[i] ); |
| 377 | |
| 378 | memcpy( IV, tmp, 16 ); |
| 379 | |
| 380 | n = ( lastn > 0 && offset == filesize - 16 ) |
| 381 | ? lastn : 16; |
| 382 | |
| 383 | if( fwrite( buffer, 1, n, fout ) != (size_t) n ) |
| 384 | { |
| 385 | fprintf( stderr, "fwrite(%d bytes) failed\n", n ); |
| 386 | goto exit; |
| 387 | } |
| 388 | } |
| 389 | |
| 390 | /* |
| 391 | * Verify the message authentication code. |
| 392 | */ |
Paul Bakker | 9e36f04 | 2013-06-30 14:34:05 +0200 | [diff] [blame] | 393 | sha256_hmac_finish( &sha_ctx, digest ); |
Paul Bakker | 5121ce5 | 2009-01-03 21:22:43 +0000 | [diff] [blame] | 394 | |
| 395 | if( fread( buffer, 1, 32, fin ) != 32 ) |
| 396 | { |
| 397 | fprintf( stderr, "fread(%d bytes) failed\n", 32 ); |
| 398 | goto exit; |
| 399 | } |
| 400 | |
Manuel Pégourié-Gonnard | 291f9af | 2013-10-28 12:51:32 +0100 | [diff] [blame^] | 401 | /* Use constant-time buffer comparison */ |
| 402 | diff = 0; |
| 403 | for( i = 0; i < 32; i++ ) |
| 404 | diff |= digest[i] ^ buffer[i]; |
| 405 | |
| 406 | if( diff != 0 ) |
Paul Bakker | 5121ce5 | 2009-01-03 21:22:43 +0000 | [diff] [blame] | 407 | { |
| 408 | fprintf( stderr, "HMAC check failed: wrong key, " |
| 409 | "or file corrupted.\n" ); |
| 410 | goto exit; |
| 411 | } |
| 412 | } |
| 413 | |
| 414 | ret = 0; |
| 415 | |
| 416 | exit: |
Paul Bakker | 6d44032 | 2011-02-06 12:49:19 +0000 | [diff] [blame] | 417 | if( fin ) |
| 418 | fclose( fin ); |
| 419 | if( fout ) |
| 420 | fclose( fout ); |
Paul Bakker | 5121ce5 | 2009-01-03 21:22:43 +0000 | [diff] [blame] | 421 | |
| 422 | memset( buffer, 0, sizeof( buffer ) ); |
| 423 | memset( digest, 0, sizeof( digest ) ); |
| 424 | |
| 425 | memset( &aes_ctx, 0, sizeof( aes_context ) ); |
Paul Bakker | 9e36f04 | 2013-06-30 14:34:05 +0200 | [diff] [blame] | 426 | memset( &sha_ctx, 0, sizeof( sha256_context ) ); |
Paul Bakker | 5121ce5 | 2009-01-03 21:22:43 +0000 | [diff] [blame] | 427 | |
| 428 | return( ret ); |
| 429 | } |
Paul Bakker | 9e36f04 | 2013-06-30 14:34:05 +0200 | [diff] [blame] | 430 | #endif /* POLARSSL_AES_C && POLARSSL_SHA256_C */ |