seen at least with recent GCC 16 trunk,
> In file included from ~/gcc/inst/include/c++/16.0.1/bits/shared_ptr.h:53,
> from ~/gcc/inst/include/c++/16.0.1/memory:82,
> from include/unotools/syslocale.hxx:25,
> from include/unotools/resmgr.hxx:24,
> from xmlsecurity/inc/resourcemanager.hxx:22,
> from xmlsecurity/source/component/documentdigitalsignatures.cxx:20:
> In destructor ‘std::_Sp_counted_ptr_inplace<_Tp, _Alloc, _Lp>::~_Sp_counted_ptr_inplace() [with _Tp = DigitalSignaturesDialog; _Alloc = std::allocator<void>; __gnu_cxx::_Lock_policy _Lp = __gnu_cxx::_S_atomic]’,
> inlined from ‘std::_Sp_counted_ptr_inplace<_Tp, _Alloc, _Lp>::~_Sp_counted_ptr_inplace() [with _Tp = DigitalSignaturesDialog; _Alloc = std::allocator<void>; __gnu_cxx::_Lock_policy _Lp = __gnu_cxx::_S_atomic]’ at ~/gcc/inst/include/c++/16.0.1/bits/shared_ptr_base.h:670:45,
> inlined from ‘void std::_Sp_counted_base<_Lp>::_M_destroy() [with __gnu_cxx::_Lock_policy _Lp = __gnu_cxx::_S_atomic]’ at ~/gcc/inst/include/c++/16.0.1/bits/shared_ptr_base.h:143:9,
> inlined from ‘void std::_Sp_counted_base<_Lp>::_M_release() [with __gnu_cxx::_Lock_policy _Lp = __gnu_cxx::_S_atomic]’ at ~/gcc/inst/include/c++/16.0.1/bits/shared_ptr_base.h:424:18,
> inlined from ‘void std::_Sp_counted_base<_Lp>::_M_release() [with __gnu_cxx::_Lock_policy _Lp = __gnu_cxx::_S_atomic]’ at ~/gcc/inst/include/c++/16.0.1/bits/shared_ptr_base.h:392:5,
> inlined from ‘std::__shared_count<_Lp>::~__shared_count() [with __gnu_cxx::_Lock_policy _Lp = __gnu_cxx::_S_atomic]’ at ~/gcc/inst/include/c++/16.0.1/bits/shared_ptr_base.h:1129:21,
> inlined from ‘std::__shared_ptr<_Tp, _Lp>::~__shared_ptr() [with _Tp = CertificateChooser; __gnu_cxx::_Lock_policy _Lp = __gnu_cxx::_S_atomic]’ at ~/gcc/inst/include/c++/16.0.1/bits/shared_ptr_base.h:1603:7,
> inlined from ‘std::shared_ptr<CertificateChooser>::~shared_ptr()’ at ~/gcc/inst/include/c++/16.0.1/bits/shared_ptr.h:175:11,
> inlined from ‘com::sun::star::uno::Sequence<com::sun::star::uno::Reference<com::sun::star::security::XCertificate> > {anonymous}::DocumentDigitalSignatures::chooseCertificatesImpl.constprop(SfxViewShell*, std::__debug::map<rtl::OUString, rtl::OUString>&, CertificateChooserUserAction, com::sun::star::security::CertificateKind)’ at xmlsecurity/source/component/documentdigitalsignatures.cxx:674:1:
> ~/gcc/inst/include/c++/16.0.1/bits/shared_ptr_base.h:670:45: error: array subscript ‘std::_Sp_counted_ptr_inplace<DigitalSignaturesDialog, std::allocator<void>, __gnu_cxx::_S_atomic>[0]’ is partly outside array bounds of ‘unsigned char [384]’ [-Werror=array-bounds=]
> 670 | ~_Sp_counted_ptr_inplace() noexcept { }
> | ^
> In file included from ~/gcc/inst/include/c++/16.0.1/x86_64-pc-linux-gnu/bits/c++allocator.h:33,
> from ~/gcc/inst/include/c++/16.0.1/bits/allocator.h:46,
> from ~/gcc/inst/include/c++/16.0.1/memory:67:
> In member function ‘_Tp* std::__new_allocator<_Tp>::allocate(size_type, const void*) [with _Tp = std::_Sp_counted_ptr_inplace<CertificateChooser, std::allocator<void>, __gnu_cxx::_S_atomic>]’,
> inlined from ‘constexpr _Tp* std::allocator< <template-parameter-1-1> >::allocate(std::size_t) [with _Tp = std::_Sp_counted_ptr_inplace<CertificateChooser, std::allocator<void>, __gnu_cxx::_S_atomic>]’ at ~/gcc/inst/include/c++/16.0.1/bits/allocator.h:203:40,
> inlined from ‘static constexpr _Tp* std::allocator_traits<std::allocator<_Up> >::allocate(allocator_type&, size_type) [with _Tp = std::_Sp_counted_ptr_inplace<CertificateChooser, std::allocator<void>, __gnu_cxx::_S_atomic>]’ at ~/gcc/inst/include/c++/16.0.1/bits/alloc_traits.h:614:28,
> inlined from ‘std::__allocated_ptr<_Alloc> std::__allocate_guarded(_Alloc&) [with _Alloc = allocator<_Sp_counted_ptr_inplace<CertificateChooser, allocator<void>, __gnu_cxx::_S_atomic> >]’ at ~/gcc/inst/include/c++/16.0.1/bits/allocated_ptr.h:103:69,
> inlined from ‘std::__shared_count<_Lp>::__shared_count(_Tp*&, std::_Sp_alloc_shared_tag<_Alloc>, _Args&& ...) [with _Tp = CertificateChooser; _Alloc = std::allocator<void>; _Args = {weld::Window*&, SfxViewShell*&, std::__debug::vector<com::sun::star::uno::Reference<com::sun::star::xml::crypto::XXMLSecurityContext>, std::allocator<com::sun::star::uno::Reference<com::sun::star::xml::crypto::XXMLSecurityContext> > >, CertificateChooserUserAction&}; __gnu_cxx::_Lock_policy _Lp = __gnu_cxx::_S_atomic]’ at ~/gcc/inst/include/c++/16.0.1/bits/shared_ptr_base.h:1027:9,
> inlined from ‘std::__shared_ptr<_Tp, _Lp>::__shared_ptr(std::_Sp_alloc_shared_tag<_Tp>, _Args&& ...) [with _Alloc = std::allocator<void>; _Args = {weld::Window*&, SfxViewShell*&, std::__debug::vector<com::sun::star::uno::Reference<com::sun::star::xml::crypto::XXMLSecurityContext>, std::allocator<com::sun::star::uno::Reference<com::sun::star::xml::crypto::XXMLSecurityContext> > >, CertificateChooserUserAction&}; _Tp = CertificateChooser; __gnu_cxx::_Lock_policy _Lp = __gnu_cxx::_S_atomic]’ at ~/gcc/inst/include/c++/16.0.1/bits/shared_ptr_base.h:1805:14,
> inlined from ‘std::shared_ptr<_Tp>::shared_ptr(std::_Sp_alloc_shared_tag<_Tp>, _Args&& ...) [with _Alloc = std::allocator<void>; _Args = {weld::Window*&, SfxViewShell*&, std::__debug::vector<com::sun::star::uno::Reference<com::sun::star::xml::crypto::XXMLSecurityContext>, std::allocator<com::sun::star::uno::Reference<com::sun::star::xml::crypto::XXMLSecurityContext> > >, CertificateChooserUserAction&}; _Tp = CertificateChooser]’ at ~/gcc/inst/include/c++/16.0.1/bits/shared_ptr.h:463:59,
> inlined from ‘std::shared_ptr<std::_NonArray<_Tp> > std::make_shared(_Args&& ...) [with _Tp = CertificateChooser; _Args = {weld::Window*&, SfxViewShell*&, __debug::vector<com::sun::star::uno::Reference<com::sun::star::xml::crypto::XXMLSecurityContext>, allocator<com::sun::star::uno::Reference<com::sun::star::xml::crypto::XXMLSecurityContext> > >, CertificateChooserUserAction&}]’ at ~/gcc/inst/include/c++/16.0.1/bits/shared_ptr.h:1066:39,
> inlined from ‘static std::shared_ptr<CertificateChooser> CertificateChooser::getInstance(weld::Window*, SfxViewShell*, std::__debug::vector<com::sun::star::uno::Reference<com::sun::star::xml::crypto::XXMLSecurityContext> >&&, CertificateChooserUserAction)’ at xmlsecurity/inc/certificatechooser.hxx:111:113,
> inlined from ‘com::sun::star::uno::Sequence<com::sun::star::uno::Reference<com::sun::star::security::XCertificate> > {anonymous}::DocumentDigitalSignatures::chooseCertificatesImpl.constprop(SfxViewShell*, std::__debug::map<rtl::OUString, rtl::OUString>&, CertificateChooserUserAction, com::sun::star::security::CertificateKind)’ at xmlsecurity/source/component/documentdigitalsignatures.cxx:664:171:
> ~/gcc/inst/include/c++/16.0.1/bits/new_allocator.h:151:73: note: object of size 384 allocated by ‘operator new’
> 151 | return static_cast<_Tp*>(_GLIBCXX_OPERATOR_NEW(__n * sizeof(_Tp)));
> | ^
> In destructor ‘std::_Sp_counted_ptr_inplace<_Tp, _Alloc, _Lp>::~_Sp_counted_ptr_inplace() [with _Tp = DigitalSignaturesDialog; _Alloc = std::allocator<void>; __gnu_cxx::_Lock_policy _Lp = __gnu_cxx::_S_atomic]’,
> inlined from ‘void std::_Sp_counted_ptr_inplace<_Tp, _Alloc, _Lp>::_M_destroy() [with _Tp = DigitalSignaturesDialog; _Alloc = std::allocator<void>; __gnu_cxx::_Lock_policy _Lp = __gnu_cxx::_S_atomic]’ at ~/gcc/inst/include/c++/16.0.1/bits/shared_ptr_base.h:684:32,
> inlined from ‘void std::_Sp_counted_base<_Lp>::_M_release() [with __gnu_cxx::_Lock_policy _Lp = __gnu_cxx::_S_atomic]’ at ~/gcc/inst/include/c++/16.0.1/bits/shared_ptr_base.h:424:18,
> inlined from ‘void std::_Sp_counted_base<_Lp>::_M_release() [with __gnu_cxx::_Lock_policy _Lp = __gnu_cxx::_S_atomic]’ at ~/gcc/inst/include/c++/16.0.1/bits/shared_ptr_base.h:392:5,
> inlined from ‘std::__shared_count<_Lp>::~__shared_count() [with __gnu_cxx::_Lock_policy _Lp = __gnu_cxx::_S_atomic]’ at ~/gcc/inst/include/c++/16.0.1/bits/shared_ptr_base.h:1129:21,
> inlined from ‘std::__shared_ptr<_Tp, _Lp>::~__shared_ptr() [with _Tp = CertificateChooser; __gnu_cxx::_Lock_policy _Lp = __gnu_cxx::_S_atomic]’ at ~/gcc/inst/include/c++/16.0.1/bits/shared_ptr_base.h:1603:7,
> inlined from ‘std::shared_ptr<CertificateChooser>::~shared_ptr()’ at ~/gcc/inst/include/c++/16.0.1/bits/shared_ptr.h:175:11,
> inlined from ‘com::sun::star::uno::Sequence<com::sun::star::uno::Reference<com::sun::star::security::XCertificate> > {anonymous}::DocumentDigitalSignatures::chooseCertificatesImpl.constprop(SfxViewShell*, std::__debug::map<rtl::OUString, rtl::OUString>&, CertificateChooserUserAction, com::sun::star::security::CertificateKind)’ at xmlsecurity/source/component/documentdigitalsignatures.cxx:674:1:
> ~/gcc/inst/include/c++/16.0.1/bits/shared_ptr_base.h:670:45: error: array subscript ‘std::_Sp_counted_ptr_inplace<DigitalSignaturesDialog, std::allocator<void>, __gnu_cxx::_S_atomic>[0]’ is partly outside array bounds of ‘unsigned char [384]’ [-Werror=array-bounds=]
> 670 | ~_Sp_counted_ptr_inplace() noexcept { }
> | ^
> In member function ‘_Tp* std::__new_allocator<_Tp>::allocate(size_type, const void*) [with _Tp = std::_Sp_counted_ptr_inplace<CertificateChooser, std::allocator<void>, __gnu_cxx::_S_atomic>]’,
> inlined from ‘constexpr _Tp* std::allocator< <template-parameter-1-1> >::allocate(std::size_t) [with _Tp = std::_Sp_counted_ptr_inplace<CertificateChooser, std::allocator<void>, __gnu_cxx::_S_atomic>]’ at ~/gcc/inst/include/c++/16.0.1/bits/allocator.h:203:40,
> inlined from ‘static constexpr _Tp* std::allocator_traits<std::allocator<_Up> >::allocate(allocator_type&, size_type) [with _Tp = std::_Sp_counted_ptr_inplace<CertificateChooser, std::allocator<void>, __gnu_cxx::_S_atomic>]’ at ~/gcc/inst/include/c++/16.0.1/bits/alloc_traits.h:614:28,
> inlined from ‘std::__allocated_ptr<_Alloc> std::__allocate_guarded(_Alloc&) [with _Alloc = allocator<_Sp_counted_ptr_inplace<CertificateChooser, allocator<void>, __gnu_cxx::_S_atomic> >]’ at ~/gcc/inst/include/c++/16.0.1/bits/allocated_ptr.h:103:69,
> inlined from ‘std::__shared_count<_Lp>::__shared_count(_Tp*&, std::_Sp_alloc_shared_tag<_Alloc>, _Args&& ...) [with _Tp = CertificateChooser; _Alloc = std::allocator<void>; _Args = {weld::Window*&, SfxViewShell*&, std::__debug::vector<com::sun::star::uno::Reference<com::sun::star::xml::crypto::XXMLSecurityContext>, std::allocator<com::sun::star::uno::Reference<com::sun::star::xml::crypto::XXMLSecurityContext> > >, CertificateChooserUserAction&}; __gnu_cxx::_Lock_policy _Lp = __gnu_cxx::_S_atomic]’ at ~/gcc/inst/include/c++/16.0.1/bits/shared_ptr_base.h:1027:9,
> inlined from ‘std::__shared_ptr<_Tp, _Lp>::__shared_ptr(std::_Sp_alloc_shared_tag<_Tp>, _Args&& ...) [with _Alloc = std::allocator<void>; _Args = {weld::Window*&, SfxViewShell*&, std::__debug::vector<com::sun::star::uno::Reference<com::sun::star::xml::crypto::XXMLSecurityContext>, std::allocator<com::sun::star::uno::Reference<com::sun::star::xml::crypto::XXMLSecurityContext> > >, CertificateChooserUserAction&}; _Tp = CertificateChooser; __gnu_cxx::_Lock_policy _Lp = __gnu_cxx::_S_atomic]’ at ~/gcc/inst/include/c++/16.0.1/bits/shared_ptr_base.h:1805:14,
> inlined from ‘std::shared_ptr<_Tp>::shared_ptr(std::_Sp_alloc_shared_tag<_Tp>, _Args&& ...) [with _Alloc = std::allocator<void>; _Args = {weld::Window*&, SfxViewShell*&, std::__debug::vector<com::sun::star::uno::Reference<com::sun::star::xml::crypto::XXMLSecurityContext>, std::allocator<com::sun::star::uno::Reference<com::sun::star::xml::crypto::XXMLSecurityContext> > >, CertificateChooserUserAction&}; _Tp = CertificateChooser]’ at ~/gcc/inst/include/c++/16.0.1/bits/shared_ptr.h:463:59,
> inlined from ‘std::shared_ptr<std::_NonArray<_Tp> > std::make_shared(_Args&& ...) [with _Tp = CertificateChooser; _Args = {weld::Window*&, SfxViewShell*&, __debug::vector<com::sun::star::uno::Reference<com::sun::star::xml::crypto::XXMLSecurityContext>, allocator<com::sun::star::uno::Reference<com::sun::star::xml::crypto::XXMLSecurityContext> > >, CertificateChooserUserAction&}]’ at ~/gcc/inst/include/c++/16.0.1/bits/shared_ptr.h:1066:39,
> inlined from ‘static std::shared_ptr<CertificateChooser> CertificateChooser::getInstance(weld::Window*, SfxViewShell*, std::__debug::vector<com::sun::star::uno::Reference<com::sun::star::xml::crypto::XXMLSecurityContext> >&&, CertificateChooserUserAction)’ at xmlsecurity/inc/certificatechooser.hxx:111:113,
> inlined from ‘com::sun::star::uno::Sequence<com::sun::star::uno::Reference<com::sun::star::security::XCertificate> > {anonymous}::DocumentDigitalSignatures::chooseCertificatesImpl.constprop(SfxViewShell*, std::__debug::map<rtl::OUString, rtl::OUString>&, CertificateChooserUserAction, com::sun::star::security::CertificateKind)’ at xmlsecurity/source/component/documentdigitalsignatures.cxx:664:171:
> ~/gcc/inst/include/c++/16.0.1/bits/new_allocator.h:151:73: note: object of size 384 allocated by ‘operator new’
> 151 | return static_cast<_Tp*>(_GLIBCXX_OPERATOR_NEW(__n * sizeof(_Tp)));
> | ^
Change-Id: I19ffa8f6d2b7a7c87fe3fbece2eb5e6dc147aa04
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/197838
Tested-by: Jenkins
Reviewed-by: Stephan Bergmann <stephan.bergmann@collabora.com>
Document Signing
Introduction
This code provides dialogs, and infrastructure wrapping libxmlsec and
gpgme that implements document signing.
For signing a document, a personal key pair is used, which consists of a private key and a public key, which is added to the document in addition to the digital signature of the document, when signing it.
The document signing can be done both for the source ODF/OOXML files and the exported PDF files. It is also possible to sign existing PDF files.
Module Contents
doc: OpenDocument workflow legacy information with some illustrations to have an idea of the workflow, for starters checkdoc/OpenDocumentSignatures-Workflow.odt.inc: Headers to a subset of source files inside the module, parts likesource/frameworkhave headers inside the folder.qa: Unit tests for signing and shell scripts for certificates creation for testing.test_docs: Documents & certificates used for testing.source: More on that below.uiconfig: User interface configuration for different dialogs, it is recommended to navigate from relevant source file to the .ui file linked in the class which will be underuiconfig/ui.util: UNO passive registration config for GPG/ NSS.
Source Primary Contents
component: Main implementation ofDocumentDigitalSignatureswhere the interaction with security environment and certificates occur.dialogs: Certificate & Signatures management dialogs.certificatechooser: Dialog that allows you to find and choose certificates or signatures for encryption.certificateviewer: More detailed information about each certificate.digitalsignaturesdialog: Main window for signatures of the documents and the start point of signing document.
framework: Various elements for verifying signatures and running security engine.gpg: The implementation of encrypting with GPG and security environment initialization.helper: Some helper classes that include signatures manager and the helpers for PDF signing, UriBinding, and XML signatures. It also include helper tools for XSecurityEnvironment.xmlsec: XML, NSS, MSCrypt encryption/ signing tools, more on the low-level side of actual implementation of algorithms.
PDF Testing
To test the signed PDFs, one can use the pdfverify in this way:
./bin/run pdfverify $PWD/xmlsecurity/qa/unit/pdfsigning/data/2good.pdf
The file parameter should be an absolute path.
This is the output of pdfverify for 2good.pdf:
verifying signatures
found 2 signatures
signature #0: digest match? 1
signature #0: partial? 0
signature #1: digest match? 1
signature #1: partial? 0