From 3038773ba07048cc73b6ed35ed5ed2c27bcd835d Mon Sep 17 00:00:00 2001 From: tb <> Date: Tue, 11 Oct 2022 13:51:41 +0000 Subject: Handle corner case in which the test case can actually be a square --- src/regress/lib/libcrypto/bn/general/bn_isqrt.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) (limited to 'src') diff --git a/src/regress/lib/libcrypto/bn/general/bn_isqrt.c b/src/regress/lib/libcrypto/bn/general/bn_isqrt.c index 40b23f8dfd..b9939dc59c 100644 --- a/src/regress/lib/libcrypto/bn/general/bn_isqrt.c +++ b/src/regress/lib/libcrypto/bn/general/bn_isqrt.c @@ -1,4 +1,4 @@ -/* $OpenBSD: bn_isqrt.c,v 1.6 2022/08/12 16:13:40 tb Exp $ */ +/* $OpenBSD: bn_isqrt.c,v 1.7 2022/10/11 13:51:41 tb Exp $ */ /* * Copyright (c) 2022 Theo Buehler * @@ -148,9 +148,7 @@ validate_tables(void) fill[i]); failed |= 1; } - } - } return failed; @@ -251,7 +249,8 @@ isqrt_test(void) if (!bn_isqrt(isqrt, &is_perfect_square, testcase, ctx)) errx(1, "bn_isqrt testcase"); - if ((cmp = BN_cmp(n, isqrt)) != 0 || is_perfect_square) { + if ((cmp = BN_cmp(n, isqrt)) != 0 || + (is_perfect_square && BN_cmp(n_sqr, testcase) != 0)) { fprintf(stderr, "n = "); BN_print_fp(stderr, n); fprintf(stderr, "\ntestcase = "); -- cgit v1.2.3-55-g6feb