00001
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042
00043
00044
00045
00046
00047
00048
00049
00050
00051
00052
00053
00054
00055
00056
00057
00058 #ifndef MBEDTLS_ECDH_H
00059 #define MBEDTLS_ECDH_H
00060
00061 #if !defined(MBEDTLS_CONFIG_FILE)
00062 #include "config.h"
00063 #else
00064 #include MBEDTLS_CONFIG_FILE
00065 #endif
00066
00067 #include "ecp.h"
00068
00069 #ifdef __cplusplus
00070 extern "C" {
00071 #endif
00072
00078 typedef enum
00079 {
00080 MBEDTLS_ECDH_OURS,
00081 MBEDTLS_ECDH_THEIRS,
00082 } mbedtls_ecdh_side;
00083
00087 typedef struct
00088 {
00089 mbedtls_ecp_group grp;
00090 mbedtls_mpi d;
00091 mbedtls_ecp_point Q;
00092 mbedtls_ecp_point Qp;
00093 mbedtls_mpi z;
00094 int point_format;
00095 mbedtls_ecp_point Vi;
00096 mbedtls_ecp_point Vf;
00097 mbedtls_mpi _d;
00098 }
00099 mbedtls_ecdh_context;
00100
00120 int mbedtls_ecdh_gen_public( mbedtls_ecp_group *grp, mbedtls_mpi *d, mbedtls_ecp_point *Q,
00121 int (*f_rng)(void *, unsigned char *, size_t),
00122 void *p_rng );
00123
00147 int mbedtls_ecdh_compute_shared( mbedtls_ecp_group *grp, mbedtls_mpi *z,
00148 const mbedtls_ecp_point *Q, const mbedtls_mpi *d,
00149 int (*f_rng)(void *, unsigned char *, size_t),
00150 void *p_rng );
00151
00157 void mbedtls_ecdh_init( mbedtls_ecdh_context *ctx );
00158
00164 void mbedtls_ecdh_free( mbedtls_ecdh_context *ctx );
00165
00189 int mbedtls_ecdh_make_params( mbedtls_ecdh_context *ctx, size_t *olen,
00190 unsigned char *buf, size_t blen,
00191 int (*f_rng)(void *, unsigned char *, size_t),
00192 void *p_rng );
00193
00210 int mbedtls_ecdh_read_params( mbedtls_ecdh_context *ctx,
00211 const unsigned char **buf, const unsigned char *end );
00212
00231 int mbedtls_ecdh_get_params( mbedtls_ecdh_context *ctx, const mbedtls_ecp_keypair *key,
00232 mbedtls_ecdh_side side );
00233
00253 int mbedtls_ecdh_make_public( mbedtls_ecdh_context *ctx, size_t *olen,
00254 unsigned char *buf, size_t blen,
00255 int (*f_rng)(void *, unsigned char *, size_t),
00256 void *p_rng );
00257
00274 int mbedtls_ecdh_read_public( mbedtls_ecdh_context *ctx,
00275 const unsigned char *buf, size_t blen );
00276
00299 int mbedtls_ecdh_calc_secret( mbedtls_ecdh_context *ctx, size_t *olen,
00300 unsigned char *buf, size_t blen,
00301 int (*f_rng)(void *, unsigned char *, size_t),
00302 void *p_rng );
00303
00304 #ifdef __cplusplus
00305 }
00306 #endif
00307
00308 #endif