summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlbert Astals Cid <aacid@kde.org>2020-06-23 00:34:51 +0200
committerAlbert Astals Cid <aacid@kde.org>2020-06-23 23:55:44 +0200
commit513ed0761fa11e0c4b0d668c92f19ec0eb85cf46 (patch)
treecda7c00ec63269adcb39ede9aa7a5c79e4595ad5
parente5001ae78d82624e4a1f07b1053c9db5e4643d48 (diff)
Small signature improvements
Add unknown signature type, and default to that one instead of adbe_pkcs7_detached Move the check for "can we validate" a bit to the bottom, this way on some files like the one from #929 we can extract propertly some more signature details
-rw-r--r--poppler/Form.cc17
-rw-r--r--poppler/Form.h3
-rw-r--r--qt5/src/poppler-form.cc3
-rw-r--r--qt5/src/poppler-form.h3
4 files changed, 16 insertions, 10 deletions
diff --git a/poppler/Form.cc b/poppler/Form.cc
index 9fb9276a..e8af54ac 100644
--- a/poppler/Form.cc
+++ b/poppler/Form.cc
@@ -1667,7 +1667,7 @@ void FormFieldChoice::reset(const std::vector<std::string>& excludedFields)
//------------------------------------------------------------------------
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(adbe_pkcs7_detached),
+ signature_type(unknown_signature_type),
signature(nullptr), signature_info(nullptr)
{
signature = nullptr;
@@ -1767,11 +1767,6 @@ FormSignatureType FormWidgetSignature::signatureType() const
SignatureInfo *FormFieldSignature::validateSignature(bool doVerifyCert, bool forceRevalidation, time_t validationTime)
{
#ifdef ENABLE_NSS3
- if (!signature_info->isSubfilterSupported()) {
- error(errUnimplemented, 0, "Unable to validate this type of signature");
- return signature_info;
- }
-
if (signature_info->getSignatureValStatus() != SIGNATURE_NOT_VERIFIED && !forceRevalidation) {
return signature_info;
}
@@ -1819,12 +1814,18 @@ SignatureInfo *FormFieldSignature::validateSignature(bool doVerifyCert, bool for
hashSignedDataBlock(&signature_handler, len);
}
- const SignatureValidationStatus sig_val_state = signature_handler.validateSignature();
- signature_info->setSignatureValStatus(sig_val_state);
signature_info->setSignerName(signature_handler.getSignerName());
signature_info->setSubjectDN(signature_handler.getSignerSubjectDN());
signature_info->setHashAlgorithm(signature_handler.getHashAlgorithm());
+ if (!signature_info->isSubfilterSupported()) {
+ error(errUnimplemented, 0, "Unable to validate this type of signature");
+ return signature_info;
+ }
+
+ const SignatureValidationStatus sig_val_state = signature_handler.validateSignature();
+ signature_info->setSignatureValStatus(sig_val_state);
+
// verify if signature contains a 'signing time' attribute
if (signature_handler.getSigningTime() != 0) {
signature_info->setSigningTime(signature_handler.getSigningTime());
diff --git a/poppler/Form.h b/poppler/Form.h
index ad85cd18..43fa14ee 100644
--- a/poppler/Form.h
+++ b/poppler/Form.h
@@ -71,7 +71,8 @@ enum VariableTextQuadding {
enum FormSignatureType {
adbe_pkcs7_sha1,
adbe_pkcs7_detached,
- ETSI_CAdES_detached
+ ETSI_CAdES_detached,
+ unknown_signature_type
};
enum FillValueType {
diff --git a/qt5/src/poppler-form.cc b/qt5/src/poppler-form.cc
index 19adbd7b..643f221a 100644
--- a/qt5/src/poppler-form.cc
+++ b/qt5/src/poppler-form.cc
@@ -953,6 +953,9 @@ FormFieldSignature::SignatureType FormFieldSignature::signatureType() const
case ETSI_CAdES_detached:
sigType = EtsiCAdESdetached;
break;
+ case unknown_signature_type:
+ sigType = UnknownSignatureType;
+ break;
}
return sigType;
}
diff --git a/qt5/src/poppler-form.h b/qt5/src/poppler-form.h
index 44322287..d84b6595 100644
--- a/qt5/src/poppler-form.h
+++ b/qt5/src/poppler-form.h
@@ -750,7 +750,8 @@ namespace Poppler {
enum SignatureType {
AdbePkcs7sha1,
AdbePkcs7detached,
- EtsiCAdESdetached
+ EtsiCAdESdetached,
+ UnknownSignatureType ///< \since 0.90
};
/**