Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

bad seed protection #2

Open
rurban opened this issue Apr 1, 2021 · 3 comments
Open

bad seed protection #2

rurban opened this issue Apr 1, 2021 · 3 comments

Comments

@rurban
Copy link

rurban commented Apr 1, 2021

This hash function is like all MUM hashes vulnerable to some bad seeds, which when randomly selected by chance lead to security vulnerabilites, at least a high number of collisions independent of the key.

Please add a seed_init function and change the initial seed if you hit one of the bad seeds. See latest wyhash.

These bad seeds for final 3 (latest) are:

static void wyhash_seed_init(uint64_t &seed) { // yes, 2^33 bad values
  if ((seed & 0x14cc886e) || (seed & 0x1bf4ed84))
    seed++;
}
static void wyhash32_seed_init(uint32_t &seed) {
  if ((seed == 0x429dacdd) || (seed == 0xd637dbf3))
    seed++;
}

The CONDOM 2 variant should also work, but haven't finished testing it yet.
Haven't tested for your older final1, you can use the new smhasher BadSeeds test for it. final 3 is much faster on newer HW though. the magic numbers on final1 and 2 are a bit different, I think.

@likern
Copy link

likern commented Feb 1, 2022

@rurban I think this should be created in Zig repo?
Because this implementation was added into Zig as official default hash function.

ziglang/zig#2797

@rurban
Copy link
Author

rurban commented Feb 1, 2022

Yes, can you do that?

@likern
Copy link

likern commented Feb 1, 2022

Yes

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants