From da50f9d581c7921f15157441f5abbb6c6381891f Mon Sep 17 00:00:00 2001 From: jsing Date: Wed, 21 Jun 2023 07:16:08 +0000 Subject: [PATCH] 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. --- regress/lib/libcrypto/bn/bn_cmp.c | 26 +++++++++++++++++++++++++- 1 file changed, 25 insertions(+), 1 deletion(-) 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 \ -- 2.20.1