mbed TLS v2.7.6
ecdh.h
Go to the documentation of this file.
1 
14 /*
15  * Copyright (C) 2006-2018, Arm Limited (or its affiliates), All Rights Reserved
16  * SPDX-License-Identifier: Apache-2.0
17  *
18  * Licensed under the Apache License, Version 2.0 (the "License"); you may
19  * not use this file except in compliance with the License.
20  * You may obtain a copy of the License at
21  *
22  * http://www.apache.org/licenses/LICENSE-2.0
23  *
24  * Unless required by applicable law or agreed to in writing, software
25  * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
26  * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
27  * See the License for the specific language governing permissions and
28  * limitations under the License.
29  *
30  * This file is part of Mbed TLS (https://tls.mbed.org)
31  */
32 
33 #ifndef MBEDTLS_ECDH_H
34 #define MBEDTLS_ECDH_H
35 
36 #include "ecp.h"
37 
38 #ifdef __cplusplus
39 extern "C" {
40 #endif
41 
47 typedef enum
48 {
52 
56 typedef struct
57 {
67 }
69 
90  int (*f_rng)(void *, unsigned char *, size_t),
91  void *p_rng );
92 
117  const mbedtls_ecp_point *Q, const mbedtls_mpi *d,
118  int (*f_rng)(void *, unsigned char *, size_t),
119  void *p_rng );
120 
127 
134 
158 int mbedtls_ecdh_make_params( mbedtls_ecdh_context *ctx, size_t *olen,
159  unsigned char *buf, size_t blen,
160  int (*f_rng)(void *, unsigned char *, size_t),
161  void *p_rng );
162 
180  const unsigned char **buf, const unsigned char *end );
181 
201  mbedtls_ecdh_side side );
202 
222 int mbedtls_ecdh_make_public( mbedtls_ecdh_context *ctx, size_t *olen,
223  unsigned char *buf, size_t blen,
224  int (*f_rng)(void *, unsigned char *, size_t),
225  void *p_rng );
226 
244  const unsigned char *buf, size_t blen );
245 
268 int mbedtls_ecdh_calc_secret( mbedtls_ecdh_context *ctx, size_t *olen,
269  unsigned char *buf, size_t blen,
270  int (*f_rng)(void *, unsigned char *, size_t),
271  void *p_rng );
272 
273 #ifdef __cplusplus
274 }
275 #endif
276 
277 #endif /* ecdh.h */
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 a public key and a TLS ServerKeyExchange payload.
mbedtls_mpi z
Definition: ecdh.h:62
Elliptic curves over GF(p)
mbedtls_mpi d
Definition: ecdh.h:59
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 a TLS ClientKeyExchange payload.
ECP key pair structure.
Definition: ecp.h:167
void mbedtls_ecdh_free(mbedtls_ecdh_context *ctx)
This function frees a context.
mbedtls_mpi _d
Definition: ecdh.h:66
int mbedtls_ecdh_read_public(mbedtls_ecdh_context *ctx, const unsigned char *buf, size_t blen)
This function parses and processes a TLS ClientKeyExchange payload.
ECP group structure.
Definition: ecp.h:140
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.
mbedtls_ecp_point Vi
Definition: ecdh.h:64
mbedtls_ecp_group grp
Definition: ecdh.h:58
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.
mbedtls_ecdh_side
Definition: ecdh.h:47
int mbedtls_ecdh_read_params(mbedtls_ecdh_context *ctx, const unsigned char **buf, const unsigned char *end)
This function parses and processes a TLS ServerKeyExhange payload.
The ECDH context structure.
Definition: ecdh.h:56
mbedtls_ecp_point Qp
Definition: ecdh.h:61
mbedtls_ecp_point Q
Definition: ecdh.h:60
mbedtls_ecp_point Vf
Definition: ecdh.h:65
MPI structure.
Definition: bignum.h:180
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.
ECP point structure (jacobian coordinates)
Definition: ecp.h:108
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.