diff --git a/Pdf4QtLib/sources/pdfsecurityhandler.cpp b/Pdf4QtLib/sources/pdfsecurityhandler.cpp index 267bba7..ec2abf0 100644 --- a/Pdf4QtLib/sources/pdfsecurityhandler.cpp +++ b/Pdf4QtLib/sources/pdfsecurityhandler.cpp @@ -273,7 +273,7 @@ PDFObject PDFSecurityHandler::encryptObject(const PDFObject& object, PDFObjectRe return visitor.getProcessedObject(); } -void PDFSecurityHandler::parseCryptFilters(const PDFDictionary* dictionary, PDFSecurityHandler& handler, int Length) +void PDFSecurityHandler::parseCryptFilters(const PDFDictionary* dictionary, PDFSecurityHandler& handler, int Length, bool publicKey) { const PDFObject& cryptFilterObjects = dictionary->get("CF"); if (cryptFilterObjects.isDictionary()) @@ -281,7 +281,7 @@ void PDFSecurityHandler::parseCryptFilters(const PDFDictionary* dictionary, PDFS const PDFDictionary* cryptFilters = cryptFilterObjects.getDictionary(); for (size_t i = 0, cryptFilterCount = cryptFilters->getCount(); i < cryptFilterCount; ++i) { - handler.m_cryptFilters[cryptFilters->getKey(i).getString()] = parseCryptFilter(Length, cryptFilters->getValue(i)); + handler.m_cryptFilters[cryptFilters->getKey(i).getString()] = parseCryptFilter(Length, cryptFilters->getValue(i), publicKey); } } @@ -435,7 +435,7 @@ PDFSecurityHandlerPointer PDFSecurityHandler::createSecurityHandler(const PDFObj if (V == 4 || V == 5) { - parseCryptFilters(dictionary, *handler, Length); + parseCryptFilters(dictionary, *handler, Length, handler->getMode() == EncryptionMode::PublicKey); } switch (handler->getMode()) @@ -694,7 +694,7 @@ PDFInteger PDFSecurityHandler::parseInt(const PDFDictionary* dictionary, const c return intObject.getInteger(); } -CryptFilter PDFSecurityHandler::parseCryptFilter(PDFInteger length, const PDFObject& object) +CryptFilter PDFSecurityHandler::parseCryptFilter(PDFInteger length, const PDFObject& object, bool publicKey) { if (!object.isDictionary()) { @@ -740,7 +740,7 @@ CryptFilter PDFSecurityHandler::parseCryptFilter(PDFInteger length, const PDFObj throw PDFException(PDFTranslationContext::tr("Unsupported authorization event '%1'.").arg(QString::fromLatin1(authEventName))); } - filter.keyLength = parseInt(cryptFilterDictionary, "Length", false, length / 8); + filter.keyLength = parseInt(cryptFilterDictionary, "Length", false, publicKey ? length : length / 8); // Recipients filter.recipients = parseRecipients(cryptFilterDictionary); diff --git a/Pdf4QtLib/sources/pdfsecurityhandler.h b/Pdf4QtLib/sources/pdfsecurityhandler.h index ea023c4..1c33150 100644 --- a/Pdf4QtLib/sources/pdfsecurityhandler.h +++ b/Pdf4QtLib/sources/pdfsecurityhandler.h @@ -206,11 +206,11 @@ protected: static bool parseBool(const PDFDictionary* dictionary, const char* key, bool required, bool defaultValue = true); static QByteArray parseName(const PDFDictionary* dictionary, const char* key, bool required, const char* defaultValue = nullptr); static PDFInteger parseInt(const PDFDictionary* dictionary, const char* key, bool required, PDFInteger defaultValue = -1); - static CryptFilter parseCryptFilter(PDFInteger length, const PDFObject& object); + static CryptFilter parseCryptFilter(PDFInteger length, const PDFObject& object, bool publicKey); static PDFSecurityHandlerPointer createSecurityHandlerInstance(const PDFDictionary* dictionary); static QByteArrayList parseRecipients(const PDFDictionary* dictionary); - static void parseCryptFilters(const PDFDictionary* dictionary, PDFSecurityHandler& handler, int Length); + static void parseCryptFilters(const PDFDictionary* dictionary, PDFSecurityHandler& handler, int Length, bool publicKey); static void parseDataStandardSecurityHandler(const PDFDictionary* dictionary, const QByteArray& id, int Length, PDFStandardSecurityHandler& handler); /// Fills encryption dictionary with basic data diff --git a/RELEASES.txt b/RELEASES.txt index 9cb5acf..371708a 100644 --- a/RELEASES.txt +++ b/RELEASES.txt @@ -1,6 +1,6 @@ CURRENT: -V: 1.2.0 +V: 1.2.0 5.6.2022 - Issue #10: Performance optimization - Issue #14: Incorrect text drawing for vertical writing systems - Issue #15: .msi installer