using /dev/random
RW
fbsd06 at mlists.homeunix.com
Tue Sep 23 21:41:01 UTC 2008
On Tue, 23 Sep 2008 11:52:07 -0400
Lowell Gilbert <freebsd-questions-local at be-well.ilk.org> wrote:
> Robert Huff <roberthuff at 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.
More information about the freebsd-questions
mailing list