aboutsummaryrefslogtreecommitdiffstats
path: root/libqpdf
diff options
context:
space:
mode:
authorJay Berkenbilt <ejb@ql.org>2009-10-19 02:17:11 +0200
committerJay Berkenbilt <ejb@ql.org>2009-10-19 02:17:11 +0200
commit09175e457852c585a68a86d43280f7e0790a4a3b (patch)
tree64269f6bb06d53975f4b8fe51a3900f868748629 /libqpdf
parent94131116a90a076c49e799aa5e4c63ce0ecb0391 (diff)
downloadqpdf-09175e457852c585a68a86d43280f7e0790a4a3b.tar.zst
more testing, bug fix for linearized aes encrypted files
git-svn-id: svn+q:///qpdf/trunk@824 71b93d88-0707-0410-a8cf-f5a4172ac649
Diffstat (limited to 'libqpdf')
-rw-r--r--libqpdf/QPDFWriter.cc59
1 files changed, 58 insertions, 1 deletions
diff --git a/libqpdf/QPDFWriter.cc b/libqpdf/QPDFWriter.cc
index d094aa66..3c1640f7 100644
--- a/libqpdf/QPDFWriter.cc
+++ b/libqpdf/QPDFWriter.cc
@@ -345,6 +345,52 @@ QPDFWriter::copyEncryptionParameters()
}
void
+QPDFWriter::disableIncompatbleEncryption(float v)
+{
+ if (! this->encrypted)
+ {
+ return;
+ }
+
+ bool disable = false;
+ if (v < 1.3)
+ {
+ disable = true;
+ }
+ else
+ {
+ int V = atoi(encryption_dictionary["/V"].c_str());
+ int R = atoi(encryption_dictionary["/R"].c_str());
+ if (v < 1.4)
+ {
+ if ((V > 1) || (R > 2))
+ {
+ disable = true;
+ }
+ }
+ else if (v < 1.5)
+ {
+ if ((V > 2) || (R > 3))
+ {
+ disable = true;
+ }
+ }
+ else if (v < 1.6)
+ {
+ if (this->encrypt_use_aes)
+ {
+ disable = true;
+ }
+ }
+ }
+ if (disable)
+ {
+ QTC::TC("qpdf", "QPDFWriter forced version disabled encryption");
+ this->encrypted = false;
+ }
+}
+
+void
QPDFWriter::setEncryptionParametersInternal(
int V, int R, int key_len, long P,
std::string const& O, std::string const& U,
@@ -965,7 +1011,7 @@ QPDFWriter::unparseObject(QPDFObjectHandle object, int level,
Buffer* buf = bufpl.getBuffer();
val = QPDF_String(
std::string((char*)buf->getBuffer(),
- (size_t)buf->getSize())).unparse();
+ (size_t)buf->getSize())).unparse(true);
delete buf;
}
else
@@ -1423,6 +1469,17 @@ QPDFWriter::write()
copyEncryptionParameters();
}
+ if (! this->forced_pdf_version.empty())
+ {
+ float v = atof(this->forced_pdf_version.c_str());
+ disableIncompatbleEncryption(v);
+ if (v < 1.5)
+ {
+ QTC::TC("qpdf", "QPDFWriter forcing object stream disable");
+ this->object_stream_mode = o_disable;
+ }
+ }
+
if (this->qdf_mode || this->normalize_content ||
(this->stream_data_mode == s_uncompress))
{