PolarSSL v1.3.9
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 
75 int ecdh_gen_public( ecp_group *grp, mpi *d, ecp_point *Q,
76  int (*f_rng)(void *, unsigned char *, size_t),
77  void *p_rng );
78 
97 int ecdh_compute_shared( ecp_group *grp, mpi *z,
98  const ecp_point *Q, const mpi *d,
99  int (*f_rng)(void *, unsigned char *, size_t),
100  void *p_rng );
101 
107 void ecdh_init( ecdh_context *ctx );
108 
114 void ecdh_free( ecdh_context *ctx );
115 
132 int ecdh_make_params( ecdh_context *ctx, size_t *olen,
133  unsigned char *buf, size_t blen,
134  int (*f_rng)(void *, unsigned char *, size_t),
135  void *p_rng );
136 
148  const unsigned char **buf, const unsigned char *end );
149 
162 int ecdh_get_params( ecdh_context *ctx, const ecp_keypair *key,
163  ecdh_side side );
164 
178 int ecdh_make_public( ecdh_context *ctx, size_t *olen,
179  unsigned char *buf, size_t blen,
180  int (*f_rng)(void *, unsigned char *, size_t),
181  void *p_rng );
182 
194  const unsigned char *buf, size_t blen );
195 
209 int ecdh_calc_secret( ecdh_context *ctx, size_t *olen,
210  unsigned char *buf, size_t blen,
211  int (*f_rng)(void *, unsigned char *, size_t),
212  void *p_rng );
213 
219 int ecdh_self_test( int verbose );
220 
221 #ifdef __cplusplus
222 }
223 #endif
224 
225 #endif /* ecdh.h */
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)
Generate a public key and a TLS ServerKeyExchange payload.
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)
Generate a public key and a TLS ClientKeyExchange payload.
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 process a TLS ClientKeyExchange payload.
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 Raw function that only does the core computation.
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:136
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:163
MPI structure.
Definition: bignum.h:182
mpi d
Definition: ecdh.h:51
ecp_point Qp
Definition: ecdh.h:53
ECP point structure (jacobian coordinates)
Definition: ecp.h:104
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 and procress a TLS ServerKeyExhange payload.
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