[Mono-dev] Mutex Bug

Brandon Perry bperry.volatile at gmail.com
Thu Jul 3 03:53:42 UTC 2014


Does the file have to be written to in real time?

Why not perform buffered writes to a memory region, then flush to disk when
a satisfiable amount of entropy has been met?


On Wed, Jul 2, 2014 at 10:32 PM, Edward Ned Harvey (mono) <
edward.harvey.mono at clevertrove.com> wrote:

> > From: Brandon Perry [mailto:bperry.volatile at gmail.com]
> >
> > Do you *have* to write to the same file?
>
> Yes.  Here is the situation:
> https://tinhatrandom.org
> An open source, MIT licensed class library aimed at improving crypto
> random available to the application developer...
>
> One of the things we need to do is this:  Assuming we have collected a lot
> of good entropy from various entropy sources, save a good strong random
> seed file on disk.  Later, any number of applications may be launched,
> potentially at the same time, which need to read & write the file, mutually
> exclusively.
>
> The reason it needs to be one file, is because that's the whole point - If
> the user has already entered random keyboard input, random mouse input, and
> we gathered entropy from the internet, and RNGCryptoServiceProvider, and
> other sources, then every application launch shouldn't need to repeat that.
>  First one does it; everyone later benefits from it.
>
> Right now, I believe, if I use FileMode.Open,  FileAccess.ReadWrite, and
> FileShare.None, that should work cross-platform to ensure only a single
> process may access the file at a time.  The process/thread that has the
> file lock can read the seed, write a new seed, and flush and close.  It
> will work reliably, I believe, for the first process that gets there, and
> to prevent any subsequent processes from accessing the same seed file
> before it is reseeded.  Any subsequent processes that fail to open the file
> (because another process already has it open) I think, will simply have to
> Sleep(1) and retry opening the file.  It's a little ghetto, but it should
> work AFAIK.
>



-- 
http://volatile-minds.blogspot.com -- blog
http://www.volatileminds.net -- website
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.ximian.com/pipermail/mono-devel-list/attachments/20140702/2331aea2/attachment-0001.html>


More information about the Mono-devel-list mailing list