|
|
404264 |
diff --git a/libqpdf/QPDF.cc b/libqpdf/QPDF.cc
|
|
|
404264 |
index 3475afe..f93ba0d 100644
|
|
|
404264 |
--- a/libqpdf/QPDF.cc
|
|
|
404264 |
+++ b/libqpdf/QPDF.cc
|
|
|
404264 |
@@ -19,6 +19,10 @@
|
|
|
404264 |
#include <qpdf/QPDF_Null.hh>
|
|
|
404264 |
#include <qpdf/QPDF_Dictionary.hh>
|
|
|
404264 |
|
|
|
404264 |
+#ifdef HAVE_GNUTLS
|
|
|
404264 |
+# include <gnutls/crypto.h>
|
|
|
404264 |
+#endif
|
|
|
404264 |
+
|
|
|
404264 |
std::string QPDF::qpdf_version = "7.1.1";
|
|
|
404264 |
|
|
|
404264 |
static char const* EMPTY_PDF =
|
|
|
404264 |
@@ -139,7 +143,13 @@ QPDF::processFile(char const* filename, char const* password)
|
|
|
404264 |
{
|
|
|
404264 |
FileInputSource* fi = new FileInputSource();
|
|
|
404264 |
fi->setFilename(filename);
|
|
|
404264 |
+#ifdef HAVE_GNUTLS
|
|
|
404264 |
+ GNUTLS_FIPS140_SET_LAX_MODE();
|
|
|
404264 |
+#endif
|
|
|
404264 |
processInputSource(fi, password);
|
|
|
404264 |
+#ifdef HAVE_GNUTLS
|
|
|
404264 |
+ GNUTLS_FIPS140_SET_STRICT_MODE();
|
|
|
404264 |
+#endif
|
|
|
404264 |
}
|
|
|
404264 |
|
|
|
404264 |
void
|
|
|
404264 |
@@ -148,7 +158,13 @@ QPDF::processFile(char const* description, FILE* filep,
|
|
|
404264 |
{
|
|
|
404264 |
FileInputSource* fi = new FileInputSource();
|
|
|
404264 |
fi->setFile(description, filep, close_file);
|
|
|
404264 |
+#ifdef HAVE_GNUTLS
|
|
|
404264 |
+ GNUTLS_FIPS140_SET_LAX_MODE();
|
|
|
404264 |
+#endif
|
|
|
404264 |
processInputSource(fi, password);
|
|
|
404264 |
+#ifdef HAVE_GNUTLS
|
|
|
404264 |
+ GNUTLS_FIPS140_SET_STRICT_MODE();
|
|
|
404264 |
+#endif
|
|
|
404264 |
}
|
|
|
404264 |
|
|
|
404264 |
void
|
|
|
404264 |
diff --git a/libqpdf/QPDFWriter.cc b/libqpdf/QPDFWriter.cc
|
|
|
404264 |
index 0544640..48fe50d 100644
|
|
|
404264 |
--- a/libqpdf/QPDFWriter.cc
|
|
|
404264 |
+++ b/libqpdf/QPDFWriter.cc
|
|
|
404264 |
@@ -23,6 +23,10 @@
|
|
|
404264 |
#include <algorithm>
|
|
|
404264 |
#include <stdlib.h>
|
|
|
404264 |
|
|
|
404264 |
+#ifdef HAVE_GNUTLS
|
|
|
404264 |
+#include <gnutls/crypto.h>
|
|
|
404264 |
+#endif
|
|
|
404264 |
+
|
|
|
404264 |
QPDFWriter::Members::Members(QPDF& pdf) :
|
|
|
404264 |
pdf(pdf),
|
|
|
404264 |
filename(0),
|
|
|
404264 |
@@ -323,6 +327,13 @@ void
|
|
|
404264 |
QPDFWriter::setDeterministicID(bool val)
|
|
|
404264 |
{
|
|
|
404264 |
this->m->deterministic_id = val;
|
|
|
404264 |
+
|
|
|
404264 |
+#ifdef HAVE_GNUTLS
|
|
|
404264 |
+ if (val)
|
|
|
404264 |
+ GNUTLS_FIPS140_SET_LAX_MODE();
|
|
|
404264 |
+ else
|
|
|
404264 |
+ GNUTLS_FIPS140_SET_STRICT_MODE();
|
|
|
404264 |
+#endif
|
|
|
404264 |
}
|
|
|
404264 |
|
|
|
404264 |
void
|
|
|
404264 |
@@ -344,6 +355,13 @@ void
|
|
|
404264 |
QPDFWriter::setPreserveEncryption(bool val)
|
|
|
404264 |
{
|
|
|
404264 |
this->m->preserve_encryption = val;
|
|
|
404264 |
+
|
|
|
404264 |
+#ifdef HAVE_GNUTLS
|
|
|
404264 |
+ if (val)
|
|
|
404264 |
+ GNUTLS_FIPS140_SET_STRICT_MODE();
|
|
|
404264 |
+ else
|
|
|
404264 |
+ GNUTLS_FIPS140_SET_LAX_MODE();
|
|
|
404264 |
+#endif
|
|
|
404264 |
}
|
|
|
404264 |
|
|
|
404264 |
void
|
|
|
404264 |
diff --git a/libqpdf/QPDF_encryption.cc b/libqpdf/QPDF_encryption.cc
|
|
|
404264 |
index fd717c3..9b38914 100644
|
|
|
404264 |
--- a/libqpdf/QPDF_encryption.cc
|
|
|
404264 |
+++ b/libqpdf/QPDF_encryption.cc
|
|
|
404264 |
@@ -1,6 +1,8 @@
|
|
|
404264 |
// This file implements methods from the QPDF class that involve
|
|
|
404264 |
// encryption.
|
|
|
404264 |
|
|
|
404264 |
+#include <qpdf/qpdf-config.h>
|
|
|
404264 |
+
|
|
|
404264 |
#include <qpdf/QPDF.hh>
|
|
|
404264 |
|
|
|
404264 |
#include <qpdf/QPDFExc.hh>
|
|
|
404264 |
@@ -18,6 +20,10 @@
|
|
|
404264 |
#include <assert.h>
|
|
|
404264 |
#include <string.h>
|
|
|
404264 |
|
|
|
404264 |
+#ifdef HAVE_GNUTLS
|
|
|
404264 |
+# include <gnutls/crypto.h>
|
|
|
404264 |
+#endif
|
|
|
404264 |
+
|
|
|
404264 |
static unsigned char const padding_string[] = {
|
|
|
404264 |
0x28, 0xbf, 0x4e, 0x5e, 0x4e, 0x75, 0x8a, 0x41,
|
|
|
404264 |
0x64, 0x00, 0x4e, 0x56, 0xff, 0xfa, 0x01, 0x08,
|
|
|
404264 |
@@ -1084,6 +1090,12 @@ QPDF::getKeyForObject(int objid, int generation, bool use_aes)
|
|
|
404264 |
void
|
|
|
404264 |
QPDF::decryptString(std::string& str, int objid, int generation)
|
|
|
404264 |
{
|
|
|
404264 |
+#ifdef HAVE_GNUTLS
|
|
|
404264 |
+ unsigned oldmode = gnutls_fips140_mode_enabled();
|
|
|
404264 |
+
|
|
|
404264 |
+ gnutls_fips140_set_mode(GNUTLS_FIPS140_LAX, GNUTLS_FIPS140_SET_MODE_THREAD);
|
|
|
404264 |
+#endif
|
|
|
404264 |
+
|
|
|
404264 |
if (objid == 0)
|
|
|
404264 |
{
|
|
|
404264 |
return;
|
|
|
404264 |
@@ -1162,6 +1174,10 @@ QPDF::decryptString(std::string& str, int objid, int generation)
|
|
|
404264 |
QUtil::int_to_string(objid) + " " +
|
|
|
404264 |
QUtil::int_to_string(generation) + ": " + e.what());
|
|
|
404264 |
}
|
|
|
404264 |
+
|
|
|
404264 |
+#ifdef HAVE_GNUTLS
|
|
|
404264 |
+ gnutls_fips140_set_mode(static_cast<gnutls_fips_mode_t>(oldmode), GNUTLS_FIPS140_SET_MODE_THREAD);
|
|
|
404264 |
+#endif
|
|
|
404264 |
}
|
|
|
404264 |
|
|
|
404264 |
void
|
|
|
404264 |
@@ -1169,6 +1185,12 @@ QPDF::decryptStream(Pipeline*& pipeline, int objid, int generation,
|
|
|
404264 |
QPDFObjectHandle& stream_dict,
|
|
|
404264 |
std::vector<PointerHolder<Pipeline> >& heap)
|
|
|
404264 |
{
|
|
|
404264 |
+#ifdef HAVE_GNUTLS
|
|
|
404264 |
+ unsigned oldmode = gnutls_fips140_mode_enabled();
|
|
|
404264 |
+
|
|
|
404264 |
+ gnutls_fips140_set_mode(GNUTLS_FIPS140_LAX, GNUTLS_FIPS140_SET_MODE_THREAD);
|
|
|
404264 |
+#endif
|
|
|
404264 |
+
|
|
|
404264 |
std::string type;
|
|
|
404264 |
if (stream_dict.getKey("/Type").isName())
|
|
|
404264 |
{
|
|
|
404264 |
@@ -1297,6 +1319,10 @@ QPDF::decryptStream(Pipeline*& pipeline, int objid, int generation,
|
|
|
404264 |
key.length());
|
|
|
404264 |
}
|
|
|
404264 |
heap.push_back(pipeline);
|
|
|
404264 |
+
|
|
|
404264 |
+#ifdef HAVE_GNUTLS
|
|
|
404264 |
+ gnutls_fips140_set_mode(static_cast<gnutls_fips_mode_t>(oldmode), GNUTLS_FIPS140_SET_MODE_THREAD);
|
|
|
404264 |
+#endif
|
|
|
404264 |
}
|
|
|
404264 |
|
|
|
404264 |
void
|