summaryrefslogtreecommitdiff
path: root/xmlsecurity
AgeCommit message (Collapse)AuthorFilesLines
2016-11-22vcl PDF mscrypto sign: upgrade SHA-1 hash to SHA-256Miklos Vajna1-0/+10
Also: - avoid writing ETSI.CAdES.detached for now on Windows till doing so results in an invalid signature in Acrobat - extend the SEC_OID_PKCS1_SHA1_WITH_RSA_ENCRYPTION hack to do the same for SHA256 and SHA512 as well, as Acrobat and NSS accepts such signatures Change-Id: Ibb0a204504b29230dd712ffb709d2037c1007218
2016-11-22xmlsecurity: no need to inherit from XSecurityController in XSecControllerMiklos Vajna3-15/+0
Change-Id: If26be2b51a1fd8a6ad3e96928e2d142d1ced2845 Reviewed-on: https://gerrit.libreoffice.org/31074 Tested-by: Jenkins <ci@libreoffice.org> Reviewed-by: Miklos Vajna <vmiklos@collabora.co.uk>
2016-11-22Executable_pdfverify: move pdfverify.cxx to workben/Miklos Vajna2-1/+1
That's where the implementation of such internal test binaries usually are. Change-Id: Ib7d2eb95de96d0d82e90e51f58da3a0c15a2ec71 Reviewed-on: https://gerrit.libreoffice.org/31073 Tested-by: Jenkins <ci@libreoffice.org> Reviewed-by: Miklos Vajna <vmiklos@collabora.co.uk>
2016-11-21add missing deps on ui filesDavid Tardon1-0/+4
Change-Id: I28bb2a33c02d8eadced584d3d3f2b62b2e847324
2016-11-20gbuild allow unitest to run once per lang in WITH_LANG_LISTNorbert Thiebaud1-1/+1
this is motivated by the new screenshot feature the initial proposed solution involved running make screenshot once per lang which took ~6 hours for --with-lang=ALL on tb68 a reasonnably big windows slavebot. with this patch, one can run make screenshot just once and get all the screenshot the elapsed time is 36 inutes on the same box/same config a 10x improvement. Change-Id: I4339caebf915c118aa455de2a7e56e1a4e413939 Reviewed-on: https://gerrit.libreoffice.org/30970 Tested-by: Jenkins <ci@libreoffice.org> Reviewed-by: Norbert Thiebaud <nthiebaud@gmail.com>
2016-11-18The PDF tests require HAVE_FEATURE_PDFIMPORTTor Lillqvist1-0/+10
Change-Id: Iac3d2206388fde23d2f3d7a05b23978851cf2800
2016-11-18xmlsecurity: clean up unused mxSecurityControllerMiklos Vajna3-10/+3
Change-Id: Ife64ab3683479baf152357a6167718f13c9b6089 Reviewed-on: https://gerrit.libreoffice.org/30964 Reviewed-by: Miklos Vajna <vmiklos@collabora.co.uk> Tested-by: Jenkins <ci@libreoffice.org>
2016-11-18Prefer to take the signature date from the XAdES SigningTime, if presentTor Lillqvist2-4/+23
Change-Id: I15a00a8c6f8c8e735694baa25e06ed4db0875d43
2016-11-18includes should be at the top of the fileNoel Grandin1-3/+3
not randomly scattered through the code found with something like: git ls-files *.cpp | xargs grep -Pzl "(?s){.*#include" Change-Id: I9c242fa4ef99e8677f2800d7ec9f16d16e488351 Reviewed-on: https://gerrit.libreoffice.org/30952 Tested-by: Jenkins <ci@libreoffice.org> Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
2016-11-17xmlsecurity PDF sign: handle AdES when writing SubFilterMiklos Vajna8-18/+22
Page 21 of "PAdES baseline signatures" specification from <http://www.etsi.org/deliver/etsi_en/319100_319199/31914201/01.01.01_60/en_31914201v010101p.pdf> says: "The Signature Dictionary shall contain a value of ETSI.CAdES.detached for the key SubFilter." So in case the UI has the adescompliant checkbox enabled, write that value instead of the Adobe default. Change-Id: I69e606a32fb09bebd5e9b25b32150d1b8672f544
2016-11-17coverity#1394292 Unchecked return valueCaolán McNamara1-1/+4
Change-Id: I90db6e3c69a6dc90ce1df0dbb5b9d7a81cd1bbea
2016-11-16xmlsecurity: fix alignment for XAdES checkboxMiklos Vajna3-14/+15
And rename it to AdES, as the PDF PAdES generation will be affected by this checkbox in the near future. Change-Id: I06121e4eb9debac7a55a737a71780c2fa5c4d084 Reviewed-on: https://gerrit.libreoffice.org/30908 Reviewed-by: Miklos Vajna <vmiklos@collabora.co.uk> Tested-by: Tor Lillqvist <tml@collabora.com>
2016-11-16Nothing from <tools/debug.hxx> used hereTor Lillqvist7-7/+0
Change-Id: Ic7aa466c62eb8850d3c6b50c0e10b0575bd9b82e
2016-11-15Add the Target for xd:QualifyingPropertiesTor Lillqvist1-1/+3
Change-Id: Ic15c34c77ff24a506b59ed02db3cfbb6722d0f25
2016-11-15Sign also the xd:SignedPropertiesTor Lillqvist1-0/+6
Change-Id: If5793cd8a721ac5b4fce5280b6180f2827c72501
2016-11-15Fix typosSamuel Mehrbrodt1-1/+1
Change-Id: I3e38b1d445c368c28e807202b94c603bd2b2c672 Reviewed-on: https://gerrit.libreoffice.org/30872 Reviewed-by: Samuel Mehrbrodt <Samuel.Mehrbrodt@cib.de> Tested-by: Samuel Mehrbrodt <Samuel.Mehrbrodt@cib.de>
2016-11-14xsd:dateTime must use period as decimal separator, not commaTor Lillqvist1-1/+4
Change-Id: I8ed5242a4337da2ec1568d92bebfdad4915e6128
2016-11-14oox, xmlsecurity: fix recently introduced style problemsMiklos Vajna1-1/+1
These files had a consistent style previously, keep them that way. Change-Id: I6347efd4a301ddd758f4661778c0dfb68585940d
2016-11-13drop extra semicolonsDavid Tardon1-1/+1
Change-Id: Ie6713d1bdf0010e5bc0bb70ca995c4dd36408673
2016-11-12cid#1394298: This field was uninitialized and unusedTor Lillqvist1-2/+0
Probably cid#1394297 was a fallout from that? Change-Id: I98134ccbbbe8bc0b7d3c172ffddcdc3666f436f6
2016-11-12More EncapsulatedX509Certificate workTor Lillqvist7-5/+29
Change-Id: I64239dfcfbc2383c2bf53c0cb86196d3f2c79330
2016-11-11xmlsecurity: extract parts of PDFDocument::Sign() into separate functionsMiklos Vajna2-33/+97
Hopefully it's easier to read this way. Change-Id: I145e00f8e57e20f2663d1c9ee494af5d93c014c7
2016-11-11More XAdES workTor Lillqvist5-1/+38
Accept and store a set of EncapsulatedX509Certificate data for a signature. Change-Id: Iae69502bc8caa0287c8f6d6c352256bdda22406b
2016-11-10'make screenshot' use-after-free fixesStephan Bergmann1-2/+2
Change-Id: I4302d0d767a1bf50fd34a78e9aa0ad6d6b0c7a22
2016-11-10xmlsecurity PDF sign: support non-compressed AcroForm objectsMiklos Vajna2-9/+28
This was the last problem to be able to counter-sign Acrobat-created PDF 1.6 signatures unlimited number of times. Change-Id: I24ab80c8516b6fe9c08d57c08907bec70384dc28 Reviewed-on: https://gerrit.libreoffice.org/30757 Tested-by: Jenkins <ci@libreoffice.org> Reviewed-by: Miklos Vajna <vmiklos@collabora.co.uk>
2016-11-10xmlsecurity PDF verify: fix incremental updates vs object streamsMiklos Vajna1-19/+18
The problem: an object stream provies obj#1 and obj#2, then an incremental updates provides an updated obj#1'. Then we look up obj#2, parse the stored objects on-demand, so at the end when later we look up the first object, we find obj#1, not obj#1'. An easy workaround would be to never update already existing objects from object streams, but that would break when an incremental update provides an object stream. Fix the problem by parsing stored objects right after tokenizing the object stream, and not later, on-demand, when we no longer have the context what objects should be ignored. This is needed (but not enough) to correctly append a signature at the end of a PDF file that has both object streams and incremental updates. Change-Id: I3c1fae5ac26804c8e8cc1984511f43cfa881c97b
2016-11-10More work in progress on XAdES compliant ODF signingTor Lillqvist15-76/+170
Pass an XAdES flag to a couple more functions and adapt to that. Factor out writeDigestMethod() and writeSignedProperties() from OOXMLSecExporter::Impl to DocumentSignatureHelper and use them in an additional place. Write xd:UnsignedProperties with EncapsulatedX509Certificate. Probably much more work needed. Change-Id: I2a0cd1db6dd487b9c7ba256ad29473de3d271cd8
2016-11-10xmlsecurity PDF verify: fix reading multiple subsections from an xref streamMiklos Vajna1-87/+105
This is especially needed, as we don't bother compressing updated objects into sections on signing, we simply use a separate section for each updated object. Work towards supporting xref streams and incremental updates at the same time. Change-Id: Ie9759edbba816991615fafc6602cdd440141b989
2016-11-10xmlsecurity PDF sign: use a predictor when compressing the xref streamMiklos Vajna2-5/+46
With this our xref stream output is close enough to Acrobat so that the existing signature verifier runs without any problems. Change-Id: I6eca7966890365759c269b465e4bf4d86d335219
2016-11-09These functions don't even need to be XMLSECURITY_DLLPUBLICTor Lillqvist1-11/+11
Change-Id: I8f2963c9b6b1c8717ea4d19453815fffa6e68484
2016-11-09xmlsecurity PDF sign: compress the xref streamMiklos Vajna1-1/+13
This way it's a bit smaller for large files and our output is closer to what Acrobat produces. Change-Id: Ide5f7b58a74a9d6ad7d806814eb57cb6931023cc Reviewed-on: https://gerrit.libreoffice.org/30726 Tested-by: Jenkins <ci@libreoffice.org> Reviewed-by: Miklos Vajna <vmiklos@collabora.co.uk>
2016-11-09xmlsecurity PDF sign: improve suggested signature IDMiklos Vajna2-2/+23
So that when we have a single signature with ID="Signature2", then we use "Signature3" for the next ID, not "Signature2". (Acrobat uses that ID for the first signature.) Change-Id: I7032fbf014184da2a5be24730a92abc32a9a1258 Reviewed-on: https://gerrit.libreoffice.org/30725 Tested-by: Jenkins <ci@libreoffice.org> Reviewed-by: Miklos Vajna <vmiklos@collabora.co.uk>
2016-11-09xmlsecurity PDF sign: conditionally write xref streamMiklos Vajna1-61/+178
In case the input document used a PDF 1.5 xref stream, not an old xref table, then write that as part of the incremental update. Acrobat seems to require this. Change-Id: I9f1f73140c26308f8720aa1ffe1b905d0e60ede0 Reviewed-on: https://gerrit.libreoffice.org/30724 Tested-by: Jenkins <ci@libreoffice.org> Reviewed-by: Miklos Vajna <vmiklos@collabora.co.uk>
2016-11-09xmlsecurity PDF sign: handle when Catalog's AcroForm is an indirect dictionaryMiklos Vajna1-30/+111
Normally it's a direct dictionary, but it's OK to have it as a reference, and then the referenced object is a dictionary. Change-Id: If09edaf23501883be68148e430c42e721ec68247 Reviewed-on: https://gerrit.libreoffice.org/30719 Tested-by: Jenkins <ci@libreoffice.org> Reviewed-by: Miklos Vajna <vmiklos@collabora.co.uk>
2016-11-09Don't use a class for what namespaces are forTor Lillqvist1-27/+19
Sure, using a namespace means we have to decorate each function with the XMLSECURITY_DLLPUBLIC, but who cares. Change-Id: If9a364d1be9c5f4cd02f3f146e8b01bd608b373e
2016-11-09loplugin:unnecessaryoverride and loplugin:overrideTor Lillqvist1-8/+1
Change-Id: Id9daf4f5e3208eca8d3d845983b58ab056557621
2016-11-09xmlsecurity PDF sign: handle when Page object's Annots is an indirect arrayMiklos Vajna1-33/+82
Normally it's a direct array, but it's OK to have it as a reference, and then the referenced object is an array. Change-Id: I191150632c2d8317ee6fd8c8169a90996298faa4 Reviewed-on: https://gerrit.libreoffice.org/30718 Tested-by: Jenkins <ci@libreoffice.org> Reviewed-by: Miklos Vajna <vmiklos@collabora.co.uk>
2016-11-08xmlsecurity PDF verify: fix handling of xref stream free objectsMiklos Vajna2-3/+16
In case our xref table doesn't have an entry for "free" object types, then the table size won't provide a valid id for a next object. That resulted in creating all new objects with the same ID. With this, our verifier at least can see the new signature when appending one to a signed PDF 1.6 file. Change-Id: Iac39a400706cfcd23dd814d2b81cb8b950c69fc6 Reviewed-on: https://gerrit.libreoffice.org/30704 Tested-by: Jenkins <ci@libreoffice.org> Reviewed-by: Miklos Vajna <vmiklos@collabora.co.uk>
2016-11-08xmlsecurity PDF sign: handle xref stream when reading trailerMiklos Vajna1-6/+23
Don't give up signing just because PDF 1.4 trailer is missing, provided that PDF 1.5 xref stream is available. Change-Id: I03360d428346537583a4398aa3a94b195b428713 Reviewed-on: https://gerrit.libreoffice.org/30703 Tested-by: Jenkins <ci@libreoffice.org> Reviewed-by: Miklos Vajna <vmiklos@collabora.co.uk>
2016-11-08xmlsecurity PDF sign: don't crash on missing trailerMiklos Vajna1-0/+5
This will need cross-reference stream write support, just don't crash for now. Change-Id: Id48c131b22d4ed96174693f3e96b14c273d596a8 Reviewed-on: https://gerrit.libreoffice.org/30702 Tested-by: Jenkins <ci@libreoffice.org> Reviewed-by: Miklos Vajna <vmiklos@collabora.co.uk>
2016-11-08xmlsecurity: move the sec context from the format helpers to the sign managerMiklos Vajna9-95/+87
The signature manager always creates an XML helper, and optionally creates a PDF helper as well. Both of them initialize xmlsec, and when the signature manager is deleted, there are two de-inits, leading to an assertion failure in xmlsec. Fix the problem by moving the duplicated xmlsec init to the signature manager. This has the additional benefit that general security-related code no longer has to talk to the XML helper, it can use the signature manager, which feels more natural. (What viewing a certificate had to do with XML?) Change-Id: If6a6bc433636445f3782849a367d4a7ac0be7688 Reviewed-on: https://gerrit.libreoffice.org/30695 Reviewed-by: Miklos Vajna <vmiklos@collabora.co.uk> Tested-by: Jenkins <ci@libreoffice.org>
2016-11-08Fallout from previous commit 248dbe1de5eeea9e9173e53a0b1891f63ff73d68Tor Lillqvist2-13/+1
Remove SignatureInformation::nSecurityEnvironmentIndex as it was always -1. Change-Id: I39247e5c40ce36e394c30b450626eca533f46267
2016-11-08Bin pointless (overloaded) member functionTor Lillqvist2-21/+2
The XSecController::setX509Certificate() overload that took a sal_Int32 nSecurityEnvironmentIndex was called in just one place, and -1 was always passed for the nSecurityEnvironmentIndex. Change-Id: Ic37b7053c90a6fbb8b4e5b6485483d34c605b965
2016-11-08Work in progress on supporting XAdES-compliant signatures for ODFTor Lillqvist18-62/+201
xmlsecurity is such a mess. Too many different classes that actually have more or less identical life-time, with names that smell of delusions of grandeur. "Manager", "security framework controller" etc for stuff that actually exist only during the execution of a simple dialog. And then a "helper" class that actually in on a higher level than a "framework controller". But oh well. Change-Id: I86e461b1bc91a0d8f5b7fb9f13a5be201729df1e
2016-11-07Fix typos (also in the code)Andrea Gelmini2-4/+4
Change-Id: I45d45513b102f4fdcb55e8de20b95b37f66ea463 Reviewed-on: https://gerrit.libreoffice.org/30658 Reviewed-by: Michael Stahl <mstahl@redhat.com> Tested-by: Michael Stahl <mstahl@redhat.com>
2016-11-04xmlsecurity PDF NSS verify: handle SHA1_WITH_RSAMiklos Vajna4-2/+34
SHA1_WITH_RSA is a signing algorithm, not a digest one, but let's accept it, so LO on Linux can verify a signature generated by LO on Windows. It's annoying that equivalent mapping in NSS is not part of their public API. Change-Id: I97186fcc1d118f922e5ee3cb472aa5b52bc4b5ca
2016-11-04vcl: extract PDFWriter::GetDateTime() from PDFWriterImplMiklos Vajna2-1/+17
And use it in xmlsecurity when signing an existing PDF. This is especially important on Windows, where the PKCS#7 blob doesn't have an (unsigned) timestamp. Change-Id: I4051dc19a43f8f8114d9f4d02309f28d6754e9ae
2016-11-04update loplugin:unnnecessaryvirtual to handler destructorsNoel Grandin2-4/+3
and update modules writerfilter..xmloff with the resulting changes Change-Id: I54d19c22ddb0ff579b32e4934d266c925b19305c Reviewed-on: https://gerrit.libreoffice.org/30530 Tested-by: Jenkins <ci@libreoffice.org> Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
2016-11-03xmlsecurity PDF sign: enable unit tests on WindowsMiklos Vajna3-33/+16
Now that the mscrypto part of PDFDocument::ValidateSignature() is implemented it's possible to run these tests on Windows as well, provided the machine has at least one signing certificate installed. Also fix a race, where the workdir of the signing test was used by the pdfsigning test. Change-Id: I80bbfbb5dc4baa400f9a6b85961883a247b0f22b
2016-11-03Bin the XSecController::m_pErrorMessage field as it was never usedTor Lillqvist3-39/+0
It was only assigned to. Some follow-up simplification. Change-Id: I3b522064e946667d3a4c8fb82ee40bd0d44dd569