|
|
|
@ -311,7 +311,7 @@ uint32_t hashlittle( const void *key, size_t length, uint32_t initval)
|
|
|
|
* rest of the string. Every machine with memory protection I've seen
|
|
|
|
* rest of the string. Every machine with memory protection I've seen
|
|
|
|
* does it on word boundaries, so is OK with this. But VALGRIND will
|
|
|
|
* does it on word boundaries, so is OK with this. But VALGRIND will
|
|
|
|
* still catch it and complain. The masking trick does make the hash
|
|
|
|
* still catch it and complain. The masking trick does make the hash
|
|
|
|
* noticably faster for short strings (like English words).
|
|
|
|
* noticeably faster for short strings (like English words).
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
#ifndef VALGRIND
|
|
|
|
#ifndef VALGRIND
|
|
|
|
|
|
|
|
|
|
|
|
@ -670,7 +670,7 @@ void hashlittle2(
|
|
|
|
* rest of the string. Every machine with memory protection I've seen
|
|
|
|
* rest of the string. Every machine with memory protection I've seen
|
|
|
|
* does it on word boundaries, so is OK with this. But VALGRIND will
|
|
|
|
* does it on word boundaries, so is OK with this. But VALGRIND will
|
|
|
|
* still catch it and complain. The masking trick does make the hash
|
|
|
|
* still catch it and complain. The masking trick does make the hash
|
|
|
|
* noticably faster for short strings (like English words).
|
|
|
|
* noticeably faster for short strings (like English words).
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
#ifndef VALGRIND
|
|
|
|
#ifndef VALGRIND
|
|
|
|
|
|
|
|
|
|
|
|
@ -846,7 +846,7 @@ uint32_t hashbig( const void *key, size_t length, uint32_t initval)
|
|
|
|
* rest of the string. Every machine with memory protection I've seen
|
|
|
|
* rest of the string. Every machine with memory protection I've seen
|
|
|
|
* does it on word boundaries, so is OK with this. But VALGRIND will
|
|
|
|
* does it on word boundaries, so is OK with this. But VALGRIND will
|
|
|
|
* still catch it and complain. The masking trick does make the hash
|
|
|
|
* still catch it and complain. The masking trick does make the hash
|
|
|
|
* noticably faster for short strings (like English words).
|
|
|
|
* noticeably faster for short strings (like English words).
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
#ifndef VALGRIND
|
|
|
|
#ifndef VALGRIND
|
|
|
|
|
|
|
|
|
|
|
|
@ -978,17 +978,18 @@ void driver2(void)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
for (j=0; j<8; ++j) /*------------------------ for each input bit, */
|
|
|
|
for (j=0; j<8; ++j) /*------------------------ for each input bit, */
|
|
|
|
{
|
|
|
|
{
|
|
|
|
for (m=1; m<8; ++m) /*------------ for serveral possible initvals, */
|
|
|
|
for (m = 1; m < 8; ++m) /*------------ for several possible initvals, */
|
|
|
|
{
|
|
|
|
{
|
|
|
|
for (l = 0; l < HASHSTATE; ++l)
|
|
|
|
for (l = 0; l < HASHSTATE; ++l)
|
|
|
|
e[l] = f[l] = g[l] = h[l] = x[l] = y[l] = ~((uint32_t)0);
|
|
|
|
e[l] = f[l] = g[l] = h[l] = x[l] = y[l] = ~((uint32_t)0);
|
|
|
|
|
|
|
|
|
|
|
|
/*---- check that every output bit is affected by that input bit */
|
|
|
|
/*---- check that every output bit is affected by that input bit */
|
|
|
|
for (k=0; k<MAXPAIR; k+=2)
|
|
|
|
for (k = 0; k < MAXPAIR; k += 2) {
|
|
|
|
{
|
|
|
|
|
|
|
|
uint32_t finished = 1;
|
|
|
|
uint32_t finished = 1;
|
|
|
|
/* keys have one bit different */
|
|
|
|
/* keys have one bit different */
|
|
|
|
for (l=0; l<hlen+1; ++l) {a[l] = b[l] = (uint8_t)0;}
|
|
|
|
for (l = 0; l < hlen + 1; ++l) {
|
|
|
|
|
|
|
|
a[l] = b[l] = (uint8_t)0;
|
|
|
|
|
|
|
|
}
|
|
|
|
/* have a and b be two keys differing in only one bit */
|
|
|
|
/* have a and b be two keys differing in only one bit */
|
|
|
|
a[i] ^= (k << j);
|
|
|
|
a[i] ^= (k << j);
|
|
|
|
a[i] ^= (k >> (8 - j));
|
|
|
|
a[i] ^= (k >> (8 - j));
|
|
|
|
@ -997,27 +998,28 @@ void driver2(void)
|
|
|
|
b[i] ^= ((k + 1) >> (8 - j));
|
|
|
|
b[i] ^= ((k + 1) >> (8 - j));
|
|
|
|
d[0] = hashlittle(b, hlen, m);
|
|
|
|
d[0] = hashlittle(b, hlen, m);
|
|
|
|
/* check every bit is 1, 0, set, and not set at least once */
|
|
|
|
/* check every bit is 1, 0, set, and not set at least once */
|
|
|
|
for (l=0; l<HASHSTATE; ++l)
|
|
|
|
for (l = 0; l < HASHSTATE; ++l) {
|
|
|
|
{
|
|
|
|
|
|
|
|
e[l] &= (c[l] ^ d[l]);
|
|
|
|
e[l] &= (c[l] ^ d[l]);
|
|
|
|
f[l] &= ~(c[l] ^ d[l]);
|
|
|
|
f[l] &= ~(c[l] ^ d[l]);
|
|
|
|
g[l] &= c[l];
|
|
|
|
g[l] &= c[l];
|
|
|
|
h[l] &= ~c[l];
|
|
|
|
h[l] &= ~c[l];
|
|
|
|
x[l] &= d[l];
|
|
|
|
x[l] &= d[l];
|
|
|
|
y[l] &= ~d[l];
|
|
|
|
y[l] &= ~d[l];
|
|
|
|
if (e[l]|f[l]|g[l]|h[l]|x[l]|y[l]) finished=0;
|
|
|
|
if (e[l] | f[l] | g[l] | h[l] | x[l] | y[l])
|
|
|
|
|
|
|
|
finished = 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (finished) break;
|
|
|
|
if (finished)
|
|
|
|
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (k>z) z=k;
|
|
|
|
if (k > z)
|
|
|
|
if (k==MAXPAIR)
|
|
|
|
z = k;
|
|
|
|
{
|
|
|
|
if (k == MAXPAIR) {
|
|
|
|
printf("Some bit didn't change: ");
|
|
|
|
printf("Some bit didn't change: ");
|
|
|
|
printf("%.8x %.8x %.8x %.8x %.8x %.8x ",
|
|
|
|
printf("%.8x %.8x %.8x %.8x %.8x %.8x ", e[0], f[0], g[0], h[0], x[0], y[0]);
|
|
|
|
e[0],f[0],g[0],h[0],x[0],y[0]);
|
|
|
|
|
|
|
|
printf("i %d j %d m %d len %d\n", i, j, m, hlen);
|
|
|
|
printf("i %d j %d m %d len %d\n", i, j, m, hlen);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (z==MAXPAIR) goto done;
|
|
|
|
if (z == MAXPAIR)
|
|
|
|
|
|
|
|
goto done;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|