cvs commit: src/lib/libmd Makefile sha256.3 sha256.h sha256c.c shadriver.c src/sbin/md5 Makefile md5.c

Mark Murray markm at FreeBSD.ORG
Thu Mar 10 01:05:11 PST 2005


Colin Percival writes:
> > But they do have bugs fixed or are optimised.
> 
> Optimized?  Perhaps.  Bugs fixed?  Almost certainly not -- writing a
> hash implementation which works for all the test vectors while failing
> for some other data would be very difficult.  There's only one code
> path through the compression function, and only a very small number
> through the wrappers -- if you get something wrong, it's going to bite
> you every time.

I'm glad you said _almost_ certainly not.

Subtle edge cases can crop up in the most nasty ways when you move to 
different architectures, etc.

In other cases, assumptions about the test data can get you in trouble.

EG - I haven't tested this, but it looks like your code gets the bit 
count wrong for large data sets, as you are not using a uint64_t, you 
are using an array of uint32_t's, and dropping a size_t (== uint32_t)
in there. For memory based operations you will be fine for most of your 
life (I guess). For a very large file, you will likely give the wrong 
answer.

M
--
Mark Murray
iumop ap!sdn w,I idlaH




More information about the cvs-src mailing list