diff --git a/CMake/FindGCrypt.cmake b/CMake/FindGCrypt.cmake new file mode 100644 index 0000000000000000000000000000000000000000..e75438e61f04fc7472b136147c5a364cff5213b3 --- /dev/null +++ b/CMake/FindGCrypt.cmake @@ -0,0 +1,46 @@ +# - Try to find GCrypt: a crypto library +# This will define: +# GCRYPT_FOUND - system has GCrypt +# GCRYPT_INCLUDE_DIR - the GCrypt include directory (cached) +# GCRYPT_INCLUDE_DIRS - the GCrypt include directories +# (identical to GCRYPT_INCLUDE_DIR) +# GCRYPT_LIBRARY - the GCrypt library (cached) +# GCRYPT_LIBRARIES - the GCrypt libraries +# (identical to GCRYPT_LIBRARY) + +# Copyright (C) 2009 +# ASTRON (Netherlands Institute for Radio Astronomy) +# P.O.Box 2, 7990 AA Dwingeloo, The Netherlands +# +# This file is part of the LOFAR software suite. +# The LOFAR software suite is free software: you can redistribute it and/or +# modify it under the terms of the GNU General Public License as published +# by the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# The LOFAR software suite is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License along +# with the LOFAR software suite. If not, see <http://www.gnu.org/licenses/>. +# +# $Id$ + +if(NOT GCRYPT_FOUND) + + find_path(GCRYPT_INCLUDE_DIR gcrypt.h + HINTS ${GCRYPT_ROOT_DIR} PATH_SUFFIXES include) + find_library(GCRYPT_LIBRARY gcrypt + HINTS ${GCRYPT_ROOT_DIR} PATH_SUFFIXES lib) + mark_as_advanced(GCRYPT_INCLUDE_DIR GCRYPT_LIBRARY) + + include(FindPackageHandleStandardArgs) + find_package_handle_standard_args(GCrypt DEFAULT_MSG + GCRYPT_LIBRARY GCRYPT_INCLUDE_DIR) + + set(GCRYPT_INCLUDE_DIRS ${GCRYPT_INCLUDE_DIR}) + set(GCRYPT_LIBRARIES ${GCRYPT_LIBRARY}) + +endif(NOT GCRYPT_FOUND) diff --git a/RTCP/Cobalt/GPUProc/CMakeLists.txt b/RTCP/Cobalt/GPUProc/CMakeLists.txt index b6978a62dca4159b8c4d0802eb9889f08fc6d4bf..c4a9057ca73bda2969d8ba77cf6eadb3029573e7 100644 --- a/RTCP/Cobalt/GPUProc/CMakeLists.txt +++ b/RTCP/Cobalt/GPUProc/CMakeLists.txt @@ -49,7 +49,8 @@ lofar_package(GPUProc 1.0 DEPENDS ${_gpuproc_deps}) lofar_find_package(OpenMP REQUIRED) lofar_find_package(LibSSH2 REQUIRED) -lofar_find_package(OpenSSL REQUIRED) +lofar_find_package(OpenSSL) +lofar_find_package(GCrypt) lofar_find_package(Boost REQUIRED) lofar_find_package(MPI) lofar_find_package(FFTW3 COMPONENTS single double threads REQUIRED) # 'double threads' for FFT unit test refs diff --git a/RTCP/Cobalt/GPUProc/src/Storage/SSH.cc b/RTCP/Cobalt/GPUProc/src/Storage/SSH.cc index f95dabc41286534d5dff1342ea406733b9897388..bbd088331c972f59ca81ff3d648feffd816ac431 100644 --- a/RTCP/Cobalt/GPUProc/src/Storage/SSH.cc +++ b/RTCP/Cobalt/GPUProc/src/Storage/SSH.cc @@ -29,7 +29,16 @@ #include <unistd.h> #include <vector> #include <sys/select.h> + +#ifdef HAVE_OPENSSL #include <openssl/crypto.h> +#endif + +#ifdef HAVE_GCRYPT +#include <pthread.h> +#include <gcrypt.h> +GCRY_THREAD_OPTION_PTHREAD_IMPL; +#endif #include <Common/LofarLogger.h> #include <Common/SystemCallException.h> @@ -701,6 +710,7 @@ namespace LOFAR +#ifdef HAVE_OPENSSL std::vector< SmartPtr<Mutex> > openssl_mutexes; static void lock_callback(int mode, int type, const char *file, int line) @@ -718,10 +728,11 @@ namespace LOFAR { return static_cast<unsigned long>(pthread_self()); } - +#endif bool SSH_Init() { +#ifdef HAVE_OPENSSL // initialise openssl openssl_mutexes.resize(CRYPTO_num_locks()); for (size_t i = 0; i < openssl_mutexes.size(); ++i) @@ -729,6 +740,12 @@ namespace LOFAR CRYPTO_set_id_callback(&thread_id_callback); CRYPTO_set_locking_callback(&lock_callback); +#endif + +#ifdef HAVE_GCRYPT + // initialise gcrypt + gcry_control(GCRYCTL_SET_THREAD_CBS, &gcry_threads_pthread); +#endif #if LIBSSH2_VERSION_NUM >= 0x010205 // initialise libssh2 @@ -748,11 +765,13 @@ namespace LOFAR libssh2_exit(); #endif +#ifdef HAVE_OPENSSL // exit openssl CRYPTO_set_locking_callback(NULL); CRYPTO_set_id_callback(NULL); openssl_mutexes.clear(); +#endif }