- Added reading of DHM context from memory and file

This commit is contained in:
Paul Bakker 2011-01-06 15:48:19 +00:00
parent 8123e9d8f1
commit 1b57b06751
8 changed files with 201 additions and 2 deletions

View file

@ -38,6 +38,7 @@ extern const char test_srv_crt[];
extern const char test_srv_key[];
extern const char test_cli_crt[];
extern const char test_cli_key[];
extern const char test_dhm_params[];
#ifdef __cplusplus
}

View file

@ -41,6 +41,8 @@ typedef enum {
POLARSSL_MD_SHA512,
} md_type_t;
#define POLARSSL_MD_MAX_SIZE 64 /* longest known is SHA512 */
/**
* Message digest information. Allows message digest functions to be called
* in a generic way.

View file

@ -453,6 +453,17 @@ void ssl_set_own_cert( ssl_context *ssl, x509_cert *own_cert,
*/
int ssl_set_dh_param( ssl_context *ssl, const char *dhm_P, const char *dhm_G );
/**
* \brief Set the Diffie-Hellman public P and G values,
* read from existing context (server-side only)
*
* \param ssl SSL context
* \param dhm_ctx Diffie-Hellman-Merkle context
*
* \return 0 if successful
*/
int ssl_set_dh_param_ctx( ssl_context *ssl, dhm_context *dhm_ctx );
/**
* \brief Set hostname for ServerName TLS Extension
*

View file

@ -28,6 +28,7 @@
#define POLARSSL_X509_H
#include "polarssl/rsa.h"
#include "polarssl/dhm.h"
/**
* @addtogroup x509_module
@ -322,7 +323,7 @@ extern "C" {
#endif
/**
* @name Functions to read in a certificate, CRL or private RSA key
* @name Functions to read in DHM parameters, a certificate, CRL or private RSA key
* @{
*/
@ -404,7 +405,31 @@ int x509parse_key( rsa_context *rsa,
*/
int x509parse_keyfile( rsa_context *rsa, const char *path,
const char *password );
/** @} name Functions to read in a certificate, CRL or private RSA key */
/** @ingroup x509_module */
/**
* \brief Parse DHM parameters
*
* \param dhm DHM context to be initialized
* \param dhmin input buffer
* \param dhminlen size of the buffer
*
* \return 0 if successful, or a specific X509 error code
*/
int x509parse_dhm( dhm_context *dhm, const unsigned char *dhmin, int dhminlen );
/** @ingroup x509_module */
/**
* \brief Load and parse DHM parameters
*
* \param dhm DHM context to be initialized
* \param path filename to read the DHM Parameters from
*
* \return 0 if successful, or a specific X509 error code
*/
int x509parse_dhmfile( dhm_context *rsa, const char *path );
/** @} name Functions to read in DHM parameters, a certificate, CRL or private RSA key */