summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/regress/lib/libcrypto/bn/bn_unit.c26
1 files changed, 25 insertions, 1 deletions
diff --git a/src/regress/lib/libcrypto/bn/bn_unit.c b/src/regress/lib/libcrypto/bn/bn_unit.c
index 1af3e8868d..6c5b210739 100644
--- a/src/regress/lib/libcrypto/bn/bn_unit.c
+++ b/src/regress/lib/libcrypto/bn/bn_unit.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: bn_unit.c,v 1.2 2022/12/06 18:23:29 tb Exp $ */ 1/* $OpenBSD: bn_unit.c,v 1.3 2023/02/14 15:08:15 tb Exp $ */
2 2
3/* 3/*
4 * Copyright (c) 2022 Theo Buehler <tb@openbsd.org> 4 * Copyright (c) 2022 Theo Buehler <tb@openbsd.org>
@@ -69,12 +69,36 @@ test_bn_print_null_derefs(void)
69 return failed; 69 return failed;
70} 70}
71 71
72static int
73test_bn_num_bits_word(void)
74{
75 BN_ULONG w = 1;
76 int i, num_bits;
77 int failed = 0;
78
79 if ((num_bits = BN_num_bits_word(0)) != 0) {
80 warnx("BN_num_bits_word(0): want 0, got %d", num_bits);
81 failed |= 1;
82 }
83
84 for (i = 0; i < BN_BITS2; i++) {
85 if ((num_bits = BN_num_bits_word(w << i)) != i + 1) {
86 warnx("BN_num_bits_word(0x%llx): want %d, got %d",
87 (unsigned long long)(w << i), i + 1, num_bits);
88 failed |= 1;
89 }
90 }
91
92 return failed;
93}
94
72int 95int
73main(void) 96main(void)
74{ 97{
75 int failed = 0; 98 int failed = 0;
76 99
77 failed |= test_bn_print_null_derefs(); 100 failed |= test_bn_print_null_derefs();
101 failed |= test_bn_num_bits_word();
78 102
79 return failed; 103 return failed;
80} 104}