From owner-freebsd-questions Mon Jun 29 18:42:20 1998 Return-Path: Received: (from majordom@localhost) by hub.freebsd.org (8.8.8/8.8.8) id SAA25996 for freebsd-questions-outgoing; Mon, 29 Jun 1998 18:42:20 -0700 (PDT) (envelope-from owner-freebsd-questions@FreeBSD.ORG) Received: from lucy.bedford.net (lucy.bedford.net [206.99.145.54]) by hub.freebsd.org (8.8.8/8.8.8) with ESMTP id SAA25953 for ; Mon, 29 Jun 1998 18:42:08 -0700 (PDT) (envelope-from listread@lucy.bedford.net) Received: (from listread@localhost) by lucy.bedford.net (8.8.8/8.8.8) id VAA07771; Mon, 29 Jun 1998 21:28:38 -0400 (EDT) (envelope-from listread) Message-Id: <199806300128.VAA07771@lucy.bedford.net> Subject: Re: /dev/random? In-Reply-To: <199806292158.RAA23991@brown.pfcs.com> from Harlan Stenn at "Jun 29, 98 05:58:34 pm" To: Harlan.Stenn@pfcs.com (Harlan Stenn) Date: Mon, 29 Jun 1998 21:28:38 -0400 (EDT) Cc: questions@FreeBSD.ORG X-no-archive: yes Reply-to: djv@bedford.net From: CyberPeasant X-Mailer: ELM [version 2.4ME+ PL38 (25)] MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Sender: owner-freebsd-questions@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.ORG 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