Skip to content

Commit 0d9488f

Browse files
committed
random: do not sign extend bytes for rotation when mixing
By using `char` instead of `unsigned char`, certain platforms will sign extend the byte when `w = rol32(*bytes++, input_rotate)` is called, meaning that bit 7 is overrepresented when mixing. This isn't a real problem (unless the mixer itself is already broken) since it's still invertible, but it's not quite correct either. Fix this by using an explicit unsigned type. Signed-off-by: Jason A. Donenfeld <[email protected]>
1 parent 9f9eff8 commit 0d9488f

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

drivers/char/random.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -546,7 +546,7 @@ static void _mix_pool_bytes(struct entropy_store *r, const void *in,
546546
unsigned long i, tap1, tap2, tap3, tap4, tap5;
547547
int input_rotate;
548548
int wordmask = r->poolinfo->poolwords - 1;
549-
const char *bytes = in;
549+
const unsigned char *bytes = in;
550550
__u32 w;
551551

552552
tap1 = r->poolinfo->tap1;

0 commit comments

Comments
 (0)