diff options
-rw-r--r-- | src/regress/lib/libcrypto/bn/bn_unit.c | 26 |
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 | ||
72 | static int | ||
73 | test_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 | |||
72 | int | 95 | int |
73 | main(void) | 96 | main(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 | } |