Fix bug where only 16 bits of entropy was used
Always use aesrand_getword() & 0xFFFFFFFF not 0xFFFF. This was causing the groups used over multiple runs of ZMap to have identical generators too often.
This commit is contained in:
parent
69fe56864b
commit
0e03d170e6
@ -126,7 +126,8 @@ static int check_coprime(uint64_t check, const cyclic_group_t *group)
|
||||
static uint64_t find_primroot(const cyclic_group_t *group)
|
||||
{
|
||||
// what luck, rand() returns a uint32_t!
|
||||
uint32_t candidate = (uint32_t) aesrand_getword() & 0xFFFF;
|
||||
uint32_t candidate = (uint32_t) aesrand_getword() & 0xFFFFFFFF;
|
||||
printf("Candidate: %u\n", (unsigned) candidate);
|
||||
while(check_coprime(candidate, group) != COPRIME) {
|
||||
++candidate;
|
||||
}
|
||||
@ -186,14 +187,14 @@ int cyclic_init(uint32_t primroot_, uint32_t current_)
|
||||
primroot = find_primroot(cur_group);
|
||||
} while (primroot >= (1LL << 32));
|
||||
log_debug(LSRC, "primitive root: %lld", primroot);
|
||||
current = (uint32_t) aesrand_getword() & 0xFFFF;
|
||||
current = (uint32_t) aesrand_getword() & 0xFFFFFFFF;
|
||||
log_debug(LSRC, "starting point: %lld", current);
|
||||
} else {
|
||||
primroot = primroot_;
|
||||
log_debug(LSRC, "primitive root %lld specified by caller",
|
||||
primroot);
|
||||
if (!current_) {
|
||||
current = (uint32_t) aesrand_getword() & 0xFFFF;
|
||||
current = (uint32_t) aesrand_getword() & 0xFFFFFFFF;
|
||||
log_debug(LSRC, "no cyclic starting point, "
|
||||
"selected random startpoint: %lld",
|
||||
current);
|
||||
|
Loading…
Reference in New Issue
Block a user