- Added base Galois/Counter mode (GCM) for AES
diff --git a/programs/test/benchmark.c b/programs/test/benchmark.c
index 0597f6b..0a43094 100644
--- a/programs/test/benchmark.c
+++ b/programs/test/benchmark.c
@@ -42,6 +42,7 @@
#include "polarssl/des.h"
#include "polarssl/aes.h"
#include "polarssl/camellia.h"
+#include "polarssl/gcm.h"
#include "polarssl/rsa.h"
#include "polarssl/timing.h"
#include "polarssl/havege.h"
@@ -99,6 +100,9 @@
#endif
#if defined(POLARSSL_AES_C)
aes_context aes;
+#if defined(POLARSSL_GCM_C)
+ gcm_context gcm;
+#endif
#endif
#if defined(POLARSSL_CAMELLIA_C)
camellia_context camellia;
@@ -255,7 +259,7 @@
#if defined(POLARSSL_AES_C)
for( keysize = 128; keysize <= 256; keysize += 64 )
{
- printf( " AES-%d : ", keysize );
+ printf( " AES-CBC-%d : ", keysize );
fflush( stdout );
memset( buf, 0, sizeof( buf ) );
@@ -274,12 +278,35 @@
printf( "%9lu Kb/s, %9lu cycles/byte\n", i * BUFSIZE / 1024,
( hardclock() - tsc ) / ( j * BUFSIZE ) );
}
+#if defined(POLARSSL_GCM_C)
+ for( keysize = 128; keysize <= 256; keysize += 64 )
+ {
+ printf( " AES-GCM-%d : ", keysize );
+ fflush( stdout );
+
+ memset( buf, 0, sizeof( buf ) );
+ memset( tmp, 0, sizeof( tmp ) );
+ gcm_init( &gcm, tmp, keysize );
+
+ set_alarm( 1 );
+
+ for( i = 1; ! alarmed; i++ )
+ gcm_crypt_and_tag( &gcm, GCM_ENCRYPT, BUFSIZE, tmp, 16, NULL, 0, buf, buf, 16, tmp );
+
+ tsc = hardclock();
+ for( j = 0; j < 4096; j++ )
+ gcm_crypt_and_tag( &gcm, GCM_ENCRYPT, BUFSIZE, tmp, 16, NULL, 0, buf, buf, 16, tmp );
+
+ printf( "%9lu Kb/s, %9lu cycles/byte\n", i * BUFSIZE / 1024,
+ ( hardclock() - tsc ) / ( j * BUFSIZE ) );
+ }
+#endif
#endif
#if defined(POLARSSL_CAMELLIA_C)
for( keysize = 128; keysize <= 256; keysize += 64 )
{
- printf( " CAMELLIA-%d : ", keysize );
+ printf( " CAMELLIA-CBC-%d: ", keysize );
fflush( stdout );
memset( buf, 0, sizeof( buf ) );
diff --git a/programs/test/selftest.c b/programs/test/selftest.c
index 6a63db4..ee31fdc 100644
--- a/programs/test/selftest.c
+++ b/programs/test/selftest.c
@@ -33,6 +33,7 @@
#include "polarssl/config.h"
#include "polarssl/ctr_drbg.h"
+#include "polarssl/gcm.h"
#include "polarssl/md2.h"
#include "polarssl/md4.h"
#include "polarssl/md5.h"
@@ -108,6 +109,11 @@
return( ret );
#endif
+#if defined(POLARSSL_GCM_C)
+ if( ( ret = gcm_self_test( v ) ) != 0 )
+ return( ret );
+#endif
+
#if defined(POLARSSL_BASE64_C)
if( ( ret = base64_self_test( v ) ) != 0 )
return( ret );