scsh-hackers
[Top] [All Lists]

Re: [Scsh-hackers] md5 for scsh

To: Martin Gasbichler <gasbichl@informatik.uni-tuebingen.de>
Subject: Re: [Scsh-hackers] md5 for scsh
From: Michel Schinz <Michel.Schinz@epfl.ch>
Date: Thu Jun 20 23:57:02 2002
Cc: scsh-hackers <scsh-hackers@lists.sourceforge.net>
List-id: Discussion among the implementors <scsh-hackers.lists.sourceforge.net>
Sender: scsh-hackers-admin@lists.sourceforge.net
Martin Gasbichler <gasbichl@informatik.uni-tuebingen.de> writes:

> I've written a set of bindings for the MD5 routines provided by
> RSA. I've taken the C code included in the FreeBSD distribution.
> 
> My interface currently looks as follows:
> 
> The low-level procedures work on a "context":
> 
> (make-md5-context) -> md5-context
> (md5-context? obj) -> boolean
> (init-md5-context! md5-context) -> unspecific
> (update-md5-context! md5-context string) -> unspecific
> (pad-md5-context! md5-context) -> unspecific

I've a first question here: Is it really useful to have separate
creation (make-md5-context) and initialisation (init-md5-context!)
functions? Wouldn't it be simpler if we had only one
create-and-initialise function? The only disadvantage I could see with
a unique function is that you could not re-initialise an md5 context,
but creating a new one is always possible, and unless it's very
expensive, it should be OK.

> To obtain the actual result of the algorithm, the next procedure turns
> a md5-context into a md5-digit:
> 
> (md5-context->md5-digest md5-context) -> md5-digit
> 
> Two pairs of procedures exist to convert a md5-digit to external
> representations and back:

(I guess the three "md5-digit" above should be "md5-digest")

> (md5-digest->number md5-digest) -> number
> (md5-digest->string md5-digest) -> string
> (string->md5-digest string) -> md5-digest
> (number->md5-digest number) -> md5-digest

Other question here: why have a separate type for md5-digest? Why not
use Scheme bignums directly, which could then be converted to and from
strings using standard R5RS functions?

Also, I do not really see the aim of "string->md5-digest" and
"number->md5-digest" since apparently the only thing you can do with
the returned md5-digest is convert it back to a number or a string.

> The following high-level procedures compute digests for strings and
> ports:
> 
> (md5-digest-for-string string) -> md5-digest
> (md5-digest-for-string port [buffersize]) -> md5-digest

(I guess the second one is called "md5-digest-for-port", no?)

It might be nice to provide an "md5-digest-for-file" procedure, taking
a file-name as argument, I guess it's a pretty common operation.

[...]

> Comments? Suggestions? Anybody alive?

Alive, yes, and thankful for all you (and the other authors) did and
do for scsh. Thanks.

As a side-remark, I would add that sometimes one needs to perform
checksums but without the cryptographic guarantees that MD5 gives. In
these cases, one can use checksum algorithms which are much much
faster than MD5. A good example is the FNV checksum algorithm [1],
which appears to have a very low probability of collision, like MD5,
while being faster and a lot easier to compute. Maybe also having this
one in scsh would be nice.

[1] http://www.isthe.com/chongo/tech/comp/fnv/

Michel.


<Prev in Thread] Current Thread [Next in Thread>