summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/regress/lib/libcrypto/ec/ectest.c57
1 files changed, 15 insertions, 42 deletions
diff --git a/src/regress/lib/libcrypto/ec/ectest.c b/src/regress/lib/libcrypto/ec/ectest.c
index 456439addb..318a8f02ca 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.28 2025/01/22 09:25:02 jsing Exp $ */ 1/* $OpenBSD: ectest.c,v 1.29 2025/01/22 15:10:30 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 */
@@ -200,10 +200,8 @@ prime_field_tests(void)
200 200
201 { 201 {
202 EC_GROUP *tmp; 202 EC_GROUP *tmp;
203 tmp = EC_GROUP_new(EC_GROUP_method_of(group)); 203
204 if (!tmp) 204 if ((tmp = EC_GROUP_dup(group)) == NULL)
205 ABORT;
206 if (!EC_GROUP_copy(tmp, group))
207 ABORT; 205 ABORT;
208 EC_GROUP_free(group); 206 EC_GROUP_free(group);
209 group = tmp; 207 group = tmp;
@@ -387,11 +385,8 @@ prime_field_tests(void)
387 385
388 group_order_tests(group); 386 group_order_tests(group);
389 387
390 if (!(P_160 = EC_GROUP_new(EC_GROUP_method_of(group)))) 388 if ((P_160 = EC_GROUP_dup(group)) == NULL)
391 ABORT; 389 ABORT;
392 if (!EC_GROUP_copy(P_160, group))
393 ABORT;
394
395 390
396 /* Curve P-192 (FIPS PUB 186-2, App. 6) */ 391 /* Curve P-192 (FIPS PUB 186-2, App. 6) */
397 392
@@ -437,11 +432,8 @@ prime_field_tests(void)
437 432
438 group_order_tests(group); 433 group_order_tests(group);
439 434
440 if (!(P_192 = EC_GROUP_new(EC_GROUP_method_of(group)))) 435 if ((P_192 = EC_GROUP_dup(group)) == NULL)
441 ABORT; 436 ABORT;
442 if (!EC_GROUP_copy(P_192, group))
443 ABORT;
444
445 437
446 /* Curve P-224 (FIPS PUB 186-2, App. 6) */ 438 /* Curve P-224 (FIPS PUB 186-2, App. 6) */
447 439
@@ -487,11 +479,8 @@ prime_field_tests(void)
487 479
488 group_order_tests(group); 480 group_order_tests(group);
489 481
490 if (!(P_224 = EC_GROUP_new(EC_GROUP_method_of(group)))) 482 if ((P_224 = EC_GROUP_dup(group)) == NULL)
491 ABORT; 483 ABORT;
492 if (!EC_GROUP_copy(P_224, group))
493 ABORT;
494
495 484
496 /* Curve P-256 (FIPS PUB 186-2, App. 6) */ 485 /* Curve P-256 (FIPS PUB 186-2, App. 6) */
497 486
@@ -537,11 +526,8 @@ prime_field_tests(void)
537 526
538 group_order_tests(group); 527 group_order_tests(group);
539 528
540 if (!(P_256 = EC_GROUP_new(EC_GROUP_method_of(group)))) 529 if ((P_256 = EC_GROUP_new(EC_GROUP_method_of(group))) == NULL)
541 ABORT; 530 ABORT;
542 if (!EC_GROUP_copy(P_256, group))
543 ABORT;
544
545 531
546 /* Curve P-384 (FIPS PUB 186-2, App. 6) */ 532 /* Curve P-384 (FIPS PUB 186-2, App. 6) */
547 533
@@ -587,11 +573,8 @@ prime_field_tests(void)
587 573
588 group_order_tests(group); 574 group_order_tests(group);
589 575
590 if (!(P_384 = EC_GROUP_new(EC_GROUP_method_of(group)))) 576 if ((P_384 = EC_GROUP_dup(group)) == NULL)
591 ABORT; 577 ABORT;
592 if (!EC_GROUP_copy(P_384, group))
593 ABORT;
594
595 578
596 /* Curve P-521 (FIPS PUB 186-2, App. 6) */ 579 /* Curve P-521 (FIPS PUB 186-2, App. 6) */
597 580
@@ -643,11 +626,8 @@ prime_field_tests(void)
643 626
644 group_order_tests(group); 627 group_order_tests(group);
645 628
646 if (!(P_521 = EC_GROUP_new(EC_GROUP_method_of(group)))) 629 if ((P_521 = EC_GROUP_dup(group)) == NULL)
647 ABORT; 630 ABORT;
648 if (!EC_GROUP_copy(P_521, group))
649 ABORT;
650
651 631
652 /* more tests using the last curve */ 632 /* more tests using the last curve */
653 fprintf(stdout, "infinity tests ..."); 633 fprintf(stdout, "infinity tests ...");
@@ -687,19 +667,12 @@ prime_field_tests(void)
687 BN_free(y); 667 BN_free(y);
688 BN_free(z); 668 BN_free(z);
689 669
690 if (P_160) 670 EC_GROUP_free(P_160);
691 EC_GROUP_free(P_160); 671 EC_GROUP_free(P_192);
692 if (P_192) 672 EC_GROUP_free(P_224);
693 EC_GROUP_free(P_192); 673 EC_GROUP_free(P_256);
694 if (P_224) 674 EC_GROUP_free(P_384);
695 EC_GROUP_free(P_224); 675 EC_GROUP_free(P_521);
696 if (P_256)
697 EC_GROUP_free(P_256);
698 if (P_384)
699 EC_GROUP_free(P_384);
700 if (P_521)
701 EC_GROUP_free(P_521);
702
703} 676}
704 677
705int 678int