Explorar el Código

Initialize libgcrypt.

We relied initialization of libgcrypt on gnutls_global_init(), but
recent change in gnutls, which changes default crypto backend from
libgcrypt to libnettle, leaves libgcrypt uninitialized if it uses
libnettle as backend(and this is likely because libnettle is chosen by
default). To fix this issue, we simply initialize libgcrypt on our
own.
Tatsuhiro Tsujikawa hace 14 años
padre
commit
afdbda8f10
Se han modificado 1 ficheros con 10 adiciones y 0 borrados
  1. 10 0
      src/Platform.cc

+ 10 - 0
src/Platform.cc

@@ -58,6 +58,9 @@
 # include <openssl/err.h>
 # include <openssl/ssl.h>
 #endif // HAVE_OPENSSL
+#ifdef HAVE_LIBGCRYPT
+# include <gcrypt.h>
+#endif // HAVE_LIBGCRYPT
 #ifdef HAVE_LIBGNUTLS
 # include <gnutls/gnutls.h>
 #endif // HAVE_LIBGNUTLS
@@ -103,6 +106,13 @@ bool Platform::setUp()
   SSL_load_error_strings();
   SSL_library_init();
 #endif // HAVE_OPENSSL
+#ifdef HAVE_LIBGCRYPT
+  if(!gcry_check_version(GCRYPT_VERSION)) {
+    throw DL_ABORT_EX("gcry_check_version() failed.");
+  }
+  gcry_control(GCRYCTL_DISABLE_SECMEM, 0);
+  gcry_control(GCRYCTL_INITIALIZATION_FINISHED, 0);
+#endif // HAVE_LIBGCRYPT
 #ifdef HAVE_LIBGNUTLS
   {
     int r = gnutls_global_init();