|
PolarSSL v1.3.9
|
Diffie-Hellman-Merkle key exchange. More...
#include "bignum.h"

Go to the source code of this file.
Data Structures | |
| struct | dhm_context |
| DHM context structure. More... | |
Macros | |
| #define | POLARSSL_ERR_DHM_BAD_INPUT_DATA -0x3080 |
| Bad input parameters to function. | |
| #define | POLARSSL_ERR_DHM_READ_PARAMS_FAILED -0x3100 |
| Reading of the DHM parameters failed. | |
| #define | POLARSSL_ERR_DHM_MAKE_PARAMS_FAILED -0x3180 |
| Making of the DHM parameters failed. | |
| #define | POLARSSL_ERR_DHM_READ_PUBLIC_FAILED -0x3200 |
| Reading of the public values failed. | |
| #define | POLARSSL_ERR_DHM_MAKE_PUBLIC_FAILED -0x3280 |
| Making of the public value failed. | |
| #define | POLARSSL_ERR_DHM_CALC_SECRET_FAILED -0x3300 |
| Calculation of the DHM secret failed. | |
| #define | POLARSSL_ERR_DHM_INVALID_FORMAT -0x3380 |
| The ASN.1 data is not formatted correctly. | |
| #define | POLARSSL_ERR_DHM_MALLOC_FAILED -0x3400 |
| Allocation of memory failed. | |
| #define | POLARSSL_ERR_DHM_FILE_IO_ERROR -0x3480 |
| Read/write of file failed. | |
| #define | POLARSSL_DHM_RFC2409_MODP_1024_P |
| RFC 2409 defines a number of standardized Diffie-Hellman groups that can be used. | |
| #define | POLARSSL_DHM_RFC2409_MODP_1024_G "02" |
| #define | POLARSSL_DHM_RFC3526_MODP_2048_P |
| #define | POLARSSL_DHM_RFC3526_MODP_2048_G "02" |
| #define | POLARSSL_DHM_RFC3526_MODP_3072_P |
| #define | POLARSSL_DHM_RFC3526_MODP_3072_G "02" |
| #define | POLARSSL_DHM_RFC5114_MODP_1024_P |
| #define | POLARSSL_DHM_RFC5114_MODP_1024_G |
| #define | POLARSSL_DHM_RFC5114_MODP_2048_P |
| #define | POLARSSL_DHM_RFC5114_MODP_2048_G |
Functions | |
| void | dhm_init (dhm_context *ctx) |
| Initialize DHM context. | |
| int | dhm_read_params (dhm_context *ctx, unsigned char **p, const unsigned char *end) |
| Parse the ServerKeyExchange parameters. | |
| int | dhm_make_params (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 | dhm_read_public (dhm_context *ctx, const unsigned char *input, size_t ilen) |
| Import the peer's public value G^Y. | |
| int | dhm_make_public (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 | dhm_calc_secret (dhm_context *ctx, unsigned char *output, 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 | dhm_free (dhm_context *ctx) |
| Free and clear the components of a DHM key. | |
| int | dhm_parse_dhm (dhm_context *dhm, const unsigned char *dhmin, size_t dhminlen) |
| Parse DHM parameters. | |
| int | dhm_parse_dhmfile (dhm_context *dhm, const char *path) |
| Load and parse DHM parameters. | |
| int | dhm_self_test (int verbose) |
| Checkup routine. | |
Diffie-Hellman-Merkle key exchange.
Copyright (C) 2006-2013, Brainspark B.V.
This file is part of PolarSSL (http://www.polarssl.org) Lead Maintainer: Paul Bakker <polarssl_maintainer at polarssl.org>
All rights reserved.
This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
Definition in file dhm.h.
| #define POLARSSL_DHM_RFC2409_MODP_1024_P |
RFC 2409 defines a number of standardized Diffie-Hellman groups that can be used.
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 2409 6.2. 1024-bit MODP Group (Second Oakley Group) RFC 3526 3. 2048-bit MODP Group RFC 3526 4. 3072-bit MODP Group RFC 5114 2.1. 1024-bit MODP Group with 160-bit Prime Order Subgroup RFC 5114 2.2. 2048-bit MODP Group with 224-bit Prime Order Subgroup
| #define POLARSSL_DHM_RFC3526_MODP_2048_P |
| #define POLARSSL_DHM_RFC3526_MODP_3072_P |
| #define POLARSSL_DHM_RFC5114_MODP_1024_G |
| #define POLARSSL_DHM_RFC5114_MODP_1024_P |
| #define POLARSSL_DHM_RFC5114_MODP_2048_G |
| #define POLARSSL_DHM_RFC5114_MODP_2048_P |
| #define POLARSSL_ERR_DHM_BAD_INPUT_DATA -0x3080 |
| #define POLARSSL_ERR_DHM_CALC_SECRET_FAILED -0x3300 |
| #define POLARSSL_ERR_DHM_FILE_IO_ERROR -0x3480 |
| #define POLARSSL_ERR_DHM_INVALID_FORMAT -0x3380 |
| #define POLARSSL_ERR_DHM_MAKE_PARAMS_FAILED -0x3180 |
| #define POLARSSL_ERR_DHM_MAKE_PUBLIC_FAILED -0x3280 |
| #define POLARSSL_ERR_DHM_MALLOC_FAILED -0x3400 |
| #define POLARSSL_ERR_DHM_READ_PARAMS_FAILED -0x3100 |
| #define POLARSSL_ERR_DHM_READ_PUBLIC_FAILED -0x3200 |
| int dhm_calc_secret | ( | dhm_context * | ctx, |
| unsigned char * | output, | ||
| 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.
| ctx | DHM context |
| output | destination buffer |
| olen | on entry, must hold the size of the destination buffer on exit, holds the actual number of bytes written |
| f_rng | RNG function, for blinding purposes |
| p_rng | RNG parameter |
| void dhm_free | ( | dhm_context * | ctx | ) |
Free and clear the components of a DHM key.
| ctx | DHM context to free and clear |
| void dhm_init | ( | dhm_context * | ctx | ) |
Initialize DHM context.
| ctx | DHM context to be initialized |
| int dhm_make_params | ( | 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.
| 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 dhm_make_public | ( | 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.
| 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 dhm_read_params | ( | 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 dhm_read_public | ( | 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 dhm_self_test | ( | int | verbose | ) |
Checkup routine.