/**
* Secret key allocated randomly with chunk_hash_seed().
*/
-static u_char key[16] = {};
+static u_char hash_key[16] = {};
/**
* Static key used in case predictable hash values are required.
fd = open("/dev/urandom", O_RDONLY);
if (fd >= 0)
{
- while (done < sizeof(key))
+ while (done < sizeof(hash_key))
{
- len = read(fd, key + done, sizeof(key) - done);
+ len = read(fd, hash_key + done, sizeof(hash_key) - done);
if (len < 0)
{
break;
close(fd);
}
/* on error we use random() to generate the key (better than nothing) */
- if (done < sizeof(key))
+ if (done < sizeof(hash_key))
{
srandom(time(NULL) + getpid());
- for (; done < sizeof(key); done++)
+ for (; done < sizeof(hash_key); done++)
{
- key[done] = (u_char)random();
+ hash_key[done] = (u_char)random();
}
}
seeded = TRUE;
uint32_t chunk_hash_inc(chunk_t chunk, uint32_t hash)
{
/* we could use a mac of the previous hash, but this is faster */
- return chunk_mac_inc(chunk, key, ((uint64_t)hash) << 32 | hash);
+ return chunk_mac_inc(chunk, hash_key, ((uint64_t)hash) << 32 | hash);
}
/**
*/
uint32_t chunk_hash(chunk_t chunk)
{
- return chunk_mac(chunk, key);
+ return chunk_mac(chunk, hash_key);
}
/**