aboutsummaryrefslogtreecommitdiffstats
path: root/libqpdf/QPDF_encryption.cc
diff options
context:
space:
mode:
authorJay Berkenbilt <ejb@ql.org>2009-10-19 03:58:31 +0200
committerJay Berkenbilt <ejb@ql.org>2009-10-19 03:58:31 +0200
commit734ac1e1d2b3ce10a2da1a7e736a30bdf0bc5cf8 (patch)
treecad02f21cf00a93e4209f74ab96b96f707dd0aaa /libqpdf/QPDF_encryption.cc
parent70ae58c0355e06cfe7d97426b28a61ab419ef276 (diff)
downloadqpdf-734ac1e1d2b3ce10a2da1a7e736a30bdf0bc5cf8.tar.zst
deal with stream-specific crypt filters
git-svn-id: svn+q:///qpdf/trunk@827 71b93d88-0707-0410-a8cf-f5a4172ac649
Diffstat (limited to 'libqpdf/QPDF_encryption.cc')
-rw-r--r--libqpdf/QPDF_encryption.cc25
1 files changed, 13 insertions, 12 deletions
diff --git a/libqpdf/QPDF_encryption.cc b/libqpdf/QPDF_encryption.cc
index fa16f55d..8962624d 100644
--- a/libqpdf/QPDF_encryption.cc
+++ b/libqpdf/QPDF_encryption.cc
@@ -600,18 +600,19 @@ QPDF::decryptStream(Pipeline*& pipeline, int objid, int generation,
encryption_method_e method = e_unknown;
std::string method_source = "/StmF from /Encrypt dictionary";
- // NOTE: the section in the PDF specification on crypt filters
- // seems to suggest that there might be a /Crypt key in
- // /DecodeParms whose value is a crypt filter (.e.g., << /Name
- // /StdCF >>), but implementation notes suggest this can only
- // happen for metadata streams, and emperical observation
- // suggests that they are otherwise ignored. Not having been
- // able to find a sample file that uses crypt filters in any
- // way other than /StrF and /StmF, I'm not really sure what to
- // do about this. If we were to override the encryption on a
- // per-stream basis using crypt filters, set method_source to
- // something useful in the error message for unknown
- // encryption methods (search for method_source).
+ if (stream_dict.getKey("/Filter").isOrHasName("/Crypt") &&
+ stream_dict.getKey("/DecodeParms").isDictionary())
+ {
+ QPDFObjectHandle decode_parms = stream_dict.getKey("/DecodeParms");
+ if (decode_parms.getKey("/Type").isName() &&
+ (decode_parms.getKey("/Type").getName() ==
+ "/CryptFilterDecodeParms"))
+ {
+ QTC::TC("qpdf", "QPDF_encryption stream crypt filter");
+ method = interpretCF(decode_parms.getKey("/Name"));
+ method_source = "stream's Crypt decode parameters";
+ }
+ }
if (method == e_unknown)
{