+static const ec_list_element *ec_curve_nid2curve(int nid)
+{
+ size_t i;
+
+ if (nid <= 0)
+ return NULL;
+
+ for (i = 0; i < curve_list_length; i++) {
+ if (curve_list[i].nid == nid)
+ return &curve_list[i];
+ }
+ return NULL;
+}
+
+static const ec_list_element *ec_curve_name2curve(const char *name)
+{
+ size_t i;
+
+ for (i = 0; i < curve_list_length; i++) {
+ if (strcasecmp(curve_list[i].name, name) == 0)
+ return &curve_list[i];
+ }
+ return NULL;
+}
+
+const char *ec_curve_nid2name(int nid)
+{
+ /*
+ * TODO(3.0) Figure out if we should try to find the nid with
+ * EC_curve_nid2nist() first, i.e. make it a priority to return
+ * NIST names if there is one for the NID. This is related to
+ * the TODO comment in ec_curve_name2nid().
+ */
+ const ec_list_element *curve = ec_curve_nid2curve(nid);
+
+ if (curve != NULL)
+ return curve->name;
+ return NULL;
+}
+
+int ec_curve_name2nid(const char *name)
+{
+ const ec_list_element *curve = NULL;
+ int nid;
+
+ if ((nid = EC_curve_nist2nid(name)) != NID_undef)
+ return nid;
+
+#ifndef FIPS_MODE
+ /*
+ * TODO(3.0) Figure out if we can use other names than the NIST names
+ * ("B-163", "K-163" & "P-192") in the FIPS module, or if other names
+ * are allowed as well as long as they lead to the same curve data.
+ * If only the NIST names are allowed in the FIPS module, we should
+ * move '#endif' to just before 'return NID_undef'.
+ */
+#endif
+ if ((curve = ec_curve_name2curve(name)) != NULL)
+ return curve->nid;
+ return NID_undef;
+}
+