From a3f053360593fe6022d75466607b03877b809d0b Mon Sep 17 00:00:00 2001 From: jsing Date: Sun, 29 Jan 2023 15:22:12 +0000 Subject: [PATCH] Correct setup for BN_mul/BN_sqr benchmarks. BN_rand() takes a bit length, not the top bit. --- regress/lib/libcrypto/bn/bn_mul_div.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/regress/lib/libcrypto/bn/bn_mul_div.c b/regress/lib/libcrypto/bn/bn_mul_div.c index 2ebb06f8214..2615904c45e 100644 --- a/regress/lib/libcrypto/bn/bn_mul_div.c +++ b/regress/lib/libcrypto/bn/bn_mul_div.c @@ -1,4 +1,4 @@ -/* $OpenBSD: bn_mul_div.c,v 1.1 2023/01/29 15:18:49 jsing Exp $ */ +/* $OpenBSD: bn_mul_div.c,v 1.2 2023/01/29 15:22:12 jsing Exp $ */ /* * Copyright (c) 2023 Joel Sing * @@ -30,9 +30,9 @@ static int benchmark_bn_mul_setup(BIGNUM *a, size_t a_bits, BIGNUM *b, size_t b_bits, BIGNUM *r) { - if (!BN_rand(a, a_bits - 1, BN_RAND_TOP_ONE, BN_RAND_BOTTOM_ANY)) + if (!BN_rand(a, a_bits, BN_RAND_TOP_ONE, BN_RAND_BOTTOM_ANY)) return 0; - if (!BN_rand(b, b_bits - 1, BN_RAND_TOP_ONE, BN_RAND_BOTTOM_ANY)) + if (!BN_rand(b, b_bits, BN_RAND_TOP_ONE, BN_RAND_BOTTOM_ANY)) return 0; if (!BN_set_bit(r, (a_bits + b_bits) - 1)) return 0; @@ -51,7 +51,7 @@ static int benchmark_bn_sqr_setup(BIGNUM *a, size_t a_bits, BIGNUM *b, size_t b_bits, BIGNUM *r) { - if (!BN_rand(a, a_bits - 1, BN_RAND_TOP_ONE, BN_RAND_BOTTOM_ANY)) + if (!BN_rand(a, a_bits, BN_RAND_TOP_ONE, BN_RAND_BOTTOM_ANY)) return 0; if (!BN_set_bit(r, (a_bits + a_bits) - 1)) return 0; -- 2.20.1