mirror of
https://github.com/wiire-a/pixiewps.git
synced 2025-07-27 07:44:36 +02:00
Fixed issue with previous changes in glibc PRNG
With the previous changes the PRNG was faster but didn't work on all instances.
This commit is contained in:
parent
7acd739002
commit
0584a78d9b
@ -26,7 +26,9 @@ static inline uint32_t *glibc_fast_nonce(uint32_t seed, uint32_t *dest)
|
||||
|
||||
/* This does: seed = (16807LL * seed) % 0x7fffffff
|
||||
using the sum of digits method which works for mod N, base N+1 */
|
||||
const uint64_t p = 16807ULL * seed; /* Seed is always positive (31 bits) */
|
||||
/* Doesn't work for seed = 0x7fffffff or 0xfffffffe */
|
||||
uint64_t p = 16807ULL * seed;
|
||||
p = (p >> 31) + (p & 0x7fffffff);
|
||||
seed = (p >> 31) + (p & 0x7fffffff);
|
||||
}
|
||||
dest[0] = word0 >> 1;
|
||||
@ -45,7 +47,9 @@ static inline uint32_t glibc_fast_seed(uint32_t seed)
|
||||
|
||||
/* This does: seed = (16807LL * seed) % 0x7fffffff
|
||||
using the sum of digits method which works for mod N, base N+1 */
|
||||
const uint64_t p = 16807ULL * seed; /* Seed is always positive (31 bits) */
|
||||
/* Doesn't work for seed = 0x7fffffff or 0xfffffffe */
|
||||
uint64_t p = 16807ULL * seed;
|
||||
p = (p >> 31) + (p & 0x7fffffff);
|
||||
seed = (p >> 31) + (p & 0x7fffffff);
|
||||
}
|
||||
return (word0 + seed * glibc_seed_tbl[33]) >> 1;
|
||||
|
Loading…
x
Reference in New Issue
Block a user