diffie-hellman: Explicitly initialize DH exponent sizes during initialization

To avoid any race conditions when multiple threads call and initialize
diffie_hellman_get_params(), explicitly examine the optimum DH exponent size
during library initialization.

Fixes #655.
This commit is contained in:
Martin Willi
2014-08-25 09:43:29 +02:00
parent 52ba4f6bf4
commit 46184b07c1
3 changed files with 38 additions and 8 deletions
@@ -148,9 +148,17 @@ struct diffie_hellman_params_t {
const chunk_t subgroup;
};
/**
* Initialize diffie hellman parameters during startup.
*/
void diffie_hellman_init();
/**
* Get the parameters associated with the specified diffie hellman group.
*
* Before calling this method, use diffie_hellman_init() to initialize the
* DH group table. This is usually done by library_init().
*
* @param group DH group
* @return The parameters or NULL, if the group is not supported
*/