diff options
author | Miklos Vajna <vmiklos@collabora.co.uk> | 2016-10-26 11:59:39 +0200 |
---|---|---|
committer | Miklos Vajna <vmiklos@collabora.co.uk> | 2016-10-26 12:20:26 +0000 |
commit | a324099538916eae7f7239d32fd98ec8018cbb72 (patch) | |
tree | f1576aeb5c2275aebf78833d4bf0a600e00432e1 /xmlsecurity/inc | |
parent | da5d20562479174504c3795aa9e7ca0856883e81 (diff) |
xmlsecurity PDF signing: only write incremental xref in an incremental update
We used to just dump all the object offsets in the xref of the
incremental update, but Adobe Acrobat doesn't like that, and considers
that a second signature invalidates the first. If we properly only
mention new and changed objects in the xref, then this doesn't happen.
This requires actually parsing incremental updates, the previous code
depended on LO writing not-really-incremental xrefs at the end of
incremental updates.
Change-Id: Icdd73fe0a3eab16f8c5a62f1355edbb49f6e73de
Reviewed-on: https://gerrit.libreoffice.org/30288
Reviewed-by: Miklos Vajna <vmiklos@collabora.co.uk>
Tested-by: Jenkins <ci@libreoffice.org>
Diffstat (limited to 'xmlsecurity/inc')
-rw-r--r-- | xmlsecurity/inc/pdfio/pdfdocument.hxx | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/xmlsecurity/inc/pdfio/pdfdocument.hxx b/xmlsecurity/inc/pdfio/pdfdocument.hxx index 3886eab8e73a..59c7f5dd6079 100644 --- a/xmlsecurity/inc/pdfio/pdfdocument.hxx +++ b/xmlsecurity/inc/pdfio/pdfdocument.hxx @@ -11,6 +11,7 @@ #ifndef INCLUDED_XMLSECURITY_INC_PDFIO_PDFDOCUMENT_HXX #define INCLUDED_XMLSECURITY_INC_PDFIO_PDFDOCUMENT_HXX +#include <map> #include <vector> #include <com/sun/star/security/XCertificate.hpp> @@ -48,8 +49,10 @@ class XMLSECURITY_DLLPUBLIC PDFDocument { /// This vector owns all elements. std::vector< std::unique_ptr<PDFElement> > m_aElements; - // List of object offsets we know. - std::vector<size_t> m_aXRef; + /// Object ID <-> object offset map. + std::map<size_t, size_t> m_aXRef; + /// Object ID <-> "are changed as part of an incremental update?" map. + std::map<size_t, bool> m_aXRefDirty; /// List of xref offsets we know. std::vector<size_t> m_aStartXRefs; /// List of EOF offsets we know. @@ -61,6 +64,8 @@ class XMLSECURITY_DLLPUBLIC PDFDocument static int AsHex(char ch); /// Decode a hex dump. static std::vector<unsigned char> DecodeHexString(PDFHexStringElement* pElement); + /// Tokenize elements from current offset, optionally only till the next EOF. + bool Tokenize(SvStream& rStream, bool bPartial); public: PDFDocument(); @@ -76,6 +81,7 @@ public: /// Remember the end location of an EOF token. void PushBackEOF(size_t nOffset); + /// Read elements from the start of the stream till its end. bool Read(SvStream& rStream); /// Sign the read document with xCertificate in the edit buffer. bool Sign(const css::uno::Reference<css::security::XCertificate>& xCertificate, const OUString& rDescription); |