Apply review feedback on ECP interface

Naming conventions are revised, style issues corrected and minor
optimisation added.
diff --git a/include/mbedtls/check_config.h b/include/mbedtls/check_config.h
index 6fe6d52..a3ec49d 100644
--- a/include/mbedtls/check_config.h
+++ b/include/mbedtls/check_config.h
@@ -150,43 +150,43 @@
 #error "MBEDTLS_GCM_C defined, but not all prerequisites"
 #endif
 
-#if defined(MBEDTLS_ECP_INIT_ALT) && !defined(MBEDTLS_ECP_FUNCTION_ALT)
+#if defined(MBEDTLS_ECP_INIT_ALT) && !defined(MBEDTLS_ECP_INTERNAL_ALT)
 #error "MBEDTLS_ECP_INIT_ALT defined, but not all prerequisites"
 #endif
 
-#if defined(MBEDTLS_ECP_DEINIT_ALT) && !defined(MBEDTLS_ECP_FUNCTION_ALT)
+#if defined(MBEDTLS_ECP_DEINIT_ALT) && !defined(MBEDTLS_ECP_INTERNAL_ALT)
 #error "MBEDTLS_ECP_DEINIT_ALT defined, but not all prerequisites"
 #endif
 
-#if defined(MBEDTLS_ECP_RANDOMIZE_JAC_ALT) && !defined(MBEDTLS_ECP_FUNCTION_ALT)
+#if defined(MBEDTLS_ECP_RANDOMIZE_JAC_ALT) && !defined(MBEDTLS_ECP_INTERNAL_ALT)
 #error "MBEDTLS_ECP_RANDOMIZE_JAC_ALT defined, but not all prerequisites"
 #endif
 
-#if defined(MBEDTLS_ECP_ADD_MIXED_ALT) && !defined(MBEDTLS_ECP_FUNCTION_ALT)
+#if defined(MBEDTLS_ECP_ADD_MIXED_ALT) && !defined(MBEDTLS_ECP_INTERNAL_ALT)
 #error "MBEDTLS_ECP_ADD_MIXED_ALT defined, but not all prerequisites"
 #endif
 
-#if defined(MBEDTLS_ECP_DOUBLE_JAC_ALT) && !defined(MBEDTLS_ECP_FUNCTION_ALT)
+#if defined(MBEDTLS_ECP_DOUBLE_JAC_ALT) && !defined(MBEDTLS_ECP_INTERNAL_ALT)
 #error "MBEDTLS_ECP_DOUBLE_JAC_ALT defined, but not all prerequisites"
 #endif
 
-#if defined(MBEDTLS_ECP_NORMALIZE_JAC_MANY_ALT) && !defined(MBEDTLS_ECP_FUNCTION_ALT)
+#if defined(MBEDTLS_ECP_NORMALIZE_JAC_MANY_ALT) && !defined(MBEDTLS_ECP_INTERNAL_ALT)
 #error "MBEDTLS_ECP_NORMALIZE_JAC_MANY_ALT defined, but not all prerequisites"
 #endif
 
-#if defined(MBEDTLS_ECP_NORMALIZE_JAC_ALT) && !defined(MBEDTLS_ECP_FUNCTION_ALT)
+#if defined(MBEDTLS_ECP_NORMALIZE_JAC_ALT) && !defined(MBEDTLS_ECP_INTERNAL_ALT)
 #error "MBEDTLS_ECP_NORMALIZE_JAC_ALT defined, but not all prerequisites"
 #endif
 
-#if defined(MBEDTLS_ECP_DOUBLE_ADD_MXZ_ALT) && !defined(MBEDTLS_ECP_FUNCTION_ALT)
+#if defined(MBEDTLS_ECP_DOUBLE_ADD_MXZ_ALT) && !defined(MBEDTLS_ECP_INTERNAL_ALT)
 #error "MBEDTLS_ECP_DOUBLE_ADD_MXZ_ALT defined, but not all prerequisites"
 #endif
 
