PolarSSL v1.3.4
ecdh.h
Go to the documentation of this file.
1 
27 #ifndef POLARSSL_ECDH_H
28 #define POLARSSL_ECDH_H
29 
30 #include "ecp.h"
31 
32 #ifdef __cplusplus
33 extern "C" {
34 #endif
35 
39 typedef enum
40 {
43 } ecdh_side;
44 
48 typedef struct
49 {
51  mpi d;
54  mpi z;
58  mpi _d;
59 }
61 
74 int ecdh_gen_public( ecp_group *grp, mpi *d, ecp_point *Q,
75  int (*f_rng)(void *, unsigned char *, size_t),
76  void *p_rng );
77 
95 int ecdh_compute_shared( ecp_group *grp, mpi *z,
96  const ecp_point *Q, const mpi *d,
97  int (*f_rng)(void *, unsigned char *, size_t),
98  void *p_rng );
99 
105 void ecdh_init( ecdh_context *ctx );
106 
112 void ecdh_free( ecdh_context *ctx );
113 
129 int ecdh_make_params( ecdh_context *ctx, size_t *olen,
130  unsigned char *buf, size_t blen,
131  int (*f_rng)(void *, unsigned char *, size_t),
132  void *p_rng );
133 
144  const unsigned char **buf, const unsigned char *end );
145 
155 int ecdh_get_params( ecdh_context *ctx, const ecp_keypair *key,
156  ecdh_side side );
157 
170 int ecdh_make_public( ecdh_context *ctx, size_t *olen,
171  unsigned char *buf, size_t blen,
172  int (*f_rng)(void *, unsigned char *, size_t),
173  void *p_rng );
174 
185  const unsigned char *buf, size_t blen );
186 
199 int ecdh_calc_secret( ecdh_context *ctx, size_t *olen,
200  unsigned char *buf, size_t blen,
201  int (*f_rng)(void *, unsigned char *, size_t),
202  void *p_rng );
203 
209 int ecdh_self_test( int verbose );
210 
211 #ifdef __cplusplus
212 }
213 #endif
214 
215 #endif
int ecdh_make_params(ecdh_context *ctx, size_t *olen, unsigned char *buf, size_t blen, int(*f_rng)(void *, unsigned char *, size_t), void *p_rng)
Setup and write the ServerKeyExhange parameters.
int ecdh_make_public(ecdh_context *ctx, size_t *olen, unsigned char *buf, size_t blen, int(*f_rng)(void *, unsigned char *, size_t), void *p_rng)
Setup and export the client's public value.
int ecdh_calc_secret(ecdh_context *ctx, size_t *olen, unsigned char *buf, size_t blen, int(*f_rng)(void *, unsigned char *, size_t), void *p_rng)
Derive and export the shared secret.
Elliptic curves over GF(p)
int ecdh_read_public(ecdh_context *ctx, const unsigned char *buf, size_t blen)
Parse and import the client's public value.
ecp_point Vf
Definition: ecdh.h:57
int ecdh_compute_shared(ecp_group *grp, mpi *z, const ecp_point *Q, const mpi *d, int(*f_rng)(void *, unsigned char *, size_t), void *p_rng)
Compute shared secret.
int ecdh_gen_public(ecp_group *grp, mpi *d, ecp_point *Q, int(*f_rng)(void *, unsigned char *, size_t), void *p_rng)
Generate a public key.
mpi _d
Definition: ecdh.h:58
ECP group structure.
Definition: ecp.h:132
int ecdh_get_params(ecdh_context *ctx, const ecp_keypair *key, ecdh_side side)
Setup an ECDH context from an EC key.
ECP key pair structure.
Definition: ecp.h:159
MPI structure.
Definition: bignum.h:177
mpi d
Definition: ecdh.h:51
ecp_point Qp
Definition: ecdh.h:53
ECP point structure (jacobian coordinates)
Definition: ecp.h:103
int point_format
Definition: ecdh.h:55
ecdh_side
When importing from an EC key, select if it is our key or the peer's key.
Definition: ecdh.h:39
mpi z
Definition: ecdh.h:54
int ecdh_read_params(ecdh_context *ctx, const unsigned char **buf, const unsigned char *end)
Parse the ServerKeyExhange parameters.
ECDH context structure.
Definition: ecdh.h:48
void ecdh_init(ecdh_context *ctx)
Initialize context.
ecp_point Vi
Definition: ecdh.h:56
int ecdh_self_test(int verbose)
Checkup routine.
void ecdh_free(ecdh_context *ctx)
Free context.
ecp_group grp
Definition: ecdh.h:50
ecp_point Q
Definition: ecdh.h:52