-/* $OpenBSD: bn_unit.c,v 1.6 2023/06/20 06:46:07 tb Exp $ */
+/* $OpenBSD: bn_unit.c,v 1.7 2023/06/21 07:15:38 jsing Exp $ */
/*
* Copyright (c) 2022 Theo Buehler <tb@openbsd.org>
errx(1, "BN_new");
if ((num_bits = BN_num_bits(bn)) != 0) {
- warnx("BN_num_bits(0): want 0, got %d", num_bits);
+ warnx("BN_num_bits(0): got %d, want 0", num_bits);
failed |= 1;
}
for (i = 0; i <= 5 * BN_BITS2; i++) {
if ((num_bits = BN_num_bits(bn)) != i + 1) {
- warnx("BN_num_bits(1 << %d): want %d, got %d",
- i, i + 1, num_bits);
+ warnx("BN_num_bits(1 << %d): got %d, want %d",
+ i, num_bits, i + 1);
failed |= 1;
}
if (!BN_lshift1(bn, bn))
errx(1, "BN_lshift1");
}
+ if (BN_hex2bn(&bn, "0000000000000000010000000000000000") != 34)
+ errx(1, "BN_hex2bn");
+
+ if ((num_bits = BN_num_bits(bn)) != 65) {
+ warnx("BN_num_bits(1 << 64) padded: got %d, want %d",
+ num_bits, 65);
+ failed |= 1;
+ }
+
BN_free(bn);
return failed;