PolarSSL
|
00001 00025 #ifndef POLARSSL_DHM_H 00026 #define POLARSSL_DHM_H 00027 00028 #include "polarssl/bignum.h" 00029 00030 #define POLARSSL_ERR_DHM_BAD_INPUT_DATA 0x0480 00031 #define POLARSSL_ERR_DHM_READ_PARAMS_FAILED 0x0490 00032 #define POLARSSL_ERR_DHM_MAKE_PARAMS_FAILED 0x04A0 00033 #define POLARSSL_ERR_DHM_READ_PUBLIC_FAILED 0x04B0 00034 #define POLARSSL_ERR_DHM_MAKE_PUBLIC_FAILED 0x04C0 00035 #define POLARSSL_ERR_DHM_CALC_SECRET_FAILED 0x04D0 00036 00037 typedef struct 00038 { 00039 int len; 00040 mpi P; 00041 mpi G; 00042 mpi X; 00043 mpi GX; 00044 mpi GY; 00045 mpi K; 00046 mpi RP; 00047 } 00048 dhm_context; 00049 00050 #ifdef __cplusplus 00051 extern "C" { 00052 #endif 00053 00063 int dhm_read_params( dhm_context *ctx, 00064 unsigned char **p, 00065 const unsigned char *end ); 00066 00083 int dhm_make_params( dhm_context *ctx, int x_size, 00084 unsigned char *output, int *olen, 00085 int (*f_rng)(void *), void *p_rng ); 00086 00096 int dhm_read_public( dhm_context *ctx, 00097 const unsigned char *input, int ilen ); 00098 00111 int dhm_make_public( dhm_context *ctx, int s_size, 00112 unsigned char *output, int olen, 00113 int (*f_rng)(void *), void *p_rng ); 00114 00124 int dhm_calc_secret( dhm_context *ctx, 00125 unsigned char *output, int *olen ); 00126 00127 /* 00128 * \brief Free the components of a DHM key 00129 */ 00130 void dhm_free( dhm_context *ctx ); 00131 00137 int dhm_self_test( int verbose ); 00138 00139 #ifdef __cplusplus 00140 } 00141 #endif 00142 00143 #endif