GNU bug report logs - #42998
27.1; gnutls-symmetric-encrypt slow when providing cipher as symbol

Previous Next

Package: emacs;

Reported by: Vasilij Schneidermann <mail <at> vasilij.de>

Date: Sun, 23 Aug 2020 16:44:02 UTC

Severity: normal

Tags: fixed

Found in version 27.1

Fixed in version 28.1

Done: Lars Ingebrigtsen <larsi <at> gnus.org>

Bug is archived. No further changes may be made.

Full log


View this message in rfc822 format

From: Lars Ingebrigtsen <larsi <at> gnus.org>
To: Vasilij Schneidermann <mail <at> vasilij.de>
Cc: 42998 <at> debbugs.gnu.org
Subject: bug#42998: 27.1; gnutls-symmetric-encrypt slow when providing cipher as symbol
Date: Mon, 24 Aug 2020 15:01:01 +0200
Vasilij Schneidermann <mail <at> vasilij.de> writes:

> I'd consider either to
> document this behavior or making the mapping more efficient, for example
> by caching the cipher list instead of recomputing it over and over
> again.

The following fixes the problem, but I'm not quite sure whether it's
correct...  Is initialising a Lisp_Object to NULL something that's
allowed over all platforms?  I can't initialise it to the more natural
Qnil, since that's not a constant, C-wise.

diff --git a/src/gnutls.c b/src/gnutls.c
index 416fb15470..75bc7d970f 100644
--- a/src/gnutls.c
+++ b/src/gnutls.c
@@ -2303,6 +2303,8 @@ gnutls_symmetric (bool encrypting, Lisp_Object cipher,
                   Lisp_Object key, Lisp_Object iv,
                   Lisp_Object input, Lisp_Object aead_auth)
 {
+  static Lisp_Object cipher_cache = NULL;
+
   if (BUFFERP (key) || STRINGP (key))
     key = list1 (key);
 
@@ -2329,7 +2331,12 @@ gnutls_symmetric (bool encrypting, Lisp_Object cipher,
 
   if (SYMBOLP (cipher))
     {
-      info = Fassq (cipher, Fgnutls_ciphers ());
+      if (! cipher_cache)
+	{
+	  cipher_cache = Fgnutls_ciphers ();
+	  staticpro (&cipher_cache);
+	}
+      info = Fassq (cipher, cipher_cache);
       if (!CONSP (info))
 	xsignal2 (Qerror,
 		  build_string ("GnuTLS cipher is invalid or not found"),


-- 
(domestic pets only, the antidote for overdose, milk.)
   bloggy blog: http://lars.ingebrigtsen.no




This bug report was last modified 4 years and 313 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.