mbedtls ported to mbed-classic

Fork of mbedtls by Christopher Haster

Embed: (wiki syntax)

« Back to documentation index

dhm.h File Reference

dhm.h File Reference

Diffie-Hellman-Merkle key exchange. More...

Go to the source code of this file.

Data Structures

struct  mbedtls_dhm_context
 DHM context structure. More...

Functions

void mbedtls_dhm_init (mbedtls_dhm_context *ctx)
 Initialize DHM context.
int mbedtls_dhm_read_params (mbedtls_dhm_context *ctx, unsigned char **p, const unsigned char *end)
 Parse the ServerKeyExchange parameters.
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.
int mbedtls_dhm_read_public (mbedtls_dhm_context *ctx, const unsigned char *input, size_t ilen)
 Import the peer's public value G^Y.
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.
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.
void mbedtls_dhm_free (mbedtls_dhm_context *ctx)
 Free and clear the components of a DHM key.
int mbedtls_dhm_parse_dhm (mbedtls_dhm_context *dhm, const unsigned char *dhmin, size_t dhminlen)
 Parse DHM parameters in PEM or DER format.
int mbedtls_dhm_parse_dhmfile (mbedtls_dhm_context *dhm, const char *path)
 Load and parse DHM parameters.
int mbedtls_dhm_self_test (int verbose)
 Checkup routine.

Detailed Description

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.


Function Documentation

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.

Parameters:
ctxDHM context
outputdestination buffer
output_sizesize of the destination buffer
olenon exit, holds the actual number of bytes written
f_rngRNG function, for blinding purposes
p_rngRNG parameter
Returns:
0 if successful, or an MBEDTLS_ERR_DHM_XXX error code
Note:
If non-NULL, f_rng is used to blind the input as countermeasure against timing attacks. Blinding is automatically used if and only if our secret value X is re-used and costs nothing otherwise, so it is recommended to always pass a non-NULL f_rng argument.

Definition at line 345 of file dhm.c.

void mbedtls_dhm_free ( mbedtls_dhm_context ctx )

Free and clear the components of a DHM key.

Parameters:
ctxDHM context to free and clear

Definition at line 398 of file dhm.c.

void mbedtls_dhm_init ( mbedtls_dhm_context ctx )

Initialize DHM context.

Parameters:
ctxDHM context to be initialized

Definition at line 118 of file dhm.c.

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.

Parameters:
ctxDHM context
x_sizeprivate value size in bytes
outputdestination buffer
olennumber of chars written
f_rngRNG function
p_rngRNG parameter
Note:
This function assumes that ctx->P and ctx->G have already been properly set (for example using mbedtls_mpi_read_string or mbedtls_mpi_read_binary).
Returns:
0 if successful, or an MBEDTLS_ERR_DHM_XXX error code

Definition at line 148 of file dhm.c.

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.

Parameters:
ctxDHM context
x_sizeprivate value size in bytes
outputdestination buffer
olenmust be equal to ctx->P.len
f_rngRNG function
p_rngRNG parameter
Returns:
0 if successful, or an MBEDTLS_ERR_DHM_XXX error code

Definition at line 233 of file dhm.c.

int mbedtls_dhm_read_params ( mbedtls_dhm_context ctx,
unsigned char **  p,
const unsigned char *  end 
)

Parse the ServerKeyExchange parameters.

Parameters:
ctxDHM context
p&(start of input buffer)
endend of buffer
Returns:
0 if successful, or an MBEDTLS_ERR_DHM_XXX error code

Definition at line 126 of file dhm.c.

int mbedtls_dhm_read_public ( mbedtls_dhm_context ctx,
const unsigned char *  input,
size_t  ilen 
)

Import the peer's public value G^Y.

Parameters:
ctxDHM context
inputinput buffer
ilensize of buffer
Returns:
0 if successful, or an MBEDTLS_ERR_DHM_XXX error code

Definition at line 216 of file dhm.c.

int mbedtls_dhm_self_test ( int  verbose )

Checkup routine.

Returns:
0 if successful, or 1 if the test failed

Definition at line 592 of file dhm.c.