summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authortb <>2023-07-07 07:47:25 +0000
committertb <>2023-07-07 07:47:25 +0000
commit21eddabc863b067714fdd732d1a7466ddad0cda4 (patch)
tree8ffa9bec18d2eb3bd31f1732e786b2aced1e7b64 /src
parentff3b387e5174bcab413248207feaf6caff7df2e4 (diff)
downloadopenbsd-21eddabc863b067714fdd732d1a7466ddad0cda4.tar.gz
openbsd-21eddabc863b067714fdd732d1a7466ddad0cda4.tar.bz2
openbsd-21eddabc863b067714fdd732d1a7466ddad0cda4.zip
Add test coverage for leading zero octet dance
Diffstat (limited to 'src')
-rw-r--r--src/regress/lib/libcrypto/bn/bn_print.c16
1 files changed, 15 insertions, 1 deletions
diff --git a/src/regress/lib/libcrypto/bn/bn_print.c b/src/regress/lib/libcrypto/bn/bn_print.c
index ce3d50d261..24f261d921 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.2 2023/07/06 15:11:21 tb Exp $ */ 1/* $OpenBSD: bn_print.c,v 1.3 2023/07/07 07:47:25 tb Exp $ */
2 2
3/* 3/*
4 * Copyright (c) 2023 Theo Buehler <tb@openbsd.org> 4 * Copyright (c) 2023 Theo Buehler <tb@openbsd.org>
@@ -134,6 +134,11 @@ const struct print_test {
134 " 47:e2:1a:e6:63:b8:3d:2e:2f:78:c4:4f:db:f4:0f:\n" 134 " 47:e2:1a:e6:63:b8:3d:2e:2f:78:c4:4f:db:f4:0f:\n"
135 " a4:68:4c:55:72:6b:95:1d:4e:18:42:95:78:cc:37\n", 135 " a4:68:4c:55:72:6b:95:1d:4e:18:42:95:78:cc:37\n",
136 }, 136 },
137 {
138 .desc = "high bit of first nibble is set",
139 .want = " mana mana\n"
140 " 00:80:00:00:00:00:00:00:00:00\n",
141 },
137}; 142};
138 143
139#define N_TESTCASES (sizeof(bn_print_tests) / sizeof(bn_print_tests[0])) 144#define N_TESTCASES (sizeof(bn_print_tests) / sizeof(bn_print_tests[0]))
@@ -267,6 +272,15 @@ main(void)
267 test = &bn_print_tests[testcase++]; 272 test = &bn_print_tests[testcase++];
268 failed |= bn_print_testcase(bn, test); 273 failed |= bn_print_testcase(bn, test);
269 274
275 /* high bit of first nibble is set. */
276 BN_zero(bn);
277 if (!BN_set_bit(bn, 71))
278 errx(1, "BN_set_bit");
279 if (testcase >= N_TESTCASES)
280 errx(1, "Too many tests");
281 test = &bn_print_tests[testcase++];
282 failed |= bn_print_testcase(bn, test);
283
270 if (testcase != N_TESTCASES) { 284 if (testcase != N_TESTCASES) {
271 warnx("Not all tests run"); 285 warnx("Not all tests run");
272 failed |= 1; 286 failed |= 1;