From b873dc9c59f4445239f68d7138aebb53cc0df648 Mon Sep 17 00:00:00 2001 From: Jay Berkenbilt Date: Sun, 18 Oct 2009 02:03:18 +0000 Subject: implemented writing R4/V4 encryption except that the output files don't open in Adobe reader 9.1.3. git-svn-id: svn+q:///qpdf/trunk@816 71b93d88-0707-0410-a8cf-f5a4172ac649 --- include/qpdf/QPDFWriter.hh | 20 +++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) (limited to 'include') diff --git a/include/qpdf/QPDFWriter.hh b/include/qpdf/QPDFWriter.hh index a9392839..8a4e9ebe 100644 --- a/include/qpdf/QPDFWriter.hh +++ b/include/qpdf/QPDFWriter.hh @@ -118,9 +118,10 @@ class DLL_EXPORT QPDFWriter // Set up for encrypted output. Disables stream prefiltering and // content normalization. Note that setting R2 encryption - // parameters sets the PDF version to at least 1.3, and setting R3 + // parameters sets the PDF version to at least 1.3, setting R3 // encryption parameters pushes the PDF version number to at least - // 1.4. + // 1.4, and setting R4 parameters pushes the version to at least + // 1.5, or if AES is used, 1.6. void setR2EncryptionParameters( char const* user_password, char const* owner_password, bool allow_print, bool allow_modify, @@ -143,6 +144,11 @@ class DLL_EXPORT QPDFWriter char const* user_password, char const* owner_password, bool allow_accessibility, bool allow_extract, r3_print_e print, r3_modify_e modify); + void setR4EncryptionParameters( + char const* user_password, char const* owner_password, + bool allow_accessibility, bool allow_extract, + r3_print_e print, r3_modify_e modify, + bool encrypt_metadata, bool use_aes); // Create linearized output. Disables qdf mode, content // normalization, and stream prefiltering. @@ -182,6 +188,11 @@ class DLL_EXPORT QPDFWriter void preserveObjectStreams(); void generateObjectStreams(); void generateID(); + void interpretR3EncryptionParameters( + std::set& bits_to_clear, + char const* user_password, char const* owner_password, + bool allow_accessibility, bool allow_extract, + r3_print_e print, r3_modify_e modify); void setEncryptionParameters( char const* user_password, char const* owner_password, int V, int R, int key_len, std::set& bits_to_clear); @@ -231,6 +242,7 @@ class DLL_EXPORT QPDFWriter // stack items are of type Pl_Buffer, the buffer is retrieved. void popPipelineStack(PointerHolder* bp = 0); + void adjustAESStreamLength(unsigned long& length); void pushEncryptionFilter(); void pushDiscardFilter(); @@ -251,6 +263,8 @@ class DLL_EXPORT QPDFWriter bool linearized; object_stream_e object_stream_mode; std::string encryption_key; + bool encrypt_metadata; + bool encrypt_use_aes; std::map encryption_dictionary; std::string id1; // for /ID key of @@ -267,7 +281,7 @@ class DLL_EXPORT QPDFWriter std::map lengths; int next_objid; int cur_stream_length_id; - int cur_stream_length; + unsigned long cur_stream_length; bool added_newline; int max_ostream_index; std::set normalized_streams; -- cgit v1.2.3-54-g00ecf