From owner-freebsd-questions@FreeBSD.ORG Wed May 25 01:17:31 2005 Return-Path: X-Original-To: freebsd-questions@freebsd.org Delivered-To: freebsd-questions@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id F0CBC16A41C for ; Wed, 25 May 2005 01:17:31 +0000 (GMT) (envelope-from kris@obsecurity.org) Received: from obsecurity.dyndns.org (CPE0050040655c8-CM00111ae02aac.cpe.net.cable.rogers.com [69.194.102.232]) by mx1.FreeBSD.org (Postfix) with ESMTP id A96B343D48 for ; Wed, 25 May 2005 01:17:31 +0000 (GMT) (envelope-from kris@obsecurity.org) Received: by obsecurity.dyndns.org (Postfix, from userid 1000) id 3D54D51419; Tue, 24 May 2005 18:18:19 -0700 (PDT) Date: Tue, 24 May 2005 18:18:18 -0700 From: Kris Kennaway To: Nicolas Blais Message-ID: <20050525011818.GA7992@xor.obsecurity.org> References: <200505242113.54226.nb_root@videotron.ca> Mime-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="bg08WKrSYDhXBjb5" Content-Disposition: inline In-Reply-To: <200505242113.54226.nb_root@videotron.ca> User-Agent: Mutt/1.4.2.1i Cc: freebsd-questions@freebsd.org Subject: Re: srandomdev() vs srandom() vs arc4random() X-BeenThere: freebsd-questions@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: User questions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 25 May 2005 01:17:32 -0000 --bg08WKrSYDhXBjb5 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Tue, May 24, 2005 at 09:13:45PM -0400, Nicolas Blais wrote: > I'm developping a software that uses random generated numbers. Since thes= e=20 > numbers must be as "chaotic" as possible, I'm using srandomdev(). My prob= lem=20 > is that I'm only able to compile my software on *BSD and certain distros = of=20 > Linux seem to be stripped of the call. This forces me to rely on=20 > srandom(time(NULL)) for portability. >=20 > I would like to know how "random" (that is, how inprobable a pattern will= =20 > appear) if I use srandom(time(NULL)) instead of srandomdev(). > > Also, would arc4random() be any better in getting the least pattern creat= ion. arc4random() should produce higher quality randomness, although srandom() may be good enough for your needs. > Finally, is there is a way to check if the call srandomdev() exists on ot= her=20 > OSes? Sure, compile a test app in your configure script :-) Kris --bg08WKrSYDhXBjb5 Content-Type: application/pgp-signature Content-Disposition: inline -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.1 (FreeBSD) iD8DBQFCk9JaWry0BWjoQKURAlPlAKCZU3su3Fo5FRvpkziE5A/mIM/0sQCgjmaX IL8O4VDz97FTTN0R+7NRliM= =tG7b -----END PGP SIGNATURE----- --bg08WKrSYDhXBjb5--