diff options
| author | Leah Rowe <leah@libreboot.org> | 2026-03-12 14:32:46 +0000 |
|---|---|---|
| committer | Leah Rowe <leah@libreboot.org> | 2026-03-12 14:32:46 +0000 |
| commit | 38c3889f67d91d9b4d4295514a08603b7db9f9c7 (patch) | |
| tree | b9a6d9e572d9019da9a870db1f54a8a859e0e867 /util/nvmutil | |
| parent | 1cee54ee2b6222671fcdeab3e182fba265ae1270 (diff) | |
util/nvmutil: improved entropy in fallback_rand
Signed-off-by: Leah Rowe <leah@libreboot.org>
Diffstat (limited to 'util/nvmutil')
| -rw-r--r-- | util/nvmutil/nvmutil.c | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/util/nvmutil/nvmutil.c b/util/nvmutil/nvmutil.c index e07efbb3..846eb2c3 100644 --- a/util/nvmutil/nvmutil.c +++ b/util/nvmutil/nvmutil.c @@ -1036,6 +1036,14 @@ fallback_rand(void) ^ (unsigned long)&mix ^ counter++; + /* + * Stack addresses can vary between + * calls, thus increasing entropy. + */ + mix ^= (unsigned long)&mix; + mix ^= (unsigned long)&tv; + mix ^= (unsigned long)&counter; + return (uint16_t)(mix & 0xf); } |
