summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorjsing <>2023-01-29 15:22:12 +0000
committerjsing <>2023-01-29 15:22:12 +0000
commitac3a3e69b377c91c63fb467b1d62980b111016f2 (patch)
tree9b4e2b78bcfa1ac4bd80bb5f5ee2637dee8a5889 /src
parent75f8404f9416bfeeeb3000f07fad7bfe961b272a (diff)
downloadopenbsd-ac3a3e69b377c91c63fb467b1d62980b111016f2.tar.gz
openbsd-ac3a3e69b377c91c63fb467b1d62980b111016f2.tar.bz2
openbsd-ac3a3e69b377c91c63fb467b1d62980b111016f2.zip
Correct setup for BN_mul/BN_sqr benchmarks.
BN_rand() takes a bit length, not the top bit.
Diffstat (limited to 'src')
-rw-r--r--src/regress/lib/libcrypto/bn/bn_mul_div.c8
1 files changed, 4 insertions, 4 deletions
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 @@
1/* $OpenBSD: bn_mul_div.c,v 1.1 2023/01/29 15:18:49 jsing Exp $ */ 1/* $OpenBSD: bn_mul_div.c,v 1.2 2023/01/29 15:22:12 jsing Exp $ */
2/* 2/*
3 * Copyright (c) 2023 Joel Sing <jsing@openbsd.org> 3 * Copyright (c) 2023 Joel Sing <jsing@openbsd.org>
4 * 4 *
@@ -30,9 +30,9 @@ static int
30benchmark_bn_mul_setup(BIGNUM *a, size_t a_bits, BIGNUM *b, size_t b_bits, 30benchmark_bn_mul_setup(BIGNUM *a, size_t a_bits, BIGNUM *b, size_t b_bits,
31 BIGNUM *r) 31 BIGNUM *r)
32{ 32{
33 if (!BN_rand(a, a_bits - 1, BN_RAND_TOP_ONE, BN_RAND_BOTTOM_ANY)) 33 if (!BN_rand(a, a_bits, BN_RAND_TOP_ONE, BN_RAND_BOTTOM_ANY))
34 return 0; 34 return 0;
35 if (!BN_rand(b, b_bits - 1, BN_RAND_TOP_ONE, BN_RAND_BOTTOM_ANY)) 35 if (!BN_rand(b, b_bits, BN_RAND_TOP_ONE, BN_RAND_BOTTOM_ANY))
36 return 0; 36 return 0;
37 if (!BN_set_bit(r, (a_bits + b_bits) - 1)) 37 if (!BN_set_bit(r, (a_bits + b_bits) - 1))
38 return 0; 38 return 0;
@@ -51,7 +51,7 @@ static int
51benchmark_bn_sqr_setup(BIGNUM *a, size_t a_bits, BIGNUM *b, size_t b_bits, 51benchmark_bn_sqr_setup(BIGNUM *a, size_t a_bits, BIGNUM *b, size_t b_bits,
52 BIGNUM *r) 52 BIGNUM *r)
53{ 53{
54 if (!BN_rand(a, a_bits - 1, BN_RAND_TOP_ONE, BN_RAND_BOTTOM_ANY)) 54 if (!BN_rand(a, a_bits, BN_RAND_TOP_ONE, BN_RAND_BOTTOM_ANY))
55 return 0; 55 return 0;
56 if (!BN_set_bit(r, (a_bits + a_bits) - 1)) 56 if (!BN_set_bit(r, (a_bits + a_bits) - 1))
57 return 0; 57 return 0;