random(4): Fix a regression in short AES mode reads

In r349154, random device reads of size < 16 bytes (AES block size) were
accidentally broken to loop forever.  Correct the loop condition for small
reads.

Reported by:	pho
Reviewed by:	delphij
Approved by:	secteam(delphij)
Differential Revision:	https://reviews.freebsd.org/D20686
This commit is contained in:
Conrad Meyer 2019-06-18 18:50:58 +00:00
parent 5c2b348a54
commit 22eedc9722
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=349176

View File

@ -489,7 +489,7 @@ random_fortuna_genbytes(uint8_t *buf, size_t bytecount,
if (!random_chachamode)
chunk_size = rounddown(chunk_size, RANDOM_BLOCKSIZE);
while (bytecount >= chunk_size) {
while (bytecount >= chunk_size && chunk_size > 0) {
randomdev_keystream(p_key, p_counter, buf, chunk_size);
buf += chunk_size;