From d669fc28c2b6423ce18f639ead40bd583135cec7 Mon Sep 17 00:00:00 2001 From: toddouska Date: Wed, 23 Sep 2015 14:42:48 -0700 Subject: [PATCH] add idea benchmark, cleanup --- configure.ac | 2 +- tests/unit.c | 3 +++ wolfcrypt/benchmark/benchmark.c | 42 +++++++++++++++++++++++++++++++++ wolfcrypt/src/idea.c | 2 -- 4 files changed, 46 insertions(+), 3 deletions(-) diff --git a/configure.ac b/configure.ac index 1725877cd..0d3f00560 100644 --- a/configure.ac +++ b/configure.ac @@ -1155,7 +1155,7 @@ AM_CONDITIONAL([BUILD_DES3], [test "x$ENABLED_DES3" = "xyes"]) # IDEA AC_ARG_ENABLE([idea], -[ --enable-idea Enable IDEA (default: disabled)], +[AS_HELP_STRING([--enable-idea],[Enable IDEA Cipher (default: disabled)])], [ ENABLED_IDEA=$enableval ], [ ENABLED_IDEA=no ] ) diff --git a/tests/unit.c b/tests/unit.c index 3a7f2452c..a05ae3ccd 100644 --- a/tests/unit.c +++ b/tests/unit.c @@ -50,6 +50,9 @@ int unit_test(int argc, char** argv) (void)argv; printf("starting unit tests...\n"); +#if defined(DEBUG_WOLFSSL) && !defined(HAVE_VALGRIND) + wolfSSL_Debugging_ON(); +#endif #ifdef HAVE_CAVIUM ret = OpenNitroxDevice(CAVIUM_DIRECT, CAVIUM_DEV_ID); if (ret != 0) diff --git a/wolfcrypt/benchmark/benchmark.c b/wolfcrypt/benchmark/benchmark.c index 938a4a641..5695a60df 100644 --- a/wolfcrypt/benchmark/benchmark.c +++ b/wolfcrypt/benchmark/benchmark.c @@ -61,6 +61,9 @@ #ifdef HAVE_ECC #include #endif +#ifdef HAVE_IDEA + #include +#endif #ifdef HAVE_CURVE25519 #include #endif @@ -121,6 +124,7 @@ void bench_des(void); +void bench_idea(void); void bench_arc4(void); void bench_hc128(void); void bench_rabbit(void); @@ -303,6 +307,9 @@ int benchmark_test(void *args) #ifndef NO_DES3 bench_des(); #endif +#ifdef HAVE_IDEA + bench_idea(); +#endif printf("\n"); @@ -661,6 +668,41 @@ void bench_des(void) #endif +#ifdef HAVE_IDEA +void bench_idea(void) +{ + Idea enc; + double start, total, persec; + int i, ret; + + ret = wc_IdeaSetKey(&enc, key, IDEA_KEY_SIZE, iv, IDEA_ENCRYPTION); + if (ret != 0) { + printf("Des3_SetKey failed, ret = %d\n", ret); + return; + } + start = current_time(1); + BEGIN_INTEL_CYCLES + + for(i = 0; i < numBlocks; i++) + wc_IdeaCbcEncrypt(&enc, plain, cipher, sizeof(plain)); + + END_INTEL_CYCLES + total = current_time(0) - start; + + persec = 1 / total * numBlocks; +#ifdef BENCH_EMBEDDED + /* since using kB, convert to MB/s */ + persec = persec / 1024; +#endif + + printf("IDEA %d %s took %5.3f seconds, %8.3f MB/s", numBlocks, + blockType, total, persec); + SHOW_INTEL_CYCLES + printf("\n"); +} +#endif /* HAVE_IDEA */ + + #ifndef NO_RC4 void bench_arc4(void) { diff --git a/wolfcrypt/src/idea.c b/wolfcrypt/src/idea.c index 3daee1a10..7214af120 100644 --- a/wolfcrypt/src/idea.c +++ b/wolfcrypt/src/idea.c @@ -23,8 +23,6 @@ #include #endif -#include - #include #ifdef HAVE_IDEA