diff options
author | tb <> | 2022-07-27 19:22:45 +0000 |
---|---|---|
committer | tb <> | 2022-07-27 19:22:45 +0000 |
commit | ea13f55f1cdf021f243b6c14244e24e60cd12355 (patch) | |
tree | e5968007b3113bcbca9a25a639953b887f4e37b0 /src | |
parent | 452e0d9e8ea01c3483f30eff266286eb6a5a3c31 (diff) | |
download | openbsd-ea13f55f1cdf021f243b6c14244e24e60cd12355.tar.gz openbsd-ea13f55f1cdf021f243b6c14244e24e60cd12355.tar.bz2 openbsd-ea13f55f1cdf021f243b6c14244e24e60cd12355.zip |
Adjust a comment to reflect reality, minor code tweaks.
Diffstat (limited to 'src')
-rw-r--r-- | src/regress/lib/libcrypto/bn/general/bn_isqrt.c | 14 |
1 files changed, 7 insertions, 7 deletions
diff --git a/src/regress/lib/libcrypto/bn/general/bn_isqrt.c b/src/regress/lib/libcrypto/bn/general/bn_isqrt.c index bf3947186a..8c932be265 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.2 2022/07/26 07:09:24 tb Exp $ */ | 1 | /* $OpenBSD: bn_isqrt.c,v 1.3 2022/07/27 19:22:45 tb Exp $ */ |
2 | /* | 2 | /* |
3 | * Copyright (c) 2022 Theo Buehler <tb@openbsd.org> | 3 | * Copyright (c) 2022 Theo Buehler <tb@openbsd.org> |
4 | * | 4 | * |
@@ -117,16 +117,16 @@ check_tables(int print) | |||
117 | } | 117 | } |
118 | 118 | ||
119 | /* | 119 | /* |
120 | * Choose a random number n between 2^10 and 2^16384 and check n == isqrt(n^2). | 120 | * Choose a random number n of bit length between LOWER_BITS and UPPER_BITS and |
121 | * Random numbers n^2 <= test < (n + 1)^2 are checked to have isqrt(test) == n. | 121 | * check that n == isqrt(n^2). Random numbers n^2 <= test < (n + 1)^2 are |
122 | * checked to have isqrt(test) == n. | ||
122 | */ | 123 | */ |
123 | static int | 124 | static int |
124 | isqrt_test(void) | 125 | isqrt_test(void) |
125 | { | 126 | { |
126 | BN_CTX *ctx; | 127 | BN_CTX *ctx; |
127 | BIGNUM *n, *n_sqr, *lower, *upper, *testcase, *isqrt; | 128 | BIGNUM *n, *n_sqr, *lower, *upper, *testcase, *isqrt; |
128 | int cmp, is_perfect_square; | 129 | int cmp, i, is_perfect_square; |
129 | int i; | ||
130 | int failed = 0; | 130 | int failed = 0; |
131 | 131 | ||
132 | if ((ctx = BN_CTX_new()) == NULL) | 132 | if ((ctx = BN_CTX_new()) == NULL) |
@@ -166,7 +166,7 @@ isqrt_test(void) | |||
166 | if ((cmp = BN_cmp(n, isqrt)) != 0 || !is_perfect_square) { | 166 | if ((cmp = BN_cmp(n, isqrt)) != 0 || !is_perfect_square) { |
167 | fprintf(stderr, "n = "); | 167 | fprintf(stderr, "n = "); |
168 | BN_print_fp(stderr, n); | 168 | BN_print_fp(stderr, n); |
169 | fprintf(stderr, "n^2 is_perfect_square: %d, cmp: %d\n", | 169 | fprintf(stderr, "\nn^2 is_perfect_square: %d, cmp: %d\n", |
170 | is_perfect_square, cmp); | 170 | is_perfect_square, cmp); |
171 | failed = 1; | 171 | failed = 1; |
172 | } | 172 | } |
@@ -204,7 +204,7 @@ isqrt_test(void) | |||
204 | * that their isqrt is n. | 204 | * that their isqrt is n. |
205 | */ | 205 | */ |
206 | 206 | ||
207 | for (i = 1; i < N_TESTS; i++) { | 207 | for (i = 0; i < N_TESTS; i++) { |
208 | if (!bn_rand_interval(testcase, n_sqr, upper)) | 208 | if (!bn_rand_interval(testcase, n_sqr, upper)) |
209 | errx(1, "bn_rand_interval testcase"); | 209 | errx(1, "bn_rand_interval testcase"); |
210 | 210 | ||