Comment 7 for bug 509562

Revision history for this message
Scott Moser (smoser) wrote :

The problem was that the euca2ools/__init__.py was doing:
   iv = (hex(BN.rand(16 * 8,top=0)))[2:34]
then
   unhexlify(iv)

But BN.rand(16*8) is not guaranteed to return a number that is
represented by 32 hex digits. I suspect that the .replace('L','c') was
added to get around this issue. By specifying 'top=0' in the BN.rand
call, we guarantee that the number will have the top bit set.

I've ran the following snippet past i=40,000,000 . Without the fix in
place I never saw it run past 1000.

while True:
   i=i+1
   try:
      uh = unhexlify((hex(BN.rand(16 * 8,top=0)))[2:34])
   except KeyboardInterrupt:
      print "tried %i times, no failures yet" % i
   except:
      print "found failure, i=%s, iv=%s len=(%s)" % (i,iv,len(iv))
      sys.exit(1)