From 734ac1e1d2b3ce10a2da1a7e736a30bdf0bc5cf8 Mon Sep 17 00:00:00 2001 From: Jay Berkenbilt Date: Mon, 19 Oct 2009 01:58:31 +0000 Subject: deal with stream-specific crypt filters git-svn-id: svn+q:///qpdf/trunk@827 71b93d88-0707-0410-a8cf-f5a4172ac649 --- qpdf/qpdf.testcov | 1 + qpdf/qtest/qpdf.test | 10 +- qpdf/qtest/qpdf/decrypted-crypt-filter.pdf | Bin 0 -> 14383 bytes qpdf/qtest/qpdf/metadata-crypt-filter.pdf | 411 +++++++++++++++++++++++++++++ 4 files changed, 421 insertions(+), 1 deletion(-) create mode 100644 qpdf/qtest/qpdf/decrypted-crypt-filter.pdf create mode 100644 qpdf/qtest/qpdf/metadata-crypt-filter.pdf (limited to 'qpdf') diff --git a/qpdf/qpdf.testcov b/qpdf/qpdf.testcov index dd9ec5b1..6246e8e1 100644 --- a/qpdf/qpdf.testcov +++ b/qpdf/qpdf.testcov @@ -170,3 +170,4 @@ QPDFWriter forcing object stream disable 0 QPDFWriter forced version disabled encryption 0 qpdf-c called qpdf_set_r4_encryption_parameters 0 qpdf-c called qpdf_set_static_aes_IV 0 +QPDF_encryption stream crypt filter 0 diff --git a/qpdf/qtest/qpdf.test b/qpdf/qtest/qpdf.test index f1f2cc53..0c05121b 100644 --- a/qpdf/qtest/qpdf.test +++ b/qpdf/qtest/qpdf.test @@ -1079,7 +1079,7 @@ $td->runtest("make sure there is no xref stream", $td->NORMALIZE_NEWLINES); # Look at some actual V4 files -$n_tests += 8; +$n_tests += 10; foreach my $d (['--force-V4', 'V4'], ['--cleartext-metadata', 'V4-clearmeta'], ['--use-aes=y', 'V4-aes'], @@ -1094,6 +1094,14 @@ foreach my $d (['--force-V4', 'V4'], {$td->FILE => "a.pdf"}, {$td->FILE => "$out.pdf"}); } +# Crypt Filter +$td->runtest("decrypt with crypt filter", + {$td->COMMAND => "qpdf --decrypt --static-id" . + " metadata-crypt-filter.pdf a.pdf"}, + {$td->STRING => "", $td->EXIT_STATUS => 0}); +$td->runtest("check output", + {$td->FILE => 'a.pdf'}, + {$td->FILE => 'decrypted-crypt-filter.pdf'}); show_ntests(); # ---------- diff --git a/qpdf/qtest/qpdf/decrypted-crypt-filter.pdf b/qpdf/qtest/qpdf/decrypted-crypt-filter.pdf new file mode 100644 index 00000000..75e7f788 Binary files /dev/null and b/qpdf/qtest/qpdf/decrypted-crypt-filter.pdf differ diff --git a/qpdf/qtest/qpdf/metadata-crypt-filter.pdf b/qpdf/qtest/qpdf/metadata-crypt-filter.pdf new file mode 100644 index 00000000..39ed3d81 --- /dev/null +++ b/qpdf/qtest/qpdf/metadata-crypt-filter.pdf @@ -0,0 +1,411 @@ +%PDF-1.5 +% +1 0 obj +<< /Metadata 3 0 R /Outlines 4 0 R /PageLabels << /Nums [ 0 << /P () >> 2 << /S /r /St 1 >> 7 << /P () >> 9 << /S /r /St 6 >> 11 << /P () >> 12 << /S /D /St 2 >> 15 << /S /D /St 6 >> 19 << /P () >> 20 << /S /D /St 12 >> 22 << /S /D /St 16059 >> 23 << /S /r /St 50 >> 29 << /S /r /St 54 >> ] >> /PageMode /UseOutlines /Pages 5 0 R /Type /Catalog >> +endobj +2 0 obj +<< /CreationDate /ModDate >> +endobj +3 0 obj +<< /Subtype /XML /Type /Metadata /DecodeParms << /Name /Identity /Type /CryptFilterDecodeParms >> /Filter /Crypt /Length 770 >> +stream + + + + + + 2003-10-10T18:04:32-03:00 + 2003-10-10T18:04:32-03:00 + + + + 2003-10-10T18:04:32-03:00 + 2003-10-10T18:04:32-03:00 + 2003-10-10T18:04:32-03:00 + + + +endstream +endobj +4 0 obj +<< /Count 6 /First 6 0 R /Last 7 0 R /Type /Outlines >> +endobj +5 0 obj +<< /Count 30 /Kids [ 8 0 R 9 0 R 10 0 R 11 0 R 12 0 R 13 0 R 14 0 R 15 0 R 16 0 R 17 0 R 18 0 R 19 0 R 20 0 R 21 0 R 22 0 R 23 0 R 24 0 R 25 0 R 26 0 R 27 0 R 28 0 R 29 0 R 30 0 R 31 0 R 32 0 R 33 0 R 34 0 R 35 0 R 36 0 R 37 0 R ] /Type /Pages >> +endobj +6 0 obj +<< /Count 4 /Dest [ 13 0 R /XYZ null null null ] /First 38 0 R /Last 39 0 R /Next 7 0 R /Parent 4 0 R /Title <0bace566042e35f13ccb00496b6552b92c0c4c87ca4a8cbe11761a3c9718c8c0> /Type /Outline >> +endobj +7 0 obj +<< /Dest [ 23 0 R /XYZ 66 756 3 ] /Parent 4 0 R /Prev 6 0 R /Title /Type /Outline >> +endobj +8 0 obj +<< /Contents 40 0 R /CropBox [ 0 0 612 792 ] /MediaBox [ 0 0 612 792 ] /Parent 5 0 R /Resources << /Font << /F1 41 0 R >> /ProcSet 42 0 R >> /Rotate 0 /Type /Page >> +endobj +9 0 obj +<< /Contents 43 0 R /CropBox [ 0 0 612 792 ] /MediaBox [ 0 0 612 792 ] /Parent 5 0 R /Resources << /Font << /F1 41 0 R >> /ProcSet 42 0 R >> /Rotate 0 /Type /Page >> +endobj +10 0 obj +<< /Contents 44 0 R /CropBox [ 0 0 612 792 ] /MediaBox [ 0 0 612 792 ] /Parent 5 0 R /Resources << /Font << /F1 41 0 R >> /ProcSet 42 0 R >> /Rotate 0 /Type /Page >> +endobj +11 0 obj +<< /Contents 45 0 R /CropBox [ 0 0 612 792 ] /MediaBox [ 0 0 612 792 ] /Parent 5 0 R /Resources << /Font << /F1 41 0 R >> /ProcSet 42 0 R >> /Rotate 0 /Type /Page >> +endobj +12 0 obj +<< /Contents 46 0 R /CropBox [ 0 0 612 792 ] /MediaBox [ 0 0 612 792 ] /Parent 5 0 R /Resources << /Font << /F1 41 0 R >> /ProcSet 42 0 R >> /Rotate 0 /Type /Page >> +endobj +13 0 obj +<< /Contents 47 0 R /CropBox [ 0 0 612 792 ] /MediaBox [ 0 0 612 792 ] /Parent 5 0 R /Resources << /Font << /F1 41 0 R >> /ProcSet 42 0 R >> /Rotate 0 /Type /Page >> +endobj +14 0 obj +<< /Contents 48 0 R /CropBox [ 0 0 612 792 ] /MediaBox [ 0 0 612 792 ] /Parent 5 0 R /Resources << /Font << /F1 41 0 R >> /ProcSet 42 0 R >> /Rotate 0 /Type /Page >> +endobj +15 0 obj +<< /Contents 49 0 R /CropBox [ 0 0 612 792 ] /MediaBox [ 0 0 612 792 ] /Parent 5 0 R /Resources << /Font << /F1 41 0 R >> /ProcSet 42 0 R >> /Rotate 0 /Type /Page >> +endobj +16 0 obj +<< /Contents 50 0 R /CropBox [ 0 0 612 792 ] /MediaBox [ 0 0 612 792 ] /Parent 5 0 R /Resources << /Font << /F1 41 0 R >> /ProcSet 42 0 R >> /Rotate 0 /Type /Page >> +endobj +17 0 obj +<< /Contents 51 0 R /CropBox [ 0 0 612 792 ] /MediaBox [ 0 0 612 792 ] /Parent 5 0 R /Resources << /Font << /F1 41 0 R >> /ProcSet 42 0 R >> /Rotate 0 /Type /Page >> +endobj +18 0 obj +<< /Contents 52 0 R /CropBox [ 0 0 612 792 ] /MediaBox [ 0 0 612 792 ] /Parent 5 0 R /Resources << /Font << /F1 41 0 R >> /ProcSet 42 0 R >> /Rotate 0 /Type /Page >> +endobj +19 0 obj +<< /Contents 53 0 R /CropBox [ 0 0 612 792 ] /MediaBox [ 0 0 612 792 ] /Parent 5 0 R /Resources << /Font << /F1 41 0 R >> /ProcSet 42 0 R >> /Rotate 0 /Type /Page >> +endobj +20 0 obj +<< /Contents 54 0 R /CropBox [ 0 0 612 792 ] /MediaBox [ 0 0 612 792 ] /Parent 5 0 R /Resources << /Font << /F1 41 0 R >> /ProcSet 42 0 R >> /Rotate 0 /Type /Page >> +endobj +21 0 obj +<< /Contents 55 0 R /CropBox [ 0 0 612 792 ] /MediaBox [ 0 0 612 792 ] /Parent 5 0 R /Resources << /Font << /F1 41 0 R >> /ProcSet 42 0 R >> /Rotate 0 /Type /Page >> +endobj +22 0 obj +<< /Contents 56 0 R /CropBox [ 0 0 612 792 ] /MediaBox [ 0 0 612 792 ] /Parent 5 0 R /Resources << /Font << /F1 41 0 R >> /ProcSet 42 0 R >> /Rotate 0 /Type /Page >> +endobj +23 0 obj +<< /Contents 57 0 R /CropBox [ 0 0 612 792 ] /MediaBox [ 0 0 612 792 ] /Parent 5 0 R /Resources << /Font << /F1 41 0 R >> /ProcSet 42 0 R >> /Rotate 0 /Type /Page >> +endobj +24 0 obj +<< /Contents 58 0 R /CropBox [ 0 0 612 792 ] /MediaBox [ 0 0 612 792 ] /Parent 5 0 R /Resources << /Font << /F1 41 0 R >> /ProcSet 42 0 R >> /Rotate 0 /Type /Page >> +endobj +25 0 obj +<< /Contents 59 0 R /CropBox [ 0 0 612 792 ] /MediaBox [ 0 0 612 792 ] /Parent 5 0 R /Resources << /Font << /F1 41 0 R >> /ProcSet 42 0 R >> /Rotate 0 /Type /Page >> +endobj +26 0 obj +<< /Contents 60 0 R /CropBox [ 0 0 612 792 ] /MediaBox [ 0 0 612 792 ] /Parent 5 0 R /Resources << /Font << /F1 41 0 R >> /ProcSet 42 0 R >> /Rotate 0 /Type /Page >> +endobj +27 0 obj +<< /Contents 61 0 R /CropBox [ 0 0 612 792 ] /MediaBox [ 0 0 612 792 ] /Parent 5 0 R /Resources << /Font << /F1 41 0 R >> /ProcSet 42 0 R >> /Rotate 0 /Type /Page >> +endobj +28 0 obj +<< /Contents 62 0 R /CropBox [ 0 0 612 792 ] /MediaBox [ 0 0 612 792 ] /Parent 5 0 R /Resources << /Font << /F1 41 0 R >> /ProcSet 42 0 R >> /Rotate 0 /Type /Page >> +endobj +29 0 obj +<< /Contents 63 0 R /CropBox [ 0 0 612 792 ] /MediaBox [ 0 0 612 792 ] /Parent 5 0 R /Resources << /Font << /F1 41 0 R >> /ProcSet 42 0 R >> /Rotate 0 /Type /Page >> +endobj +30 0 obj +<< /Contents 64 0 R /CropBox [ 0 0 612 792 ] /MediaBox [ 0 0 612 792 ] /Parent 5 0 R /Resources << /Font << /F1 41 0 R >> /ProcSet 42 0 R >> /Rotate 0 /Type /Page >> +endobj +31 0 obj +<< /Contents 65 0 R /CropBox [ 0 0 612 792 ] /MediaBox [ 0 0 612 792 ] /Parent 5 0 R /Resources << /Font << /F1 41 0 R >> /ProcSet 42 0 R >> /Rotate 0 /Type /Page >> +endobj +32 0 obj +<< /Contents 66 0 R /CropBox [ 0 0 612 792 ] /MediaBox [ 0 0 612 792 ] /Parent 5 0 R /Resources << /Font << /F1 41 0 R >> /ProcSet 42 0 R >> /Rotate 0 /Type /Page >> +endobj +33 0 obj +<< /Contents 67 0 R /CropBox [ 0 0 612 792 ] /MediaBox [ 0 0 612 792 ] /Parent 5 0 R /Resources << /Font << /F1 41 0 R >> /ProcSet 42 0 R >> /Rotate 0 /Type /Page >> +endobj +34 0 obj +<< /Contents 68 0 R /CropBox [ 0 0 612 792 ] /MediaBox [ 0 0 612 792 ] /Parent 5 0 R /Resources << /Font << /F1 41 0 R >> /ProcSet 42 0 R >> /Rotate 0 /Type /Page >> +endobj +35 0 obj +<< /Contents 69 0 R /CropBox [ 0 0 612 792 ] /MediaBox [ 0 0 612 792 ] /Parent 5 0 R /Resources << /Font << /F1 41 0 R >> /ProcSet 42 0 R >> /Rotate 0 /Type /Page >> +endobj +36 0 obj +<< /Contents 70 0 R /CropBox [ 0 0 612 792 ] /MediaBox [ 0 0 612 792 ] /Parent 5 0 R /Resources << /Font << /F1 41 0 R >> /ProcSet 42 0 R >> /Rotate 0 /Type /Page >> +endobj +37 0 obj +<< /Contents 71 0 R /CropBox [ 0 0 612 792 ] /MediaBox [ 0 0 612 792 ] /Parent 5 0 R /Resources << /Font << /F1 41 0 R >> /ProcSet 42 0 R >> /Rotate 0 /Type /Page >> +endobj +38 0 obj +<< /Count -3 /Dest [ 19 0 R /Fit ] /First 72 0 R /Last 73 0 R /Next 39 0 R /Parent 6 0 R /Title <3fb30ac89234ff057e20814f60a034d2e5025f8cc58e> /Type /Outline >> +endobj +39 0 obj +<< /Count 2 /Dest [ 21 0 R /FitH 792 ] /First 74 0 R /Last 75 0 R /Parent 6 0 R /Prev 38 0 R /Title /Type /Outline >> +endobj +40 0 obj +<< /Length 50 /Filter /FlateDecode >> +stream + tv4Rnjaa-XjEB)s7DZJlendstream +endobj +41 0 obj +<< /BaseFont /Helvetica /Encoding /WinAnsiEncoding /Name /F1 /Subtype /Type1 /Type /Font >> +endobj +42 0 obj +[ /PDF /Text ] +endobj +43 0 obj +<< /Length 50 /Filter /FlateDecode >> +stream +KCZX.WZhwwA'v jWY}endstream +endobj +44 0 obj +<< /Length 50 /Filter /FlateDecode >> +stream +ę|qsg:/IƸҐQ,V;Ukb{Ԝ,endstream +endobj +45 0 obj +<< /Length 50 /Filter /FlateDecode >> +stream +Cv=J@VޥI>Ht5y{7ݢK٪Py˨h_endstream +endobj +46 0 obj +<< /Length 50 /Filter /FlateDecode >> +stream +FKEnADov8 ,J;4J؇am"endstream +endobj +47 0 obj +<< /Length 50 /Filter /FlateDecode >> +stream +1'[1fi:l:S$GʮD1:]Ѩiendstream +endobj +48 0 obj +<< /Length 50 /Filter /FlateDecode >> +stream +2d#[ߑ)Oŵ j)^iNmOʢf}endstream +endobj +49 0 obj +<< /Length 50 /Filter /FlateDecode >> +stream +&;PG2fs@[Ԡy> +stream +7ۥsIT!ݔ%ÞXjIdMVQ+{65fendstream +endobj +51 0 obj +<< /Length 50 /Filter /FlateDecode >> +stream +l∿q kO vѪ[F3D{CAp,endstream +endobj +52 0 obj +<< /Length 51 /Filter /FlateDecode >> +stream +bǕM+|f.Ѥ8|{o#-&t%ca|Tendstream +endobj +53 0 obj +<< /Length 51 /Filter /FlateDecode >> +stream +Nc&fFuy4e.X\X"Kp;E[hzKcbendstream +endobj +54 0 obj +<< /Length 51 /Filter /FlateDecode >> +stream +}s+8QH}zM >i|v&&|!endstream +endobj +55 0 obj +<< /Length 51 /Filter /FlateDecode >> +stream +&hyu8iҐ̈́qSQ #.P5)I}+ˮendstream +endobj +56 0 obj +<< /Length 51 /Filter /FlateDecode >> +stream +X$Q$ B2.`e\tVw'q#E(~Yހd}endstream +endobj +57 0 obj +<< /Length 51 /Filter /FlateDecode >> +stream +_|Y9-n*k IAs}瑁L_9AsRendstream +endobj +58 0 obj +<< /Length 51 /Filter /FlateDecode >> +stream +_ZţH#!ެk39$/m?ڦl/Z/}@6@Vve7endstream +endobj +59 0 obj +<< /Length 51 /Filter /FlateDecode >> +stream +Fl+y'k`2orfY%1endstream +endobj +60 0 obj +<< /Length 51 /Filter /FlateDecode >> +stream +D%MXe=F( Iv_enҩVb! r!Iendstream +endobj +61 0 obj +<< /Length 51 /Filter /FlateDecode >> +stream +}Q[ULWh]"*ԶGt3~njoo{CD endstream +endobj +62 0 obj +<< /Length 51 /Filter /FlateDecode >> +stream +!Ӂ7aJ8c1[LܼPQl.bS)al L#+&sendstream +endobj +63 0 obj +<< /Length 51 /Filter /FlateDecode >> +stream +nqbv0X:V|b毕hmG0۔> +stream +@UYX#`[sS?*f( HuhByendstream +endobj +65 0 obj +<< /Length 51 /Filter /FlateDecode >> +stream +dq[!r09 F)hBQcGS`E)6k?mIendstream +endobj +66 0 obj +<< /Length 50 /Filter /FlateDecode >> +stream +p*-$ +>v_a.F!f2%endstream +endobj +67 0 obj +<< /Length 51 /Filter /FlateDecode >> +stream +WSX\,^Mʵ2A" p]>|/X,P3endstream +endobj +68 0 obj +<< /Length 51 /Filter /FlateDecode >> +stream +օU=MŢNSgϮݏX +#߀}`*?h6Pss{Vendstream +endobj +69 0 obj +<< /Length 51 /Filter /FlateDecode >> +stream +!h,s!/Ci"#mCAO$9Ⱦh${OM'endstream +endobj +70 0 obj +<< /Length 51 /Filter /FlateDecode >> +stream +7ZSL0=ƻ./ +|:&_! s*u#endstream +endobj +71 0 obj +<< /Length 51 /Filter /FlateDecode >> +stream +P+@Y( {?g]lvR9UŒ?-wOendstream +endobj +72 0 obj +<< /Count -2 /Dest [ 20 0 R /FitV 100 ] /First 76 0 R /Last 77 0 R /Next 73 0 R /Parent 38 0 R /Title /Type /Outline >> +endobj +73 0 obj +<< /Count 1 /Dest [ 20 0 R /XYZ null null null ] /First 78 0 R /Last 78 0 R /Parent 38 0 R /Prev 72 0 R /Title (輧:8\226v\)N\(\210\035NT\036mvj\tnl\212;o.\2113) /Type /Outline >> +endobj +74 0 obj +<< /Dest [ 9 0 R /FitR 66 714 180 770 ] /Next 75 0 R /Parent 39 0 R /Title <498fe6ebfb28be416edddb53c1a63ffee3887fce2a7a2e34043792493f5a7c1f8818fa24a81dbbd055212dae> /Type /Outline >> +endobj +75 0 obj +<< /Dest [ 8 0 R /XYZ null null null ] /Parent 39 0 R /Prev 74 0 R /Title <69fb82b1b1b8833e343e5f401879d3083e0cd738a3f54342e881ead5b6bc1816e7e3b431d48b1c0a14> /Type /Outline >> +endobj +76 0 obj +<< /Dest [ 26 0 R /XYZ null null null ] /Next 77 0 R /Parent 72 0 R /Title <1433a18038fcd41d81200f85f0f942caedcce35a9fddde851dd1b70def5f196aeac27ccf5f5b725ecc89be> /Type /Outline >> +endobj +77 0 obj +<< /Dest [ 27 0 R /XYZ null null null ] /Parent 72 0 R /Prev 76 0 R /Title <9028484736aaf8f0b5eedc521a7169cc9e2295cfd80eed0c2e41c44c26ba7c6ff586a290be701394f7e5ad> /Type /Outline >> +endobj +78 0 obj +<< /Dest [ 30 0 R /XYZ null null null ] /Parent 73 0 R /Title <6c21f1d776e7e20cadb7be7247c9856e4da1fbaded20b1596cc68c35e8c7f5c2ebd4a242796ea858837daa> /Type /Outline >> +endobj +79 0 obj +<< /CF << /StdCF << /AuthEvent /DocOpen /CFM /V2 >> >> /EncryptMetadata false /Filter /Standard /Length 128 /O <566fa873ee33c797cd3b904fdadf814afa34df9a38f6ed41b984e2c6da2aa6f5> /P -4 /R 4 /StmF /StdCF /StrF /StdCF /U <3a40816f776fccd39a9c505a9d4110e60122456a91bae5134273a6db134c87c4> /V 4 >> +endobj +xref +0 80 +0000000000 65535 f +0000000015 00000 n +0000000378 00000 n +0000000520 00000 n +0000001450 00000 n +0000001521 00000 n +0000001783 00000 n +0000001992 00000 n +0000002153 00000 n +0000002334 00000 n +0000002515 00000 n +0000002697 00000 n +0000002879 00000 n +0000003061 00000 n +0000003243 00000 n +0000003425 00000 n +0000003607 00000 n +0000003789 00000 n +0000003971 00000 n +0000004153 00000 n +0000004335 00000 n +0000004517 00000 n +0000004699 00000 n +0000004881 00000 n +0000005063 00000 n +0000005245 00000 n +0000005427 00000 n +0000005609 00000 n +0000005791 00000 n +0000005973 00000 n +0000006155 00000 n +0000006337 00000 n +0000006519 00000 n +0000006701 00000 n +0000006883 00000 n +0000007065 00000 n +0000007247 00000 n +0000007429 00000 n +0000007611 00000 n +0000007788 00000 n +0000007977 00000 n +0000008098 00000 n +0000008206 00000 n +0000008237 00000 n +0000008358 00000 n +0000008479 00000 n +0000008600 00000 n +0000008721 00000 n +0000008842 00000 n +0000008963 00000 n +0000009084 00000 n +0000009205 00000 n +0000009326 00000 n +0000009448 00000 n +0000009570 00000 n +0000009692 00000 n +0000009814 00000 n +0000009936 00000 n +0000010058 00000 n +0000010180 00000 n +0000010302 00000 n +0000010424 00000 n +0000010546 00000 n +0000010668 00000 n +0000010790 00000 n +0000010912 00000 n +0000011034 00000 n +0000011155 00000 n +0000011277 00000 n +0000011399 00000 n +0000011521 00000 n +0000011643 00000 n +0000011765 00000 n +0000011966 00000 n +0000012176 00000 n +0000012376 00000 n +0000012569 00000 n +0000012767 00000 n +0000012965 00000 n +0000013150 00000 n +trailer << /Info 2 0 R /Root 1 0 R /Size 80 /ID [<66d36a30a97e0f16f39955c6221e0c2a><31415926535897932384626433832795>] /Encrypt 79 0 R >> +startxref +13459 +%%EOF -- cgit v1.2.3-70-g09d2