[RFC] Support for /dev/urandom in kdelibs

Michael Buesch mbuesch at freenet.de
Sun Dec 26 12:49:59 GMT 2004


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/randomizer.h?rev=1.2&view=markup
http://webcvs.kde.org/kdeextragear-3/pwmanager/pwmanager/randomizer/randomizer.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.

-- 
Regards Michael Buesch  [ http://www.tuxsoft.de.vu ]


-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: not available
URL: <http://mail.kde.org/pipermail/kde-core-devel/attachments/20041226/45e939c9/attachment.sig>


More information about the kde-core-devel mailing list