diff options
author | Theo de Raadt <deraadt@cvs.openbsd.org> | 2011-01-10 06:08:39 +0000 |
---|---|---|
committer | Theo de Raadt <deraadt@cvs.openbsd.org> | 2011-01-10 06:08:39 +0000 |
commit | b0bcad6eb44ca87a04c97f0194780face0cb7cb1 (patch) | |
tree | 8a11b0d9daea37b37e261f8741cabb9b845362dc /sys/dev | |
parent | 81270f48fd7512db8263a791e09078180c9edccb (diff) |
update the documentation regarding the *4 vs *6 decision for early RC4
stream discard. this continues to be under discussion... at least this
moves the large-buffer transactions to using a *6 discard
discussed at length with djm and kjell
Diffstat (limited to 'sys/dev')
-rw-r--r-- | sys/dev/rnd.c | 18 |
1 files changed, 11 insertions, 7 deletions
diff --git a/sys/dev/rnd.c b/sys/dev/rnd.c index 50c60e745d9..5953b40645c 100644 --- a/sys/dev/rnd.c +++ b/sys/dev/rnd.c @@ -1,4 +1,4 @@ -/* $OpenBSD: rnd.c,v 1.136 2011/01/10 06:05:23 deraadt Exp $ */ +/* $OpenBSD: rnd.c,v 1.137 2011/01/10 06:08:38 deraadt Exp $ */ /* * Copyright (c) 2011 Theo de Raadt. @@ -518,12 +518,16 @@ extract_entropy(u_int8_t *buf, int nbytes) #define ARC4_KEY_BYTES 64 /* - * 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.) + * Throw away a multiple of 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.) If the start + * of a new RC stream is an event that a consumer could spot, we drop + * the strictly recommended amount (ceil(n/log e) = 6). If consumers + * only see random sub-streams, we cheat and do less computation. */ #define ARC4_STATE 256 -#define ARC4_PARANOIA 4 +#define ARC4_DISCARD_SAFE 6 +#define ARC4_DISCARD_CHEAP 4 /* * Start with an unstable state so that rc4_getbytes() can @@ -629,7 +633,7 @@ arc4_init(void *v, void *w) buf[i] ^= p[i]; rc4_keysetup(&new_ctx, buf, sizeof(buf)); - rc4_skip(&new_ctx, ARC4_STATE * ARC4_PARANOIA); + rc4_skip(&new_ctx, ARC4_STATE * ARC4_DISCARD_CHEAP); mtx_enter(&rndlock); bcopy(&new_ctx, &arc4random_state, sizeof(new_ctx)); @@ -716,7 +720,7 @@ randomread(dev_t dev, struct uio *uio, int ioflag) if (total > ARC4_MAIN_MAX_BYTES) { arc4random_buf(lbuf, sizeof(lbuf)); rc4_keysetup(&lctx, lbuf, sizeof(lbuf)); - rc4_skip(&lctx, ARC4_STATE * ARC4_PARANOIA); + rc4_skip(&lctx, ARC4_STATE * ARC4_DISCARD_SAFE); bzero(lbuf, sizeof(lbuf)); myctx = 1; } |