diff options
author | tb <> | 2022-10-11 13:51:41 +0000 |
---|---|---|
committer | tb <> | 2022-10-11 13:51:41 +0000 |
commit | 3038773ba07048cc73b6ed35ed5ed2c27bcd835d (patch) | |
tree | c1a1f130d9d700b9b73cbc6f38479b8824a1514e /src | |
parent | 1c67ca7737a2fda72c71ac9f0dfed99220b3a76b (diff) | |
download | openbsd-3038773ba07048cc73b6ed35ed5ed2c27bcd835d.tar.gz openbsd-3038773ba07048cc73b6ed35ed5ed2c27bcd835d.tar.bz2 openbsd-3038773ba07048cc73b6ed35ed5ed2c27bcd835d.zip |
Handle corner case in which the test case can actually be a square
Diffstat (limited to 'src')
-rw-r--r-- | src/regress/lib/libcrypto/bn/general/bn_isqrt.c | 7 |
1 files changed, 3 insertions, 4 deletions
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 @@ | |||
1 | /* $OpenBSD: bn_isqrt.c,v 1.6 2022/08/12 16:13:40 tb Exp $ */ | 1 | /* $OpenBSD: bn_isqrt.c,v 1.7 2022/10/11 13:51:41 tb Exp $ */ |
2 | /* | 2 | /* |
3 | * Copyright (c) 2022 Theo Buehler <tb@openbsd.org> | 3 | * Copyright (c) 2022 Theo Buehler <tb@openbsd.org> |
4 | * | 4 | * |
@@ -148,9 +148,7 @@ validate_tables(void) | |||
148 | fill[i]); | 148 | fill[i]); |
149 | failed |= 1; | 149 | failed |= 1; |
150 | } | 150 | } |
151 | |||
152 | } | 151 | } |
153 | |||
154 | } | 152 | } |
155 | 153 | ||
156 | return failed; | 154 | return failed; |
@@ -251,7 +249,8 @@ isqrt_test(void) | |||
251 | if (!bn_isqrt(isqrt, &is_perfect_square, testcase, ctx)) | 249 | if (!bn_isqrt(isqrt, &is_perfect_square, testcase, ctx)) |
252 | errx(1, "bn_isqrt testcase"); | 250 | errx(1, "bn_isqrt testcase"); |
253 | 251 | ||
254 | if ((cmp = BN_cmp(n, isqrt)) != 0 || is_perfect_square) { | 252 | if ((cmp = BN_cmp(n, isqrt)) != 0 || |
253 | (is_perfect_square && BN_cmp(n_sqr, testcase) != 0)) { | ||
255 | fprintf(stderr, "n = "); | 254 | fprintf(stderr, "n = "); |
256 | BN_print_fp(stderr, n); | 255 | BN_print_fp(stderr, n); |
257 | fprintf(stderr, "\ntestcase = "); | 256 | fprintf(stderr, "\ntestcase = "); |