aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJouni Malinen <j@w1.fi>2009-11-21 18:17:24 (GMT)
committerJouni Malinen <j@w1.fi>2009-11-22 19:40:46 (GMT)
commit5aceab7cb52ea90c1cc4c366632133b78ace1615 (patch)
treeef20a5cf68e41a08cba68773011dfe4d2570d8d6
parent456fe11d1b92bced01df39d04aa5ba005c65dad5 (diff)
downloadhostap-06-5aceab7cb52ea90c1cc4c366632133b78ace1615.zip
hostap-06-5aceab7cb52ea90c1cc4c366632133b78ace1615.tar.gz
hostap-06-5aceab7cb52ea90c1cc4c366632133b78ace1615.tar.bz2
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> (cherry picked from commit 6d798e8b7e748935e10262566dc9b6ff02ac7d31)
-rw-r--r--src/crypto/sha1.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/src/crypto/sha1.c b/src/crypto/sha1.c
index ceec1a4..141e4f4 100644
--- a/src/crypto/sha1.c
+++ b/src/crypto/sha1.c
@@ -606,8 +606,8 @@ static void SHA1Transform(u32 state[5], const unsigned char buffer[64])
} CHAR64LONG16;
CHAR64LONG16* block;
#ifdef SHA1HANDSOFF
- u32 workspace[16];
- block = (CHAR64LONG16 *) workspace;
+ CHAR64LONG16 workspace;
+ block = &workspace;
os_memcpy(block, buffer, 64);
#else
block = (CHAR64LONG16 *) buffer;