[PATCH] Message digest test suite and incomplete MD4 support

Werner Koch wk@gnupg.org
Sat, 23 Nov 2002 12:39:00 +0100


On Sat, 23 Nov 2002 03:40:16 +0100, Simon Josefsson said:

> -    static u32 checked_algos[256/32];
> +    static u32 checked_algos[512/32];

Thanks.

> -    if( algo > 255 || !algo )
> +    if( algo > 512 || !algo )

It should be 511 or >=

> +// #define F(x, y, z) (((x) & (y)) | ((~x) & (z)))

[please don't use C99 comments]

>  #define F(x, y, z) ((z) ^ ((x) & ((y) ^ (z))))
>  #define G(x, y, z) (((x) & (y)) | ((x) & (z)) | ((y) & (z)))
>  #define H(x, y, z) ((x) ^ (y) ^ (z))
 
> -    memcpy( correct_words, data, 64 );
> -#endif
> +    u32 *in = (u32*)data;

This bears 2 problems: It does not work on big endian machines and
DATA might not be aligned on a 4 byte boundary which results in a bus
error or unpleasant software emulation of the instructions by the CPU
(I once got complains from a Alpha admin, that I should fix my programs
because the kernel log was full with unaligned instructions warnings ;-).

I have fixed and tested this for ia32.

Thanks,

   Werner