|
|
727bdf |
diff --git a/crypto/ec/ec_backend.c b/crypto/ec/ec_backend.c
|
|
|
727bdf |
index bea01fb38f66..48721369ae8f 100644
|
|
|
727bdf |
--- a/crypto/ec/ec_backend.c
|
|
|
727bdf |
+++ b/crypto/ec/ec_backend.c
|
|
|
727bdf |
@@ -318,6 +318,11 @@ int ossl_ec_group_todata(const EC_GROUP *group, OSSL_PARAM_BLD *tmpl,
|
|
|
727bdf |
return 0;
|
|
|
727bdf |
}
|
|
|
727bdf |
|
|
|
727bdf |
+ if (!ossl_param_build_set_int(tmpl, params,
|
|
|
727bdf |
+ OSSL_PKEY_PARAM_EC_DECODED_FROM_EXPLICIT_PARAMS,
|
|
|
727bdf |
+ group->decoded_from_explicit_params))
|
|
|
727bdf |
+ return 0;
|
|
|
727bdf |
+
|
|
|
727bdf |
curve_nid = EC_GROUP_get_curve_name(group);
|
|
|
727bdf |
|
|
|
727bdf |
/*
|
|
|
727bdf |
diff --git a/crypto/ec/ec_lib.c b/crypto/ec/ec_lib.c
|
|
|
727bdf |
index 6b0591c6c8c7..b1696d93bd6d 100644
|
|
|
727bdf |
--- a/crypto/ec/ec_lib.c
|
|
|
727bdf |
+++ b/crypto/ec/ec_lib.c
|
|
|
727bdf |
@@ -1556,13 +1556,23 @@ EC_GROUP *EC_GROUP_new_from_params(const OSSL_PARAM params[],
|
|
|
727bdf |
/* This is the simple named group case */
|
|
|
727bdf |
ptmp = OSSL_PARAM_locate_const(params, OSSL_PKEY_PARAM_GROUP_NAME);
|
|
|
727bdf |
if (ptmp != NULL) {
|
|
|
727bdf |
- group = group_new_from_name(ptmp, libctx, propq);
|
|
|
727bdf |
- if (group != NULL) {
|
|
|
727bdf |
- if (!ossl_ec_group_set_params(group, params)) {
|
|
|
727bdf |
- EC_GROUP_free(group);
|
|
|
727bdf |
- group = NULL;
|
|
|
727bdf |
- }
|
|
|
727bdf |
+ int decoded = 0;
|
|
|
727bdf |
+
|
|
|
727bdf |
+ if ((group = group_new_from_name(ptmp, libctx, propq)) == NULL)
|
|
|
727bdf |
+ return NULL;
|
|
|
727bdf |
+ if (!ossl_ec_group_set_params(group, params)) {
|
|
|
727bdf |
+ EC_GROUP_free(group);
|
|
|
727bdf |
+ return NULL;
|
|
|
727bdf |
+ }
|
|
|
727bdf |
+
|
|
|
727bdf |
+ ptmp = OSSL_PARAM_locate_const(params,
|
|
|
727bdf |
+ OSSL_PKEY_PARAM_EC_DECODED_FROM_EXPLICIT_PARAMS);
|
|
|
727bdf |
+ if (ptmp != NULL && !OSSL_PARAM_get_int(ptmp, &decoded)) {
|
|
|
727bdf |
+ ERR_raise(ERR_LIB_EC, EC_R_WRONG_CURVE_PARAMETERS);
|
|
|
727bdf |
+ EC_GROUP_free(group);
|
|
|
727bdf |
+ return NULL;
|
|
|
727bdf |
}
|
|
|
727bdf |
+ group->decoded_from_explicit_params = decoded > 0;
|
|
|
727bdf |
return group;
|
|
|
727bdf |
}
|
|
|
727bdf |
#ifdef FIPS_MODULE
|
|
|
727bdf |
@@ -1733,6 +1743,8 @@ EC_GROUP *EC_GROUP_new_from_params(const OSSL_PARAM params[],
|
|
|
727bdf |
EC_GROUP_free(group);
|
|
|
727bdf |
group = named_group;
|
|
|
727bdf |
}
|
|
|
727bdf |
+ /* We've imported the group from explicit parameters, set it so. */
|
|
|
727bdf |
+ group->decoded_from_explicit_params = 1;
|
|
|
727bdf |
ok = 1;
|
|
|
727bdf |
err:
|
|
|
727bdf |
if (!ok) {
|
|
|
727bdf |
diff --git a/doc/man7/EVP_PKEY-EC.pod b/doc/man7/EVP_PKEY-EC.pod
|
|
|
727bdf |
index eed83237c3b2..ee66a074f889 100644
|
|
|
727bdf |
--- a/doc/man7/EVP_PKEY-EC.pod
|
|
|
727bdf |
+++ b/doc/man7/EVP_PKEY-EC.pod
|
|
|
727bdf |
@@ -70,8 +70,8 @@ I<order> multiplied by the I<cofactor> gives the number of points on the curve.
|
|
|
727bdf |
|
|
|
727bdf |
=item "decoded-from-explicit" (B<OSSL_PKEY_PARAM_EC_DECODED_FROM_EXPLICIT_PARAMS>) <integer>
|
|
|
727bdf |
|
|
|
727bdf |
-Gets a flag indicating wether the key or parameters were decoded from explicit
|
|
|
727bdf |
-curve parameters. Set to 1 if so or 0 if a named curve was used.
|
|
|
727bdf |
+Sets or gets a flag indicating whether the key or parameters were decoded from
|
|
|
727bdf |
+explicit curve parameters. Set to 1 if so or 0 if a named curve was used.
|
|
|
727bdf |
|
|
|
727bdf |
=item "use-cofactor-flag" (B<OSSL_PKEY_PARAM_USE_COFACTOR_ECDH>) <integer>
|
|
|
727bdf |
|
|
|
727bdf |
diff --git a/providers/implementations/keymgmt/ec_kmgmt.c b/providers/implementations/keymgmt/ec_kmgmt.c
|
|
|
727bdf |
index 9260d4bf3635..7aed057cac89 100644
|
|
|
727bdf |
--- a/providers/implementations/keymgmt/ec_kmgmt.c
|
|
|
727bdf |
+++ b/providers/implementations/keymgmt/ec_kmgmt.c
|
|
|
727bdf |
@@ -525,7 +525,8 @@ int ec_export(void *keydata, int selection, OSSL_CALLBACK *param_cb,
|
|
|
727bdf |
OSSL_PARAM_octet_string(OSSL_PKEY_PARAM_EC_GENERATOR, NULL, 0), \
|
|
|
727bdf |
OSSL_PARAM_BN(OSSL_PKEY_PARAM_EC_ORDER, NULL, 0), \
|
|
|
727bdf |
OSSL_PARAM_BN(OSSL_PKEY_PARAM_EC_COFACTOR, NULL, 0), \
|
|
|
727bdf |
- OSSL_PARAM_octet_string(OSSL_PKEY_PARAM_EC_SEED, NULL, 0)
|
|
|
727bdf |
+ OSSL_PARAM_octet_string(OSSL_PKEY_PARAM_EC_SEED, NULL, 0), \
|
|
|
727bdf |
+ OSSL_PARAM_int(OSSL_PKEY_PARAM_EC_DECODED_FROM_EXPLICIT_PARAMS, NULL)
|
|
|
727bdf |
|
|
|
727bdf |
# define EC_IMEXPORTABLE_PUBLIC_KEY \
|
|
|
727bdf |
OSSL_PARAM_octet_string(OSSL_PKEY_PARAM_PUB_KEY, NULL, 0)
|
|
|
727bdf |
diff --git a/test/recipes/25-test_verify.t b/test/recipes/25-test_verify.t
|
|
|
727bdf |
index 700bbd849c95..ede14864d5ac 100644
|
|
|
727bdf |
--- a/test/recipes/25-test_verify.t
|
|
|
727bdf |
+++ b/test/recipes/25-test_verify.t
|
|
|
727bdf |
@@ -12,7 +12,7 @@ use warnings;
|
|
|
727bdf |
|
|
|
727bdf |
use File::Spec::Functions qw/canonpath/;
|
|
|
727bdf |
use File::Copy;
|
|
|
727bdf |
-use OpenSSL::Test qw/:DEFAULT srctop_file ok_nofips with/;
|
|
|
727bdf |
+use OpenSSL::Test qw/:DEFAULT srctop_file bldtop_dir ok_nofips with/;
|
|
|
727bdf |
use OpenSSL::Test::Utils;
|
|
|
727bdf |
|
|
|
727bdf |
setup("test_verify");
|
|
|
727bdf |
@@ -29,7 +29,7 @@ sub verify {
|
|
|
727bdf |
run(app([@args]));
|
|
|
727bdf |
}
|
|
|
727bdf |
|
|
|
727bdf |
-plan tests => 160;
|
|
|
727bdf |
+plan tests => 163;
|
|
|
727bdf |
|
|
|
727bdf |
# Canonical success
|
|
|
727bdf |
ok(verify("ee-cert", "sslserver", ["root-cert"], ["ca-cert"]),
|
|
|
727bdf |
@@ -309,6 +309,29 @@ SKIP: {
|
|
|
727bdf |
["ca-cert-ec-named"]),
|
|
|
727bdf |
"accept named curve leaf with named curve intermediate");
|
|
|
727bdf |
}
|
|
|
727bdf |
+# Same as above but with base provider used for decoding
|
|
|
727bdf |
+SKIP: {
|
|
|
727bdf |
+ my $no_fips = disabled('fips') || ($ENV{NO_FIPS} // 0);
|
|
|
727bdf |
+ skip "EC is not supported or FIPS is disabled", 3
|
|
|
727bdf |
+ if disabled("ec") || $no_fips;
|
|
|
727bdf |
+
|
|
|
727bdf |
+ my $provconf = srctop_file("test", "fips-and-base.cnf");
|
|
|
727bdf |
+ my $provpath = bldtop_dir("providers");
|
|
|
727bdf |
+ my @prov = ("-provider-path", $provpath);
|
|
|
727bdf |
+ $ENV{OPENSSL_CONF} = $provconf;
|
|
|
727bdf |
+
|
|
|
727bdf |
+ ok(!verify("ee-cert-ec-explicit", "", ["root-cert"],
|
|
|
727bdf |
+ ["ca-cert-ec-named"], @prov),
|
|
|
727bdf |
+ "reject explicit curve leaf with named curve intermediate w/fips");
|
|
|
727bdf |
+ ok(!verify("ee-cert-ec-named-explicit", "", ["root-cert"],
|
|
|
727bdf |
+ ["ca-cert-ec-explicit"], @prov),
|
|
|
727bdf |
+ "reject named curve leaf with explicit curve intermediate w/fips");
|
|
|
727bdf |
+ ok(verify("ee-cert-ec-named-named", "", ["root-cert"],
|
|
|
727bdf |
+ ["ca-cert-ec-named"], @prov),
|
|
|
727bdf |
+ "accept named curve leaf with named curve intermediate w/fips");
|
|
|
727bdf |
+
|
|
|
727bdf |
+ delete $ENV{OPENSSL_CONF};
|
|
|
727bdf |
+}
|
|
|
727bdf |
|
|
|
727bdf |
# Depth tests, note the depth limit bounds the number of CA certificates
|
|
|
727bdf |
# between the trust-anchor and the leaf, so, for example, with a root->ca->leaf
|