aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNoam Postavsky2018-09-15 10:25:11 -0400
committerNoam Postavsky2018-09-17 17:54:32 -0400
commitb5bee6bf489d8c54a5e39baed4d578ada54c99bf (patch)
treee17d16a6174028d33cb0b8b706b4eef77ae96032
parent67eb80e0bf099e8075f31da3a3d22b5568786bfa (diff)
downloademacs-b5bee6bf489d8c54a5e39baed4d578ada54c99bf.tar.gz
emacs-b5bee6bf489d8c54a5e39baed4d578ada54c99bf.zip
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.
-rw-r--r--src/gnutls.c49
1 files changed, 45 insertions, 4 deletions
diff --git a/src/gnutls.c b/src/gnutls.c
index 461260e27f4..d0869ae9015 100644
--- a/src/gnutls.c
+++ b/src/gnutls.c
@@ -38,6 +38,23 @@ along with GNU Emacs. If not, see <https://www.gnu.org/licenses/>. */
38 So, require 3.5.1. */ 38 So, require 3.5.1. */
39#if GNUTLS_VERSION_NUMBER >= 0x030501 39#if GNUTLS_VERSION_NUMBER >= 0x030501
40# define HAVE_GNUTLS_AEAD 40# define HAVE_GNUTLS_AEAD
41#else
42/* gnutls_cipher_get_tag_size was introduced in 3.2.0, but it's only
43 relevant for AEAD ciphers. */
44# define gnutls_cipher_get_tag_size(cipher) 0
45#endif
46
47#if GNUTLS_VERSION_NUMBER < 0x030200
48/* gnutls_cipher_get_iv_size was introduced in 3.2.0. For the ciphers
49 available in previous versions, block size is equivalent. */
50#define gnutls_cipher_get_iv_size(cipher) gnutls_cipher_get_block_size (cipher)
51#endif
52
53#if GNUTLS_VERSION_NUMBER < 0x030202
54/* gnutls_digest_list and gnutls_digest_get_name were added in 3.2.2.
55 For previous versions, the mac algorithms are equivalent. */
56# define gnutls_digest_list() ((const gnutls_digest_algorithm_t *) gnutls_mac_list ())
57# define gnutls_digest_get_name(id) gnutls_mac_get_name ((gnutls_mac_algorithm_t) id)
41#endif 58#endif
42 59
43/* gnutls_mac_get_nonce_size was added in GnuTLS 3.2.0, but was 60/* 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));
205DEF_DLL_FN (size_t, gnutls_mac_get_nonce_size, (gnutls_mac_algorithm_t)); 222DEF_DLL_FN (size_t, gnutls_mac_get_nonce_size, (gnutls_mac_algorithm_t));
206# endif 223# endif
207DEF_DLL_FN (size_t, gnutls_mac_get_key_size, (gnutls_mac_algorithm_t)); 224DEF_DLL_FN (size_t, gnutls_mac_get_key_size, (gnutls_mac_algorithm_t));
225# ifndef gnutls_digest_list
208DEF_DLL_FN (const gnutls_digest_algorithm_t *, gnutls_digest_list, (void)); 226DEF_DLL_FN (const gnutls_digest_algorithm_t *, gnutls_digest_list, (void));
227# endif
228# ifndef gnutls_digest_get_name
209DEF_DLL_FN (const char *, gnutls_digest_get_name, (gnutls_digest_algorithm_t)); 229DEF_DLL_FN (const char *, gnutls_digest_get_name, (gnutls_digest_algorithm_t));
230# endif
210DEF_DLL_FN (gnutls_cipher_algorithm_t *, gnutls_cipher_list, (void)); 231DEF_DLL_FN (gnutls_cipher_algorithm_t *, gnutls_cipher_list, (void));
232# ifndef gnutls_cipher_get_iv_size
211DEF_DLL_FN (int, gnutls_cipher_get_iv_size, (gnutls_cipher_algorithm_t)); 233DEF_DLL_FN (int, gnutls_cipher_get_iv_size, (gnutls_cipher_algorithm_t));
234# endif
212DEF_DLL_FN (size_t, gnutls_cipher_get_key_size, (gnutls_cipher_algorithm_t)); 235DEF_DLL_FN (size_t, gnutls_cipher_get_key_size, (gnutls_cipher_algorithm_t));
213DEF_DLL_FN (int, gnutls_cipher_get_block_size, (gnutls_cipher_algorithm_t)); 236DEF_DLL_FN (int, gnutls_cipher_get_block_size, (gnutls_cipher_algorithm_t));
237# ifndef gnutls_cipher_get_tag_size
214DEF_DLL_FN (int, gnutls_cipher_get_tag_size, (gnutls_cipher_algorithm_t)); 238DEF_DLL_FN (int, gnutls_cipher_get_tag_size, (gnutls_cipher_algorithm_t));
239# endif
215DEF_DLL_FN (int, gnutls_cipher_init, 240DEF_DLL_FN (int, gnutls_cipher_init,
216 (gnutls_cipher_hd_t *, gnutls_cipher_algorithm_t, 241 (gnutls_cipher_hd_t *, gnutls_cipher_algorithm_t,
217 const gnutls_datum_t *, const gnutls_datum_t *)); 242 const gnutls_datum_t *, const gnutls_datum_t *));
@@ -339,13 +364,21 @@ init_gnutls_functions (void)
339 LOAD_DLL_FN (library, gnutls_mac_get_nonce_size); 364 LOAD_DLL_FN (library, gnutls_mac_get_nonce_size);
340# endif 365# endif
341 LOAD_DLL_FN (library, gnutls_mac_get_key_size); 366 LOAD_DLL_FN (library, gnutls_mac_get_key_size);
367# ifndef gnutls_digest_list
342 LOAD_DLL_FN (library, gnutls_digest_list); 368 LOAD_DLL_FN (library, gnutls_digest_list);
369# endif
370# ifndef gnutls_digest_get_name
343 LOAD_DLL_FN (library, gnutls_digest_get_name); 371 LOAD_DLL_FN (library, gnutls_digest_get_name);
372# endif
344 LOAD_DLL_FN (library, gnutls_cipher_list); 373 LOAD_DLL_FN (library, gnutls_cipher_list);
374# ifndef gnutls_cipher_get_iv_size
345 LOAD_DLL_FN (library, gnutls_cipher_get_iv_size); 375 LOAD_DLL_FN (library, gnutls_cipher_get_iv_size);
376# endif
346 LOAD_DLL_FN (library, gnutls_cipher_get_key_size); 377 LOAD_DLL_FN (library, gnutls_cipher_get_key_size);
347 LOAD_DLL_FN (library, gnutls_cipher_get_block_size); 378 LOAD_DLL_FN (library, gnutls_cipher_get_block_size);
379# ifndef gnutls_cipher_get_tag_size
348 LOAD_DLL_FN (library, gnutls_cipher_get_tag_size); 380 LOAD_DLL_FN (library, gnutls_cipher_get_tag_size);
381# endif
349 LOAD_DLL_FN (library, gnutls_cipher_init); 382 LOAD_DLL_FN (library, gnutls_cipher_init);
350 LOAD_DLL_FN (library, gnutls_cipher_set_iv); 383 LOAD_DLL_FN (library, gnutls_cipher_set_iv);
351 LOAD_DLL_FN (library, gnutls_cipher_encrypt2); 384 LOAD_DLL_FN (library, gnutls_cipher_encrypt2);
@@ -455,13 +488,21 @@ init_gnutls_functions (void)
455# define gnutls_mac_get_nonce_size fn_gnutls_mac_get_nonce_size 488# define gnutls_mac_get_nonce_size fn_gnutls_mac_get_nonce_size
456# endif 489# endif
457# define gnutls_mac_get_key_size fn_gnutls_mac_get_key_size 490# define gnutls_mac_get_key_size fn_gnutls_mac_get_key_size
458# define gnutls_digest_list fn_gnutls_digest_list 491# ifndef gnutls_digest_list
459# define gnutls_digest_get_name fn_gnutls_digest_get_name 492# define gnutls_digest_list fn_gnutls_digest_list
493# endif
494# ifndef gnutls_digest_get_name
495# define gnutls_digest_get_name fn_gnutls_digest_get_name
496# endif
460# define gnutls_cipher_list fn_gnutls_cipher_list 497# define gnutls_cipher_list fn_gnutls_cipher_list
461# define gnutls_cipher_get_iv_size fn_gnutls_cipher_get_iv_size 498# ifndef gnutls_cipher_get_iv_size
499# define gnutls_cipher_get_iv_size fn_gnutls_cipher_get_iv_size
500# endif
462# define gnutls_cipher_get_key_size fn_gnutls_cipher_get_key_size 501# define gnutls_cipher_get_key_size fn_gnutls_cipher_get_key_size
463# define gnutls_cipher_get_block_size fn_gnutls_cipher_get_block_size 502# define gnutls_cipher_get_block_size fn_gnutls_cipher_get_block_size
464# define gnutls_cipher_get_tag_size fn_gnutls_cipher_get_tag_size 503# ifndef gnutls_cipher_get_tag_size
504# define gnutls_cipher_get_tag_size fn_gnutls_cipher_get_tag_size
505# endif
465# define gnutls_cipher_init fn_gnutls_cipher_init 506# define gnutls_cipher_init fn_gnutls_cipher_init
466# define gnutls_cipher_set_iv fn_gnutls_cipher_set_iv 507# define gnutls_cipher_set_iv fn_gnutls_cipher_set_iv
467# define gnutls_cipher_encrypt2 fn_gnutls_cipher_encrypt2 508# define gnutls_cipher_encrypt2 fn_gnutls_cipher_encrypt2