[RFC] Support for /dev/urandom in kdelibs

Albert Astals Cid astals11 at terra.es
Sun Dec 26 18:54:13 GMT 2004


KApplication::random() code seems to use /dev/urandom

Albert

A Diumenge 26 Desembre 2004 13:49, Michael Buesch va escriure:
> Hi,
>
> Is there a possibility to get support for a cryptographically strong
> randomizer into the kdelibs for KDE-4?
> If I did not miss something, there is only KRandomSequence which
> generates random values based on a seed.
>
> What about something like the following class:
> http://webcvs.kde.org/kdeextragear-3/pwmanager/pwmanager/randomizer/randomi
>zer.h?rev=1.2&view=markup
> http://webcvs.kde.org/kdeextragear-3/pwmanager/pwmanager/randomizer/randomi
>zer.cpp?rev=1.2&view=markup
>
> I use this class in my program PwManager.
> It probes for the availability of strong randomizers in the
> system. In the unlikely case that there is neither /dev/urandom,
> /dev/random nor a running EGD, it falls back to the stdlib randomizer.
> (Yes, there is room for improvement at the stdlib rand() fallback.
> It's not reentrant yet and it's very bad).
>
> Usage of the class is as follows:
>
> int foo;
> Randomizer rnd;
> rnd >> foo;
> // foo has a random value now.
>
> [SNIP]
>
> QByteArray foo(666);
> Randomizer rnd;
> rnd >> foo;
> // foo is a QByteArray with 666 random bytes.
>
> [SNIP]
>
> char foo[123];
> Randomizer rnd;
> rnd.nextSize(sizeof(foo));
> rnd >> foo;
> // foo is a char array with sizeof(foo) == 123 random bytes.




More information about the kde-core-devel mailing list