aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorAndreas Schwab2017-10-13 11:47:29 +0200
committerAndreas Schwab2017-10-13 12:42:45 +0200
commit716b84034d10b8cae5d721173108c4c299f66ed0 (patch)
treeec17245087161858da8a53dc2e4de3f021cc2e3b /src
parent55e313f7bea318f03bac0a2c9db362ed361961e6 (diff)
downloademacs-716b84034d10b8cae5d721173108c4c299f66ed0.tar.gz
emacs-716b84034d10b8cae5d721173108c4c299f66ed0.zip
gnutls_mac_get_nonce_size has been added in gnutls 3.3
* src/gnutls.c (HAVE_GNUTLS_MAC_GET_NONCE_SIZE) [GNUTLS_VERSION_NUMBER >= 0x030300]: Define. (gnutls_mac_get_nonce_size): Depend on HAVE_GNUTLS_MAC_GET_NONCE_SIZE. (Fgnutls_macs): Use 0 for :mac-algorithm-noncesize if !HAVE_GNUTLS_MAC_GET_NONCE_SIZE.
Diffstat (limited to 'src')
-rw-r--r--src/gnutls.c32
1 files changed, 24 insertions, 8 deletions
diff --git a/src/gnutls.c b/src/gnutls.c
index b55d1b9289f..36f65c4acb3 100644
--- a/src/gnutls.c
+++ b/src/gnutls.c
@@ -26,7 +26,7 @@ along with GNU Emacs. If not, see <https://www.gnu.org/licenses/>. */
26#include "coding.h" 26#include "coding.h"
27#include "buffer.h" 27#include "buffer.h"
28 28
29#if 0x030014 <= GNUTLS_VERSION_NUMBER 29#if GNUTLS_VERSION_NUMBER >= 0x030014
30# define HAVE_GNUTLS_X509_SYSTEM_TRUST 30# define HAVE_GNUTLS_X509_SYSTEM_TRUST
31#endif 31#endif
32 32
@@ -36,10 +36,16 @@ along with GNU Emacs. If not, see <https://www.gnu.org/licenses/>. */
36 The relevant fix seems to have been made in GnuTLS 3.5.1; see: 36 The relevant fix seems to have been made in GnuTLS 3.5.1; see:
37 https://gitlab.com/gnutls/gnutls/commit/568935848dd6b82b9315d8b6c529d00e2605e03d 37 https://gitlab.com/gnutls/gnutls/commit/568935848dd6b82b9315d8b6c529d00e2605e03d
38 So, require 3.5.1. */ 38 So, require 3.5.1. */
39#if 0x030501 <= GNUTLS_VERSION_NUMBER 39#if GNUTLS_VERSION_NUMBER >= 0x030501
40# define HAVE_GNUTLS_AEAD 40# define HAVE_GNUTLS_AEAD
41#endif 41#endif
42 42
43/* gnutls_mac_get_nonce_size was added in GnuTLS 3.2.0, but was
44 exported only since 3.3.0. */
45#if GNUTLS_VERSION_NUMBER >= 0x030300
46# define HAVE_GNUTLS_MAC_GET_NONCE_SIZE
47#endif
48
43#ifdef HAVE_GNUTLS 49#ifdef HAVE_GNUTLS
44 50
45# ifdef WINDOWSNT 51# ifdef WINDOWSNT
@@ -187,7 +193,9 @@ DEF_DLL_FN (const char *, gnutls_mac_get_name, (gnutls_mac_algorithm_t));
187# ifdef HAVE_GNUTLS3 193# ifdef HAVE_GNUTLS3
188DEF_DLL_FN (int, gnutls_rnd, (gnutls_rnd_level_t, void *, size_t)); 194DEF_DLL_FN (int, gnutls_rnd, (gnutls_rnd_level_t, void *, size_t));
189DEF_DLL_FN (const gnutls_mac_algorithm_t *, gnutls_mac_list, (void)); 195DEF_DLL_FN (const gnutls_mac_algorithm_t *, gnutls_mac_list, (void));
196# ifdef HAVE_GNUTLS_MAC_GET_NONCE_SIZE
190DEF_DLL_FN (size_t, gnutls_mac_get_nonce_size, (gnutls_mac_algorithm_t)); 197DEF_DLL_FN (size_t, gnutls_mac_get_nonce_size, (gnutls_mac_algorithm_t));
198# endif
191DEF_DLL_FN (size_t, gnutls_mac_get_key_size, (gnutls_mac_algorithm_t)); 199DEF_DLL_FN (size_t, gnutls_mac_get_key_size, (gnutls_mac_algorithm_t));
192DEF_DLL_FN (const gnutls_digest_algorithm_t *, gnutls_digest_list, (void)); 200DEF_DLL_FN (const gnutls_digest_algorithm_t *, gnutls_digest_list, (void));
193DEF_DLL_FN (const char *, gnutls_digest_get_name, (gnutls_digest_algorithm_t)); 201DEF_DLL_FN (const char *, gnutls_digest_get_name, (gnutls_digest_algorithm_t));
@@ -316,7 +324,9 @@ init_gnutls_functions (void)
316# ifdef HAVE_GNUTLS3 324# ifdef HAVE_GNUTLS3
317 LOAD_DLL_FN (library, gnutls_rnd); 325 LOAD_DLL_FN (library, gnutls_rnd);
318 LOAD_DLL_FN (library, gnutls_mac_list); 326 LOAD_DLL_FN (library, gnutls_mac_list);
327# ifdef HAVE_GNUTLS_MAC_GET_NONCE_SIZE
319 LOAD_DLL_FN (library, gnutls_mac_get_nonce_size); 328 LOAD_DLL_FN (library, gnutls_mac_get_nonce_size);
329# endif
320 LOAD_DLL_FN (library, gnutls_mac_get_key_size); 330 LOAD_DLL_FN (library, gnutls_mac_get_key_size);
321 LOAD_DLL_FN (library, gnutls_digest_list); 331 LOAD_DLL_FN (library, gnutls_digest_list);
322 LOAD_DLL_FN (library, gnutls_digest_get_name); 332 LOAD_DLL_FN (library, gnutls_digest_get_name);
@@ -427,7 +437,9 @@ init_gnutls_functions (void)
427# ifdef HAVE_GNUTLS3 437# ifdef HAVE_GNUTLS3
428# define gnutls_rnd fn_gnutls_rnd 438# define gnutls_rnd fn_gnutls_rnd
429# define gnutls_mac_list fn_gnutls_mac_list 439# define gnutls_mac_list fn_gnutls_mac_list
430# define gnutls_mac_get_nonce_size fn_gnutls_mac_get_nonce_size 440# ifdef HAVE_GNUTLS_MAC_GET_NONCE_SIZE
441# define gnutls_mac_get_nonce_size fn_gnutls_mac_get_nonce_size
442# endif
431# define gnutls_mac_get_key_size fn_gnutls_mac_get_key_size 443# define gnutls_mac_get_key_size fn_gnutls_mac_get_key_size
432# define gnutls_digest_list fn_gnutls_digest_list 444# define gnutls_digest_list fn_gnutls_digest_list
433# define gnutls_digest_get_name fn_gnutls_digest_get_name 445# define gnutls_digest_get_name fn_gnutls_digest_get_name
@@ -442,10 +454,10 @@ init_gnutls_functions (void)
442# define gnutls_cipher_decrypt2 fn_gnutls_cipher_decrypt2 454# define gnutls_cipher_decrypt2 fn_gnutls_cipher_decrypt2
443# define gnutls_cipher_deinit fn_gnutls_cipher_deinit 455# define gnutls_cipher_deinit fn_gnutls_cipher_deinit
444# ifdef HAVE_GNUTLS_AEAD 456# ifdef HAVE_GNUTLS_AEAD
445# define gnutls_aead_cipher_encrypt fn_gnutls_aead_cipher_encrypt 457# define gnutls_aead_cipher_encrypt fn_gnutls_aead_cipher_encrypt
446# define gnutls_aead_cipher_decrypt fn_gnutls_aead_cipher_decrypt 458# define gnutls_aead_cipher_decrypt fn_gnutls_aead_cipher_decrypt
447# define gnutls_aead_cipher_init fn_gnutls_aead_cipher_init 459# define gnutls_aead_cipher_init fn_gnutls_aead_cipher_init
448# define gnutls_aead_cipher_deinit fn_gnutls_aead_cipher_deinit 460# define gnutls_aead_cipher_deinit fn_gnutls_aead_cipher_deinit
449# endif 461# endif
450# define gnutls_hmac_init fn_gnutls_hmac_init 462# define gnutls_hmac_init fn_gnutls_hmac_init
451# define gnutls_hmac_get_len fn_gnutls_hmac_get_len 463# define gnutls_hmac_get_len fn_gnutls_hmac_get_len
@@ -2178,6 +2190,10 @@ name. */)
2178 /* A symbol representing the GnuTLS MAC algorithm. */ 2190 /* A symbol representing the GnuTLS MAC algorithm. */
2179 Lisp_Object gma_symbol = intern (gnutls_mac_get_name (gma)); 2191 Lisp_Object gma_symbol = intern (gnutls_mac_get_name (gma));
2180 2192
2193 size_t nonce_size = 0;
2194#ifdef HAVE_GNUTLS_MAC_GET_NONCE_SIZE
2195 nonce_size = gnutls_mac_get_nonce_size (gma);
2196#endif
2181 Lisp_Object mp = listn (CONSTYPE_HEAP, 11, gma_symbol, 2197 Lisp_Object mp = listn (CONSTYPE_HEAP, 11, gma_symbol,
2182 QCmac_algorithm_id, make_number (gma), 2198 QCmac_algorithm_id, make_number (gma),
2183 QCtype, Qgnutls_type_mac_algorithm, 2199 QCtype, Qgnutls_type_mac_algorithm,
@@ -2189,7 +2205,7 @@ name. */)
2189 make_number (gnutls_mac_get_key_size (gma)), 2205 make_number (gnutls_mac_get_key_size (gma)),
2190 2206
2191 QCmac_algorithm_noncesize, 2207 QCmac_algorithm_noncesize,
2192 make_number (gnutls_mac_get_nonce_size (gma))); 2208 make_number (nonce_size));
2193 mac_algorithms = Fcons (mp, mac_algorithms); 2209 mac_algorithms = Fcons (mp, mac_algorithms);
2194 } 2210 }
2195 2211