+#ifndef OPENSSL_NO_ECDSA
+ if (strncmp("ec:",p,3) == 0)
+ {
+ X509 *xtmp=NULL;
+ EVP_PKEY *dtmp;
+ EC_GROUP *group;
+
+ pkey_type=TYPE_EC;
+ p+=3;
+ if ((in=BIO_new_file(p,"r")) == NULL)
+ {
+ perror(p);
+ goto end;
+ }
+ if ((ec_params = EC_KEY_new()) == NULL)
+ goto end;
+ group = PEM_read_bio_ECPKParameters(in, NULL, NULL, NULL);
+ if (group == NULL)
+ {
+ EC_KEY_free(ec_params);
+ ERR_clear_error();
+ (void)BIO_reset(in);
+ if ((xtmp=PEM_read_bio_X509(in,NULL,NULL,NULL)) == NULL)
+ {
+ BIO_printf(bio_err,"unable to load EC parameters from file\n");
+ goto end;
+ }
+
+ if ((dtmp=X509_get_pubkey(xtmp))==NULL)
+ goto end;
+ if (dtmp->type == EVP_PKEY_EC)
+ ec_params = EC_KEY_dup(dtmp->pkey.ec);
+ EVP_PKEY_free(dtmp);
+ X509_free(xtmp);
+ if (ec_params == NULL)
+ {
+ BIO_printf(bio_err,"Certificate does not contain EC parameters\n");
+ goto end;
+ }
+ }
+ else
+ {
+ if (EC_KEY_set_group(ec_params, group) == 0)
+ goto end;
+ EC_GROUP_free(group);
+ }
+
+ BIO_free(in);
+ in=NULL;
+ newkey = EC_GROUP_get_degree(EC_KEY_get0_group(ec_params));
+ }
+ else
+#endif
+#ifndef OPENSSL_NO_DH