diff options
| author | jsing <> | 2025-01-22 09:25:02 +0000 |
|---|---|---|
| committer | jsing <> | 2025-01-22 09:25:02 +0000 |
| commit | 4a41240194c5582891973b8c44c917dffa2b4e00 (patch) | |
| tree | f0d1742fbe4e97e54451abeb94014da641e70ce6 | |
| parent | 22273305d61b1a72de8438c1cd10ba64f9731a24 (diff) | |
| download | openbsd-4a41240194c5582891973b8c44c917dffa2b4e00.tar.gz openbsd-4a41240194c5582891973b8c44c917dffa2b4e00.tar.bz2 openbsd-4a41240194c5582891973b8c44c917dffa2b4e00.zip | |
Ensure the cyclic subgroup cycles in the expected number of iterations.
Also print the iteration number and fix some indentation.
| -rw-r--r-- | src/regress/lib/libcrypto/ec/ectest.c | 23 |
1 files changed, 14 insertions, 9 deletions
diff --git a/src/regress/lib/libcrypto/ec/ectest.c b/src/regress/lib/libcrypto/ec/ectest.c index 7492c21e72..456439addb 100644 --- a/src/regress/lib/libcrypto/ec/ectest.c +++ b/src/regress/lib/libcrypto/ec/ectest.c | |||
| @@ -1,4 +1,4 @@ | |||
| 1 | /* $OpenBSD: ectest.c,v 1.27 2025/01/22 06:46:08 tb Exp $ */ | 1 | /* $OpenBSD: ectest.c,v 1.28 2025/01/22 09:25:02 jsing Exp $ */ |
| 2 | /* | 2 | /* |
| 3 | * Originally written by Bodo Moeller for the OpenSSL project. | 3 | * Originally written by Bodo Moeller for the OpenSSL project. |
| 4 | */ | 4 | */ |
| @@ -262,18 +262,16 @@ prime_field_tests(void) | |||
| 262 | } | 262 | } |
| 263 | 263 | ||
| 264 | fprintf(stdout, "A cyclic subgroup:\n"); | 264 | fprintf(stdout, "A cyclic subgroup:\n"); |
| 265 | k = 100; | 265 | k = 0; |
| 266 | do { | 266 | do { |
| 267 | if (k-- == 0) | 267 | fprintf(stderr, " %d - ", k); |
| 268 | ABORT; | ||
| 269 | |||
| 270 | if (EC_POINT_is_at_infinity(group, P)) | 268 | if (EC_POINT_is_at_infinity(group, P)) |
| 271 | fprintf(stdout, " point at infinity\n"); | 269 | fprintf(stdout, "point at infinity\n"); |
| 272 | else { | 270 | else { |
| 273 | if (!EC_POINT_get_affine_coordinates(group, P, x, y, ctx)) | 271 | if (!EC_POINT_get_affine_coordinates(group, P, x, y, ctx)) |
| 274 | ABORT; | 272 | ABORT; |
| 275 | 273 | ||
| 276 | fprintf(stdout, " x = 0x"); | 274 | fprintf(stdout, "x = 0x"); |
| 277 | BN_print_fp(stdout, x); | 275 | BN_print_fp(stdout, x); |
| 278 | fprintf(stdout, ", y = 0x"); | 276 | fprintf(stdout, ", y = 0x"); |
| 279 | BN_print_fp(stdout, y); | 277 | BN_print_fp(stdout, y); |
| @@ -284,8 +282,15 @@ prime_field_tests(void) | |||
| 284 | ABORT; | 282 | ABORT; |
| 285 | if (!EC_POINT_add(group, P, P, Q, ctx)) | 283 | if (!EC_POINT_add(group, P, P, Q, ctx)) |
| 286 | ABORT; | 284 | ABORT; |
| 285 | if (k++ > 99) | ||
| 286 | ABORT; | ||
| 287 | } while (!EC_POINT_is_at_infinity(group, P)); | 287 | } while (!EC_POINT_is_at_infinity(group, P)); |
| 288 | 288 | ||
| 289 | if (k != 7) { | ||
| 290 | fprintf(stderr, "cycled in %d iterations, want 7\n", k); | ||
| 291 | ABORT; | ||
| 292 | } | ||
| 293 | |||
| 289 | if (!EC_POINT_add(group, P, Q, R, ctx)) | 294 | if (!EC_POINT_add(group, P, Q, R, ctx)) |
| 290 | ABORT; | 295 | ABORT; |
| 291 | if (!EC_POINT_is_at_infinity(group, P)) | 296 | if (!EC_POINT_is_at_infinity(group, P)) |
| @@ -321,8 +326,8 @@ prime_field_tests(void) | |||
| 321 | fprintf(stdout, "\nGenerator as octet string, hybrid form:\n "); | 326 | fprintf(stdout, "\nGenerator as octet string, hybrid form:\n "); |
| 322 | for (i = 0; i < len; i++) fprintf(stdout, "%02X", buf[i]); | 327 | for (i = 0; i < len; i++) fprintf(stdout, "%02X", buf[i]); |
| 323 | 328 | ||
| 324 | if (!EC_POINT_get_affine_coordinates(group, R, x, y, ctx)) | 329 | if (!EC_POINT_get_affine_coordinates(group, R, x, y, ctx)) |
| 325 | ABORT; | 330 | ABORT; |
| 326 | fprintf(stdout, "\nThe inverse of that generator:\n X = 0x"); | 331 | fprintf(stdout, "\nThe inverse of that generator:\n X = 0x"); |
| 327 | BN_print_fp(stdout, x); | 332 | BN_print_fp(stdout, x); |
| 328 | fprintf(stdout, ", Y = 0x"); | 333 | fprintf(stdout, ", Y = 0x"); |
