mirror of
https://github.com/JakubMelka/PDF4QT.git
synced 2025-01-31 09:35:05 +01:00
Filtr pro adbe.pkcs7.sha1
This commit is contained in:
parent
6fb32613f3
commit
515a8184d4
@ -23,6 +23,7 @@
|
||||
#include "pdfsignaturehandler_impl.h"
|
||||
|
||||
#include <openssl/err.h>
|
||||
#include <openssl/sha.h>
|
||||
|
||||
#include <QMutex>
|
||||
#include <QMutexLocker>
|
||||
@ -149,6 +150,10 @@ PDFSignatureHandler* PDFSignatureHandler::createHandler(const PDFFormFieldSignat
|
||||
{
|
||||
return new PDFSignatureHandler_adbe_pkcs7_detached(signatureField, sourceData, parameters);
|
||||
}
|
||||
else if (subfilter == "adbe.pkcs7.sha1")
|
||||
{
|
||||
return new PDFSignatureHandler_adbe_pkcs7_sha1(signatureField, sourceData, parameters);
|
||||
}
|
||||
|
||||
return nullptr;
|
||||
}
|
||||
@ -670,6 +675,32 @@ PDFSignatureVerificationResult PDFSignatureHandler_adbe_pkcs7_detached::verify()
|
||||
return result;
|
||||
}
|
||||
|
||||
PDFSignatureVerificationResult PDFSignatureHandler_adbe_pkcs7_sha1::verify() const
|
||||
{
|
||||
PDFSignatureVerificationResult result;
|
||||
initializeResult(result);
|
||||
verifyCertificate(result);
|
||||
verifySignature(result);
|
||||
result.validate();
|
||||
return result;
|
||||
}
|
||||
|
||||
BIO* PDFSignatureHandler_adbe_pkcs7_sha1::getSignedDataBuffer(PDFSignatureVerificationResult& result, QByteArray& outputBuffer) const
|
||||
{
|
||||
QByteArray temporaryBuffer;
|
||||
if (BIO* bio = PDFPublicKeySignatureHandler::getSignedDataBuffer(result, temporaryBuffer))
|
||||
{
|
||||
// Calculate SHA1
|
||||
outputBuffer.resize(SHA_DIGEST_LENGTH);
|
||||
SHA1(reinterpret_cast<const unsigned char*>(temporaryBuffer.data()), temporaryBuffer.length(), reinterpret_cast<unsigned char*>(outputBuffer.data()));
|
||||
BIO_free(bio);
|
||||
|
||||
return BIO_new_mem_buf(outputBuffer.data(), outputBuffer.length());
|
||||
}
|
||||
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
PDFCertificateInfo PDFPublicKeySignatureHandler::getCertificateInfo(X509* certificate)
|
||||
{
|
||||
PDFCertificateInfo info;
|
||||
|
@ -44,7 +44,7 @@ protected:
|
||||
void verifySignature(PDFSignatureVerificationResult& result) const;
|
||||
void addTrustedCertificates(X509_STORE* store) const;
|
||||
|
||||
BIO* getSignedDataBuffer(PDFSignatureVerificationResult& result, QByteArray& outputBuffer) const;
|
||||
virtual BIO* getSignedDataBuffer(PDFSignatureVerificationResult& result, QByteArray& outputBuffer) const;
|
||||
|
||||
public:
|
||||
/// Return a list of certificates from PKCS7 object
|
||||
@ -78,6 +78,21 @@ public:
|
||||
virtual PDFSignatureVerificationResult verify() const override;
|
||||
};
|
||||
|
||||
class PDFSignatureHandler_adbe_pkcs7_sha1 : public PDFPublicKeySignatureHandler
|
||||
{
|
||||
public:
|
||||
explicit PDFSignatureHandler_adbe_pkcs7_sha1(const PDFFormFieldSignature* signatureField, const QByteArray& sourceData, const Parameters& parameters) :
|
||||
PDFPublicKeySignatureHandler(signatureField, sourceData, parameters)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
virtual PDFSignatureVerificationResult verify() const override;
|
||||
|
||||
protected:
|
||||
virtual BIO* getSignedDataBuffer(PDFSignatureVerificationResult& result, QByteArray& outputBuffer) const override;
|
||||
};
|
||||
|
||||
} // namespace pdf
|
||||
|
||||
#endif // PDFSIGNATUREHANDLER_IMPL_H
|
||||
|
Loading…
x
Reference in New Issue
Block a user