diff options
author | Theo Buehler <tb@cvs.openbsd.org> | 2023-07-10 20:21:38 +0000 |
---|---|---|
committer | Theo Buehler <tb@cvs.openbsd.org> | 2023-07-10 20:21:38 +0000 |
commit | d8895bda146515be46a07e1364e2989610248053 (patch) | |
tree | 2368c8683cc20ea65876d93c8103389138eefc58 /regress/lib | |
parent | c1200e9d0d527a2a0bfc66b77fe1d7429dea3ef7 (diff) |
Add test case for negative number with highest bit of top octet set
This currently adds an incorrect 00: padding, consistent with OpenSSL's
behavior.
Diffstat (limited to 'regress/lib')
-rw-r--r-- | regress/lib/libcrypto/bn/bn_print.c | 14 |
1 files changed, 13 insertions, 1 deletions
diff --git a/regress/lib/libcrypto/bn/bn_print.c b/regress/lib/libcrypto/bn/bn_print.c index 24f261d921d..47def85773c 100644 --- a/regress/lib/libcrypto/bn/bn_print.c +++ b/regress/lib/libcrypto/bn/bn_print.c @@ -1,4 +1,4 @@ -/* $OpenBSD: bn_print.c,v 1.3 2023/07/07 07:47:25 tb Exp $ */ +/* $OpenBSD: bn_print.c,v 1.4 2023/07/10 20:21:37 tb Exp $ */ /* * Copyright (c) 2023 Theo Buehler <tb@openbsd.org> @@ -139,6 +139,11 @@ const struct print_test { .want = " mana mana\n" " 00:80:00:00:00:00:00:00:00:00\n", }, + { + .desc = "high bit of first nibble is set for negative number", + .want = " mana mana (Negative)\n" + " 00:80:00:00:00:00:00:00:00:00\n", + }, }; #define N_TESTCASES (sizeof(bn_print_tests) / sizeof(bn_print_tests[0])) @@ -281,6 +286,13 @@ main(void) test = &bn_print_tests[testcase++]; failed |= bn_print_testcase(bn, test); + /* high bit of first nibble is set for negative number. */ + BN_set_negative(bn, 1); + if (testcase >= N_TESTCASES) + errx(1, "Too many tests"); + test = &bn_print_tests[testcase++]; + failed |= bn_print_testcase(bn, test); + if (testcase != N_TESTCASES) { warnx("Not all tests run"); failed |= 1; |