Commit da0854b984 for openssl.org

commit da0854b984ee3bf6827dd332843622f98406f118
Author: Pauli <paul.dale@oracle.com>
Date:   Mon Aug 31 13:09:17 2026 +1000

    ec: apply group options to explicit parameters

    Apply encoding and point-conversion options after constructing an EC group from explicit parameters, and add regression coverage for accepted and invalid option values.

    Assisted-by: ChatGPT:gpt-5.6Sol

    Reviewed-by: Shane Lontis <shane.lontis@oracle.com>
    Reviewed-by: Mounir Idrassi <mounir.idrassi@idrix.fr>
    (Merged from https://github.com/openssl/openssl/pull/32502)

diff --git a/crypto/ec/ec_lib.c b/crypto/ec/ec_lib.c
index 74d0a1da56..6df9774ed9 100644
--- a/crypto/ec/ec_lib.c
+++ b/crypto/ec/ec_lib.c
@@ -1815,6 +1815,8 @@ EC_GROUP *ossl_ec_group_new_from_params_parsed(const EC_PARAMS *params,
         EC_GROUP_free(group);
         group = named_group;
     }
+    if (!ossl_ec_group_set_params_parsed(group, params))
+        goto err;
     /* We've imported the group from explicit parameters, set it so. */
     group->decoded_from_explicit_params = 1;
     ok = 1;
diff --git a/test/ectest.c b/test/ectest.c
index 363d119c96..beafd50099 100644
--- a/test/ectest.c
+++ b/test/ectest.c
@@ -2113,6 +2113,39 @@ err:
     return r;
 }

+static int ossl_explicit_parameter_options_test(void)
+{
+    EC_GROUP *source = NULL, *imported = NULL;
+    OSSL_PARAM *params = NULL;
+    OSSL_PARAM *point_format;
+    int ret = 0;
+
+    if (!TEST_ptr(source = EC_GROUP_new_by_curve_name(NID_X9_62_prime256v1)))
+        goto err;
+    EC_GROUP_set_curve_name(source, NID_undef);
+    EC_GROUP_set_asn1_flag(source, OPENSSL_EC_EXPLICIT_CURVE);
+
+    if (!TEST_ptr(params = EC_GROUP_to_params(source, NULL, NULL, NULL))
+        || !TEST_ptr(imported = EC_GROUP_new_from_params(params, NULL, NULL))
+        || !TEST_int_eq(EC_GROUP_get_asn1_flag(imported),
+            OPENSSL_EC_EXPLICIT_CURVE)
+        || !TEST_ptr(point_format = OSSL_PARAM_locate(params,
+                         OSSL_PKEY_PARAM_EC_POINT_CONVERSION_FORMAT))
+        || !TEST_true(OSSL_PARAM_set_utf8_string(point_format, "invalid")))
+        goto err;
+
+    EC_GROUP_free(imported);
+    imported = NULL;
+    if (!TEST_ptr_null(imported = EC_GROUP_new_from_params(params, NULL, NULL)))
+        goto err;
+    ret = 1;
+err:
+    EC_GROUP_free(source);
+    EC_GROUP_free(imported);
+    OSSL_PARAM_free(params);
+    return ret;
+}
+
 #ifndef OPENSSL_NO_EC_EXPLICIT_CURVES
 /*-
  * random 256-bit explicit parameters curve, cofactor absent
@@ -3152,6 +3185,7 @@ int setup_tests(void)

     ADD_TEST(parameter_test);
     ADD_TEST(ossl_parameter_test);
+    ADD_TEST(ossl_explicit_parameter_options_test);
 #ifndef OPENSSL_NO_EC_EXPLICIT_CURVES
     ADD_TEST(cofactor_range_test);
 #endif