32 #ifndef MBEDTLS_ECDH_H
33 #define MBEDTLS_ECDH_H
53 #if defined(MBEDTLS_ECP_RESTARTABLE)
54 #define MBEDTLS_ECDH_LEGACY_CONTEXT
56 #undef MBEDTLS_ECDH_LEGACY_CONTEXT
59 #if defined(MBEDTLS_ECDH_VARIANT_EVEREST_ENABLED)
60 #undef MBEDTLS_ECDH_LEGACY_CONTEXT
61 #include "everest/everest.h"
77 #if !defined(MBEDTLS_ECDH_LEGACY_CONTEXT)
86 MBEDTLS_ECDH_VARIANT_NONE = 0,
87 MBEDTLS_ECDH_VARIANT_MBEDTLS_2_0,
88 #if defined(MBEDTLS_ECDH_VARIANT_EVEREST_ENABLED)
89 MBEDTLS_ECDH_VARIANT_EVEREST
91 } mbedtls_ecdh_variant;
100 typedef struct mbedtls_ecdh_context_mbed
107 #if defined(MBEDTLS_ECP_RESTARTABLE)
110 } mbedtls_ecdh_context_mbed;
122 #if defined(MBEDTLS_ECDH_LEGACY_CONTEXT)
132 #if defined(MBEDTLS_ECP_RESTARTABLE)
144 #if defined(MBEDTLS_ECDH_VARIANT_EVEREST_ENABLED)
150 #if defined(MBEDTLS_ECP_RESTARTABLE)
196 int (*f_rng)(
void *,
unsigned char *,
size_t),
232 int (*f_rng)(
void *,
unsigned char *,
size_t),
296 unsigned char *buf,
size_t blen,
297 int (*f_rng)(
void *,
unsigned char *,
size_t),
325 const unsigned char **buf,
326 const unsigned char *end );
378 unsigned char *buf,
size_t blen,
379 int (*f_rng)(
void *,
unsigned char *,
size_t),
402 const unsigned char *buf,
size_t blen );
434 unsigned char *buf,
size_t blen,
435 int (*f_rng)(
void *,
unsigned char *,
size_t),
438 #if defined(MBEDTLS_ECP_RESTARTABLE)
int mbedtls_ecdh_make_params(mbedtls_ecdh_context *ctx, size_t *olen, unsigned char *buf, size_t blen, int(*f_rng)(void *, unsigned char *, size_t), void *p_rng)
This function generates an EC key pair and exports its in the format used in a TLS ServerKeyExchange ...
This file provides an API for Elliptic Curves over GF(P) (ECP).
int mbedtls_ecdh_make_public(mbedtls_ecdh_context *ctx, size_t *olen, unsigned char *buf, size_t blen, int(*f_rng)(void *, unsigned char *, size_t), void *p_rng)
This function generates a public key and exports it as a TLS ClientKeyExchange payload.
The ECP key-pair structure.
void mbedtls_ecdh_free(mbedtls_ecdh_context *ctx)
This function frees a context.
int mbedtls_ecdh_setup(mbedtls_ecdh_context *ctx, mbedtls_ecp_group_id grp_id)
This function sets up the ECDH context with the information given.
#define MBEDTLS_PRIVATE(member)
int mbedtls_ecdh_read_public(mbedtls_ecdh_context *ctx, const unsigned char *buf, size_t blen)
This function parses and processes the ECDHE payload of a TLS ClientKeyExchange message.
int mbedtls_ecdh_compute_shared(mbedtls_ecp_group *grp, mbedtls_mpi *z, const mbedtls_ecp_point *Q, const mbedtls_mpi *d, int(*f_rng)(void *, unsigned char *, size_t), void *p_rng)
This function computes the shared secret.
void mbedtls_ecdh_init(mbedtls_ecdh_context *ctx)
This function initializes an ECDH context.
int mbedtls_ecdh_gen_public(mbedtls_ecp_group *grp, mbedtls_mpi *d, mbedtls_ecp_point *Q, int(*f_rng)(void *, unsigned char *, size_t), void *p_rng)
This function generates an ECDH keypair on an elliptic curve.
Macro wrapper for struct's memebrs.
int mbedtls_ecdh_read_params(mbedtls_ecdh_context *ctx, const unsigned char **buf, const unsigned char *end)
This function parses the ECDHE parameters in a TLS ServerKeyExchange handshake message.
void mbedtls_ecdh_enable_restart(mbedtls_ecdh_context *ctx)
This function enables restartable EC computations for this context. (Default: disabled.)
struct mbedtls_ecdh_context mbedtls_ecdh_context
The ECDH context structure.
The ECDH context structure.
Build-time configuration info.
int mbedtls_ecdh_calc_secret(mbedtls_ecdh_context *ctx, size_t *olen, unsigned char *buf, size_t blen, int(*f_rng)(void *, unsigned char *, size_t), void *p_rng)
This function derives and exports the shared secret.
General context for resuming ECC operations.
int mbedtls_ecdh_can_do(mbedtls_ecp_group_id gid)
Check whether a given group can be used for ECDH.
The ECP point structure, in Jacobian coordinates.
int mbedtls_ecdh_get_params(mbedtls_ecdh_context *ctx, const mbedtls_ecp_keypair *key, mbedtls_ecdh_side side)
This function sets up an ECDH context from an EC key.