summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlbert Astals Cid <aacid@kde.org>2021-05-30 00:14:52 +0200
committerAlbert Astals Cid <aacid@kde.org>2021-05-30 00:14:52 +0200
commitb4146c1bb021b48dba20ee343d8c3058ba4d756c (patch)
tree2917daedbde82f0a03dcdbda9259f9b8c24897d1
parentdc587846bff99b07dc351d2d21e5b6908c99afdb (diff)
Move the ownerKey/userKey padding to the correct place
-rw-r--r--poppler/SecurityHandler.cc22
1 files changed, 11 insertions, 11 deletions
diff --git a/poppler/SecurityHandler.cc b/poppler/SecurityHandler.cc
index a746f5a4..91cf72c8 100644
--- a/poppler/SecurityHandler.cc
+++ b/poppler/SecurityHandler.cc
@@ -242,6 +242,17 @@ StandardSecurityHandler::StandardSecurityHandler(PDFDoc *docA, Object *encryptDi
} else if (!(encVersion == -1 && encRevision == -1)) {
error(errUnimplemented, -1, "Unsupported version/revision ({0:d}/{1:d}) of Standard security handler", encVersion, encRevision);
}
+
+ if (encRevision <= 4) {
+ // Adobe apparently zero-pads the U value (and maybe the O value?)
+ // if it's short
+ while (ownerKey->getLength() < 32) {
+ ownerKey->append((char)0x00);
+ }
+ while (userKey->getLength() < 32) {
+ userKey->append((char)0x00);
+ }
+ }
} else {
error(errSyntaxError, -1,
"Invalid encryption key length. version: {0:d} - revision: {1:d} - ownerKeyLength: {2:d} - userKeyLength: {3:d} - ownerEncIsString: {4:d} - ownerEncLength: {5:d} - userEncIsString: {6:d} - userEncLength: {7:d}",
@@ -251,17 +262,6 @@ StandardSecurityHandler::StandardSecurityHandler(PDFDoc *docA, Object *encryptDi
} else {
error(errSyntaxError, -1, "Weird encryption info");
}
-
- if (encRevision <= 4) {
- // Adobe apparently zero-pads the U value (and maybe the O value?)
- // if it's short
- while (ownerKey->getLength() < 32) {
- ownerKey->append((char)0x00);
- }
- while (userKey->getLength() < 32) {
- userKey->append((char)0x00);
- }
- }
}
StandardSecurityHandler::~StandardSecurityHandler()