[tor-bugs] #23061 [Core Tor/Tor]: crypto_rand_double() should produce all possible outputs on platforms with 32-bit int

Tor Bug Tracker & Wiki blackhole at torproject.org
Thu Aug 24 22:51:54 UTC 2017


#23061: crypto_rand_double() should produce all possible outputs on platforms with
32-bit int
-------------------------------------------------+-------------------------
 Reporter:  teor                                 |          Owner:  nickm
     Type:  defect                               |         Status:
                                                 |  needs_review
 Priority:  Medium                               |      Milestone:  Tor:
                                                 |  0.3.2.x-final
Component:  Core Tor/Tor                         |        Version:  Tor:
                                                 |  0.2.2.14-alpha
 Severity:  Normal                               |     Resolution:
 Keywords:  tor-relay, security-low, privcount,  |  Actual Points:  0.5
  031-backport, 030-backport, 029-backport, 028  |
  -backport-maybe, 027-backport-maybe, 026       |
  -backport-maybe, review-group-22               |
Parent ID:                                       |         Points:  0.1
 Reviewer:                                       |        Sponsor:
                                                 |  SponsorQ
-------------------------------------------------+-------------------------

Comment (by yawning):

 Replying to [comment:21 nickm]:
 > but can we do better?

 Yeah, fix the broken test.

 {{{
 do {
   d = crypto_rand_double(); // d = n * pow(2, -53) (Where n is the post
 mask sampled integer)

   /* Now check the granularity, by finding the lower bits of the result.
 */
   d *= pow(2, EXPECTED_RAND_MANTISSA_BITS);  // d *= pow(2, 53)
                                              // d  = n * pow(2, -53) *
 pow(2, 53)
                                              // d  = n
   d -= trunc(d);                             // d -= d (trunc(d) = d)
 } while (d == 0.0);
 }}}

--
Ticket URL: <https://trac.torproject.org/projects/tor/ticket/23061#comment:27>
Tor Bug Tracker & Wiki <https://trac.torproject.org/>
The Tor Project: anonymity online


More information about the tor-bugs mailing list