Date: Tue, 23 Sep 2008 22:40:57 +0100 From: RW <fbsd06@mlists.homeunix.com> To: freebsd-questions@freebsd.org Subject: Re: using /dev/random Message-ID: <20080923224057.46955938@gumby.homeunix.com.> References: <18648.30321.369520.631459@jerusalem.litteratus.org>
next in thread | previous in thread | raw e-mail | index | archive | help
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.
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20080923224057.46955938>