mbed TLS v2.2.0
|
Diffie-Hellman-Merkle key exchange.
Copyright (C) 2006-2015, ARM Limited, All Rights Reserved SPDX-License-Identifier: Apache-2.0
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
This file is part of mbed TLS (https://tls.mbed.org)
Definition in file dhm.h.
#include "bignum.h"
Go to the source code of this file.
Data Structures | |
struct | mbedtls_dhm_context |
DHM context structure. More... | |
Macros | |
#define | MBEDTLS_ERR_DHM_BAD_INPUT_DATA -0x3080 |
Bad input parameters to function. More... | |
#define | MBEDTLS_ERR_DHM_READ_PARAMS_FAILED -0x3100 |
Reading of the DHM parameters failed. More... | |
#define | MBEDTLS_ERR_DHM_MAKE_PARAMS_FAILED -0x3180 |
Making of the DHM parameters failed. More... | |
#define | MBEDTLS_ERR_DHM_READ_PUBLIC_FAILED -0x3200 |
Reading of the public values failed. More... | |
#define | MBEDTLS_ERR_DHM_MAKE_PUBLIC_FAILED -0x3280 |
Making of the public value failed. More... | |
#define | MBEDTLS_ERR_DHM_CALC_SECRET_FAILED -0x3300 |
Calculation of the DHM secret failed. More... | |
#define | MBEDTLS_ERR_DHM_INVALID_FORMAT -0x3380 |
The ASN.1 data is not formatted correctly. More... | |
#define | MBEDTLS_ERR_DHM_ALLOC_FAILED -0x3400 |
Allocation of memory failed. More... | |
#define | MBEDTLS_ERR_DHM_FILE_IO_ERROR -0x3480 |
Read/write of file failed. More... | |
#define | MBEDTLS_DHM_RFC3526_MODP_2048_P |
RFC 3526 defines a number of standardized Diffie-Hellman groups for IKE. More... | |
#define | MBEDTLS_DHM_RFC3526_MODP_2048_G "02" |
#define | MBEDTLS_DHM_RFC3526_MODP_3072_P |
#define | MBEDTLS_DHM_RFC3526_MODP_3072_G "02" |
#define | MBEDTLS_DHM_RFC3526_MODP_4096_P |
#define | MBEDTLS_DHM_RFC3526_MODP_4096_G "02" |
#define | MBEDTLS_DHM_RFC5114_MODP_2048_P |
#define | MBEDTLS_DHM_RFC5114_MODP_2048_G |
Functions | |
void | mbedtls_dhm_init (mbedtls_dhm_context *ctx) |
Initialize DHM context. More... | |
int | mbedtls_dhm_read_params (mbedtls_dhm_context *ctx, unsigned char **p, const unsigned char *end) |
Parse the ServerKeyExchange parameters. More... | |
int | mbedtls_dhm_make_params (mbedtls_dhm_context *ctx, int x_size, unsigned char *output, size_t *olen, int(*f_rng)(void *, unsigned char *, size_t), void *p_rng) |
Setup and write the ServerKeyExchange parameters. More... | |
int | mbedtls_dhm_read_public (mbedtls_dhm_context *ctx, const unsigned char *input, size_t ilen) |
Import the peer's public value G^Y. More... | |
int | mbedtls_dhm_make_public (mbedtls_dhm_context *ctx, int x_size, unsigned char *output, size_t olen, int(*f_rng)(void *, unsigned char *, size_t), void *p_rng) |
Create own private value X and export G^X. More... | |
int | mbedtls_dhm_calc_secret (mbedtls_dhm_context *ctx, unsigned char *output, size_t output_size, size_t *olen, int(*f_rng)(void *, unsigned char *, size_t), void *p_rng) |
Derive and export the shared secret (G^Y)^X mod P. More... | |
void | mbedtls_dhm_free (mbedtls_dhm_context *ctx) |
Free and clear the components of a DHM key. More... | |
int | mbedtls_dhm_self_test (int verbose) |
Checkup routine. More... | |
#define MBEDTLS_DHM_RFC3526_MODP_2048_P |
RFC 3526 defines a number of standardized Diffie-Hellman groups for IKE.
RFC 5114 defines a number of standardized Diffie-Hellman groups that can be used.
Some are included here for convenience.
Included are: RFC 3526 3. 2048-bit MODP Group RFC 3526 4. 3072-bit MODP Group RFC 3526 5. 4096-bit MODP Group RFC 5114 2.2. 2048-bit MODP Group with 224-bit Prime Order Subgroup
#define MBEDTLS_DHM_RFC3526_MODP_3072_P |
#define MBEDTLS_DHM_RFC3526_MODP_4096_P |
#define MBEDTLS_DHM_RFC5114_MODP_2048_G |
#define MBEDTLS_DHM_RFC5114_MODP_2048_P |
#define MBEDTLS_ERR_DHM_ALLOC_FAILED -0x3400 |
#define MBEDTLS_ERR_DHM_BAD_INPUT_DATA -0x3080 |
#define MBEDTLS_ERR_DHM_CALC_SECRET_FAILED -0x3300 |
#define MBEDTLS_ERR_DHM_FILE_IO_ERROR -0x3480 |
#define MBEDTLS_ERR_DHM_INVALID_FORMAT -0x3380 |
#define MBEDTLS_ERR_DHM_MAKE_PARAMS_FAILED -0x3180 |
#define MBEDTLS_ERR_DHM_MAKE_PUBLIC_FAILED -0x3280 |
#define MBEDTLS_ERR_DHM_READ_PARAMS_FAILED -0x3100 |
#define MBEDTLS_ERR_DHM_READ_PUBLIC_FAILED -0x3200 |
int mbedtls_dhm_calc_secret | ( | mbedtls_dhm_context * | ctx, |
unsigned char * | output, | ||
size_t | output_size, | ||
size_t * | olen, | ||
int(*)(void *, unsigned char *, size_t) | f_rng, | ||
void * | p_rng | ||
) |
Derive and export the shared secret (G^Y)^X mod P.
ctx | DHM context |
output | destination buffer |
output_size | size of the destination buffer |
olen | on exit, holds the actual number of bytes written |
f_rng | RNG function, for blinding purposes |
p_rng | RNG parameter |
void mbedtls_dhm_free | ( | mbedtls_dhm_context * | ctx | ) |
Free and clear the components of a DHM key.
ctx | DHM context to free and clear |
void mbedtls_dhm_init | ( | mbedtls_dhm_context * | ctx | ) |
Initialize DHM context.
ctx | DHM context to be initialized |
int mbedtls_dhm_make_params | ( | mbedtls_dhm_context * | ctx, |
int | x_size, | ||
unsigned char * | output, | ||
size_t * | olen, | ||
int(*)(void *, unsigned char *, size_t) | f_rng, | ||
void * | p_rng | ||
) |
Setup and write the ServerKeyExchange parameters.
ctx | DHM context |
x_size | private value size in bytes |
output | destination buffer |
olen | number of chars written |
f_rng | RNG function |
p_rng | RNG parameter |
int mbedtls_dhm_make_public | ( | mbedtls_dhm_context * | ctx, |
int | x_size, | ||
unsigned char * | output, | ||
size_t | olen, | ||
int(*)(void *, unsigned char *, size_t) | f_rng, | ||
void * | p_rng | ||
) |
Create own private value X and export G^X.
ctx | DHM context |
x_size | private value size in bytes |
output | destination buffer |
olen | must be equal to ctx->P.len |
f_rng | RNG function |
p_rng | RNG parameter |
int mbedtls_dhm_read_params | ( | mbedtls_dhm_context * | ctx, |
unsigned char ** | p, | ||
const unsigned char * | end | ||
) |
Parse the ServerKeyExchange parameters.
ctx | DHM context |
p | &(start of input buffer) |
end | end of buffer |
int mbedtls_dhm_read_public | ( | mbedtls_dhm_context * | ctx, |
const unsigned char * | input, | ||
size_t | ilen | ||
) |
Import the peer's public value G^Y.
ctx | DHM context |
input | input buffer |
ilen | size of buffer |
int mbedtls_dhm_self_test | ( | int | verbose | ) |
Checkup routine.