Windows doesn't know sys/file.h
[openssl.git] / apps / ecparam.c
index e0a56062d340dc7c756e06c243eb9d41e052ec2c..02bf6c1a9dd5e0bfebb48caaf713e7aa0a4ed3dd 100644 (file)
  * The Contribution is licensed pursuant to the OpenSSL open source
  * license provided above.
  *
- * In addition, Sun covenants to all licensees who provide a reciprocal
- * covenant with respect to their own patents if any, not to sue under
- * current and future patent claims necessarily infringed by the making,
- * using, practicing, selling, offering for sale and/or otherwise
- * disposing of the Contribution as delivered hereunder 
- * (or portions thereof), provided that such covenant shall not apply:
- *  1) for code that a licensee deletes from the Contribution;
- *  2) separates from the Contribution; or
- *  3) for infringements caused by:
- *       i) the modification of the Contribution or
- *      ii) the combination of the Contribution with other software or
- *          devices where such combination causes the infringement.
- *
  * The elliptic curve binary polynomial software is originally written by 
  * Sheueling Chang Shantz and Douglas Stebila of Sun Microsystems Laboratories.
  *
@@ -352,19 +339,33 @@ bad:
 
        if (list_curves)
                {
-               int counter=0;
+               EC_builtin_curve *curves = NULL;
+               size_t crv_len = 0;
+               size_t n = 0;
+               size_t len;
+
+               crv_len = EC_get_builtin_curves(NULL, 0);
+
+               curves = OPENSSL_malloc(sizeof(EC_builtin_curve) * crv_len);
+
+               if (curves == NULL)
+                       goto end;
 
-               for (;;)
+               if (!EC_get_builtin_curves(curves, crv_len))
+                       {
+                       OPENSSL_free(curves);
+                       goto end;
+                       }
+
+               
+               for (n = 0; n < crv_len; n++)
                        {
                        const char *comment;
                        const char *sname;
-                       int len, nid = ec_group_index2nid(counter++);
-                       if (!nid)
-                               break;
-                       comment = EC_GROUP_get0_comment(nid);
-                       sname   = OBJ_nid2sn(nid);
+                       comment = curves[n].comment;
+                       sname   = OBJ_nid2sn(curves[n].nid);
                        if (comment == NULL)
-                               comment = "";
+                               comment = "CURVE DESCRIPTION NOT AVAILABLE";
                        if (sname == NULL)
                                sname = "";
 
@@ -375,6 +376,7 @@ bad:
                                BIO_printf(out, "%s\n", comment);
                        } 
 
+               OPENSSL_free(curves);
                ret = 0;
                goto end;
                }