mirror of
https://github.com/zeek/zeek.git
synced 2025-10-02 14:48:21 +00:00
Switch file UID hashing from md5 to highwayhash.
This commit switches UID hashing from md5 to a highway hash. It also moves the salt value out of the file plugin - and makes it installation-specific instead - it is moved to the global namespace. There now are digest hash functions to make "static" installation-specific hashes that are stable over workers available to everyone; hashes can be 64, 128 or 256 bits in size. Due to the fact that we switch the file hashing algorithm, all file hashes change. The underlyigng algorithm that is used for hashing is highwayhash-128, which is significantly faster than md5.
This commit is contained in:
parent
bc546634d1
commit
3bce313b12
153 changed files with 953 additions and 799 deletions
24
src/Hash.cc
24
src/Hash.cc
|
@ -6,6 +6,8 @@
|
|||
#include "digest.h"
|
||||
#include "Reporter.h"
|
||||
#include "BroString.h"
|
||||
#include "Val.h" // needed for const.bif
|
||||
#include "const.bif.netvar_h"
|
||||
|
||||
#include "highwayhash/sip_hash.h"
|
||||
#include "highwayhash/highwayhash_target.h"
|
||||
|
@ -36,6 +38,11 @@ void KeyedHash::InitializeSeeds(const std::array<uint32_t, SEED_INIT_SIZE>& seed
|
|||
seeds_initialized = true;
|
||||
}
|
||||
|
||||
void KeyedHash::InitOptions()
|
||||
{
|
||||
calculate_digest(Hash_SHA256, BifConst::digest_salt->Bytes(), BifConst::digest_salt->Len(), reinterpret_cast<unsigned char*>(cluster_highwayhash_key));
|
||||
}
|
||||
|
||||
hash64_t KeyedHash::Hash64(const void* bytes, uint64_t size)
|
||||
{
|
||||
return highwayhash::SipHash(shared_siphash_key, reinterpret_cast<const char *>(bytes), size);
|
||||
|
@ -51,6 +58,23 @@ void KeyedHash::Hash256(const void* bytes, uint64_t size, hash256_t* result)
|
|||
highwayhash::InstructionSets::Run<highwayhash::HighwayHash>(shared_highwayhash_key, reinterpret_cast<const char *>(bytes), size, result);
|
||||
}
|
||||
|
||||
hash64_t KeyedHash::StaticHash64(const void* bytes, uint64_t size)
|
||||
{
|
||||
hash64_t result;
|
||||
highwayhash::InstructionSets::Run<highwayhash::HighwayHash>(cluster_highwayhash_key, reinterpret_cast<const char *>(bytes), size, &result);
|
||||
return result;
|
||||
}
|
||||
|
||||
void KeyedHash::StaticHash128(const void* bytes, uint64_t size, hash128_t* result)
|
||||
{
|
||||
highwayhash::InstructionSets::Run<highwayhash::HighwayHash>(cluster_highwayhash_key, reinterpret_cast<const char *>(bytes), size, result);
|
||||
}
|
||||
|
||||
void KeyedHash::StaticHash256(const void* bytes, uint64_t size, hash256_t* result)
|
||||
{
|
||||
highwayhash::InstructionSets::Run<highwayhash::HighwayHash>(cluster_highwayhash_key, reinterpret_cast<const char *>(bytes), size, result);
|
||||
}
|
||||
|
||||
void init_hash_function()
|
||||
{
|
||||
// Make sure we have already called init_random_seed().
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue