Move the ownerKey/userKey padding to the correct place
diff --git a/poppler/SecurityHandler.cc b/poppler/SecurityHandler.cc
index a746f5a..91cf72c 100644
--- a/poppler/SecurityHandler.cc
+++ b/poppler/SecurityHandler.cc
@@ -242,6 +242,17 @@
} 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 @@
} 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()