[glib-networking/mcatanzaro/gnutls-check-version: 2/2] gnutls: introduce GTLS_GNUTLS_CHECK_VERSION macro
- From: Michael Catanzaro <mcatanzaro src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [glib-networking/mcatanzaro/gnutls-check-version: 2/2] gnutls: introduce GTLS_GNUTLS_CHECK_VERSION macro
- Date: Thu, 24 Jun 2021 17:00:08 +0000 (UTC)
commit 083346dd812bc3f7f1e2475544f917a1000c2e89
Author: Michael Catanzaro <mcatanzaro redhat com>
Date: Thu Jun 24 11:57:36 2021 -0500
gnutls: introduce GTLS_GNUTLS_CHECK_VERSION macro
This is much less-unwieldy than manually using the version macros. This
replaces df8146a2.
tls/gnutls/gtlsconnection-gnutls.c | 7 ++++---
tls/gnutls/gtlsdatabase-gnutls.c | 5 +++--
tls/gnutls/gtlsgnutls-version.h | 33 +++++++++++++++++++++++++++++++++
3 files changed, 40 insertions(+), 5 deletions(-)
---
diff --git a/tls/gnutls/gtlsconnection-gnutls.c b/tls/gnutls/gtlsconnection-gnutls.c
index c072a1d..beb9534 100644
--- a/tls/gnutls/gtlsconnection-gnutls.c
+++ b/tls/gnutls/gtlsconnection-gnutls.c
@@ -38,6 +38,7 @@
#include "gtlsclientconnection-gnutls.h"
#include "gtlsdatabase-gnutls.h"
#include "gtlslog.h"
+#include "gtlsgnutls-version.h"
#ifdef G_OS_WIN32
#include <winsock2.h>
@@ -1168,7 +1169,7 @@ gnutls_get_binding_tls_server_end_point (GTlsConnectionGnutls *gnutls,
GByteArray *data,
GError **error)
{
-#if GNUTLS_VERSION_MAJOR > 3 || GNUTLS_VERSION_MAJOR == 3 && GNUTLS_VERSION_MINOR >= 7
+#if GTLS_GNUTLS_CHECK_VERSION(3, 7, 2)
return gnutls_get_binding (gnutls, data, GNUTLS_CB_TLS_SERVER_END_POINT, error);
#else
GTlsConnectionGnutlsPrivate *priv = g_tls_connection_gnutls_get_instance_private (gnutls);
@@ -1268,7 +1269,7 @@ gnutls_get_binding_tls_server_end_point (GTlsConnectionGnutls *gnutls,
#endif
}
-#if !(GNUTLS_VERSION_MAJOR > 3 || GNUTLS_VERSION_MAJOR == 3 && GNUTLS_VERSION_MINOR >= 7)
+#if !GTLS_GNUTLS_CHECK_VERSION(3, 7, 2)
#define RFC5705_LABEL_DATA "EXPORTER-Channel-Binding"
#define RFC5705_LABEL_LEN 24
#endif
@@ -1280,7 +1281,7 @@ gnutls_get_binding_tls_exporter (GTlsConnectionGnutls *gnutls,
GByteArray *data,
GError **error)
{
-#if GNUTLS_VERSION_MAJOR > 3 || GNUTLS_VERSION_MAJOR == 3 && GNUTLS_VERSION_MINOR >= 7
+#if GTLS_GNUTLS_CHECK_VERSION(3, 7, 2)
return gnutls_get_binding (gnutls, data, GNUTLS_CB_TLS_EXPORTER, error);
#else
GTlsConnectionGnutlsPrivate *priv = g_tls_connection_gnutls_get_instance_private (gnutls);
diff --git a/tls/gnutls/gtlsdatabase-gnutls.c b/tls/gnutls/gtlsdatabase-gnutls.c
index 5499ae5..af0becc 100644
--- a/tls/gnutls/gtlsdatabase-gnutls.c
+++ b/tls/gnutls/gtlsdatabase-gnutls.c
@@ -35,6 +35,7 @@
#include "gtlscertificate-gnutls.h"
#include "gtlshttp.h"
+#include "gtlsgnutls-version.h"
typedef struct
{
@@ -566,7 +567,7 @@ g_tls_database_gnutls_create_handle_for_certificate (GTlsDatabaseGnutls *self,
return uri;
}
-#if GNUTLS_VERSION_MAJOR > 3 || GNUTLS_VERSION_MAJOR == 3 && GNUTLS_VERSION_MINOR >= 7
+#if GTLS_GNUTLS_CHECK_VERSION(3, 7, 1)
static int
issuer_missing_cb (gnutls_x509_trust_list_t tlist,
const gnutls_x509_crt_t crt,
@@ -725,7 +726,7 @@ create_trust_list (GTlsDatabaseGnutls *self,
return NULL;
}
-#if GNUTLS_VERSION_MAJOR > 3 || GNUTLS_VERSION_MAJOR == 3 && GNUTLS_VERSION_MINOR >= 7
+#if GTLS_GNUTLS_CHECK_VERSION(3, 7, 1)
gnutls_x509_trust_list_set_getissuer_function (trust_list, issuer_missing_cb);
gnutls_x509_trust_list_set_ptr (trust_list, self);
#endif
diff --git a/tls/gnutls/gtlsgnutls-version.h b/tls/gnutls/gtlsgnutls-version.h
new file mode 100644
index 0000000..f2d37e4
--- /dev/null
+++ b/tls/gnutls/gtlsgnutls-version.h
@@ -0,0 +1,33 @@
+/* -*- Mode: C; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
+/*
+ * GIO - GLib Input, Output and Streaming Library
+ *
+ * Copyright 2021 Red Hat, Inc
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library 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
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General
+ * Public License along with this library; if not, see
+ * <http://www.gnu.org/licenses/>.
+ *
+ * In addition, when the library is used with OpenSSL, a special
+ * exception applies. Refer to the LICENSE_EXCEPTION file for details.
+ */
+
+#pragma once
+
+#include <gnutls/gnutls.h>
+
+#define GTLS_GNUTLS_CHECK_VERSION(major,minor,micro) \
+ (GNUTLS_VERSION_MAJOR > (major) || \
+ (GNUTLS_VERSION_MAJOR == (major) && GNUTLS_VERSION_MINOR > (minor)) || \
+ (GNUTLS_VERSION_MAJOR == (major) && GNUTLS_VERSION_MINOR == (minor) && \
+ GNUTLS_VERSION_MICRO >= (micro)))
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]