emacs-devel
[Top][All Lists]
Advanced

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

Re: Adding sha256 and sha512 to C?


From: Paul Eggert
Subject: Re: Adding sha256 and sha512 to C?
Date: Sat, 11 Jun 2011 09:02:36 -0700
User-agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.2.17) Gecko/20110516 Thunderbird/3.1.10

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 
<http://lists.gnu.org/archive/html/emacs-devel/2011-05/msg00872.html>
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.



reply via email to

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