From ac3a3e69b377c91c63fb467b1d62980b111016f2 Mon Sep 17 00:00:00 2001 From: jsing <> Date: Sun, 29 Jan 2023 15:22:12 +0000 Subject: Correct setup for BN_mul/BN_sqr benchmarks. BN_rand() takes a bit length, not the top bit. --- src/regress/lib/libcrypto/bn/bn_mul_div.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'src') diff --git a/src/regress/lib/libcrypto/bn/bn_mul_div.c b/src/regress/lib/libcrypto/bn/bn_mul_div.c index 2ebb06f821..2615904c45 100644 --- a/src/regress/lib/libcrypto/bn/bn_mul_div.c +++ b/src/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; -- cgit v1.2.3-55-g6feb