summaryrefslogtreecommitdiffstats
path: root/src/corelib/global/qrandom_p.h
Commit message (Collapse)AuthorAgeFilesLines
* Merge remote-tracking branch 'origin/5.13' into 5.14Liang Qi2019-09-301-8/+0
|\ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Conflicts: src/corelib/global/qrandom.cpp src/corelib/io/qfileinfo.cpp src/corelib/kernel/qeventdispatcher_win.cpp src/corelib/kernel/qeventdispatcher_win_p.h src/gui/text/qfontdatabase.cpp src/platformsupport/fontdatabases/mac/qcoretextfontdatabase.mm src/plugins/platforms/windows/qwindowsglcontext.cpp src/testlib/qtestcase.cpp Done-With: Tor Arne Vestbø <tor.arne.vestbo@qt.io> Done-With: Edward Welbourne <edward.welbourne@qt.io> Change-Id: I4893212471aa24be804c989a581810e2f714545c
| * Fix QRandomGenerator initialization on AMD CPUsDmitry Kazakov2019-09-261-8/+0
| | | | | | | | | | | | | | | | | | | | | | | | | | | | Some AMD CPUs (e.g. AMD A4-6250J and AMD Ryzen 3000-series) have a failing random generation instruction, which always returns 0xffffffff, even when generation was "successful". This code checks if hardware random generator generates four consecutive equal numbers. If it does, then we probably have a failing one and should disable it completely. Change-Id: I38c87920ca2e8cce4143afbff5e453ce3845d11a Fixes: QTBUG-69423 Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
* | Port from implicit to explicit atomic integer operationsMarc Mutz2019-06-281-1/+3
|/ | | | | | | | | | | | The old code used the implicit conversions from QAtomicInteger<T> to T and vice versa. The semantics of these differ from the ones std::atomic uses, so we're going to deprecate these, like we did for load() and store(), too. This patch fixex some users of these APIs before we deprecate them. Change-Id: I4877276581757cd57e042efea8296fe535a493d1 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* Change QRandomGenerator to have a deterministic modeThiago Macieira2017-11-111-0/+17
| | | | | | | | | Now only QRandomGenerator::system() will access the system-wide RNG, which we document to be cryptographically-safe and possibly backed by a true HWRNG. Everything else just wraps a Mersenne Twister. Change-Id: I0a103569c81b4711a649fffd14ec8cd3469425df Reviewed-by: Lars Knoll <lars.knoll@qt.io>
* QRandomGenerator: remove the per-thread bufferThiago Macieira2017-11-111-1/+0
| | | | | | | | | | | Since we're adding a deterministic generator that inherently does not use syscalls, and people should really use that one by default, there is no point in optimizing the secure generator wrt syscalls. Besides, keeping the random data in memory for longer than needed is likely inadviseable. Change-Id: Ib17dde1a1dbb49a7bba8fffd14ed0871117fe930 Reviewed-by: Lars Knoll <lars.knoll@qt.io>
* Long live QRandomGeneratorThiago Macieira2017-06-121-0/+78
This class provides a reasonably-secure random number generator that does not need seeding. That is quite unlike qrand(), which requires a seed and is low-quality (definitely not secure). This class is also like std::random_device, but better. It provides an operator() like std::random_device, but unlike that, it also provides a way to fill a buffer with random data, not just one 32-bit quantity. It's also stateless. Finally, it also implements std::seed_seq-like generate(). It obeys the standard requirement of the range (32-bit) but not that of the algorithm (if you wanted that, you'd use std::seed_seq itself). Instead, generate() fills with pure random data. Change-Id: Icd0e0d4b27cb4e5eb892fffd14b4e3ba9ea04da8 Reviewed-by: Lars Knoll <lars.knoll@qt.io>