unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
From: Noam Postavsky <npostavs@gmail.com>
To: Eli Zaretskii <eliz@gnu.org>
Cc: 32446@debbugs.gnu.org, tzz@lifelogs.com,
	Gavin Smith <gavinsmith0123@gmail.com>
Subject: bug#32446: Configure-time requirement for gnutls is too old
Date: Sun, 16 Sep 2018 16:31:16 -0400	[thread overview]
Message-ID: <87sh29qj57.fsf@gmail.com> (raw)
In-Reply-To: <83k1nmivll.fsf@gnu.org> (Eli Zaretskii's message of "Sat, 15 Sep 2018 19:17:10 +0300")

[-- Attachment #1: Type: text/plain, Size: 993 bytes --]

Eli Zaretskii <eliz@gnu.org> writes:

> The patch LGTM as well, so, Noam, please push eto emacs-26, and
> thanks.

Ah, minor problem, I had initially written this on Windows, but it turns
out on GNU/Linux when the '#ifdef WINDOWSNT' part is skipped, gcc gives
a few warnings.  I've adjusted the patch to avoid this (see attached);
I'll push it tomorrow after double checking the updated version on
Windows.

  CC       gnutls.o
../../src/gnutls.c:59:0: warning: macro "HAVE_GNUTLS_DIGEST_GET_NAME" is not used [-Wunused-macros]
 # define HAVE_GNUTLS_DIGEST_GET_NAME
 
../../src/gnutls.c:43:0: warning: macro "HAVE_GNUTLS_CIPHER_GET_TAG_SIZE" is not used [-Wunused-macros]
 # define HAVE_GNUTLS_CIPHER_GET_TAG_SIZE
 
../../src/gnutls.c:50:0: warning: macro "HAVE_GNUTLS_CIPHER_GET_IV_SIZE" is not used [-Wunused-macros]
 # define HAVE_GNUTLS_CIPHER_GET_IV_SIZE
 
../../src/gnutls.c:58:0: warning: macro "HAVE_GNUTLS_DIGEST_LIST" is not used [-Wunused-macros]
 # define HAVE_GNUTLS_DIGEST_LIST


[-- Attachment #2: patch --]
[-- Type: text/plain, Size: 5142 bytes --]

From f7d6e2b5b6c4cc24d935d1eee84df4dfc6ded7c8 Mon Sep 17 00:00:00 2001
From: Noam Postavsky <npostavs@gmail.com>
Date: Sat, 15 Sep 2018 10:25:11 -0400
Subject: [PATCH v2] Fix build with gnutls versions 3.0 to 3.2 (Bug#32446)

We previously used functions available only in 3.2+ for all 3.x
versions.
* src/gnutls.c [GNUTLS_VERSION_NUMBER < 0x030501]: Replace calls to
gnutls_cipher_get_tag_size with 0.
[GNUTLS_VERSION_NUMBER < 0x030200]: Alias gnutls_cipher_get_iv_size
to gnutls_cipher_get_block_size, gnutls_digest_list to
gnutls_mac_list, and gnutls_digest_get_name to gnutls_mac_get_name.
[WINDOWSNT]: Adjust DLL function definitions and declarations
accordingly.
---
 src/gnutls.c | 49 +++++++++++++++++++++++++++++++++++++++++++++----
 1 file changed, 45 insertions(+), 4 deletions(-)

diff --git a/src/gnutls.c b/src/gnutls.c
index 461260e27f..2a834d9391 100644
--- a/src/gnutls.c
+++ b/src/gnutls.c
@@ -38,6 +38,23 @@ your option) any later version.
    So, require 3.5.1.  */
 #if GNUTLS_VERSION_NUMBER >= 0x030501
 # define HAVE_GNUTLS_AEAD
+#else
+/* gnutls_cipher_get_tag_size was introduced in 3.2.0, but it's only
+   relevant for AEAD ciphers.  */
+# define gnutls_cipher_get_tag_size(cipher) 0
+#endif
+
+#if GNUTLS_VERSION_NUMBER < 0x030200
+/* gnutls_cipher_get_iv_size was introduced in 3.2.0.  For the ciphers
+   available in previous versions, block size is equivalent.  */
+#define gnutls_cipher_get_iv_size(cipher) gnutls_cipher_get_block_size (cipher)
+#endif
+
+#if GNUTLS_VERSION_NUMBER < 0x030202
+/* gnutls_digest_list and gnutls_digest_get_name were added in 3.2.2.
+   For previous versions, the mac algorithms are equivalent.  */
+# define gnutls_digest_list() ((const gnutls_digest_algorithm_t *) gnutls_mac_list ())
+# define gnutls_digest_get_name(id) gnutls_mac_get_name ((gnutls_mac_algorithm_t) id)
 #endif
 
 /* gnutls_mac_get_nonce_size was added in GnuTLS 3.2.0, but was
@@ -205,13 +222,21 @@ DEF_DLL_FN (const gnutls_mac_algorithm_t *, gnutls_mac_list, (void));
 DEF_DLL_FN (size_t, gnutls_mac_get_nonce_size, (gnutls_mac_algorithm_t));
 #   endif
 DEF_DLL_FN (size_t, gnutls_mac_get_key_size, (gnutls_mac_algorithm_t));
+#   ifndef gnutls_digest_list
 DEF_DLL_FN (const gnutls_digest_algorithm_t *, gnutls_digest_list, (void));
+#   endif
+#   ifndef gnutls_digest_get_name
 DEF_DLL_FN (const char *, gnutls_digest_get_name, (gnutls_digest_algorithm_t));
+#   endif
 DEF_DLL_FN (gnutls_cipher_algorithm_t *, gnutls_cipher_list, (void));
+#   ifndef gnutls_cipher_get_iv_size
 DEF_DLL_FN (int, gnutls_cipher_get_iv_size, (gnutls_cipher_algorithm_t));
+#   endif
 DEF_DLL_FN (size_t, gnutls_cipher_get_key_size, (gnutls_cipher_algorithm_t));
 DEF_DLL_FN (int, gnutls_cipher_get_block_size, (gnutls_cipher_algorithm_t));
+#   ifndef gnutls_cipher_get_tag_size
 DEF_DLL_FN (int, gnutls_cipher_get_tag_size, (gnutls_cipher_algorithm_t));
+#   endif
 DEF_DLL_FN (int, gnutls_cipher_init,
 	    (gnutls_cipher_hd_t *, gnutls_cipher_algorithm_t,
 	     const gnutls_datum_t *, const gnutls_datum_t *));
@@ -339,13 +364,21 @@ init_gnutls_functions (void)
   LOAD_DLL_FN (library, gnutls_mac_get_nonce_size);
 #   endif
   LOAD_DLL_FN (library, gnutls_mac_get_key_size);
+#   ifndef gnutls_digest_list
   LOAD_DLL_FN (library, gnutls_digest_list);
+#   endif
+#   ifdef HAVE_GNUTLS_DIGEST_GET_NAME
   LOAD_DLL_FN (library, gnutls_digest_get_name);
+#   endif
   LOAD_DLL_FN (library, gnutls_cipher_list);
+#   ifndef gnutls_cipher_get_iv_size
   LOAD_DLL_FN (library, gnutls_cipher_get_iv_size);
+#   endif
   LOAD_DLL_FN (library, gnutls_cipher_get_key_size);
   LOAD_DLL_FN (library, gnutls_cipher_get_block_size);
+#   ifndef gnutls_cipher_get_tag_size
   LOAD_DLL_FN (library, gnutls_cipher_get_tag_size);
+#   endif
   LOAD_DLL_FN (library, gnutls_cipher_init);
   LOAD_DLL_FN (library, gnutls_cipher_set_iv);
   LOAD_DLL_FN (library, gnutls_cipher_encrypt2);
@@ -455,13 +488,21 @@ init_gnutls_functions (void)
 #    define gnutls_mac_get_nonce_size fn_gnutls_mac_get_nonce_size
 #   endif
 #  define gnutls_mac_get_key_size fn_gnutls_mac_get_key_size
-#  define gnutls_digest_list fn_gnutls_digest_list
-#  define gnutls_digest_get_name fn_gnutls_digest_get_name
+#  ifndef gnutls_digest_list
+#   define gnutls_digest_list fn_gnutls_digest_list
+#  endif
+#  ifdef HAVE_GNUTLS_DIGEST_GET_NAME
+#   define gnutls_digest_get_name fn_gnutls_digest_get_name
+#  endif
 #  define gnutls_cipher_list fn_gnutls_cipher_list
-#  define gnutls_cipher_get_iv_size fn_gnutls_cipher_get_iv_size
+#  ifndef gnutls_cipher_get_iv_size
+#   define gnutls_cipher_get_iv_size fn_gnutls_cipher_get_iv_size
+#  endif
 #  define gnutls_cipher_get_key_size fn_gnutls_cipher_get_key_size
 #  define gnutls_cipher_get_block_size fn_gnutls_cipher_get_block_size
-#  define gnutls_cipher_get_tag_size fn_gnutls_cipher_get_tag_size
+#  ifndef gnutls_cipher_get_tag_size
+#   define gnutls_cipher_get_tag_size fn_gnutls_cipher_get_tag_size
+#  endif
 #  define gnutls_cipher_init fn_gnutls_cipher_init
 #  define gnutls_cipher_set_iv fn_gnutls_cipher_set_iv
 #  define gnutls_cipher_encrypt2 fn_gnutls_cipher_encrypt2
-- 
2.11.0


  reply	other threads:[~2018-09-16 20:31 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-08-15 11:12 bug#32446: Configure-time requirement for gnutls is too old Gavin Smith
2018-08-15 16:09 ` Eli Zaretskii
2018-08-21  2:08   ` Glenn Morris
2018-09-15 14:44   ` Noam Postavsky
2018-09-15 15:26     ` Eli Zaretskii
2018-09-15 15:55       ` Gavin Smith
2018-09-15 16:17         ` Eli Zaretskii
2018-09-16 20:31           ` Noam Postavsky [this message]
2018-09-17 23:29             ` Noam Postavsky
2018-09-18 10:28               ` Eli Zaretskii
2018-09-18 13:14                 ` Noam Postavsky
2018-09-18 14:08                   ` Eli Zaretskii

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87sh29qj57.fsf@gmail.com \
    --to=npostavs@gmail.com \
    --cc=32446@debbugs.gnu.org \
    --cc=eliz@gnu.org \
    --cc=gavinsmith0123@gmail.com \
    --cc=tzz@lifelogs.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).