summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTed Zlatanov <tzz@lifelogs.com>2017-06-28 15:33:46 -0400
committerTed Zlatanov <tzz@lifelogs.com>2017-06-28 15:33:46 -0400
commite88fc649f5928833599daa1d3d3a2fc730239575 (patch)
treebdca351a0bf6b517cfecfc642b62b06f75268dbc
parentc0797db1b0319c055700e910873c7913461bc6d9 (diff)
downloademacs-scratch/tzz/nettle.tar.gz
WIP: GnuTLS: determine capabilities in autoconfscratch/tzz/nettle
-rw-r--r--configure.ac58
-rw-r--r--doc/lispref/text.texi2
-rw-r--r--src/gnutls.c21
3 files changed, 71 insertions, 10 deletions
diff --git a/configure.ac b/configure.ac
index 60f8f705f6a..bb68aa75328 100644
--- a/configure.ac
+++ b/configure.ac
@@ -2828,9 +2828,61 @@ if test "${with_gnutls}" = "yes" ; then
AC_DEFINE(HAVE_GNUTLS, 1, [Define if using GnuTLS.])
EMACS_CHECK_MODULES([LIBGNUTLS3], [gnutls >= 3.0.0],
[AC_DEFINE(HAVE_GNUTLS3, 1, [Define if using GnuTLS v3.])], [])
- dnl TODO: check the relevant functions directly, this is not great
- EMACS_CHECK_MODULES([LIBGNUTLS3_AEAD], [gnutls >= 3.4.0],
- [AC_DEFINE(HAVE_GNUTLS3_AEAD, 1, [Define if using GnuTLS v3 with AEAD support.])], [])
+
+ AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
+#include <gnutls/gnutls.h>
+#include <gnutls/crypto.h>
+]],
+[[
+int main (int argc, char **argv)
+{
+ gnutls_hmac_hd_t handle;
+ gnutls_hmac_deinit(handle, NULL);
+}
+]])],
+ [AC_DEFINE(HAVE_GNUTLS3_HMAC, 1, [Define if using GnuTLS v3 with HMAC support.])])
+
+ AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
+#include <gnutls/gnutls.h>
+#include <gnutls/crypto.h>
+]],
+[[
+int main (int argc, char **argv)
+{
+ gnutls_aead_cipher_hd_t handle;
+ gnutls_aead_cipher_deinit(handle);
+}
+]])],
+ [AC_DEFINE(HAVE_GNUTLS3_AEAD, 1, [Define if using GnuTLS v3 with AEAD support.])])
+
+ AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
+#include <gnutls/gnutls.h>
+#include <gnutls/crypto.h>
+]],
+[[
+int main (int argc, char **argv)
+{
+ gnutls_cipher_hd_t handle;
+ gnutls_cipher_encrypt2 (handle,
+ NULL, 0,
+ NULL, 0);
+ gnutls_cipher_deinit(handle);
+}
+]])],
+ [AC_DEFINE(HAVE_GNUTLS3_CIPHER, 1, [Define if using GnuTLS v3 with cipher support.])])
+
+ AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
+#include <gnutls/gnutls.h>
+#include <gnutls/crypto.h>
+]],
+[[
+int main (int argc, char **argv)
+{
+ gnutls_hash_hd_t handle;
+ gnutls_hash_deinit(handle, NULL);
+}
+]])],
+ [AC_DEFINE(HAVE_GNUTLS3_DIGEST, 1, [Define if using GnuTLS v3 with digest support.])])
fi
# Windows loads GnuTLS dynamically
diff --git a/doc/lispref/text.texi b/doc/lispref/text.texi
index e33b2b34d2b..fd6ddc98fed 100644
--- a/doc/lispref/text.texi
+++ b/doc/lispref/text.texi
@@ -4511,8 +4511,6 @@ It should be somewhat more efficient on larger buffers than
@cindex symmetric cipher
@cindex cipher, symmetric
-TODO: without autoconf macros, we have to require 3.4
-
If compiled with GnuTLS, Emacs offers built-in cryptographic support.
Following the GnuTLS API terminology, the available tools are digests,
MACs, symmetric ciphers, and AEAD ciphers.
diff --git a/src/gnutls.c b/src/gnutls.c
index 4b44d96f638..7a4e92f0d3f 100644
--- a/src/gnutls.c
+++ b/src/gnutls.c
@@ -2315,16 +2315,27 @@ GnuTLS AEAD ciphers : the list will contain 'AEAD-ciphers. */)
#ifdef HAVE_GNUTLS
Lisp_Object capabilities = Qnil;
- // TODO: fix the autoconf function-checking macros that will tell us for sure.
+#ifdef HAVE_GNUTLS3
+
+ capabilities = Fcons (intern("gnutls3"), capabilities);
+
+#ifdef HAVE_GNUTLS3_DIGEST
+ capabilities = Fcons (intern("digests"), capabilities);
+#endif
+
+#ifdef HAVE_GNUTLS3_CIPHER
+ capabilities = Fcons (intern("ciphers"), capabilities);
+
#ifdef HAVE_GNUTLS3_AEAD
capabilities = Fcons (intern("AEAD-ciphers"), capabilities);
#endif
-#ifdef HAVE_GNUTLS3
- capabilities = Fcons (intern("gnutls3"), capabilities);
- capabilities = Fcons (intern("ciphers"), capabilities);
+#ifdef HAVE_GNUTLS3_HMAC
capabilities = Fcons (intern("macs"), capabilities);
- capabilities = Fcons (intern("digests"), capabilities);
+#endif
+
+#endif
+
#endif
# ifdef WINDOWSNT