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.
This commit is contained in:
Andreas Schwab 2017-10-13 11:47:29 +02:00
parent 55e313f7be
commit 716b84034d

View file

@ -26,7 +26,7 @@ along with GNU Emacs. If not, see <https://www.gnu.org/licenses/>. */
#include "coding.h"
#include "buffer.h"
#if 0x030014 <= GNUTLS_VERSION_NUMBER
#if GNUTLS_VERSION_NUMBER >= 0x030014
# define HAVE_GNUTLS_X509_SYSTEM_TRUST
#endif
@ -36,10 +36,16 @@ along with GNU Emacs. If not, see <https://www.gnu.org/licenses/>. */
The relevant fix seems to have been made in GnuTLS 3.5.1; see:
https://gitlab.com/gnutls/gnutls/commit/568935848dd6b82b9315d8b6c529d00e2605e03d
So, require 3.5.1. */
#if 0x030501 <= GNUTLS_VERSION_NUMBER
#if GNUTLS_VERSION_NUMBER >= 0x030501
# define HAVE_GNUTLS_AEAD
#endif
/* gnutls_mac_get_nonce_size was added in GnuTLS 3.2.0, but was
exported only since 3.3.0. */
#if GNUTLS_VERSION_NUMBER >= 0x030300
# define HAVE_GNUTLS_MAC_GET_NONCE_SIZE
#endif
#ifdef HAVE_GNUTLS
# ifdef WINDOWSNT
@ -187,7 +193,9 @@ DEF_DLL_FN (const char *, gnutls_mac_get_name, (gnutls_mac_algorithm_t));
# ifdef HAVE_GNUTLS3
DEF_DLL_FN (int, gnutls_rnd, (gnutls_rnd_level_t, void *, size_t));
DEF_DLL_FN (const gnutls_mac_algorithm_t *, gnutls_mac_list, (void));
# ifdef HAVE_GNUTLS_MAC_GET_NONCE_SIZE
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));
DEF_DLL_FN (const gnutls_digest_algorithm_t *, gnutls_digest_list, (void));
DEF_DLL_FN (const char *, gnutls_digest_get_name, (gnutls_digest_algorithm_t));
@ -316,7 +324,9 @@ init_gnutls_functions (void)
# ifdef HAVE_GNUTLS3
LOAD_DLL_FN (library, gnutls_rnd);
LOAD_DLL_FN (library, gnutls_mac_list);
# ifdef HAVE_GNUTLS_MAC_GET_NONCE_SIZE
LOAD_DLL_FN (library, gnutls_mac_get_nonce_size);
# endif
LOAD_DLL_FN (library, gnutls_mac_get_key_size);
LOAD_DLL_FN (library, gnutls_digest_list);
LOAD_DLL_FN (library, gnutls_digest_get_name);
@ -427,7 +437,9 @@ init_gnutls_functions (void)
# ifdef HAVE_GNUTLS3
# define gnutls_rnd fn_gnutls_rnd
# define gnutls_mac_list fn_gnutls_mac_list
# define gnutls_mac_get_nonce_size fn_gnutls_mac_get_nonce_size
# ifdef HAVE_GNUTLS_MAC_GET_NONCE_SIZE
# 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
@ -442,10 +454,10 @@ init_gnutls_functions (void)
# define gnutls_cipher_decrypt2 fn_gnutls_cipher_decrypt2
# define gnutls_cipher_deinit fn_gnutls_cipher_deinit
# ifdef HAVE_GNUTLS_AEAD
# define gnutls_aead_cipher_encrypt fn_gnutls_aead_cipher_encrypt
# define gnutls_aead_cipher_decrypt fn_gnutls_aead_cipher_decrypt
# define gnutls_aead_cipher_init fn_gnutls_aead_cipher_init
# define gnutls_aead_cipher_deinit fn_gnutls_aead_cipher_deinit
# define gnutls_aead_cipher_encrypt fn_gnutls_aead_cipher_encrypt
# define gnutls_aead_cipher_decrypt fn_gnutls_aead_cipher_decrypt
# define gnutls_aead_cipher_init fn_gnutls_aead_cipher_init
# define gnutls_aead_cipher_deinit fn_gnutls_aead_cipher_deinit
# endif
# define gnutls_hmac_init fn_gnutls_hmac_init
# define gnutls_hmac_get_len fn_gnutls_hmac_get_len
@ -2178,6 +2190,10 @@ name. */)
/* A symbol representing the GnuTLS MAC algorithm. */
Lisp_Object gma_symbol = intern (gnutls_mac_get_name (gma));
size_t nonce_size = 0;
#ifdef HAVE_GNUTLS_MAC_GET_NONCE_SIZE
nonce_size = gnutls_mac_get_nonce_size (gma);
#endif
Lisp_Object mp = listn (CONSTYPE_HEAP, 11, gma_symbol,
QCmac_algorithm_id, make_number (gma),
QCtype, Qgnutls_type_mac_algorithm,
@ -2189,7 +2205,7 @@ name. */)
make_number (gnutls_mac_get_key_size (gma)),
QCmac_algorithm_noncesize,
make_number (gnutls_mac_get_nonce_size (gma)));
make_number (nonce_size));
mac_algorithms = Fcons (mp, mac_algorithms);
}