diff options
author | mread <qt-info@nokia.com> | 2011-08-24 12:04:02 (GMT) |
---|---|---|
committer | mread <qt-info@nokia.com> | 2011-08-24 12:04:02 (GMT) |
commit | ac10a99e642c9005efc7639583fcb726acc169fd (patch) | |
tree | 62dd69423a934e14a83cd545c7cacd6cf29bbdd0 /src/corelib | |
parent | 33f65993866e3eb2a80001f1b53f38dbfc7017ce (diff) | |
download | Qt-ac10a99e642c9005efc7639583fcb726acc169fd.zip Qt-ac10a99e642c9005efc7639583fcb726acc169fd.tar.gz Qt-ac10a99e642c9005efc7639583fcb726acc169fd.tar.bz2 |
Giving QUuid::createUuid() more entropy on Symbian
QUuid::createUuid() uuids have low entropy on Symbian, giving a
dangerously high probability of collision. This change adds in more
entropy from the kernel tick count to reduce the possibility of
collision.
Task-number: QTBUG-21072
Reviewed-by: Sami Merila
Diffstat (limited to 'src/corelib')
-rw-r--r-- | src/corelib/plugin/quuid.cpp | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/src/corelib/plugin/quuid.cpp b/src/corelib/plugin/quuid.cpp index af63b79..83c6194 100644 --- a/src/corelib/plugin/quuid.cpp +++ b/src/corelib/plugin/quuid.cpp @@ -901,6 +901,12 @@ QUuid QUuid::createUuid() uint randNumber = 0; for (int filled = 0; filled < intbits; filled += randbits) randNumber |= qrand()<<filled; +#if defined(Q_OS_SYMBIAN) + // Symbian does not have /dev/urandom, so entropy is low. + // Add more entropy from the kernel tick count (1ms resolution). + // big multipler used to splatter the tick count bits over the whole 32 bits + randNumber ^= User::NTickCount() * 0x3b9aca07; +#endif *(data+chunks) = randNumber; } } |