ReactOS 0.4.16-dev-297-gc569aee
ecdh.h
Go to the documentation of this file.
1
15/*
16 * Copyright The Mbed TLS Contributors
17 * SPDX-License-Identifier: Apache-2.0 OR GPL-2.0-or-later
18 *
19 * This file is provided under the Apache License 2.0, or the
20 * GNU General Public License v2.0 or later.
21 *
22 * **********
23 * Apache License 2.0:
24 *
25 * Licensed under the Apache License, Version 2.0 (the "License"); you may
26 * not use this file except in compliance with the License.
27 * You may obtain a copy of the License at
28 *
29 * http://www.apache.org/licenses/LICENSE-2.0
30 *
31 * Unless required by applicable law or agreed to in writing, software
32 * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
33 * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
34 * See the License for the specific language governing permissions and
35 * limitations under the License.
36 *
37 * **********
38 *
39 * **********
40 * GNU General Public License v2.0 or later:
41 *
42 * This program is free software; you can redistribute it and/or modify
43 * it under the terms of the GNU General Public License as published by
44 * the Free Software Foundation; either version 2 of the License, or
45 * (at your option) any later version.
46 *
47 * This program is distributed in the hope that it will be useful,
48 * but WITHOUT ANY WARRANTY; without even the implied warranty of
49 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
50 * GNU General Public License for more details.
51 *
52 * You should have received a copy of the GNU General Public License along
53 * with this program; if not, write to the Free Software Foundation, Inc.,
54 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
55 *
56 * **********
57 */
58
59#ifndef MBEDTLS_ECDH_H
60#define MBEDTLS_ECDH_H
61
62#if !defined(MBEDTLS_CONFIG_FILE)
63#include "config.h"
64#else
65#include MBEDTLS_CONFIG_FILE
66#endif
67
68#include "ecp.h"
69
70/*
71 * Use a backward compatible ECDH context.
72 *
73 * This flag is always enabled for now and future versions might add a
74 * configuration option that conditionally undefines this flag.
75 * The configuration option in question may have a different name.
76 *
77 * Features undefining this flag, must have a warning in their description in
78 * config.h stating that the feature breaks backward compatibility.
79 */
80#define MBEDTLS_ECDH_LEGACY_CONTEXT
81
82#ifdef __cplusplus
83extern "C" {
84#endif
85
89typedef enum
90{
94
95#if !defined(MBEDTLS_ECDH_LEGACY_CONTEXT)
102typedef enum
103{
104 MBEDTLS_ECDH_VARIANT_NONE = 0,
105 MBEDTLS_ECDH_VARIANT_MBEDTLS_2_0,
106} mbedtls_ecdh_variant;
107
115typedef struct mbedtls_ecdh_context_mbed
116{
118 mbedtls_mpi d;
121 mbedtls_mpi z;
122#if defined(MBEDTLS_ECP_RESTARTABLE)
124#endif
125} mbedtls_ecdh_context_mbed;
126#endif
127
136{
137#if defined(MBEDTLS_ECDH_LEGACY_CONTEXT)
147#if defined(MBEDTLS_ECP_RESTARTABLE)
148 int restart_enabled;
150#endif /* MBEDTLS_ECP_RESTARTABLE */
151#else
155 mbedtls_ecdh_variant var;
156 union
157 {
158 mbedtls_ecdh_context_mbed mbed_ecdh;
159 } ctx;
162#if defined(MBEDTLS_ECP_RESTARTABLE)
163 uint8_t restart_enabled;
168#endif /* MBEDTLS_ECP_RESTARTABLE */
169#endif /* MBEDTLS_ECDH_LEGACY_CONTEXT */
170}
172
199 int (*f_rng)(void *, unsigned char *, size_t),
200 void *p_rng );
201
237 const mbedtls_ecp_point *Q, const mbedtls_mpi *d,
238 int (*f_rng)(void *, unsigned char *, size_t),
239 void *p_rng );
240
247
265 mbedtls_ecp_group_id grp_id );
266
275
302 unsigned char *buf, size_t blen,
303 int (*f_rng)(void *, unsigned char *, size_t),
304 void *p_rng );
305
331 const unsigned char **buf,
332 const unsigned char *end );
333
355 mbedtls_ecdh_side side );
356
384 unsigned char *buf, size_t blen,
385 int (*f_rng)(void *, unsigned char *, size_t),
386 void *p_rng );
387
408 const unsigned char *buf, size_t blen );
409
441 unsigned char *buf, size_t blen,
442 int (*f_rng)(void *, unsigned char *, size_t),
443 void *p_rng );
444
445#if defined(MBEDTLS_ECP_RESTARTABLE)
458void mbedtls_ecdh_enable_restart( mbedtls_ecdh_context *ctx );
459#endif /* MBEDTLS_ECP_RESTARTABLE */
460
461#ifdef __cplusplus
462}
463#endif
464
465#endif /* ecdh.h */
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.
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.
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.
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.
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.
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 ...
void mbedtls_ecdh_free(mbedtls_ecdh_context *ctx)
This function frees a context.
void mbedtls_ecdh_init(mbedtls_ecdh_context *ctx)
This function initializes an ECDH context.
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.
mbedtls_ecdh_side
Definition: ecdh.h:90
@ MBEDTLS_ECDH_OURS
Definition: ecdh.h:91
@ MBEDTLS_ECDH_THEIRS
Definition: ecdh.h:92
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.
GLuint GLuint end
Definition: gl.h:1545
GLenum GLuint GLenum GLsizei const GLchar * buf
Definition: glext.h:7751
GLdouble GLdouble z
Definition: glext.h:5874
#define d
Definition: ke_i.h:81
const char * var
Definition: shader.c:5666
BYTE uint8_t
Definition: msvideo1.c:66
This file provides an API for Elliptic Curves over GF(P) (ECP).
mbedtls_ecp_group_id
Definition: ecp.h:103
Definition: copy.c:22
The ECDH context structure.
Definition: ecdh.h:136
mbedtls_mpi d
Definition: ecdh.h:139
mbedtls_ecp_point Vf
Definition: ecdh.h:145
mbedtls_ecp_point Qp
Definition: ecdh.h:141
mbedtls_ecp_point Vi
Definition: ecdh.h:144
mbedtls_ecp_group grp
Definition: ecdh.h:138
mbedtls_mpi z
Definition: ecdh.h:142
mbedtls_ecp_point Q
Definition: ecdh.h:140
mbedtls_mpi _d
Definition: ecdh.h:146
The ECP group structure.
Definition: ecp.h:233
The ECP key-pair structure.
Definition: ecp.h:398
The ECP point structure, in Jacobian coordinates.
Definition: ecp.h:150
MPI structure.
Definition: bignum.h:211