diff options
author | Noel Grandin <noel.grandin@collabora.co.uk> | 2018-08-16 16:57:15 +0200 |
---|---|---|
committer | Noel Grandin <noel.grandin@collabora.co.uk> | 2018-08-22 13:31:57 +0200 |
commit | 60bc26354763fa3461db49a3e827da552484150d (patch) | |
tree | 5c66cee43f76f556f9a086a67fa8a6e88750c5d5 /package | |
parent | 7867e1f1cdd726cb98a236245e3d08557cc3a313 (diff) |
new loplugin:conststringfield
Look for const string fields which can be static, and
mostly convert them to OUStringLiteral
And add a getLength() method to OUStringLiteral to make
the transition easier.
Remove dead code in XclExpRoot::GenerateDefaultEncryptionData,
default password is never empty.
Change-Id: Iae75514d9dbb87289fd5b016222f640abe755091
Reviewed-on: https://gerrit.libreoffice.org/59204
Tested-by: Jenkins
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'package')
-rw-r--r-- | package/source/manifest/ManifestImport.cxx | 289 | ||||
-rw-r--r-- | package/source/manifest/ManifestImport.hxx | 71 |
2 files changed, 145 insertions, 215 deletions
diff --git a/package/source/manifest/ManifestImport.cxx b/package/source/manifest/ManifestImport.cxx index cd0034a2e1df..9982aae75209 100644 --- a/package/source/manifest/ManifestImport.cxx +++ b/package/source/manifest/ManifestImport.cxx @@ -33,83 +33,84 @@ using namespace com::sun::star::beans; using namespace com::sun::star; using namespace std; + +static const OUStringLiteral gsFileEntryElement ( ELEMENT_FILE_ENTRY ); +static const OUStringLiteral gsEncryptionDataElement( ELEMENT_ENCRYPTION_DATA ); +static const OUStringLiteral gsAlgorithmElement ( ELEMENT_ALGORITHM ); +static const OUStringLiteral gsStartKeyAlgElement ( ELEMENT_START_KEY_GENERATION ); +static const OUStringLiteral gsKeyDerivationElement( ELEMENT_KEY_DERIVATION ); + +static const OUStringLiteral gsMediaTypeAttribute ( ATTRIBUTE_MEDIA_TYPE ); +static const OUStringLiteral gsVersionAttribute ( ATTRIBUTE_VERSION ); +static const OUStringLiteral gsFullPathAttribute ( ATTRIBUTE_FULL_PATH ); +static const OUStringLiteral gsSizeAttribute ( ATTRIBUTE_SIZE ); +static const OUStringLiteral gsSaltAttribute ( ATTRIBUTE_SALT ); +static const OUStringLiteral gsInitialisationVectorAttribute ( ATTRIBUTE_INITIALISATION_VECTOR ); +static const OUStringLiteral gsIterationCountAttribute ( ATTRIBUTE_ITERATION_COUNT ); +static const OUStringLiteral gsKeySizeAttribute ( ATTRIBUTE_KEY_SIZE ); +static const OUStringLiteral gsAlgorithmNameAttribute ( ATTRIBUTE_ALGORITHM_NAME ); +static const OUStringLiteral gsStartKeyAlgNameAttribute ( ATTRIBUTE_START_KEY_GENERATION_NAME ); +static const OUStringLiteral gsKeyDerivationNameAttribute ( ATTRIBUTE_KEY_DERIVATION_NAME ); +static const OUStringLiteral gsChecksumAttribute ( ATTRIBUTE_CHECKSUM ); +static const OUStringLiteral gsChecksumTypeAttribute ( ATTRIBUTE_CHECKSUM_TYPE ); + +static const OUStringLiteral gsKeyInfoElement ( ELEMENT_ENCRYPTED_KEYINFO ); +static const OUStringLiteral gsManifestKeyInfoElement ( ELEMENT_MANIFEST_KEYINFO ); +static const OUStringLiteral gsEncryptedKeyElement ( ELEMENT_ENCRYPTEDKEY ); +static const OUStringLiteral gsEncryptionMethodElement ( ELEMENT_ENCRYPTIONMETHOD ); +static const OUStringLiteral gsPgpDataElement ( ELEMENT_PGPDATA ); +static const OUStringLiteral gsPgpKeyIDElement ( ELEMENT_PGPKEYID ); +static const OUStringLiteral gsPGPKeyPacketElement ( ELEMENT_PGPKEYPACKET ); +static const OUStringLiteral gsAlgorithmAttribute ( ATTRIBUTE_ALGORITHM ); +static const OUStringLiteral gsCipherDataElement ( ELEMENT_CIPHERDATA ); +static const OUStringLiteral gsCipherValueElement ( ELEMENT_CIPHERVALUE ); + +static const OUStringLiteral gsManifestKeyInfoElement13 ( ELEMENT_MANIFEST13_KEYINFO ); +static const OUStringLiteral gsEncryptedKeyElement13 ( ELEMENT_ENCRYPTEDKEY13 ); +static const OUStringLiteral gsEncryptionMethodElement13 ( ELEMENT_ENCRYPTIONMETHOD13 ); +static const OUStringLiteral gsPgpDataElement13 ( ELEMENT_PGPDATA13 ); +static const OUStringLiteral gsPgpKeyIDElement13 ( ELEMENT_PGPKEYID13 ); +static const OUStringLiteral gsPGPKeyPacketElement13 ( ELEMENT_PGPKEYPACKET13 ); +static const OUStringLiteral gsAlgorithmAttribute13 ( ATTRIBUTE_ALGORITHM13 ); +static const OUStringLiteral gsCipherDataElement13 ( ELEMENT_CIPHERDATA13 ); +static const OUStringLiteral gsCipherValueElement13 ( ELEMENT_CIPHERVALUE13 ); + +static const OUStringLiteral gsFullPathProperty ( "FullPath" ); +static const OUStringLiteral gsMediaTypeProperty ( "MediaType" ); +static const OUStringLiteral gsVersionProperty ( "Version" ); +static const OUStringLiteral gsIterationCountProperty ( "IterationCount" ); +static const OUStringLiteral gsDerivedKeySizeProperty ( "DerivedKeySize" ); +static const OUStringLiteral gsSaltProperty ( "Salt" ); +static const OUStringLiteral gsInitialisationVectorProperty ( "InitialisationVector" ); +static const OUStringLiteral gsSizeProperty ( "Size" ); +static const OUStringLiteral gsDigestProperty ( "Digest" ); +static const OUStringLiteral gsEncryptionAlgProperty ( "EncryptionAlgorithm" ); +static const OUStringLiteral gsStartKeyAlgProperty ( "StartKeyAlgorithm" ); +static const OUStringLiteral gsDigestAlgProperty ( "DigestAlgorithm" ); + +static const OUStringLiteral gsSHA256_URL_ODF12 ( SHA256_URL_ODF12 ); +static const OUStringLiteral gsSHA256_URL ( SHA256_URL ); +static const OUStringLiteral gsSHA1_Name ( SHA1_NAME ); +static const OUStringLiteral gsSHA1_URL ( SHA1_URL ); + +static const OUStringLiteral gsSHA256_1k_URL ( SHA256_1K_URL ); +static const OUStringLiteral gsSHA1_1k_Name ( SHA1_1K_NAME ); +static const OUStringLiteral gsSHA1_1k_URL ( SHA1_1K_URL ); + +static const OUStringLiteral gsBlowfish_Name ( BLOWFISH_NAME ); +static const OUStringLiteral gsBlowfish_URL ( BLOWFISH_URL ); +static const OUStringLiteral gsAES128_URL ( AES128_URL ); +static const OUStringLiteral gsAES192_URL ( AES192_URL ); +static const OUStringLiteral gsAES256_URL ( AES256_URL ); + +static const OUStringLiteral gsPBKDF2_Name ( PBKDF2_NAME ); +static const OUStringLiteral gsPBKDF2_URL ( PBKDF2_URL ); + ManifestImport::ManifestImport( vector < Sequence < PropertyValue > > & rNewManVector ) : bIgnoreEncryptData ( false ) , bPgpEncryption ( false ) , nDerivedKeySize( 0 ) , rManVector ( rNewManVector ) - - , sFileEntryElement ( ELEMENT_FILE_ENTRY ) - , sEncryptionDataElement( ELEMENT_ENCRYPTION_DATA ) - , sAlgorithmElement ( ELEMENT_ALGORITHM ) - , sStartKeyAlgElement ( ELEMENT_START_KEY_GENERATION ) - , sKeyDerivationElement( ELEMENT_KEY_DERIVATION ) - - , sMediaTypeAttribute ( ATTRIBUTE_MEDIA_TYPE ) - , sVersionAttribute ( ATTRIBUTE_VERSION ) - , sFullPathAttribute ( ATTRIBUTE_FULL_PATH ) - , sSizeAttribute ( ATTRIBUTE_SIZE ) - , sSaltAttribute ( ATTRIBUTE_SALT ) - , sInitialisationVectorAttribute ( ATTRIBUTE_INITIALISATION_VECTOR ) - , sIterationCountAttribute ( ATTRIBUTE_ITERATION_COUNT ) - , sKeySizeAttribute ( ATTRIBUTE_KEY_SIZE ) - , sAlgorithmNameAttribute ( ATTRIBUTE_ALGORITHM_NAME ) - , sStartKeyAlgNameAttribute ( ATTRIBUTE_START_KEY_GENERATION_NAME ) - , sKeyDerivationNameAttribute ( ATTRIBUTE_KEY_DERIVATION_NAME ) - , sChecksumAttribute ( ATTRIBUTE_CHECKSUM ) - , sChecksumTypeAttribute ( ATTRIBUTE_CHECKSUM_TYPE ) - - , sKeyInfoElement ( ELEMENT_ENCRYPTED_KEYINFO ) - , sManifestKeyInfoElement ( ELEMENT_MANIFEST_KEYINFO ) - , sEncryptedKeyElement ( ELEMENT_ENCRYPTEDKEY ) - , sEncryptionMethodElement ( ELEMENT_ENCRYPTIONMETHOD ) - , sPgpDataElement ( ELEMENT_PGPDATA ) - , sPgpKeyIDElement ( ELEMENT_PGPKEYID ) - , sPGPKeyPacketElement ( ELEMENT_PGPKEYPACKET ) - , sAlgorithmAttribute ( ATTRIBUTE_ALGORITHM ) - , sCipherDataElement ( ELEMENT_CIPHERDATA ) - , sCipherValueElement ( ELEMENT_CIPHERVALUE ) - - , sManifestKeyInfoElement13 ( ELEMENT_MANIFEST13_KEYINFO ) - , sEncryptedKeyElement13 ( ELEMENT_ENCRYPTEDKEY13 ) - , sEncryptionMethodElement13 ( ELEMENT_ENCRYPTIONMETHOD13 ) - , sPgpDataElement13 ( ELEMENT_PGPDATA13 ) - , sPgpKeyIDElement13 ( ELEMENT_PGPKEYID13 ) - , sPGPKeyPacketElement13 ( ELEMENT_PGPKEYPACKET13 ) - , sAlgorithmAttribute13 ( ATTRIBUTE_ALGORITHM13 ) - , sCipherDataElement13 ( ELEMENT_CIPHERDATA13 ) - , sCipherValueElement13 ( ELEMENT_CIPHERVALUE13 ) - - , sFullPathProperty ( "FullPath" ) - , sMediaTypeProperty ( "MediaType" ) - , sVersionProperty ( "Version" ) - , sIterationCountProperty ( "IterationCount" ) - , sDerivedKeySizeProperty ( "DerivedKeySize" ) - , sSaltProperty ( "Salt" ) - , sInitialisationVectorProperty ( "InitialisationVector" ) - , sSizeProperty ( "Size" ) - , sDigestProperty ( "Digest" ) - , sEncryptionAlgProperty ( "EncryptionAlgorithm" ) - , sStartKeyAlgProperty ( "StartKeyAlgorithm" ) - , sDigestAlgProperty ( "DigestAlgorithm" ) - - , sSHA256_URL_ODF12 ( SHA256_URL_ODF12 ) - , sSHA256_URL ( SHA256_URL ) - , sSHA1_Name ( SHA1_NAME ) - , sSHA1_URL ( SHA1_URL ) - - , sSHA256_1k_URL ( SHA256_1K_URL ) - , sSHA1_1k_Name ( SHA1_1K_NAME ) - , sSHA1_1k_URL ( SHA1_1K_URL ) - - , sBlowfish_Name ( BLOWFISH_NAME ) - , sBlowfish_URL ( BLOWFISH_URL ) - , sAES128_URL ( AES128_URL ) - , sAES192_URL ( AES192_URL ) - , sAES256_URL ( AES256_URL ) - - , sPBKDF2_Name ( PBKDF2_NAME ) - , sPBKDF2_URL ( PBKDF2_URL ) { aStack.reserve( 10 ); } @@ -130,21 +131,21 @@ void ManifestImport::doFileEntry(StringHashMap &rConvertedAttribs) { aSequence.resize(PKG_SIZE_ENCR_MNFST); - aSequence[PKG_MNFST_FULLPATH].Name = sFullPathProperty; - aSequence[PKG_MNFST_FULLPATH].Value <<= rConvertedAttribs[sFullPathAttribute]; - aSequence[PKG_MNFST_MEDIATYPE].Name = sMediaTypeProperty; - aSequence[PKG_MNFST_MEDIATYPE].Value <<= rConvertedAttribs[sMediaTypeAttribute]; + aSequence[PKG_MNFST_FULLPATH].Name = gsFullPathProperty; + aSequence[PKG_MNFST_FULLPATH].Value <<= rConvertedAttribs[gsFullPathAttribute]; + aSequence[PKG_MNFST_MEDIATYPE].Name = gsMediaTypeProperty; + aSequence[PKG_MNFST_MEDIATYPE].Value <<= rConvertedAttribs[gsMediaTypeAttribute]; - OUString sVersion = rConvertedAttribs[sVersionAttribute]; + OUString sVersion = rConvertedAttribs[gsVersionAttribute]; if ( sVersion.getLength() ) { - aSequence[PKG_MNFST_VERSION].Name = sVersionProperty; + aSequence[PKG_MNFST_VERSION].Name = gsVersionProperty; aSequence[PKG_MNFST_VERSION].Value <<= sVersion; } - OUString sSize = rConvertedAttribs[sSizeAttribute]; + OUString sSize = rConvertedAttribs[gsSizeAttribute]; if ( sSize.getLength() ) { sal_Int64 nSize = sSize.toInt64(); - aSequence[PKG_MNFST_UCOMPSIZE].Name = sSizeProperty; + aSequence[PKG_MNFST_UCOMPSIZE].Name = gsSizeProperty; aSequence[PKG_MNFST_UCOMPSIZE].Value <<= nSize; } } @@ -229,22 +230,22 @@ void ManifestImport::doEncryptionData(StringHashMap &rConvertedAttribs) // If this element exists, then this stream is encrypted and we need // to import the initialisation vector, salt and iteration count used nDerivedKeySize = 0; - OUString aString = rConvertedAttribs[sChecksumTypeAttribute]; + OUString aString = rConvertedAttribs[gsChecksumTypeAttribute]; if ( !bIgnoreEncryptData ) { - if ( aString == sSHA1_1k_Name || aString == sSHA1_1k_URL ) { - aSequence[PKG_MNFST_DIGESTALG].Name = sDigestAlgProperty; + if ( aString == gsSHA1_1k_Name || aString == gsSHA1_1k_URL ) { + aSequence[PKG_MNFST_DIGESTALG].Name = gsDigestAlgProperty; aSequence[PKG_MNFST_DIGESTALG].Value <<= xml::crypto::DigestID::SHA1_1K; - } else if ( aString == sSHA256_1k_URL ) { - aSequence[PKG_MNFST_DIGESTALG].Name = sDigestAlgProperty; + } else if ( aString == gsSHA256_1k_URL ) { + aSequence[PKG_MNFST_DIGESTALG].Name = gsDigestAlgProperty; aSequence[PKG_MNFST_DIGESTALG].Value <<= xml::crypto::DigestID::SHA256_1K; } else bIgnoreEncryptData = true; if ( !bIgnoreEncryptData ) { - aString = rConvertedAttribs[sChecksumAttribute]; + aString = rConvertedAttribs[gsChecksumAttribute]; uno::Sequence < sal_Int8 > aDecodeBuffer; ::comphelper::Base64::decode(aDecodeBuffer, aString); - aSequence[PKG_MNFST_DIGEST].Name = sDigestProperty; + aSequence[PKG_MNFST_DIGEST].Name = gsDigestProperty; aSequence[PKG_MNFST_DIGEST].Value <<= aDecodeBuffer; } } @@ -253,22 +254,22 @@ void ManifestImport::doEncryptionData(StringHashMap &rConvertedAttribs) void ManifestImport::doAlgorithm(StringHashMap &rConvertedAttribs) { if ( !bIgnoreEncryptData ) { - OUString aString = rConvertedAttribs[sAlgorithmNameAttribute]; - if ( aString == sBlowfish_Name || aString == sBlowfish_URL ) { - aSequence[PKG_MNFST_ENCALG].Name = sEncryptionAlgProperty; + OUString aString = rConvertedAttribs[gsAlgorithmNameAttribute]; + if ( aString == gsBlowfish_Name || aString == gsBlowfish_URL ) { + aSequence[PKG_MNFST_ENCALG].Name = gsEncryptionAlgProperty; aSequence[PKG_MNFST_ENCALG].Value <<= xml::crypto::CipherID::BLOWFISH_CFB_8; - } else if ( aString == sAES256_URL ) { - aSequence[PKG_MNFST_ENCALG].Name = sEncryptionAlgProperty; + } else if ( aString == gsAES256_URL ) { + aSequence[PKG_MNFST_ENCALG].Name = gsEncryptionAlgProperty; aSequence[PKG_MNFST_ENCALG].Value <<= xml::crypto::CipherID::AES_CBC_W3C_PADDING; OSL_ENSURE( !nDerivedKeySize || nDerivedKeySize == 32, "Unexpected derived key length!" ); nDerivedKeySize = 32; - } else if ( aString == sAES192_URL ) { - aSequence[PKG_MNFST_ENCALG].Name = sEncryptionAlgProperty; + } else if ( aString == gsAES192_URL ) { + aSequence[PKG_MNFST_ENCALG].Name = gsEncryptionAlgProperty; aSequence[PKG_MNFST_ENCALG].Value <<= xml::crypto::CipherID::AES_CBC_W3C_PADDING; OSL_ENSURE( !nDerivedKeySize || nDerivedKeySize == 24, "Unexpected derived key length!" ); nDerivedKeySize = 24; - } else if ( aString == sAES128_URL ) { - aSequence[PKG_MNFST_ENCALG].Name = sEncryptionAlgProperty; + } else if ( aString == gsAES128_URL ) { + aSequence[PKG_MNFST_ENCALG].Name = gsEncryptionAlgProperty; aSequence[PKG_MNFST_ENCALG].Value <<= xml::crypto::CipherID::AES_CBC_W3C_PADDING; OSL_ENSURE( !nDerivedKeySize || nDerivedKeySize == 16, "Unexpected derived key length!" ); nDerivedKeySize = 16; @@ -276,10 +277,10 @@ void ManifestImport::doAlgorithm(StringHashMap &rConvertedAttribs) bIgnoreEncryptData = true; if ( !bIgnoreEncryptData ) { - aString = rConvertedAttribs[sInitialisationVectorAttribute]; + aString = rConvertedAttribs[gsInitialisationVectorAttribute]; uno::Sequence < sal_Int8 > aDecodeBuffer; ::comphelper::Base64::decode(aDecodeBuffer, aString); - aSequence[PKG_MNFST_INIVECTOR].Name = sInitialisationVectorProperty; + aSequence[PKG_MNFST_INIVECTOR].Name = gsInitialisationVectorProperty; aSequence[PKG_MNFST_INIVECTOR].Value <<= aDecodeBuffer; } } @@ -288,19 +289,19 @@ void ManifestImport::doAlgorithm(StringHashMap &rConvertedAttribs) void ManifestImport::doKeyDerivation(StringHashMap &rConvertedAttribs) { if ( !bIgnoreEncryptData ) { - OUString aString = rConvertedAttribs[sKeyDerivationNameAttribute]; - if ( aString == sPBKDF2_Name || aString == sPBKDF2_URL ) { - aString = rConvertedAttribs[sSaltAttribute]; + OUString aString = rConvertedAttribs[gsKeyDerivationNameAttribute]; + if ( aString == gsPBKDF2_Name || aString == gsPBKDF2_URL ) { + aString = rConvertedAttribs[gsSaltAttribute]; uno::Sequence < sal_Int8 > aDecodeBuffer; ::comphelper::Base64::decode(aDecodeBuffer, aString); - aSequence[PKG_MNFST_SALT].Name = sSaltProperty; + aSequence[PKG_MNFST_SALT].Name = gsSaltProperty; aSequence[PKG_MNFST_SALT].Value <<= aDecodeBuffer; - aString = rConvertedAttribs[sIterationCountAttribute]; - aSequence[PKG_MNFST_ITERATION].Name = sIterationCountProperty; + aString = rConvertedAttribs[gsIterationCountAttribute]; + aSequence[PKG_MNFST_ITERATION].Name = gsIterationCountProperty; aSequence[PKG_MNFST_ITERATION].Value <<= aString.toInt32(); - aString = rConvertedAttribs[sKeySizeAttribute]; + aString = rConvertedAttribs[gsKeySizeAttribute]; if ( aString.getLength() ) { sal_Int32 nKey = aString.toInt32(); OSL_ENSURE( !nDerivedKeySize || nKey == nDerivedKeySize , "Provided derived key length differs from the expected one!" ); @@ -310,7 +311,7 @@ void ManifestImport::doKeyDerivation(StringHashMap &rConvertedAttribs) else if ( nDerivedKeySize != 16 ) OSL_ENSURE( false, "Default derived key length differs from the expected one!" ); - aSequence[PKG_MNFST_DERKEYSIZE].Name = sDerivedKeySizeProperty; + aSequence[PKG_MNFST_DERKEYSIZE].Name = gsDerivedKeySizeProperty; aSequence[PKG_MNFST_DERKEYSIZE].Value <<= nDerivedKeySize; } else if ( bPgpEncryption ) { if ( aString != "PGP" ) @@ -322,12 +323,12 @@ void ManifestImport::doKeyDerivation(StringHashMap &rConvertedAttribs) void ManifestImport::doStartKeyAlg(StringHashMap &rConvertedAttribs) { - OUString aString = rConvertedAttribs[sStartKeyAlgNameAttribute]; - if (aString == sSHA256_URL || aString == sSHA256_URL_ODF12) { - aSequence[PKG_MNFST_STARTALG].Name = sStartKeyAlgProperty; + OUString aString = rConvertedAttribs[gsStartKeyAlgNameAttribute]; + if (aString == gsSHA256_URL || aString == gsSHA256_URL_ODF12) { + aSequence[PKG_MNFST_STARTALG].Name = gsStartKeyAlgProperty; aSequence[PKG_MNFST_STARTALG].Value <<= xml::crypto::DigestID::SHA256; - } else if ( aString == sSHA1_Name || aString == sSHA1_URL ) { - aSequence[PKG_MNFST_STARTALG].Name = sStartKeyAlgProperty; + } else if ( aString == gsSHA1_Name || aString == gsSHA1_URL ) { + aSequence[PKG_MNFST_STARTALG].Name = gsStartKeyAlgProperty; aSequence[PKG_MNFST_STARTALG].Value <<= xml::crypto::DigestID::SHA1; } else bIgnoreEncryptData = true; @@ -349,11 +350,11 @@ void SAL_CALL ManifestImport::startElement( const OUString& aName, const uno::Re break; } case 2: { - if (aConvertedName == sFileEntryElement) //manifest:file-entry + if (aConvertedName == gsFileEntryElement) //manifest:file-entry doFileEntry(aConvertedAttribs); - else if (aConvertedName == sManifestKeyInfoElement) //loext:keyinfo + else if (aConvertedName == gsManifestKeyInfoElement) //loext:keyinfo doKeyInfoEntry(aConvertedAttribs); - else if (aConvertedName == sManifestKeyInfoElement13) //manifest:keyinfo + else if (aConvertedName == gsManifestKeyInfoElement13) //manifest:keyinfo doKeyInfoEntry(aConvertedAttribs); else aStack.back().m_bValid = false; @@ -365,11 +366,11 @@ void SAL_CALL ManifestImport::startElement( const OUString& aName, const uno::Re if (!aIter->m_bValid) aStack.back().m_bValid = false; - else if (aConvertedName == sEncryptionDataElement) //manifest:encryption-data + else if (aConvertedName == gsEncryptionDataElement) //manifest:encryption-data doEncryptionData(aConvertedAttribs); - else if (aConvertedName == sEncryptedKeyElement) //loext:encrypted-key + else if (aConvertedName == gsEncryptedKeyElement) //loext:encrypted-key doEncryptedKey(aConvertedAttribs); - else if (aConvertedName == sEncryptedKeyElement13) //manifest:encrypted-key + else if (aConvertedName == gsEncryptedKeyElement13) //manifest:encrypted-key doEncryptedKey(aConvertedAttribs); else aStack.back().m_bValid = false; @@ -381,23 +382,23 @@ void SAL_CALL ManifestImport::startElement( const OUString& aName, const uno::Re if (!aIter->m_bValid) aStack.back().m_bValid = false; - else if (aConvertedName == sAlgorithmElement) //manifest:algorithm, + else if (aConvertedName == gsAlgorithmElement) //manifest:algorithm, doAlgorithm(aConvertedAttribs); - else if (aConvertedName == sKeyDerivationElement) //manifest:key-derivation, + else if (aConvertedName == gsKeyDerivationElement) //manifest:key-derivation, doKeyDerivation(aConvertedAttribs); - else if (aConvertedName == sStartKeyAlgElement) //manifest:start-key-generation + else if (aConvertedName == gsStartKeyAlgElement) //manifest:start-key-generation doStartKeyAlg(aConvertedAttribs); - else if (aConvertedName == sEncryptionMethodElement) //loext:encryption-method - doEncryptionMethod(aConvertedAttribs, sAlgorithmAttribute); - else if (aConvertedName == sEncryptionMethodElement13) //manifest:encryption-method - doEncryptionMethod(aConvertedAttribs, sAlgorithmAttribute13); - else if (aConvertedName == sKeyInfoElement) //loext:KeyInfo + else if (aConvertedName == gsEncryptionMethodElement) //loext:encryption-method + doEncryptionMethod(aConvertedAttribs, gsAlgorithmAttribute); + else if (aConvertedName == gsEncryptionMethodElement13) //manifest:encryption-method + doEncryptionMethod(aConvertedAttribs, gsAlgorithmAttribute13); + else if (aConvertedName == gsKeyInfoElement) //loext:KeyInfo doEncryptedKeyInfo(aConvertedAttribs); - else if (aConvertedName == sCipherDataElement) //loext:CipherData + else if (aConvertedName == gsCipherDataElement) //loext:CipherData doEncryptedCipherData(aConvertedAttribs); - else if (aConvertedName == sCipherDataElement13) //manifest:CipherData + else if (aConvertedName == gsCipherDataElement13) //manifest:CipherData doEncryptedCipherData(aConvertedAttribs); - else if (aConvertedName == sPgpDataElement13) //manifest:PGPData + else if (aConvertedName == gsPgpDataElement13) //manifest:PGPData doEncryptedPgpData(aConvertedAttribs); else aStack.back().m_bValid = false; @@ -409,18 +410,18 @@ void SAL_CALL ManifestImport::startElement( const OUString& aName, const uno::Re if (!aIter->m_bValid) aStack.back().m_bValid = false; - else if (aConvertedName == sPgpDataElement) //loext:PGPData + else if (aConvertedName == gsPgpDataElement) //loext:PGPData doEncryptedPgpData(aConvertedAttribs); - else if (aConvertedName == sCipherValueElement) //loext:CipherValue + else if (aConvertedName == gsCipherValueElement) //loext:CipherValue // ciphervalue action happens on endElement aCurrentCharacters = ""; - else if (aConvertedName == sCipherValueElement13) //manifest:CipherValue + else if (aConvertedName == gsCipherValueElement13) //manifest:CipherValue // ciphervalue action happens on endElement aCurrentCharacters = ""; - else if (aConvertedName == sPgpKeyIDElement13) //manifest:PGPKeyID + else if (aConvertedName == gsPgpKeyIDElement13) //manifest:PGPKeyID // ciphervalue action happens on endElement aCurrentCharacters = ""; - else if (aConvertedName == sPGPKeyPacketElement13) //manifest:PGPKeyPacket + else if (aConvertedName == gsPGPKeyPacketElement13) //manifest:PGPKeyPacket // ciphervalue action happens on endElement aCurrentCharacters = ""; else @@ -433,10 +434,10 @@ void SAL_CALL ManifestImport::startElement( const OUString& aName, const uno::Re if (!aIter->m_bValid) aStack.back().m_bValid = false; - else if (aConvertedName == sPgpKeyIDElement) //loext:PGPKeyID + else if (aConvertedName == gsPgpKeyIDElement) //loext:PGPKeyID // ciphervalue action happens on endElement aCurrentCharacters = ""; - else if (aConvertedName == sPGPKeyPacketElement) //loext:PGPKeyPacket + else if (aConvertedName == gsPGPKeyPacketElement) //loext:PGPKeyPacket // ciphervalue action happens on endElement aCurrentCharacters = ""; else @@ -465,7 +466,7 @@ void SAL_CALL ManifestImport::endElement( const OUString& aName ) OUString aConvertedName = ConvertName( aName ); if ( !aStack.empty() && aStack.rbegin()->m_aConvertedName == aConvertedName ) { - if ( aConvertedName == sFileEntryElement && aStack.back().m_bValid ) { + if ( aConvertedName == gsFileEntryElement && aStack.back().m_bValid ) { // root folder gets KeyInfo entry if any, for PGP encryption if (!bIgnoreEncryptData && !aKeys.empty() && aSequence[PKG_MNFST_FULLPATH].Value.get<OUString>() == "/" ) { @@ -481,8 +482,8 @@ void SAL_CALL ManifestImport::endElement( const OUString& aName ) aSequence.clear(); } - else if ( (aConvertedName == sEncryptedKeyElement - || aConvertedName == sEncryptedKeyElement13) + else if ( (aConvertedName == gsEncryptedKeyElement + || aConvertedName == gsEncryptedKeyElement13) && aStack.back().m_bValid ) { if ( !bIgnoreEncryptData ) { @@ -495,22 +496,22 @@ void SAL_CALL ManifestImport::endElement( const OUString& aName ) // end element handling for elements with cdata switch (nLevel) { case 5: { - if (aConvertedName == sCipherValueElement) //loext:CipherValue + if (aConvertedName == gsCipherValueElement) //loext:CipherValue doEncryptedCipherValue(); - else if (aConvertedName == sCipherValueElement13) //manifest:CipherValue + else if (aConvertedName == gsCipherValueElement13) //manifest:CipherValue doEncryptedCipherValue(); - else if (aConvertedName == sPgpKeyIDElement13) //manifest:PGPKeyID + else if (aConvertedName == gsPgpKeyIDElement13) //manifest:PGPKeyID doEncryptedKeyId(); - else if (aConvertedName == sPGPKeyPacketElement13) //manifest:PGPKeyPacket + else if (aConvertedName == gsPGPKeyPacketElement13) //manifest:PGPKeyPacket doEncryptedKeyPacket(); else aStack.back().m_bValid = false; break; } case 6: { - if (aConvertedName == sPgpKeyIDElement) //loext:PGPKeyID + if (aConvertedName == gsPgpKeyIDElement) //loext:PGPKeyID doEncryptedKeyId(); - else if (aConvertedName == sPGPKeyPacketElement) //loext:PGPKeyPacket + else if (aConvertedName == gsPGPKeyPacketElement) //loext:PGPKeyPacket doEncryptedKeyPacket(); else aStack.back().m_bValid = false; diff --git a/package/source/manifest/ManifestImport.hxx b/package/source/manifest/ManifestImport.hxx index 6661dc70b4e6..19d426b14f25 100644 --- a/package/source/manifest/ManifestImport.hxx +++ b/package/source/manifest/ManifestImport.hxx @@ -61,77 +61,6 @@ class ManifestImport final : public cppu::WeakImplHelper < css::xml::sax::XDocum sal_Int32 nDerivedKeySize; ::std::vector < css::uno::Sequence < css::beans::PropertyValue > > & rManVector; - const OUString sFileEntryElement; - const OUString sEncryptionDataElement; - const OUString sAlgorithmElement; - const OUString sStartKeyAlgElement; - const OUString sKeyDerivationElement; - - const OUString sMediaTypeAttribute; - const OUString sVersionAttribute; - const OUString sFullPathAttribute; - const OUString sSizeAttribute; - const OUString sSaltAttribute; - const OUString sInitialisationVectorAttribute; - const OUString sIterationCountAttribute; - const OUString sKeySizeAttribute; - const OUString sAlgorithmNameAttribute; - const OUString sStartKeyAlgNameAttribute; - const OUString sKeyDerivationNameAttribute; - const OUString sChecksumAttribute; - const OUString sChecksumTypeAttribute; - - const OUString sKeyInfoElement; - const OUString sManifestKeyInfoElement; - const OUString sEncryptedKeyElement; - const OUString sEncryptionMethodElement; - const OUString sPgpDataElement; - const OUString sPgpKeyIDElement; - const OUString sPGPKeyPacketElement; - const OUString sAlgorithmAttribute; - const OUString sCipherDataElement; - const OUString sCipherValueElement; - - const OUString sManifestKeyInfoElement13; - const OUString sEncryptedKeyElement13; - const OUString sEncryptionMethodElement13; - const OUString sPgpDataElement13; - const OUString sPgpKeyIDElement13; - const OUString sPGPKeyPacketElement13; - const OUString sAlgorithmAttribute13; - const OUString sCipherDataElement13; - const OUString sCipherValueElement13; - - const OUString sFullPathProperty; - const OUString sMediaTypeProperty; - const OUString sVersionProperty; - const OUString sIterationCountProperty; - const OUString sDerivedKeySizeProperty; - const OUString sSaltProperty; - const OUString sInitialisationVectorProperty; - const OUString sSizeProperty; - const OUString sDigestProperty; - const OUString sEncryptionAlgProperty; - const OUString sStartKeyAlgProperty; - const OUString sDigestAlgProperty; - - const OUString sSHA256_URL_ODF12; - const OUString sSHA256_URL; - const OUString sSHA1_Name; - const OUString sSHA1_URL; - - const OUString sSHA256_1k_URL; - const OUString sSHA1_1k_Name; - const OUString sSHA1_1k_URL; - - const OUString sBlowfish_Name; - const OUString sBlowfish_URL; - const OUString sAES128_URL; - const OUString sAES192_URL; - const OUString sAES256_URL; - - const OUString sPBKDF2_Name; - const OUString sPBKDF2_URL; OUString PushNameAndNamespaces( const OUString& aName, const css::uno::Reference< css::xml::sax::XAttributeList >& xAttribs, |