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
00059
00060 #ifndef MBEDTLS_ECDH_H
00061 #define MBEDTLS_ECDH_H
00062
00063 #if !defined(MBEDTLS_CONFIG_FILE)
00064 #include "config.h"
00065 #else
00066 #include MBEDTLS_CONFIG_FILE
00067 #endif
00068
00069 #include "ecp.h"
00070
00071 #ifdef __cplusplus
00072 extern "C" {
00073 #endif
00074
00080 typedef enum
00081 {
00082 MBEDTLS_ECDH_OURS,
00083 MBEDTLS_ECDH_THEIRS,
00084 } mbedtls_ecdh_side;
00085
00089 typedef struct
00090 {
00091 mbedtls_ecp_group grp;
00092 mbedtls_mpi d;
00093 mbedtls_ecp_point Q;
00094 mbedtls_ecp_point Qp;
00095 mbedtls_mpi z;
00096 int point_format;
00097 mbedtls_ecp_point Vi;
00098 mbedtls_ecp_point Vf;
00099 mbedtls_mpi _d;
00100 }
00101 mbedtls_ecdh_context;
00102
00122 int mbedtls_ecdh_gen_public( mbedtls_ecp_group *grp, mbedtls_mpi *d, mbedtls_ecp_point *Q,
00123 int (*f_rng)(void *, unsigned char *, size_t),
00124 void *p_rng );
00125
00149 int mbedtls_ecdh_compute_shared( mbedtls_ecp_group *grp, mbedtls_mpi *z,
00150 const mbedtls_ecp_point *Q, const mbedtls_mpi *d,
00151 int (*f_rng)(void *, unsigned char *, size_t),
00152 void *p_rng );
00153
00159 void mbedtls_ecdh_init( mbedtls_ecdh_context *ctx );
00160
00166 void mbedtls_ecdh_free( mbedtls_ecdh_context *ctx );
00167
00191 int mbedtls_ecdh_make_params( mbedtls_ecdh_context *ctx, size_t *olen,
00192 unsigned char *buf, size_t blen,
00193 int (*f_rng)(void *, unsigned char *, size_t),
00194 void *p_rng );
00195
00212 int mbedtls_ecdh_read_params( mbedtls_ecdh_context *ctx,
00213 const unsigned char **buf, const unsigned char *end );
00214
00233 int mbedtls_ecdh_get_params( mbedtls_ecdh_context *ctx, const mbedtls_ecp_keypair *key,
00234 mbedtls_ecdh_side side );
00235
00255 int mbedtls_ecdh_make_public( mbedtls_ecdh_context *ctx, size_t *olen,
00256 unsigned char *buf, size_t blen,
00257 int (*f_rng)(void *, unsigned char *, size_t),
00258 void *p_rng );
00259
00276 int mbedtls_ecdh_read_public( mbedtls_ecdh_context *ctx,
00277 const unsigned char *buf, size_t blen );
00278
00301 int mbedtls_ecdh_calc_secret( mbedtls_ecdh_context *ctx, size_t *olen,
00302 unsigned char *buf, size_t blen,
00303 int (*f_rng)(void *, unsigned char *, size_t),
00304 void *p_rng );
00305
00306 #ifdef __cplusplus
00307 }
00308 #endif
00309
00310 #endif