[PATCH] Use arc4random instead of rand where available

Yann Droneaud ydroneaud at mandriva.com
Tue Mar 23 05:05:22 PDT 2010


Le lundi 22 mars 2010 à 17:49 -0700, Jeremy Huddleston a écrit :
> I was thinking smaller would be more "acceptable" ... but I too would  
> prefer something like OsRandom() in os/utils.c ... 

I would prefer too, since GNU libc doesn't have a definition for
arc4random, something like OsRandom() would be definitely better.
You should also specify known output range for the PRNG:
rand() returns an int in range [0..RAND_MAX] while arc4random() returns
an uint32_t with range [0..2^32-1].


(Let me introduce you to "hasard" library, a portable random generator
library:

 http://bitbucket.org/haypo/hasard/wiki/Home
 http://bitbucket.org/haypo/hasard/

This library could be use to wrote a portable OsRandom(), with a fast,
non secure PRNG.)

Regards.

-- 
Yann Droneaud





More information about the xorg-devel mailing list