00001
00004 #ifndef XYSSL_DHM_H
00005 #define XYSSL_DHM_H
00006
00007 #include "bignum.h"
00008
00009 #define XYSSL_ERR_DHM_BAD_INPUT_DATA -0x0480
00010 #define XYSSL_ERR_DHM_READ_PARAMS_FAILED -0x0490
00011 #define XYSSL_ERR_DHM_MAKE_PARAMS_FAILED -0x04A0
00012 #define XYSSL_ERR_DHM_READ_PUBLIC_FAILED -0x04B0
00013 #define XYSSL_ERR_DHM_MAKE_PUBLIC_FAILED -0x04C0
00014 #define XYSSL_ERR_DHM_CALC_SECRET_FAILED -0x04D0
00015
00016 typedef struct
00017 {
00018 int len;
00019 mpi P;
00020 mpi G;
00021 mpi X;
00022 mpi GX;
00023 mpi GY;
00024 mpi K;
00025 mpi RP;
00026 }
00027 dhm_context;
00028
00029 #ifdef __cplusplus
00030 extern "C" {
00031 #endif
00032
00042 int dhm_read_params( dhm_context *ctx,
00043 unsigned char **p,
00044 unsigned char *end );
00045
00062 int dhm_make_params( dhm_context *ctx, int s_size,
00063 unsigned char *output, int *olen,
00064 int (*f_rng)(void *), void *p_rng );
00065
00075 int dhm_read_public( dhm_context *ctx,
00076 unsigned char *input, int ilen );
00077
00090 int dhm_make_public( dhm_context *ctx, int s_size,
00091 unsigned char *output, int olen,
00092 int (*f_rng)(void *), void *p_rng );
00093
00103 int dhm_calc_secret( dhm_context *ctx,
00104 unsigned char *output, int *olen );
00105
00106
00107
00108
00109 void dhm_free( dhm_context *ctx );
00110
00116 int dhm_self_test( int verbose );
00117
00118 #ifdef __cplusplus
00119 }
00120 #endif
00121
00122 #endif