utils/CMakeLists.txt | 12 +-- utils/Makefile.am | 6 - utils/pdfdetach.1 | 5 + utils/pdffonts.1 | 3 utils/pdfimages.1 | 5 + utils/pdfinfo.1 | 3 utils/pdfseparate.1 | 10 ++ utils/pdfsig.1 | 46 +++++++++++++ utils/pdfsig.cc | 176 ++++++++++++++++++++++++++++++++++++++++++++++++++ utils/pdfsigverify.cc | 173 ------------------------------------------------- utils/pdftocairo.1 | 3 utils/pdftohtml.1 | 3 utils/pdftoppm.1 | 3 utils/pdftops.1 | 3 utils/pdftotext.1 | 5 + utils/pdfunite.1 | 10 ++ 16 files changed, 281 insertions(+), 185 deletions(-)
New commits: commit 298caa2fc52cf50e92e1afda39b77b11f2de9743 Author: Adrian Johnson <[email protected]> Date: Wed Oct 28 20:54:43 2015 +1030 Add pdfsig reference (and other missing utils) to man pages diff --git a/utils/pdfdetach.1 b/utils/pdfdetach.1 index 2bba58b..ff71431 100644 --- a/utils/pdfdetach.1 +++ b/utils/pdfdetach.1 @@ -76,11 +76,14 @@ Other error. The pdfinfo software and documentation are copyright 1996-2011 Glyph & Cog, LLC. .SH "SEE ALSO" -.BR pdfimages (1), .BR pdffonts (1), +.BR pdfimages (1), .BR pdfinfo (1), .BR pdftocairo (1), .BR pdftohtml (1), .BR pdftoppm (1), .BR pdftops (1), .BR pdftotext (1) +.BR pdfseparate (1), +.BR pdfsig (1), +.BR pdfunite (1), diff --git a/utils/pdffonts.1 b/utils/pdffonts.1 index 4afc395..b44600c 100644 --- a/utils/pdffonts.1 +++ b/utils/pdffonts.1 @@ -117,3 +117,6 @@ The pdffonts software and documentation are copyright 1996-2011 Glyph .BR pdftoppm (1), .BR pdftops (1), .BR pdftotext (1) +.BR pdfseparate (1), +.BR pdfsig (1), +.BR pdfunite (1), diff --git a/utils/pdfimages.1 b/utils/pdfimages.1 index 8485f3d..c10e331 100644 --- a/utils/pdfimages.1 +++ b/utils/pdfimages.1 @@ -250,7 +250,7 @@ Other error. The pdfimages software and documentation are copyright 1998-2011 Glyph & Cog, LLC. .SH "SEE ALSO" -.BR pdfdetach (1) +.BR pdfdetach (1), .BR pdffonts (1), .BR pdfinfo (1), .BR pdftocairo (1), @@ -258,3 +258,6 @@ The pdfimages software and documentation are copyright 1998-2011 Glyph .BR pdftoppm (1), .BR pdftops (1), .BR pdftotext (1) +.BR pdfseparate (1), +.BR pdfsig (1), +.BR pdfunite (1), diff --git a/utils/pdfinfo.1 b/utils/pdfinfo.1 index 1dd7466..c82e9bd 100644 --- a/utils/pdfinfo.1 +++ b/utils/pdfinfo.1 @@ -150,3 +150,6 @@ Cog, LLC. .BR pdftoppm (1), .BR pdftops (1), .BR pdftotext (1) +.BR pdfseparate (1), +.BR pdfsig (1), +.BR pdfunite (1), diff --git a/utils/pdfseparate.1 b/utils/pdfseparate.1 index 07779a1..8b2a054 100644 --- a/utils/pdfseparate.1 +++ b/utils/pdfseparate.1 @@ -46,4 +46,14 @@ sample-1.pdf, sample-2.pdf, sample-3.pdf The pdfseparate software and documentation are copyright 1996-2004 Glyph & Cog, LLC and copyright 2005-2011 The Poppler Developers - http://poppler.freedesktop.org .SH "SEE ALSO" +.BR pdfdetach (1), +.BR pdffonts (1), +.BR pdfimages (1), +.BR pdfinfo (1), +.BR pdftocairo (1), +.BR pdftohtml (1), +.BR pdftoppm (1), +.BR pdftops (1), +.BR pdftotext (1) +.BR pdfsig (1), .BR pdfunite (1), diff --git a/utils/pdftocairo.1 b/utils/pdftocairo.1 index 7575cab..ac112e5 100644 --- a/utils/pdftocairo.1 +++ b/utils/pdftocairo.1 @@ -293,3 +293,6 @@ The pdftocairo software and documentation are copyright 1996-2004 Glyph .BR pdftoppm (1), .BR pdftops (1), .BR pdftotext (1) +.BR pdfseparate (1), +.BR pdfsig (1), +.BR pdfunite (1), diff --git a/utils/pdftohtml.1 b/utils/pdftohtml.1 index e179070..76ded91 100644 --- a/utils/pdftohtml.1 +++ b/utils/pdftohtml.1 @@ -105,3 +105,6 @@ for the Debian GNU/Linux system (but may be used by others). .BR pdftoppm (1), .BR pdftops (1), .BR pdftotext (1) +.BR pdfseparate (1), +.BR pdfsig (1), +.BR pdfunite (1), diff --git a/utils/pdftoppm.1 b/utils/pdftoppm.1 index 7f88b6d..e30174b 100644 --- a/utils/pdftoppm.1 +++ b/utils/pdftoppm.1 @@ -168,3 +168,6 @@ The pdftoppm software and documentation are copyright 1996-2011 Glyph .BR pdftohtml (1), .BR pdftops (1), .BR pdftotext (1) +.BR pdfseparate (1), +.BR pdfsig (1), +.BR pdfunite (1), diff --git a/utils/pdftops.1 b/utils/pdftops.1 index acaec99..2154773 100644 --- a/utils/pdftops.1 +++ b/utils/pdftops.1 @@ -232,3 +232,6 @@ Cog, LLC. .BR pdftohtml (1), .BR pdftoppm (1), .BR pdftotext (1) +.BR pdfseparate (1), +.BR pdfsig (1), +.BR pdfunite (1), diff --git a/utils/pdftotext.1 b/utils/pdftotext.1 index b53f82f..4fe4848 100644 --- a/utils/pdftotext.1 +++ b/utils/pdftotext.1 @@ -138,4 +138,7 @@ The pdftotext software and documentation are copyright 1996-2011 Glyph .BR pdftocairo (1), .BR pdftohtml (1), .BR pdftoppm (1), -.BR pdftops (1) +.BR pdftops (1), +.BR pdfseparate (1), +.BR pdfsig (1), +.BR pdfunite (1), diff --git a/utils/pdfunite.1 b/utils/pdfunite.1 index 9b1f2e8..d00b4cd 100644 --- a/utils/pdfunite.1 +++ b/utils/pdfunite.1 @@ -30,4 +30,14 @@ merges all pages from sample1.pdf and sample2.pdf (in that order) and creates sa The pdfunite software and documentation are copyright 1996-2004 Glyph & Cog, LLC and copyright 2005-2011 The Poppler Developers - http://poppler.freedesktop.org .SH "SEE ALSO" +.BR pdfdetach (1), +.BR pdffonts (1), +.BR pdfimages (1), +.BR pdfinfo (1), +.BR pdftocairo (1), +.BR pdftohtml (1), +.BR pdftoppm (1), +.BR pdftops (1), +.BR pdftotext (1) .BR pdfseparate (1), +.BR pdfsig (1), commit 5a6d6f5ec8782bb69a5805d8d8379a33aa00edec Author: Adrian Johnson <[email protected]> Date: Wed Oct 28 20:54:23 2015 +1030 Add pdfsig man page diff --git a/utils/pdfsig.1 b/utils/pdfsig.1 new file mode 100644 index 0000000..5f9894e --- /dev/null +++ b/utils/pdfsig.1 @@ -0,0 +1,46 @@ +.\" Copyright 2011 The Poppler Developers - http://poppler.freedesktop.org +.TH pdfsig 1 "28 October 2015" +.SH NAME +pdfsig \- Portable Document Format (PDF) digitial signatures tool +.SH SYNOPSIS +.B pdfsig +[options] +.RI [ PDF-file ] +.SH DESCRIPTION +.B pdfsig +verifies the digital signature in a PDF document. +.PP +Certificates are searched for in the following locations: +.IP \(bu +The NSS Certificate database in the default Firefox profile. +.IP \(bu +The NSS Certificate database in /etc/pki/nssdb. +.SH OPTIONS +.TP +.B \-nocert +Do not validate the certificate. +.TP +.B \-v +Print copyright and version information. +.TP +.B \-h +Print usage information. +.RB ( \-help +and +.B \-\-help +are equivalent.) +.SH AUTHOR +The pdfsig software and documentation are copyright 1996-2004 Glyph & Cog, LLC +and copyright 2005-2015 The Poppler Developers - http://poppler.freedesktop.org +.SH "SEE ALSO" +.BR pdfdetach (1), +.BR pdffonts (1), +.BR pdfimages (1), +.BR pdfinfo (1), +.BR pdftocairo (1), +.BR pdftohtml (1), +.BR pdftoppm (1), +.BR pdftops (1), +.BR pdftotext (1) +.BR pdfseparate (1), +.BR pdfunite (1), commit 1f8e1a029773cefe0c31357c1e450cc4ecd5a5b5 Author: Adrian Johnson <[email protected]> Date: Wed Oct 28 19:38:14 2015 +1030 pdfsig: rename -c to -nocert and make help options consistent with other tools (add -? and list help options last) diff --git a/utils/pdfsig.cc b/utils/pdfsig.cc index 88abcdc..6762c37 100644 --- a/utils/pdfsig.cc +++ b/utils/pdfsig.cc @@ -89,14 +89,17 @@ static GBool printHelp = gFalse; static GBool dontVerifyCert = gFalse; static const ArgDesc argDesc[] = { + {"-nocert", argFlag, &dontVerifyCert, 0, + "don't perform certificate validation"}, + {"-v", argFlag, &printVersion, 0, "print copyright and version info"}, {"-h", argFlag, &printHelp, 0, "print usage information"}, {"-help", argFlag, &printHelp, 0, "print usage information"}, - {"-c", argFlag, &dontVerifyCert, 0, - "don't perform certificate validation"}, + {"-?", argFlag, &printHelp, 0, + "print usage information"}, {NULL} }; commit 9d5bf425bd82dda303362380c488559be0007d78 Author: Adrian Johnson <[email protected]> Date: Wed Oct 28 19:34:26 2015 +1030 rename pdfsigverify to pdfsig diff --git a/utils/CMakeLists.txt b/utils/CMakeLists.txt index 8155cb2..af81161 100644 --- a/utils/CMakeLists.txt +++ b/utils/CMakeLists.txt @@ -90,13 +90,13 @@ install(TARGETS pdfinfo DESTINATION bin) install(FILES pdfinfo.1 DESTINATION ${SHARE_INSTALL_DIR}/man/man1) if (ENABLE_NSS3) - # pdfsigverify - set(pdfsigverify_SOURCES ${common_srcs} - pdfsigverify.cc + # pdfsig + set(pdfsig_SOURCES ${common_srcs} + pdfsig.cc ) - add_executable(pdfsigverify ${pdfsigverify_SOURCES}) - target_link_libraries(pdfsigverify ${common_libs}) - install(TARGETS pdfsigverify DESTINATION bin) + add_executable(pdfsig ${pdfsig_SOURCES}) + target_link_libraries(pdfsig ${common_libs}) + install(TARGETS pdfsig DESTINATION bin) endif (ENABLE_NSS3) # pdftops diff --git a/utils/Makefile.am b/utils/Makefile.am index 2ddcca0..8ea0b85 100644 --- a/utils/Makefile.am +++ b/utils/Makefile.am @@ -26,7 +26,7 @@ bin_PROGRAMS = \ pdfunite if BUILD_NSS -bin_PROGRAMS += pdfsigverify +bin_PROGRAMS += pdfsig endif if BUILD_SPLASH_OUTPUT @@ -64,8 +64,8 @@ pdfdetach_SOURCES = \ pdffonts_SOURCES = \ pdffonts.cc -pdfsigverify_SOURCES = \ - pdfsigverify.cc +pdfsig_SOURCES = \ + pdfsig.cc pdfimages_SOURCES = \ pdfimages.cc \ diff --git a/utils/pdfsig.cc b/utils/pdfsig.cc new file mode 100644 index 0000000..88abcdc --- /dev/null +++ b/utils/pdfsig.cc @@ -0,0 +1,173 @@ +//======================================================================== +// +// pdfsig.cc +// +// This file is licensed under the GPLv2 or later +// +// Copyright 2015 André Guerreiro <[email protected]> +// Copyright 2015 André Esser <[email protected]> +// Copyright 2015 Albert Astals Cid <[email protected]> +// +//======================================================================== + +#include "config.h" +#include <poppler-config.h> +#include <stdio.h> +#include <stdlib.h> +#include <stddef.h> +#include <string.h> +#include <time.h> +#include "parseargs.h" +#include "Object.h" +#include "Array.h" +#include "Page.h" +#include "PDFDoc.h" +#include "PDFDocFactory.h" +#include "Error.h" +#include "GlobalParams.h" +#include "SignatureInfo.h" + + +const char * getReadableSigState(SignatureValidationStatus sig_vs) +{ + switch(sig_vs) { + case SIGNATURE_VALID: + return "Signature is Valid."; + + case SIGNATURE_INVALID: + return "Signature is Invalid."; + + case SIGNATURE_DIGEST_MISMATCH: + return "Digest Mismatch."; + + case SIGNATURE_DECODING_ERROR: + return "Document isn't signed or corrupted data."; + + case SIGNATURE_NOT_VERIFIED: + return "Signature has not yet been verified."; + + default: + return "Unknown Validation Failure."; + } +} + +const char * getReadableCertState(CertificateValidationStatus cert_vs) +{ + switch(cert_vs) { + case CERTIFICATE_TRUSTED: + return "Certificate is Trusted."; + + case CERTIFICATE_UNTRUSTED_ISSUER: + return "Certificate issuer isn't Trusted."; + + case CERTIFICATE_UNKNOWN_ISSUER: + return "Certificate issuer is unknown."; + + case CERTIFICATE_REVOKED: + return "Certificate has been Revoked."; + + case CERTIFICATE_EXPIRED: + return "Certificate has Expired"; + + case CERTIFICATE_NOT_VERIFIED: + return "Certificate has not yet been verified."; + + default: + return "Unknown issue with Certificate or corrupted data."; + } +} + +char *getReadableTime(time_t unix_time) +{ + char * time_str = (char *) gmalloc(64); + strftime(time_str, 64, "%b %d %Y %H:%M:%S", localtime(&unix_time)); + return time_str; +} + +static GBool printVersion = gFalse; +static GBool printHelp = gFalse; +static GBool dontVerifyCert = gFalse; + +static const ArgDesc argDesc[] = { + {"-v", argFlag, &printVersion, 0, + "print copyright and version info"}, + {"-h", argFlag, &printHelp, 0, + "print usage information"}, + {"-help", argFlag, &printHelp, 0, + "print usage information"}, + {"-c", argFlag, &dontVerifyCert, 0, + "don't perform certificate validation"}, + {NULL} +}; + + +int main(int argc, char *argv[]) +{ + PDFDoc *doc = NULL; + unsigned int sigCount; + GooString * fileName = NULL; + SignatureInfo *sig_info = NULL; + char *time_str = NULL; + std::vector<FormWidgetSignature*> sig_widgets; + globalParams = new GlobalParams(); + + int exitCode = 99; + GBool ok; + + ok = parseArgs(argDesc, &argc, argv); + + if (!ok || argc != 2 || printVersion || printHelp) { + fprintf(stderr, "pdfsig version %s\n", PACKAGE_VERSION); + fprintf(stderr, "%s\n", popplerCopyright); + fprintf(stderr, "%s\n", xpdfCopyright); + if (!printVersion) { + printUsage("pdfsig", "<PDF-file>", argDesc); + } + if (printVersion || printHelp) + exitCode = 0; + goto end; + } + + fileName = new GooString(argv[argc - 1]); + + // open PDF file + doc = PDFDocFactory().createPDFDoc(*fileName, NULL, NULL); + + if (!doc->isOk()) { + exitCode = 1; + goto end; + } + + sig_widgets = doc->getSignatureWidgets(); + sigCount = sig_widgets.size(); + + if (sigCount >= 1) { + printf("Digital Signature Info of: %s\n", fileName->getCString()); + } else { + printf("File '%s' does not contain any signatures\n", fileName->getCString()); + exitCode = 2; + goto end; + } + + for (unsigned int i = 0; i < sigCount; i++) { + sig_info = sig_widgets.at(i)->validateSignature(!dontVerifyCert, false); + printf("Signature #%d:\n", i+1); + printf(" - Signer Certificate Common Name: %s\n", sig_info->getSignerName()); + printf(" - Signing Time: %s\n", time_str = getReadableTime(sig_info->getSigningTime())); + printf(" - Signature Validation: %s\n", getReadableSigState(sig_info->getSignatureValStatus())); + gfree(time_str); + if (sig_info->getSignatureValStatus() != SIGNATURE_VALID || dontVerifyCert) { + continue; + } + printf(" - Certificate Validation: %s\n", getReadableCertState(sig_info->getCertificateValStatus())); + } + + exitCode = 0; + +end: + delete globalParams; + delete fileName; + delete doc; + + return exitCode; +} diff --git a/utils/pdfsigverify.cc b/utils/pdfsigverify.cc deleted file mode 100644 index a9a801d..0000000 --- a/utils/pdfsigverify.cc +++ /dev/null @@ -1,173 +0,0 @@ -//======================================================================== -// -// pdfsigverify.cc -// -// This file is licensed under the GPLv2 or later -// -// Copyright 2015 André Guerreiro <[email protected]> -// Copyright 2015 André Esser <[email protected]> -// Copyright 2015 Albert Astals Cid <[email protected]> -// -//======================================================================== - -#include "config.h" -#include <poppler-config.h> -#include <stdio.h> -#include <stdlib.h> -#include <stddef.h> -#include <string.h> -#include <time.h> -#include "parseargs.h" -#include "Object.h" -#include "Array.h" -#include "Page.h" -#include "PDFDoc.h" -#include "PDFDocFactory.h" -#include "Error.h" -#include "GlobalParams.h" -#include "SignatureInfo.h" - - -const char * getReadableSigState(SignatureValidationStatus sig_vs) -{ - switch(sig_vs) { - case SIGNATURE_VALID: - return "Signature is Valid."; - - case SIGNATURE_INVALID: - return "Signature is Invalid."; - - case SIGNATURE_DIGEST_MISMATCH: - return "Digest Mismatch."; - - case SIGNATURE_DECODING_ERROR: - return "Document isn't signed or corrupted data."; - - case SIGNATURE_NOT_VERIFIED: - return "Signature has not yet been verified."; - - default: - return "Unknown Validation Failure."; - } -} - -const char * getReadableCertState(CertificateValidationStatus cert_vs) -{ - switch(cert_vs) { - case CERTIFICATE_TRUSTED: - return "Certificate is Trusted."; - - case CERTIFICATE_UNTRUSTED_ISSUER: - return "Certificate issuer isn't Trusted."; - - case CERTIFICATE_UNKNOWN_ISSUER: - return "Certificate issuer is unknown."; - - case CERTIFICATE_REVOKED: - return "Certificate has been Revoked."; - - case CERTIFICATE_EXPIRED: - return "Certificate has Expired"; - - case CERTIFICATE_NOT_VERIFIED: - return "Certificate has not yet been verified."; - - default: - return "Unknown issue with Certificate or corrupted data."; - } -} - -char *getReadableTime(time_t unix_time) -{ - char * time_str = (char *) gmalloc(64); - strftime(time_str, 64, "%b %d %Y %H:%M:%S", localtime(&unix_time)); - return time_str; -} - -static GBool printVersion = gFalse; -static GBool printHelp = gFalse; -static GBool dontVerifyCert = gFalse; - -static const ArgDesc argDesc[] = { - {"-v", argFlag, &printVersion, 0, - "print copyright and version info"}, - {"-h", argFlag, &printHelp, 0, - "print usage information"}, - {"-help", argFlag, &printHelp, 0, - "print usage information"}, - {"-c", argFlag, &dontVerifyCert, 0, - "don't perform certificate validation"}, - {NULL} -}; - - -int main(int argc, char *argv[]) -{ - PDFDoc *doc = NULL; - unsigned int sigCount; - GooString * fileName = NULL; - SignatureInfo *sig_info = NULL; - char *time_str = NULL; - std::vector<FormWidgetSignature*> sig_widgets; - globalParams = new GlobalParams(); - - int exitCode = 99; - GBool ok; - - ok = parseArgs(argDesc, &argc, argv); - - if (!ok || argc != 2 || printVersion || printHelp) { - fprintf(stderr, "pdfsigverify version %s\n", PACKAGE_VERSION); - fprintf(stderr, "%s\n", popplerCopyright); - fprintf(stderr, "%s\n", xpdfCopyright); - if (!printVersion) { - printUsage("pdfsigverify", "<PDF-file>", argDesc); - } - if (printVersion || printHelp) - exitCode = 0; - goto end; - } - - fileName = new GooString(argv[argc - 1]); - - // open PDF file - doc = PDFDocFactory().createPDFDoc(*fileName, NULL, NULL); - - if (!doc->isOk()) { - exitCode = 1; - goto end; - } - - sig_widgets = doc->getSignatureWidgets(); - sigCount = sig_widgets.size(); - - if (sigCount >= 1) { - printf("Digital Signature Info of: %s\n", fileName->getCString()); - } else { - printf("File '%s' does not contain any signatures\n", fileName->getCString()); - exitCode = 2; - goto end; - } - - for (unsigned int i = 0; i < sigCount; i++) { - sig_info = sig_widgets.at(i)->validateSignature(!dontVerifyCert, false); - printf("Signature #%d:\n", i+1); - printf(" - Signer Certificate Common Name: %s\n", sig_info->getSignerName()); - printf(" - Signing Time: %s\n", time_str = getReadableTime(sig_info->getSigningTime())); - printf(" - Signature Validation: %s\n", getReadableSigState(sig_info->getSignatureValStatus())); - gfree(time_str); - if (sig_info->getSignatureValStatus() != SIGNATURE_VALID || dontVerifyCert) { - continue; - } - printf(" - Certificate Validation: %s\n", getReadableCertState(sig_info->getCertificateValStatus())); - } - - exitCode = 0; - -end: - delete globalParams; - delete fileName; - delete doc; - - return exitCode; -}
_______________________________________________ poppler mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/poppler
