git: 2cc41234353f - stable/12 - Fortuna: Add trivial assert to match FS&K definition

David E. O'Brien obrien at FreeBSD.org
Fri Aug 6 00:49:26 UTC 2021


The branch stable/12 has been updated by obrien:

URL: https://cgit.FreeBSD.org/src/commit/?id=2cc41234353f4fff0b55984367b60748b67481ec

commit 2cc41234353f4fff0b55984367b60748b67481ec
Author:     Conrad Meyer <cem at FreeBSD.org>
AuthorDate: 2018-10-20 20:12:57 +0000
Commit:     David E. O'Brien <obrien at FreeBSD.org>
CommitDate: 2021-08-06 00:28:00 +0000

    Fortuna: Add trivial assert to match FS&K definition
    
    FS&K GenerateBlocks function asserts C (counter) != 0.  This should also
    be true in our implementation.
    
    Reviewed by:    delphij, markm
    Approved by:    secteam (delphij)
    Sponsored by:   Dell EMC Isilon
    Differential Revision:  https://reviews.freebsd.org/D16936
    (cherry picked from commit 84880efae7040bb55e6f63166f53158135574e3a)
---
 sys/dev/random/fortuna.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/sys/dev/random/fortuna.c b/sys/dev/random/fortuna.c
index d203c2f138a1..7b4193b528d4 100644
--- a/sys/dev/random/fortuna.c
+++ b/sys/dev/random/fortuna.c
@@ -310,6 +310,8 @@ random_fortuna_genblocks(uint8_t *buf, u_int blockcount)
 	u_int i;
 
 	RANDOM_RESEED_ASSERT_LOCK_OWNED();
+	KASSERT(!uint128_is_zero(fortuna_state.fs_counter), ("FS&K: C != 0"));
+
 	for (i = 0; i < blockcount; i++) {
 		/*-
 		 * FS&K - r = r|E(K,C)


More information about the dev-commits-src-branches mailing list