mirror of
https://boringssl.googlesource.com/boringssl
synced 2026-07-21 14:43:51 +00:00
MLKEM benchmark: also add a "private key from seed" benchmark.
Change-Id: Ie78a79edb29e1ef0ed31ec621290262e6a6a6964 Reviewed-on: https://boringssl-review.googlesource.com/c/boringssl/+/98067 Reviewed-by: Xiangfei Ding <xfding@google.com> Auto-Submit: Rudolf Polzer <rpolzer@google.com> Commit-Queue: Xiangfei Ding <xfding@google.com>
This commit is contained in:
committed by
boringssl-scoped@luci-project-accounts.iam.gserviceaccount.com
parent
e748facbaa
commit
9ae3188aba
@@ -21,6 +21,7 @@
|
||||
#include <openssl/err.h>
|
||||
#include <openssl/evp.h>
|
||||
#include <openssl/mlkem.h>
|
||||
#include <openssl/rand.h>
|
||||
|
||||
#include "./internal.h"
|
||||
|
||||
@@ -136,6 +137,23 @@ void BM_SpeedMLKEM768KeyGenOnly(benchmark::State &state) {
|
||||
}
|
||||
}
|
||||
|
||||
void BM_SpeedMLKEM768PrivateKeyFromSeedOnly(benchmark::State &state) {
|
||||
for (auto _ : state) {
|
||||
state.PauseTiming();
|
||||
uint8_t seed[MLKEM_SEED_BYTES];
|
||||
RAND_bytes(seed, sizeof(seed));
|
||||
benchmark::DoNotOptimize(seed);
|
||||
state.ResumeTiming();
|
||||
|
||||
MLKEM768_private_key priv;
|
||||
if (!MLKEM768_private_key_from_seed(&priv, seed, sizeof(seed))) {
|
||||
state.SkipWithError("MLKEM768_private_key_from_seed failed");
|
||||
return;
|
||||
}
|
||||
benchmark::DoNotOptimize(priv);
|
||||
}
|
||||
}
|
||||
|
||||
void BM_SpeedMLKEM768DecapOnly(benchmark::State &state) {
|
||||
uint8_t ciphertext[MLKEM768_CIPHERTEXT_BYTES];
|
||||
// This ciphertext is nonsense, but decap is constant-time so, for the
|
||||
@@ -215,6 +233,23 @@ void BM_SpeedMLKEM1024KeyGenOnly(benchmark::State &state) {
|
||||
}
|
||||
}
|
||||
|
||||
void BM_SpeedMLKEM1024PrivateKeyFromSeedOnly(benchmark::State &state) {
|
||||
for (auto _ : state) {
|
||||
state.PauseTiming();
|
||||
uint8_t seed[MLKEM_SEED_BYTES];
|
||||
RAND_bytes(seed, sizeof(seed));
|
||||
benchmark::DoNotOptimize(seed);
|
||||
state.ResumeTiming();
|
||||
|
||||
MLKEM1024_private_key priv;
|
||||
if (!MLKEM1024_private_key_from_seed(&priv, seed, sizeof(seed))) {
|
||||
state.SkipWithError("MLKEM1024_private_key_from_seed failed");
|
||||
return;
|
||||
}
|
||||
benchmark::DoNotOptimize(priv);
|
||||
}
|
||||
}
|
||||
|
||||
void BM_SpeedMLKEM1024DecapOnly(benchmark::State &state) {
|
||||
uint8_t ciphertext[MLKEM1024_CIPHERTEXT_BYTES];
|
||||
// This ciphertext is nonsense, but decap is constant-time so, for the
|
||||
@@ -294,10 +329,14 @@ BSSL_BENCH_LAZY_REGISTER() {
|
||||
BENCHMARK(BM_SpeedMLKEM1024ParseEncap)->Apply(bssl::bench::SetThreads);
|
||||
|
||||
BENCHMARK(BM_SpeedMLKEM768KeyGenOnly)->Apply(bssl::bench::SetThreads);
|
||||
BENCHMARK(BM_SpeedMLKEM768PrivateKeyFromSeedOnly)
|
||||
->Apply(bssl::bench::SetThreads);
|
||||
BENCHMARK(BM_SpeedMLKEM768DecapOnly)->Apply(bssl::bench::SetThreads);
|
||||
BENCHMARK(BM_SpeedMLKEM768ParseOnly)->Apply(bssl::bench::SetThreads);
|
||||
BENCHMARK(BM_SpeedMLKEM768EncapOnly)->Apply(bssl::bench::SetThreads);
|
||||
BENCHMARK(BM_SpeedMLKEM1024KeyGenOnly)->Apply(bssl::bench::SetThreads);
|
||||
BENCHMARK(BM_SpeedMLKEM1024PrivateKeyFromSeedOnly)
|
||||
->Apply(bssl::bench::SetThreads);
|
||||
BENCHMARK(BM_SpeedMLKEM1024DecapOnly)->Apply(bssl::bench::SetThreads);
|
||||
BENCHMARK(BM_SpeedMLKEM1024ParseOnly)->Apply(bssl::bench::SetThreads);
|
||||
BENCHMARK(BM_SpeedMLKEM1024EncapOnly)->Apply(bssl::bench::SetThreads);
|
||||
|
||||
Reference in New Issue
Block a user