[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]
Re: [tor-bugs] #23061 [Core Tor/Tor]: crypto_rand_double() should produce all possible outputs on 32-bit platforms
#23061: crypto_rand_double() should produce all possible outputs on 32-bit
platforms
------------------------------------------------+--------------------------
Reporter: teor | Owner:
Type: defect | Status: new
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:
Parent ID: | Points: 0.1
Reviewer: | Sponsor: SponsorQ
------------------------------------------------+--------------------------
Comment (by teor):
Turns out that we only get 32 bits of random mantissa on 64-bit, so fixing
this bug might be harder than I thought:
{{{
/* Test for regression to bug 23061, where we produced excessively
granular
* random double values. */
int low_bits_zero_count = 0;
do {
/* First check the value is within the range */
d = crypto_rand_double();
tt_assert(d >= 0);
tt_assert(d < 1.0);
/* Now check the granularity, by finding the last bit of the result.
* doubles have a 53 bit mantissa. */
d *= pow(2, 32);
d -= trunc(d);
low_bits_zero_count++;
/* If the granularity is correct, this will fail with probability
* 1 in 2**100, which is approximately the RAM bit error rate. */
tt_assert(low_bits_zero_count <= 100);
} while (d == 0.0);
}}}
--
Ticket URL: <https://trac.torproject.org/projects/tor/ticket/23061#comment:2>
Tor Bug Tracker & Wiki <https://trac.torproject.org/>
The Tor Project: anonymity online
_______________________________________________
tor-bugs mailing list
tor-bugs@xxxxxxxxxxxxxxxxxxxx
https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-bugs