summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--poppler/Form.cc10
-rw-r--r--poppler/Form.h8
-rw-r--r--poppler/PDFDoc.cc2
-rw-r--r--qt5/src/poppler-form.cc2
-rw-r--r--qt6/src/poppler-form.cc2
-rw-r--r--utils/pdfsig.cc8
6 files changed, 19 insertions, 13 deletions
diff --git a/poppler/Form.cc b/poppler/Form.cc
index 738bfe30..08b2c1a3 100644
--- a/poppler/Form.cc
+++ b/poppler/Form.cc
@@ -601,7 +601,7 @@ static bool hashFileRange(FILE *f, SignatureHandler *handler, Goffset start, Gof
}
#endif
-bool FormWidgetSignature::signDocument(const char *saveFilename, const char *certNickname, const char *digestName, const char *password, const GooString *reason, const GooString *location, const std::optional<GooString> &ownerPassword,
+bool FormWidgetSignature::signDocument(const char *saveFilename, const char *certNickname, const char *password, const GooString *reason, const GooString *location, const std::optional<GooString> &ownerPassword,
const std::optional<GooString> &userPassword)
{
#ifdef ENABLE_NSS3
@@ -688,9 +688,9 @@ bool FormWidgetSignature::signDocument(const char *saveFilename, const char *cer
#endif
}
-bool FormWidgetSignature::signDocumentWithAppearance(const char *saveFilename, const char *certNickname, const char *digestName, const char *password, const GooString *reason, const GooString *location,
- const std::optional<GooString> &ownerPassword, const std::optional<GooString> &userPassword, const GooString &signatureText, const GooString &signatureTextLeft, double fontSize,
- double leftFontSize, std::unique_ptr<AnnotColor> &&fontColor, double borderWidth, std::unique_ptr<AnnotColor> &&borderColor, std::unique_ptr<AnnotColor> &&backgroundColor)
+bool FormWidgetSignature::signDocumentWithAppearance(const char *saveFilename, const char *certNickname, const char *password, const GooString *reason, const GooString *location, const std::optional<GooString> &ownerPassword,
+ const std::optional<GooString> &userPassword, const GooString &signatureText, const GooString &signatureTextLeft, double fontSize, double leftFontSize,
+ std::unique_ptr<AnnotColor> &&fontColor, double borderWidth, std::unique_ptr<AnnotColor> &&borderColor, std::unique_ptr<AnnotColor> &&backgroundColor)
{
// Set the appearance
GooString *aux = getField()->getDefaultAppearance();
@@ -727,7 +727,7 @@ bool FormWidgetSignature::signDocumentWithAppearance(const char *saveFilename, c
ffs->setCustomAppearanceLeftContent(signatureTextLeft);
ffs->setCustomAppearanceLeftFontSize(leftFontSize);
- const bool success = signDocument(saveFilename, certNickname, digestName, password, reason, location, ownerPassword, userPassword);
+ const bool success = signDocument(saveFilename, certNickname, password, reason, location, ownerPassword, userPassword);
// Now bring back the annotation appearance back to what it was
ffs->setDefaultAppearance(originalDefaultAppearance);
diff --git a/poppler/Form.h b/poppler/Form.h
index 248dcb2e..1ba8f3ad 100644
--- a/poppler/Form.h
+++ b/poppler/Form.h
@@ -307,13 +307,13 @@ public:
// field "ByteRange" in the dictionary "V".
// Arguments reason and location are UTF-16 big endian strings with BOM. An empty string and nullptr are acceptable too.
// Returns success.
- bool signDocument(const char *filename, const char *certNickname, const char *digestName, const char *password, const GooString *reason = nullptr, const GooString *location = nullptr, const std::optional<GooString> &ownerPassword = {},
+ bool signDocument(const char *filename, const char *certNickname, const char *password, const GooString *reason = nullptr, const GooString *location = nullptr, const std::optional<GooString> &ownerPassword = {},
const std::optional<GooString> &userPassword = {});
// Same as above but adds text, font color, etc.
- bool signDocumentWithAppearance(const char *filename, const char *certNickname, const char *digestName, const char *password, const GooString *reason = nullptr, const GooString *location = nullptr,
- const std::optional<GooString> &ownerPassword = {}, const std::optional<GooString> &userPassword = {}, const GooString &signatureText = {}, const GooString &signatureTextLeft = {}, double fontSize = {},
- double leftFontSize = {}, std::unique_ptr<AnnotColor> &&fontColor = {}, double borderWidth = {}, std::unique_ptr<AnnotColor> &&borderColor = {}, std::unique_ptr<AnnotColor> &&backgroundColor = {});
+ bool signDocumentWithAppearance(const char *filename, const char *certNickname, const char *password, const GooString *reason = nullptr, const GooString *location = nullptr, const std::optional<GooString> &ownerPassword = {},
+ const std::optional<GooString> &userPassword = {}, const GooString &signatureText = {}, const GooString &signatureTextLeft = {}, double fontSize = {}, double leftFontSize = {},
+ std::unique_ptr<AnnotColor> &&fontColor = {}, double borderWidth = {}, std::unique_ptr<AnnotColor> &&borderColor = {}, std::unique_ptr<AnnotColor> &&backgroundColor = {});
// checks the length encoding of the signature and returns the hex encoded signature
// if the check passed (and the checked file size as output parameter in checkedFileSize)
diff --git a/poppler/PDFDoc.cc b/poppler/PDFDoc.cc
index e5b6ed55..a67f359d 100644
--- a/poppler/PDFDoc.cc
+++ b/poppler/PDFDoc.cc
@@ -2246,7 +2246,7 @@ bool PDFDoc::sign(const char *saveFilename, const char *certNickname, const char
FormWidgetSignature *fws = dynamic_cast<FormWidgetSignature *>(formWidget);
if (fws) {
- const bool res = fws->signDocument(saveFilename, certNickname, "SHA256", password, reason, location, ownerPassword, userPassword);
+ const bool res = fws->signDocument(saveFilename, certNickname, password, reason, location, ownerPassword, userPassword);
// Now remove the signature stuff in case the user wants to continue editing stuff
// So the document object is clean
diff --git a/qt5/src/poppler-form.cc b/qt5/src/poppler-form.cc
index 9e17bee3..2de1d6e0 100644
--- a/qt5/src/poppler-form.cc
+++ b/qt5/src/poppler-form.cc
@@ -1114,7 +1114,7 @@ FormFieldSignature::SigningResult FormFieldSignature::sign(const QString &output
const auto gSignatureLeftText = std::unique_ptr<GooString>(QStringToUnicodeGooString(data.signatureLeftText()));
const bool success =
- fws->signDocumentWithAppearance(outputFileName.toUtf8().constData(), data.certNickname().toUtf8().constData(), "SHA256", data.password().toUtf8().constData(), reason.get(), location.get(), ownerPwd, userPwd, *gSignatureText,
+ fws->signDocumentWithAppearance(outputFileName.toUtf8().constData(), data.certNickname().toUtf8().constData(), data.password().toUtf8().constData(), reason.get(), location.get(), ownerPwd, userPwd, *gSignatureText,
*gSignatureLeftText, data.fontSize(), data.leftFontSize(), convertQColor(data.fontColor()), data.borderWidth(), convertQColor(data.borderColor()), convertQColor(data.backgroundColor()));
return success ? SigningSuccess : GenericSigningError;
diff --git a/qt6/src/poppler-form.cc b/qt6/src/poppler-form.cc
index a3762cc4..8ae6e6fb 100644
--- a/qt6/src/poppler-form.cc
+++ b/qt6/src/poppler-form.cc
@@ -1114,7 +1114,7 @@ FormFieldSignature::SigningResult FormFieldSignature::sign(const QString &output
const auto gSignatureLeftText = std::unique_ptr<GooString>(QStringToUnicodeGooString(data.signatureLeftText()));
const bool success =
- fws->signDocumentWithAppearance(outputFileName.toUtf8().constData(), data.certNickname().toUtf8().constData(), "SHA256", data.password().toUtf8().constData(), reason.get(), location.get(), ownerPwd, userPwd, *gSignatureText,
+ fws->signDocumentWithAppearance(outputFileName.toUtf8().constData(), data.certNickname().toUtf8().constData(), data.password().toUtf8().constData(), reason.get(), location.get(), ownerPwd, userPwd, *gSignatureText,
*gSignatureLeftText, data.fontSize(), data.leftFontSize(), convertQColor(data.fontColor()), data.borderWidth(), convertQColor(data.borderColor()), convertQColor(data.backgroundColor()));
return success ? SigningSuccess : GenericSigningError;
diff --git a/utils/pdfsig.cc b/utils/pdfsig.cc
index 9326b74f..efca6bbc 100644
--- a/utils/pdfsig.cc
+++ b/utils/pdfsig.cc
@@ -416,6 +416,12 @@ int main(int argc, char *argv[])
return 2;
}
+ if (digestName != std::string("SHA256")) {
+ printf("Only digest SHA256 is supported at the moment\n");
+ printf("Please file a bug report if this is important for you\n");
+ return 2;
+ }
+
bool getCertsError;
// We need to call this otherwise NSS spins forever
getAvailableSigningCertificates(&getCertsError);
@@ -440,7 +446,7 @@ int main(int argc, char *argv[])
return 2;
}
FormWidgetSignature *fws = static_cast<FormWidgetSignature *>(ffs->getWidget(0));
- const bool success = fws->signDocument(argv[2], certNickname, digestName, pw, rs.get());
+ const bool success = fws->signDocument(argv[2], certNickname, pw, rs.get());
return success ? 0 : 3;
}