<div dir="ltr"><br><div class="gmail_extra"><br><div class="gmail_quote">On Mon, Nov 2, 2015 at 4:32 PM, Levente Uzonyi <span dir="ltr">&lt;<a href="mailto:leves@elte.hu" target="_blank">leves@elte.hu</a>&gt;</span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Hi All,<br>
<br>
With the recent UUID changes, we&#39;re facing the problem of properly seeding a Random instance. The current method provides only 2^32 different initial states, with which the chance for two images to have the same values on startup is way too high (~9300 startups for 1% chance of collision).<br>
To avoid the collisions we need a reliable source of random bytes.<br>
Currently we have the following sources:<br>
1. /dev/urandom: fast, reliable, but not available on all platforms (e.g. windows).<br>
2. UUIDPlugin: fast, but this is what we wanted to get rid of in the first place, so it may not be available.<br>
3. Audio recorded through SoundSystem: slow, unreliable, and it may not be available.<br>
4. Time primUTCMicrosecondClock. On its own it has way too little entropy. We can still use it to initalize the PRNG by using additional sources of entropy (image name, path, vm version, whatever). We can use SHA1 to get &quot;more random&quot; bits from out entropy sources. But this is more like a last resort than a solution to rely on.<br>
<br>
So I suggest we should create a new primitive, which can fill a given indexable object (bytes and optionally words) with random values - the same way Random &gt;&gt; #nextBytes:into:startingAt: works. It could use CryptGenRandom on Windows, and /dev/urandom on other unix-like platforms.<br>
<br>
As fallback mechanisms, I&#39;d implement 1. 2. and optionally 4., and use them in the given order. The drawback of these mechanisms is that they create unwanted package dependencies, because Random is in Kernel, while most potetial sources of entropy, along with SHA1, are in other packages.<br></blockquote><div><br></div><div>Why do we want to get rid of UUIDPlugin? Is it just because fewer plugins is better, or is there a problem with this one in particular?</div><div><br></div><div>Also, if we&#39;re going to have a primitive that supplies fast, high-quality, random bytes, shouldn&#39;t Random just call that for random values, rather than seeding a PRNG? </div></div><br></div><div class="gmail_extra">That said, I think I&#39;d do seeding using</div><div class="gmail_extra"><br></div><div class="gmail_extra">1. the primitive, if available</div><div class="gmail_extra">2. UUIDPlugin, if available</div><div class="gmail_extra">3. The current method</div><div class="gmail_extra"><br></div><div class="gmail_extra">Most VMs will have either the primitive or the plugin, so the current method will be used rarely, and thus collisions will be very rare. Keep it simple. </div><div class="gmail_extra"><br></div><div class="gmail_extra">Colin</div></div>