From: tb Date: Fri, 7 Jul 2023 07:47:25 +0000 (+0000) Subject: Add test coverage for leading zero octet dance X-Git-Url: http://artulab.com/gitweb/?a=commitdiff_plain;h=0b88608e5595cdbc1da8ae1365a5140a44dec8c3;p=openbsd Add test coverage for leading zero octet dance --- diff --git a/regress/lib/libcrypto/bn/bn_print.c b/regress/lib/libcrypto/bn/bn_print.c index ce3d50d2616..24f261d921d 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.2 2023/07/06 15:11:21 tb Exp $ */ +/* $OpenBSD: bn_print.c,v 1.3 2023/07/07 07:47:25 tb Exp $ */ /* * Copyright (c) 2023 Theo Buehler @@ -134,6 +134,11 @@ const struct print_test { " 47:e2:1a:e6:63:b8:3d:2e:2f:78:c4:4f:db:f4:0f:\n" " a4:68:4c:55:72:6b:95:1d:4e:18:42:95:78:cc:37\n", }, + { + .desc = "high bit of first nibble is set", + .want = " mana mana\n" + " 00:80:00:00:00:00:00:00:00:00\n", + }, }; #define N_TESTCASES (sizeof(bn_print_tests) / sizeof(bn_print_tests[0])) @@ -267,6 +272,15 @@ main(void) test = &bn_print_tests[testcase++]; failed |= bn_print_testcase(bn, test); + /* high bit of first nibble is set. */ + BN_zero(bn); + if (!BN_set_bit(bn, 71)) + errx(1, "BN_set_bit"); + 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;