PolarSSL v1.1.4
dhm.h
Go to the documentation of this file.
1 
27 #ifndef POLARSSL_DHM_H
28 #define POLARSSL_DHM_H
29 
30 #include "bignum.h"
31 
32 /*
33  * DHM Error codes
34  */
35 #define POLARSSL_ERR_DHM_BAD_INPUT_DATA -0x3080
36 #define POLARSSL_ERR_DHM_READ_PARAMS_FAILED -0x3100
37 #define POLARSSL_ERR_DHM_MAKE_PARAMS_FAILED -0x3180
38 #define POLARSSL_ERR_DHM_READ_PUBLIC_FAILED -0x3200
39 #define POLARSSL_ERR_DHM_MAKE_PUBLIC_FAILED -0x3280
40 #define POLARSSL_ERR_DHM_CALC_SECRET_FAILED -0x3300
45 typedef struct
46 {
47  size_t len;
48  mpi P;
49  mpi G;
50  mpi X;
51  mpi GX;
52  mpi GY;
53  mpi K;
54  mpi RP;
55 }
57 
58 #ifdef __cplusplus
59 extern "C" {
60 #endif
61 
72  unsigned char **p,
73  const unsigned char *end );
74 
91 int dhm_make_params( dhm_context *ctx, int x_size,
92  unsigned char *output, size_t *olen,
93  int (*f_rng)(void *, unsigned char *, size_t),
94  void *p_rng );
95 
105 int dhm_read_public( dhm_context *ctx,
106  const unsigned char *input, size_t ilen );
107 
120 int dhm_make_public( dhm_context *ctx, int x_size,
121  unsigned char *output, size_t olen,
122  int (*f_rng)(void *, unsigned char *, size_t),
123  void *p_rng );
124 
134 int dhm_calc_secret( dhm_context *ctx,
135  unsigned char *output, size_t *olen );
136 
137 /*
138  * \brief Free the components of a DHM key
139  */
140 void dhm_free( dhm_context *ctx );
141 
147 int dhm_self_test( int verbose );
148 
149 #ifdef __cplusplus
150 }
151 #endif
152 
153 #endif