[Mono-devel-list] [PATCH] New random patch

Sebastien Pouliot spouliot at videotron.ca
Mon May 17 22:17:06 EDT 2004


Hello,

Here's a new patch for runtime random. It includes the previous perfect (as
in no comments ;-) patch sent on the mono-devel list.

Actually this new patch is the recursive result of:

* a reported bug where an ArgumentOutOfRange exception is thrown in
System.Random;
* which turned out to be a thread related problem in System.Guid (instance
members aren't thread-safe);
* which turned out to have a hidden TODO (private method) for the getting
the MAC address;
* which results in System.Random being only initialized with the current
time;
* which can give non-unique Guid (e.g. on multiple machines);
* which I thought would be nice to replace by completely random Guid
(simpler and safer);
* which made me remember that CryptoAPI isn't thread-safe either;
* which turns out our RNGCryptoServiceProvider may fail under Windows

so here's the patch and I'll go forward my previous problem ;-)

The patch has the indirect advantage to be 20% faster on Linux to obtain
small random buffers (16 bytes, 128 bits) like it is often used for
symmetric keys and IV.

I didn't (much) touch the EGD code as I don't have it installed and can't
test it.


Sebastien Pouliot
http://pages.infinit.net/ctech/poupou.html




-------------- next part --------------
A non-text attachment was scrubbed...
Name: RNGCryptoServiceProvider.diff
Type: text/x-patch
Size: 3203 bytes
Desc: not available
Url : http://lists.ximian.com/pipermail/mono-devel-list/attachments/20040517/189926ba/attachment.bin 
-------------- next part --------------
A non-text attachment was scrubbed...
Name: runtime.diff
Type: text/x-patch
Size: 9443 bytes
Desc: not available
Url : http://lists.ximian.com/pipermail/mono-devel-list/attachments/20040517/189926ba/attachment-0001.bin 


More information about the Mono-devel-list mailing list