LCOV - code coverage report
Current view: top level - package/source/manifest - ManifestExport.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 125 228 54.8 %
Date: 2012-08-25 Functions: 1 1 100.0 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 148 466 31.8 %

           Branch data     Line data    Source code
       1                 :            : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
       2                 :            : /*
       3                 :            :  * This file is part of the LibreOffice project.
       4                 :            :  *
       5                 :            :  * This Source Code Form is subject to the terms of the Mozilla Public
       6                 :            :  * License, v. 2.0. If a copy of the MPL was not distributed with this
       7                 :            :  * file, You can obtain one at http://mozilla.org/MPL/2.0/.
       8                 :            :  *
       9                 :            :  * This file incorporates work covered by the following license notice:
      10                 :            :  *
      11                 :            :  *   Licensed to the Apache Software Foundation (ASF) under one or more
      12                 :            :  *   contributor license agreements. See the NOTICE file distributed
      13                 :            :  *   with this work for additional information regarding copyright
      14                 :            :  *   ownership. The ASF licenses this file to you under the Apache
      15                 :            :  *   License, Version 2.0 (the "License"); you may not use this file
      16                 :            :  *   except in compliance with the License. You may obtain a copy of
      17                 :            :  *   the License at http://www.apache.org/licenses/LICENSE-2.0 .
      18                 :            :  */
      19                 :            : 
      20                 :            : 
      21                 :            : #include <com/sun/star/xml/sax/XExtendedDocumentHandler.hpp>
      22                 :            : #include <com/sun/star/xml/sax/XDocumentHandler.hpp>
      23                 :            : #include <com/sun/star/xml/sax/XAttributeList.hpp>
      24                 :            : #include <com/sun/star/xml/crypto/DigestID.hpp>
      25                 :            : #include <com/sun/star/xml/crypto/CipherID.hpp>
      26                 :            : #include <com/sun/star/beans/PropertyValue.hpp>
      27                 :            : #include <com/sun/star/uno/RuntimeException.hpp>
      28                 :            : 
      29                 :            : #include <ManifestDefines.hxx>
      30                 :            : #include <ManifestExport.hxx>
      31                 :            : #include <sax/tools/converter.hxx>
      32                 :            : 
      33                 :            : #include <rtl/ustrbuf.hxx>
      34                 :            : #include <comphelper/documentconstants.hxx>
      35                 :            : #include <comphelper/attributelist.hxx>
      36                 :            : 
      37                 :            : using namespace ::com::sun::star;
      38                 :            : 
      39                 :            : using ::rtl::OUString;
      40                 :            : using ::rtl::OUStringBuffer;
      41                 :            : 
      42                 :        281 : ManifestExport::ManifestExport( uno::Reference< xml::sax::XDocumentHandler > xHandler,  const uno::Sequence< uno::Sequence < beans::PropertyValue > >& rManList )
      43                 :            : {
      44         [ +  - ]:        281 :     const ::rtl::OUString sFileEntryElement     ( RTL_CONSTASCII_USTRINGPARAM ( ELEMENT_FILE_ENTRY ) );
      45         [ +  - ]:        281 :     const ::rtl::OUString sManifestElement      ( RTL_CONSTASCII_USTRINGPARAM ( ELEMENT_MANIFEST ) );
      46         [ +  - ]:        281 :     const ::rtl::OUString sEncryptionDataElement( RTL_CONSTASCII_USTRINGPARAM ( ELEMENT_ENCRYPTION_DATA ) );
      47         [ +  - ]:        281 :     const ::rtl::OUString sAlgorithmElement     ( RTL_CONSTASCII_USTRINGPARAM ( ELEMENT_ALGORITHM ) );
      48         [ +  - ]:        281 :     const ::rtl::OUString sStartKeyGenerationElement ( RTL_CONSTASCII_USTRINGPARAM ( ELEMENT_START_KEY_GENERATION ) );
      49         [ +  - ]:        281 :     const ::rtl::OUString sKeyDerivationElement ( RTL_CONSTASCII_USTRINGPARAM ( ELEMENT_KEY_DERIVATION ) );
      50                 :            : 
      51         [ +  - ]:        281 :     const ::rtl::OUString sCdataAttribute       ( RTL_CONSTASCII_USTRINGPARAM ( ATTRIBUTE_CDATA ) );
      52         [ +  - ]:        281 :     const ::rtl::OUString sMediaTypeAttribute   ( RTL_CONSTASCII_USTRINGPARAM ( ATTRIBUTE_MEDIA_TYPE ) );
      53         [ +  - ]:        281 :     const ::rtl::OUString sVersionAttribute     ( RTL_CONSTASCII_USTRINGPARAM ( ATTRIBUTE_VERSION ) );
      54         [ +  - ]:        281 :     const ::rtl::OUString sFullPathAttribute    ( RTL_CONSTASCII_USTRINGPARAM ( ATTRIBUTE_FULL_PATH ) );
      55         [ +  - ]:        281 :     const ::rtl::OUString sSizeAttribute        ( RTL_CONSTASCII_USTRINGPARAM ( ATTRIBUTE_SIZE ) );
      56         [ +  - ]:        281 :     const ::rtl::OUString sKeySizeAttribute     ( RTL_CONSTASCII_USTRINGPARAM ( ATTRIBUTE_KEY_SIZE ) );
      57         [ +  - ]:        281 :     const ::rtl::OUString sSaltAttribute        ( RTL_CONSTASCII_USTRINGPARAM ( ATTRIBUTE_SALT ) );
      58         [ +  - ]:        281 :     const ::rtl::OUString sInitialisationVectorAttribute ( RTL_CONSTASCII_USTRINGPARAM ( ATTRIBUTE_INITIALISATION_VECTOR ) );
      59         [ +  - ]:        281 :     const ::rtl::OUString sIterationCountAttribute  ( RTL_CONSTASCII_USTRINGPARAM ( ATTRIBUTE_ITERATION_COUNT ) );
      60         [ +  - ]:        281 :     const ::rtl::OUString sAlgorithmNameAttribute   ( RTL_CONSTASCII_USTRINGPARAM ( ATTRIBUTE_ALGORITHM_NAME ) );
      61         [ +  - ]:        281 :     const ::rtl::OUString sStartKeyGenerationNameAttribute ( RTL_CONSTASCII_USTRINGPARAM ( ATTRIBUTE_START_KEY_GENERATION_NAME ) );
      62         [ +  - ]:        281 :     const ::rtl::OUString sKeyDerivationNameAttribute   ( RTL_CONSTASCII_USTRINGPARAM ( ATTRIBUTE_KEY_DERIVATION_NAME ) );
      63         [ +  - ]:        281 :     const ::rtl::OUString sChecksumTypeAttribute    ( RTL_CONSTASCII_USTRINGPARAM ( ATTRIBUTE_CHECKSUM_TYPE ) );
      64         [ +  - ]:        281 :     const ::rtl::OUString sChecksumAttribute    ( RTL_CONSTASCII_USTRINGPARAM ( ATTRIBUTE_CHECKSUM) );
      65                 :            : 
      66         [ +  - ]:        281 :     const ::rtl::OUString sFullPathProperty     ( RTL_CONSTASCII_USTRINGPARAM ( "FullPath" ) );
      67         [ +  - ]:        281 :     const ::rtl::OUString sVersionProperty  ( RTL_CONSTASCII_USTRINGPARAM ( "Version" ) );
      68         [ +  - ]:        281 :     const ::rtl::OUString sMediaTypeProperty    ( RTL_CONSTASCII_USTRINGPARAM ( "MediaType" ) );
      69         [ +  - ]:        281 :     const ::rtl::OUString sIterationCountProperty   ( RTL_CONSTASCII_USTRINGPARAM ( "IterationCount" ) );
      70         [ +  - ]:        281 :     const ::rtl::OUString  sDerivedKeySizeProperty  ( RTL_CONSTASCII_USTRINGPARAM ( "DerivedKeySize" ) );
      71         [ +  - ]:        281 :     const ::rtl::OUString sSaltProperty         ( RTL_CONSTASCII_USTRINGPARAM ( "Salt" ) );
      72         [ +  - ]:        281 :     const ::rtl::OUString sInitialisationVectorProperty( RTL_CONSTASCII_USTRINGPARAM ( "InitialisationVector" ) );
      73         [ +  - ]:        281 :     const ::rtl::OUString sSizeProperty         ( RTL_CONSTASCII_USTRINGPARAM ( "Size" ) );
      74         [ +  - ]:        281 :     const ::rtl::OUString sDigestProperty       ( RTL_CONSTASCII_USTRINGPARAM ( "Digest" ) );
      75         [ +  - ]:        281 :     const ::rtl::OUString sEncryptionAlgProperty    ( RTL_CONSTASCII_USTRINGPARAM ( "EncryptionAlgorithm" ) );
      76         [ +  - ]:        281 :     const ::rtl::OUString sStartKeyAlgProperty  ( RTL_CONSTASCII_USTRINGPARAM ( "StartKeyAlgorithm" ) );
      77         [ +  - ]:        281 :     const ::rtl::OUString sDigestAlgProperty    ( RTL_CONSTASCII_USTRINGPARAM ( "DigestAlgorithm" ) );
      78                 :            : 
      79         [ +  - ]:        281 :     const ::rtl::OUString sWhiteSpace           ( RTL_CONSTASCII_USTRINGPARAM ( " " ) );
      80                 :            : 
      81         [ +  - ]:        281 :     const ::rtl::OUString sSHA256_URL           ( RTL_CONSTASCII_USTRINGPARAM ( SHA256_URL ) );
      82         [ +  - ]:        281 :     const ::rtl::OUString  sSHA1_Name           ( RTL_CONSTASCII_USTRINGPARAM ( SHA1_NAME ) );
      83                 :            : 
      84         [ +  - ]:        281 :     const ::rtl::OUString  sSHA1_1k_Name        ( RTL_CONSTASCII_USTRINGPARAM ( SHA1_1K_NAME ) );
      85         [ +  - ]:        281 :     const ::rtl::OUString  sSHA256_1k_URL       ( RTL_CONSTASCII_USTRINGPARAM ( SHA256_1K_URL ) );
      86                 :            : 
      87         [ +  - ]:        281 :     const ::rtl::OUString  sBlowfish_Name       ( RTL_CONSTASCII_USTRINGPARAM ( BLOWFISH_NAME ) );
      88         [ +  - ]:        281 :     const ::rtl::OUString  sAES256_URL          ( RTL_CONSTASCII_USTRINGPARAM ( AES256_URL ) );
      89                 :            : 
      90         [ +  - ]:        281 :     const ::rtl::OUString  sPBKDF2_Name         ( RTL_CONSTASCII_USTRINGPARAM ( PBKDF2_NAME ) );
      91                 :            : 
      92         [ +  - ]:        281 :     ::comphelper::AttributeList * pRootAttrList = new ::comphelper::AttributeList;
      93                 :        281 :     const uno::Sequence < beans::PropertyValue > *pSequence = rManList.getConstArray();
      94                 :        281 :     const sal_uInt32 nManLength = rManList.getLength();
      95                 :            : 
      96                 :            :     // find the mediatype of the document if any
      97                 :        281 :     ::rtl::OUString aDocMediaType;
      98                 :        281 :     ::rtl::OUString aDocVersion;
      99         [ +  - ]:        562 :     for (sal_uInt32 nInd = 0; nInd < nManLength ; nInd++ )
     100                 :            :     {
     101                 :        281 :         ::rtl::OUString aMediaType;
     102                 :        281 :         ::rtl::OUString aPath;
     103                 :        281 :         ::rtl::OUString aVersion;
     104                 :            : 
     105                 :        281 :         const beans::PropertyValue *pValue = pSequence[nInd].getConstArray();
     106         [ +  + ]:       1075 :         for (sal_uInt32 j = 0, nNum = pSequence[nInd].getLength(); j < nNum; j++, pValue++)
     107                 :            :         {
     108         [ +  + ]:        843 :             if (pValue->Name.equals (sMediaTypeProperty) )
     109                 :            :             {
     110                 :        281 :                 pValue->Value >>= aMediaType;
     111                 :            :             }
     112         [ +  + ]:        562 :             else if (pValue->Name.equals (sFullPathProperty) )
     113                 :            :             {
     114                 :        281 :                 pValue->Value >>= aPath;
     115                 :            :             }
     116         [ +  - ]:        281 :             else if (pValue->Name.equals (sVersionProperty) )
     117                 :            :             {
     118                 :        281 :                 pValue->Value >>= aVersion;
     119                 :            :             }
     120                 :            : 
     121 [ +  - ][ +  + ]:        843 :             if ( !aPath.isEmpty() && !aMediaType.isEmpty() && !aVersion.isEmpty() )
         [ +  + ][ +  + ]
     122                 :         49 :                 break;
     123                 :            :         }
     124                 :            : 
     125         [ +  - ]:        281 :         if ( aPath == "/" )
     126                 :            :         {
     127                 :        281 :             aDocMediaType = aMediaType;
     128                 :        281 :             aDocVersion = aVersion;
     129                 :            :             break;
     130                 :            :         }
     131 [ +  - ][ +  - ]:        281 :     }
                 [ -  + ]
     132                 :            : 
     133                 :        281 :     sal_Bool bProvideDTD = sal_False;
     134                 :        281 :     sal_Bool bAcceptNonemptyVersion = sal_False;
     135                 :        281 :     sal_Bool bStoreStartKeyGeneration = sal_False;
     136         [ +  + ]:        281 :     if ( !aDocMediaType.isEmpty() )
     137                 :            :     {
     138   [ +  +  +  -  :       1723 :         if ( aDocMediaType == MIMETYPE_OASIS_OPENDOCUMENT_TEXT_ASCII
          +  -  +  +  +  
          +  +  +  +  -  
          +  +  +  -  +  
          +  +  -  +  -  
          +  -  +  -  -  
              + ][ +  + ]
     139                 :        208 :           || aDocMediaType == MIMETYPE_OASIS_OPENDOCUMENT_TEXT_WEB_ASCII
     140                 :        208 :           || aDocMediaType == MIMETYPE_OASIS_OPENDOCUMENT_TEXT_GLOBAL_ASCII
     141                 :        208 :           || aDocMediaType == MIMETYPE_OASIS_OPENDOCUMENT_DRAWING_ASCII
     142                 :        206 :           || aDocMediaType == MIMETYPE_OASIS_OPENDOCUMENT_PRESENTATION_ASCII
     143                 :        204 :           || aDocMediaType == MIMETYPE_OASIS_OPENDOCUMENT_SPREADSHEET_ASCII
     144                 :        189 :           || aDocMediaType == MIMETYPE_OASIS_OPENDOCUMENT_CHART_ASCII
     145                 :        189 :           || aDocMediaType == MIMETYPE_OASIS_OPENDOCUMENT_DATABASE_ASCII
     146                 :         15 :           || aDocMediaType == MIMETYPE_OASIS_OPENDOCUMENT_FORMULA_ASCII
     147                 :         15 :           || aDocMediaType == MIMETYPE_OASIS_OPENDOCUMENT_TEXT_TEMPLATE_ASCII
     148                 :         10 :           || aDocMediaType == MIMETYPE_OASIS_OPENDOCUMENT_DRAWING_TEMPLATE_ASCII
     149                 :         10 :           || aDocMediaType == MIMETYPE_OASIS_OPENDOCUMENT_PRESENTATION_TEMPLATE_ASCII
     150                 :         10 :           || aDocMediaType == MIMETYPE_OASIS_OPENDOCUMENT_SPREADSHEET_TEMPLATE_ASCII
     151                 :         10 :           || aDocMediaType == MIMETYPE_OASIS_OPENDOCUMENT_CHART_TEMPLATE_ASCII
     152                 :         10 :           || aDocMediaType == MIMETYPE_OASIS_OPENDOCUMENT_FORMULA_TEMPLATE_ASCII )
     153                 :            : 
     154                 :            :         {
     155                 :            :             // oasis format
     156                 :            :             pRootAttrList->AddAttribute ( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM ( ATTRIBUTE_XMLNS ) ),
     157                 :            :                                         sCdataAttribute,
     158 [ +  - ][ +  - ]:        221 :                                         ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM ( MANIFEST_OASIS_NAMESPACE ) ) );
                 [ +  - ]
     159                 :        221 :             bAcceptNonemptyVersion = sal_True;
     160 [ +  + ][ +  - ]:        221 :             if ( aDocVersion.compareTo( ODFVER_012_TEXT ) >= 0 )
     161                 :            :             {
     162                 :            :                 // this is ODF12 generation, let encrypted streams contain start-key-generation entry
     163                 :         39 :                 bStoreStartKeyGeneration = sal_True;
     164         [ +  - ]:         39 :                 pRootAttrList->AddAttribute ( sVersionAttribute, sCdataAttribute, aDocVersion );
     165                 :            :             }
     166                 :            :         }
     167                 :            :         else
     168                 :            :         {
     169                 :            :             // even if it is no SO6 format the namespace must be specified
     170                 :            :             // thus SO6 format is used as default one
     171                 :            :             pRootAttrList->AddAttribute ( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM ( ATTRIBUTE_XMLNS ) ),
     172                 :            :                                         sCdataAttribute,
     173 [ +  - ][ +  - ]:         10 :                                         ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM ( MANIFEST_NAMESPACE ) ) );
                 [ +  - ]
     174                 :            : 
     175                 :         10 :             bProvideDTD = sal_True;
     176                 :            :         }
     177                 :            :     }
     178                 :            : 
     179 [ +  - ][ +  - ]:        281 :     uno::Reference < xml::sax::XAttributeList > xRootAttrList (pRootAttrList);
     180                 :            : 
     181 [ +  - ][ +  - ]:        281 :     xHandler->startDocument();
     182         [ +  - ]:        281 :     uno::Reference < xml::sax::XExtendedDocumentHandler > xExtHandler ( xHandler, uno::UNO_QUERY );
     183 [ +  - ][ +  + ]:        281 :     if ( xExtHandler.is() && bProvideDTD )
                 [ +  + ]
     184                 :            :     {
     185         [ +  - ]:         10 :         ::rtl::OUString aDocType ( RTL_CONSTASCII_USTRINGPARAM ( MANIFEST_DOCTYPE ) );
     186 [ +  - ][ +  - ]:         10 :         xExtHandler->unknown ( aDocType );
     187 [ +  - ][ +  - ]:         10 :         xHandler->ignorableWhitespace ( sWhiteSpace );
     188                 :            :     }
     189 [ +  - ][ +  - ]:        281 :     xHandler->startElement( sManifestElement, xRootAttrList );
     190                 :            : 
     191         [ +  + ]:       1357 :     for (sal_uInt32 i = 0 ; i < nManLength ; i++)
     192                 :            :     {
     193         [ +  - ]:       1076 :         ::comphelper::AttributeList *pAttrList = new ::comphelper::AttributeList;
     194                 :       1076 :         const beans::PropertyValue *pValue = pSequence[i].getConstArray();
     195                 :       1076 :         ::rtl::OUString aString;
     196                 :       1076 :         const uno::Any *pVector = NULL, *pSalt = NULL, *pIterationCount = NULL, *pDigest = NULL, *pDigestAlg = NULL, *pEncryptAlg = NULL, *pStartKeyAlg = NULL, *pDerivedKeySize = NULL;
     197         [ +  + ]:       4304 :         for (sal_uInt32 j = 0, nNum = pSequence[i].getLength(); j < nNum; j++, pValue++)
     198                 :            :         {
     199         [ +  + ]:       3228 :             if (pValue->Name.equals (sMediaTypeProperty) )
     200                 :            :             {
     201                 :       1076 :                 pValue->Value >>= aString;
     202         [ +  - ]:       1076 :                 pAttrList->AddAttribute ( sMediaTypeAttribute, sCdataAttribute, aString );
     203                 :            :             }
     204         [ +  + ]:       2152 :             else if (pValue->Name.equals (sVersionProperty) )
     205                 :            :             {
     206                 :       1076 :                 pValue->Value >>= aString;
     207                 :            :                 // the version is stored only if it is not empty
     208 [ +  + ][ +  + ]:       1076 :                 if ( bAcceptNonemptyVersion && !aString.isEmpty() )
                 [ +  + ]
     209         [ +  - ]:         39 :                     pAttrList->AddAttribute ( sVersionAttribute, sCdataAttribute, aString );
     210                 :            :             }
     211         [ +  - ]:       1076 :             else if (pValue->Name.equals (sFullPathProperty) )
     212                 :            :             {
     213                 :       1076 :                 pValue->Value >>= aString;
     214         [ +  - ]:       1076 :                 pAttrList->AddAttribute ( sFullPathAttribute, sCdataAttribute, aString );
     215                 :            :             }
     216         [ #  # ]:          0 :             else if (pValue->Name.equals (sSizeProperty) )
     217                 :            :             {
     218                 :          0 :                 sal_Int32 nSize = 0;
     219                 :          0 :                 pValue->Value >>= nSize;
     220                 :          0 :                 ::rtl::OUStringBuffer aBuffer;
     221         [ #  # ]:          0 :                 aBuffer.append ( nSize );
     222 [ #  # ][ #  # ]:          0 :                 pAttrList->AddAttribute ( sSizeAttribute, sCdataAttribute, aBuffer.makeStringAndClear() );
     223                 :            :             }
     224         [ #  # ]:          0 :             else if (pValue->Name.equals (sInitialisationVectorProperty) )
     225                 :          0 :                 pVector = &pValue->Value;
     226         [ #  # ]:          0 :             else if (pValue->Name.equals (sSaltProperty) )
     227                 :          0 :                 pSalt = &pValue->Value;
     228         [ #  # ]:          0 :             else if (pValue->Name.equals (sIterationCountProperty) )
     229                 :          0 :                 pIterationCount = &pValue->Value;
     230         [ #  # ]:          0 :             else if (pValue->Name.equals ( sDigestProperty ) )
     231                 :          0 :                 pDigest = &pValue->Value;
     232         [ #  # ]:          0 :             else if (pValue->Name.equals ( sDigestAlgProperty ) )
     233                 :          0 :                 pDigestAlg = &pValue->Value;
     234         [ #  # ]:          0 :             else if (pValue->Name.equals ( sEncryptionAlgProperty ) )
     235                 :          0 :                 pEncryptAlg = &pValue->Value;
     236         [ #  # ]:          0 :             else if (pValue->Name.equals ( sStartKeyAlgProperty ) )
     237                 :          0 :                 pStartKeyAlg = &pValue->Value;
     238         [ #  # ]:          0 :             else if (pValue->Name.equals ( sDerivedKeySizeProperty ) )
     239                 :          0 :                 pDerivedKeySize = &pValue->Value;
     240                 :            :         }
     241                 :            : 
     242 [ +  - ][ +  - ]:       1076 :         xHandler->ignorableWhitespace ( sWhiteSpace );
     243 [ +  - ][ +  - ]:       1076 :         uno::Reference < xml::sax::XAttributeList > xAttrList ( pAttrList );
     244 [ +  - ][ +  - ]:       1076 :         xHandler->startElement( sFileEntryElement , xAttrList);
     245 [ -  + ][ #  # ]:       1076 :         if ( pVector && pSalt && pIterationCount && pDigest && pDigestAlg && pEncryptAlg && pStartKeyAlg && pDerivedKeySize )
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
     246                 :            :         {
     247                 :            :             // ==== Encryption Data
     248         [ #  # ]:          0 :             ::comphelper::AttributeList * pNewAttrList = new ::comphelper::AttributeList;
     249 [ #  # ][ #  # ]:          0 :             uno::Reference < xml::sax::XAttributeList > xNewAttrList (pNewAttrList);
     250                 :          0 :             ::rtl::OUStringBuffer aBuffer;
     251         [ #  # ]:          0 :             uno::Sequence < sal_Int8 > aSequence;
     252                 :            : 
     253 [ #  # ][ #  # ]:          0 :             xHandler->ignorableWhitespace ( sWhiteSpace );
     254                 :            : 
     255                 :            :             // ==== Digest
     256                 :          0 :             ::rtl::OUString sChecksumType;
     257                 :          0 :             sal_Int32 nDigestAlgID = 0;
     258                 :          0 :             *pDigestAlg >>= nDigestAlgID;
     259         [ #  # ]:          0 :             if ( nDigestAlgID == xml::crypto::DigestID::SHA256_1K )
     260                 :          0 :                 sChecksumType = sSHA256_1k_URL;
     261         [ #  # ]:          0 :             else if ( nDigestAlgID == xml::crypto::DigestID::SHA1_1K )
     262                 :          0 :                 sChecksumType = sSHA1_1k_Name;
     263                 :            :             else
     264 [ #  # ][ #  # ]:          0 :                 throw uno::RuntimeException( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX "Unexpected digest algorithm is provided!" ) ), uno::Reference< uno::XInterface >() );
     265                 :            : 
     266         [ #  # ]:          0 :             pNewAttrList->AddAttribute ( sChecksumTypeAttribute, sCdataAttribute, sChecksumType );
     267         [ #  # ]:          0 :             *pDigest >>= aSequence;
     268         [ #  # ]:          0 :             ::sax::Converter::encodeBase64(aBuffer, aSequence);
     269 [ #  # ][ #  # ]:          0 :             pNewAttrList->AddAttribute ( sChecksumAttribute, sCdataAttribute, aBuffer.makeStringAndClear() );
     270                 :            : 
     271 [ #  # ][ #  # ]:          0 :             xHandler->startElement( sEncryptionDataElement , xNewAttrList);
     272                 :            : 
     273                 :            :             // ==== Algorithm
     274         [ #  # ]:          0 :             pNewAttrList = new ::comphelper::AttributeList;
     275 [ #  # ][ #  # ]:          0 :             xNewAttrList = pNewAttrList;
     276                 :            : 
     277                 :          0 :             sal_Int32 nEncAlgID = 0;
     278                 :          0 :             sal_Int32 nDerivedKeySize = 0;
     279                 :          0 :             *pEncryptAlg >>= nEncAlgID;
     280                 :          0 :             *pDerivedKeySize >>= nDerivedKeySize;
     281                 :            : 
     282                 :          0 :             ::rtl::OUString sEncAlgName;
     283         [ #  # ]:          0 :             if ( nEncAlgID == xml::crypto::CipherID::AES_CBC_W3C_PADDING )
     284                 :            :             {
     285                 :            :                 OSL_ENSURE( nDerivedKeySize, "Unexpected key size is provided!" );
     286         [ #  # ]:          0 :                 if ( nDerivedKeySize != 32 )
     287 [ #  # ][ #  # ]:          0 :                     throw uno::RuntimeException( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX "Unexpected key size is provided!" ) ), uno::Reference< uno::XInterface >() );
     288                 :            : 
     289                 :          0 :                 sEncAlgName = sAES256_URL;
     290                 :            :             }
     291         [ #  # ]:          0 :             else if ( nEncAlgID == xml::crypto::CipherID::BLOWFISH_CFB_8 )
     292                 :            :             {
     293                 :          0 :                 sEncAlgName = sBlowfish_Name;
     294                 :            :             }
     295                 :            :             else
     296 [ #  # ][ #  # ]:          0 :                 throw uno::RuntimeException( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX "Unexpected encryption algorithm is provided!" ) ), uno::Reference< uno::XInterface >() );
     297                 :            : 
     298         [ #  # ]:          0 :             pNewAttrList->AddAttribute ( sAlgorithmNameAttribute, sCdataAttribute, sEncAlgName );
     299                 :            : 
     300         [ #  # ]:          0 :             *pVector >>= aSequence;
     301         [ #  # ]:          0 :             ::sax::Converter::encodeBase64(aBuffer, aSequence);
     302 [ #  # ][ #  # ]:          0 :             pNewAttrList->AddAttribute ( sInitialisationVectorAttribute, sCdataAttribute, aBuffer.makeStringAndClear() );
     303                 :            : 
     304 [ #  # ][ #  # ]:          0 :             xHandler->ignorableWhitespace ( sWhiteSpace );
     305 [ #  # ][ #  # ]:          0 :             xHandler->startElement( sAlgorithmElement , xNewAttrList);
     306 [ #  # ][ #  # ]:          0 :             xHandler->ignorableWhitespace ( sWhiteSpace );
     307 [ #  # ][ #  # ]:          0 :             xHandler->endElement( sAlgorithmElement );
     308                 :            : 
     309                 :            :             // ==== Key Derivation
     310         [ #  # ]:          0 :             pNewAttrList = new ::comphelper::AttributeList;
     311 [ #  # ][ #  # ]:          0 :             xNewAttrList = pNewAttrList;
     312                 :            : 
     313         [ #  # ]:          0 :             pNewAttrList->AddAttribute ( sKeyDerivationNameAttribute, sCdataAttribute, sPBKDF2_Name );
     314                 :            : 
     315         [ #  # ]:          0 :             if ( bStoreStartKeyGeneration )
     316                 :            :             {
     317         [ #  # ]:          0 :                 aBuffer.append( nDerivedKeySize );
     318 [ #  # ][ #  # ]:          0 :                 pNewAttrList->AddAttribute ( sKeySizeAttribute, sCdataAttribute, aBuffer.makeStringAndClear() );
     319                 :            :             }
     320                 :            : 
     321                 :          0 :             sal_Int32 nCount = 0;
     322                 :          0 :             *pIterationCount >>= nCount;
     323         [ #  # ]:          0 :             aBuffer.append (nCount);
     324 [ #  # ][ #  # ]:          0 :             pNewAttrList->AddAttribute ( sIterationCountAttribute, sCdataAttribute, aBuffer.makeStringAndClear() );
     325                 :            : 
     326         [ #  # ]:          0 :             *pSalt >>= aSequence;
     327         [ #  # ]:          0 :             ::sax::Converter::encodeBase64(aBuffer, aSequence);
     328 [ #  # ][ #  # ]:          0 :             pNewAttrList->AddAttribute ( sSaltAttribute, sCdataAttribute, aBuffer.makeStringAndClear() );
     329                 :            : 
     330 [ #  # ][ #  # ]:          0 :             xHandler->ignorableWhitespace ( sWhiteSpace );
     331 [ #  # ][ #  # ]:          0 :             xHandler->startElement( sKeyDerivationElement , xNewAttrList);
     332 [ #  # ][ #  # ]:          0 :             xHandler->ignorableWhitespace ( sWhiteSpace );
     333 [ #  # ][ #  # ]:          0 :             xHandler->endElement( sKeyDerivationElement );
     334                 :            : 
     335                 :            :             // we have to store start-key-generation element as the last one to workaround the parsing problem
     336                 :            :             // in OOo3.1 and older versions
     337         [ #  # ]:          0 :             if ( bStoreStartKeyGeneration )
     338                 :            :             {
     339                 :            :                 // ==== Start Key Generation
     340         [ #  # ]:          0 :                 pNewAttrList = new ::comphelper::AttributeList;
     341 [ #  # ][ #  # ]:          0 :                 xNewAttrList = pNewAttrList;
     342                 :            : 
     343                 :          0 :                 ::rtl::OUString sStartKeyAlg;
     344                 :          0 :                 ::rtl::OUString sStartKeySize;
     345                 :          0 :                 sal_Int32 nStartKeyAlgID = 0;
     346                 :          0 :                 *pStartKeyAlg >>= nStartKeyAlgID;
     347         [ #  # ]:          0 :                 if ( nStartKeyAlgID == xml::crypto::DigestID::SHA256 )
     348                 :            :                 {
     349                 :          0 :                     sStartKeyAlg = sSHA256_URL;
     350         [ #  # ]:          0 :                     aBuffer.append( (sal_Int32)32 );
     351         [ #  # ]:          0 :                     sStartKeySize = aBuffer.makeStringAndClear();
     352                 :            :                 }
     353         [ #  # ]:          0 :                 else if ( nStartKeyAlgID == xml::crypto::DigestID::SHA1 )
     354                 :            :                 {
     355                 :          0 :                     sStartKeyAlg = sSHA1_Name;
     356         [ #  # ]:          0 :                     aBuffer.append( (sal_Int32)20 );
     357         [ #  # ]:          0 :                     sStartKeySize = aBuffer.makeStringAndClear();
     358                 :            :                 }
     359                 :            :                 else
     360 [ #  # ][ #  # ]:          0 :                     throw uno::RuntimeException( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX "Unexpected start key algorithm is provided!" ) ), uno::Reference< uno::XInterface >() );
     361                 :            : 
     362         [ #  # ]:          0 :                 pNewAttrList->AddAttribute ( sStartKeyGenerationNameAttribute, sCdataAttribute, sStartKeyAlg );
     363         [ #  # ]:          0 :                 pNewAttrList->AddAttribute ( sKeySizeAttribute, sCdataAttribute, sStartKeySize );
     364                 :            : 
     365 [ #  # ][ #  # ]:          0 :                 xHandler->ignorableWhitespace ( sWhiteSpace );
     366 [ #  # ][ #  # ]:          0 :                 xHandler->startElement( sStartKeyGenerationElement , xNewAttrList);
     367 [ #  # ][ #  # ]:          0 :                 xHandler->ignorableWhitespace ( sWhiteSpace );
     368 [ #  # ][ #  # ]:          0 :                 xHandler->endElement( sStartKeyGenerationElement );
     369                 :            :             }
     370                 :            : 
     371 [ #  # ][ #  # ]:          0 :             xHandler->ignorableWhitespace ( sWhiteSpace );
     372 [ #  # ][ #  # ]:          0 :             xHandler->endElement( sEncryptionDataElement );
                 [ #  # ]
     373                 :            :         }
     374 [ +  - ][ +  - ]:       1076 :         xHandler->ignorableWhitespace ( sWhiteSpace );
     375 [ +  - ][ +  - ]:       1076 :         xHandler->endElement( sFileEntryElement );
     376                 :       1076 :     }
     377 [ +  - ][ +  - ]:        281 :     xHandler->ignorableWhitespace ( sWhiteSpace );
     378 [ +  - ][ +  - ]:        281 :     xHandler->endElement( sManifestElement );
     379 [ +  - ][ +  - ]:        281 :     xHandler->endDocument();
     380                 :        281 : }
     381                 :            : 
     382                 :            : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10