summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/regress/lib/libcrypto/bn/bn_print.c14
1 files changed, 13 insertions, 1 deletions
diff --git a/src/regress/lib/libcrypto/bn/bn_print.c b/src/regress/lib/libcrypto/bn/bn_print.c
index 24f261d921..47def85773 100644
--- a/src/regress/lib/libcrypto/bn/bn_print.c
+++ b/src/regress/lib/libcrypto/bn/bn_print.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: bn_print.c,v 1.3 2023/07/07 07:47:25 tb Exp $ */ 1/* $OpenBSD: bn_print.c,v 1.4 2023/07/10 20:21:37 tb Exp $ */
2 2
3/* 3/*
4 * Copyright (c) 2023 Theo Buehler <tb@openbsd.org> 4 * Copyright (c) 2023 Theo Buehler <tb@openbsd.org>
@@ -139,6 +139,11 @@ const struct print_test {
139 .want = " mana mana\n" 139 .want = " mana mana\n"
140 " 00:80:00:00:00:00:00:00:00:00\n", 140 " 00:80:00:00:00:00:00:00:00:00\n",
141 }, 141 },
142 {
143 .desc = "high bit of first nibble is set for negative number",
144 .want = " mana mana (Negative)\n"
145 " 00:80:00:00:00:00:00:00:00:00\n",
146 },
142}; 147};
143 148
144#define N_TESTCASES (sizeof(bn_print_tests) / sizeof(bn_print_tests[0])) 149#define N_TESTCASES (sizeof(bn_print_tests) / sizeof(bn_print_tests[0]))
@@ -281,6 +286,13 @@ main(void)
281 test = &bn_print_tests[testcase++]; 286 test = &bn_print_tests[testcase++];
282 failed |= bn_print_testcase(bn, test); 287 failed |= bn_print_testcase(bn, test);
283 288
289 /* high bit of first nibble is set for negative number. */
290 BN_set_negative(bn, 1);
291 if (testcase >= N_TESTCASES)
292 errx(1, "Too many tests");
293 test = &bn_print_tests[testcase++];
294 failed |= bn_print_testcase(bn, test);
295
284 if (testcase != N_TESTCASES) { 296 if (testcase != N_TESTCASES) {
285 warnx("Not all tests run"); 297 warnx("Not all tests run");
286 failed |= 1; 298 failed |= 1;