- Added reading of DHM context from memory and file
diff --git a/include/polarssl/certs.h b/include/polarssl/certs.h
index c793932..af8fcd6 100644
--- a/include/polarssl/certs.h
+++ b/include/polarssl/certs.h
@@ -38,6 +38,7 @@
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
}
diff --git a/include/polarssl/md.h b/include/polarssl/md.h
index b23167b..13250dd 100644
--- a/include/polarssl/md.h
+++ b/include/polarssl/md.h
@@ -41,6 +41,8 @@
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.
diff --git a/include/polarssl/ssl.h b/include/polarssl/ssl.h
index 100c004..715a4e8 100644
--- a/include/polarssl/ssl.h
+++ b/include/polarssl/ssl.h
@@ -454,6 +454,17 @@
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
*
*
diff --git a/include/polarssl/x509.h b/include/polarssl/x509.h
index cbcb5b0..0df8433 100644
--- a/include/polarssl/x509.h
+++ b/include/polarssl/x509.h
@@ -28,6 +28,7 @@
#define POLARSSL_X509_H
#include "polarssl/rsa.h"
+#include "polarssl/dhm.h"
/**
* @addtogroup x509_module
@@ -322,7 +323,7 @@
#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_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 */