-#if defined(MBEDTLS_ECP_RANDOMIZE_MXZ_ALT) && !defined(MBEDTLS_ECP_FUNCTION_ALT)
+#if defined(MBEDTLS_ECP_RANDOMIZE_MXZ_ALT) && !defined(MBEDTLS_ECP_INTERNAL_ALT)
 #error "MBEDTLS_ECP_RANDOMIZE_MXZ_ALT defined, but not all prerequisites"
 #endif
 
-#if defined(MBEDTLS_ECP_NORMALIZE_MXZ_ALT) && !defined(MBEDTLS_ECP_FUNCTION_ALT)
+#if defined(MBEDTLS_ECP_NORMALIZE_MXZ_ALT) && !defined(MBEDTLS_ECP_INTERNAL_ALT)
 #error "MBEDTLS_ECP_NORMALIZE_MXZ_ALT defined, but not all prerequisites"
 #endif
 
diff --git a/include/mbedtls/config.h b/include/mbedtls/config.h
index 50dc70c..f5df5c9 100644
--- a/include/mbedtls/config.h
+++ b/include/mbedtls/config.h
@@ -296,7 +296,9 @@
 //#define MBEDTLS_AES_DECRYPT_ALT
 
 /**
- * \def MBEDTLS_ECP_FUNCTION_ALT
+ * \def MBEDTLS_ECP_INTERNAL_ALT
+ *
+ * Expose a part of the internal interface of the Elliptic Curve Point module.
  *
  * MBEDTLS_ECP__FUNCTION_NAME__ALT: Uncomment a macro to let mbed TLS use your
  * alternative core implementation of elliptic curve arithmetic. Keep in mind
@@ -307,37 +309,34 @@
  * is still present and it is used for group structures not supported by the
  * alternative.
  *
- * Any of these options become available by defining MBEDTLS_ECP_FUNCTION_ALT
- * and implementing the following function:
- * unsigned char mbedtls_ecp_alt_grp_capable( const mbedtls_ecp_group *grp )
- * This should return 1 if the replacement functions implement arithmetic for
- * the given group and 0 otherwise.
+ * Any of these options become available by defining MBEDTLS_ECP_INTERNAL_ALT
+ * and implementing the following functions:
+ *      unsigned char mbedtls_internal_ecp_grp_capable(
+ *          const mbedtls_ecp_group *grp )
+ *      int  mbedtls_internal_ecp_init( const mbedtls_ecp_group *grp )
+ *      void mbedtls_internal_ecp_deinit( const mbedtls_ecp_group *grp )
+ * The mbedtls_internal_ecp_grp_capable function should return 1 if the
+ * replacement functions implement arithmetic for the given group and 0
+ * otherwise.
+ * The functions mbedtls_internal_ecp_init and mbedtls_internal_ecp_deinit are
+ * called before and after each point operation and provide an opportunity to
+ * implement optimized set up and tear down instructions.
  *
- * The functions:
- *      int  mbedtls_ecp_alt_init( const mbedtls_ecp_group *grp )
- *      void mbedtls_ecp_alt_deinit( const mbedtls_ecp_group *grp )
- * can be enabled by MBEDTLS_ECP_INIT_ALT and MBEDTLS_ECP_DEINIT_ALT.
- * They are called before and after each point operation and provide an
- * opportunity to implement optimized set up and tear down instructions.
- *
- * Example: In case you uncomment MBEDTLS_ECP_FUNCTION_ALT and
+ * Example: In case you uncomment MBEDTLS_ECP_INTERNAL_ALT and
  * MBEDTLS_ECP_DOUBLE_JAC_ALT, mbed TLS will still provide the ecp_double_jac
- * function, but will use your mbedtls_ecp_double_jac_alt if the group is
- * supported (your mbedtls_ecp_alt_grp_capable function returns 1 when receives
- * it as an argument). If the group is not supported then the original
+ * function, but will use your mbedtls_internal_ecp_double_jac if the group is
+ * supported (your mbedtls_internal_ecp_grp_capable function returns 1 when
+ * receives it as an argument). If the group is not supported then the original
  * implementation is used. The other functions and the definition of
  * mbedtls_ecp_group and mbedtls_ecp_point will not change, so your
- * implementation of mbedtls_ecp_double_jac_alt and mbedtls_ecp_alt_grp_capable
- * must be compatible with this definition.
+ * implementation of mbedtls_internal_ecp_double_jac and
+ * mbedtls_internal_ecp_grp_capable must be compatible with this definition.
  *
  * Uncomment a macro to enable alternate implementation of the corresponding
  * function.
  */
 /* Required for all the functions in this section */
-//#define MBEDTLS_ECP_FUNCTION_ALT
-/* Utility functions for setup and cleanup */
-//#define MBEDTLS_ECP_INIT_ALT
-//#define MBEDTLS_ECP_DEINIT_ALT
+//#define MBEDTLS_ECP_INTERNAL_ALT
 /* Support for Weierstrass curves with Jacobi representation */
 //#define MBEDTLS_ECP_RANDOMIZE_JAC_ALT
 //#define MBEDTLS_ECP_ADD_MIXED_ALT
diff --git a/include/mbedtls/ecp.h b/include/mbedtls/ecp.h
index 2a43a7a..bf9abef 100644
--- a/include/mbedtls/ecp.h
+++ b/include/mbedtls/ecp.h
@@ -38,11 +38,13 @@
 #define MBEDTLS_ERR_ECP_SIG_LEN_MISMATCH                  -0x4C00  /**< Signature is valid but shorter than the user-supplied length. */
 
 #if !defined(MBEDTLS_ECP_ALT)
-// default mbed TLS elliptic curve arithmetic implementation
-//
-// (in case MBEDTLS_ECP_ALT is defined then the developer has to provide an
-// alternative implementation for the whole module and it will replace this
-// one.)
+/*
+ * default mbed TLS elliptic curve arithmetic implementation
+ *
+ * (in case MBEDTLS_ECP_ALT is defined then the developer has to provide an
+ * alternative implementation for the whole module and it will replace this
+ * one.)
+ */
 
 #ifdef __cplusplus
 extern "C" {
diff --git a/include/mbedtls/ecp_internal.h b/include/mbedtls/ecp_internal.h
index eda07ba..a9f5bc5 100644
--- a/include/mbedtls/ecp_internal.h
+++ b/include/mbedtls/ecp_internal.h
@@ -21,62 +21,62 @@
  *
  *  This file is part of mbed TLS (https://tls.mbed.org)
  */
-#ifndef MBEDTLS_ECP_FUNCTION_ALT_H
-#define MBEDTLS_ECP_FUNCTION_ALT_H
+#ifndef MBEDTLS_ECP_INTERNAL_H
+#define MBEDTLS_ECP_INTERNAL_H
 
-#if defined(MBEDTLS_ECP_FUNCTION_ALT)
+#if defined(MBEDTLS_ECP_INTERNAL_ALT)
 
-unsigned char mbedtls_int_ecp_grp_capable( const mbedtls_ecp_group *grp );
+unsigned char mbedtls_internal_ecp_grp_capable( const mbedtls_ecp_group *grp );
 
-int mbedtls_int_ecp_init( const mbedtls_ecp_group *grp );
+int mbedtls_internal_ecp_init( const mbedtls_ecp_group *grp );
 
-void mbedtls_int_ecp_deinit( const mbedtls_ecp_group *grp );
+void mbedtls_internal_ecp_free( const mbedtls_ecp_group *grp );
 
 #if defined(MBEDTLS_ECP_RANDOMIZE_JAC_ALT)
-int mbedtls_int_ecp_randomize_jac( const mbedtls_ecp_group *grp,
+int mbedtls_internal_ecp_randomize_jac( const mbedtls_ecp_group *grp,
         mbedtls_ecp_point *pt, int (*f_rng)(void *, unsigned char *, size_t),
         void *p_rng );
 #endif
 
 #if defined(MBEDTLS_ECP_ADD_MIXED_ALT)
-int mbedtls_int_ecp_add_mixed( const mbedtls_ecp_group *grp,
+int mbedtls_internal_ecp_add_mixed( const mbedtls_ecp_group *grp,
         mbedtls_ecp_point *R, const mbedtls_ecp_point *P,
         const mbedtls_ecp_point *Q );
 #endif
 
 #if defined(MBEDTLS_ECP_DOUBLE_JAC_ALT)
-int mbedtls_int_ecp_double_jac( const mbedtls_ecp_group *grp,
+int mbedtls_internal_ecp_double_jac( const mbedtls_ecp_group *grp,
         mbedtls_ecp_point *R, const mbedtls_ecp_point *P );
 #endif
 
 #if defined(MBEDTLS_ECP_NORMALIZE_JAC_MANY_ALT)
-int mbedtls_int_ecp_normalize_jac_many( const mbedtls_ecp_group *grp,
+int mbedtls_internal_ecp_normalize_jac_many( const mbedtls_ecp_group *grp,
         mbedtls_ecp_point *T[], size_t t_len );
 #endif
 
 #if defined(MBEDTLS_ECP_NORMALIZE_JAC_ALT)
-int mbedtls_int_ecp_normalize_jac( const mbedtls_ecp_group *grp,
+int mbedtls_internal_ecp_normalize_jac( const mbedtls_ecp_group *grp,
         mbedtls_ecp_point *pt );
 #endif
 
 #if defined(MBEDTLS_ECP_DOUBLE_ADD_MXZ_ALT)
-int mbedtls_int_ecp_double_add_mxz( const mbedtls_ecp_group *grp,
+int mbedtls_internal_ecp_double_add_mxz( const mbedtls_ecp_group *grp,
         mbedtls_ecp_point *R, mbedtls_ecp_point *S, const mbedtls_ecp_point *P,
         const mbedtls_ecp_point *Q, const mbedtls_mpi *d );
 #endif
 
 #if defined(MBEDTLS_ECP_RANDOMIZE_MXZ_ALT)
-int mbedtls_int_ecp_randomize_mxz( const mbedtls_ecp_group *grp,
+int mbedtls_internal_ecp_randomize_mxz( const mbedtls_ecp_group *grp,
         mbedtls_ecp_point *P, int (*f_rng)(void *, unsigned char *, size_t),
         void *p_rng );
 #endif
 
 #if defined(MBEDTLS_ECP_NORMALIZE_MXZ_ALT)
-int mbedtls_int_ecp_normalize_mxz( const mbedtls_ecp_group *grp,
+int mbedtls_internal_ecp_normalize_mxz( const mbedtls_ecp_group *grp,
         mbedtls_ecp_point *P );
 #endif
 
-#endif /* MBEDTLS_ECP_FUNCTION_ALT */
+#endif /* MBEDTLS_ECP_INTERNAL_ALT */
 
-#endif /* ecp_function_alt.h */
+#endif /* ecp_internal.h */
 
diff --git a/include/mbedtls/threading.h b/include/mbedtls/threading.h
index d2d79a1..a89fd64 100644
--- a/include/mbedtls/threading.h
+++ b/include/mbedtls/threading.h
@@ -97,8 +97,8 @@
  */
 extern mbedtls_threading_mutex_t mbedtls_threading_readdir_mutex;
 extern mbedtls_threading_mutex_t mbedtls_threading_gmtime_mutex;
-#if defined(MBEDTLS_ECP_FUNCTION_ALT)
-extern mbedtls_threading_mutex_t mbedtls_threading_cryptohw_asym_mutex;
+#if defined(MBEDTLS_ECP_INTERNAL_ALT)
+extern mbedtls_threading_mutex_t mbedtls_threading_ecp_mutex;
 #endif
 #endif /* MBEDTLS_THREADING_C */