Renamings and other fixes
diff --git a/library/ecp.c b/library/ecp.c
index 992c436..ad6e5f5 100644
--- a/library/ecp.c
+++ b/library/ecp.c
@@ -115,13 +115,10 @@
  *  - size in bits
  *  - readable name
  *
- * The sequence of elements in this list also determines the default preference
- * of the curves used by an ECHDE handshake.
- * We start with the most secure curves. From the same sized curves, we prefer
- * the SECP ones because they are much faster.
- *
+ * Curves are listed in order: largest curves first, and for a given size,
+ * fastest curves first. This provides the default order for the SSL module.
  */
-static const ecp_curve_info ecp_supported_curves[] =
+static const ecp_curve_info ecp_supported_curves[POLARSSL_ECP_DP_MAX] =
 {
 #if defined(POLARSSL_ECP_DP_SECP521R1_ENABLED)
     { POLARSSL_ECP_DP_SECP521R1,    25,     521,    "secp521r1"         },
@@ -138,28 +135,28 @@
 #if defined(POLARSSL_ECP_DP_SECP256R1_ENABLED)
     { POLARSSL_ECP_DP_SECP256R1,    23,     256,    "secp256r1"         },
 #endif
+#if defined(POLARSSL_ECP_DP_SECP256K1_ENABLED)
+    { POLARSSL_ECP_DP_SECP256K1,    22,     256,    "secp256k1"         },
+#endif
 #if defined(POLARSSL_ECP_DP_BP256R1_ENABLED)
     { POLARSSL_ECP_DP_BP256R1,      26,     256,    "brainpoolP256r1"   },
 #endif
 #if defined(POLARSSL_ECP_DP_SECP224R1_ENABLED)
     { POLARSSL_ECP_DP_SECP224R1,    21,     224,    "secp224r1"         },
 #endif
-#if defined(POLARSSL_ECP_DP_SECP192R1_ENABLED)
-    { POLARSSL_ECP_DP_SECP192R1,    19,     192,    "secp192r1"         },
-#endif
-#if defined(POLARSSL_ECP_DP_SECP256K1_ENABLED)
-    { POLARSSL_ECP_DP_SECP256K1,    22,     256,    "secp256k1"         },
-#endif
 #if defined(POLARSSL_ECP_DP_SECP224K1_ENABLED)
     { POLARSSL_ECP_DP_SECP224K1,    20,     224,    "secp224k1"         },
 #endif
+#if defined(POLARSSL_ECP_DP_SECP192R1_ENABLED)
+    { POLARSSL_ECP_DP_SECP192R1,    19,     192,    "secp192r1"         },
+#endif
 #if defined(POLARSSL_ECP_DP_SECP192K1_ENABLED)
     { POLARSSL_ECP_DP_SECP192K1,    18,     192,    "secp192k1"         },
 #endif
     { POLARSSL_ECP_DP_NONE,          0,     0,      NULL                },
 };
-#define ECP_NUM_SUPPORTED_CURVES ( sizeof( ecp_supported_curves ) / \
-                                   sizeof( ecp_curve_info )         )
+
+static ecp_group_id ecp_supported_grp_id[POLARSSL_ECP_DP_MAX];
 
 /*
  * List of supported curves and associated info
@@ -170,7 +167,33 @@
 }
 
 /*
- * Get the curve info for the internal identifer
+ * List of supported curves, group ID only
+ */
+const ecp_group_id *ecp_grp_id_list( void )
+{
+    static int init_done = 0;
+
+    if( ! init_done )
+    {
+        size_t i = 0;
+        const ecp_curve_info *curve_info;
+
+        for( curve_info = ecp_curve_list();
+             curve_info->grp_id != POLARSSL_ECP_DP_NONE;
+             curve_info++ )
+        {
+            ecp_supported_grp_id[i++] = curve_info->grp_id;
+        }
+        ecp_supported_grp_id[i] = POLARSSL_ECP_DP_NONE;
+
+        init_done = 1;
+    }
+
+    return ecp_supported_grp_id;
+}
+
+/*
+ * Get the curve info for the internal identifier
  */
 const ecp_curve_info *ecp_curve_info_from_grp_id( ecp_group_id grp_id )
 {
@@ -224,23 +247,6 @@
 }
 
 /*
- * Get the default ECDH curve list
- */
-ecp_group_id *ecp_get_default_echd_curve_list( void )
-{
-    static ecp_group_id ecdh_default_curve_list[ECP_NUM_SUPPORTED_CURVES];
-    int i;
-
-    /* Build the list of default curves based on ecp_supported_curves[] */
-    for( i = 0; i < ECP_NUM_SUPPORTED_CURVES; i++)
-    {
-        ecdh_default_curve_list[i] = ecp_supported_curves[i].grp_id;
-    }
-
-    return ecdh_default_curve_list;
-}
-
-/*
  * Get the type of a curve
  */
 static inline ecp_curve_type ecp_get_type( const ecp_group *grp )