diff options
author | Martin Willi <martin@strongswan.org> | 2009-06-04 15:49:19 +0200 |
---|---|---|
committer | Martin Willi <martin@strongswan.org> | 2009-06-09 11:18:56 +0200 |
commit | 513a1a2835d94a7b409b40051628c7a2d1107af3 (patch) | |
tree | 4c7029004c20b32e92d85d265f934d3a165f66a9 /src/libstrongswan/plugins/gcrypt/gcrypt_plugin.c | |
parent | 4977018c23a93469296891e65bd2d3c33eeb5511 (diff) | |
download | strongswan-513a1a2835d94a7b409b40051628c7a2d1107af3.tar.bz2 strongswan-513a1a2835d94a7b409b40051628c7a2d1107af3.tar.xz |
initialize gcrypt threadsave, currently for pthread only
Diffstat (limited to 'src/libstrongswan/plugins/gcrypt/gcrypt_plugin.c')
-rw-r--r-- | src/libstrongswan/plugins/gcrypt/gcrypt_plugin.c | 26 |
1 files changed, 25 insertions, 1 deletions
diff --git a/src/libstrongswan/plugins/gcrypt/gcrypt_plugin.c b/src/libstrongswan/plugins/gcrypt/gcrypt_plugin.c index 1b3c66d1d..c31dbe33d 100644 --- a/src/libstrongswan/plugins/gcrypt/gcrypt_plugin.c +++ b/src/libstrongswan/plugins/gcrypt/gcrypt_plugin.c @@ -16,6 +16,11 @@ #include "gcrypt_plugin.h" #include <library.h> +#include <debug.h> + +#include <errno.h> +#include <gcrypt.h> +#include <pthread.h> typedef struct private_gcrypt_plugin_t private_gcrypt_plugin_t; @@ -31,6 +36,11 @@ struct private_gcrypt_plugin_t { }; /** + * Thread callback implementations for pthread + */ +GCRY_THREAD_OPTION_PTHREAD_IMPL; + +/** * Implementation of gcrypt_plugin_t.destroy */ static void destroy(private_gcrypt_plugin_t *this) @@ -43,7 +53,21 @@ static void destroy(private_gcrypt_plugin_t *this) */ plugin_t *plugin_create() { - private_gcrypt_plugin_t *this = malloc_thing(private_gcrypt_plugin_t); + private_gcrypt_plugin_t *this; + + gcry_control(GCRYCTL_SET_THREAD_CBS, &gcry_threads_pthread); + + if (!gcry_check_version(GCRYPT_VERSION)) + { + DBG1("libgcrypt version mismatch"); + return NULL; + } + + /* we currently do not use secure memory */ + gcry_control(GCRYCTL_DISABLE_SECMEM, 0); + gcry_control(GCRYCTL_INITIALIZATION_FINISHED, 0); + + this = malloc_thing(private_gcrypt_plugin_t); this->public.plugin.destroy = (void(*)(plugin_t*))destroy; |