forked from wolfSSL/wolfssl
add SHA-384 benchmark
This commit is contained in:
@ -98,6 +98,7 @@ void bench_camellia(void);
|
|||||||
void bench_md5(void);
|
void bench_md5(void);
|
||||||
void bench_sha(void);
|
void bench_sha(void);
|
||||||
void bench_sha256(void);
|
void bench_sha256(void);
|
||||||
|
void bench_sha384(void);
|
||||||
void bench_sha512(void);
|
void bench_sha512(void);
|
||||||
void bench_ripemd(void);
|
void bench_ripemd(void);
|
||||||
|
|
||||||
@ -215,6 +216,9 @@ int benchmark_test(void *args)
|
|||||||
#ifndef NO_SHA256
|
#ifndef NO_SHA256
|
||||||
bench_sha256();
|
bench_sha256();
|
||||||
#endif
|
#endif
|
||||||
|
#ifdef CYASSL_SHA384
|
||||||
|
bench_sha384();
|
||||||
|
#endif
|
||||||
#ifdef CYASSL_SHA512
|
#ifdef CYASSL_SHA512
|
||||||
bench_sha512();
|
bench_sha512();
|
||||||
#endif
|
#endif
|
||||||
@ -763,6 +767,47 @@ void bench_sha256(void)
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#ifdef CYASSL_SHA384
|
||||||
|
void bench_sha384(void)
|
||||||
|
{
|
||||||
|
Sha384 hash;
|
||||||
|
byte digest[SHA384_DIGEST_SIZE];
|
||||||
|
double start, total, persec;
|
||||||
|
int i, ret;
|
||||||
|
|
||||||
|
ret = InitSha384(&hash);
|
||||||
|
if (ret != 0) {
|
||||||
|
printf("InitSha384 failed, ret = %d\n", ret);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
start = current_time(1);
|
||||||
|
|
||||||
|
for(i = 0; i < numBlocks; i++) {
|
||||||
|
ret = Sha384Update(&hash, plain, sizeof(plain));
|
||||||
|
if (ret != 0) {
|
||||||
|
printf("Sha384Update failed, ret = %d\n", ret);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
ret = Sha384Final(&hash, digest);
|
||||||
|
if (ret != 0) {
|
||||||
|
printf("Sha384Final failed, ret = %d\n", ret);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
total = current_time(0) - start;
|
||||||
|
persec = 1 / total * numBlocks;
|
||||||
|
#ifdef BENCH_EMBEDDED
|
||||||
|
/* since using kB, convert to MB/s */
|
||||||
|
persec = persec / 1024;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
printf("SHA-384 %d %s took %5.3f seconds, %7.3f MB/s\n", numBlocks,
|
||||||
|
blockType, total, persec);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
#ifdef CYASSL_SHA512
|
#ifdef CYASSL_SHA512
|
||||||
void bench_sha512(void)
|
void bench_sha512(void)
|
||||||
{
|
{
|
||||||
|
Reference in New Issue
Block a user