From 0f2eacbd09da84b8cdf781868f148b067da2783d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Manuel=20P=C3=A9gouri=C3=A9-Gonnard?= Date: Mon, 25 Nov 2013 17:55:17 +0100 Subject: [PATCH] crypt_and_hash: check MAC earlier --- programs/aes/crypt_and_hash.c | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/programs/aes/crypt_and_hash.c b/programs/aes/crypt_and_hash.c index 50218e164..333f10e22 100644 --- a/programs/aes/crypt_and_hash.c +++ b/programs/aes/crypt_and_hash.c @@ -455,17 +455,6 @@ int main( int argc, char *argv[] ) } } - /* - * Write the final block of data - */ - cipher_finish( &cipher_ctx, output, &olen ); - - if( fwrite( output, 1, olen, fout ) != olen ) - { - fprintf( stderr, "fwrite(%ld bytes) failed\n", (long) olen ); - goto exit; - } - /* * Verify the message authentication code. */ @@ -488,6 +477,17 @@ int main( int argc, char *argv[] ) "or file corrupted.\n" ); goto exit; } + + /* + * Write the final block of data + */ + cipher_finish( &cipher_ctx, output, &olen ); + + if( fwrite( output, 1, olen, fout ) != olen ) + { + fprintf( stderr, "fwrite(%ld bytes) failed\n", (long) olen ); + goto exit; + } } ret = 0;