From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Paul Eggert Newsgroups: gmane.emacs.devel Subject: Re: Adding sha256 and sha512 to C? Date: Sat, 11 Jun 2011 09:02:36 -0700 Organization: UCLA Computer Science Department Message-ID: <4DF3919C.9070907@cs.ucla.edu> References: <19936.26998.559386.371174@priss.frightenedpiglet.com> <4DE072EE.4030303@cs.ucla.edu> <83mxi7b82v.fsf@gnu.org> <838vt8bxwh.fsf@gnu.org> <834o3wbdbw.fsf@gnu.org> NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-Trace: dough.gmane.org 1307808558 27188 80.91.229.12 (11 Jun 2011 16:09:18 GMT) X-Complaints-To: usenet@dough.gmane.org NNTP-Posting-Date: Sat, 11 Jun 2011 16:09:18 +0000 (UTC) Cc: sand@blarg.net, Leo , monnier@iro.umontreal.ca, emacs-devel@gnu.org To: Eli Zaretskii Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Sat Jun 11 18:09:13 2011 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([140.186.70.17]) by lo.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1QVQkJ-00021y-6n for ged-emacs-devel@m.gmane.org; Sat, 11 Jun 2011 18:09:11 +0200 Original-Received: from localhost ([::1]:45422 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1QVQkI-0000Vh-9B for ged-emacs-devel@m.gmane.org; Sat, 11 Jun 2011 12:09:10 -0400 Original-Received: from eggs.gnu.org ([140.186.70.92]:40362) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1QVQeC-0007QW-T4 for emacs-devel@gnu.org; Sat, 11 Jun 2011 12:02:54 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1QVQeB-0005Zw-CF for emacs-devel@gnu.org; Sat, 11 Jun 2011 12:02:52 -0400 Original-Received: from smtp.cs.ucla.edu ([131.179.128.62]:42562) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1QVQe8-0005ZL-Gf; Sat, 11 Jun 2011 12:02:48 -0400 Original-Received: from localhost (localhost.localdomain [127.0.0.1]) by smtp.cs.ucla.edu (Postfix) with ESMTP id 8CE5039E80F9; Sat, 11 Jun 2011 09:02:45 -0700 (PDT) X-Virus-Scanned: amavisd-new at smtp.cs.ucla.edu Original-Received: from smtp.cs.ucla.edu ([127.0.0.1]) by localhost (smtp.cs.ucla.edu [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id kOfbLmavPG4T; Sat, 11 Jun 2011 09:02:44 -0700 (PDT) Original-Received: from [192.168.1.10] (pool-71-189-109-235.lsanca.fios.verizon.net [71.189.109.235]) by smtp.cs.ucla.edu (Postfix) with ESMTPSA id 4F6B139E80F8; Sat, 11 Jun 2011 09:02:44 -0700 (PDT) User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.2.17) Gecko/20110516 Thunderbird/3.1.10 In-Reply-To: <834o3wbdbw.fsf@gnu.org> X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 3) X-Received-From: 131.179.128.62 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:140380 Archived-At: On 06/11/11 08:24, Eli Zaretskii wrote: > Like this: > > (sha2 OBJECT &optional BEG END BINARY ALGORITHM) > > where ALGORITHM can be sha-224, sha-256, etc. > > (We could have ALGORITHM the 3rd argument, if keeping a signature > compatible with sha1 is not important.) Or better yet: (crypto-hash-function ALGORITHM OBJECT &optional START END NOERROR BINARY) as was discussed in and the ensuing thread. The above suggestion removes the previously-proposed CODING-SYSTEM argument that Stefan didn't think was needed, which means that people who want md5's CODING-SYSTEM feature would have to invoke the md5 function directly. The advantage of this approach is that we don't pollute the Lisp namespace with one function name per algorithm. Some other comments: Please modify GNULIB_MODULES in Makefile.in to reflect the new dependencies. No need to use EMACS_UINT for digest_size. Please use plain 'int'. We prefer to not use unsigned types due to problems when they're used in comparisons. No need to use sizeof (char). It is always 1. Please write "F (ARGS)" rather than "F(ARGS)". When creating the digest the code should use make_unibyte_string rather than make_string. (This comment applies also to the original.) Please don't cast function pointers to void * and back, as that defeats the purpose of the C type checking. Instead, just use the unvarnished C types.