CryptoSign: Allow backends to support different signature types
diff --git a/poppler/CryptoSignBackend.cc b/poppler/CryptoSignBackend.cc
index 426ece5..82bf73b 100644
--- a/poppler/CryptoSignBackend.cc
+++ b/poppler/CryptoSignBackend.cc
@@ -17,6 +17,35 @@
namespace CryptoSign {
+SignatureType signatureTypeFromString(std::string_view data)
+{
+ if (data == std::string_view("ETSI.CAdES.detached")) {
+ return CryptoSign::SignatureType::ETSI_CAdES_detached;
+ } else if (data == std::string_view("adbe.pkcs7.detached")) {
+ return CryptoSign::SignatureType::adbe_pkcs7_detached;
+ } else if (data == std::string_view("adbe.pkcs7.sha1")) {
+ return CryptoSign::SignatureType::adbe_pkcs7_sha1;
+ }
+ return CryptoSign::SignatureType::unknown_signature_type;
+}
+
+std::string toStdString(SignatureType type)
+{
+ switch (type) {
+ case CryptoSign::SignatureType::unsigned_signature_field:
+ return "Unsigned";
+ case CryptoSign::SignatureType::unknown_signature_type:
+ return "Unknown";
+ case CryptoSign::SignatureType::ETSI_CAdES_detached:
+ return "ETSI.CAdES.detached";
+ case CryptoSign::SignatureType::adbe_pkcs7_detached:
+ return "adbe.pkcs7.detached";
+ case CryptoSign::SignatureType::adbe_pkcs7_sha1:
+ return "adbe.pkcs7.sha1";
+ }
+ return "Unhandled";
+}
+
void Factory::setPreferredBackend(CryptoSign::Backend::Type backend)
{
preferredBackend = backend;
diff --git a/poppler/CryptoSignBackend.h b/poppler/CryptoSignBackend.h
index 26415c8..aa11de9 100644
--- a/poppler/CryptoSignBackend.h
+++ b/poppler/CryptoSignBackend.h
@@ -24,6 +24,19 @@
namespace CryptoSign {
+enum class SignatureType
+{
+ adbe_pkcs7_sha1,
+ adbe_pkcs7_detached,
+ ETSI_CAdES_detached,
+ unknown_signature_type,
+ unsigned_signature_field
+};
+
+SignatureType signatureTypeFromString(std::string_view data);
+
+std::string toStdString(SignatureType type);
+
// experiments seems to say that this is a bit above
// what we have seen in the wild, and much larger than
// what we have managed to get nss and gpgme to create.
@@ -65,6 +78,7 @@
{
public:
virtual void addData(unsigned char *data_block, int data_len) = 0;
+ virtual SignatureType signatureType() const = 0;
virtual std::unique_ptr<X509CertificateInfo> getCertificateInfo() const = 0;
virtual std::variant<GooString, SigningError> signDetached(const std::string &password) = 0;
virtual ~SigningInterface();
@@ -81,7 +95,7 @@
NSS3,
GPGME
};
- virtual std::unique_ptr<VerificationInterface> createVerificationHandler(std::vector<unsigned char> &&pkcs7) = 0;
+ virtual std::unique_ptr<VerificationInterface> createVerificationHandler(std::vector<unsigned char> &&pkcs7, SignatureType type) = 0;
virtual std::unique_ptr<SigningInterface> createSigningHandler(const std::string &certID, HashAlgorithm digestAlgTag) = 0;
virtual std::vector<std::unique_ptr<X509CertificateInfo>> getAvailableSigningCertificates() = 0;
virtual ~Backend();
diff --git a/poppler/Form.cc b/poppler/Form.cc
index 581053c..8338c0e 100644
--- a/poppler/Form.cc
+++ b/poppler/Form.cc
@@ -649,7 +649,7 @@
Object vObj(new Dict(xref));
Ref vref = xref->addIndirectObject(vObj);
- if (!createSignature(vObj, vref, GooString(signerName), CryptoSign::maxSupportedSignatureSize, reason, location)) {
+ if (!createSignature(vObj, vref, GooString(signerName), CryptoSign::maxSupportedSignatureSize, reason, location, sigHandler->signatureType())) {
return CryptoSign::SigningError::InternalError;
}
@@ -936,11 +936,11 @@
return true;
}
-bool FormWidgetSignature::createSignature(Object &vObj, Ref vRef, const GooString &name, int placeholderLength, const GooString *reason, const GooString *location)
+bool FormWidgetSignature::createSignature(Object &vObj, Ref vRef, const GooString &name, int placeholderLength, const GooString *reason, const GooString *location, CryptoSign::SignatureType signatureType)
{
vObj.dictAdd("Type", Object(objName, "Sig"));
vObj.dictAdd("Filter", Object(objName, "Adobe.PPKLite"));
- vObj.dictAdd("SubFilter", Object(objName, "adbe.pkcs7.detached"));
+ vObj.dictAdd("SubFilter", Object(objName, toStdString(signatureType).c_str()));
vObj.dictAdd("Name", Object(name.copy()));
GooString *date = timeToDateString(nullptr);
vObj.dictAdd("M", Object(date));
@@ -2261,7 +2261,7 @@
// FormFieldSignature
//------------------------------------------------------------------------
FormFieldSignature::FormFieldSignature(PDFDoc *docA, Object &&dict, const Ref refA, FormField *parentA, std::set<int> *usedParents)
- : FormField(docA, std::move(dict), refA, parentA, usedParents, formSignature), signature_type(unsigned_signature_field), signature(nullptr)
+ : FormField(docA, std::move(dict), refA, parentA, usedParents, formSignature), signature_type(CryptoSign::SignatureType::unsigned_signature_field), signature(nullptr)
{
signature_info = new SignatureInfo();
parseInfo();
@@ -2374,17 +2374,18 @@
// check if subfilter is supported for signature validation, only detached signatures work for now
Object subfilterName = sig_dict.dictLookup("SubFilter");
- if (subfilterName.isName("adbe.pkcs7.sha1")) {
- signature_type = adbe_pkcs7_sha1;
- signature_info->setSubFilterSupport(true);
- } else if (subfilterName.isName("adbe.pkcs7.detached")) {
- signature_type = adbe_pkcs7_detached;
- signature_info->setSubFilterSupport(true);
- } else if (subfilterName.isName("ETSI.CAdES.detached")) {
- signature_type = ETSI_CAdES_detached;
- signature_info->setSubFilterSupport(true);
- } else {
- signature_type = unknown_signature_type;
+ if (subfilterName.getType() == objName && subfilterName.getName()) {
+ signature_type = CryptoSign::signatureTypeFromString(subfilterName.getName());
+ switch (signature_type) {
+ case CryptoSign::SignatureType::adbe_pkcs7_sha1:
+ case CryptoSign::SignatureType::adbe_pkcs7_detached:
+ case CryptoSign::SignatureType::ETSI_CAdES_detached:
+ signature_info->setSubFilterSupport(true);
+ break;
+ case CryptoSign::SignatureType::unknown_signature_type:
+ case CryptoSign::SignatureType::unsigned_signature_field:
+ break;
+ }
}
}
@@ -2411,12 +2412,12 @@
}
}
-FormSignatureType FormWidgetSignature::signatureType() const
+CryptoSign::SignatureType FormWidgetSignature::signatureType() const
{
return static_cast<FormFieldSignature *>(field)->getSignatureType();
}
-void FormWidgetSignature::setSignatureType(FormSignatureType fst)
+void FormWidgetSignature::setSignatureType(CryptoSign::SignatureType fst)
{
static_cast<FormFieldSignature *>(field)->setSignatureType(fst);
}
@@ -2466,7 +2467,7 @@
const int signature_len = signature->getLength();
std::vector<unsigned char> signatureData(signature_len);
memcpy(signatureData.data(), signature->c_str(), signature_len);
- signature_handler = backend->createVerificationHandler(std::move(signatureData));
+ signature_handler = backend->createVerificationHandler(std::move(signatureData), signature_type);
Goffset fileLength = doc->getBaseStream()->getLength();
for (int i = 0; i < arrayLen / 2; i++) {
diff --git a/poppler/Form.h b/poppler/Form.h
index ace2a1c..d775161 100644
--- a/poppler/Form.h
+++ b/poppler/Form.h
@@ -40,6 +40,7 @@
#include "CryptoSignBackend.h"
#include "Object.h"
#include "poppler_private_export.h"
+#include "CryptoSignBackend.h"
#include "SignatureInfo.h"
#include <ctime>
@@ -79,15 +80,6 @@
formButtonRadio
};
-enum FormSignatureType
-{
- adbe_pkcs7_sha1,
- adbe_pkcs7_detached,
- ETSI_CAdES_detached,
- unknown_signature_type,
- unsigned_signature_field
-};
-
enum FillValueType
{
fillValue,
@@ -296,8 +288,8 @@
FormWidgetSignature(PDFDoc *docA, Object *dictObj, unsigned num, Ref ref, FormField *p);
void updateWidgetAppearance() override;
- FormSignatureType signatureType() const;
- void setSignatureType(FormSignatureType fst);
+ CryptoSign::SignatureType signatureType() const;
+ void setSignatureType(CryptoSign::SignatureType fst);
// Use -1 for now as validationTime
// ocspRevocation and aiafetch might happen async in the Background
@@ -343,7 +335,7 @@
const GooString *getSignature() const;
private:
- bool createSignature(Object &vObj, Ref vRef, const GooString &name, int placeholderLength, const GooString *reason = nullptr, const GooString *location = nullptr);
+ bool createSignature(Object &vObj, Ref vRef, const GooString &name, int placeholderLength, const GooString *reason, const GooString *location, CryptoSign::SignatureType signatureType);
bool getObjectStartEnd(const GooString &filename, int objNum, Goffset *objStart, Goffset *objEnd, const std::optional<GooString> &ownerPassword, const std::optional<GooString> &userPassword);
bool updateOffsets(FILE *f, Goffset objStart, Goffset objEnd, Goffset *sigStart, Goffset *sigEnd, Goffset *fileSize);
@@ -646,8 +638,8 @@
Object *getByteRange() { return &byte_range; }
const GooString *getSignature() const { return signature; }
void setSignature(const GooString &sig);
- FormSignatureType getSignatureType() const { return signature_type; }
- void setSignatureType(FormSignatureType t) { signature_type = t; }
+ CryptoSign::SignatureType getSignatureType() const { return signature_type; }
+ void setSignatureType(CryptoSign::SignatureType t) { signature_type = t; }
const GooString &getCustomAppearanceContent() const;
void setCustomAppearanceContent(const GooString &s);
@@ -670,7 +662,7 @@
void parseInfo();
void hashSignedDataBlock(CryptoSign::VerificationInterface *handler, Goffset block_len);
- FormSignatureType signature_type;
+ CryptoSign::SignatureType signature_type;
Object byte_range;
GooString *signature;
SignatureInfo *signature_info;
diff --git a/poppler/GPGMECryptoSignBackend.cc b/poppler/GPGMECryptoSignBackend.cc
index ec91e1a..de1d9a2 100644
--- a/poppler/GPGMECryptoSignBackend.cc
+++ b/poppler/GPGMECryptoSignBackend.cc
@@ -191,9 +191,18 @@
return std::make_unique<GpgSignatureCreation>(certID);
}
-std::unique_ptr<CryptoSign::VerificationInterface> GpgSignatureBackend::createVerificationHandler(std::vector<unsigned char> &&pkcs7)
+std::unique_ptr<CryptoSign::VerificationInterface> GpgSignatureBackend::createVerificationHandler(std::vector<unsigned char> &&pkcs7, CryptoSign::SignatureType type)
{
- return std::make_unique<GpgSignatureVerification>(std::move(pkcs7));
+ switch (type) {
+ case CryptoSign::SignatureType::unknown_signature_type:
+ case CryptoSign::SignatureType::unsigned_signature_field:
+ return {};
+ case CryptoSign::SignatureType::ETSI_CAdES_detached:
+ case CryptoSign::SignatureType::adbe_pkcs7_detached:
+ case CryptoSign::SignatureType::adbe_pkcs7_sha1:
+ return std::make_unique<GpgSignatureVerification>(std::move(pkcs7));
+ }
+ return {};
}
std::vector<std::unique_ptr<X509CertificateInfo>> GpgSignatureBackend::getAvailableSigningCertificates()
@@ -252,6 +261,11 @@
return GooString(std::move(signatureString));
}
+CryptoSign::SignatureType GpgSignatureCreation::signatureType() const
+{
+ return CryptoSign::SignatureType::adbe_pkcs7_detached;
+}
+
std::unique_ptr<X509CertificateInfo> GpgSignatureCreation::getCertificateInfo() const
{
if (!key) {
diff --git a/poppler/GPGMECryptoSignBackend.h b/poppler/GPGMECryptoSignBackend.h
index fc5d262..43ed7f3 100644
--- a/poppler/GPGMECryptoSignBackend.h
+++ b/poppler/GPGMECryptoSignBackend.h
@@ -20,7 +20,7 @@
{
public:
GpgSignatureBackend();
- std::unique_ptr<CryptoSign::VerificationInterface> createVerificationHandler(std::vector<unsigned char> &&pkcs7) final;
+ std::unique_ptr<CryptoSign::VerificationInterface> createVerificationHandler(std::vector<unsigned char> &&pkcs7, CryptoSign::SignatureType type) final;
std::unique_ptr<CryptoSign::SigningInterface> createSigningHandler(const std::string &certID, HashAlgorithm digestAlgTag) final;
std::vector<std::unique_ptr<X509CertificateInfo>> getAvailableSigningCertificates() final;
static bool hasSufficientVersion();
@@ -33,6 +33,7 @@
void addData(unsigned char *dataBlock, int dataLen) final;
std::unique_ptr<X509CertificateInfo> getCertificateInfo() const final;
std::variant<GooString, CryptoSign::SigningError> signDetached(const std::string &password) final;
+ CryptoSign::SignatureType signatureType() const final;
private:
std::unique_ptr<GpgME::Context> gpgContext;
diff --git a/poppler/NSSCryptoSignBackend.cc b/poppler/NSSCryptoSignBackend.cc
index 56ab001..f7a210f 100644
--- a/poppler/NSSCryptoSignBackend.cc
+++ b/poppler/NSSCryptoSignBackend.cc
@@ -1223,9 +1223,18 @@
return nullptr;
}
-std::unique_ptr<CryptoSign::VerificationInterface> NSSCryptoSignBackend::createVerificationHandler(std::vector<unsigned char> &&pkcs7)
+std::unique_ptr<CryptoSign::VerificationInterface> NSSCryptoSignBackend::createVerificationHandler(std::vector<unsigned char> &&pkcs7, CryptoSign::SignatureType type)
{
- return std::make_unique<NSSSignatureVerification>(std::move(pkcs7));
+ switch (type) {
+ case CryptoSign::SignatureType::unknown_signature_type:
+ case CryptoSign::SignatureType::unsigned_signature_field:
+ return {};
+ case CryptoSign::SignatureType::ETSI_CAdES_detached:
+ case CryptoSign::SignatureType::adbe_pkcs7_detached:
+ case CryptoSign::SignatureType::adbe_pkcs7_sha1:
+ return std::make_unique<NSSSignatureVerification>(std::move(pkcs7));
+ }
+ return {};
}
std::unique_ptr<CryptoSign::SigningInterface> NSSCryptoSignBackend::createSigningHandler(const std::string &certID, HashAlgorithm digestAlgTag)
diff --git a/poppler/NSSCryptoSignBackend.h b/poppler/NSSCryptoSignBackend.h
index 1d90f63..12369ae 100644
--- a/poppler/NSSCryptoSignBackend.h
+++ b/poppler/NSSCryptoSignBackend.h
@@ -108,6 +108,7 @@
std::unique_ptr<X509CertificateInfo> getCertificateInfo() const final;
void addData(unsigned char *data_block, int data_len) final;
std::variant<GooString, CryptoSign::SigningError> signDetached(const std::string &password) final;
+ CryptoSign::SignatureType signatureType() const final { return CryptoSign::SignatureType::adbe_pkcs7_detached; }
NSSSignatureCreation(const NSSSignatureCreation &) = delete;
NSSSignatureCreation &operator=(const NSSSignatureCreation &) = delete;
@@ -140,7 +141,7 @@
class NSSCryptoSignBackend final : public CryptoSign::Backend
{
public:
- std::unique_ptr<CryptoSign::VerificationInterface> createVerificationHandler(std::vector<unsigned char> &&pkcs7) final;
+ std::unique_ptr<CryptoSign::VerificationInterface> createVerificationHandler(std::vector<unsigned char> &&pkcs7, CryptoSign::SignatureType) final;
std::unique_ptr<CryptoSign::SigningInterface> createSigningHandler(const std::string &certID, HashAlgorithm digestAlgTag) final;
std::vector<std::unique_ptr<X509CertificateInfo>> getAvailableSigningCertificates() final;
~NSSCryptoSignBackend() final;
diff --git a/qt5/src/poppler-form.cc b/qt5/src/poppler-form.cc
index 7f12942..e0dcce4 100644
--- a/qt5/src/poppler-form.cc
+++ b/qt5/src/poppler-form.cc
@@ -963,19 +963,19 @@
SignatureType sigType = AdbePkcs7detached;
FormWidgetSignature *fws = static_cast<FormWidgetSignature *>(m_formData->fm);
switch (fws->signatureType()) {
- case adbe_pkcs7_sha1:
+ case CryptoSign::SignatureType::adbe_pkcs7_sha1:
sigType = AdbePkcs7sha1;
break;
- case adbe_pkcs7_detached:
+ case CryptoSign::SignatureType::adbe_pkcs7_detached:
sigType = AdbePkcs7detached;
break;
- case ETSI_CAdES_detached:
+ case CryptoSign::SignatureType::ETSI_CAdES_detached:
sigType = EtsiCAdESdetached;
break;
- case unknown_signature_type:
+ case CryptoSign::SignatureType::unknown_signature_type:
sigType = UnknownSignatureType;
break;
- case unsigned_signature_field:
+ case CryptoSign::SignatureType::unsigned_signature_field:
sigType = UnsignedSignature;
break;
}
@@ -1169,7 +1169,7 @@
FormFieldSignature::SigningResult FormFieldSignature::sign(const QString &outputFileName, const PDFConverter::NewSignatureData &data) const
{
FormWidgetSignature *fws = static_cast<FormWidgetSignature *>(m_formData->fm);
- if (fws->signatureType() != unsigned_signature_field) {
+ if (fws->signatureType() != CryptoSign::SignatureType::unsigned_signature_field) {
return FieldAlreadySigned;
}
diff --git a/qt5/tests/check_signature_basics.cpp b/qt5/tests/check_signature_basics.cpp
index 2612c0b..44a6c7d 100644
--- a/qt5/tests/check_signature_basics.cpp
+++ b/qt5/tests/check_signature_basics.cpp
@@ -111,7 +111,7 @@
{
auto signatureFields = doc->getSignatureFields();
QCOMPARE(signatureFields[0]->getCreateWidget()->getField()->getFullyQualifiedName()->toStr(), std::string { "P2.AnA_Signature0_B_" });
- QCOMPARE(signatureFields[0]->getSignatureType(), ETSI_CAdES_detached);
+ QCOMPARE(signatureFields[0]->getSignatureType(), CryptoSign::SignatureType::ETSI_CAdES_detached);
auto siginfo0 = signatureFields[0]->validateSignatureAsync(false, false, -1 /* now */, false, false, {});
signatureFields[0]->validateSignatureResult();
#ifdef ENABLE_SIGNATURES
@@ -125,7 +125,7 @@
QCOMPARE(siginfo0->getSigningTime(), time_t(1677570911));
QCOMPARE(signatureFields[1]->getCreateWidget()->getField()->getFullyQualifiedName()->toStr(), std::string { "P2.AnA_Signature1_B_" });
- QCOMPARE(signatureFields[1]->getSignatureType(), ETSI_CAdES_detached);
+ QCOMPARE(signatureFields[1]->getSignatureType(), CryptoSign::SignatureType::ETSI_CAdES_detached);
auto siginfo1 = signatureFields[1]->validateSignatureAsync(false, false, -1 /* now */, false, false, {});
signatureFields[1]->validateSignatureResult();
#ifdef ENABLE_SIGNATURES
@@ -145,9 +145,9 @@
QCOMPARE(siginfo1->getSigningTime(), time_t(1677840601));
QCOMPARE(signatureFields[2]->getCreateWidget()->getField()->getFullyQualifiedName()->toStr(), std::string { "P2.AnA_Signature2_B_" });
- QCOMPARE(signatureFields[2]->getSignatureType(), unsigned_signature_field);
+ QCOMPARE(signatureFields[2]->getSignatureType(), CryptoSign::SignatureType::unsigned_signature_field);
QCOMPARE(signatureFields[3]->getCreateWidget()->getField()->getFullyQualifiedName()->toStr(), std::string { "P2.AnA_Signature3_B_" });
- QCOMPARE(signatureFields[3]->getSignatureType(), unsigned_signature_field);
+ QCOMPARE(signatureFields[3]->getSignatureType(), CryptoSign::SignatureType::unsigned_signature_field);
}
void TestSignatureBasics::testSignedRanges()
diff --git a/qt6/src/poppler-form.cc b/qt6/src/poppler-form.cc
index 01a14bb..18a26cc 100644
--- a/qt6/src/poppler-form.cc
+++ b/qt6/src/poppler-form.cc
@@ -963,19 +963,19 @@
SignatureType sigType = AdbePkcs7detached;
FormWidgetSignature *fws = static_cast<FormWidgetSignature *>(m_formData->fm);
switch (fws->signatureType()) {
- case adbe_pkcs7_sha1:
+ case CryptoSign::SignatureType::adbe_pkcs7_sha1:
sigType = AdbePkcs7sha1;
break;
- case adbe_pkcs7_detached:
+ case CryptoSign::SignatureType::adbe_pkcs7_detached:
sigType = AdbePkcs7detached;
break;
- case ETSI_CAdES_detached:
+ case CryptoSign::SignatureType::ETSI_CAdES_detached:
sigType = EtsiCAdESdetached;
break;
- case unknown_signature_type:
+ case CryptoSign::SignatureType::unknown_signature_type:
sigType = UnknownSignatureType;
break;
- case unsigned_signature_field:
+ case CryptoSign::SignatureType::unsigned_signature_field:
sigType = UnsignedSignature;
break;
}
@@ -1169,7 +1169,7 @@
FormFieldSignature::SigningResult FormFieldSignature::sign(const QString &outputFileName, const PDFConverter::NewSignatureData &data) const
{
FormWidgetSignature *fws = static_cast<FormWidgetSignature *>(m_formData->fm);
- if (fws->signatureType() != unsigned_signature_field) {
+ if (fws->signatureType() != CryptoSign::SignatureType::unsigned_signature_field) {
return FieldAlreadySigned;
}
diff --git a/qt6/tests/check_signature_basics.cpp b/qt6/tests/check_signature_basics.cpp
index 9135908..8a64069 100644
--- a/qt6/tests/check_signature_basics.cpp
+++ b/qt6/tests/check_signature_basics.cpp
@@ -109,7 +109,7 @@
{
auto signatureFields = doc->getSignatureFields();
QCOMPARE(signatureFields[0]->getCreateWidget()->getField()->getFullyQualifiedName()->toStr(), std::string { "P2.AnA_Signature0_B_" });
- QCOMPARE(signatureFields[0]->getSignatureType(), ETSI_CAdES_detached);
+ QCOMPARE(signatureFields[0]->getSignatureType(), CryptoSign::SignatureType::ETSI_CAdES_detached);
auto siginfo0 = signatureFields[0]->validateSignatureAsync(false, false, -1 /* now */, false, false, {});
signatureFields[0]->validateSignatureResult();
#ifdef ENABLE_SIGNATURES
@@ -123,7 +123,7 @@
QCOMPARE(siginfo0->getSigningTime(), time_t(1677570911));
QCOMPARE(signatureFields[1]->getCreateWidget()->getField()->getFullyQualifiedName()->toStr(), std::string { "P2.AnA_Signature1_B_" });
- QCOMPARE(signatureFields[1]->getSignatureType(), ETSI_CAdES_detached);
+ QCOMPARE(signatureFields[1]->getSignatureType(), CryptoSign::SignatureType::ETSI_CAdES_detached);
auto siginfo1 = signatureFields[1]->validateSignatureAsync(false, false, -1 /* now */, false, false, {});
signatureFields[1]->validateSignatureResult();
#ifdef ENABLE_SIGNATURES
@@ -143,9 +143,9 @@
QCOMPARE(siginfo1->getSigningTime(), time_t(1677840601));
QCOMPARE(signatureFields[2]->getCreateWidget()->getField()->getFullyQualifiedName()->toStr(), std::string { "P2.AnA_Signature2_B_" });
- QCOMPARE(signatureFields[2]->getSignatureType(), unsigned_signature_field);
+ QCOMPARE(signatureFields[2]->getSignatureType(), CryptoSign::SignatureType::unsigned_signature_field);
QCOMPARE(signatureFields[3]->getCreateWidget()->getField()->getFullyQualifiedName()->toStr(), std::string { "P2.AnA_Signature3_B_" });
- QCOMPARE(signatureFields[3]->getSignatureType(), unsigned_signature_field);
+ QCOMPARE(signatureFields[3]->getSignatureType(), CryptoSign::SignatureType::unsigned_signature_field);
}
void TestSignatureBasics::testSignedRanges()
diff --git a/utils/pdfsig.cc b/utils/pdfsig.cc
index e7d6441..233e99f 100644
--- a/utils/pdfsig.cc
+++ b/utils/pdfsig.cc
@@ -516,7 +516,7 @@
return 2;
}
if (etsiCAdESdetached) {
- ffs->setSignatureType(ETSI_CAdES_detached);
+ ffs->setSignatureType(CryptoSign::SignatureType::ETSI_CAdES_detached);
}
const auto rs = std::unique_ptr<GooString>(reason.toStr().empty() ? nullptr : std::make_unique<GooString>(utf8ToUtf16WithBom(reason.toStr())));
if (ffs->getNumWidgets() != 1) {
@@ -579,7 +579,7 @@
// Let's start the signature check first for signatures.
// we can always wait for completion later
FormFieldSignature *ffs = signatures.at(i);
- if (ffs->getSignatureType() == unsigned_signature_field) {
+ if (ffs->getSignatureType() == CryptoSign::SignatureType::unsigned_signature_field) {
continue;
}
signatureInfos[i] = ffs->validateSignatureAsync(!dontVerifyCert, false, -1 /* now */, !noOCSPRevocationCheck, useAIACertFetch, {});
@@ -594,7 +594,7 @@
printf(" - Signature Field Name: %s\n", name.c_str());
}
- if (ffs->getSignatureType() == unsigned_signature_field) {
+ if (ffs->getSignatureType() == CryptoSign::SignatureType::unsigned_signature_field) {
printf(" The signature form field is not signed.\n");
continue;
}
@@ -632,16 +632,17 @@
}
printf(" - Signature Type: ");
switch (ffs->getSignatureType()) {
- case adbe_pkcs7_sha1:
+ case CryptoSign::SignatureType::adbe_pkcs7_sha1:
printf("adbe.pkcs7.sha1\n");
break;
- case adbe_pkcs7_detached:
+ case CryptoSign::SignatureType::adbe_pkcs7_detached:
printf("adbe.pkcs7.detached\n");
break;
- case ETSI_CAdES_detached:
+ case CryptoSign::SignatureType::ETSI_CAdES_detached:
printf("ETSI.CAdES.detached\n");
break;
- default:
+ case CryptoSign::SignatureType::unknown_signature_type:
+ case CryptoSign::SignatureType::unsigned_signature_field: /*shouldn't happen*/
printf("unknown\n");
}
const std::vector<Goffset> ranges = ffs->getSignedRangeBounds();