mirror of
https://github.com/roc-lang/roc.git
synced 2025-07-18 20:15:05 +00:00
Seed Dict and Set
This changes Dict and Set to have a compilation depedent seed. The seed is not exposed to userland in anyway. This gets a much more DOS resistant Dict and Set with no cost.
This commit is contained in:
parent
8ecbd8c071
commit
b4c359588e
11 changed files with 69 additions and 30 deletions
|
@ -436,3 +436,12 @@ test "increfC, static data" {
|
|||
increfRcPtrC(ptr_to_refcount, 2);
|
||||
try std.testing.expectEqual(mock_rc, REFCOUNT_MAX_ISIZE);
|
||||
}
|
||||
|
||||
// This returns a compilation dependent pseudo random seed for dictionaries.
|
||||
// The seed is the address of this function.
|
||||
// This avoids all roc Dicts using a known seed and being trivial to DOS.
|
||||
// Still not as secure as true random, but a lot better.
|
||||
// This value must not change between calls unless Dict is changed to store the seed on creation.
|
||||
pub fn dictPseudoSeed() callconv(.C) u64 {
|
||||
return @intCast(u64, @ptrToInt(dictPseudoSeed));
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue