[ox/std] Shift away 4 lowest bits of random numbers generated in UUID,
as Xoroshiro128+ is apparently weaker for those bits
This commit is contained in:
parent
b576a7ec12
commit
06f6656c85
4
deps/ox/src/ox/std/uuid.cpp
vendored
4
deps/ox/src/ox/std/uuid.cpp
vendored
@ -25,7 +25,9 @@ Result<UUID> UUID::generate() noexcept {
|
||||
}
|
||||
UUID out;
|
||||
for (auto &v : out.m_value) {
|
||||
v = static_cast<uint8_t>(s_rand.gen() % 255);
|
||||
// shift away 4 lowest bits, as Xoroshiro128+ randomness is weaker there
|
||||
const auto rand = s_rand.gen() >> 4;
|
||||
v = static_cast<uint8_t>(rand % 255);
|
||||
}
|
||||
out.m_value[6] &= 0x0f;
|
||||
out.m_value[6] |= 4 << 4;
|
||||
|
Loading…
Reference in New Issue
Block a user