Fix incorrect return value in apps/apps.c:parse_yesno()
[openssl.git] / apps / req.c
index db70dc22755c2caaa22aae264dc5d1ebec820df7..f58e65ec852f9d87177d48685be32fa8b3146c0f 100644 (file)
 #include <openssl/x509v3.h>
 #include <openssl/objects.h>
 #include <openssl/pem.h>
-#include "../crypto/cryptlib.h"
+#include <openssl/bn.h>
+#ifndef OPENSSL_NO_RSA
+#include <openssl/rsa.h>
+#endif
+#ifndef OPENSSL_NO_DSA
+#include <openssl/dsa.h>
+#endif
 
 #define SECTION                "req"
 
@@ -344,6 +350,7 @@ int MAIN(int argc, char **argv)
                                {
                                X509 *xtmp=NULL;
                                EVP_PKEY *dtmp;
+                               EC_GROUP *group;
 
                                pkey_type=TYPE_EC;
                                p+=3;
@@ -354,10 +361,10 @@ int MAIN(int argc, char **argv)
                                        }
                                if ((ec_params = EC_KEY_new()) == NULL)
                                        goto end;
-                               if ((ec_params->group = PEM_read_bio_ECPKParameters(in, NULL, NULL, NULL)) == NULL)
+                               group = PEM_read_bio_ECPKParameters(in, NULL, NULL, NULL);
+                               if (group == NULL)
                                        {
-                                       if (ec_params)
-                                               EC_KEY_free(ec_params);
+                                       EC_KEY_free(ec_params);
                                        ERR_clear_error();
                                        (void)BIO_reset(in);
                                        if ((xtmp=PEM_read_bio_X509(in,NULL,NULL,NULL)) == NULL)
@@ -369,7 +376,7 @@ int MAIN(int argc, char **argv)
                                        if ((dtmp=X509_get_pubkey(xtmp))==NULL)
                                                goto end;
                                        if (dtmp->type == EVP_PKEY_EC)
-                                               ec_params = ECParameters_dup(dtmp->pkey.eckey);
+                                               ec_params = EC_KEY_dup(dtmp->pkey.ec);
                                        EVP_PKEY_free(dtmp);
                                        X509_free(xtmp);
                                        if (ec_params == NULL)
@@ -378,12 +385,16 @@ int MAIN(int argc, char **argv)
                                                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_params->group);
-
+                               newkey = EC_GROUP_get_degree(EC_KEY_get0_group(ec_params));
                                }
                        else
 #endif
@@ -720,7 +731,9 @@ bad:
 
        if (newreq && (pkey == NULL))
                {
+#ifndef OPENSSL_NO_RSA
                BN_GENCB cb;
+#endif
                char *randfile = NCONF_get_string(req_conf,SECTION,"RANDFILE");
                if (randfile == NULL)
                        ERR_clear_error();