opnsense-src/sys/dev/random
Mark Johnston 108e4f3142 armv8rng: Fix an inverted test in random_rndr_read_one()
If we get a random number, the NZCV is set to 0b0000.  Then
"cset %w1, ne" will test whether Z == 0 and set %w1 to 1 if so.
More specifically, "cset %w1, ne" maps to "csinc %w1, wzr, wzr, eq",
which stores 0 in %w1 when NZCV == 0b0100 and 1 otherwise.

Thus, on a successful read we expect ret != 0, so the loop condition
needs to be fixed.  In practice this means that we would end up trying
to fetch entropy up to ten times in a row.  If all attempts are
successful, the last will be returned, otherwise no entropy will be
returned.

Reported by:	Kevin Day <kevin@your.org>
Reviewed by:	andrew
Fixes:		9eecef0521 ("Add an Armv8 rndr random number provider")
MFC after:	1 week
Differential Revision:	https://reviews.freebsd.org/D54259

(cherry picked from commit 93811883500b99f9f1fb4ffd6e764226d37dcfd0)
2025-12-29 14:50:34 +00:00
..
fenestrasX random: Have RANDOM_PURE_START be a cross-platform source 2025-11-07 18:19:13 -08:00
armv8rng.c armv8rng: Fix an inverted test in random_rndr_read_one() 2025-12-29 14:50:34 +00:00
build.sh
darn.c random: Make random_source definitions const 2025-08-19 14:06:02 +00:00
fortuna.c random: Add NIST SP 800-90B entropy source health test implementations 2025-07-18 20:33:06 +00:00
fortuna.h
hash.c
hash.h
ivy.c random: add RDSEED as a provably unique entropy source 2025-10-28 23:10:45 -07:00
nehemiah.c random: Make random_source definitions const 2025-08-19 14:06:02 +00:00
other_algorithm.c
other_algorithm.h
random_harvestq.c random: Have RANDOM_PURE_START be a cross-platform source 2025-11-07 18:19:13 -08:00
random_harvestq.h random: Add NIST SP 800-90B entropy source health test implementations 2025-07-18 20:33:06 +00:00
random_infra.c
randomdev.c random: Treat writes to /dev/random as separate from /entropy 2025-07-18 20:33:06 +00:00
randomdev.h random: Allow pure entropy sources to provide a min-entropy estimate 2025-09-30 09:43:08 +00:00
rdseed.c random: add RDSEED as a provably unique entropy source 2025-10-28 23:10:45 -07:00
uint128.h
unit_test.c
unit_test.h