From: Niels Möller Date: Thu, 3 Jul 2025 16:13:16 +0000 (+0200) Subject: Add benchmarking of slh-dsa-sha2-128s. X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=27cb3d0c828517724ec0aa256ab7e3e77bb5f3e9;p=thirdparty%2Fnettle.git Add benchmarking of slh-dsa-sha2-128s. --- diff --git a/examples/hogweed-benchmark.c b/examples/hogweed-benchmark.c index 5b7930d4..927e1068 100644 --- a/examples/hogweed-benchmark.c +++ b/examples/hogweed-benchmark.c @@ -870,7 +870,7 @@ struct slh_dsa_ctx }; static void * -bench_slh_dsa_init_s (unsigned size) +bench_slh_dsa_init_shake_s (unsigned size) { struct slh_dsa_ctx *ctx; assert (size == 128); @@ -888,7 +888,7 @@ bench_slh_dsa_init_s (unsigned size) } static void * -bench_slh_dsa_init_f (unsigned size) +bench_slh_dsa_init_shake_f (unsigned size) { struct slh_dsa_ctx *ctx; assert (size == 128); @@ -905,6 +905,24 @@ bench_slh_dsa_init_f (unsigned size) return ctx; } +static void * +bench_slh_dsa_init_sha2_s (unsigned size) +{ + struct slh_dsa_ctx *ctx; + assert (size == 128); + + ctx = xalloc (sizeof (*ctx)); + memset (ctx->key, 1, SLH_DSA_128_KEY_SIZE); + memset (ctx->pub, 2, SLH_DSA_128_SEED_SIZE); + slh_dsa_sha2_128s_root (ctx->pub, ctx->key, ctx->pub + SLH_DSA_128_SEED_SIZE); + memset (ctx->msg, 3, sizeof (ctx->msg)); + ctx->sig = xalloc (SLH_DSA_128S_SIGNATURE_SIZE); + slh_dsa_sha2_128s_sign (ctx->pub, ctx->key, sizeof (ctx->msg), ctx->msg, ctx->sig); + ctx->sign = slh_dsa_sha2_128s_sign; + ctx->verify = slh_dsa_sha2_128s_verify; + return ctx; +} + static void bench_slh_dsa_sign (void *p) { @@ -959,8 +977,9 @@ struct alg alg_list[] = { { "curve", 448, bench_curve_init, bench_curve_mul_g, bench_curve_mul, bench_curve_clear }, { "gostdsa", 256, bench_gostdsa_init, bench_gostdsa_sign, bench_gostdsa_verify, bench_gostdsa_clear }, { "gostdsa", 512, bench_gostdsa_init, bench_gostdsa_sign, bench_gostdsa_verify, bench_gostdsa_clear }, - { "slh-dsa-shake-s", 128, bench_slh_dsa_init_s, bench_slh_dsa_sign, bench_slh_dsa_verify, bench_slh_dsa_clear }, - { "slh-dsa-shake-f", 128, bench_slh_dsa_init_f, bench_slh_dsa_sign, bench_slh_dsa_verify, bench_slh_dsa_clear }, + { "slh-dsa-shake-s", 128, bench_slh_dsa_init_shake_s, bench_slh_dsa_sign, bench_slh_dsa_verify, bench_slh_dsa_clear }, + { "slh-dsa-shake-f", 128, bench_slh_dsa_init_shake_f, bench_slh_dsa_sign, bench_slh_dsa_verify, bench_slh_dsa_clear }, + { "slh-dsa-sha2-s", 128, bench_slh_dsa_init_sha2_s, bench_slh_dsa_sign, bench_slh_dsa_verify, bench_slh_dsa_clear }, }; #define numberof(x) (sizeof (x) / sizeof ((x)[0]))