Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 29 Jun 1998 21:28:38 -0400 (EDT)
From:      CyberPeasant <djv@bedford.net>
To:        Harlan.Stenn@pfcs.com (Harlan Stenn)
Cc:        questions@FreeBSD.ORG
Subject:   Re: /dev/random?
Message-ID:  <199806300128.VAA07771@lucy.bedford.net>
In-Reply-To: <199806292158.RAA23991@brown.pfcs.com> from Harlan Stenn at "Jun 29, 98 05:58:34 pm"

next in thread | previous in thread | raw e-mail | index | archive | help
Harlan Stenn wrote:
> When I to read a hunk of data from /dev/random I get a logical EOF pretty
> quickly.

Yes, this is expected. 

> Is there a way around this?

Not really, it's a result of the way /dev/random is implemented.

> While I'm testing using "less -f /dev/random", my eventual goal is to read
> data from /dev/random via "dd" so I can begin to study how my DDS/2 tape
> drive behaves.
> 
> Just to be clear, "dd if=/dev/random" also "stops" very quickly.

Right, for the same reasons.

Short answer: /dev/random is not intended to provide an efficient
stream of random numbers. This function could be provided in the
kernel, but the overhead of a system call would be prohibitive.
If you don't want to take the steps outlined in the rest of this
answer, use /dev/urandom instead. (man 4 random for explanation).

[Reference: man -a random]  The device /dev/random is probably best
used to obtain high-quality random numbers which are then used as
a seed (or seeds) to a decent pseudo-random number generator such
as that provided by the random(3) library function(s). These numbers
should be good enough for any non-crypto purpose. If you need a
program to produce an endless stream of random numbers on its stdout,
this can be easily written.  One advantage of this is that the
stream of random numbers will be repeatable, provided you know the
/dev/random generated "seeds".

I'm not sure what uses you are making of these numbers. If they are
just to simulate "data", then I would suggest using non random numbers,
such as a series of increasing integers, to aid tracking where the
data ends up on the tape.  If the numbers are being used to generate
commands, "Seek to block N", "Write M blocks", or whatever, I would
suggest generating a series of pseudo-randoms to a disk file, where
it could be parsed for legality, named, ("test55"), and remain available
for study in conjunction with other test results.

Dave
-- 
http://www.microsoft.com/security: `Microsoft Windows NT Server is the most 
                  secure network operating system available.'
Don Quixote: `You are mistaken, Sancho.'

To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-questions" in the body of the message



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?199806300128.VAA07771>