Public key handler: Finish of PDF public key security handler

This commit is contained in:
Jakub Melka 2022-06-29 17:40:59 +02:00
parent 3456977f22
commit 704d06e0c3
3 changed files with 8 additions and 8 deletions

View File

@ -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);

View File

@ -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

View File

@ -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