19 Aug 2002 Artimage   » (Journeyer)

Randomness

So EGTP gives this warning under windows: This OS needs a better source of entropy (or something similar). So I thought hey, this is something I should look into. Google, Oracle for all things geeky, of course shown a light on the path of wisdom. This post to a mailing list seemed to have a cookie cutter answer for what I was looking for. (Side note: this should work on all windows with IE3 or later, or 95 OEMsp2 or later.)

So I quickly got it working, and spewing out nice random output. But I wondered how good the output was. Which led to David Wagner's page on randomness. What a treasure trove this is. So I grabbed Diehard, a series of tests for RNG's (Random Number Generators), and read up on how to use it. Thirty minutes later I have generated an eleven meg data file for it, and it is churning away. (Small side note, due to an error in the DOS version I was forced to enter the filename each time.)

This turned out to be disappointing, though not surprising. Since I was really using code to grab a seed for an RNG, it turned out the data wasn't passing the tests. Which means what? I am not sure. I know that on linux /dev/random will run out if you if you don't give it time to replenish. The cookbook answer didn't tell me how to check to make sure my data was good. In the end, this is still better than the way we were doing it. (Using time and mouse position. This short post by Don Davis tells why mouse position is not a good source.)

With all of this done, I talked to the other EGTP hackers about where to put my code. First reaction, add a patch to crypto++, Wei Dai's C++ crypto package that we use. Now, if you have been following my links, you will notice that the first recipe I found was also posted by Mr. Dai. Wouldn't he have used that snippet in his own library you ask? Oh, yes, he did. But when the code was written it either wasn't there, or didn't get researched. Wei has a great class called AutoSeededRandomPool that plays nicely with /dev/random (Linux), /dev/urandom (*BSD), and Windows.

I talked with Zooko, and it turns out that embedding C++ code into python isn't the easiest thing for a Python novice to be doing. It will be much simpler to just create a small file that simply does our entropy gathering. So that is what I will do now, and we can come back and do a major overhaul later.

Anyway, I have got the code compiling and working in Python using distutils. There is still some testing ahead, but it feels good to have gotten it working and to have a better understanding of distutils and the C/Python API.

Latest blog entries     Older blog entries

New Advogato Features

New HTML Parser: The long-awaited libxml2 based HTML parser code is live. It needs further work but already handles most markup better than the original parser.

Keep up with the latest Advogato features by reading the Advogato status blog.

If you're a C programmer with some spare time, take a look at the mod_virgule project page and help us with one of the tasks on the ToDo list!