On 09 Feb 2014, at 23:57, Olivier Goffart <[email protected]> wrote:
> On Sunday 09 February 2014 22:40:22 Kurt Pattyn wrote:
>
> I think you are making it more complicated than it need to be.
> It turns out 32 bit entropy is enough because that's the size of your mask,
> so
> just use qrand with a decent proper seed:
>
> #if has_std_randrom_device
> return qsrand(std::random_device()());
you still need to check for the entropy and must be prepared to catch
std::exception
> #else
> static QElapsedTimer t;
> return qsrand(t.nsecsElapsed());
> #endif
Well, I can simplify to
quint32 seed = 0;
try {
std::random_device seeder;
if (seeder.entropy() >= 0.5) {
seed = seeder();
success = true;
}
} catch (const std::exception &) {
//fall through
}
if (!success) {
//need to do something here
//it is known that the MingW version of GCC 4.8 has a bug
//in std::random_device
//in that case, we can fall back to the Windows CryptoAPI
//or we can make our live easy and fall back to some low entropy
//source (also for the cases where std::random_device fails)
//using std::seek_seq can then partially obscure the low entropy
}
> --
> Olivier
>
> Woboq - Qt services and support - http://woboq.com - http://code.woboq.org
>
>
_______________________________________________
Development mailing list
[email protected]
http://lists.qt-project.org/mailman/listinfo/development