Fix strict aliasing issue with the internal SHA-1 implementation
authorJouni Malinen <j@w1.fi>
Sat, 21 Nov 2009 18:17:24 +0000 (20:17 +0200)
committerJouni Malinen <j@w1.fi>
Sat, 21 Nov 2009 18:17:24 +0000 (20:17 +0200)
commit6d798e8b7e748935e10262566dc9b6ff02ac7d31
tree02706fe49e5c1d98f1fefe622d2771f79854e42d
parent11ff95783ec7746feaf579ede37714af16a68d7e
Fix strict aliasing issue with the internal SHA-1 implementation

Need to define the workspace buffer properly to allow compiler to handle
strict aliasing between the incoming unsigned char[64] buffer as an u32
array. The previous version built with strict aliasing enabled can
result in SHA-1 producing incorrect results and consequently, with
4-way handshake failing.

This is based on a report and patch from Dan Williams <dcbw@redhat.com>
but with a different type (the union) used as a fix to avoid needing
extra type casting.

Discovered as part of the investigation of:

https://bugzilla.redhat.com/show_bug.cgi?id=494262#c32

if sha1 is built with gcc without turning off strict aliasing, it will
fail to correctly generate the hashes and will fail its own testcases as
well.

Signed-off-by: Dan Williams <dcbw@redhat.com>
src/crypto/sha1-internal.c