mbed TLS v2.7.16
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 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  * This file is part of Mbed TLS (https://tls.mbed.org)
58  */
59 
60 #ifndef MBEDTLS_ECDH_H
61 #define MBEDTLS_ECDH_H
62 
63 #if !defined(MBEDTLS_CONFIG_FILE)
64 #include "config.h"
65 #else
66 #include MBEDTLS_CONFIG_FILE
67 #endif
68 
69 #include "ecp.h"
70 
71 #ifdef __cplusplus
72 extern "C" {
73 #endif
74 
80 typedef enum
81 {
85 
89 typedef struct
90 {
100 }
102 
123  int (*f_rng)(void *, unsigned char *, size_t),
124  void *p_rng );
125 
150  const mbedtls_ecp_point *Q, const mbedtls_mpi *d,
151  int (*f_rng)(void *, unsigned char *, size_t),
152  void *p_rng );
153 
160 
167 
191 int mbedtls_ecdh_make_params( mbedtls_ecdh_context *ctx, size_t *olen,
192  unsigned char *buf, size_t blen,
193  int (*f_rng)(void *, unsigned char *, size_t),
194  void *p_rng );
195 
213  const unsigned char **buf, const unsigned char *end );
214 
234  mbedtls_ecdh_side side );
235 
255 int mbedtls_ecdh_make_public( mbedtls_ecdh_context *ctx, size_t *olen,
256  unsigned char *buf, size_t blen,
257  int (*f_rng)(void *, unsigned char *, size_t),
258  void *p_rng );
259 
277  const unsigned char *buf, size_t blen );
278 
301 int mbedtls_ecdh_calc_secret( mbedtls_ecdh_context *ctx, size_t *olen,
302  unsigned char *buf, size_t blen,
303  int (*f_rng)(void *, unsigned char *, size_t),
304  void *p_rng );
305 
306 #ifdef __cplusplus
307 }
308 #endif
309 
310 #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:95
Elliptic curves over GF(p)
mbedtls_mpi d
Definition: ecdh.h:92
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:200
void mbedtls_ecdh_free(mbedtls_ecdh_context *ctx)
This function frees a context.
Configuration options (set of defines)
mbedtls_mpi _d
Definition: ecdh.h:99
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:173
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:97
mbedtls_ecp_group grp
Definition: ecdh.h:91
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:80
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:89
mbedtls_ecp_point Qp
Definition: ecdh.h:94
mbedtls_ecp_point Q
Definition: ecdh.h:93
mbedtls_ecp_point Vf
Definition: ecdh.h:98
MPI structure.
Definition: bignum.h:207
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:141
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.