2 * Noise generation for PuTTY's cryptographic random number
15 * This function is called once, at PuTTY startup, and will do some
16 * seriously silly things like listing directories and getting disk
17 * free space and a process snapshot.
20 static void noise_get_processes(void (*func) (void *, int))
22 ProcessSerialNumber psn = {0, kNoProcess};
27 if (psn.highLongOfPSN == 0 && psn.lowLongOfPSN == kNoProcess) return;
28 info.processInfoLength = sizeof(info);
29 info.processName = NULL;
30 info.processAppSpec = NULL;
31 GetProcessInformation(&psn, &info);
32 func(&info, sizeof(info));
36 void noise_get_heavy(void (*func) (void *, int))
39 noise_get_light(func);
40 noise_get_processes(func);
41 read_random_seed(func);
42 /* Update the seed immediately, in case another instance uses it. */
46 void random_save_seed(void)
52 random_get_savedata(&data, &len);
53 write_random_seed(data, len);
59 * This function is called every time the random pool needs
60 * stirring, and will acquire the system time.
62 void noise_get_light(void (*func) (void *, int))
67 func(&utc, sizeof(utc));
71 * This function is called on every keypress or mouse move, and
72 * will add the current time to the noise pool. It gets the scan
73 * code or mouse position passed in, and adds that too.
75 void noise_ultralight(unsigned long data)
80 random_add_noise(&utc, sizeof(utc));
81 random_add_noise(&data, sizeof(data));
86 * c-file-style: "simon"