From 414800fe212827b9deaf4e2ecf04352fddba7b28 Mon Sep 17 00:00:00 2001 From: Fabian Albert Date: Thu, 12 Oct 2023 09:22:57 +0200 Subject: [PATCH] Add LMS/HSS to speed CI tests --- src/cli/speed.cpp | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) diff --git a/src/cli/speed.cpp b/src/cli/speed.cpp index 0ee7b797686..afcfefee3ac 100644 --- a/src/cli/speed.cpp +++ b/src/cli/speed.cpp @@ -124,6 +124,10 @@ #include #endif +#if defined(BOTAN_HAS_HSS_LMS) + #include +#endif + #if defined(BOTAN_HAS_SPHINCS_PLUS_WITH_SHA2) || defined(BOTAN_HAS_SPHINCS_PLUS_WITH_SHAKE) #include #endif @@ -609,6 +613,11 @@ class Speed final : public Command { bench_xmss(provider, msec); } #endif +#if defined(BOTAN_HAS_HSS_LMS) + else if(algo == "HSS-LMS") { + bench_hss_lms(provider, msec); + } +#endif #if defined(BOTAN_HAS_SPHINCS_PLUS_WITH_SHA2) || defined(BOTAN_HAS_SPHINCS_PLUS_WITH_SHAKE) else if(algo == "SPHINCS+") { bench_sphincs_plus(provider, msec); @@ -2065,6 +2074,33 @@ class Speed final : public Command { } #endif +#if defined(BOTAN_HAS_HSS_LMS) + void bench_hss_lms(const std::string& provider, std::chrono::milliseconds msec) { + // At first we compare instances with multiple hash functions. LMS trees with + // height 10 are suitable, since they can be used for enough signatures and are + // fast enough for speed testing. + // Afterward, setups with multiple HSS layers are tested + std::vector hss_lms_instances{"SHA-256,HW(10,1)", + "SHAKE-256(256),HW(10,1)", + "SHAKE-256(192),HW(10,1)", + "Truncated(SHA-256,192),HW(10,1)", + "SHA-256,HW(10,1),HW(10,1)", + "SHA-256,HW(10,1),HW(10,1),HW(10,1)"}; + + for(auto params : hss_lms_instances) { + auto keygen_timer = make_timer(params, provider, "keygen"); + + std::unique_ptr key( + keygen_timer->run([&] { return Botan::create_private_key("HSS-LMS", rng(), params); })); + + record_result(keygen_timer); + if(bench_pk_sig(*key, params, provider, "", msec) == 1) { + break; + } + } + } +#endif + #if defined(BOTAN_HAS_ZFEC) void bench_zfec(std::chrono::milliseconds msec) { const size_t k = 4;