Yet more fallout from the 16-colour changes. I think by this time
[u/mdw/putty] / mac / macnoise.c
CommitLineData
d4af3006 1/*
2 * Noise generation for PuTTY's cryptographic random number
3 * generator.
4 */
5
6#include <Types.h>
7#include <Timer.h>
8
9#include "putty.h"
10#include "ssh.h"
11#include "storage.h"
12
13/*
14 * This function is called once, at PuTTY startup, and will do some
15 * seriously silly things like listing directories and getting disk
16 * free space and a process snapshot.
17 */
18
19void noise_get_heavy(void (*func) (void *, int))
20{
21
22 read_random_seed(func);
23 /* Update the seed immediately, in case another instance uses it. */
24 random_save_seed();
25}
26
27void random_save_seed(void)
28{
29 int len;
30 void *data;
31
32 if (random_active) {
33 random_get_savedata(&data, &len);
34 write_random_seed(data, len);
35 sfree(data);
36 }
37}
38
39/*
40 * This function is called every time the random pool needs
41 * stirring, and will acquire the system time.
42 */
43void noise_get_light(void (*func) (void *, int))
44{
45 UnsignedWide utc;
46
47 Microseconds(&utc);
48 func(&utc, sizeof(utc));
49}
50
51/*
52 * This function is called on every keypress or mouse move, and
53 * will add the current time to the noise pool. It gets the scan
54 * code or mouse position passed in, and adds that too.
55 */
56void noise_ultralight(unsigned long data)
57{
58 UnsignedWide utc;
59
60 Microseconds(&utc);
61 random_add_noise(&utc, sizeof(utc));
62 random_add_noise(&data, sizeof(data));
63}
64
65/*
66 * Local Variables:
67 * c-file-style: "simon"
68 * End:
69 */