From 3d58fe8af6edcff68b77633d62624025b053c7fc Mon Sep 17 00:00:00 2001 From: Paul Bakker Date: Wed, 4 Jul 2012 17:15:31 +0000 Subject: [PATCH] - Added Blowfish to benchmarks --- programs/test/benchmark.c | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/programs/test/benchmark.c b/programs/test/benchmark.c index 55972c9bd..86de2c63c 100644 --- a/programs/test/benchmark.c +++ b/programs/test/benchmark.c @@ -41,6 +41,7 @@ #include "polarssl/arc4.h" #include "polarssl/des.h" #include "polarssl/aes.h" +#include "polarssl/blowfish.h" #include "polarssl/camellia.h" #include "polarssl/gcm.h" #include "polarssl/rsa.h" @@ -104,6 +105,9 @@ int main( int argc, char *argv[] ) gcm_context gcm; #endif #endif +#if defined(POLARSSL_BLOWFISH_C) + blowfish_context blowfish; +#endif #if defined(POLARSSL_CAMELLIA_C) camellia_context camellia; #endif @@ -327,6 +331,30 @@ int main( int argc, char *argv[] ) } #endif +#if defined(POLARSSL_BLOWFISH_C) + for( keysize = 128; keysize <= 256; keysize += 64 ) + { + printf( " BLOWFISH-CBC-%d: ", keysize ); + fflush( stdout ); + + memset( buf, 0, sizeof( buf ) ); + memset( tmp, 0, sizeof( tmp ) ); + blowfish_setkey( &blowfish, tmp, keysize ); + + set_alarm( 1 ); + + for( i = 1; ! alarmed; i++ ) + blowfish_crypt_cbc( &blowfish, BLOWFISH_ENCRYPT, BUFSIZE, tmp, buf, buf ); + + tsc = hardclock(); + for( j = 0; j < 4096; j++ ) + blowfish_crypt_cbc( &blowfish, BLOWFISH_ENCRYPT, BUFSIZE, tmp, buf, buf ); + + printf( "%9lu Kb/s, %9lu cycles/byte\n", i * BUFSIZE / 1024, + ( hardclock() - tsc ) / ( j * BUFSIZE ) ); + } +#endif + #if defined(POLARSSL_HAVEGE_C) printf( HEADER_FORMAT, "HAVEGE" ); fflush( stdout );