From a101533e0a76a0890a2ad3ea5fcbb578da75a6b4 Mon Sep 17 00:00:00 2001 From: Jay Berkenbilt Date: Sun, 15 Jul 2012 21:15:24 -0400 Subject: 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. --- libqpdf/QPDF_encryption.cc | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) (limited to 'libqpdf/QPDF_encryption.cc') 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 @@ -743,6 +743,17 @@ 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) { @@ -750,8 +761,13 @@ QPDF::isEncrypted(int& R, int& P) 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 -- cgit v1.2.3-54-g00ecf