Subject: Re: kernel ip_randomid() and libc randomid(3) still "broken"
To: Jun-ichiro itojun Hagino <itojun@itojun.org>
From: Simon Burge <simonb@wasabisystems.com>
List: tech-net
Date: 12/05/2003 16:18:12
Jun-ichiro itojun Hagino wrote:
> > BTW, I also analyzed why "seed2" failed the way it did.
> >
> > The important thing to note is that, when using a prime modulus, the modular
> > exponentiation has a cycle of modulus-1 (i.e. RU_N-1). That is to say, the
> > exponent RU_N-1 generates the same output as the exponent 0, RU_N the same as
> > 1, etc. The xor was causing aliasing.
> >
> > Replacing the xor with an addition fixes this problem, but I'm not sure
> > whether it has the desired behavior in other regards.
>
> just changing xor into addition will consistute problem. the topmost
> bit is used for special purpose, so the addition must be performed
> in mod 2^15 space.
The xor (or add) is used on the exponent argument passed to the pmod
function and thus it's value doesn't affect the high bit.
Simon.
--
Simon Burge <simonb@wasabisystems.com>
NetBSD Support and Service: http://www.wasabisystems.com/