diff options
author | djm <> | 2003-11-26 21:40:08 +0000 |
---|---|---|
committer | djm <> | 2003-11-26 21:40:08 +0000 |
commit | 69c7506e35ed76129bf0240740001b973c27cb33 (patch) | |
tree | 8d44f181c659f196caeae4cfc1a1580aacc7790b /src/lib/libc/crypt | |
parent | 80f1950833e78c999c010c970e78ca9ed473babb (diff) | |
download | openbsd-69c7506e35ed76129bf0240740001b973c27cb33.tar.gz openbsd-69c7506e35ed76129bf0240740001b973c27cb33.tar.bz2 openbsd-69c7506e35ed76129bf0240740001b973c27cb33.zip |
Discard first 256 bytes of keystream, as per recommendation in
"Weaknesses in the Key Scheduling Algorithm of RC4", Fluhrer, Mantin and
Shamir. ok itojun@
Diffstat (limited to 'src/lib/libc/crypt')
-rw-r--r-- | src/lib/libc/crypt/arc4random.c | 11 |
1 files changed, 10 insertions, 1 deletions
diff --git a/src/lib/libc/crypt/arc4random.c b/src/lib/libc/crypt/arc4random.c index 5e3b2925a6..5b376488ec 100644 --- a/src/lib/libc/crypt/arc4random.c +++ b/src/lib/libc/crypt/arc4random.c | |||
@@ -1,4 +1,4 @@ | |||
1 | /* $OpenBSD: arc4random.c,v 1.9 2003/08/16 19:07:40 tedu Exp $ */ | 1 | /* $OpenBSD: arc4random.c,v 1.10 2003/11/26 21:40:08 djm Exp $ */ |
2 | 2 | ||
3 | /* | 3 | /* |
4 | * Arc4 random number generator for OpenBSD. | 4 | * Arc4 random number generator for OpenBSD. |
@@ -48,6 +48,8 @@ static int rs_initialized; | |||
48 | static struct arc4_stream rs; | 48 | static struct arc4_stream rs; |
49 | static pid_t arc4_stir_pid; | 49 | static pid_t arc4_stir_pid; |
50 | 50 | ||
51 | static inline u_int8_t arc4_getbyte(struct arc4_stream *); | ||
52 | |||
51 | static inline void | 53 | static inline void |
52 | arc4_init(struct arc4_stream *as) | 54 | arc4_init(struct arc4_stream *as) |
53 | { | 55 | { |
@@ -98,6 +100,13 @@ arc4_stir(struct arc4_stream *as) | |||
98 | 100 | ||
99 | arc4_stir_pid = getpid(); | 101 | arc4_stir_pid = getpid(); |
100 | arc4_addrandom(as, (void *) &rdat, sizeof(rdat)); | 102 | arc4_addrandom(as, (void *) &rdat, sizeof(rdat)); |
103 | |||
104 | /* | ||
105 | * Discard early keystream, as per recommendations in: | ||
106 | * http://www.wisdom.weizmann.ac.il/~itsik/RC4/Papers/Rc4_ksa.ps | ||
107 | */ | ||
108 | for (i = 0; i < 256; i++) | ||
109 | (void) arc4_getbyte(as); | ||
101 | } | 110 | } |
102 | 111 | ||
103 | static inline u_int8_t | 112 | static inline u_int8_t |