Date: Thu, 25 Sep 2008 20:33:34 +0100 From: Kris Kennaway <kris@FreeBSD.org> To: RW <fbsd06@mlists.homeunix.com> Cc: freebsd-questions@freebsd.org Subject: Re: using /dev/random Message-ID: <48DBE78E.70101@FreeBSD.org> In-Reply-To: <20080923224057.46955938@gumby.homeunix.com.> References: <18648.30321.369520.631459@jerusalem.litteratus.org> <20080923224057.46955938@gumby.homeunix.com.>
next in thread | previous in thread | raw e-mail | index | archive | help
RW wrote:
> On Tue, 23 Sep 2008 11:52:07 -0400
> Lowell Gilbert <freebsd-questions-local@be-well.ilk.org> wrote:
>
>> Robert Huff <roberthuff@rcn.com> writes:
>>
>>> What is the canonical way to get data from /dev/random?
>>> Specifically: having opened the file, how do I read the stream?
>>> I'm currently using
>>>
>>>
>>> union {
>>> float f;
>>> char c[4];
>>> } foo;
>>>
>>> foo.f = 0.0;
>>>
>>> fscanf(rand_fp,"%4c",foo.c);
>>>
>>>
>>> which doesn't seem to produce anywhere near "random bytes"
>>> as promised by the man page.
>> Have you turned off the "seeded" variable? You'll fall back to a
>> software pseudorandom sequence if you don't.
>
> kern.random.sys.seeded is just a flag that gets set to 1 on each
> reseed. IIRC it's also initialized to 1 so it doesn't actually do
> anything very useful.
Except tell you that the kernel random number generator has finished
seeding ;)
Kris
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?48DBE78E.70101>
