diff --git a/HISTORY b/HISTORY index 356b5ff4..31c448cf 100644 --- a/HISTORY +++ b/HISTORY @@ -8,7 +8,7 @@ SnapRAID HISTORY To convert you can use the new 'rehash' command. * Added RAID5/RAID6 mmx and sse2 implementations with unrolling by 4. They are a little faster than the previous unroll by 2. - * Added a hash seed to make hash values unique and not recognizable. + * Added a hash seed to make harder intentional collision attacks. 3.1 2013/5 ========== diff --git a/Makefile.am b/Makefile.am index 33c216d1..331358f9 100644 --- a/Makefile.am +++ b/Makefile.am @@ -32,8 +32,10 @@ noinst_HEADERS = \ state.h \ parity.h \ handle.h \ - murmurhash3.c \ - spookyhash2.c \ + murmur3.c \ + murmur3test.c \ + spooky2.c \ + spooky2test.c \ tommyarray.h \ tommychain.h \ tommyhash.h \ diff --git a/murmurhash3.c b/murmur3.c similarity index 90% rename from murmurhash3.c rename to murmur3.c index e7e46267..f3eb0c63 100644 --- a/murmurhash3.c +++ b/murmur3.c @@ -75,32 +75,39 @@ uint32_t c2 = 0xab0e9789; uint32_t c3 = 0x38b34ae5; uint32_t c4 = 0xa1e38b93; -void MurmurHash3_x86_128(const void* key, unsigned len, uint32_t seed, void* out) +void MurmurHash3_x86_128(const void* key, unsigned len, const uint8_t* seed, void* out) { const uint8_t* data = key; unsigned nblocks = len / 16; unsigned i; - uint32_t h1 = seed; - uint32_t h2 = seed; - uint32_t h3 = seed; - uint32_t h4 = seed; + uint32_t h1 = ((uint32_t*)seed)[0]; + uint32_t h2 = ((uint32_t*)seed)[1]; + uint32_t h3 = ((uint32_t*)seed)[2]; + uint32_t h4 = ((uint32_t*)seed)[3]; + +#if WORDS_BIGENDIAN + h1 = swap32(h1); + h2 = swap32(h2); + h3 = swap32(h3); + h4 = swap32(h4); +#endif const uint32_t* blocks = (const uint32_t*)data; /* body */ for(i=0;i