aboutsummaryrefslogtreecommitdiffstats
path: root/libqpdf/Pl_AES_PDF.cc
diff options
context:
space:
mode:
authorJay Berkenbilt <ejb@ql.org>2012-12-28 22:37:46 +0100
committerJay Berkenbilt <ejb@ql.org>2012-12-31 16:32:32 +0100
commit4eccb9d87b793ad2b6e1532ef4c89ab9d2bb3a90 (patch)
treea6b1bb9319ac1363a76da0a2b86453688bb149aa /libqpdf/Pl_AES_PDF.cc
parent16a23368e738be88669f4fbf4d3341dd473519c7 (diff)
downloadqpdf-4eccb9d87b793ad2b6e1532ef4c89ab9d2bb3a90.tar.zst
Add random number functions to QUtil
Diffstat (limited to 'libqpdf/Pl_AES_PDF.cc')
-rw-r--r--libqpdf/Pl_AES_PDF.cc19
1 files changed, 1 insertions, 18 deletions
diff --git a/libqpdf/Pl_AES_PDF.cc b/libqpdf/Pl_AES_PDF.cc
index 09c975d6..52876101 100644
--- a/libqpdf/Pl_AES_PDF.cc
+++ b/libqpdf/Pl_AES_PDF.cc
@@ -6,11 +6,6 @@
#include <qpdf/rijndael.h>
#include <string>
#include <stdlib.h>
-#include <qpdf/qpdf-config.h>
-#ifndef HAVE_RANDOM
-# define random rand
-# define srandom srand
-#endif
bool Pl_AES_PDF::use_static_iv = false;
@@ -155,15 +150,6 @@ Pl_AES_PDF::finish()
void
Pl_AES_PDF::initializeVector()
{
- static bool seeded_random = false;
- if (! seeded_random)
- {
- // Seed the random number generator with something simple, but
- // just to be interesting, don't use the unmodified current
- // time....
- srandom((int)QUtil::get_current_time() ^ 0xcccc);
- seeded_random = true;
- }
if (use_zero_iv)
{
for (unsigned int i = 0; i < this->buf_size; ++i)
@@ -184,10 +170,7 @@ Pl_AES_PDF::initializeVector()
}
else
{
- for (unsigned int i = 0; i < this->buf_size; ++i)
- {
- this->cbc_block[i] = (unsigned char)((random() & 0xff0) >> 4);
- }
+ QUtil::initializeWithRandomBytes(this->cbc_block, this->buf_size);
}
}