diff options
| author | tb <> | 2023-07-10 20:21:37 +0000 |
|---|---|---|
| committer | tb <> | 2023-07-10 20:21:37 +0000 |
| commit | 987c9d09fa4171ebd33a66e334cf7edc8b73c437 (patch) | |
| tree | d6ea87f2472fabc12991d991b0401335eb8095bb | |
| parent | bfb18033d6a99b9bcd6163a67b935402e8dc9909 (diff) | |
| download | openbsd-987c9d09fa4171ebd33a66e334cf7edc8b73c437.tar.gz openbsd-987c9d09fa4171ebd33a66e334cf7edc8b73c437.tar.bz2 openbsd-987c9d09fa4171ebd33a66e334cf7edc8b73c437.zip | |
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 '')
| -rw-r--r-- | src/regress/lib/libcrypto/bn/bn_print.c | 14 |
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; |
