00001
00023 #ifndef MBEDTLS_ECJPAKE_H
00024 #define MBEDTLS_ECJPAKE_H
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042
00043 #include "ecp.h"
00044 #include "md.h"
00045
00046 #ifdef __cplusplus
00047 extern "C" {
00048 #endif
00049
00053 typedef enum {
00054 MBEDTLS_ECJPAKE_CLIENT = 0,
00055 MBEDTLS_ECJPAKE_SERVER,
00056 } mbedtls_ecjpake_role;
00057
00069 typedef struct
00070 {
00071 const mbedtls_md_info_t *md_info;
00072 mbedtls_ecp_group grp;
00073 mbedtls_ecjpake_role role;
00074 int point_format;
00076 mbedtls_ecp_point Xm1;
00077 mbedtls_ecp_point Xm2;
00078 mbedtls_ecp_point Xp1;
00079 mbedtls_ecp_point Xp2;
00080 mbedtls_ecp_point Xp;
00082 mbedtls_mpi xm1;
00083 mbedtls_mpi xm2;
00085 mbedtls_mpi s;
00086 } mbedtls_ecjpake_context;
00087
00094 void mbedtls_ecjpake_init( mbedtls_ecjpake_context *ctx );
00095
00112 int mbedtls_ecjpake_setup( mbedtls_ecjpake_context *ctx,
00113 mbedtls_ecjpake_role role,
00114 mbedtls_md_type_t hash,
00115 mbedtls_ecp_group_id curve,
00116 const unsigned char *secret,
00117 size_t len );
00118
00119
00120
00121
00122
00123
00124
00125
00126
00127 int mbedtls_ecjpake_check( const mbedtls_ecjpake_context *ctx );
00128
00144 int mbedtls_ecjpake_write_round_one( mbedtls_ecjpake_context *ctx,
00145 unsigned char *buf, size_t len, size_t *olen,
00146 int (*f_rng)(void *, unsigned char *, size_t),
00147 void *p_rng );
00148
00161 int mbedtls_ecjpake_read_round_one( mbedtls_ecjpake_context *ctx,
00162 const unsigned char *buf,
00163 size_t len );
00164
00179 int mbedtls_ecjpake_write_round_two( mbedtls_ecjpake_context *ctx,
00180 unsigned char *buf, size_t len, size_t *olen,
00181 int (*f_rng)(void *, unsigned char *, size_t),
00182 void *p_rng );
00183
00195 int mbedtls_ecjpake_read_round_two( mbedtls_ecjpake_context *ctx,
00196 const unsigned char *buf,
00197 size_t len );
00198
00213 int mbedtls_ecjpake_derive_secret( mbedtls_ecjpake_context *ctx,
00214 unsigned char *buf, size_t len, size_t *olen,
00215 int (*f_rng)(void *, unsigned char *, size_t),
00216 void *p_rng );
00217
00223 void mbedtls_ecjpake_free( mbedtls_ecjpake_context *ctx );
00224
00225 #if defined(MBEDTLS_SELF_TEST)
00226
00231 int mbedtls_ecjpake_self_test( int verbose );
00232 #endif
00233
00234 #ifdef __cplusplus
00235 }
00236 #endif
00237
00238 #endif