diff options
author | Damien Miller <djm@cvs.openbsd.org> | 2011-01-11 06:15:04 +0000 |
---|---|---|
committer | Damien Miller <djm@cvs.openbsd.org> | 2011-01-11 06:15:04 +0000 |
commit | b213df0aa82ae99344ceb0938840e004a1cd96d1 (patch) | |
tree | 77287fe422c112bbc522356b1888a9fa5e417dd2 | |
parent | 2e16b90839976d743640fd76be0ee001df5b8ec4 (diff) |
bring back carrying over state from the previous RC4 instance when
rekeying; ok deraadt@
-rw-r--r-- | sys/dev/rnd.c | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/sys/dev/rnd.c b/sys/dev/rnd.c index f617bb6562f..0c6ff53540a 100644 --- a/sys/dev/rnd.c +++ b/sys/dev/rnd.c @@ -1,4 +1,4 @@ -/* $OpenBSD: rnd.c,v 1.138 2011/01/11 06:08:28 tedu Exp $ */ +/* $OpenBSD: rnd.c,v 1.139 2011/01/11 06:15:03 djm Exp $ */ /* * Copyright (c) 2011 Theo de Raadt. @@ -632,6 +632,12 @@ arc4_init(void *v, void *w) for (p = (u_int8_t *)&ts, i = 0; i < sizeof(ts); i++) buf[i] ^= p[i]; + /* Carry over some state from the previous PRNG instance */ + mtx_enter(&rndlock); + if (rndstats.arc4_nstirs > 0) + rc4_crypt(&arc4random_state, buf, buf, sizeof(buf)); + mtx_leave(&rndlock); + rc4_keysetup(&new_ctx, buf, sizeof(buf)); rc4_skip(&new_ctx, ARC4_STATE * ARC4_DISCARD_CHEAP); |