aboutsummaryrefslogtreecommitdiffstats
path: root/include
diff options
context:
space:
mode:
authorJay Berkenbilt <ejb@ql.org>2018-01-14 16:17:17 +0100
committerJay Berkenbilt <ejb@ql.org>2018-01-14 16:21:05 +0100
commit569d74d36ba287b6951687ee1bdea45ae19091f8 (patch)
tree2a8e05610e45ddc16f86bd06eae926fa12087f44 /include
parent3e306ae64cc3d160034f27d72ad27bee03a65aa5 (diff)
downloadqpdf-569d74d36ba287b6951687ee1bdea45ae19091f8.tar.zst
Allow raw encryption key to be specified
Add options to enable the raw encryption key to be directly shown or specified. Thanks to Didier Stevens <didier.stevens@gmail.com> for the idea and contribution of one implementation of this idea.
Diffstat (limited to 'include')
-rw-r--r--include/qpdf/QPDF.hh19
1 files changed, 18 insertions, 1 deletions
diff --git a/include/qpdf/QPDF.hh b/include/qpdf/QPDF.hh
index d82af11e..70bfac3e 100644
--- a/include/qpdf/QPDF.hh
+++ b/include/qpdf/QPDF.hh
@@ -64,7 +64,11 @@ class QPDF
// those that set parameters. If the input file is not
// encrypted,either a null password or an empty password can be
// used. If the file is encrypted, either the user password or
- // the owner password may be supplied.
+ // the owner password may be supplied. The method
+ // setPasswordIsHexKey may be called prior to calling this method
+ // or any of the other process methods to force the password to be
+ // interpreted as a raw encryption key. See comments on
+ // setPasswordIsHexKey for more information.
QPDF_DLL
void processFile(char const* filename, char const* password = 0);
@@ -94,6 +98,18 @@ class QPDF
void processInputSource(PointerHolder<InputSource>,
char const* password = 0);
+ // For certain forensic or investigatory purposes, it may
+ // sometimes be useful to specify the encryption key directly,
+ // even though regular PDF applications do not provide a way to do
+ // this. calling setPasswordIsHexKey(true) before calling any of
+ // the process methods will bypass the normal encryption key
+ // computation or recovery mechanisms and interpret the bytes in
+ // the password as a hex-encoded encryption key. Note that we
+ // hex-encode the key because it may contain null bytes and
+ // therefore can't be represented in a char const*.
+ QPDF_DLL
+ void setPasswordIsHexKey(bool);
+
// Create a QPDF object for an empty PDF. This PDF has no pages
// or objects other than a minimal trailer, a document catalog,
// and a /Pages tree containing zero pages. Pages and other
@@ -1145,6 +1161,7 @@ class QPDF
QPDFTokenizer tokenizer;
PointerHolder<InputSource> file;
std::string last_object_description;
+ bool provided_password_is_hex_key;
bool encrypted;
bool encryption_initialized;
bool ignore_xref_streams;