Add AES-Counter to benchmark.c

This commit is contained in:
Takashi Kojo
2014-03-10 10:46:40 +09:00
parent 65dc202356
commit a12fe60723
2 changed files with 69 additions and 25 deletions

11
.gitignore vendored
View File

@@ -46,10 +46,17 @@ testsuite/*.pem
testsuite/*.raw testsuite/*.raw
cert.der cert.der
cert.pem cert.pem
certecc.der
certecc.pem
othercert.der othercert.der
othercert.pem othercert.pem
key.der key.der
key.pem key.pem
certreq.der
certreq.pem
pkcs7cert.der
pkcs7signedData.der
pkcs7envelopedData.der
diff diff
sslSniffer/sslSnifferTest/tracefile.txt sslSniffer/sslSnifferTest/tracefile.txt
*.gz *.gz
@@ -81,9 +88,13 @@ cov-int
cyassl.tgz cyassl.tgz
*.log *.log
*.trs *.trs
IDE\MDK-ARM\Projects/
IDE\MDK-ARM\STM32F2xx_StdPeriph_Lib/inc
IDE\MDK-ARM\STM32F2xx_StdPeriph_Lib/src
IDE\MDK-ARM\LPC43xx\Drivers/ IDE\MDK-ARM\LPC43xx\Drivers/
IDE\MDK-ARM\LPC43xx\LPC43xx/ IDE\MDK-ARM\LPC43xx\LPC43xx/
*.gcno *.gcno
*.gcda *.gcda
*.gcov *.gcov
Memo/

View File

@@ -85,6 +85,7 @@ void bench_rabbit(void);
void bench_aes(int); void bench_aes(int);
void bench_aesgcm(void); void bench_aesgcm(void);
void bench_aesccm(void); void bench_aesccm(void);
void bench_aesctr(void);
void bench_camellia(void); void bench_camellia(void);
void bench_md5(void); void bench_md5(void);
@@ -155,6 +156,11 @@ int benchmark_test(void *args)
#ifdef HAVE_AESGCM #ifdef HAVE_AESGCM
bench_aesgcm(); bench_aesgcm();
#endif #endif
#ifdef CYASSL_AES_COUNTER
bench_aesctr();
#endif
#ifdef HAVE_AESCCM #ifdef HAVE_AESCCM
bench_aesccm(); bench_aesccm();
#endif #endif
@@ -285,7 +291,7 @@ void bench_aes(int show)
#endif #endif
if (show) if (show)
printf("AES %d %s took %5.3f seconds, %6.2f MB/s\n", numBlocks, printf("AES %d %s took %5.3f seconds, %6.3f MB/s\n", numBlocks,
blockType, total, persec); blockType, total, persec);
#ifdef HAVE_CAVIUM #ifdef HAVE_CAVIUM
AesFreeCavium(&enc); AesFreeCavium(&enc);
@@ -320,13 +326,40 @@ void bench_aesgcm(void)
persec = persec / 1024; persec = persec / 1024;
#endif #endif
printf("AES-GCM %d %s took %5.3f seconds, %6.2f MB/s\n", numBlocks, printf("AES-GCM %d %s took %5.3f seconds, %6.3f MB/s\n", numBlocks,
blockType, total, persec);
}
#endif
#ifdef CYASSL_AES_COUNTER
void bench_aesctr(void)
{
Aes enc;
double start, total, persec;
int i;
AesSetKeyDirect(&enc, key, AES_BLOCK_SIZE, iv, AES_ENCRYPTION);
start = current_time(1);
for(i = 0; i < numBlocks; i++)
AesCtrEncrypt(&enc, plain, cipher, sizeof(plain));
total = current_time(0) - start;
persec = 1 / total * numBlocks;
#ifdef BENCH_EMBEDDED
/* since using kB, convert to MB/s */
persec = persec / 1024;
#endif
printf("AES-CTR %d %s took %5.3f seconds, %6.3f MB/s\n", numBlocks,
blockType, total, persec); blockType, total, persec);
} }
#endif #endif
#ifdef HAVE_AESCCM
#ifdef CYASSL_AESCCM
void bench_aesccm(void) void bench_aesccm(void)
{ {
Aes enc; Aes enc;
@@ -348,7 +381,7 @@ void bench_aesccm(void)
persec = persec / 1024; persec = persec / 1024;
#endif #endif
printf("AES-CCM %d %s took %5.3f seconds, %6.2f MB/s\n", numBlocks, printf("AES-CCM %d %s took %5.3f seconds, %6.3f MB/s\n", numBlocks,
blockType, total, persec); blockType, total, persec);
} }
#endif #endif
@@ -375,7 +408,7 @@ void bench_camellia(void)
persec = persec / 1024; persec = persec / 1024;
#endif #endif
printf("Camellia %d %s took %5.3f seconds, %6.2f MB/s\n", numBlocks, printf("Camellia %d %s took %5.3f seconds, %6.3f MB/s\n", numBlocks,
blockType, total, persec); blockType, total, persec);
} }
#endif #endif
@@ -406,7 +439,7 @@ void bench_des(void)
persec = persec / 1024; persec = persec / 1024;
#endif #endif
printf("3DES %d %s took %5.3f seconds, %6.2f MB/s\n", numBlocks, printf("3DES %d %s took %5.3f seconds, %6.3f MB/s\n", numBlocks,
blockType, total, persec); blockType, total, persec);
#ifdef HAVE_CAVIUM #ifdef HAVE_CAVIUM
Des3_FreeCavium(&enc); Des3_FreeCavium(&enc);
@@ -440,7 +473,7 @@ void bench_arc4(void)
persec = persec / 1024; persec = persec / 1024;
#endif #endif
printf("ARC4 %d %s took %5.3f seconds, %6.2f MB/s\n", numBlocks, printf("ARC4 %d %s took %5.3f seconds, %6.3f MB/s\n", numBlocks,
blockType, total, persec); blockType, total, persec);
#ifdef HAVE_CAVIUM #ifdef HAVE_CAVIUM
Arc4FreeCavium(&enc); Arc4FreeCavium(&enc);
@@ -469,7 +502,7 @@ void bench_hc128(void)
persec = persec / 1024; persec = persec / 1024;
#endif #endif
printf("HC128 %d %s took %5.3f seconds, %6.2f MB/s\n", numBlocks, printf("HC128 %d %s took %5.3f seconds, %6.3f MB/s\n", numBlocks,
blockType, total, persec); blockType, total, persec);
} }
#endif /* HAVE_HC128 */ #endif /* HAVE_HC128 */
@@ -495,7 +528,7 @@ void bench_rabbit(void)
persec = persec / 1024; persec = persec / 1024;
#endif #endif
printf("RABBIT %d %s took %5.3f seconds, %6.2f MB/s\n", numBlocks, printf("RABBIT %d %s took %5.3f seconds, %6.3f MB/s\n", numBlocks,
blockType, total, persec); blockType, total, persec);
} }
#endif /* NO_RABBIT */ #endif /* NO_RABBIT */
@@ -524,7 +557,7 @@ void bench_md5(void)
persec = persec / 1024; persec = persec / 1024;
#endif #endif
printf("MD5 %d %s took %5.3f seconds, %6.2f MB/s\n", numBlocks, printf("MD5 %d %s took %5.3f seconds, %6.3f MB/s\n", numBlocks,
blockType, total, persec); blockType, total, persec);
} }
#endif /* NO_MD5 */ #endif /* NO_MD5 */
@@ -553,7 +586,7 @@ void bench_sha(void)
persec = persec / 1024; persec = persec / 1024;
#endif #endif
printf("SHA %d %s took %5.3f seconds, %6.2f MB/s\n", numBlocks, printf("SHA %d %s took %5.3f seconds, %6.3f MB/s\n", numBlocks,
blockType, total, persec); blockType, total, persec);
} }
#endif /* NO_SHA */ #endif /* NO_SHA */
@@ -582,7 +615,7 @@ void bench_sha256(void)
persec = persec / 1024; persec = persec / 1024;
#endif #endif
printf("SHA-256 %d %s took %5.3f seconds, %6.2f MB/s\n", numBlocks, printf("SHA-256 %d %s took %5.3f seconds, %6.3f MB/s\n", numBlocks,
blockType, total, persec); blockType, total, persec);
} }
#endif #endif
@@ -610,7 +643,7 @@ void bench_sha512(void)
persec = persec / 1024; persec = persec / 1024;
#endif #endif
printf("SHA-512 %d %s took %5.3f seconds, %6.2f MB/s\n", numBlocks, printf("SHA-512 %d %s took %5.3f seconds, %6.3f MB/s\n", numBlocks,
blockType, total, persec); blockType, total, persec);
} }
#endif #endif
@@ -638,7 +671,7 @@ void bench_ripemd(void)
persec = persec / 1024; persec = persec / 1024;
#endif #endif
printf("RIPEMD %d %s took %5.3f seconds, %6.2f MB/s\n", numBlocks, printf("RIPEMD %d %s took %5.3f seconds, %6.3f MB/s\n", numBlocks,
blockType, total, persec); blockType, total, persec);
} }
#endif #endif
@@ -667,7 +700,7 @@ void bench_blake2(void)
persec = persec / 1024; persec = persec / 1024;
#endif #endif
printf("BLAKE2b %d %s took %5.3f seconds, %6.2f MB/s\n", numBlocks, printf("BLAKE2b %d %s took %5.3f seconds, %6.3f MB/s\n", numBlocks,
blockType, total, persec); blockType, total, persec);
} }
#endif #endif
@@ -749,7 +782,7 @@ void bench_rsa(void)
each = total / ntimes; /* per second */ each = total / ntimes; /* per second */
milliEach = each * 1000; /* milliseconds */ milliEach = each * 1000; /* milliseconds */
printf("RSA %d encryption took %6.2f milliseconds, avg over %d" printf("RSA %d encryption took %6.3f milliseconds, avg over %d"
" iterations\n", rsaKeySz, milliEach, ntimes); " iterations\n", rsaKeySz, milliEach, ntimes);
if (ret < 0) { if (ret < 0) {
@@ -768,7 +801,7 @@ void bench_rsa(void)
each = total / ntimes; /* per second */ each = total / ntimes; /* per second */
milliEach = each * 1000; /* milliseconds */ milliEach = each * 1000; /* milliseconds */
printf("RSA %d decryption took %6.2f milliseconds, avg over %d" printf("RSA %d decryption took %6.3f milliseconds, avg over %d"
" iterations\n", rsaKeySz, milliEach, ntimes); " iterations\n", rsaKeySz, milliEach, ntimes);
FreeRsaKey(&rsaKey); FreeRsaKey(&rsaKey);
@@ -854,7 +887,7 @@ void bench_dh(void)
each = total / ntimes; /* per second */ each = total / ntimes; /* per second */
milliEach = each * 1000; /* milliseconds */ milliEach = each * 1000; /* milliseconds */
printf("DH %d key generation %6.2f milliseconds, avg over %d" printf("DH %d key generation %6.3f milliseconds, avg over %d"
" iterations\n", dhKeySz, milliEach, ntimes); " iterations\n", dhKeySz, milliEach, ntimes);
DhGenerateKeyPair(&dhKey, &rng, priv2, &privSz2, pub2, &pubSz2); DhGenerateKeyPair(&dhKey, &rng, priv2, &privSz2, pub2, &pubSz2);
@@ -867,7 +900,7 @@ void bench_dh(void)
each = total / ntimes; /* per second */ each = total / ntimes; /* per second */
milliEach = each * 1000; /* milliseconds */ milliEach = each * 1000; /* milliseconds */
printf("DH %d key agreement %6.2f milliseconds, avg over %d" printf("DH %d key agreement %6.3f milliseconds, avg over %d"
" iterations\n", dhKeySz, milliEach, ntimes); " iterations\n", dhKeySz, milliEach, ntimes);
#if !defined(USE_CERT_BUFFERS_1024) && !defined(USE_CERT_BUFFERS_2048) #if !defined(USE_CERT_BUFFERS_1024) && !defined(USE_CERT_BUFFERS_2048)
@@ -897,7 +930,7 @@ void bench_rsaKeyGen(void)
each = total / genTimes; /* per second */ each = total / genTimes; /* per second */
milliEach = each * 1000; /* millisconds */ milliEach = each * 1000; /* millisconds */
printf("\n"); printf("\n");
printf("RSA 1024 key generation %6.2f milliseconds, avg over %d" printf("RSA 1024 key generation %6.3f milliseconds, avg over %d"
" iterations\n", milliEach, genTimes); " iterations\n", milliEach, genTimes);
/* 2048 bit */ /* 2048 bit */
@@ -912,7 +945,7 @@ void bench_rsaKeyGen(void)
total = current_time(0) - start; total = current_time(0) - start;
each = total / genTimes; /* per second */ each = total / genTimes; /* per second */
milliEach = each * 1000; /* millisconds */ milliEach = each * 1000; /* millisconds */
printf("RSA 2048 key generation %6.2f milliseconds, avg over %d" printf("RSA 2048 key generation %6.3f milliseconds, avg over %d"
" iterations\n", milliEach, genTimes); " iterations\n", milliEach, genTimes);
} }
#endif /* CYASSL_KEY_GEN */ #endif /* CYASSL_KEY_GEN */
@@ -941,7 +974,7 @@ void bench_eccKeyGen(void)
each = total / genTimes; /* per second */ each = total / genTimes; /* per second */
milliEach = each * 1000; /* millisconds */ milliEach = each * 1000; /* millisconds */
printf("\n"); printf("\n");
printf("ECC 256 key generation %6.2f milliseconds, avg over %d" printf("ECC 256 key generation %6.3f milliseconds, avg over %d"
" iterations\n", milliEach, genTimes); " iterations\n", milliEach, genTimes);
} }
@@ -991,7 +1024,7 @@ void bench_eccKeyAgree(void)
total = current_time(0) - start; total = current_time(0) - start;
each = total / agreeTimes; /* per second */ each = total / agreeTimes; /* per second */
milliEach = each * 1000; /* millisconds */ milliEach = each * 1000; /* millisconds */
printf("EC-DHE key agreement %6.2f milliseconds, avg over %d" printf("EC-DHE key agreement %6.3f milliseconds, avg over %d"
" iterations\n", milliEach, agreeTimes); " iterations\n", milliEach, agreeTimes);
/* make dummy digest */ /* make dummy digest */
@@ -1013,7 +1046,7 @@ void bench_eccKeyAgree(void)
total = current_time(0) - start; total = current_time(0) - start;
each = total / agreeTimes; /* per second */ each = total / agreeTimes; /* per second */
milliEach = each * 1000; /* millisconds */ milliEach = each * 1000; /* millisconds */
printf("EC-DSA sign time %6.2f milliseconds, avg over %d" printf("EC-DSA sign time %6.3f milliseconds, avg over %d"
" iterations\n", milliEach, agreeTimes); " iterations\n", milliEach, agreeTimes);
start = current_time(1); start = current_time(1);
@@ -1030,7 +1063,7 @@ void bench_eccKeyAgree(void)
total = current_time(0) - start; total = current_time(0) - start;
each = total / agreeTimes; /* per second */ each = total / agreeTimes; /* per second */
milliEach = each * 1000; /* millisconds */ milliEach = each * 1000; /* millisconds */
printf("EC-DSA verify time %6.2f milliseconds, avg over %d" printf("EC-DSA verify time %6.3f milliseconds, avg over %d"
" iterations\n", milliEach, agreeTimes); " iterations\n", milliEach, agreeTimes);
ecc_free(&genKey2); ecc_free(&genKey2);