From 93ac1695a4b79f3d5b71e2d57ed876c28866d2c9 Mon Sep 17 00:00:00 2001 From: Jay Berkenbilt Date: Sat, 29 Dec 2012 19:00:05 -0500 Subject: Support files with only attachments encrypted Test cases added in a future commit since they depend on /R=6 support. --- libqpdf/QPDFWriter.cc | 28 +++++++--------------------- 1 file changed, 7 insertions(+), 21 deletions(-) (limited to 'libqpdf/QPDFWriter.cc') diff --git a/libqpdf/QPDFWriter.cc b/libqpdf/QPDFWriter.cc index cde76af9..8bfb6ff9 100644 --- a/libqpdf/QPDFWriter.cc +++ b/libqpdf/QPDFWriter.cc @@ -470,27 +470,13 @@ QPDFWriter::copyEncryptionParameters(QPDF& qpdf) } if (V >= 4) { - if (encrypt.hasKey("/CF") && - encrypt.getKey("/CF").isDictionary() && - encrypt.hasKey("/StmF") && - encrypt.getKey("/StmF").isName()) - { - // Determine whether to use AES from StmF. QPDFWriter - // can't write files with different StrF and StmF. - QPDFObjectHandle CF = encrypt.getKey("/CF"); - QPDFObjectHandle StmF = encrypt.getKey("/StmF"); - if (CF.hasKey(StmF.getName()) && - CF.getKey(StmF.getName()).isDictionary()) - { - QPDFObjectHandle StmF_data = CF.getKey(StmF.getName()); - if (StmF_data.hasKey("/CFM") && - StmF_data.getKey("/CFM").isName() && - StmF_data.getKey("/CFM").getName() == "/AESV2") - { - this->encrypt_use_aes = true; - } - } - } + // When copying encryption parameters, use AES even if the + // original file did not. Acrobat doesn't create files + // with V >= 4 that don't use AES, and the logic of + // figuring out whether AES is used or not is complicated + // with /StmF, /StrF, and /EFF all potentially having + // different values. + this->encrypt_use_aes = true; } QTC::TC("qpdf", "QPDFWriter copy encrypt metadata", this->encrypt_metadata ? 0 : 1); -- cgit v1.2.3-54-g00ecf