From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Eli Zaretskii Newsgroups: gmane.emacs.devel Subject: Re: GNU Emacs-libnettle-libhogweed integration patch v1 Date: Sun, 06 Oct 2013 19:09:41 +0300 Message-ID: <83wqlq5qka.fsf@gnu.org> References: <877gdqrc9u.fsf@flea.lifelogs.com> Reply-To: Eli Zaretskii NNTP-Posting-Host: plane.gmane.org X-Trace: ger.gmane.org 1381075800 13114 80.91.229.3 (6 Oct 2013 16:10:00 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Sun, 6 Oct 2013 16:10:00 +0000 (UTC) To: emacs-devel@gnu.org Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Sun Oct 06 18:10:03 2013 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1VSquA-0003nw-Ml for ged-emacs-devel@m.gmane.org; Sun, 06 Oct 2013 18:10:02 +0200 Original-Received: from localhost ([::1]:55740 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VSquA-0001ht-2h for ged-emacs-devel@m.gmane.org; Sun, 06 Oct 2013 12:10:02 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:56020) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VSqu3-0001hg-7r for emacs-devel@gnu.org; Sun, 06 Oct 2013 12:10:00 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1VSqty-0001HY-4E for emacs-devel@gnu.org; Sun, 06 Oct 2013 12:09:55 -0400 Original-Received: from mtaout21.012.net.il ([80.179.55.169]:55448) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VSqtx-0001HI-Sk for emacs-devel@gnu.org; Sun, 06 Oct 2013 12:09:50 -0400 Original-Received: from conversion-daemon.a-mtaout21.012.net.il by a-mtaout21.012.net.il (HyperSendmail v2007.08) id <0MU900N008UN3M00@a-mtaout21.012.net.il> for emacs-devel@gnu.org; Sun, 06 Oct 2013 19:09:48 +0300 (IDT) Original-Received: from HOME-C4E4A596F7 ([87.69.4.28]) by a-mtaout21.012.net.il (HyperSendmail v2007.08) with ESMTPA id <0MU900MFE8WCS5A0@a-mtaout21.012.net.il> for emacs-devel@gnu.org; Sun, 06 Oct 2013 19:09:48 +0300 (IDT) In-reply-to: <877gdqrc9u.fsf@flea.lifelogs.com> X-012-Sender: halo1@inter.net.il X-detected-operating-system: by eggs.gnu.org: Solaris 10 X-Received-From: 80.179.55.169 X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Original-Sender: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.devel:163910 Archived-At: > From: Ted Zlatanov > Date: Sun, 06 Oct 2013 05:15:09 -0400 > Cc: nettle-bugs@lists.lysator.liu.se > > This is the first cut of the Nettle integration for your review. Thanks. > +DEFUN ("nettle-available-p", Fnettle_available_p, Snettle_available_p, 0, 0, 0, > + doc: /* Return t if libnettle+libhogweed are available in this instance of Emacs. */) > + (void) > +{ > + return Qt; > +} For the record: this will have to be changed for MS-Windows, to support dynamic loading, like we do, e.g., in decompress.c. > +DEFUN ("nettle-hmac", Fnettle_hmac, Snettle_hmac, 3, 3, 0, > + doc: /* Hash INPUT string with HASH-METHOD and KEY into a unibyte string according to HMAC (RFC 2104). The first line of the doc string is too long. (There are others with similar problems.) > + digest = xzalloc (length); > + hmac_digest (outer_ctx, inner_ctx, state_ctx, alg, length, digest); > + > + ret = make_unibyte_string (digest, length); Instead of xzalloc, then make_unibyte_string, I think you should be able to allocate a string first, and then work on its SDATA. This will save you from at least one allocation. > + free (digest); > + free (state_ctx); > + free (outer_ctx); > + free (inner_ctx); We tend to use xfree, not free. > + sha1_mode = 0 == strcmp (SDATA (hash_method), "sha1"); > + sha256_mode = 0 == strcmp (SDATA (hash_method), "sha256"); Perhaps using Fstring_equal is better here, not sure. > + uint8_t *digest = xzalloc (outlength); ^^^^^^^ Why not 'unsigned char'? > + if (!rsa_keypair_from_der (&key, NULL, 0, SCHARS (public_key), SDATA (public_key)) && > + !rsa_keypair_from_sexp (&key, NULL, 0, SCHARS (public_key), SDATA (public_key))) The && should be at the beginning of a line, not at the end.