00001 00027 #ifndef POLARSSL_ECDH_H 00028 #define POLARSSL_ECDH_H 00029 00030 #include "ecp.h" 00031 00032 #ifdef __cplusplus 00033 extern "C" { 00034 #endif 00035 00039 typedef struct 00040 { 00041 ecp_group grp; 00042 mpi d; 00043 ecp_point Q; 00044 ecp_point Qp; 00045 mpi z; 00046 int point_format; 00047 ecp_point Vi; 00048 ecp_point Vf; 00049 mpi _d; 00050 } 00051 ecdh_context; 00052 00065 int ecdh_gen_public( ecp_group *grp, mpi *d, ecp_point *Q, 00066 int (*f_rng)(void *, unsigned char *, size_t), 00067 void *p_rng ); 00068 00086 int ecdh_compute_shared( ecp_group *grp, mpi *z, 00087 const ecp_point *Q, const mpi *d, 00088 int (*f_rng)(void *, unsigned char *, size_t), 00089 void *p_rng ); 00090 00096 void ecdh_init( ecdh_context *ctx ); 00097 00103 void ecdh_free( ecdh_context *ctx ); 00104 00120 int ecdh_make_params( ecdh_context *ctx, size_t *olen, 00121 unsigned char *buf, size_t blen, 00122 int (*f_rng)(void *, unsigned char *, size_t), 00123 void *p_rng ); 00124 00134 int ecdh_read_params( ecdh_context *ctx, 00135 const unsigned char **buf, const unsigned char *end ); 00136 00149 int ecdh_make_public( ecdh_context *ctx, size_t *olen, 00150 unsigned char *buf, size_t blen, 00151 int (*f_rng)(void *, unsigned char *, size_t), 00152 void *p_rng ); 00153 00163 int ecdh_read_public( ecdh_context *ctx, 00164 const unsigned char *buf, size_t blen ); 00165 00178 int ecdh_calc_secret( ecdh_context *ctx, size_t *olen, 00179 unsigned char *buf, size_t blen, 00180 int (*f_rng)(void *, unsigned char *, size_t), 00181 void *p_rng ); 00182 00188 int ecdh_self_test( int verbose ); 00189 00190 #ifdef __cplusplus 00191 } 00192 #endif 00193 00194 #endif