From 8ec561d1bccc46e9db40a9f61310cd8b3763914e Mon Sep 17 00:00:00 2001 From: Paul Gardiner Date: Thu, 1 Feb 2018 13:19:48 +0000 Subject: Signature support: add a null pdf_check_signature function Add a version of pdf_check_signature function that reports no support, for builds without openssl. This allows the removal of ifdefs from the apps. --- Makefile | 9 ++++----- platform/win32/mupdf.vcproj | 17 ----------------- platform/x11/pdfapp.c | 4 ---- source/helpers/pkcs7/pkcs7-check.c | 14 +++++++++++++- source/tools/pdfsign.c | 4 ---- 5 files changed, 17 insertions(+), 31 deletions(-) diff --git a/Makefile b/Makefile index acf559fe..de46568d 100644 --- a/Makefile +++ b/Makefile @@ -141,7 +141,10 @@ CBZ_SRC := $(sort $(wildcard source/cbz/*.c)) HTML_SRC := $(sort $(wildcard source/html/*.c)) GPRF_SRC := $(sort $(wildcard source/gprf/*.c)) THREAD_SRC := $(sort $(wildcard source/helpers/mu-threads/*.c)) -PKCS7_SRC := $(sort $(wildcard source/helpers/pkcs7/*.c)) +PKCS7_SRC := $(wildcard source/helpers/pkcs7/pkcs7-check.c) +ifeq "$(HAVE_LIBCRYPTO)" "yes" +PKCS7_SRC += $(wildcard source/helpers/pkcs7/pkcs7-openssl.c) +endif FITZ_SRC_HDR := $(wildcard source/fitz/*.h) PDF_SRC_HDR := $(wildcard source/pdf/*.h) source/pdf/pdf-name-table.h @@ -325,9 +328,7 @@ generate: $(JAVASCRIPT_GEN) MUPDF_LIB = $(OUT)/libmupdf.a THIRD_LIB = $(OUT)/libmupdfthird.a THREAD_LIB = $(OUT)/libmuthreads.a -ifeq "$(HAVE_LIBCRYPTO)" "yes" PKCS7_LIB = $(OUT)/libmupkcs7.a -endif MUPDF_OBJ := \ $(FITZ_OBJ) \ @@ -357,9 +358,7 @@ THIRD_OBJ := \ $(MUPDF_LIB) : $(MUPDF_OBJ) $(THIRD_LIB) : $(THIRD_OBJ) $(THREAD_LIB) : $(THREAD_OBJ) -ifeq "$(HAVE_LIBCRYPTO)" "yes" $(PKCS7_LIB) : $(PKCS7_OBJ) -endif INSTALL_LIBS := $(MUPDF_LIB) $(THIRD_LIB) diff --git a/platform/win32/mupdf.vcproj b/platform/win32/mupdf.vcproj index 84e3a359..d4c42ec8 100644 --- a/platform/win32/mupdf.vcproj +++ b/platform/win32/mupdf.vcproj @@ -1360,7 +1360,6 @@ > @@ -126,3 +128,13 @@ int pdf_check_signature(fz_context *ctx, pdf_document *doc, pdf_widget *widget, return res; } + +#else + +int pdf_check_signature(fz_context *ctx, pdf_document *doc, pdf_widget *widget, char *ebuf, int ebufsize) +{ + fz_strlcpy(ebuf, "No digital signing support in this build", ebufsize); + return 0; +} + +#endif diff --git a/source/tools/pdfsign.c b/source/tools/pdfsign.c index 434c9332..b9b1c862 100644 --- a/source/tools/pdfsign.c +++ b/source/tools/pdfsign.c @@ -23,14 +23,10 @@ static void usage(void) void verify_signature(fz_context *ctx, pdf_document *doc, int n, pdf_widget *widget) { -#ifdef HAVE_LIBCRYPTO char msg[256]; printf("verifying signature on page %d\n", n+1); pdf_check_signature(ctx, doc, widget, msg, sizeof msg); printf(" result: '%s'\n", msg); -#else - printf("No signature support in this build\n"); -#endif } void verify_page(fz_context *ctx, pdf_document *doc, int n, pdf_page *page) -- cgit v1.2.3