mirror of
https://git.tartarus.org/simon/putty.git
synced 2025-07-15 10:07:39 -05:00
Label random-noise sources with an enum of ids.
The upcoming PRNG revamp will want to tell noise sources apart, so that it can treat them all fairly. So I've added an extra parameter to noise_ultralight and random_add_noise, which takes values in an enumeration covering all the vague classes of entropy source I'm collecting. In this commit, though, it's simply ignored.
This commit is contained in:
@ -121,16 +121,16 @@ void noise_regular(void)
|
||||
|
||||
if ((fd = open("/proc/meminfo", O_RDONLY)) >= 0) {
|
||||
while ( (ret = read(fd, buf, sizeof(buf))) > 0)
|
||||
random_add_noise(buf, ret);
|
||||
random_add_noise(NOISE_SOURCE_MEMINFO, buf, ret);
|
||||
close(fd);
|
||||
}
|
||||
if ((fd = open("/proc/stat", O_RDONLY)) >= 0) {
|
||||
while ( (ret = read(fd, buf, sizeof(buf))) > 0)
|
||||
random_add_noise(buf, ret);
|
||||
random_add_noise(NOISE_SOURCE_STAT, buf, ret);
|
||||
close(fd);
|
||||
}
|
||||
getrusage(RUSAGE_SELF, &rusage);
|
||||
random_add_noise(&rusage, sizeof(rusage));
|
||||
random_add_noise(NOISE_SOURCE_RUSAGE, &rusage, sizeof(rusage));
|
||||
}
|
||||
|
||||
/*
|
||||
@ -138,10 +138,10 @@ void noise_regular(void)
|
||||
* will add the current time to the noise pool. It gets the scan
|
||||
* code or mouse position passed in, and adds that too.
|
||||
*/
|
||||
void noise_ultralight(unsigned long data)
|
||||
void noise_ultralight(NoiseSourceId id, unsigned long data)
|
||||
{
|
||||
struct timeval tv;
|
||||
gettimeofday(&tv, NULL);
|
||||
random_add_noise(&tv, sizeof(tv));
|
||||
random_add_noise(&data, sizeof(data));
|
||||
random_add_noise(NOISE_SOURCE_TIME, &tv, sizeof(tv));
|
||||
random_add_noise(id, &data, sizeof(data));
|
||||
}
|
||||
|
Reference in New Issue
Block a user