summaryrefslogtreecommitdiff
path: root/src/regress/lib/libcrypto/ec/ectest.c
diff options
context:
space:
mode:
authortb <>2024-10-18 19:55:34 +0000
committertb <>2024-10-18 19:55:34 +0000
commit78eb5b882cac45cd24460fa3569aa965475abe1c (patch)
treed50d156a8551758eea5562268a6205b9a842663e /src/regress/lib/libcrypto/ec/ectest.c
parent2b5b0449a68f53d499f44a405400ebd9de632ff5 (diff)
downloadopenbsd-78eb5b882cac45cd24460fa3569aa965475abe1c.tar.gz
openbsd-78eb5b882cac45cd24460fa3569aa965475abe1c.tar.bz2
openbsd-78eb5b882cac45cd24460fa3569aa965475abe1c.zip
ec_asn1_test: call EC_GROUP_check() for the builtin curves
This makes the internal curve test in ectest.c superfluous. Also fix a logic error.
Diffstat (limited to 'src/regress/lib/libcrypto/ec/ectest.c')
-rw-r--r--src/regress/lib/libcrypto/ec/ectest.c58
1 files changed, 1 insertions, 57 deletions
diff --git a/src/regress/lib/libcrypto/ec/ectest.c b/src/regress/lib/libcrypto/ec/ectest.c
index e60fde60e6..b653ab7876 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.23 2024/02/29 20:04:43 tb Exp $ */ 1/* $OpenBSD: ectest.c,v 1.24 2024/10/18 19:55:34 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 */
@@ -703,68 +703,12 @@ prime_field_tests(void)
703 703
704} 704}
705 705
706static void
707internal_curve_test(void)
708{
709 EC_builtin_curve *curves = NULL;
710 size_t crv_len = 0, n = 0;
711 int ok = 1;
712
713 crv_len = EC_get_builtin_curves(NULL, 0);
714
715 curves = reallocarray(NULL, sizeof(EC_builtin_curve), crv_len);
716
717 if (curves == NULL)
718 return;
719
720 if (!EC_get_builtin_curves(curves, crv_len)) {
721 free(curves);
722 return;
723 }
724
725 fprintf(stdout, "testing internal curves: ");
726
727 for (n = 0; n < crv_len; n++) {
728 EC_GROUP *group = NULL;
729 int nid = curves[n].nid;
730 if ((group = EC_GROUP_new_by_curve_name(nid)) == NULL) {
731 ok = 0;
732 fprintf(stdout, "\nEC_GROUP_new_curve_name() failed with"
733 " curve %s\n", OBJ_nid2sn(nid));
734 /* try next curve */
735 continue;
736 }
737 if (!EC_GROUP_check(group, NULL)) {
738 ok = 0;
739 fprintf(stdout, "\nEC_GROUP_check() failed with"
740 " curve %s\n", OBJ_nid2sn(nid));
741 EC_GROUP_free(group);
742 /* try the next curve */
743 continue;
744 }
745 fprintf(stdout, ".");
746 fflush(stdout);
747 EC_GROUP_free(group);
748 }
749 if (ok)
750 fprintf(stdout, " ok\n\n");
751 else {
752 fprintf(stdout, " failed\n\n");
753 ABORT;
754 }
755 free(curves);
756 return;
757}
758
759int 706int
760main(int argc, char *argv[]) 707main(int argc, char *argv[])
761{ 708{
762 ERR_load_crypto_strings(); 709 ERR_load_crypto_strings();
763 710
764 prime_field_tests(); 711 prime_field_tests();
765 puts("");
766 /* test the internal curves */
767 internal_curve_test();
768 712
769 CRYPTO_cleanup_all_ex_data(); 713 CRYPTO_cleanup_all_ex_data();
770 ERR_free_strings(); 714 ERR_free_strings();