Kaydet (Commit) cae5f2a5 authored tarafından Thorsten Behrens's avatar Thorsten Behrens

gpg4libre: initial GPG signature generation

* takes XML-Sec signature template
* calculates digest for all added reference streams
* produces signature value over canonicalized signature template
* writes same as detached signature into template, streams that out

Change-Id: I303e080dc25c440175fe1ae897f03cf356d5d0f2
Reviewed-on: https://gerrit.libreoffice.org/36106Reviewed-by: 's avatarSiegmund Gorr <siegmund.gorr@cib.de>
Reviewed-by: 's avatarThorsten Behrens <Thorsten.Behrens@CIB.de>
Tested-by: 's avatarThorsten Behrens <Thorsten.Behrens@CIB.de>
üst 4c05834a
......@@ -109,6 +109,7 @@ $(eval $(call gb_Rdb_add_components,services,\
xmloff/util/xo \
xmlscript/util/xmlscript \
$(if $(ENABLE_NSS), \
xmlsecurity/util/xsec_gpg \
xmlsecurity/util/xmlsecurity \
xmlsecurity/util/xsec_xmlsec$(if $(filter WNT,$(OS)),.windows)) \
$(if $(ENABLE_COINMP), \
......
......@@ -9,13 +9,20 @@
$(eval $(call gb_Library_Library,xsec_gpg))
ifneq ($(OS),WNT)
$(eval $(call gb_Library_set_componentfile,xsec_gpg,xmlsecurity/util/xsec_gpg))
endif
$(eval $(call gb_Library_set_include,xsec_gpg,\
$$(INCLUDE) \
-I$(SRCDIR)/xmlsecurity/inc \
-I$(SRCDIR)/xmlsecurity/source/gpg \
))
-I$(call gb_UnpackedTarball_get_dir,xmlsec/include \
)))
$(eval $(call gb_Library_add_defs,xsec_gpg,\
-DXMLSEC_NO_XSLT \
-DXMLSEC_CRYPTO_NSS \
-DXSECGPG_DLLIMPLEMENTATION \
))
......@@ -27,7 +34,14 @@ $(eval $(call gb_Library_use_sdk_api,xsec_gpg))
$(eval $(call gb_Library_set_precompiled_header,xsec_gpg,$(SRCDIR)/xmlsecurity/inc/pch/precompiled_xsec_gpg))
$(eval $(call gb_Library_use_externals,xsec_gpg,gpgmepp))
$(eval $(call gb_Library_use_packages,xsec_gpg,\
xmlsec \
))
$(eval $(call gb_Library_use_externals,xsec_gpg,\
boost_headers \
libxml2 \
nss3 \
gpgmepp))
$(eval $(call gb_Library_use_libraries,xsec_gpg,\
comphelper \
......@@ -37,17 +51,27 @@ $(eval $(call gb_Library_use_libraries,xsec_gpg,\
svl \
tl \
xo \
xsec_xmlsec \
))
$(eval $(call gb_Library_add_defs,xsec_gpg,\
-DXMLSEC_CRYPTO_NSS \
))
$(eval $(call gb_Library_add_libs,xsec_gpg,\
$(call gb_UnpackedTarball_get_dir,xmlsec)/src/nss/.libs/libxmlsec1-nss.a \
$(call gb_UnpackedTarball_get_dir,xmlsec)/src/.libs/libxmlsec1.a \
))
$(eval $(call gb_Library_add_exception_objects,xsec_gpg,\
xmlsecurity/source/gpg/CertificateImpl \
xmlsecurity/source/gpg/CipherContext \
xmlsecurity/source/gpg/DigestContext \
xmlsecurity/source/gpg/GpgComponentFactory \
xmlsecurity/source/gpg/SecurityEnvironment \
xmlsecurity/source/gpg/SEInitializer \
xmlsecurity/source/gpg/XMLEncryption \
xmlsecurity/source/gpg/XMLSecurityContext \
xmlsecurity/source/gpg/XMLSignature \
xmlsecurity/source/gpg/xmlsignature_gpgimpl \
))
# vim: set noet sw=4 ts=4:
......@@ -27,12 +27,13 @@
#include <cppuhelper/implbase.hxx>
#include <libxml/tree.h>
#include <xsecxmlsecdllapi.h>
namespace com { namespace sun { namespace star { namespace uno {
class XComponentContext;
} } } }
class XMLElementWrapper_XmlSecImpl : public cppu::WeakImplHelper
class XSECXMLSEC_DLLPUBLIC XMLElementWrapper_XmlSecImpl : public cppu::WeakImplHelper
<
css::xml::wrapper::XXMLElementWrapper,
css::lang::XUnoTunnel,
......
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/*
* This file is part of the LibreOffice project.
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/
#include <sal/config.h>
#include <osl/mutex.hxx>
#include <osl/thread.h>
#include <cppuhelper/factory.hxx>
#include <com/sun/star/lang/XSingleServiceFactory.hpp>
#include "xmlsignature_gpgimpl.hxx"
using namespace ::cppu;
using namespace ::com::sun::star::uno;
using namespace ::com::sun::star::lang;
using namespace ::com::sun::star::registry;
extern "C"
{
void* SAL_CALL gpg_component_getFactory( const sal_Char* pImplName , void* pServiceManager , void* /*pRegistryKey*/ )
{
void* pRet = nullptr;
Reference< XSingleServiceFactory > xFactory ;
if( pImplName != nullptr && pServiceManager != nullptr )
{
if( XMLSignature_GpgImpl::impl_getImplementationName().equalsAscii( pImplName ) )
{
xFactory = XMLSignature_GpgImpl::impl_createFactory( static_cast< XMultiServiceFactory* >( pServiceManager ) ) ;
}
}
if( xFactory.is() ) {
xFactory->acquire() ;
pRet = xFactory.get() ;
}
return pRet ;
}
}
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/*
* This file is part of the LibreOffice project.
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/
#include "XMLSignature.hxx"
#include "SecurityEnvironment.hxx"
#include "XMLSecurityContext.hxx"
#include <cppuhelper/supportsservice.hxx>
using namespace css::uno;
using namespace css::lang;
using namespace css::xml::wrapper;
using namespace css::xml::crypto;
XMLSignatureGpg::XMLSignatureGpg()
{
}
XMLSignatureGpg::~XMLSignatureGpg()
{
}
/* XXMLSignature */
Reference< XXMLSignatureTemplate > SAL_CALL XMLSignatureGpg::generate(const Reference< XXMLSignatureTemplate >& /*aTemplate*/,
const Reference< XSecurityEnvironment >& /*aEnvironment*/)
{
return nullptr;
}
/* XXMLSignature */
Reference< XXMLSignatureTemplate > SAL_CALL XMLSignatureGpg::validate(const Reference< XXMLSignatureTemplate >& /*aTemplate*/,
const Reference< XXMLSecurityContext >& /*aSecurityCtx*/)
{
return nullptr;
}
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/*
* This file is part of the LibreOffice project.
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/
#ifndef INCLUDED_XMLSECURITY_SOURCE_XMLSEC_GPG_XMLSIGNATURE_HXX
#define INCLUDED_XMLSECURITY_SOURCE_XMLSEC_GPG_XMLSIGNATURE_HXX
#include <sal/config.h>
#include <rtl/ustring.hxx>
#include <cppuhelper/implbase.hxx>
#include <com/sun/star/uno/Exception.hpp>
#include <com/sun/star/uno/Reference.hxx>
#include <com/sun/star/xml/crypto/XXMLSignature.hpp>
#include <com/sun/star/xml/crypto/XXMLSignatureTemplate.hpp>
#include <com/sun/star/xml/crypto/XXMLSecurityContext.hpp>
#include <com/sun/star/xml/crypto/XMLSignatureException.hpp>
class XMLSignatureGpg : public cppu::WeakImplHelper< css::xml::crypto::XXMLSignature >
{
public:
explicit XMLSignatureGpg();
virtual ~XMLSignatureGpg() override;
// XXMLSignature
virtual css::uno::Reference< css::xml::crypto::XXMLSignatureTemplate > SAL_CALL generate(
const css::uno::Reference< css::xml::crypto::XXMLSignatureTemplate >& aTemplate ,
const css::uno::Reference< css::xml::crypto::XSecurityEnvironment >& aEnvironment
) override;
virtual css::uno::Reference< css::xml::crypto::XXMLSignatureTemplate > SAL_CALL validate(
const css::uno::Reference< css::xml::crypto::XXMLSignatureTemplate >& aTemplate ,
const css::uno::Reference< css::xml::crypto::XXMLSecurityContext >& aContext
) override;
};
#endif // INCLUDED_XMLSECURITY_SOURCE_XMLSEC_GPG_XMLSIGNATURE_HXX
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
This diff is collapsed.
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/*
* This file is part of the LibreOffice project.
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*
* This file incorporates work covered by the following license notice:
*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed
* with this work for additional information regarding copyright
* ownership. The ASF licenses this file to you under the Apache
* License, Version 2.0 (the "License"); you may not use this file
* except in compliance with the License. You may obtain a copy of
* the License at http://www.apache.org/licenses/LICENSE-2.0 .
*/
#ifndef INCLUDED_XMLSECURITY_SOURCE_GPG_XMLSIGNATURE_GPGIMPL_HXX
#define INCLUDED_XMLSECURITY_SOURCE_GPG_XMLSIGNATURE_GPGIMPL_HXX
#include <sal/config.h>
#include <rtl/ustring.hxx>
#include <xsecgpgdllapi.h>
#include <cppuhelper/factory.hxx>
#include <cppuhelper/implbase.hxx>
#include <com/sun/star/uno/Exception.hpp>
#include <com/sun/star/uno/Reference.hxx>
#include <com/sun/star/lang/XSingleServiceFactory.hpp>
#include <com/sun/star/lang/XServiceInfo.hpp>
#include <com/sun/star/xml/crypto/XXMLSignature.hpp>
#include <com/sun/star/xml/crypto/XXMLSignatureTemplate.hpp>
#include <com/sun/star/xml/crypto/XXMLSecurityContext.hpp>
// TODO: hack, remove dllpublic again...
class XSECGPG_DLLPUBLIC XMLSignature_GpgImpl : public ::cppu::WeakImplHelper<
css::xml::crypto::XXMLSignature ,
css::lang::XServiceInfo >
{
public:
explicit XMLSignature_GpgImpl();
virtual ~XMLSignature_GpgImpl() override ;
//Methods from XXMLSignature
virtual css::uno::Reference< css::xml::crypto::XXMLSignatureTemplate > SAL_CALL generate(
const css::uno::Reference< css::xml::crypto::XXMLSignatureTemplate >& aTemplate ,
const css::uno::Reference< css::xml::crypto::XSecurityEnvironment >& aEnvironment
) override ;
virtual css::uno::Reference< css::xml::crypto::XXMLSignatureTemplate > SAL_CALL validate(
const css::uno::Reference< css::xml::crypto::XXMLSignatureTemplate >& aTemplate ,
const css::uno::Reference< css::xml::crypto::XXMLSecurityContext >& aContext
) override;
//Methods from XServiceInfo
virtual OUString SAL_CALL getImplementationName() override ;
virtual sal_Bool SAL_CALL supportsService(
const OUString& ServiceName
) override ;
virtual css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames() override ;
//Helper for XServiceInfo
static css::uno::Sequence< OUString > impl_getSupportedServiceNames() ;
/// @throws css::uno::RuntimeException
static OUString impl_getImplementationName() ;
//Helper for registry
/// @throws css::uno::RuntimeException
static css::uno::Reference< css::uno::XInterface > SAL_CALL impl_createInstance( const css::uno::Reference< css::lang::XMultiServiceFactory >& aServiceManager ) ;
static css::uno::Reference< css::lang::XSingleServiceFactory > impl_createFactory( const css::uno::Reference< css::lang::XMultiServiceFactory >& aServiceManager ) ;
} ;
#endif // INCLUDED_XMLSECURITY_SOURCE_GPG_XMLSIGNATURE_GPGIMPL_HXX
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
......@@ -17,7 +17,7 @@
* the License at http://www.apache.org/licenses/LICENSE-2.0 .
*/
#include "errorcallback.hxx"
#include "xmlsec/errorcallback.hxx"
#include "xmlsec-wrapper.h"
......@@ -48,12 +48,12 @@ void errorCallback(const char* file,
SAL_WARN("xmlsecurity.xmlsec", file << ":" << line << ": " << func << "() '" << pErrorObject << "' '" << pErrorSubject << "' " << reason << " '" << pMsg << "'" << systemErrorString);
}
void setErrorRecorder()
SAL_DLLPUBLIC_EXPORT void setErrorRecorder()
{
xmlSecErrorsSetCallback(errorCallback);
}
void clearErrorRecorder()
SAL_DLLPUBLIC_EXPORT void clearErrorRecorder()
{
xmlSecErrorsSetCallback(nullptr);
}
......
......@@ -24,11 +24,10 @@
#include "xmlencryption_nssimpl.hxx"
#include "xmlsec/xmldocumentwrapper_xmlsecimpl.hxx"
#include "xmlelementwrapper_xmlsecimpl.hxx"
#include "xmlsec/xmlelementwrapper_xmlsecimpl.hxx"
#include "xmlsec/errorcallback.hxx"
#include "securityenvironment_nssimpl.hxx"
#include "errorcallback.hxx"
#include "xmlsec-wrapper.h"
......
......@@ -22,7 +22,7 @@
#include "securityenvironment_nssimpl.hxx"
#include "xmlsecuritycontext_nssimpl.hxx"
#include "xmlstreamio.hxx"
#include "xmlsec/xmlstreamio.hxx"
#include "xmlsec-wrapper.h"
......
......@@ -22,14 +22,13 @@
#include "xmlsignature_nssimpl.hxx"
#include "xmlsec/xmldocumentwrapper_xmlsecimpl.hxx"
#include "xmlelementwrapper_xmlsecimpl.hxx"
#include "xmlsec/xmlelementwrapper_xmlsecimpl.hxx"
#include "xmlsec/xmlstreamio.hxx"
#include "xmlsec/errorcallback.hxx"
#include "securityenvironment_nssimpl.hxx"
#include "xmlsecuritycontext_nssimpl.hxx"
#include "xmlstreamio.hxx"
#include "errorcallback.hxx"
#include "xmlsec-wrapper.h"
......
......@@ -34,7 +34,9 @@
#include <com/sun/star/xml/crypto/XXMLSignatureTemplate.hpp>
#include <com/sun/star/xml/crypto/XXMLSecurityContext.hpp>
class XMLSignature_NssImpl : public ::cppu::WeakImplHelper<
#include "xsecxmlsecdllapi.h"
class XSECXMLSEC_DLLPUBLIC XMLSignature_NssImpl : public ::cppu::WeakImplHelper<
css::xml::crypto::XXMLSignature ,
css::lang::XServiceInfo >
{
......
......@@ -23,9 +23,9 @@
#include <com/sun/star/uno/XComponentContext.hpp>
#include <cppuhelper/supportsservice.hxx>
#include "xmlsec/xmldocumentwrapper_xmlsecimpl.hxx"
#include "xmlsec/xmlelementwrapper_xmlsecimpl.hxx"
#include <xmloff/attrlist.hxx>
#include "xmlelementwrapper_xmlsecimpl.hxx"
#include <stdlib.h>
#include <string.h>
......
......@@ -19,7 +19,7 @@
#include <string.h>
#include "xmlelementwrapper_xmlsecimpl.hxx"
#include "xmlsec/xmlelementwrapper_xmlsecimpl.hxx"
#include <com/sun/star/uno/XComponentContext.hpp>
#include <cppuhelper/supportsservice.hxx>
#include <cppuhelper/typeprovider.hxx>
......
......@@ -21,7 +21,7 @@
/*
* Implementation of the I/O interfaces based on stream and URI binding
*/
#include "xmlstreamio.hxx"
#include "xmlsec/xmlstreamio.hxx"
#include <rtl/ustring.hxx>
#include <rtl/uri.hxx>
......@@ -180,7 +180,7 @@ int xmlEnableStreamInputCallbacks()
return 0 ;
}
int xmlRegisterStreamInputCallbacks(
SAL_DLLPUBLIC_EXPORT int xmlRegisterStreamInputCallbacks(
css::uno::Reference< css::xml::crypto::XUriBinding >& aUriBinding
) {
if( !( enableXmlStreamIO & XMLSTREAMIO_INITIALIZED ) ) {
......@@ -197,7 +197,7 @@ int xmlRegisterStreamInputCallbacks(
return 0 ;
}
int xmlUnregisterStreamInputCallbacks()
SAL_DLLPUBLIC_EXPORT int xmlUnregisterStreamInputCallbacks()
{
if( ( enableXmlStreamIO & XMLSTREAMIO_REGISTERED ) ) {
//Clear the uri-stream binding
......
......@@ -23,7 +23,7 @@
#include <cppuhelper/factory.hxx>
#include "serialnumberadapter.hxx"
#include "xmlelementwrapper_xmlsecimpl.hxx"
#include "xmlsec/xmlelementwrapper_xmlsecimpl.hxx"
#include "xmlsec/xmldocumentwrapper_xmlsecimpl.hxx"
#include "xsec_xmlsec.hxx"
......
<?xml version="1.0" encoding="UTF-8"?>
<!--
* This file is part of the LibreOffice project.
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*
* This file incorporates work covered by the following license notice:
*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed
* with this work for additional information regarding copyright
* ownership. The ASF licenses this file to you under the Apache
* License, Version 2.0 (the "License"); you may not use this file
* except in compliance with the License. You may obtain a copy of
* the License at http://www.apache.org/licenses/LICENSE-2.0 .
-->
<component loader="com.sun.star.loader.SharedLibrary" environment="@CPPU_ENV@"
prefix="xsec_gpg" xmlns="http://openoffice.org/2010/uno-components">
<implementation name="com.sun.star.xml.security.bridge.xmlsec.XMLSignature_GpgImpl">
<service name="com.sun.star.xml.crypto.XMLSignature"/>
</implementation>
</component>
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment