PolarSSL v1.1.4
dhm.h
Go to the documentation of this file.
00001 
00027 #ifndef POLARSSL_DHM_H
00028 #define POLARSSL_DHM_H
00029 
00030 #include "bignum.h"
00031 
00032 /*
00033  * DHM Error codes
00034  */
00035 #define POLARSSL_ERR_DHM_BAD_INPUT_DATA                    -0x3080  
00036 #define POLARSSL_ERR_DHM_READ_PARAMS_FAILED                -0x3100  
00037 #define POLARSSL_ERR_DHM_MAKE_PARAMS_FAILED                -0x3180  
00038 #define POLARSSL_ERR_DHM_READ_PUBLIC_FAILED                -0x3200  
00039 #define POLARSSL_ERR_DHM_MAKE_PUBLIC_FAILED                -0x3280  
00040 #define POLARSSL_ERR_DHM_CALC_SECRET_FAILED                -0x3300  
00045 typedef struct
00046 {
00047     size_t len; 
00048     mpi P;      
00049     mpi G;      
00050     mpi X;      
00051     mpi GX;     
00052     mpi GY;     
00053     mpi K;      
00054     mpi RP;     
00055 }
00056 dhm_context;
00057 
00058 #ifdef __cplusplus
00059 extern "C" {
00060 #endif
00061 
00071 int dhm_read_params( dhm_context *ctx,
00072                      unsigned char **p,
00073                      const unsigned char *end );
00074 
00091 int dhm_make_params( dhm_context *ctx, int x_size,
00092                      unsigned char *output, size_t *olen,
00093                      int (*f_rng)(void *, unsigned char *, size_t),
00094                      void *p_rng );
00095 
00105 int dhm_read_public( dhm_context *ctx,
00106                      const unsigned char *input, size_t ilen );
00107 
00120 int dhm_make_public( dhm_context *ctx, int x_size,
00121                      unsigned char *output, size_t olen,
00122                      int (*f_rng)(void *, unsigned char *, size_t),
00123                      void *p_rng );
00124 
00134 int dhm_calc_secret( dhm_context *ctx,
00135                      unsigned char *output, size_t *olen );
00136 
00137 /*
00138  * \brief          Free the components of a DHM key
00139  */
00140 void dhm_free( dhm_context *ctx );
00141 
00147 int dhm_self_test( int verbose );
00148 
00149 #ifdef __cplusplus
00150 }
00151 #endif
00152 
00153 #endif