From 8b82015376bf2392f73e0fdd134451598a7fcf47 Mon Sep 17 00:00:00 2001 From: Niels Provos Date: Thu, 26 Aug 1999 13:38:11 +0000 Subject: add an inner xor to make prediction attacks against the ids harder, due to an attack pointed out by David Wagner. --- lib/libc/net/res_random.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) (limited to 'lib') diff --git a/lib/libc/net/res_random.c b/lib/libc/net/res_random.c index bd32a50c332..ef768a7348c 100644 --- a/lib/libc/net/res_random.c +++ b/lib/libc/net/res_random.c @@ -1,4 +1,4 @@ -/* $OpenBSD: res_random.c,v 1.7 1997/07/25 20:30:08 mickey Exp $ */ +/* $OpenBSD: res_random.c,v 1.8 1999/08/26 13:38:10 provos Exp $ */ /* * Copyright 1997 Niels Provos @@ -83,7 +83,7 @@ const static u_int16_t pfacts[PFAC_N] = { }; static u_int16_t ru_x; -static u_int16_t ru_seed; +static u_int16_t ru_seed, ru_seed2; static u_int16_t ru_a, ru_b; static u_int16_t ru_g; static u_int16_t ru_counter = 0; @@ -143,6 +143,8 @@ res_initid() /* 15 bits of random seed */ ru_seed = (tmp >> 16) & 0x7FFF; + tmp = arc4random(); + ru_seed2 = tmp & 0x7FFF; tmp = arc4random(); @@ -204,7 +206,7 @@ res_randomid() ru_counter += i; - return (ru_seed ^ pmod(ru_g,ru_x,RU_N)) | ru_msb; + return (ru_seed ^ pmod(ru_g,ru_seed2 ^ ru_x,RU_N)) | ru_msb; } #if 0 -- cgit v1.2.3