[gs-commits] mupdf 1.16.1.80 Set signature content end marker to /Type
[email protected] (Sebastian Rasmussen) Fri, 4 Oct 2019 10:28:15 +0000 (UTC)
| Newsgroups | gmane.comp.printing.ghostscript.cvs |
|---|---|
| Message-ID | <[email protected]> |
commit 3d1edf46d4ae4fd483141c1eae1977b22695c001 Author: Pete McLaughlin <[email protected]> Date: Thu Oct 3 09:39:10 2019 +0100 Set signature content end marker to /Type /Sig. In commit a56db95ef we added the optional '/Type /Sig' entry to the signature dictionary, but the code in pdf-write.c:complete_signatures() was still using the '/Filter' entry as the marker for the end of the digest content. This resulted in the calculations for the byte range being out by 8 as we were including the recently added /Type /Sig entry, and resulted in verify errors when we parsed the digest in pdf-form.c:validate_certificate_data(). This commit modifies pdf-form.c:pdf_signature_set_value() to add the /Type entry after the other entries so that the mandatory /Filter entry is still directly after the contents. diff --git a/source/pdf/pdf-form.c b/source/pdf/pdf-form.c index 2729f2e..9b5d044 100644 --- a/source/pdf/pdf-form.c +++ b/source/pdf/pdf-form.c @@ -1322,7 +1322,6 @@ void pdf_signature_set_value(fz_context *ctx, pdf_document *doc, pdf_obj *field, pdf_obj *v = NULL; pdf_obj *indv; int vnum; - pdf_obj *contents; int max_digest_size; char *buf = NULL; @@ -1341,11 +1340,15 @@ void pdf_signature_set_value(fz_context *ctx, pdf_document *doc, pdf_obj *field, buf = fz_calloc(ctx, max_digest_size, 1); + /* Ensure that the /Filter entry is the first entry in the + dictionary after the digest contents since we look for + this tag when completing signatures in pdf-write.c in order + to generate the correct byte range. */ pdf_dict_put_array(ctx, v, PDF_NAME(ByteRange), 4); pdf_dict_put_string(ctx, v, PDF_NAME(Contents), buf, max_digest_size); - pdf_dict_put(ctx, v, PDF_NAME(Type), PDF_NAME(Sig)); pdf_dict_put(ctx, v, PDF_NAME(Filter), PDF_NAME(Adobe_PPKLite)); pdf_dict_put(ctx, v, PDF_NAME(SubFilter), PDF_NAME(adbe_pkcs7_detached)); + pdf_dict_put(ctx, v, PDF_NAME(Type), PDF_NAME(Sig)); /* Record details within the document structure so that contents * and byte_range can be updated with their correct values at http://git.ghostscript.com/?p=mupdf.git;a=commit;h=3d1edf46d4ae4fd483141c1eae1977b22695c001 -- MuPDF library Artifex Software, Inc.