#8089 NORM 8.2.0 (: /dev/hwrng isn't random.

Zarro Boogs per Child bugtracker at laptop.org
Fri Sep 12 01:20:21 EDT 2008


#8089: /dev/hwrng isn't random.
-----------------------------------+----------------------------------------
   Reporter:  cscott               |       Owner:  cscott                 
       Type:  defect               |      Status:  new                    
   Priority:  normal               |   Milestone:  8.2.0 (was Update.2)   
  Component:  ofw - open firmware  |     Version:  not specified          
 Resolution:                       |    Keywords:  blocks?:8.2.0 cjbfor8.2
Next_action:  qa signoff           |    Verified:  0                      
  Blockedby:                       |    Blocking:  8024                   
-----------------------------------+----------------------------------------
Changes (by cscott):

 * cc: dilinger, JordanCrouse (added)


Comment:

 My rough calculation says the odds of picking less than 64 numbers is
 approx (1/4)^(192), which is an incredibly small number.  I verified the
 expected results with the following code:
 {{{
 #!/usr/bin/python2.5
 from __future__ import division
 import random
 TRIALS=50000
 probs={}

 for __ in xrange(TRIALS):
     saw={}
     for i in xrange(256):
         n = random.randint(0, 255)
         saw[n] = saw.get(n, 0) + 1
     n = len(saw)
     probs[n] = probs.get(n, 0) + 1

 for i in xrange(256):
     if i in probs:
         print i, 100*probs[i]/TRIALS


 }}}

 In 50,000 runs I never saw less than 140 unique values.  So even the 81,
 76, and 72 that I saw in my run on my B4 were highly unlikely -- or else
 there's a bug in how I'm counting the number on unique bytes emitted.  But
 running:
 {{{
 python -c 'print "\n".join("%d" % ord(x) for x in
 open("/dev/urandom").read(256))' | sort | uniq -c | wc -l
 }}}
 on a normal Linux system gives results in the 150-160 range for me, too.

 Hm.  *Something* is wrong here.

-- 
Ticket URL: <http://dev.laptop.org/ticket/8089#comment:17>
One Laptop Per Child <http://laptop.org/>
OLPC bug tracking system


More information about the Bugs mailing list