Follow on from CVE-2014-3571. This fixes the code that was the original source
[oweals/openssl.git] / apps / ecparam.c
index e9aa0a184ae7a38868d1bd3753c5cbdc6fe06cc7..4f6a65491916ebaa08119fff37dd1058d163520d 100644 (file)
@@ -87,7 +87,8 @@
 #undef PROG
 #define PROG   ecparam_main
 
-/* -inform arg      - input format - default PEM (DER or PEM)
+/*-
+ * -inform arg      - input format - default PEM (DER or PEM)
  * -outform arg     - output format - default PEM
  * -in  arg         - input file  - default stdin
  * -out arg         - output file - default stdout
  *                    in the asn1 der encoding
  *                    possible values: named_curve (default)
  *                                     explicit
- * -no_seed         - if 'explicit' parameters are choosen do not use the seed
+ * -no_seed         - if 'explicit' parameters are chosen do not use the seed
  * -genkey          - generate ec key
  * -rand file       - files to use for random number input
  * -engine e        - use engine e, possibly a hardware device
@@ -129,9 +130,6 @@ int MAIN(int argc, char **argv)
        char    *infile = NULL, *outfile = NULL, *prog;
        BIO     *in = NULL, *out = NULL;
        int     informat, outformat, noout = 0, C = 0, ret = 1;
-#ifndef OPENSSL_NO_ENGINE
-       ENGINE  *e = NULL;
-#endif
        char    *engine = NULL;
 
        BIGNUM  *ec_p = NULL, *ec_a = NULL, *ec_b = NULL,
@@ -289,7 +287,7 @@ bad:
                BIO_printf(bio_err, "                                   "
                                " explicit\n");
                BIO_printf(bio_err, " -no_seed          if 'explicit'"
-                               " parameters are choosen do not"
+                               " parameters are chosen do not"
                                " use the seed\n");
                BIO_printf(bio_err, " -genkey           generate ec"
                                " key\n");
@@ -340,7 +338,7 @@ bad:
                }
 
 #ifndef OPENSSL_NO_ENGINE
-       e = setup_engine(bio_err, engine, 0);
+       setup_engine(bio_err, engine, 0);
 #endif
 
        if (list_curves)
@@ -405,6 +403,9 @@ bad:
                        }
                else
                        nid = OBJ_sn2nid(curve_name);
+
+               if (nid == 0)
+                       nid = EC_curve_nist2nid(curve_name);
        
                if (nid == 0)
                        {