[poppler] poppler/Form.cc poppler/Form.h qt5/src

GitLab Mirror gitlab-mirror at kemper.freedesktop.org
Tue Jun 23 22:00:32 UTC 2020


 poppler/Form.cc         |   17 +++++++++--------
 poppler/Form.h          |    3 ++-
 qt5/src/poppler-form.cc |    3 +++
 qt5/src/poppler-form.h  |    3 ++-
 4 files changed, 16 insertions(+), 10 deletions(-)

New commits:
commit 513ed0761fa11e0c4b0d668c92f19ec0eb85cf46
Author: Albert Astals Cid <aacid at kde.org>
Date:   Tue Jun 23 00:34:51 2020 +0200

    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

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
 	};
 
 	/**


More information about the poppler mailing list