diff options
| author | tb <> | 2025-01-22 15:20:06 +0000 |
|---|---|---|
| committer | tb <> | 2025-01-22 15:20:06 +0000 |
| commit | c4e7df619cb0e7803a37df5ac9f37666491a02f5 (patch) | |
| tree | a64d54d87b5a510ec8265f8affba2fb6508fee09 /src | |
| parent | d5e3f3f790a153cecb9dc6dac1cd2b88b2886929 (diff) | |
| download | openbsd-c4e7df619cb0e7803a37df5ac9f37666491a02f5.tar.gz openbsd-c4e7df619cb0e7803a37df5ac9f37666491a02f5.tar.bz2 openbsd-c4e7df619cb0e7803a37df5ac9f37666491a02f5.zip | |
ectest: even more lipstick
Diffstat (limited to 'src')
| -rw-r--r-- | src/regress/lib/libcrypto/ec/ectest.c | 32 |
1 files changed, 15 insertions, 17 deletions
diff --git a/src/regress/lib/libcrypto/ec/ectest.c b/src/regress/lib/libcrypto/ec/ectest.c index 212d5eef1a..427d1504b4 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.30 2025/01/22 15:15:21 tb Exp $ */ | 1 | /* $OpenBSD: ectest.c,v 1.31 2025/01/22 15:20:06 tb 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 | */ |
| @@ -94,21 +94,22 @@ | |||
| 94 | 94 | ||
| 95 | /* test multiplication with group order, long and negative scalars */ | 95 | /* test multiplication with group order, long and negative scalars */ |
| 96 | static void | 96 | static void |
| 97 | group_order_tests(EC_GROUP *group) | 97 | group_order_tests(EC_GROUP *group, BN_CTX *ctx) |
| 98 | { | 98 | { |
| 99 | BIGNUM *n1, *n2, *order; | 99 | BIGNUM *n1, *n2, *order; |
| 100 | EC_POINT *P = EC_POINT_new(group); | 100 | EC_POINT *P = EC_POINT_new(group); |
| 101 | EC_POINT *Q = EC_POINT_new(group); | 101 | EC_POINT *Q = EC_POINT_new(group); |
| 102 | BN_CTX *ctx; | ||
| 103 | 102 | ||
| 104 | if ((ctx = BN_CTX_new()) == NULL) | 103 | if (P == NULL || Q == NULL) |
| 105 | ABORT; | 104 | ABORT; |
| 106 | 105 | ||
| 107 | if ((n1 = BN_new()) == NULL) | 106 | BN_CTX_start(ctx); |
| 107 | |||
| 108 | if ((n1 = BN_CTX_get(ctx)) == NULL) | ||
| 108 | ABORT; | 109 | ABORT; |
| 109 | if ((n2 = BN_new()) == NULL) | 110 | if ((n2 = BN_CTX_get(ctx)) == NULL) |
| 110 | ABORT; | 111 | ABORT; |
| 111 | if ((order = BN_new()) == NULL) | 112 | if ((order = BN_CTX_get(ctx)) == NULL) |
| 112 | ABORT; | 113 | ABORT; |
| 113 | fprintf(stdout, "verify group order ..."); | 114 | fprintf(stdout, "verify group order ..."); |
| 114 | fflush(stdout); | 115 | fflush(stdout); |
| @@ -154,10 +155,7 @@ group_order_tests(EC_GROUP *group) | |||
| 154 | fprintf(stdout, "ok\n"); | 155 | fprintf(stdout, "ok\n"); |
| 155 | EC_POINT_free(P); | 156 | EC_POINT_free(P); |
| 156 | EC_POINT_free(Q); | 157 | EC_POINT_free(Q); |
| 157 | BN_free(n1); | 158 | BN_CTX_end(ctx); |
| 158 | BN_free(n2); | ||
| 159 | BN_free(order); | ||
| 160 | BN_CTX_free(ctx); | ||
| 161 | } | 159 | } |
| 162 | 160 | ||
| 163 | static void | 161 | static void |
| @@ -378,7 +376,7 @@ prime_field_tests(void) | |||
| 378 | ABORT; | 376 | ABORT; |
| 379 | fprintf(stdout, " ok\n"); | 377 | fprintf(stdout, " ok\n"); |
| 380 | 378 | ||
| 381 | group_order_tests(group); | 379 | group_order_tests(group, ctx); |
| 382 | 380 | ||
| 383 | if ((P_160 = EC_GROUP_dup(group)) == NULL) | 381 | if ((P_160 = EC_GROUP_dup(group)) == NULL) |
| 384 | ABORT; | 382 | ABORT; |
| @@ -425,7 +423,7 @@ prime_field_tests(void) | |||
| 425 | ABORT; | 423 | ABORT; |
| 426 | fprintf(stdout, " ok\n"); | 424 | fprintf(stdout, " ok\n"); |
| 427 | 425 | ||
| 428 | group_order_tests(group); | 426 | group_order_tests(group, ctx); |
| 429 | 427 | ||
| 430 | if ((P_192 = EC_GROUP_dup(group)) == NULL) | 428 | if ((P_192 = EC_GROUP_dup(group)) == NULL) |
| 431 | ABORT; | 429 | ABORT; |
| @@ -472,7 +470,7 @@ prime_field_tests(void) | |||
| 472 | ABORT; | 470 | ABORT; |
| 473 | fprintf(stdout, " ok\n"); | 471 | fprintf(stdout, " ok\n"); |
| 474 | 472 | ||
| 475 | group_order_tests(group); | 473 | group_order_tests(group, ctx); |
| 476 | 474 | ||
| 477 | if ((P_224 = EC_GROUP_dup(group)) == NULL) | 475 | if ((P_224 = EC_GROUP_dup(group)) == NULL) |
| 478 | ABORT; | 476 | ABORT; |
| @@ -519,7 +517,7 @@ prime_field_tests(void) | |||
| 519 | ABORT; | 517 | ABORT; |
| 520 | fprintf(stdout, " ok\n"); | 518 | fprintf(stdout, " ok\n"); |
| 521 | 519 | ||
| 522 | group_order_tests(group); | 520 | group_order_tests(group, ctx); |
| 523 | 521 | ||
| 524 | if ((P_256 = EC_GROUP_dup(group)) == NULL) | 522 | if ((P_256 = EC_GROUP_dup(group)) == NULL) |
| 525 | ABORT; | 523 | ABORT; |
| @@ -566,7 +564,7 @@ prime_field_tests(void) | |||
| 566 | ABORT; | 564 | ABORT; |
| 567 | fprintf(stdout, " ok\n"); | 565 | fprintf(stdout, " ok\n"); |
| 568 | 566 | ||
| 569 | group_order_tests(group); | 567 | group_order_tests(group, ctx); |
| 570 | 568 | ||
| 571 | if ((P_384 = EC_GROUP_dup(group)) == NULL) | 569 | if ((P_384 = EC_GROUP_dup(group)) == NULL) |
| 572 | ABORT; | 570 | ABORT; |
| @@ -619,7 +617,7 @@ prime_field_tests(void) | |||
| 619 | ABORT; | 617 | ABORT; |
| 620 | fprintf(stdout, " ok\n"); | 618 | fprintf(stdout, " ok\n"); |
| 621 | 619 | ||
| 622 | group_order_tests(group); | 620 | group_order_tests(group, ctx); |
| 623 | 621 | ||
| 624 | if ((P_521 = EC_GROUP_dup(group)) == NULL) | 622 | if ((P_521 = EC_GROUP_dup(group)) == NULL) |
| 625 | ABORT; | 623 | ABORT; |
