00001
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024 #ifndef MBEDTLS_ECJPAKE_H
00025 #define MBEDTLS_ECJPAKE_H
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042
00043
00044 #include "ecp.h"
00045 #include "md.h"
00046
00047 #if !defined(MBEDTLS_ECJPAKE_ALT)
00048
00049 #ifdef __cplusplus
00050 extern "C" {
00051 #endif
00052
00056 typedef enum {
00057 MBEDTLS_ECJPAKE_CLIENT = 0,
00058 MBEDTLS_ECJPAKE_SERVER,
00059 } mbedtls_ecjpake_role;
00060
00072 typedef struct
00073 {
00074 const mbedtls_md_info_t *md_info;
00075 mbedtls_ecp_group grp;
00076 mbedtls_ecjpake_role role;
00077 int point_format;
00079 mbedtls_ecp_point Xm1;
00080 mbedtls_ecp_point Xm2;
00081 mbedtls_ecp_point Xp1;
00082 mbedtls_ecp_point Xp2;
00083 mbedtls_ecp_point Xp;
00085 mbedtls_mpi xm1;
00086 mbedtls_mpi xm2;
00088 mbedtls_mpi s;
00089 } mbedtls_ecjpake_context;
00090
00097 void mbedtls_ecjpake_init( mbedtls_ecjpake_context *ctx );
00098
00115 int mbedtls_ecjpake_setup( mbedtls_ecjpake_context *ctx,
00116 mbedtls_ecjpake_role role,
00117 mbedtls_md_type_t hash,
00118 mbedtls_ecp_group_id curve,
00119 const unsigned char *secret,
00120 size_t len );
00121
00130 int mbedtls_ecjpake_check( const mbedtls_ecjpake_context *ctx );
00131
00147 int mbedtls_ecjpake_write_round_one( mbedtls_ecjpake_context *ctx,
00148 unsigned char *buf, size_t len, size_t *olen,
00149 int (*f_rng)(void *, unsigned char *, size_t),
00150 void *p_rng );
00151
00164 int mbedtls_ecjpake_read_round_one( mbedtls_ecjpake_context *ctx,
00165 const unsigned char *buf,
00166 size_t len );
00167
00182 int mbedtls_ecjpake_write_round_two( mbedtls_ecjpake_context *ctx,
00183 unsigned char *buf, size_t len, size_t *olen,
00184 int (*f_rng)(void *, unsigned char *, size_t),
00185 void *p_rng );
00186
00198 int mbedtls_ecjpake_read_round_two( mbedtls_ecjpake_context *ctx,
00199 const unsigned char *buf,
00200 size_t len );
00201
00216 int mbedtls_ecjpake_derive_secret( mbedtls_ecjpake_context *ctx,
00217 unsigned char *buf, size_t len, size_t *olen,
00218 int (*f_rng)(void *, unsigned char *, size_t),
00219 void *p_rng );
00220
00226 void mbedtls_ecjpake_free( mbedtls_ecjpake_context *ctx );
00227
00228 #ifdef __cplusplus
00229 }
00230 #endif
00231
00232 #else
00233 #include "ecjpake_alt.h"
00234 #endif
00235
00236 #if defined(MBEDTLS_SELF_TEST)
00237
00238 #ifdef __cplusplus
00239 extern "C" {
00240 #endif
00241
00247 int mbedtls_ecjpake_self_test( int verbose );
00248
00249 #ifdef __cplusplus
00250 }
00251 #endif
00252
00253 #endif
00254
00255 #endif