From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Robert Pluim Newsgroups: gmane.emacs.bugs Subject: bug#50507: New function in Emacs GnuTLS implementation Date: Thu, 29 Sep 2022 11:02:49 +0200 Message-ID: <87a66id03q.fsf@gmail.com> References: <83ee9wiozc.fsf@gnu.org> <87sflkgy49.fsf@gnus.org> <87edwd15ck.fsf@gnus.org> <87tu4u8kjv.fsf@gnus.org> <878rm69hop.fsf@gmail.com> <87v8p7d4oq.fsf@gmail.com> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="13742"; mail-complaints-to="usenet@ciao.gmane.io" Cc: 50507@debbugs.gnu.org, Lars Ingebrigtsen , Eli Zaretskii To: Nikolaos Chatzikonstantinou Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Thu Sep 29 11:20:58 2022 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1odpiz-0003Re-K4 for geb-bug-gnu-emacs@m.gmane-mx.org; Thu, 29 Sep 2022 11:20:57 +0200 Original-Received: from localhost ([::1]:45582 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1odpiy-0001xt-KQ for geb-bug-gnu-emacs@m.gmane-mx.org; Thu, 29 Sep 2022 05:20:56 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:56834) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1odpRe-00008F-VT for bug-gnu-emacs@gnu.org; Thu, 29 Sep 2022 05:03:04 -0400 Original-Received: from debbugs.gnu.org ([209.51.188.43]:36882) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1odpRd-0004wP-PW for bug-gnu-emacs@gnu.org; Thu, 29 Sep 2022 05:03:02 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1odpRd-00031W-Kr for bug-gnu-emacs@gnu.org; Thu, 29 Sep 2022 05:03:01 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Robert Pluim Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Thu, 29 Sep 2022 09:03:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 50507 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: moreinfo Original-Received: via spool by 50507-submit@debbugs.gnu.org id=B50507.166444217911614 (code B ref 50507); Thu, 29 Sep 2022 09:03:01 +0000 Original-Received: (at 50507) by debbugs.gnu.org; 29 Sep 2022 09:02:59 +0000 Original-Received: from localhost ([127.0.0.1]:35960 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1odpRa-00031G-UO for submit@debbugs.gnu.org; Thu, 29 Sep 2022 05:02:59 -0400 Original-Received: from mail-wr1-f43.google.com ([209.85.221.43]:39886) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1odpRY-000312-LB for 50507@debbugs.gnu.org; Thu, 29 Sep 2022 05:02:57 -0400 Original-Received: by mail-wr1-f43.google.com with SMTP id cc5so1112137wrb.6 for <50507@debbugs.gnu.org>; Thu, 29 Sep 2022 02:02:56 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:message-id:date:references :in-reply-to:subject:cc:to:from:from:to:cc:subject:date; bh=JNsfWkZM99MqJ8sKmeqnYHH77uqHhllZfksAhOsS+zQ=; b=QPTTOw6BhuwZc1xZh1oZimWR276sKnhltIYVhl4N9xuK+SOm3fLA5sSw4tXwo4PDcX SBdTlKySaIcSaE/5r8w/RibWzgkiOUIhOJzWd+zRCQ2kVJNx1whT0kRZKvRZpvhyKlRA f4TVSnU8R7oCfqtk4BONSCAHJfJcxlH0dF2PZeAwDj/eFW33g1OzSbGw7yyyFCuGCXdD NAu3FfKijeF7GPGpJ05B7vqciozX/XQqfvJNtm4xn3EltgmqueNVi3w+HDViWio9uZrB F3bByz/l9qSa7W1/73yMSEVDTh6Vc1SMHKEMiuYu//0M1EsqKspZGdtV3ixqRYfqohCJ 6nZQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:message-id:date:references :in-reply-to:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date; bh=JNsfWkZM99MqJ8sKmeqnYHH77uqHhllZfksAhOsS+zQ=; b=X49a7i9SQh6QtDyFkvI5bG3PySQKJTuxPF49EyUR1/nuUxpsGzMGnirKKJ2h2nclqk P0PCndXh6/GHL+a6SXuD92AlhT9D0JzpqsnHE6KFyFXqhezhA7vIsVgblTYqe8Ts5WO0 jBbn3P6BLSaY+0GzZQIt5JD5vlepq0Xqd45Yv1NWkIVuKYZ3ugnDgz5uFD/EyEDEV191 JRnYd+p4JWOq3dnNLQ010cKXbVpNqb8+ETo8MSEDnUcdkx00f4gd5VVdpnf4JL0AfRwK YQNebfVSuNbM9sz3ONe69liCISPI3UAuzYKVxS0RM22nHXjJ3smASDir+cC/CdVOKU4U uG0w== X-Gm-Message-State: ACrzQf0kAGTecCvT432i8NEaZ5OW4LTEv2nV+hSNjE3bq0HrvPc+tsB8 oIytP+u/s/V95tW3+BzDHtI= X-Google-Smtp-Source: AMsMyM6H/ZIUszURJJjXC+fxR8QtqnzoCBeTw2uyQxo/Sv/B9LB4inHMbOHhen/eJdS9HLiVv5kcug== X-Received: by 2002:adf:cd10:0:b0:22c:a109:f51d with SMTP id w16-20020adfcd10000000b0022ca109f51dmr1414496wrm.238.1664442170585; Thu, 29 Sep 2022 02:02:50 -0700 (PDT) Original-Received: from rltb ([2a01:e0a:3f3:fb50:8359:d07c:62db:a1ca]) by smtp.gmail.com with ESMTPSA id l18-20020a05600c2cd200b003a63a3b55c3sm4120662wmc.14.2022.09.29.02.02.49 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 29 Sep 2022 02:02:49 -0700 (PDT) In-Reply-To: (Nikolaos Chatzikonstantinou's message of "Wed, 28 Sep 2022 23:09:46 -0400") X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Original-Sender: "bug-gnu-emacs" Xref: news.gmane.io gmane.emacs.bugs:243883 Archived-At: >>>>> On Wed, 28 Sep 2022 23:09:46 -0400, Nikolaos Chatzikonstantinou said: Nikolaos> On Wed, Sep 28, 2022 at 9:11 AM Robert Pluim wrote: >>=20 >> >>>>> On Wed, 28 Sep 2022 08:15:26 -0400, Nikolaos Chatzikonstantino= u said: >>=20 >>=20 Nikolaos> Okay, I'm submitting this patch with corrections included, se= e attachment. >>=20 >> I see a .sig attachment, but no patch (we don=CA=BCt currently requi= re >> signing of commits at all, but I guess there=CA=BCs nothing stopping= people >> from doing it). Nikolaos> My bad, here it is. I also added "Copyright-paperwork-exempt:= yes" (or Nikolaos> will this require paperwork?) and gave the helper function st= atic Nikolaos> linkage in src/gnutls.c. Eli answered that. A few nits below Nikolaos> From b11707c423773f6234746991222acd80ab3f708c Mon Sep 17 00:0= 0:00 2001 Nikolaos> From: Nikolaos Chatzikonstantinou Nikolaos> Date: Mon, 26 Sep 2022 11:08:18 -0400 Nikolaos> Subject: [PATCH] add :pass and :flags to gnutls-boot for :key= list Nikolaos> * lisp/net/gnutls.el (gnutls-boot-parameters): add the keys := pass and Nikolaos> :flags, and update the documentation. Nikolaos> * src/gnutls.c (gnutls-boot): add the keys :pass and :flags, = and Nikolaos> update the documentation. Nikolaos> (syms_of_gnutls): add the symbols :pass, :flags, and the symb= ols that Nikolaos> correspond to the enumeration constants of the GnuTLS enum Nikolaos> `gnutls_pkcs_encrypt_flags_t`. Nikolaos> ; (key_file2_aux): private helper function that translates a = list of Nikolaos> ; symbols to its corresponding `unsigned int` value of the Gn= uTLS C Nikolaos> ; enum `gnutls_pkcs_encrypt_flags_t`. Each description of a change is a sentence, and should start with a capital letter. The lines starting with ';' should not start with ';' Nikolaos> +PASS is a string, the password of the key. Nikolaos> + Nikolaos> +FLAGS is an ORed sequence of gnutls_pkcs_encrypt_flags_t val= ues. Nikolaos> + This is now a list of symbols, so the docstring needs adjusting. Nikolaos> +/* Helper function for gnutls-boot. Nikolaos> + Nikolaos> + The key :flags receives a lisp of symbols, each of which s/lisp/list/ Nikolaos> + corresponds to a GnuTLS C flag, the ORed result is to be = passed to Nikolaos> + the function gnutls_certificate_set_x509_key_file2() as i= ts last Nikolaos> + argument. Nikolaos> +*/ Nikolaos> +static unsigned int Nikolaos> +key_file2_aux (Lisp_Object flags) Nikolaos> +{ Nikolaos> + unsigned int rv =3D 0; Nikolaos> + Lisp_Object tail; Nikolaos> + for (tail =3D flags; CONSP (tail); tail =3D XCDR (tail)) We have some convenience macros in lisp.h for traversing lists, one of which is FOR_EACH_TAIL. The reason to prefer it is that it will detect circular lists, which is good practice since this list will come from the user level, so it could be anything :-) Also, the function is only relevant if HAVE_GNUTLS_CERTIFICATE_SET_X509_KEY_FILE2 is defined, so you could wrap it in a #ifdef Nikolaos> +The :pass and :flags keys are ignored with old versions of G= nuTLS, and Nikolaos> +:flags is ignored if :pass is not specified. Nikolaos> + Maybe mention that not specifying :flags or passing :flags nil means passing '0' to the GnuTLS function? Nikolaos> +# ifdef HAVE_GNUTLS_CERTIFICATE_SET_X509_KEY_FILE2 Nikolaos> + if (STRINGP (pass)) Nikolaos> + ret =3D gnutls_certificate_set_x509_key_file2 Nikolaos> + (x509_cred, SSDATA (certfile), SSDATA (keyfile), file_fo= rmat, SSDATA (pass), key_file2_aux (flags)); I think you should re-wrap this line. Nikolaos> + DEFSYM (Qgnutls_pkcs_plain, "GNUTLS_PKCS_PLAIN"); Nikolaos> + DEFSYM (Qgnutls_pkcs_pkcs12_3des, "GNUTLS_PKCS_PKCS12_3DES= "); Nikolaos> + DEFSYM (Qgnutls_pkcs_pkcs12_arcfour, "GNUTLS_PKCS_PKCS12_A= RCFOUR"); Nikolaos> + DEFSYM (Qgnutls_pkcs_pkcs12_rc2_40, "GNUTLS_PKCS_PKCS12_RC= 2_40"); Nikolaos> + DEFSYM (Qgnutls_pkcs_pbes2_3des, "GNUTLS_PKCS_PBES2_3DES"); Nikolaos> + DEFSYM (Qgnutls_pkcs_pbes2_aes_128, "GNUTLS_PKCS_PBES2_AES= _128"); Nikolaos> + DEFSYM (Qgnutls_pkcs_pbes2_aes_192, "GNUTLS_PKCS_PBES2_AES= _192"); Nikolaos> + DEFSYM (Qgnutls_pkcs_pbes2_aes_256, "GNUTLS_PKCS_PBES2_AES= _256"); Nikolaos> + DEFSYM (Qgnutls_pkcs_null_password, "GNUTLS_PKCS_NULL_PASS= WORD"); Nikolaos> + DEFSYM (Qgnutls_pkcs_pbes2_des, "GNUTLS_PKCS_PBES2_DES"); Nikolaos> + DEFSYM (Qgnutls_pkcs_pbes1_des_md5, "GNUTLS_PKCS_PBES1_DES= _MD5"); Nikolaos> + DEFSYM (Qgnutls_pkcs_pbes2_gost_tc26z, "GNUTLS_PKCS_PBES2_= GOST_TC26Z"); Nikolaos> + DEFSYM (Qgnutls_pkcs_pbes2_gost_cpa, "GNUTLS_PKCS_PBES2_GO= ST_CPA"); Nikolaos> + DEFSYM (Qgnutls_pkcs_pbes2_gost_cpb, "GNUTLS_PKCS_PBES2_GO= ST_CPB"); Nikolaos> + DEFSYM (Qgnutls_pkcs_pbes2_gost_cpc, "GNUTLS_PKCS_PBES2_GO= ST_CPC"); Nikolaos> + DEFSYM (Qgnutls_pkcs_pbes2_gost_cpd, "GNUTLS_PKCS_PBES2_GO= ST_CPD"); All this is kind of awkward, but apart from doing DEFVAR_LISP I=CA=BCm not aware of how to define a lisp level symbol with a value (it would allow you to simplify `key_file2_aux', since you could just extract the values directly from the symbols). Robert --=20