From kde-core-devel Sun Dec 26 18:54:13 2004 From: Albert Astals Cid Date: Sun, 26 Dec 2004 18:54:13 +0000 To: kde-core-devel Subject: Re: [RFC] Support for /dev/urandom in kdelibs Message-Id: <200412261954.14099.astals11 () terra ! es> X-MARC-Message: https://marc.info/?l=kde-core-devel&m=110408724730150 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.