From 81f251660026fff198daf8920edc62bbc782ff7d Mon Sep 17 00:00:00 2001 From: Thiago Macieira Date: Thu, 12 Oct 2017 14:59:51 -0700 Subject: QRandomGenerator: add system() and global() Right now,this does really nothing. This commit is just to allow us to transition the other modules (besides qtbase) to use the syntax that will become the API. I've marked three places to use the system CSPRNG: 1) the QHash seed 2) QUuid 3) QAuthenticator I didn't think the HTTP multipart boundary needed to be cryptographically safe, so I changed that one to the global generator. Change-Id: Ib17dde1a1dbb49a7bba8fffd14ecf1938bd8ff61 Reviewed-by: Edward Welbourne --- src/corelib/global/qrandom.h | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) (limited to 'src/corelib/global/qrandom.h') diff --git a/src/corelib/global/qrandom.h b/src/corelib/global/qrandom.h index 2259f2657a..049495d4e8 100644 --- a/src/corelib/global/qrandom.h +++ b/src/corelib/global/qrandom.h @@ -51,9 +51,12 @@ class QRandomGenerator template using IfValidUInt = typename std::enable_if::value && sizeof(UInt) >= sizeof(uint), bool>::type; public: + static QRandomGenerator system() { return {}; } + static QRandomGenerator global() { return {}; } QRandomGenerator() = default; // ### REMOVE BEFORE 5.10 + QRandomGenerator *operator->() { return this; } static quint32 get32() { return generate(); } static quint64 get64() { return generate64(); } static qreal getReal() { return generateDouble(); } @@ -135,13 +138,14 @@ public: static Q_DECL_CONSTEXPR result_type max() { return (std::numeric_limits::max)(); } private: - Q_DISABLE_COPY(QRandomGenerator) static Q_CORE_EXPORT void fillRange_helper(void *buffer, void *bufferEnd); }; class QRandomGenerator64 { public: + static QRandomGenerator64 system() { return {}; } + static QRandomGenerator64 global() { return {}; } QRandomGenerator64() = default; static quint64 generate() { return QRandomGenerator::generate64(); } @@ -152,9 +156,6 @@ public: double entropy() const Q_DECL_NOTHROW { return 0.0; } static Q_DECL_CONSTEXPR result_type min() { return (std::numeric_limits::min)(); } static Q_DECL_CONSTEXPR result_type max() { return (std::numeric_limits::max)(); } - -private: - Q_DISABLE_COPY(QRandomGenerator64) }; -- cgit v1.2.3