aboutsummaryrefslogtreecommitdiffstats
path: root/libqpdf/QPDF_encryption.cc
diff options
context:
space:
mode:
authorJay Berkenbilt <ejb@ql.org>2012-07-16 03:15:24 +0200
committerJay Berkenbilt <ejb@ql.org>2012-07-16 03:15:24 +0200
commita101533e0a76a0890a2ad3ea5fcbb578da75a6b4 (patch)
treebbd553716ff1ddd2224a03248ba7be802bfcd4ea /libqpdf/QPDF_encryption.cc
parentb26ce88ea172a5a3b66d0b8dd94b98043831eb27 (diff)
downloadqpdf-a101533e0a76a0890a2ad3ea5fcbb578da75a6b4.tar.zst
Add command line option to copy encryption from other file
Add --copy-encryption and --encryption-file-password options to qpdf. Also strengthen test suite for copying encryption. The strengthened test suite would have caught the failure to preserve AES and the failure to update the file version, which was invalidating the encrypted data.
Diffstat (limited to 'libqpdf/QPDF_encryption.cc')
-rw-r--r--libqpdf/QPDF_encryption.cc16
1 files changed, 16 insertions, 0 deletions
diff --git a/libqpdf/QPDF_encryption.cc b/libqpdf/QPDF_encryption.cc
index ee5d5685..c73a47bf 100644
--- a/libqpdf/QPDF_encryption.cc
+++ b/libqpdf/QPDF_encryption.cc
@@ -744,14 +744,30 @@ QPDF::isEncrypted() const
bool
QPDF::isEncrypted(int& R, int& P)
{
+ int V;
+ encryption_method_e stream, string, file;
+ return isEncrypted(R, P, V, stream, string, file);
+}
+
+bool
+QPDF::isEncrypted(int& R, int& P, int& V,
+ encryption_method_e& stream_method,
+ encryption_method_e& string_method,
+ encryption_method_e& file_method)
+{
if (this->encrypted)
{
QPDFObjectHandle trailer = getTrailer();
QPDFObjectHandle encrypt = trailer.getKey("/Encrypt");
QPDFObjectHandle Pkey = encrypt.getKey("/P");
QPDFObjectHandle Rkey = encrypt.getKey("/R");
+ QPDFObjectHandle Vkey = encrypt.getKey("/V");
P = Pkey.getIntValue();
R = Rkey.getIntValue();
+ V = Vkey.getIntValue();
+ stream_method = this->cf_stream;
+ string_method = this->cf_stream;
+ file_method = this->cf_file;
return true;
}
else