isaacpittman-hitachi / rpms / openssl

Forked from rpms/openssl 2 years ago
Clone

Blame SOURCES/openssl-1.1.1-explicit-params.patch

ec892a
diff -up openssl-1.1.1g/crypto/ec/ec_asn1.c.explicit-params openssl-1.1.1g/crypto/ec/ec_asn1.c
ec892a
--- openssl-1.1.1g/crypto/ec/ec_asn1.c.explicit-params	2020-04-21 14:22:39.000000000 +0200
ec892a
+++ openssl-1.1.1g/crypto/ec/ec_asn1.c	2020-10-23 15:27:31.304312344 +0200
ec892a
@@ -137,6 +137,12 @@ struct ec_parameters_st {
ec892a
     ASN1_INTEGER *cofactor;
ec892a
 } /* ECPARAMETERS */ ;
ec892a
 
ec892a
+typedef enum {
ec892a
+    ECPKPARAMETERS_TYPE_NAMED = 0,
ec892a
+    ECPKPARAMETERS_TYPE_EXPLICIT,
ec892a
+    ECPKPARAMETERS_TYPE_IMPLICIT
ec892a
+} ecpk_parameters_type_t;
ec892a
+
ec892a
 struct ecpk_parameters_st {
ec892a
     int type;
ec892a
     union {
ec892a
@@ -535,9 +541,10 @@ ECPKPARAMETERS *EC_GROUP_get_ecpkparamet
ec892a
             return NULL;
ec892a
         }
ec892a
     } else {
ec892a
-        if (ret->type == 0)
ec892a
+        if (ret->type == ECPKPARAMETERS_TYPE_NAMED)
ec892a
             ASN1_OBJECT_free(ret->value.named_curve);
ec892a
-        else if (ret->type == 1 && ret->value.parameters)
ec892a
+        else if (ret->type == ECPKPARAMETERS_TYPE_EXPLICIT
ec892a
+                 && ret->value.parameters != NULL)
ec892a
             ECPARAMETERS_free(ret->value.parameters);
ec892a
     }
ec892a
 
ec892a
@@ -547,7 +554,7 @@ ECPKPARAMETERS *EC_GROUP_get_ecpkparamet
ec892a
          */
ec892a
         tmp = EC_GROUP_get_curve_name(group);
ec892a
         if (tmp) {
ec892a
-            ret->type = 0;
ec892a
+            ret->type = ECPKPARAMETERS_TYPE_NAMED;
ec892a
             if ((ret->value.named_curve = OBJ_nid2obj(tmp)) == NULL)
ec892a
                 ok = 0;
ec892a
         } else
ec892a
@@ -555,7 +562,7 @@ ECPKPARAMETERS *EC_GROUP_get_ecpkparamet
ec892a
             ok = 0;
ec892a
     } else {
ec892a
         /* use the ECPARAMETERS structure */
ec892a
-        ret->type = 1;
ec892a
+        ret->type = ECPKPARAMETERS_TYPE_EXPLICIT;
ec892a
         if ((ret->value.parameters =
ec892a
              EC_GROUP_get_ecparameters(group, NULL)) == NULL)
ec892a
             ok = 0;
ec892a
@@ -894,7 +901,8 @@ EC_GROUP *EC_GROUP_new_from_ecpkparamete
ec892a
         return NULL;
ec892a
     }
ec892a
 
