mbed TLS v2.7.17
ecdh.h
Go to the documentation of this file.
1 
14 /*
15  * Copyright The Mbed TLS Contributors
16  * SPDX-License-Identifier: Apache-2.0 OR GPL-2.0-or-later
17  *
18  * This file is provided under the Apache License 2.0, or the
19  * GNU General Public License v2.0 or later.
20  *
21  * **********
22  * Apache License 2.0:
23  *
24  * Licensed under the Apache License, Version 2.0 (the "License"); you may
25  * not use this file except in compliance with the License.
26  * You may obtain a copy of the License at
27  *
28  * http://www.apache.org/licenses/LICENSE-2.0
29  *
30  * Unless required by applicable law or agreed to in writing, software
31  * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
32  * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
33  * See the License for the specific language governing permissions and
34  * limitations under the License.
35  *
36  * **********
37  *
38  * **********
39  * GNU General Public License v2.0 or later:
40  *
41  * This program is free software; you can redistribute it and/or modify
42  * it under the terms of the GNU General Public License as published by
43  * the Free Software Foundation; either version 2 of the License, or
44  * (at your option) any later version.
45  *
46  * This program is distributed in the hope that it will be useful,
47  * but WITHOUT ANY WARRANTY; without even the implied warranty of
48  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
49  * GNU General Public License for more details.
50  *
51  * You should have received a copy of the GNU General Public License along
52  * with this program; if not, write to the Free Software Foundation, Inc.,
53  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
54  *
55  * **********
56  */
57 
58 #ifndef MBEDTLS_ECDH_H
59 #define MBEDTLS_ECDH_H
60 
61 #if !defined(MBEDTLS_CONFIG_FILE)
62 #include "config.h"
63 #else
64 #include MBEDTLS_CONFIG_FILE
65 #endif
66 
67 #include "ecp.h"
68 
69 #ifdef __cplusplus
70 extern "C" {
71 #endif
72 
78 typedef enum
79 {
83 
87 typedef struct
88 {
98 }
100 
121  int (*f_rng)(void *, unsigned char *, size_t),
122  void *p_rng );
123 
148  const mbedtls_ecp_point *Q, const mbedtls_mpi *d,
149  int (*f_rng)(void *, unsigned char *, size_t),
150  void *p_rng );
151 
158 
165 
189 int mbedtls_ecdh_make_params( mbedtls_ecdh_context *ctx, size_t *olen,
190  unsigned char *buf, size_t blen,
191  int (*f_rng)(void *, unsigned char *, size_t),
192  void *p_rng );
193 
211  const unsigned char **buf, const unsigned char *end );
212 
232  mbedtls_ecdh_side side );
233 
253 int mbedtls_ecdh_make_public( mbedtls_ecdh_context *ctx, size_t *olen,
254  unsigned char *buf, size_t blen,
255  int (*f_rng)(void *, unsigned char *, size_t),
256  void *p_rng );
257 
275  const unsigned char *buf, size_t blen );
276 
299 int mbedtls_ecdh_calc_secret( mbedtls_ecdh_context *ctx, size_t *olen,
300  unsigned char *buf, size_t blen,
301  int (*f_rng)(void *, unsigned char *, size_t),
302  void *p_rng );
303 
304 #ifdef __cplusplus
305 }
306 #endif
307 
308 #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:93
Elliptic curves over GF(p)
mbedtls_mpi d
Definition: ecdh.h:90
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:198
void mbedtls_ecdh_free(mbedtls_ecdh_context *ctx)
This function frees a context.
Configuration options (set of defines)
mbedtls_mpi _d
Definition: ecdh.h:97
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:171
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:95
mbedtls_ecp_group grp
Definition: ecdh.h:89
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:78
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:87
mbedtls_ecp_point Qp
Definition: ecdh.h:92
mbedtls_ecp_point Q
Definition: ecdh.h:91
mbedtls_ecp_point Vf
Definition: ecdh.h:96
MPI structure.
Definition: bignum.h:205
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:139
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.