From d5fe2d494c6475263b954a36812b888b11e1a50b Mon Sep 17 00:00:00 2001 From: Guy Harris Date: Mon, 10 Aug 2020 14:33:03 -0700 Subject: [PATCH] wsutil: define HAVE_LIBGCRYPT_AEAD in wsutil/wsgcrypt.h. It's used in a number of source files; don't force each of them to test GCRYPT_VERSION_NUMBER independently. Make sure every file that uses HAVE_LIBGCRYPT_AEAD includes wsutil/wsgcrypt.h. Also do some other definitions that are based on the libgcrypt version there as well. This requires that the Qt UI code be given the include directory for libgcrypt, as the follow stream code includes epan/dissectors/packet-quic.h, which includes wsutil/wsgcrypt.h to get HAVE_LIBGCRYPT_AEAD defined, and wsutil/wsgcrypt.h includes . Change-Id: I9cb50f411f5b2b6b9e28a38bfd901f4a66d9cc8f Reviewed-on: https://code.wireshark.org/review/38116 Petri-Dish: Guy Harris Tested-by: Petri Dish Buildbot Reviewed-by: Guy Harris --- epan/dissectors/packet-isakmp.c | 3 --- epan/dissectors/packet-quic.c | 9 --------- epan/dissectors/packet-quic.h | 2 ++ epan/dissectors/packet-tls-utils.c | 8 -------- epan/dissectors/packet-tls.c | 8 -------- ui/qt/CMakeLists.txt | 4 ++++ wsutil/wsgcrypt.h | 19 +++++++++++++++++++ 7 files changed, 25 insertions(+), 28 deletions(-) diff --git a/epan/dissectors/packet-isakmp.c b/epan/dissectors/packet-isakmp.c index 05d11ec957..8bb79ae607 100644 --- a/epan/dissectors/packet-isakmp.c +++ b/epan/dissectors/packet-isakmp.c @@ -54,9 +54,6 @@ #include #include #include -#if GCRYPT_VERSION_NUMBER >= 0x010600 -#define HAVE_LIBGCRYPT_AEAD 1 -#endif void proto_register_isakmp(void); void proto_reg_handoff_isakmp(void); diff --git a/epan/dissectors/packet-quic.c b/epan/dissectors/packet-quic.c index fa37525b77..a54bcac3e7 100644 --- a/epan/dissectors/packet-quic.c +++ b/epan/dissectors/packet-quic.c @@ -57,15 +57,6 @@ #include #include -#if GCRYPT_VERSION_NUMBER >= 0x010600 /* 1.6.0 */ -/* Whether to provide support for authentication in addition to decryption. */ -#define HAVE_LIBGCRYPT_AEAD -#endif -#if GCRYPT_VERSION_NUMBER >= 0x010700 /* 1.7.0 */ -/* Whether ChaCh20 PNE can be supported. */ -#define HAVE_LIBGCRYPT_CHACHA20 -#endif - /* Prototypes */ void proto_reg_handoff_quic(void); void proto_register_quic(void); diff --git a/epan/dissectors/packet-quic.h b/epan/dissectors/packet-quic.h index 9a111fed7d..1802ec2329 100644 --- a/epan/dissectors/packet-quic.h +++ b/epan/dissectors/packet-quic.h @@ -16,6 +16,8 @@ extern "C" { #include "ws_symbol_export.h" +#include /* needed to define HAVE_LIBGCRYPT_AEAD */ + /** * Metadata for a STREAM frame. * https://tools.ietf.org/html/draft-ietf-quic-transport-23#section-19.8 diff --git a/epan/dissectors/packet-tls-utils.c b/epan/dissectors/packet-tls-utils.c index c00deb62bf..4a45959823 100644 --- a/epan/dissectors/packet-tls-utils.c +++ b/epan/dissectors/packet-tls-utils.c @@ -51,14 +51,6 @@ #if defined(HAVE_LIBGNUTLS) #include #endif -#if GCRYPT_VERSION_NUMBER >= 0x010600 /* 1.6.0 */ -/* Whether to provide support for authentication in addition to decryption. */ -#define HAVE_LIBGCRYPT_AEAD -#endif -#if GCRYPT_VERSION_NUMBER >= 0x010700 /* 1.7.0 */ -/* Whether AEAD_CHACHA20_POLY1305 can be supported. */ -#define HAVE_LIBGCRYPT_CHACHA20_POLY1305 -#endif /* Lookup tables {{{ */ const value_string ssl_version_short_names[] = { diff --git a/epan/dissectors/packet-tls.c b/epan/dissectors/packet-tls.c index 0d92bc0b73..410b1074ca 100644 --- a/epan/dissectors/packet-tls.c +++ b/epan/dissectors/packet-tls.c @@ -71,14 +71,6 @@ #include "packet-tls.h" #include "packet-tls-utils.h" #include "packet-ber.h" -#if GCRYPT_VERSION_NUMBER >= 0x010600 /* 1.6.0 */ -/* Whether to provide support for authentication in addition to decryption. */ -#define HAVE_LIBGCRYPT_AEAD -#endif -#if GCRYPT_VERSION_NUMBER >= 0x010700 /* 1.7.0 */ -/* Whether AEAD_CHACHA20_POLY1305 can be supported. */ -#define HAVE_LIBGCRYPT_CHACHA20_POLY1305 -#endif void proto_register_tls(void); diff --git a/ui/qt/CMakeLists.txt b/ui/qt/CMakeLists.txt index c7751bc87b..a159e0afe9 100644 --- a/ui/qt/CMakeLists.txt +++ b/ui/qt/CMakeLists.txt @@ -9,6 +9,10 @@ ADD_CUSTOM_CMAKE_INCLUDE() +include_directories( + ${GCRYPT_INCLUDE_DIRS} +) + set(WIRESHARK_WIDGET_HEADERS widgets/additional_toolbar.h widgets/apply_line_edit.h diff --git a/wsutil/wsgcrypt.h b/wsutil/wsgcrypt.h index e81dc73834..6099667780 100644 --- a/wsutil/wsgcrypt.h +++ b/wsutil/wsgcrypt.h @@ -25,6 +25,25 @@ DIAG_OFF(deprecated-declarations) DIAG_ON(deprecated-declarations) +/* + * Define HAVE_LIBGCRYPT_AEAD here, because it's used in several source + * files. + */ +#if GCRYPT_VERSION_NUMBER >= 0x010600 /* 1.6.0 */ +/* Whether to provide support for authentication in addition to decryption. */ +#define HAVE_LIBGCRYPT_AEAD +#endif + +/* + * Define some other "do we have?" items as well. + */ +#if GCRYPT_VERSION_NUMBER >= 0x010700 /* 1.7.0 */ +/* Whether ChaCh20 PNE can be supported. */ +#define HAVE_LIBGCRYPT_CHACHA20 +/* Whether AEAD_CHACHA20_POLY1305 can be supported. */ +#define HAVE_LIBGCRYPT_CHACHA20_POLY1305 +#endif + #define HASH_MD5_LENGTH 16 #define HASH_SHA1_LENGTH 20 #define HASH_SHA2_224_LENGTH 28