diff --git a/main.c b/main.c index 76b492f..6984274 100644 --- a/main.c +++ b/main.c @@ -182,6 +182,26 @@ process_line(char *start, char *end) usb_printf("line: %.*s", end - start, start); } +/* + * Seed the randomness from the radio. This is not a great + * seed, and is hard to gauge how much randomness is really + * there. Assuming about 1 bit per 8 bits looks pretty safe, + * so add 256 * 8 / 32 words. + */ +static void +radio_seed_rng(void) +{ +#if 1 + uint32_t v; + int i; + + for (i = 0; i < 256 * 8 / 32; i++) { + v = Radio.Random(); + strobe_seed_prng((uint8_t *)&v, sizeof v); + } +#endif +} + int main(void) { @@ -191,6 +211,10 @@ main(void) BoardInitMcu(); + Radio.Init(&revents); + + radio_seed_rng(); + strobe_rng_save(); /* turn on LED */ @@ -206,17 +230,8 @@ main(void) usb_printf("\r\n"); #endif - Radio.Init(&revents); - uint32_t v; - v = Radio.Random(); - usb_printf("rr: %#x\r\n", v); - v = Radio.Random(); - usb_printf("rr: %#x\r\n", v); - v = Radio.Random(); - usb_printf("rr: %#x\r\n", v); - usb_printf("gs: %#x\r\n", Radio.GetStatus()); usb_printf("set modem\r\n");