Skip to content

Commit

Permalink
Kyber benchmark: allow ML-KEM and Kyber
Browse files Browse the repository at this point in the history
Fix benchmark to use ML-KEM/Kyber depending on how code is built.
  • Loading branch information
SparkiDev committed Nov 11, 2024
1 parent c08bbf0 commit cadafff
Showing 1 changed file with 41 additions and 0 deletions.
41 changes: 41 additions & 0 deletions wolfcrypt/benchmark/benchmark.c
Original file line number Diff line number Diff line change
Expand Up @@ -3652,6 +3652,24 @@ static void* benchmarks_do(void* args)

#ifdef WOLFSSL_HAVE_KYBER
if (bench_all || (bench_pq_asym_algs & BENCH_KYBER)) {
#ifndef WOLFSSL_NO_ML_KEM
#ifdef WOLFSSL_KYBER512
if (bench_all || (bench_pq_asym_algs & BENCH_KYBER512)) {
bench_kyber(WC_ML_KEM_512);
}
#endif
#ifdef WOLFSSL_KYBER768
if (bench_all || (bench_pq_asym_algs & BENCH_KYBER768)) {
bench_kyber(WC_ML_KEM_768);
}
#endif
#ifdef WOLFSSL_KYBER1024
if (bench_all || (bench_pq_asym_algs & BENCH_KYBER1024)) {
bench_kyber(WC_ML_KEM_1024);
}
#endif
#endif
#ifdef WOLFSSL_KYBER_ORIGINAL
#ifdef WOLFSSL_KYBER512
if (bench_all || (bench_pq_asym_algs & BENCH_KYBER512)) {
bench_kyber(KYBER512);
Expand All @@ -3667,6 +3685,7 @@ static void* benchmarks_do(void* args)
bench_kyber(KYBER1024);
}
#endif
#endif
}
#endif

Expand Down Expand Up @@ -9471,6 +9490,27 @@ void bench_kyber(int type)
int keySize = 0;

switch (type) {
#ifndef WOLFSSL_NO_ML_KEM
#ifdef WOLFSSL_WC_ML_KEM_512
case WC_ML_KEM_512:
name = "ML-KEM 512 ";
keySize = 128;
break;
#endif
#ifdef WOLFSSL_WC_ML_KEM_768
case WC_ML_KEM_768:
name = "ML-KEM 768 ";
keySize = 192;
break;
#endif
#ifdef WOLFSSL_WC_ML_KEM_1024
case WC_ML_KEM_1024:
name = "ML-KEM 1024 ";
keySize = 256;
break;
#endif
#endif
#ifdef WOLFSSL_KYBER_ORIGINAL
#ifdef WOLFSSL_KYBER512
case KYBER512:
name = "KYBER512 ";
Expand All @@ -9488,6 +9528,7 @@ void bench_kyber(int type)
name = "KYBER1024";
keySize = 256;
break;
#endif
#endif
}

Expand Down

0 comments on commit cadafff

Please sign in to comment.