mbed TLS v2.7.12
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 #if !defined(MBEDTLS_CONFIG_FILE)
37 #include "config.h"
38 #else
39 #include MBEDTLS_CONFIG_FILE
40 #endif
41 
42 #include "ecp.h"
43 
44 #ifdef __cplusplus
45 extern "C" {
46 #endif
47 
53 typedef enum
54 {
58 
62 typedef struct
63 {
73 }
75 
96  int (*f_rng)(void *, unsigned char *, size_t),
97  void *p_rng );
98 
123  const mbedtls_ecp_point *Q, const mbedtls_mpi *d,
124  int (*f_rng)(void *, unsigned char *, size_t),
125  void *p_rng );
126 
133 
140 
164 int mbedtls_ecdh_make_params( mbedtls_ecdh_context *ctx, size_t *olen,
165  unsigned char *buf, size_t blen,
166  int (*f_rng)(void *, unsigned char *, size_t),
167  void *p_rng );
168 
186  const unsigned char **buf, const unsigned char *end );
187 
207  mbedtls_ecdh_side side );
208 
228 int mbedtls_ecdh_make_public( mbedtls_ecdh_context *ctx, size_t *olen,
229  unsigned char *buf, size_t blen,
230  int (*f_rng)(void *, unsigned char *, size_t),
231  void *p_rng );
232 
250  const unsigned char *buf, size_t blen );
251 
274 int mbedtls_ecdh_calc_secret( mbedtls_ecdh_context *ctx, size_t *olen,
275  unsigned char *buf, size_t blen,
276  int (*f_rng)(void *, unsigned char *, size_t),
277  void *p_rng );
278 
279 #ifdef __cplusplus
280 }
281 #endif
282 
283 #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:68
Elliptic curves over GF(p)
mbedtls_mpi d
Definition: ecdh.h:65
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:173
void mbedtls_ecdh_free(mbedtls_ecdh_context *ctx)
This function frees a context.
Configuration options (set of defines)
mbedtls_mpi _d
Definition: ecdh.h:72
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:146
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:70
mbedtls_ecp_group grp
Definition: ecdh.h:64
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:53
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:62
mbedtls_ecp_point Qp
Definition: ecdh.h:67
mbedtls_ecp_point Q
Definition: ecdh.h:66
mbedtls_ecp_point Vf
Definition: ecdh.h:71
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:114
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.