summaryrefslogtreecommitdiff
path: root/src/lib
diff options
context:
space:
mode:
authorprovos <>1999-08-26 13:38:10 +0000
committerprovos <>1999-08-26 13:38:10 +0000
commit16cba6f0dd5d54ed11696fbb4b172ea0e3d44036 (patch)
tree5c87acf19644604cb04319678bd2a3ac3bcb7064 /src/lib
parent785006428bed01f8361290c2e722628ea9f237d9 (diff)
downloadopenbsd-16cba6f0dd5d54ed11696fbb4b172ea0e3d44036.tar.gz
openbsd-16cba6f0dd5d54ed11696fbb4b172ea0e3d44036.tar.bz2
openbsd-16cba6f0dd5d54ed11696fbb4b172ea0e3d44036.zip
add an inner xor to make prediction attacks against the ids harder, due
to an attack pointed out by David Wagner.
Diffstat (limited to 'src/lib')
-rw-r--r--src/lib/libc/net/res_random.c8
1 files changed, 5 insertions, 3 deletions
diff --git a/src/lib/libc/net/res_random.c b/src/lib/libc/net/res_random.c
index bd32a50c33..ef768a7348 100644
--- a/src/lib/libc/net/res_random.c
+++ b/src/lib/libc/net/res_random.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: res_random.c,v 1.7 1997/07/25 20:30:08 mickey Exp $ */ 1/* $OpenBSD: res_random.c,v 1.8 1999/08/26 13:38:10 provos Exp $ */
2 2
3/* 3/*
4 * Copyright 1997 Niels Provos <provos@physnet.uni-hamburg.de> 4 * Copyright 1997 Niels Provos <provos@physnet.uni-hamburg.de>
@@ -83,7 +83,7 @@ const static u_int16_t pfacts[PFAC_N] = {
83}; 83};
84 84
85static u_int16_t ru_x; 85static u_int16_t ru_x;
86static u_int16_t ru_seed; 86static u_int16_t ru_seed, ru_seed2;
87static u_int16_t ru_a, ru_b; 87static u_int16_t ru_a, ru_b;
88static u_int16_t ru_g; 88static u_int16_t ru_g;
89static u_int16_t ru_counter = 0; 89static u_int16_t ru_counter = 0;
@@ -143,6 +143,8 @@ res_initid()
143 143
144 /* 15 bits of random seed */ 144 /* 15 bits of random seed */
145 ru_seed = (tmp >> 16) & 0x7FFF; 145 ru_seed = (tmp >> 16) & 0x7FFF;
146 tmp = arc4random();
147 ru_seed2 = tmp & 0x7FFF;
146 148
147 tmp = arc4random(); 149 tmp = arc4random();
148 150
@@ -204,7 +206,7 @@ res_randomid()
204 206
205 ru_counter += i; 207 ru_counter += i;
206 208
207 return (ru_seed ^ pmod(ru_g,ru_x,RU_N)) | ru_msb; 209 return (ru_seed ^ pmod(ru_g,ru_seed2 ^ ru_x,RU_N)) | ru_msb;
208} 210}
209 211
210#if 0 212#if 0