aboutsummaryrefslogtreecommitdiffstats
path: root/libqpdf/QPDF_encryption.cc
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 /libqpdf/QPDF_encryption.cc
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 'libqpdf/QPDF_encryption.cc')
-rw-r--r--libqpdf/QPDF_encryption.cc14
1 files changed, 11 insertions, 3 deletions
diff --git a/libqpdf/QPDF_encryption.cc b/libqpdf/QPDF_encryption.cc
index a2445b61..fd717c35 100644
--- a/libqpdf/QPDF_encryption.cc
+++ b/libqpdf/QPDF_encryption.cc
@@ -1007,8 +1007,12 @@ QPDF::initializeEncryption()
EncryptionData data(V, R, Length / 8, P, O, U, OE, UE, Perms,
id1, this->m->encrypt_metadata);
- if (check_owner_password(
- this->m->user_password, this->m->provided_password, data))
+ if (this->m->provided_password_is_hex_key)
+ {
+ // ignore passwords in file
+ }
+ else if (check_owner_password(
+ this->m->user_password, this->m->provided_password, data))
{
// password supplied was owner password; user_password has
// been initialized for V < 5
@@ -1023,7 +1027,11 @@ QPDF::initializeEncryption()
"", 0, "invalid password");
}
- if (V < 5)
+ if (this->m->provided_password_is_hex_key)
+ {
+ this->m->encryption_key = QUtil::hex_decode(this->m->provided_password);
+ }
+ else if (V < 5)
{
// For V < 5, the user password is encrypted with the owner
// password, and the user password is always used for