diff options
Diffstat (limited to 'libqpdf/InsecureRandomDataProvider.cc')
-rw-r--r-- | libqpdf/InsecureRandomDataProvider.cc | 18 |
1 files changed, 8 insertions, 10 deletions
diff --git a/libqpdf/InsecureRandomDataProvider.cc b/libqpdf/InsecureRandomDataProvider.cc index 4077a35f..b29b0f9f 100644 --- a/libqpdf/InsecureRandomDataProvider.cc +++ b/libqpdf/InsecureRandomDataProvider.cc @@ -1,7 +1,7 @@ #include <qpdf/InsecureRandomDataProvider.hh> -#include <qpdf/qpdf-config.h> #include <qpdf/QUtil.hh> +#include <qpdf/qpdf-config.h> #include <stdlib.h> InsecureRandomDataProvider::InsecureRandomDataProvider() : @@ -16,8 +16,7 @@ InsecureRandomDataProvider::~InsecureRandomDataProvider() void InsecureRandomDataProvider::provideRandomData(unsigned char* data, size_t len) { - for (size_t i = 0; i < len; ++i) - { + for (size_t i = 0; i < len; ++i) { data[i] = static_cast<unsigned char>((this->random() & 0xff0) >> 4); } } @@ -25,13 +24,12 @@ InsecureRandomDataProvider::provideRandomData(unsigned char* data, size_t len) long InsecureRandomDataProvider::random() { - if (! this->seeded_random) - { + if (!this->seeded_random) { // Seed the random number generator with something simple, but // just to be interesting, don't use the unmodified current // time. It would be better if this were a more secure seed. - unsigned int seed = static_cast<unsigned int>( - QUtil::get_current_time() ^ 0xcccc); + unsigned int seed = + static_cast<unsigned int>(QUtil::get_current_time() ^ 0xcccc); #ifdef HAVE_RANDOM ::srandom(seed); #else @@ -40,11 +38,11 @@ InsecureRandomDataProvider::random() this->seeded_random = true; } -# ifdef HAVE_RANDOM +#ifdef HAVE_RANDOM return ::random(); -# else +#else return rand(); -# endif +#endif } RandomDataProvider* |