From 85fb69515cf1739bea53ce62b832a17e08ab3647 Mon Sep 17 00:00:00 2001 From: Christian Beier Date: Fri, 29 Jun 2018 12:30:17 +0200 Subject: [PATCH] crypto: move to common As of now, only LibVNCServer makes uses of these digest functions _and_ they depend on sys/uio.h, but in the future LibVNCClient will need those as well. --- CMakeLists.txt | 29 +++++++++++++++---- {libvncserver => common}/rfbcrypto.h | 0 {libvncserver => common}/rfbcrypto_gnutls.c | 0 {libvncserver => common}/rfbcrypto_included.c | 0 {libvncserver => common}/rfbcrypto_openssl.c | 0 {libvncserver => common}/rfbcrypto_polarssl.c | 0 6 files changed, 23 insertions(+), 6 deletions(-) rename {libvncserver => common}/rfbcrypto.h (100%) rename {libvncserver => common}/rfbcrypto_gnutls.c (100%) rename {libvncserver => common}/rfbcrypto_included.c (100%) rename {libvncserver => common}/rfbcrypto_openssl.c (100%) rename {libvncserver => common}/rfbcrypto_polarssl.c (100%) diff --git a/CMakeLists.txt b/CMakeLists.txt index b533494..26c686a 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -204,25 +204,40 @@ if(SYSTEMD_FOUND) set(ADDITIONAL_LIBS ${ADDITIONAL_LIBS} ${SYSTEMD_LIBRARIES}) endif(SYSTEMD_FOUND) +if(LIBVNCSERVER_HAVE_SYS_UIO_H) + if(GNUTLS_FOUND) + message(STATUS "Building crypto with GnuTLS") + set(CRYPTO_LIBRARIES ${GNUTLS_LIBRARIES}) + set(CRYPTO_SOURCES ${COMMON_DIR}/rfbcrypto_gnutls) + include_directories(${GNUTLS_INCLUDE_DIR}) + elseif(OPENSSL_FOUND) + message(STATUS "Building crypto with OpenSSL") + set(CRYPTO_LIBRARIES ${OPENSSL_LIBRARIES}) + set(CRYPTO_SOURCES ${COMMON_DIR}/rfbcrypto_openssl) + else() + message(STATUS "Building crypto with builtin functions") + set(CRYPTO_SOURCES ${COMMON_DIR}/rfbcrypto_included.c ${COMMON_DIR}/md5.c ${COMMON_DIR}/sha1.c) + endif() +endif(LIBVNCSERVER_HAVE_SYS_UIO_H) + -if(WITH_WEBSOCKETS AND LIBVNCSERVER_HAVE_SYS_UIO_H) +if(WITH_WEBSOCKETS) set(LIBVNCSERVER_WITH_WEBSOCKETS 1) if(GNUTLS_FOUND) - set(LIBVNCSERVER_WITH_CLIENT_TLS 1) message(STATUS "Building websockets with GnuTLS") set(WEBSOCKET_LIBRARIES ${GNUTLS_LIBRARIES}) - set(WSSRCS ${LIBVNCSERVER_DIR}/rfbssl_gnutls ${LIBVNCSERVER_DIR}/rfbcrypto_gnutls) + set(WSSRCS ${LIBVNCSERVER_DIR}/rfbssl_gnutls) include_directories(${GNUTLS_INCLUDE_DIR}) elseif(OPENSSL_FOUND) message(STATUS "Building websockets with OpenSSL") set(WEBSOCKET_LIBRARIES ${OPENSSL_LIBRARIES}) - set(WSSRCS ${LIBVNCSERVER_DIR}/rfbssl_openssl ${LIBVNCSERVER_DIR}/rfbcrypto_openssl) + set(WSSRCS ${LIBVNCSERVER_DIR}/rfbssl_openssl) else() message(STATUS "Building websockets without SSL") set(WEBSOCKET_LIBRARIES) - set(WSSRCS ${LIBVNCSERVER_DIR}/rfbssl_none.c ${LIBVNCSERVER_DIR}/rfbcrypto_included.c ${COMMON_DIR}/md5.c ${COMMON_DIR}/sha1.c) + set(WSSRCS ${LIBVNCSERVER_DIR}/rfbssl_none.c) endif() -endif(WITH_WEBSOCKETS AND LIBVNCSERVER_HAVE_SYS_UIO_H) +endif(WITH_WEBSOCKETS) if(WITH_GCRYPT AND LIBGCRYPT_LIBRARIES) message(STATUS "Found libgcrypt: ${LIBGCRYPT_LIBRARIES}") @@ -400,6 +415,7 @@ if(LIBVNCSERVER_WITH_WEBSOCKETS) ${LIBVNCSERVER_DIR}/websockets.c ${LIBVNCSERVER_DIR}/ws_decode.c ${COMMON_DIR}/base64.c + ${CRYPTO_SOURCES} ${WSSRCS} ) endif(LIBVNCSERVER_WITH_WEBSOCKETS) @@ -422,6 +438,7 @@ target_link_libraries(vncserver ${ZLIB_LIBRARIES} ${JPEG_LIBRARIES} ${PNG_LIBRARIES} + ${CRYPTO_LIBRARIES} ${WEBSOCKET_LIBRARIES} ) diff --git a/libvncserver/rfbcrypto.h b/common/rfbcrypto.h similarity index 100% rename from libvncserver/rfbcrypto.h rename to common/rfbcrypto.h diff --git a/libvncserver/rfbcrypto_gnutls.c b/common/rfbcrypto_gnutls.c similarity index 100% rename from libvncserver/rfbcrypto_gnutls.c rename to common/rfbcrypto_gnutls.c diff --git a/libvncserver/rfbcrypto_included.c b/common/rfbcrypto_included.c similarity index 100% rename from libvncserver/rfbcrypto_included.c rename to common/rfbcrypto_included.c diff --git a/libvncserver/rfbcrypto_openssl.c b/common/rfbcrypto_openssl.c similarity index 100% rename from libvncserver/rfbcrypto_openssl.c rename to common/rfbcrypto_openssl.c diff --git a/libvncserver/rfbcrypto_polarssl.c b/common/rfbcrypto_polarssl.c similarity index 100% rename from libvncserver/rfbcrypto_polarssl.c rename to common/rfbcrypto_polarssl.c