mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-09-08 18:46:03 +00:00
AK: Implement SipHash as the default hash algorithm for most use cases
SipHash is highly HashDoS-resistent, initialized with a random seed at startup (i.e. non-deterministic) and usable for security-critical use cases with large enough parameters. We just use it because it's reasonably secure with parameters 1-3 while having excellent properties and not being significantly slower than before.
This commit is contained in:
parent
5e15c29e22
commit
9a026fc8d5
Notes:
sideshowbarker
2024-07-17 12:02:22 +09:00
Author: https://github.com/kleinesfilmroellchen
Commit: 9a026fc8d5
Pull-request: https://github.com/SerenityOS/serenity/pull/21069
Reviewed-by: https://github.com/alimpfard
9 changed files with 282 additions and 11 deletions
|
@ -10,6 +10,10 @@
|
|||
|
||||
namespace AK {
|
||||
|
||||
// FIXME: This hashing algorithm isn't well-known and may not be good at all.
|
||||
// We can't use SipHash since that depends on runtime parameters,
|
||||
// but some string hashes like IPC endpoint magic numbers need to be deterministic.
|
||||
// Maybe use a SipHash with a statically-known key?
|
||||
constexpr u32 string_hash(char const* characters, size_t length, u32 seed = 0)
|
||||
{
|
||||
u32 hash = seed;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue