Add ECDH primitives
diff --git a/include/polarssl/ecdh.h b/include/polarssl/ecdh.h
index 5c9be45..ad13106 100644
--- a/include/polarssl/ecdh.h
+++ b/include/polarssl/ecdh.h
@@ -33,9 +33,35 @@
extern "C" {
#endif
-#ifdef __cplusplus
-}
-#endif
+/**
+ * \brief Generate a public key
+ *
+ * \param grp ECP group
+ * \param d Destination MPI (secret exponent)
+ * \param Q Destination point (public key)
+ * \param f_rng RNG function
+ * \param p_rng RNG parameter
+ *
+ * \return 0 if successful,
+ * or a POLARSSL_ERR_ECP_XXX or POLARSSL_MPI_XXX error code
+ */
+int ecdh_gen_public( const ecp_group *grp, mpi *d, ecp_point *Q,
+ int (*f_rng)(void *, unsigned char *, size_t),
+ void *p_rng );
+
+/**
+ * \brief Compute shared secret
+ *
+ * \param grp ECP group
+ * \param z Destination MPI (shared secret)
+ * \param Q Public key from other party
+ * \param d Our secret exponent
+ *
+ * \return 0 if successful,
+ * or a POLARSSL_ERR_ECP_XXX or POLARSSL_MPI_XXX error code
+ */
+int ecdh_compute_shared( const ecp_group *grp, mpi *z,
+ const ecp_point *Q, const mpi *d );
/**
* \brief Checkup routine
@@ -44,4 +70,8 @@
*/
int ecdh_self_test( int verbose );
+#ifdef __cplusplus
+}
+#endif
+
#endif
diff --git a/include/polarssl/ecp.h b/include/polarssl/ecp.h
index e1b0995..b8b1997 100644
--- a/include/polarssl/ecp.h
+++ b/include/polarssl/ecp.h
@@ -147,12 +147,23 @@
/**
* \brief Set a point to zero
*
+ * \param pt Destination point
+ *
* \return 0 if successful,
* POLARSSL_ERR_MPI_MALLOC_FAILED if memory allocation failed
*/
int ecp_set_zero( ecp_point *pt );
/**
+ * \brief Tell if a point is zero
+ *
+ * \param pt Point to test
+ *
+ * \return 1 if point is zero, 0 otherwise
+ */
+int ecp_is_zero( ecp_point *pt );
+
+/**
* \brief Copy the contents of point Q into P
*
* \param P Destination point