mbed TLS v1.3.17
ecdh.h
Go to the documentation of this file.
1 
24 #ifndef POLARSSL_ECDH_H
25 #define POLARSSL_ECDH_H
26 
27 #include "ecp.h"
28 
29 #ifdef __cplusplus
30 extern "C" {
31 #endif
32 
36 typedef enum
37 {
40 } ecdh_side;
41 
45 typedef struct
46 {
48  mpi d;
51  mpi z;
55  mpi _d;
56 }
58 
72 int ecdh_gen_public( ecp_group *grp, mpi *d, ecp_point *Q,
73  int (*f_rng)(void *, unsigned char *, size_t),
74  void *p_rng );
75 
94 int ecdh_compute_shared( ecp_group *grp, mpi *z,
95  const ecp_point *Q, const mpi *d,
96  int (*f_rng)(void *, unsigned char *, size_t),
97  void *p_rng );
98 
104 void ecdh_init( ecdh_context *ctx );
105 
111 void ecdh_free( ecdh_context *ctx );
112 
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 
145  const unsigned char **buf, const unsigned char *end );
146 
159 int ecdh_get_params( ecdh_context *ctx, const ecp_keypair *key,
160  ecdh_side side );
161 
175 int ecdh_make_public( ecdh_context *ctx, size_t *olen,
176  unsigned char *buf, size_t blen,
177  int (*f_rng)(void *, unsigned char *, size_t),
178  void *p_rng );
179 
191  const unsigned char *buf, size_t blen );
192 
206 int ecdh_calc_secret( ecdh_context *ctx, size_t *olen,
207  unsigned char *buf, size_t blen,
208  int (*f_rng)(void *, unsigned char *, size_t),
209  void *p_rng );
210 
216 int ecdh_self_test( int verbose );
217 
218 #ifdef __cplusplus
219 }
220 #endif
221 
222 #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:54
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:55
ECP group structure.
Definition: ecp.h:133
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:160
MPI structure.
Definition: bignum.h:183
mpi d
Definition: ecdh.h:48
ecp_point Qp
Definition: ecdh.h:50
ECP point structure (jacobian coordinates)
Definition: ecp.h:101
int point_format
Definition: ecdh.h:52
ecdh_side
When importing from an EC key, select if it is our key or the peer's key.
Definition: ecdh.h:36
mpi z
Definition: ecdh.h:51
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:45
void ecdh_init(ecdh_context *ctx)
Initialize context.
ecp_point Vi
Definition: ecdh.h:53
int ecdh_self_test(int verbose)
Checkup routine.
void ecdh_free(ecdh_context *ctx)
Free context.
ecp_group grp
Definition: ecdh.h:47
ecp_point Q
Definition: ecdh.h:49