aboutsummaryrefslogtreecommitdiff
path: root/sys/dev/random/fortuna.c
diff options
context:
space:
mode:
Diffstat (limited to 'sys/dev/random/fortuna.c')
-rw-r--r--sys/dev/random/fortuna.c16
1 files changed, 6 insertions, 10 deletions
diff --git a/sys/dev/random/fortuna.c b/sys/dev/random/fortuna.c
index 3a46d527fa9a..4c7ccc13309d 100644
--- a/sys/dev/random/fortuna.c
+++ b/sys/dev/random/fortuna.c
@@ -308,20 +308,16 @@ random_fortuna_reseed_internal(uint32_t *entropy_data, u_int blockcount)
static __inline void
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)
- * - C = C + 1
- */
- randomdev_encrypt(&fortuna_state.fs_key, &fortuna_state.fs_counter, buf, RANDOM_BLOCKSIZE);
- buf += RANDOM_BLOCKSIZE;
- uint128_increment(&fortuna_state.fs_counter);
- }
+ /*
+ * Fills buf with RANDOM_BLOCKSIZE * blockcount bytes of keystream.
+ * Increments fs_counter as it goes.
+ */
+ randomdev_keystream(&fortuna_state.fs_key, &fortuna_state.fs_counter,
+ buf, blockcount);
}
/*-