git: 480928ae657d - main - random: Exclude the timestamp from healthtest for pure sources
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Mon, 08 Sep 2025 15:26:35 UTC
The branch main has been updated by markj: URL: https://cgit.FreeBSD.org/src/commit/?id=480928ae657d81e41f8c10837cd1cf0ca87b14ae commit 480928ae657d81e41f8c10837cd1cf0ca87b14ae Author: Mark Johnston <markj@FreeBSD.org> AuthorDate: 2025-09-08 14:46:12 +0000 Commit: Mark Johnston <markj@FreeBSD.org> CommitDate: 2025-09-08 15:21:43 +0000 random: Exclude the timestamp from healthtest for pure sources So-called pure sources provide entropy at regular intervals, so the timestamp counter provides little entropy. Exclude it from health testing for such sources. Reviewed by: cem, emaste MFC after: 2 weeks Sponsored by: Stormshield Sponsored by: Klara, Inc. Differential Revision: https://reviews.freebsd.org/D52233 --- sys/dev/random/random_harvestq.c | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/sys/dev/random/random_harvestq.c b/sys/dev/random/random_harvestq.c index c308f6f80d59..2d7af254c52c 100644 --- a/sys/dev/random/random_harvestq.c +++ b/sys/dev/random/random_harvestq.c @@ -343,7 +343,17 @@ copy_event(uint32_t dst[static HARVESTSIZE + 1], { memset(dst, 0, sizeof(uint32_t) * (HARVESTSIZE + 1)); memcpy(dst, event->he_entropy, event->he_size); - dst[HARVESTSIZE] = event->he_somecounter; + if (event->he_source <= RANDOM_ENVIRONMENTAL_END) { + /* + * For pure entropy sources the timestamp counter is generally + * quite determinstic since samples are taken at regular + * intervals, so does not contribute much to the entropy. To + * make health tests more effective, exclude it from the sample, + * since it might otherwise defeat the health tests in a + * scenario where the source is stuck. + */ + dst[HARVESTSIZE] = event->he_somecounter; + } } static void