]> git.ipfire.org Git - thirdparty/ipxe.git/commit
[libc] Use wall clock time as seed for the (non-cryptographic) RNG 1052/head
authorMichael Brown <mcb30@ipxe.org>
Fri, 6 Oct 2023 11:43:02 +0000 (12:43 +0100)
committerMichael Brown <mcb30@ipxe.org>
Fri, 6 Oct 2023 11:50:43 +0000 (12:50 +0100)
commitff0f860483e344f1af633f94696ff7bc1854611f
tree65448287a264184b9f8c911cc1cbc992f24d7976
parent8b14652e506d99499cfbeaed0df07d6a83ec029e
[libc] Use wall clock time as seed for the (non-cryptographic) RNG

We currently use the number of timer ticks since power-on as a seed
for the non-cryptographic RNG implemented by random().  Since iPXE is
often executed directly after power-on, and since the timer tick
resolution is generally low, this can often result in identical seed
values being used on each cold boot attempt.

As of commit 41f786c ("[settings] Add "unixtime" builtin setting to
expose the current time"), the current wall-clock time is always
available within the default build of iPXE.  Use this time instead, to
introduce variability between cold boot attempts on the same host.
(Note that variability between different hosts is obtained by using
the MAC address as an additional seed value.)

This has no effect on the separate DRBG used by cryptographic code.

Suggested-by: Heiko <heik0@xs4all.nl>
Signed-off-by: Michael Brown <mcb30@ipxe.org>
src/core/random.c