From: jsing Date: Wed, 21 Jun 2023 07:16:08 +0000 (+0000) Subject: Add BN_cmp()/BN_ucmp() tests with zero padded inputs. X-Git-Url: http://artulab.com/gitweb/?a=commitdiff_plain;h=da50f9d581c7921f15157441f5abbb6c6381891f;p=openbsd Add BN_cmp()/BN_ucmp() tests with zero padded inputs. Currently BN_hex2bn() removes the leading zeros, however this will not be the case in the future. --- diff --git a/regress/lib/libcrypto/bn/bn_cmp.c b/regress/lib/libcrypto/bn/bn_cmp.c index 2f5c7c02e7f..047fac3ba9e 100644 --- a/regress/lib/libcrypto/bn/bn_cmp.c +++ b/regress/lib/libcrypto/bn/bn_cmp.c @@ -1,4 +1,4 @@ -/* $OpenBSD: bn_cmp.c,v 1.1 2022/11/30 02:51:05 jsing Exp $ */ +/* $OpenBSD: bn_cmp.c,v 1.2 2023/06/21 07:16:08 jsing Exp $ */ /* * Copyright (c) 2022 Joel Sing * @@ -75,6 +75,30 @@ struct bn_cmp_test bn_cmp_tests[] = { .cmp = -1, .ucmp = 1, }, + { + .a = "1ffffffffffffffff", + .b = "00000000000000001ffffffffffffffff", + .cmp = 0, + .ucmp = 0, + }, + { + .a = "-1ffffffffffffffff", + .b = "-00000000000000001ffffffffffffffff", + .cmp = 0, + .ucmp = 0, + }, + { + .a = "1ffffffffffffffff", + .b = "-00000000000000001ffffffffffffffff", + .cmp = 1, + .ucmp = 0, + }, + { + .a = "-1ffffffffffffffff", + .b = "00000000000000001ffffffffffffffff", + .cmp = -1, + .ucmp = 0, + }, }; #define N_BN_CMP_TESTS \