From: Nikos Mavrogiannopoulos Date: Wed, 8 May 2002 10:27:14 +0000 (+0000) Subject: Updated libgcrypt initialization stuff. Now depends on libgcrypt 1.1.7, and only... X-Git-Tag: gnutls_0_4_2~32 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=8669c9d61a73802fb14d44f9bb8f951b893de171;p=thirdparty%2Fgnutls.git Updated libgcrypt initialization stuff. Now depends on libgcrypt 1.1.7, and only initializes libgcrypt if this has not been done before. --- diff --git a/configure.in b/configure.in index 80fbf87524..28184fb0f9 100644 --- a/configure.in +++ b/configure.in @@ -198,7 +198,7 @@ AC_MSG_RESULT([*** *** Checking for external libraries... ]) -AM_PATH_LIBGCRYPT(1.1.5,, +AM_PATH_LIBGCRYPT(1.1.7,, AC_MSG_ERROR([[ *** *** libgcrypt was not found. You may want to get it from diff --git a/lib/gnutls_global.c b/lib/gnutls_global.c index 9e6bf7a008..4efab7fee0 100644 --- a/lib/gnutls_global.c +++ b/lib/gnutls_global.c @@ -80,6 +80,11 @@ static int _gnutls_init = 0; * You must call gnutls_global_deinit() when gnutls usage is no longer needed * Returns zero on success. * + * Note that this function will also initialize libgcrypt, if it has not + * been initialized before. Thus if you want to manualy initialize libgcrypt + * you must do it before calling this function. (useful in cases you want + * to disable internal lockings etc.) + * **/ int gnutls_global_init( void) { @@ -91,9 +96,15 @@ int gnutls_global_init( void) return 0; } - /* for gcrypt in order to be able to allocate memory */ - gcry_set_allocation_handler(gnutls_malloc, gnutls_secure_malloc, _gnutls_is_secure_memory, gnutls_realloc, gnutls_free); + if (gcry_control( GCRYCTL_ANY_INITIALIZATION_P) == 0) { + /* for gcrypt in order to be able to allocate memory */ + gcry_set_allocation_handler(gnutls_malloc, gnutls_secure_malloc, _gnutls_is_secure_memory, gnutls_realloc, gnutls_free); + + /* gcry_control (GCRYCTL_DISABLE_INTERNAL_LOCKING, NULL, 0); */ + gcry_control (GCRYCTL_INITIALIZATION_FINISHED, NULL,0); + } + /* set default recv/send functions */ gnutls_global_set_log_func( dlog);