From 91868665a935a40a2ec41dcd15213269e7d57a73 Mon Sep 17 00:00:00 2001 From: Xin LI Date: Tue, 14 Mar 2017 06:00:44 +0000 Subject: [PATCH] Discard first 3072 bytes of RC4 keystream, this is a bandaid that allows us to work on switching to a more modern PRNG. Submitted by: Steven Chamberlain Approved by: so --- lib/libc/gen/arc4random.c | 2 +- sys/libkern/arc4random.c | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/libc/gen/arc4random.c b/lib/libc/gen/arc4random.c index becc17bc2711..1c4d6eebe5fe 100644 --- a/lib/libc/gen/arc4random.c +++ b/lib/libc/gen/arc4random.c @@ -160,7 +160,7 @@ arc4_stir(void) * Discard early keystream, as per recommendations in: * "(Not So) Random Shuffles of RC4" by Ilya Mironov. */ - for (i = 0; i < 1024; i++) + for (i = 0; i < 3072; i++) (void)arc4_getbyte(); arc4_count = 1600000; } diff --git a/sys/libkern/arc4random.c b/sys/libkern/arc4random.c index 86431002ba89..ccda6ad5bd50 100644 --- a/sys/libkern/arc4random.c +++ b/sys/libkern/arc4random.c @@ -84,11 +84,11 @@ arc4_randomstir(struct arc4_s* arc4) /* * Throw away the first N words of output, as suggested in the * paper "Weaknesses in the Key Scheduling Algorithm of RC4" - * by Fluher, Mantin, and Shamir. (N = 256 in our case.) + * by Fluher, Mantin, and Shamir. (N = 768 in our case.) * * http://dl.acm.org/citation.cfm?id=646557.694759 */ - for (n = 0; n < 256*4; n++) + for (n = 0; n < 768*4; n++) arc4_randbyte(arc4); mtx_unlock(&arc4->mtx);