ec892a
-    if (params->type == 0) {    /* the curve is given by an OID */
ec892a
+    if (params->type == ECPKPARAMETERS_TYPE_NAMED) {
ec892a
+        /* the curve is given by an OID */
ec892a
         tmp = OBJ_obj2nid(params->value.named_curve);
ec892a
         if ((ret = EC_GROUP_new_by_curve_name(tmp)) == NULL) {
ec892a
             ECerr(EC_F_EC_GROUP_NEW_FROM_ECPKPARAMETERS,
ec892a
@@ -902,15 +910,16 @@ EC_GROUP *EC_GROUP_new_from_ecpkparamete
ec892a
             return NULL;
ec892a
         }
ec892a
         EC_GROUP_set_asn1_flag(ret, OPENSSL_EC_NAMED_CURVE);
ec892a
-    } else if (params->type == 1) { /* the parameters are given by a
ec892a
-                                     * ECPARAMETERS structure */
ec892a
+    } else if (params->type == ECPKPARAMETERS_TYPE_EXPLICIT) {
ec892a
+        /* the parameters are given by an ECPARAMETERS structure */
ec892a
         ret = EC_GROUP_new_from_ecparameters(params->value.parameters);
ec892a
         if (!ret) {
ec892a
             ECerr(EC_F_EC_GROUP_NEW_FROM_ECPKPARAMETERS, ERR_R_EC_LIB);
ec892a
             return NULL;
ec892a
         }
ec892a
         EC_GROUP_set_asn1_flag(ret, OPENSSL_EC_EXPLICIT_CURVE);
ec892a
-    } else if (params->type == 2) { /* implicitlyCA */
ec892a
+    } else if (params->type == ECPKPARAMETERS_TYPE_IMPLICIT) {
ec892a
+        /* implicit parameters inherited from CA - unsupported */
ec892a
         return NULL;
ec892a
     } else {
ec892a
         ECerr(EC_F_EC_GROUP_NEW_FROM_ECPKPARAMETERS, EC_R_ASN1_ERROR);
ec892a
@@ -940,6 +949,9 @@ EC_GROUP *d2i_ECPKParameters(EC_GROUP **
ec892a
         return NULL;
ec892a
     }
ec892a
 
ec892a
+    if (params->type == ECPKPARAMETERS_TYPE_EXPLICIT)
ec892a
+        group->decoded_from_explicit_params = 1;
ec892a
+
ec892a
     if (a) {
ec892a
         EC_GROUP_free(*a);
ec892a
         *a = group;
ec892a
@@ -991,6 +1003,9 @@ EC_KEY *d2i_ECPrivateKey(EC_KEY **a, con
ec892a
     if (priv_key->parameters) {
ec892a
         EC_GROUP_free(ret->group);
ec892a
         ret->group = EC_GROUP_new_from_ecpkparameters(priv_key->parameters);
ec892a
+        if (ret->group != NULL
ec892a
+            && priv_key->parameters->type == ECPKPARAMETERS_TYPE_EXPLICIT)
ec892a
+            ret->group->decoded_from_explicit_params = 1;
ec892a
     }
ec892a
 
ec892a
     if (ret->group == NULL) {
ec892a
diff -up openssl-1.1.1g/crypto/ec/ec_key.c.explicit-params openssl-1.1.1g/crypto/ec/ec_key.c
ec892a
--- openssl-1.1.1g/crypto/ec/ec_key.c.explicit-params	2020-10-23 15:27:31.296312275 +0200
ec892a
+++ openssl-1.1.1g/crypto/ec/ec_key.c	2020-10-23 15:27:31.304312344 +0200
ec892a
@@ -566,6 +566,13 @@ void EC_KEY_clear_flags(EC_KEY *key, int
ec892a
     key->flags &= ~flags;
ec892a
 }
ec892a
 
ec892a
+int EC_KEY_decoded_from_explicit_params(const EC_KEY *key)
ec892a
+{
ec892a
+    if (key == NULL || key->group == NULL)
ec892a
+        return -1;
ec892a
+    return key->group->decoded_from_explicit_params;
ec892a
+}
ec892a
+
ec892a
 size_t EC_KEY_key2buf(const EC_KEY *key, point_conversion_form_t form,
ec892a
                         unsigned char **pbuf, BN_CTX *ctx)
ec892a
 {
ec892a
diff -up openssl-1.1.1g/crypto/ec/ec_lib.c.explicit-params openssl-1.1.1g/crypto/ec/ec_lib.c
ec892a
--- openssl-1.1.1g/crypto/ec/ec_lib.c.explicit-params	2020-04-21 14:22:39.000000000 +0200
ec892a
+++ openssl-1.1.1g/crypto/ec/ec_lib.c	2020-10-23 15:27:31.304312344 +0200
ec892a
@@ -211,6 +211,7 @@ int EC_GROUP_copy(EC_GROUP *dest, const
ec892a
 
ec892a
     dest->asn1_flag = src->asn1_flag;
ec892a
     dest->asn1_form = src->asn1_form;
ec892a
+    dest->decoded_from_explicit_params = src->decoded_from_explicit_params;
ec892a
 
ec892a
     if (src->seed) {
ec892a
         OPENSSL_free(dest->seed);
ec892a
diff -up openssl-1.1.1g/crypto/ec/ec_local.h.explicit-params openssl-1.1.1g/crypto/ec/ec_local.h
ec892a
--- openssl-1.1.1g/crypto/ec/ec_local.h.explicit-params	2020-10-23 15:27:31.281312147 +0200
ec892a
+++ openssl-1.1.1g/crypto/ec/ec_local.h	2020-10-23 15:27:31.304312344 +0200
ec892a
@@ -217,6 +217,8 @@ struct ec_group_st {
ec892a
     BIGNUM *order, *cofactor;
ec892a
     int curve_name;             /* optional NID for named curve */
ec892a
     int asn1_flag;              /* flag to control the asn1 encoding */
ec892a
+    int decoded_from_explicit_params; /* set if decoded from explicit
ec892a
+                                       * curve parameters encoding */
ec892a
     point_conversion_form_t asn1_form;
ec892a
     unsigned char *seed;        /* optional seed for parameters (appears in
ec892a
                                  * ASN1) */
ec892a
diff -up openssl-1.1.1g/crypto/x509/x509_txt.c.explicit-params openssl-1.1.1g/crypto/x509/x509_txt.c
ec892a
--- openssl-1.1.1g/crypto/x509/x509_txt.c.explicit-params	2020-04-21 14:22:39.000000000 +0200
ec892a
+++ openssl-1.1.1g/crypto/x509/x509_txt.c	2020-10-23 15:27:31.305312352 +0200
ec892a
@@ -174,6 +174,8 @@ const char *X509_verify_cert_error_strin
ec892a
         return "OCSP verification failed";
ec892a
     case X509_V_ERR_OCSP_CERT_UNKNOWN:
ec892a
         return "OCSP unknown cert";
ec892a
+    case X509_V_ERR_EC_KEY_EXPLICIT_PARAMS:
ec892a
+        return "Certificate public key has explicit ECC parameters";
ec892a
 
ec892a
     default:
ec892a
         /* Printing an error number into a static buffer is not thread-safe */
ec892a
diff -up openssl-1.1.1g/crypto/x509/x509_vfy.c.explicit-params openssl-1.1.1g/crypto/x509/x509_vfy.c
ec892a
--- openssl-1.1.1g/crypto/x509/x509_vfy.c.explicit-params	2020-10-23 15:27:31.252311900 +0200
ec892a
+++ openssl-1.1.1g/crypto/x509/x509_vfy.c	2020-10-23 15:27:31.305312352 +0200
ec892a
@@ -80,6 +80,7 @@ static int get_issuer_sk(X509 **issuer,
ec892a
 static int check_dane_issuer(X509_STORE_CTX *ctx, int depth);
ec892a
 static int check_key_level(X509_STORE_CTX *ctx, X509 *cert);
ec892a
 static int check_sig_level(X509_STORE_CTX *ctx, X509 *cert);
ec892a
+static int check_curve(X509 *cert);
ec892a
 
ec892a
 static int get_crl_score(X509_STORE_CTX *ctx, X509 **pissuer,
ec892a
                          unsigned int *preasons, X509_CRL *crl, X509 *x);
ec892a
@@ -508,6 +509,14 @@ static int check_chain_extensions(X509_S
ec892a
                 ret = 1;
ec892a
             break;
ec892a
         }
ec892a
+        if ((ctx->param->flags & X509_V_FLAG_X509_STRICT) && num > 1) {
ec892a
+            /* Check for presence of explicit elliptic curve parameters */
ec892a
+            ret = check_curve(x);
ec892a
+            if (ret < 0)
ec892a
+                ctx->error = X509_V_ERR_UNSPECIFIED;
ec892a
+            else if (ret == 0)
ec892a
+                ctx->error = X509_V_ERR_EC_KEY_EXPLICIT_PARAMS;
ec892a
+        }
ec892a
         if ((x->ex_flags & EXFLAG_CA) == 0
ec892a
             && x->ex_pathlen != -1
ec892a
             && (ctx->param->flags & X509_V_FLAG_X509_STRICT)) {
ec892a
@@ -3259,6 +3268,32 @@ static int check_key_level(X509_STORE_CT
ec892a
 }
ec892a
 
ec892a
 /*
ec892a
+ * Check whether the public key of ``cert`` does not use explicit params
ec892a
+ * for an elliptic curve.
ec892a
+ *
ec892a
+ * Returns 1 on success, 0 if check fails, -1 for other errors.
ec892a
+ */
ec892a
+static int check_curve(X509 *cert)
ec892a
+{
ec892a
+#ifndef OPENSSL_NO_EC
ec892a
+    EVP_PKEY *pkey = X509_get0_pubkey(cert);
ec892a
+
ec892a
+    /* Unsupported or malformed key */
ec892a
+    if (pkey == NULL)
ec892a
+        return -1;
ec892a
+
ec892a
+    if (EVP_PKEY_id(pkey) == EVP_PKEY_EC) {
ec892a
+        int ret;
ec892a
+
ec892a
+        ret = EC_KEY_decoded_from_explicit_params(EVP_PKEY_get0_EC_KEY(pkey));
ec892a
+        return ret < 0 ? ret : !ret;
ec892a
+    }
ec892a
+#endif
ec892a
+
ec892a
+    return 1;
ec892a
+}
ec892a
+
ec892a
+/*
ec892a
  * Check whether the signature digest algorithm of ``cert`` meets the security
ec892a
  * level of ``ctx``.  Should not be checked for trust anchors (whether
ec892a
  * self-signed or otherwise).
ec892a
diff -up openssl-1.1.1g/doc/man3/EC_KEY_new.pod.explicit-params openssl-1.1.1g/doc/man3/EC_KEY_new.pod
ec892a
--- openssl-1.1.1g/doc/man3/EC_KEY_new.pod.explicit-params	2020-04-21 14:22:39.000000000 +0200
ec892a
+++ openssl-1.1.1g/doc/man3/EC_KEY_new.pod	2020-10-23 15:27:31.305312352 +0200
ec892a
@@ -9,7 +9,8 @@ EC_KEY_get0_engine,
ec892a
 EC_KEY_get0_group, EC_KEY_set_group, EC_KEY_get0_private_key,
ec892a
 EC_KEY_set_private_key, EC_KEY_get0_public_key, EC_KEY_set_public_key,
ec892a
 EC_KEY_get_conv_form,
ec892a
-EC_KEY_set_conv_form, EC_KEY_set_asn1_flag, EC_KEY_precompute_mult,
ec892a
+EC_KEY_set_conv_form, EC_KEY_set_asn1_flag,
ec892a
+EC_KEY_decoded_from_explicit_params, EC_KEY_precompute_mult,
ec892a
 EC_KEY_generate_key, EC_KEY_check_key, EC_KEY_set_public_key_affine_coordinates,
ec892a
 EC_KEY_oct2key, EC_KEY_key2buf, EC_KEY_oct2priv, EC_KEY_priv2oct,
ec892a
 EC_KEY_priv2buf - Functions for creating, destroying and manipulating
ec892a
@@ -38,6 +39,7 @@ EC_KEY objects
ec892a
  point_conversion_form_t EC_KEY_get_conv_form(const EC_KEY *key);
ec892a
  void EC_KEY_set_conv_form(EC_KEY *eckey, point_conversion_form_t cform);
ec892a
  void EC_KEY_set_asn1_flag(EC_KEY *eckey, int asn1_flag);
ec892a
+ int EC_KEY_decoded_from_explicit_params(const EC_KEY *key);
ec892a
  int EC_KEY_precompute_mult(EC_KEY *key, BN_CTX *ctx);
ec892a
  int EC_KEY_generate_key(EC_KEY *key);
ec892a
  int EC_KEY_check_key(const EC_KEY *key);
ec892a
@@ -118,6 +120,10 @@ EC_KEY_set_asn1_flag() sets the asn1_fla
ec892a
 (if set). Refer to L<EC_GROUP_copy(3)> for further information on the
ec892a
 asn1_flag.
ec892a
 
ec892a
+EC_KEY_decoded_from_explicit_params() returns 1 if the group of the I<key> was
ec892a
+decoded from data with explicitly encoded group parameters, -1 if the I<key>
ec892a
+is NULL or the group parameters are missing, and 0 otherwise.
ec892a
+
ec892a
 EC_KEY_precompute_mult() stores multiples of the underlying EC_GROUP generator
ec892a
 for faster point multiplication. See also L<EC_POINT_add(3)>.
ec892a
 
ec892a
diff -up openssl-1.1.1g/include/openssl/ec.h.explicit-params openssl-1.1.1g/include/openssl/ec.h
ec892a
--- openssl-1.1.1g/include/openssl/ec.h.explicit-params	2020-04-21 14:22:39.000000000 +0200
ec892a
+++ openssl-1.1.1g/include/openssl/ec.h	2020-10-23 15:27:31.305312352 +0200
ec892a
@@ -829,6 +829,8 @@ void EC_KEY_set_flags(EC_KEY *key, int f
ec892a
 
ec892a
 void EC_KEY_clear_flags(EC_KEY *key, int flags);
ec892a
 
ec892a
+int EC_KEY_decoded_from_explicit_params(const EC_KEY *key);
ec892a
+
ec892a
 /** Creates a new EC_KEY object using a named curve as underlying
ec892a
  *  EC_GROUP object.
ec892a
  *  \param  nid  NID of the named curve.
ec892a
diff -up openssl-1.1.1g/include/openssl/x509_vfy.h.explicit-params openssl-1.1.1g/include/openssl/x509_vfy.h
ec892a
--- openssl-1.1.1g/include/openssl/x509_vfy.h.explicit-params	2020-04-21 14:22:39.000000000 +0200
ec892a
+++ openssl-1.1.1g/include/openssl/x509_vfy.h	2020-10-23 15:27:31.305312352 +0200
ec892a
@@ -184,6 +184,7 @@ void X509_STORE_CTX_set_depth(X509_STORE
ec892a
 # define         X509_V_ERR_OCSP_VERIFY_NEEDED                   73  /* Need OCSP verification */
ec892a
 # define         X509_V_ERR_OCSP_VERIFY_FAILED                   74  /* Couldn't verify cert through OCSP */
ec892a
 # define         X509_V_ERR_OCSP_CERT_UNKNOWN                    75  /* Certificate wasn't recognized by the OCSP responder */
ec892a
+# define         X509_V_ERR_EC_KEY_EXPLICIT_PARAMS               79
ec892a
 
ec892a
 /* Certificate verify flags */
ec892a
 
ec892a
diff -up openssl-1.1.1g/ssl/statem/statem_lib.c.explicit-params openssl-1.1.1g/ssl/statem/statem_lib.c
ec892a
--- openssl-1.1.1g/ssl/statem/statem_lib.c.explicit-params	2020-10-23 15:27:31.249311874 +0200
ec892a
+++ openssl-1.1.1g/ssl/statem/statem_lib.c	2020-10-23 15:27:31.305312352 +0200
ec892a
@@ -1341,6 +1341,7 @@ int tls_get_message_body(SSL *s, size_t
ec892a
 static const X509ERR2ALERT x509table[] = {
ec892a
     {X509_V_ERR_APPLICATION_VERIFICATION, SSL_AD_HANDSHAKE_FAILURE},
ec892a
     {X509_V_ERR_CA_KEY_TOO_SMALL, SSL_AD_BAD_CERTIFICATE},
ec892a
+    {X509_V_ERR_EC_KEY_EXPLICIT_PARAMS, SSL_AD_BAD_CERTIFICATE},
ec892a
     {X509_V_ERR_CA_MD_TOO_WEAK, SSL_AD_BAD_CERTIFICATE},
ec892a
     {X509_V_ERR_CERT_CHAIN_TOO_LONG, SSL_AD_UNKNOWN_CA},
ec892a
     {X509_V_ERR_CERT_HAS_EXPIRED, SSL_AD_CERTIFICATE_EXPIRED},
ec892a
diff -up openssl-1.1.1g/test/certs/ca-cert-ec-explicit.pem.explicit-params openssl-1.1.1g/test/certs/ca-cert-ec-explicit.pem
ec892a
--- openssl-1.1.1g/test/certs/ca-cert-ec-explicit.pem.explicit-params	2020-10-23 15:27:31.306312361 +0200
ec892a
+++ openssl-1.1.1g/test/certs/ca-cert-ec-explicit.pem	2020-10-23 15:27:31.305312352 +0200
ec892a
@@ -0,0 +1,19 @@
ec892a
+-----BEGIN CERTIFICATE-----
ec892a
+MIIDGDCCAgCgAwIBAgIBAjANBgkqhkiG9w0BAQsFADASMRAwDgYDVQQDDAdSb290
ec892a
+IENBMCAXDTIwMDkxNTEzMDY0MVoYDzIxMjAwOTE2MTMwNjQxWjANMQswCQYDVQQD
ec892a
+DAJDQTCCAUswggEDBgcqhkjOPQIBMIH3AgEBMCwGByqGSM49AQECIQD/////AAAA
ec892a
+AQAAAAAAAAAAAAAAAP///////////////zBbBCD/////AAAAAQAAAAAAAAAAAAAA
ec892a
+AP///////////////AQgWsY12Ko6k+ez671VdpiGvGUdBrDMU7D2O848PifSYEsD
ec892a
+FQDEnTYIhucEk2pmeOETnSa3gZ9+kARBBGsX0fLhLEJH+Lzm5WOkQPJ3A32BLesz
ec892a
+oPShOUXYmMKWT+NC4v4af5uO5+tKfA+eFivOM1drMV7Oy7ZAaDe/UfUCIQD/////
ec892a
+AAAAAP//////////vOb6racXnoTzucrC/GMlUQIBAQNCAASlXna3kSD/Yol3RA5I
ec892a
+icjIxYb9UJoCTzb/LsxjlOvIS5OqCTzpqP0p3JrnvLPsbzq7Cf/g0bNlxAGs1iVM
ec892a
+5NDco1MwUTAdBgNVHQ4EFgQUFk6ucH6gMXeadmuV7a1iWEnU/CIwHwYDVR0jBBgw
ec892a
+FoAUjvUlrx6ba4Q9fICayVOcTXL3o1IwDwYDVR0TAQH/BAUwAwEB/zANBgkqhkiG
ec892a
+9w0BAQsFAAOCAQEAdyUgfT0eAsZzoHFXoWN5uqi0MHuhLI37TEzkH5h7iTpDQJTQ
ec892a
+F0SjbawfM/nxxUekRW3mjFu3lft+VA7yC0OTNBLffan/vTh+HGOvvYZSMJYgKrMG
ec892a
+PRWgDId+n9RTcQCf+91cISvOazHixRiJG7JfRLdNZsAE+miw4HgPLFboTwpxtTDJ
ec892a
+zJ4ssBC6P+5IHwBCtNMiilJMMMzuSaZa5iSo6M9AdXWfcQN3uhW1lgQOLOlKLcbo
ec892a
+3UhW1GMMhTTeytM5aylbKhRsnL7ozmS44zsKZ25YaQxgjdKitFjVN6j7eyQ7C9J2
ec892a
+bLXgl3APweLQbGGs0zv08Ad0SCCKYLHK6mMJqg==
ec892a
+-----END CERTIFICATE-----
ec892a
diff -up openssl-1.1.1g/test/certs/ca-cert-ec-named.pem.explicit-params openssl-1.1.1g/test/certs/ca-cert-ec-named.pem
ec892a
--- openssl-1.1.1g/test/certs/ca-cert-ec-named.pem.explicit-params	2020-10-23 15:27:31.306312361 +0200
ec892a
+++ openssl-1.1.1g/test/certs/ca-cert-ec-named.pem	2020-10-23 15:27:31.306312361 +0200
ec892a
@@ -0,0 +1,14 @@
ec892a
+-----BEGIN CERTIFICATE-----
ec892a
+MIICJDCCAQygAwIBAgIBAjANBgkqhkiG9w0BAQsFADASMRAwDgYDVQQDDAdSb290
ec892a
+IENBMCAXDTIwMDkxNTEzMDY1MFoYDzIxMjAwOTE2MTMwNjUwWjANMQswCQYDVQQD
ec892a
+DAJDQTBZMBMGByqGSM49AgEGCCqGSM49AwEHA0IABPt+MXCi9+wztEvmdG2EVSk7
ec892a
+bAiJMXJXW/u0NbcGCrrbhO1NJSHHV3Lks888sqeSPh/bif/ASJ0HX+VarMUoFIKj
ec892a
+UzBRMB0GA1UdDgQWBBRjigU5REz8Lwf1iD6mALVhsHIanjAfBgNVHSMEGDAWgBSO
ec892a
+9SWvHptrhD18gJrJU5xNcvejUjAPBgNVHRMBAf8EBTADAQH/MA0GCSqGSIb3DQEB
ec892a
+CwUAA4IBAQCQs9wpblefb2C9a7usGL1DJjWJQIFHtUf+6p/KPgEV7LF138ECjL5s
ec892a
+0AWRd8Q8SbsBH49j2r3LLLMkvFglyRaN+FF+TCC/UQtclTb4+HgLsUT2xSU8U2cY
ec892a
+SOnzNB5AX/qAAsdOGqOjivPtGXcXFexDKPsw3n+3rJgymBP6hbLagb47IabNhot5
ec892a
+bMM6S+bmfpMwfsm885zr5vG2Gg9FjjH94Vx4I7eRLkjCS88gkIR1J35ecHFteOdo
ec892a
+idOaCHQddYiKukBzgdjtTxSDXKffkaybylrwOZ8VBlQd3zC7s02d+riHCnroLnnE
ec892a
+cwYLlJ5z6jN7zoPZ55yX/EmA0RVny2le
ec892a
+-----END CERTIFICATE-----
ec892a
diff -up openssl-1.1.1g/test/certs/ca-key-ec-explicit.pem.explicit-params openssl-1.1.1g/test/certs/ca-key-ec-explicit.pem
ec892a
--- openssl-1.1.1g/test/certs/ca-key-ec-explicit.pem.explicit-params	2020-10-23 15:27:31.306312361 +0200
ec892a
+++ openssl-1.1.1g/test/certs/ca-key-ec-explicit.pem	2020-10-23 15:27:31.306312361 +0200
ec892a
@@ -0,0 +1,10 @@
ec892a
+-----BEGIN PRIVATE KEY-----
ec892a
+MIIBeQIBADCCAQMGByqGSM49AgEwgfcCAQEwLAYHKoZIzj0BAQIhAP////8AAAAB
ec892a
+AAAAAAAAAAAAAAAA////////////////MFsEIP////8AAAABAAAAAAAAAAAAAAAA
ec892a
+///////////////8BCBaxjXYqjqT57PrvVV2mIa8ZR0GsMxTsPY7zjw+J9JgSwMV
ec892a
+AMSdNgiG5wSTamZ44ROdJreBn36QBEEEaxfR8uEsQkf4vOblY6RA8ncDfYEt6zOg
ec892a
+9KE5RdiYwpZP40Li/hp/m47n60p8D54WK84zV2sxXs7LtkBoN79R9QIhAP////8A
ec892a
+AAAA//////////+85vqtpxeehPO5ysL8YyVRAgEBBG0wawIBAQQgdEf20fpuqEZU
ec892a
+tZ4ORoq4vb5ETV4a6QOl/iGnDQt++/ihRANCAASlXna3kSD/Yol3RA5IicjIxYb9
ec892a
+UJoCTzb/LsxjlOvIS5OqCTzpqP0p3JrnvLPsbzq7Cf/g0bNlxAGs1iVM5NDc
ec892a
+-----END PRIVATE KEY-----
ec892a
diff -up openssl-1.1.1g/test/certs/ca-key-ec-named.pem.explicit-params openssl-1.1.1g/test/certs/ca-key-ec-named.pem
ec892a
--- openssl-1.1.1g/test/certs/ca-key-ec-named.pem.explicit-params	2020-10-23 15:27:31.306312361 +0200
ec892a
+++ openssl-1.1.1g/test/certs/ca-key-ec-named.pem	2020-10-23 15:27:31.306312361 +0200
ec892a
@@ -0,0 +1,5 @@
ec892a
+-----BEGIN PRIVATE KEY-----
ec892a
+MIGHAgEAMBMGByqGSM49AgEGCCqGSM49AwEHBG0wawIBAQQgCTrYrMKcyV49+w4B
ec892a
+TWr2WTZsMM4aFpaYulKAuhiuQ7mhRANCAAT7fjFwovfsM7RL5nRthFUpO2wIiTFy
ec892a
+V1v7tDW3Bgq624TtTSUhx1dy5LPPPLKnkj4f24n/wEidB1/lWqzFKBSC
ec892a
+-----END PRIVATE KEY-----
ec892a
diff -up openssl-1.1.1g/test/certs/ee-cert-ec-explicit.pem.explicit-params openssl-1.1.1g/test/certs/ee-cert-ec-explicit.pem
ec892a
--- openssl-1.1.1g/test/certs/ee-cert-ec-explicit.pem.explicit-params	2020-10-23 15:27:31.306312361 +0200
ec892a
+++ openssl-1.1.1g/test/certs/ee-cert-ec-explicit.pem	2020-10-23 15:27:31.306312361 +0200
ec892a
@@ -0,0 +1,16 @@
ec892a
+-----BEGIN CERTIFICATE-----
ec892a
+MIIChzCCAi6gAwIBAgIBAjAKBggqhkjOPQQDAjANMQswCQYDVQQDDAJDQTAgFw0y
ec892a
+MDA5MTUxMzE0MzlaGA8yMTIwMDkxNjEzMTQzOVowGTEXMBUGA1UEAwwOc2VydmVy
ec892a
+LmV4YW1wbGUwggFLMIIBAwYHKoZIzj0CATCB9wIBATAsBgcqhkjOPQEBAiEA////
ec892a
+/wAAAAEAAAAAAAAAAAAAAAD///////////////8wWwQg/////wAAAAEAAAAAAAAA
ec892a
+AAAAAAD///////////////wEIFrGNdiqOpPns+u9VXaYhrxlHQawzFOw9jvOPD4n
ec892a
+0mBLAxUAxJ02CIbnBJNqZnjhE50mt4GffpAEQQRrF9Hy4SxCR/i85uVjpEDydwN9
ec892a
+gS3rM6D0oTlF2JjClk/jQuL+Gn+bjufrSnwPnhYrzjNXazFezsu2QGg3v1H1AiEA
ec892a
+/////wAAAAD//////////7zm+q2nF56E87nKwvxjJVECAQEDQgAE+7TDP7C9VqQP
ec892a
+TnqoJc/Fvf/N45BX+lBfmfiGBeRKtSsvrERUlymzQ4/nxVtymozAgFxQ0my998HH
ec892a
+TSVCj7Sq56N9MHswHQYDVR0OBBYEFKKwEfKYhNv6fbQf0Xd0te7J3GZdMB8GA1Ud
ec892a
+IwQYMBaAFGOKBTlETPwvB/WIPqYAtWGwchqeMAkGA1UdEwQCMAAwEwYDVR0lBAww
ec892a
+CgYIKwYBBQUHAwEwGQYDVR0RBBIwEIIOc2VydmVyLmV4YW1wbGUwCgYIKoZIzj0E
ec892a
+AwIDRwAwRAIgb4UITAOFlATeaayWQX9r5gf61qcnzT7TjXCekf7ww9oCIBDltg/u
ec892a
+ZvS9gqviMFuPjTuk/FhsCTAUzTT7WmgcWeH7
ec892a
+-----END CERTIFICATE-----
ec892a
diff -up openssl-1.1.1g/test/certs/ee-cert-ec-named-explicit.pem.explicit-params openssl-1.1.1g/test/certs/ee-cert-ec-named-explicit.pem
ec892a
--- openssl-1.1.1g/test/certs/ee-cert-ec-named-explicit.pem.explicit-params	2020-10-23 15:27:31.306312361 +0200
ec892a
+++ openssl-1.1.1g/test/certs/ee-cert-ec-named-explicit.pem	2020-10-23 15:27:31.306312361 +0200
ec892a
@@ -0,0 +1,11 @@
ec892a
+-----BEGIN CERTIFICATE-----
ec892a
+MIIBlDCCATqgAwIBAgIBAjAKBggqhkjOPQQDAjANMQswCQYDVQQDDAJDQTAgFw0y
ec892a
+MDA5MTUxMzE0NDVaGA8yMTIwMDkxNjEzMTQ0NVowGTEXMBUGA1UEAwwOc2VydmVy
ec892a
+LmV4YW1wbGUwWTATBgcqhkjOPQIBBggqhkjOPQMBBwNCAAQv5PnMStW/Wx9lpvjl
ec892a
+JTsFIjc2wBv14sNuMh1hfNX8ZJcoCfAAKYu6ujxXt328GWBMaubRbBjOd/eqpEst
ec892a
+tYKzo30wezAdBgNVHQ4EFgQUmb/qcE413hkpmtjEMyRZZFcN1TYwHwYDVR0jBBgw
ec892a
+FoAUFk6ucH6gMXeadmuV7a1iWEnU/CIwCQYDVR0TBAIwADATBgNVHSUEDDAKBggr
ec892a
+BgEFBQcDATAZBgNVHREEEjAQgg5zZXJ2ZXIuZXhhbXBsZTAKBggqhkjOPQQDAgNI
ec892a
+ADBFAiEA9y6J8rdAbO0mDZscIb8rIn6HgxBW4WAqTlFeZeHjjOYCIAmt2ldyObOL
ec892a
+tXaiaxYX3WAOR1vmfzsdrkCAOCfAkpbo
ec892a
+-----END CERTIFICATE-----
ec892a
diff -up openssl-1.1.1g/test/certs/ee-cert-ec-named-named.pem.explicit-params openssl-1.1.1g/test/certs/ee-cert-ec-named-named.pem
ec892a
--- openssl-1.1.1g/test/certs/ee-cert-ec-named-named.pem.explicit-params	2020-10-23 15:27:31.306312361 +0200
ec892a
+++ openssl-1.1.1g/test/certs/ee-cert-ec-named-named.pem	2020-10-23 15:27:31.306312361 +0200
ec892a
@@ -0,0 +1,11 @@
ec892a
+-----BEGIN CERTIFICATE-----
ec892a
+MIIBkzCCATqgAwIBAgIBAjAKBggqhkjOPQQDAjANMQswCQYDVQQDDAJDQTAgFw0y
ec892a
+MDA5MTUxNDEwNDhaGA8yMTIwMDkxNjE0MTA0OFowGTEXMBUGA1UEAwwOc2VydmVy
ec892a
+LmV4YW1wbGUwWTATBgcqhkjOPQIBBggqhkjOPQMBBwNCAAS0YU57+RFRWxr/frnL
ec892a
++vOYkY3h9roKnvxCG07wK5tevEYtSdKz0KsHvDBDatw1r3JNv+m2p54/3AqFPAZ3
ec892a
+5b0Po30wezAdBgNVHQ4EFgQUypypuZrUl0BEmbuhfJpo3QFNIvUwHwYDVR0jBBgw
ec892a
+FoAUY4oFOURM/C8H9Yg+pgC1YbByGp4wCQYDVR0TBAIwADATBgNVHSUEDDAKBggr
ec892a
+BgEFBQcDATAZBgNVHREEEjAQgg5zZXJ2ZXIuZXhhbXBsZTAKBggqhkjOPQQDAgNH
ec892a
+ADBEAiAEkKD7H5uxQ4YbQOiN4evbu5RCV5W7TVE80iBfcY5u4wIgGcwr++lVNX0Q
ec892a
+CTT+M3ukDjOA8OEvKUz1TiDuRAQ29qU=
ec892a
+-----END CERTIFICATE-----
ec892a
diff -up openssl-1.1.1g/test/certs/ee-key-ec-explicit.pem.explicit-params openssl-1.1.1g/test/certs/ee-key-ec-explicit.pem
ec892a
--- openssl-1.1.1g/test/certs/ee-key-ec-explicit.pem.explicit-params	2020-10-23 15:27:31.306312361 +0200
ec892a
+++ openssl-1.1.1g/test/certs/ee-key-ec-explicit.pem	2020-10-23 15:27:31.306312361 +0200
ec892a
@@ -0,0 +1,10 @@
ec892a
+-----BEGIN PRIVATE KEY-----
ec892a
+MIIBeQIBADCCAQMGByqGSM49AgEwgfcCAQEwLAYHKoZIzj0BAQIhAP////8AAAAB
ec892a
+AAAAAAAAAAAAAAAA////////////////MFsEIP////8AAAABAAAAAAAAAAAAAAAA
ec892a
+///////////////8BCBaxjXYqjqT57PrvVV2mIa8ZR0GsMxTsPY7zjw+J9JgSwMV
ec892a
+AMSdNgiG5wSTamZ44ROdJreBn36QBEEEaxfR8uEsQkf4vOblY6RA8ncDfYEt6zOg
ec892a
+9KE5RdiYwpZP40Li/hp/m47n60p8D54WK84zV2sxXs7LtkBoN79R9QIhAP////8A
ec892a
+AAAA//////////+85vqtpxeehPO5ysL8YyVRAgEBBG0wawIBAQQg0cmpcTcEYG5G
ec892a
+ZaVkGjtsBc3sLZn1EuV9qNK2qx6iNzmhRANCAAT7tMM/sL1WpA9Oeqglz8W9/83j
ec892a
+kFf6UF+Z+IYF5Eq1Ky+sRFSXKbNDj+fFW3KajMCAXFDSbL33wcdNJUKPtKrn
ec892a
+-----END PRIVATE KEY-----
ec892a
diff -up openssl-1.1.1g/test/certs/ee-key-ec-named-explicit.pem.explicit-params openssl-1.1.1g/test/certs/ee-key-ec-named-explicit.pem
ec892a
--- openssl-1.1.1g/test/certs/ee-key-ec-named-explicit.pem.explicit-params	2020-10-23 15:27:31.306312361 +0200
ec892a
+++ openssl-1.1.1g/test/certs/ee-key-ec-named-explicit.pem	2020-10-23 15:27:31.306312361 +0200
ec892a
@@ -0,0 +1,5 @@
ec892a
+-----BEGIN PRIVATE KEY-----
ec892a
+MIGHAgEAMBMGByqGSM49AgEGCCqGSM49AwEHBG0wawIBAQQg2ue+X5ZFJPJPQG2E
ec892a
+WQY4ALv2PkPp2Gy6KrMiokgmjkehRANCAAQv5PnMStW/Wx9lpvjlJTsFIjc2wBv1
ec892a
+4sNuMh1hfNX8ZJcoCfAAKYu6ujxXt328GWBMaubRbBjOd/eqpEsttYKz
ec892a
+-----END PRIVATE KEY-----
ec892a
diff -up openssl-1.1.1g/test/certs/ee-key-ec-named-named.pem.explicit-params openssl-1.1.1g/test/certs/ee-key-ec-named-named.pem
ec892a
--- openssl-1.1.1g/test/certs/ee-key-ec-named-named.pem.explicit-params	2020-10-23 15:27:31.306312361 +0200
ec892a
+++ openssl-1.1.1g/test/certs/ee-key-ec-named-named.pem	2020-10-23 15:27:31.306312361 +0200
ec892a
@@ -0,0 +1,5 @@
ec892a
+-----BEGIN PRIVATE KEY-----
ec892a
+MIGHAgEAMBMGByqGSM49AgEGCCqGSM49AwEHBG0wawIBAQQgGSoneIKG3//ujXGu
ec892a
+/EoJdNhpKZj026EF/YQ5FblUBWahRANCAAS0YU57+RFRWxr/frnL+vOYkY3h9roK
ec892a
+nvxCG07wK5tevEYtSdKz0KsHvDBDatw1r3JNv+m2p54/3AqFPAZ35b0P
ec892a
+-----END PRIVATE KEY-----
ec892a
diff -up openssl-1.1.1g/test/certs/setup.sh.explicit-params openssl-1.1.1g/test/certs/setup.sh
ec892a
--- openssl-1.1.1g/test/certs/setup.sh.explicit-params	2020-04-21 14:22:39.000000000 +0200
ec892a
+++ openssl-1.1.1g/test/certs/setup.sh	2020-10-23 15:27:31.306312361 +0200
ec892a
@@ -116,6 +116,10 @@ openssl x509 -in ca-cert-md5.pem -trusto
ec892a
 # CA has 768-bit key
ec892a
 OPENSSL_KEYBITS=768 \
ec892a
 ./mkcert.sh genca "CA" ca-key-768 ca-cert-768 root-key root-cert
ec892a
+# EC cert with explicit curve
ec892a
+./mkcert.sh genca "CA" ca-key-ec-explicit ca-cert-ec-explicit root-key root-cert
ec892a
+# EC cert with named curve
ec892a
+./mkcert.sh genca "CA" ca-key-ec-named ca-cert-ec-named root-key root-cert
ec892a
 
ec892a
 # client intermediate ca: cca-cert
ec892a
 # trust variants: +serverAuth, -serverAuth, +clientAuth, -clientAuth
ec892a
@@ -184,6 +188,14 @@ OPENSSL_SIGALG=md5 \
ec892a
 # 768-bit leaf key
ec892a
 OPENSSL_KEYBITS=768 \
ec892a
 ./mkcert.sh genee server.example ee-key-768 ee-cert-768 ca-key ca-cert
ec892a
+# EC cert with explicit curve signed by named curve ca
ec892a
+./mkcert.sh genee server.example ee-key-ec-explicit ee-cert-ec-explicit ca-key-ec-named ca-cert-ec-named
ec892a
+# EC cert with named curve signed by explicit curve ca
ec892a
+./mkcert.sh genee server.example ee-key-ec-named-explicit \
ec892a
+    ee-cert-ec-named-explicit ca-key-ec-explicit ca-cert-ec-explicit
ec892a
+# EC cert with named curve signed by named curve ca
ec892a
+./mkcert.sh genee server.example ee-key-ec-named-named \
ec892a
+    ee-cert-ec-named-named ca-key-ec-named ca-cert-ec-named
ec892a
 
ec892a
 # Proxy certificates, off of ee-client
ec892a
 # Start with some good ones
ec892a
diff -up openssl-1.1.1g/test/ec_internal_test.c.explicit-params openssl-1.1.1g/test/ec_internal_test.c
ec892a
--- openssl-1.1.1g/test/ec_internal_test.c.explicit-params	2020-04-21 14:22:39.000000000 +0200
ec892a
+++ openssl-1.1.1g/test/ec_internal_test.c	2020-10-23 15:27:31.306312361 +0200
ec892a
@@ -183,6 +183,106 @@ static int field_tests_default(int n)
ec892a
     return ret;
ec892a
 }
ec892a
 
ec892a
+/*
ec892a
+ * Tests behavior of the decoded_from_explicit_params flag and API
ec892a
+ */
ec892a
+static int decoded_flag_test(void)
ec892a
+{
ec892a
+    EC_GROUP *grp;
ec892a
+    EC_GROUP *grp_copy = NULL;
ec892a
+    ECPARAMETERS *ecparams = NULL;
ec892a
+    ECPKPARAMETERS *ecpkparams = NULL;
ec892a
+    EC_KEY *key = NULL;
ec892a
+    unsigned char *encodedparams = NULL;
ec892a
+    const unsigned char *encp;
ec892a
+    int encodedlen;
ec892a
+    int testresult = 0;
ec892a
+
ec892a
+    /* Test EC_GROUP_new not setting the flag */
ec892a
+    grp = EC_GROUP_new(EC_GFp_simple_method());
ec892a
+    if (!TEST_ptr(grp)
ec892a
+        || !TEST_int_eq(grp->decoded_from_explicit_params, 0))
ec892a
+        goto err;
ec892a
+    EC_GROUP_free(grp);
ec892a
+
ec892a
+    /* Test EC_GROUP_new_by_curve_name not setting the flag */
ec892a
+    grp = EC_GROUP_new_by_curve_name(NID_X9_62_prime256v1);
ec892a
+    if (!TEST_ptr(grp)
ec892a
+        || !TEST_int_eq(grp->decoded_from_explicit_params, 0))
ec892a
+        goto err;
ec892a
+
ec892a
+    /* Test EC_GROUP_new_from_ecparameters not setting the flag */
ec892a
+    if (!TEST_ptr(ecparams = EC_GROUP_get_ecparameters(grp, NULL))
ec892a
+        || !TEST_ptr(grp_copy = EC_GROUP_new_from_ecparameters(ecparams))
ec892a
+        || !TEST_int_eq(grp_copy->decoded_from_explicit_params, 0))
ec892a
+        goto err;
ec892a
+    EC_GROUP_free(grp_copy);
ec892a
+    grp_copy = NULL;
ec892a
+    ECPARAMETERS_free(ecparams);
ec892a
+    ecparams = NULL;
ec892a
+
ec892a
+    /* Test EC_GROUP_new_from_ecpkparameters not setting the flag */
ec892a
+    if (!TEST_int_eq(EC_GROUP_get_asn1_flag(grp), OPENSSL_EC_NAMED_CURVE)
ec892a
+        || !TEST_ptr(ecpkparams = EC_GROUP_get_ecpkparameters(grp, NULL))
ec892a
+        || !TEST_ptr(grp_copy = EC_GROUP_new_from_ecpkparameters(ecpkparams))
ec892a
+        || !TEST_int_eq(grp_copy->decoded_from_explicit_params, 0)
ec892a
+        || !TEST_ptr(key = EC_KEY_new())
ec892a
+    /* Test EC_KEY_decoded_from_explicit_params on key without a group */
ec892a
+        || !TEST_int_eq(EC_KEY_decoded_from_explicit_params(key), -1)
ec892a
+        || !TEST_int_eq(EC_KEY_set_group(key, grp_copy), 1)
ec892a
+    /* Test EC_KEY_decoded_from_explicit_params negative case */
ec892a
+        || !TEST_int_eq(EC_KEY_decoded_from_explicit_params(key), 0))
ec892a
+        goto err;
ec892a
+    EC_GROUP_free(grp_copy);
ec892a
+    grp_copy = NULL;
ec892a
+    ECPKPARAMETERS_free(ecpkparams);
ec892a
+    ecpkparams = NULL;
ec892a
+
ec892a
+    /* Test d2i_ECPKParameters with named params not setting the flag */
ec892a
+    if (!TEST_int_gt(encodedlen = i2d_ECPKParameters(grp, &encodedparams), 0)
ec892a
+        || !TEST_ptr(encp = encodedparams)
ec892a
+        || !TEST_ptr(grp_copy = d2i_ECPKParameters(NULL, &encp, encodedlen))
ec892a
+        || !TEST_int_eq(grp_copy->decoded_from_explicit_params, 0))
ec892a
+        goto err;
ec892a
+    EC_GROUP_free(grp_copy);
ec892a
+    grp_copy = NULL;
ec892a
+    OPENSSL_free(encodedparams);
ec892a
+    encodedparams = NULL;
ec892a
+
ec892a
+    /* Asn1 flag stays set to explicit with EC_GROUP_new_from_ecpkparameters */
ec892a
+    EC_GROUP_set_asn1_flag(grp, OPENSSL_EC_EXPLICIT_CURVE);
ec892a
+    if (!TEST_ptr(ecpkparams = EC_GROUP_get_ecpkparameters(grp, NULL))
ec892a
+        || !TEST_ptr(grp_copy = EC_GROUP_new_from_ecpkparameters(ecpkparams))
ec892a
+        || !TEST_int_eq(EC_GROUP_get_asn1_flag(grp_copy), OPENSSL_EC_EXPLICIT_CURVE)
ec892a
+        || !TEST_int_eq(grp_copy->decoded_from_explicit_params, 0))
ec892a
+        goto err;
ec892a
+    EC_GROUP_free(grp_copy);
ec892a
+    grp_copy = NULL;
ec892a
+
ec892a
+    /* Test d2i_ECPKParameters with explicit params setting the flag */
ec892a
+    if (!TEST_int_gt(encodedlen = i2d_ECPKParameters(grp, &encodedparams), 0)
ec892a
+        || !TEST_ptr(encp = encodedparams)
ec892a
+        || !TEST_ptr(grp_copy = d2i_ECPKParameters(NULL, &encp, encodedlen))
ec892a
+        || !TEST_int_eq(EC_GROUP_get_asn1_flag(grp_copy), OPENSSL_EC_EXPLICIT_CURVE)
ec892a
+        || !TEST_int_eq(grp_copy->decoded_from_explicit_params, 1)
ec892a
+        || !TEST_int_eq(EC_KEY_set_group(key, grp_copy), 1)
ec892a
+    /* Test EC_KEY_decoded_from_explicit_params positive case */
ec892a
+        || !TEST_int_eq(EC_KEY_decoded_from_explicit_params(key), 1))
ec892a
+        goto err;
ec892a
+
ec892a
+    testresult = 1;
ec892a
+
ec892a
+ err:
ec892a
+    EC_KEY_free(key);
ec892a
+    EC_GROUP_free(grp);
ec892a
+    EC_GROUP_free(grp_copy);
ec892a
+    ECPARAMETERS_free(ecparams);
ec892a
+    ECPKPARAMETERS_free(ecpkparams);
ec892a
+    OPENSSL_free(encodedparams);
ec892a
+
ec892a
+    return testresult;
ec892a
+}
ec892a
+
ec892a
 int setup_tests(void)
ec892a
 {
ec892a
     crv_len = EC_get_builtin_curves(NULL, 0);
ec892a
@@ -196,6 +296,7 @@ int setup_tests(void)
ec892a
     ADD_TEST(field_tests_ec2_simple);
ec892a
 #endif
ec892a
     ADD_ALL_TESTS(field_tests_default, crv_len);
ec892a
+    ADD_TEST(decoded_flag_test);
ec892a
     return 1;
ec892a
 }
ec892a
 
ec892a
diff -up openssl-1.1.1g/test/recipes/25-test_verify.t.explicit-params openssl-1.1.1g/test/recipes/25-test_verify.t
ec892a
--- openssl-1.1.1g/test/recipes/25-test_verify.t.explicit-params	2020-10-23 15:27:31.253311908 +0200
ec892a
+++ openssl-1.1.1g/test/recipes/25-test_verify.t	2020-10-23 15:27:31.306312361 +0200
ec892a
@@ -27,7 +27,7 @@ sub verify {
ec892a
     run(app([@args]));
ec892a
 }
ec892a
 
ec892a
-plan tests => 137;
ec892a
+plan tests => 142;
ec892a
 
ec892a
 # Canonical success
ec892a
 ok(verify("ee-cert", "sslserver", ["root-cert"], ["ca-cert"]),
ec892a
@@ -280,6 +280,27 @@ ok(verify("ee-cert-md5", "sslserver", ["
ec892a
 ok(!verify("ee-cert-md5", "sslserver", ["root-cert"], ["ca-cert"]),
ec892a
    "reject md5 leaf at auth level 1");
ec892a
 
ec892a
+# Explicit vs named curve tests
ec892a
+SKIP: {
ec892a
+    skip "EC is not supported by this OpenSSL build", 5
ec892a
+        if disabled("ec");
ec892a
+    ok(verify("ee-cert-ec-explicit", "sslserver", ["root-cert"],
ec892a
+               ["ca-cert-ec-named"]),
ec892a
+        "accept explicit curve leaf with named curve intermediate without strict");
ec892a
+    ok(verify("ee-cert-ec-named-explicit", "sslserver", ["root-cert"],
ec892a
+               ["ca-cert-ec-explicit"]),
ec892a
+        "accept named curve leaf with explicit curve intermediate without strict");
ec892a
+    ok(!verify("ee-cert-ec-explicit", "sslserver", ["root-cert"],
ec892a
+               ["ca-cert-ec-named"], "-x509_strict"),
ec892a
+        "reject explicit curve leaf with named curve intermediate with strict");
ec892a
+    ok(!verify("ee-cert-ec-named-explicit", "sslserver", ["root-cert"],
ec892a
+               ["ca-cert-ec-explicit"], "-x509_strict"),
ec892a
+        "reject named curve leaf with explicit curve intermediate with strict");
ec892a
+    ok(verify("ee-cert-ec-named-named", "sslserver", ["root-cert"],
ec892a
+              ["ca-cert-ec-named"], "-x509_strict"),
ec892a
+        "accept named curve leaf with named curve intermediate with strict");
ec892a
+}
ec892a
+
ec892a
 # Depth tests, note the depth limit bounds the number of CA certificates
ec892a
 # between the trust-anchor and the leaf, so, for example, with a root->ca->leaf
ec892a
 # chain, depth = 1 is sufficient, but depth == 0 is not.
ec892a
diff -up openssl-1.1.1g/util/libcrypto.num.explicit-params openssl-1.1.1g/util/libcrypto.num
ec892a
--- openssl-1.1.1g/util/libcrypto.num.explicit-params	2020-10-23 15:27:31.265312011 +0200
ec892a
+++ openssl-1.1.1g/util/libcrypto.num	2020-10-23 15:31:37.424413877 +0200
ec892a
@@ -4587,6 +4587,7 @@ EVP_PKEY_meth_set_digestverify
ec892a
 EVP_PKEY_meth_get_digestverify          4541	1_1_1e	EXIST::FUNCTION:
ec892a
 EVP_PKEY_meth_get_digestsign            4542	1_1_1e	EXIST::FUNCTION:
ec892a
 RSA_get0_pss_params                     4543	1_1_1e	EXIST::FUNCTION:RSA
ec892a
+EC_KEY_decoded_from_explicit_params     4547	1_1_1h	EXIST::FUNCTION:EC
ec892a
 FIPS_drbg_reseed                        6348	1_1_0g	EXIST::FUNCTION:
ec892a
 FIPS_selftest_check                     6349	1_1_0g	EXIST::FUNCTION:
ec892a
 FIPS_rand_set_method                    6350	1_1_0g	EXIST::FUNCTION: