/* -*- 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 .
*/
class XSecController final : public cppu::WeakImplHelper
<
css::xml::crypto::sax::XSAXEventKeeperStatusChangeListener,
css::xml::crypto::sax::XSignatureCreationResultListener,
css::xml::crypto::sax::XSignatureVerifyResultListener
> /****** XSecController.hxx/CLASS XSecController ******************************* * * NAME * XSecController -- the xml security framework controller * * FUNCTION * Controls the whole xml security framework to create signatures or to * verify signatures. *
******************************************************************************/
{ friendclass XSecParser; friendclass OOXMLSecParser;
/* * used to buffer SAX events
*/
rtl::Reference<XMLDocumentWrapper_XmlSecImpl> m_xXMLDocumentWrapper;
/* * the SAX events keeper
*/
rtl::Reference<SAXEventKeeperImpl> m_xSAXEventKeeper;
/* * the bridge component which creates/verifies signature
*/
css::uno::Reference< css::xml::crypto::XXMLSignature > m_xXMLSignature;
/* * the Security Context
*/
css::uno::Reference< css::xml::crypto::XXMLSecurityContext > m_xSecurityContext;
/* * the security id incrementer, in order to make any security id unique * to the SAXEventKeeper. * Because each XSecController has its own SAXEventKeeper, so this variable * is not necessary to be static.
*/
sal_Int32 m_nNextSecurityId;
/* * Signature information
*/
std::vector< InternalSignatureInformation > m_vInternalSignatureInformations;
/* * the previous node on the SAX chain. * The reason that use a Reference<XInterface> type variable * is that the previous components are different when exporting * and importing, and there is no other common interface they * can provided.
*/
css::uno::Reference< css::uno::XInterface > m_xPreviousNodeOnSAXChain; /* * whether the previous node can provide an XInitialize interface, * use this variable in order to typecast the XInterface to the * correct interface type.
*/ bool m_bIsPreviousNodeInitializable;
/* * a flag representing whether the SAXEventKeeper is now on the * SAX chain.
*/ bool m_bIsSAXEventKeeperConnected;
/* * a flag representing whether it is collecting some element, * which means that the SAXEventKeeper can't be chained off the * SAX chain.
*/ bool m_bIsCollectingElement;
/* * a flag representing whether the SAX event stream is blocking, * which also means that the SAXEventKeeper can't be chained off * the SAX chain.
*/ bool m_bIsBlocking;
/* * a flag representing the current status of security related * components.
*/
/* * status of security related components
*/ enumclass InitializationState { UNINITIALIZED, INITIALIZED, FAILTOINITIALIZED } m_eStatusOfSecurityComponents;
/* * a flag representing whether the SAXEventKeeper need to be * on the SAX chain all the time. * This flag is used to the situation when creating signature.
*/ bool m_bIsSAXEventKeeperSticky;
/* * the XSecParser which is used to parse the signature stream
*/
css::uno::Reference<css::xml::sax::XDocumentHandler> m_xSecParser;
/* * the caller assigned signature id for the next signature in the * signature stream
*/
sal_Int32 m_nReservedSignatureId;
/* * representing whether to verify the current signature
*/ bool m_bVerifyCurrentSignature;
/* * An xUriBinding is provided to map Uris to XInputStream interfaces.
*/
rtl::Reference<UriBindingHelper> m_xUriBinding;
SignatureInformation getSignatureInformation( sal_Int32 nSecurityId ) const;
SignatureInformations getSignatureInformations() const; /// only verify can figure out which X509Data is the signing certificate void UpdateSignatureInformation(sal_Int32 nSecurityId,
std::vector<SignatureInformation::X509Data> && rDatas);
It is absolutely necessary that the parameter ouX509IssuerName is set. It contains the base64 encoded certificate, which is DER encoded. The XMLSec needs it to find the private key. Although issuer name and certificate should be sufficient to identify the certificate the implementation in XMLSec is broken, both for Windows and mozilla. The reason is that they use functions to find the certificate which take as parameter the DER encoded ASN.1 issuer name. The issuer name is a DName, where most attributes are of type DirectoryName, which is a choice of 5 string types. This information is not contained in the issuer string and while it is converted to the ASN.1 name the conversion function must assume a particular type, which is often wrong. For example, the Windows function CertStrToName will use a T.61 string if the string does not contain special characters. So if the certificate uses simple characters but encodes the issuer attributes in Utf8, then CertStrToName will use T.61. The resulting DER encoded ASN.1 name now contains different bytes which indicate the string type. The functions for finding the certificate apparently use memcmp - hence they fail to find the certificate.
*/ void setX509Certificate(
sal_Int32 nSecurityId, const OUString& ouX509IssuerName, const OUString& ouX509SerialNumber, const OUString& ouX509Cert, const OUString& ouX509CertDigest,
svl::crypto::SignatureMethodAlgorithm eAlgorithmID);
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.