emacs-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Emacs-diffs] scratch/tzz/nettle e88fc64: WIP: GnuTLS: determine capabil


From: Teodor Zlatanov
Subject: [Emacs-diffs] scratch/tzz/nettle e88fc64: WIP: GnuTLS: determine capabilities in autoconf
Date: Wed, 28 Jun 2017 15:34:00 -0400 (EDT)

branch: scratch/tzz/nettle
commit e88fc649f5928833599daa1d3d3a2fc730239575
Author: Ted Zlatanov <address@hidden>
Commit: Ted Zlatanov <address@hidden>

    WIP: GnuTLS: determine capabilities in autoconf
---
 configure.ac          | 58 ++++++++++++++++++++++++++++++++++++++++++++++++---
 doc/lispref/text.texi |  2 --
 src/gnutls.c          | 21 ++++++++++++++-----
 3 files changed, 71 insertions(+), 10 deletions(-)

diff --git a/configure.ac b/configure.ac
index 60f8f70..bb68aa7 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 e33b2b3..fd6ddc9 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 4b44d96..7a4e92f 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



reply via email to

[Prev in Thread] Current Thread [Next in Thread]