Add AES-Counter to benchmark.c
This commit is contained in:
parent
65dc202356
commit
a12fe60723
11
.gitignore
vendored
11
.gitignore
vendored
@ -46,10 +46,17 @@ testsuite/*.pem
|
||||
testsuite/*.raw
|
||||
cert.der
|
||||
cert.pem
|
||||
certecc.der
|
||||
certecc.pem
|
||||
othercert.der
|
||||
othercert.pem
|
||||
key.der
|
||||
key.pem
|
||||
certreq.der
|
||||
certreq.pem
|
||||
pkcs7cert.der
|
||||
pkcs7signedData.der
|
||||
pkcs7envelopedData.der
|
||||
diff
|
||||
sslSniffer/sslSnifferTest/tracefile.txt
|
||||
*.gz
|
||||
@ -81,9 +88,13 @@ cov-int
|
||||
cyassl.tgz
|
||||
*.log
|
||||
*.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\LPC43xx/
|
||||
*.gcno
|
||||
*.gcda
|
||||
*.gcov
|
||||
|
||||
Memo/
|
||||
|
@ -85,6 +85,7 @@ void bench_rabbit(void);
|
||||
void bench_aes(int);
|
||||
void bench_aesgcm(void);
|
||||
void bench_aesccm(void);
|
||||
void bench_aesctr(void);
|
||||
void bench_camellia(void);
|
||||
|
||||
void bench_md5(void);
|
||||
@ -155,6 +156,11 @@ int benchmark_test(void *args)
|
||||
#ifdef HAVE_AESGCM
|
||||
bench_aesgcm();
|
||||
#endif
|
||||
|
||||
#ifdef CYASSL_AES_COUNTER
|
||||
bench_aesctr();
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_AESCCM
|
||||
bench_aesccm();
|
||||
#endif
|
||||
@ -285,7 +291,7 @@ void bench_aes(int show)
|
||||
#endif
|
||||
|
||||
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);
|
||||
#ifdef HAVE_CAVIUM
|
||||
AesFreeCavium(&enc);
|
||||
@ -320,13 +326,40 @@ void bench_aesgcm(void)
|
||||
persec = persec / 1024;
|
||||
#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);
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
#ifdef HAVE_AESCCM
|
||||
|
||||
#ifdef CYASSL_AESCCM
|
||||
void bench_aesccm(void)
|
||||
{
|
||||
Aes enc;
|
||||
@ -348,7 +381,7 @@ void bench_aesccm(void)
|
||||
persec = persec / 1024;
|
||||
#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);
|
||||
}
|
||||
#endif
|
||||
@ -375,7 +408,7 @@ void bench_camellia(void)
|
||||
persec = persec / 1024;
|
||||
#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);
|
||||
}
|
||||
#endif
|
||||
@ -406,7 +439,7 @@ void bench_des(void)
|
||||
persec = persec / 1024;
|
||||
#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);
|
||||
#ifdef HAVE_CAVIUM
|
||||
Des3_FreeCavium(&enc);
|
||||
@ -440,7 +473,7 @@ void bench_arc4(void)
|
||||
persec = persec / 1024;
|
||||
#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);
|
||||
#ifdef HAVE_CAVIUM
|
||||
Arc4FreeCavium(&enc);
|
||||
@ -469,7 +502,7 @@ void bench_hc128(void)
|
||||
persec = persec / 1024;
|
||||
#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);
|
||||
}
|
||||
#endif /* HAVE_HC128 */
|
||||
@ -495,7 +528,7 @@ void bench_rabbit(void)
|
||||
persec = persec / 1024;
|
||||
#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);
|
||||
}
|
||||
#endif /* NO_RABBIT */
|
||||
@ -524,7 +557,7 @@ void bench_md5(void)
|
||||
persec = persec / 1024;
|
||||
#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);
|
||||
}
|
||||
#endif /* NO_MD5 */
|
||||
@ -553,7 +586,7 @@ void bench_sha(void)
|
||||
persec = persec / 1024;
|
||||
#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);
|
||||
}
|
||||
#endif /* NO_SHA */
|
||||
@ -582,7 +615,7 @@ void bench_sha256(void)
|
||||
persec = persec / 1024;
|
||||
#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);
|
||||
}
|
||||
#endif
|
||||
@ -610,7 +643,7 @@ void bench_sha512(void)
|
||||
persec = persec / 1024;
|
||||
#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);
|
||||
}
|
||||
#endif
|
||||
@ -638,7 +671,7 @@ void bench_ripemd(void)
|
||||
persec = persec / 1024;
|
||||
#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);
|
||||
}
|
||||
#endif
|
||||
@ -667,7 +700,7 @@ void bench_blake2(void)
|
||||
persec = persec / 1024;
|
||||
#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);
|
||||
}
|
||||
#endif
|
||||
@ -749,7 +782,7 @@ void bench_rsa(void)
|
||||
each = total / ntimes; /* per second */
|
||||
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);
|
||||
|
||||
if (ret < 0) {
|
||||
@ -768,7 +801,7 @@ void bench_rsa(void)
|
||||
each = total / ntimes; /* per second */
|
||||
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);
|
||||
|
||||
FreeRsaKey(&rsaKey);
|
||||
@ -854,7 +887,7 @@ void bench_dh(void)
|
||||
each = total / ntimes; /* per second */
|
||||
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);
|
||||
|
||||
DhGenerateKeyPair(&dhKey, &rng, priv2, &privSz2, pub2, &pubSz2);
|
||||
@ -867,7 +900,7 @@ void bench_dh(void)
|
||||
each = total / ntimes; /* per second */
|
||||
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);
|
||||
|
||||
#if !defined(USE_CERT_BUFFERS_1024) && !defined(USE_CERT_BUFFERS_2048)
|
||||
@ -897,7 +930,7 @@ void bench_rsaKeyGen(void)
|
||||
each = total / genTimes; /* per second */
|
||||
milliEach = each * 1000; /* millisconds */
|
||||
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);
|
||||
|
||||
/* 2048 bit */
|
||||
@ -912,7 +945,7 @@ void bench_rsaKeyGen(void)
|
||||
total = current_time(0) - start;
|
||||
each = total / genTimes; /* per second */
|
||||
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);
|
||||
}
|
||||
#endif /* CYASSL_KEY_GEN */
|
||||
@ -941,7 +974,7 @@ void bench_eccKeyGen(void)
|
||||
each = total / genTimes; /* per second */
|
||||
milliEach = each * 1000; /* millisconds */
|
||||
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);
|
||||
}
|
||||
|
||||
@ -991,7 +1024,7 @@ void bench_eccKeyAgree(void)
|
||||
total = current_time(0) - start;
|
||||
each = total / agreeTimes; /* per second */
|
||||
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);
|
||||
|
||||
/* make dummy digest */
|
||||
@ -1013,7 +1046,7 @@ void bench_eccKeyAgree(void)
|
||||
total = current_time(0) - start;
|
||||
each = total / agreeTimes; /* per second */
|
||||
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);
|
||||
|
||||
start = current_time(1);
|
||||
@ -1030,7 +1063,7 @@ void bench_eccKeyAgree(void)
|
||||
total = current_time(0) - start;
|
||||
each = total / agreeTimes; /* per second */
|
||||
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);
|
||||
|
||||
ecc_free(&genKey2);
|
||||
|
Loading…
Reference in New Issue
Block a user