diff options
Diffstat (limited to 'src')
| -rw-r--r-- | src/regress/lib/libcrypto/bn/bn_unit.c | 17 |
1 files changed, 13 insertions, 4 deletions
diff --git a/src/regress/lib/libcrypto/bn/bn_unit.c b/src/regress/lib/libcrypto/bn/bn_unit.c index bc49192b8c..3a88bfca6e 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.6 2023/06/20 06:46:07 tb Exp $ */ | 1 | /* $OpenBSD: bn_unit.c,v 1.7 2023/06/21 07:15:38 jsing Exp $ */ |
| 2 | 2 | ||
| 3 | /* | 3 | /* |
| 4 | * Copyright (c) 2022 Theo Buehler <tb@openbsd.org> | 4 | * Copyright (c) 2022 Theo Buehler <tb@openbsd.org> |
| @@ -80,7 +80,7 @@ test_bn_num_bits(void) | |||
| 80 | errx(1, "BN_new"); | 80 | errx(1, "BN_new"); |
| 81 | 81 | ||
| 82 | if ((num_bits = BN_num_bits(bn)) != 0) { | 82 | if ((num_bits = BN_num_bits(bn)) != 0) { |
| 83 | warnx("BN_num_bits(0): want 0, got %d", num_bits); | 83 | warnx("BN_num_bits(0): got %d, want 0", num_bits); |
| 84 | failed |= 1; | 84 | failed |= 1; |
| 85 | } | 85 | } |
| 86 | 86 | ||
| @@ -89,14 +89,23 @@ test_bn_num_bits(void) | |||
| 89 | 89 | ||
| 90 | for (i = 0; i <= 5 * BN_BITS2; i++) { | 90 | for (i = 0; i <= 5 * BN_BITS2; i++) { |
| 91 | if ((num_bits = BN_num_bits(bn)) != i + 1) { | 91 | if ((num_bits = BN_num_bits(bn)) != i + 1) { |
| 92 | warnx("BN_num_bits(1 << %d): want %d, got %d", | 92 | warnx("BN_num_bits(1 << %d): got %d, want %d", |
| 93 | i, i + 1, num_bits); | 93 | i, num_bits, i + 1); |
| 94 | failed |= 1; | 94 | failed |= 1; |
| 95 | } | 95 | } |
| 96 | if (!BN_lshift1(bn, bn)) | 96 | if (!BN_lshift1(bn, bn)) |
| 97 | errx(1, "BN_lshift1"); | 97 | errx(1, "BN_lshift1"); |
| 98 | } | 98 | } |
| 99 | 99 | ||
| 100 | if (BN_hex2bn(&bn, "0000000000000000010000000000000000") != 34) | ||
| 101 | errx(1, "BN_hex2bn"); | ||
| 102 | |||
| 103 | if ((num_bits = BN_num_bits(bn)) != 65) { | ||
| 104 | warnx("BN_num_bits(1 << 64) padded: got %d, want %d", | ||
| 105 | num_bits, 65); | ||
| 106 | failed |= 1; | ||
| 107 | } | ||
| 108 | |||
| 100 | BN_free(bn); | 109 | BN_free(bn); |
| 101 | 110 | ||
| 102 | return failed; | 111 | return failed; |
