1
0
mirror of https://github.com/Mbed-TLS/mbedtls.git synced 2025-07-30 22:43:08 +03:00

Add ECDH primitives

This commit is contained in:
Manuel Pégourié-Gonnard
2013-01-26 16:05:22 +01:00
parent 0bad5c2381
commit 6545ca7bed
4 changed files with 91 additions and 3 deletions

View File

@ -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 @@ extern "C" {
*/
int ecdh_self_test( int verbose );
#ifdef __cplusplus
}
#endif
#endif