RC4 is broken and is vulnerable to key recovery attacks.
See http://en.wikipedia.org/wiki/RC4#Security
Dropping the first 3072 bytes of the stream makes one of these attacks
harder. This doesn't fix the problems with using RC4 but it is an
improvement.
These problems are probably theoretical right now because plausible
contemporary threat models don't seem to involve the fake flash drive
trying serious cryptanalysis on our datastream.
Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
setvbuf(fp, 0, _IONBF, 0);
char generated[4096], input[4096];
long long remain = size;
+ static const size_t rc4drop = 3072; // en.wikipedia.org/wiki/RC4#Security
+ assert(rc4drop <= sizeof(generated));
+ rng.stream(generated, rc4drop);
while(remain > 0) {
size_t bytesGenerated = (remain > (ssize_t)sizeof generated
? sizeof generated