From 569d74d36ba287b6951687ee1bdea45ae19091f8 Mon Sep 17 00:00:00 2001 From: Jay Berkenbilt Date: Sun, 14 Jan 2018 10:17:17 -0500 Subject: 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 for the idea and contribution of one implementation of this idea. --- include/qpdf/QPDF.hh | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) (limited to 'include') 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, 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 file; std::string last_object_description; + bool provided_password_is_hex_key; bool encrypted; bool encryption_initialized; bool ignore_xref_streams; -- cgit v1.2.3-54-g00ecf