Commit 67e353e4e4a9207e26171502f44fb2efbf7848c1

Authored by Jay Berkenbilt
1 parent b873dc9c

use StdCF to make adobe reader happy; handle EncryptMetadata properly when reading

git-svn-id: svn+q:///qpdf/trunk@817 71b93d88-0707-0410-a8cf-f5a4172ac649
@@ -55,12 +55,12 @@ @@ -55,12 +55,12 @@
55 55
56 - figure out a way to test crypt filters defined on a stream 56 - figure out a way to test crypt filters defined on a stream
57 57
  58 + - test extraction of metadata with and without encrypted metadata
  59 +
58 - would be nice to test strings and streams with different 60 - would be nice to test strings and streams with different
59 encryption types, but without sample data, we'd have to write 61 encryption types, but without sample data, we'd have to write
60 them ourselves which is not that useful 62 them ourselves which is not that useful
61 63
62 - - figure out why xpdf can open my files but not acroread  
63 -  
64 - figure out how to look at the metadata so I can tell whether 64 - figure out how to look at the metadata so I can tell whether
65 /EncryptMetadata is working the way it's supposed to 65 /EncryptMetadata is working the way it's supposed to
66 66
libqpdf/QPDFWriter.cc
@@ -363,11 +363,14 @@ QPDFWriter::setEncryptionParametersInternal( @@ -363,11 +363,14 @@ QPDFWriter::setEncryptionParametersInternal(
363 } 363 }
364 if (V == 4) 364 if (V == 4)
365 { 365 {
366 - encryption_dictionary["/StmF"] = "/CF1";  
367 - encryption_dictionary["/StrF"] = "/CF1"; 366 + // The spec says the value for the crypt filter key can be
  367 + // anything, and xpdf seems to agree. However, Adobe Reader
  368 + // won't open our files unless we use /StdCF.
  369 + encryption_dictionary["/StmF"] = "/StdCF";
  370 + encryption_dictionary["/StrF"] = "/StdCF";
368 std::string method = (this->encrypt_use_aes ? "/AESV2" : "/V2"); 371 std::string method = (this->encrypt_use_aes ? "/AESV2" : "/V2");
369 encryption_dictionary["/CF"] = 372 encryption_dictionary["/CF"] =
370 - "<< /CF1 << /AuthEvent /DocOpen /CFM " + method + " >> >>"; 373 + "<< /StdCF << /AuthEvent /DocOpen /CFM " + method + " >> >>";
371 } 374 }
372 375
373 this->encrypted = true; 376 this->encrypted = true;
libqpdf/QPDF_encryption.cc
@@ -612,7 +612,7 @@ QPDF::decryptStream(Pipeline*&amp; pipeline, int objid, int generation, @@ -612,7 +612,7 @@ QPDF::decryptStream(Pipeline*&amp; pipeline, int objid, int generation,
612 // XXX What about embedded file streams? 612 // XXX What about embedded file streams?
613 } 613 }
614 use_aes = false; 614 use_aes = false;
615 - switch (this->cf_stream) 615 + switch (method)
616 { 616 {
617 case e_none: 617 case e_none:
618 return; 618 return;