mirror of
https://github.com/JakubMelka/PDF4QT.git
synced 2025-02-15 11:10:40 +01:00
Public key handler: Finish of PDF public key security handler
This commit is contained in:
parent
3456977f22
commit
704d06e0c3
@ -273,7 +273,7 @@ PDFObject PDFSecurityHandler::encryptObject(const PDFObject& object, PDFObjectRe
|
|||||||
return visitor.getProcessedObject();
|
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");
|
const PDFObject& cryptFilterObjects = dictionary->get("CF");
|
||||||
if (cryptFilterObjects.isDictionary())
|
if (cryptFilterObjects.isDictionary())
|
||||||
@ -281,7 +281,7 @@ void PDFSecurityHandler::parseCryptFilters(const PDFDictionary* dictionary, PDFS
|
|||||||
const PDFDictionary* cryptFilters = cryptFilterObjects.getDictionary();
|
const PDFDictionary* cryptFilters = cryptFilterObjects.getDictionary();
|
||||||
for (size_t i = 0, cryptFilterCount = cryptFilters->getCount(); i < cryptFilterCount; ++i)
|
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)
|
if (V == 4 || V == 5)
|
||||||
{
|
{
|
||||||
parseCryptFilters(dictionary, *handler, Length);
|
parseCryptFilters(dictionary, *handler, Length, handler->getMode() == EncryptionMode::PublicKey);
|
||||||
}
|
}
|
||||||
|
|
||||||
switch (handler->getMode())
|
switch (handler->getMode())
|
||||||
@ -694,7 +694,7 @@ PDFInteger PDFSecurityHandler::parseInt(const PDFDictionary* dictionary, const c
|
|||||||
return intObject.getInteger();
|
return intObject.getInteger();
|
||||||
}
|
}
|
||||||
|
|
||||||
CryptFilter PDFSecurityHandler::parseCryptFilter(PDFInteger length, const PDFObject& object)
|
CryptFilter PDFSecurityHandler::parseCryptFilter(PDFInteger length, const PDFObject& object, bool publicKey)
|
||||||
{
|
{
|
||||||
if (!object.isDictionary())
|
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)));
|
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
|
// Recipients
|
||||||
filter.recipients = parseRecipients(cryptFilterDictionary);
|
filter.recipients = parseRecipients(cryptFilterDictionary);
|
||||||
|
@ -206,11 +206,11 @@ protected:
|
|||||||
static bool parseBool(const PDFDictionary* dictionary, const char* key, bool required, bool defaultValue = true);
|
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 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 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 PDFSecurityHandlerPointer createSecurityHandlerInstance(const PDFDictionary* dictionary);
|
||||||
static QByteArrayList parseRecipients(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);
|
static void parseDataStandardSecurityHandler(const PDFDictionary* dictionary, const QByteArray& id, int Length, PDFStandardSecurityHandler& handler);
|
||||||
|
|
||||||
/// Fills encryption dictionary with basic data
|
/// Fills encryption dictionary with basic data
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
CURRENT:
|
CURRENT:
|
||||||
|
|
||||||
V: 1.2.0
|
V: 1.2.0 5.6.2022
|
||||||
- Issue #10: Performance optimization
|
- Issue #10: Performance optimization
|
||||||
- Issue #14: Incorrect text drawing for vertical writing systems
|
- Issue #14: Incorrect text drawing for vertical writing systems
|
||||||
- Issue #15: .msi installer
|
- Issue #15: .msi installer
|
||||||
|
Loading…
x
Reference in New Issue
Block a user