diff options
author | Thorsten Behrens <Thorsten.Behrens@CIB.de> | 2018-06-28 15:17:40 +0200 |
---|---|---|
committer | Thorsten Behrens <Thorsten.Behrens@CIB.de> | 2018-06-29 13:06:28 +0200 |
commit | a7bf6488ebb544e1efaed0a1e53073df9cc2064d (patch) | |
tree | fe6cc2e666104a89ac7a932f9f4824514b1e37f5 /package | |
parent | 6947cee055a17a041819e9b3010c0b26d33d002c (diff) |
ODF1.3: import new OpenPGP encryption markup
With OFFICE-3940 the loext markup got accepted for ODF1.3 (and
the redundant KeyInfo element removed). Make sure manifest parser
can import new markup.
Change-Id: Id3c88654e8e6e0e256cd68fbb43f1ef670849cf7
Reviewed-on: https://gerrit.libreoffice.org/56597
Tested-by: Jenkins
Reviewed-by: Thorsten Behrens <Thorsten.Behrens@CIB.de>
Diffstat (limited to 'package')
-rw-r--r-- | package/source/manifest/ManifestDefines.hxx | 9 | ||||
-rw-r--r-- | package/source/manifest/ManifestImport.cxx | 48 | ||||
-rw-r--r-- | package/source/manifest/ManifestImport.hxx | 12 |
3 files changed, 63 insertions, 6 deletions
diff --git a/package/source/manifest/ManifestDefines.hxx b/package/source/manifest/ManifestDefines.hxx index c68c241c7514..44c0cb4c5254 100644 --- a/package/source/manifest/ManifestDefines.hxx +++ b/package/source/manifest/ManifestDefines.hxx @@ -46,6 +46,15 @@ #define ATTRIBUTE_ALGORITHM "loext:PGPAlgorithm" #define ELEMENT_CIPHERDATA "loext:CipherData" #define ELEMENT_CIPHERVALUE "loext:CipherValue" +#define ELEMENT_MANIFEST13_KEYINFO "manifest:keyinfo" +#define ELEMENT_ENCRYPTEDKEY13 "manifest:encrypted-key" +#define ELEMENT_ENCRYPTIONMETHOD13 "manifest:encryption-method" +#define ELEMENT_PGPDATA13 "manifest:PGPData" +#define ELEMENT_PGPKEYID13 "manifest:PGPKeyID" +#define ELEMENT_PGPKEYPACKET13 "manifest:PGPKeyPacket" +#define ATTRIBUTE_ALGORITHM13 "manifest:PGPAlgorithm" +#define ELEMENT_CIPHERDATA13 "manifest:CipherData" +#define ELEMENT_CIPHERVALUE13 "manifest:CipherValue" #define ELEMENT_ENCRYPTION_DATA "manifest:encryption-data" #define ATTRIBUTE_CHECKSUM_TYPE "manifest:checksum-type" diff --git a/package/source/manifest/ManifestImport.cxx b/package/source/manifest/ManifestImport.cxx index 916db4c3c694..cd0034a2e1df 100644 --- a/package/source/manifest/ManifestImport.cxx +++ b/package/source/manifest/ManifestImport.cxx @@ -70,6 +70,16 @@ ManifestImport::ManifestImport( vector < Sequence < PropertyValue > > & rNewManV , 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" ) @@ -149,9 +159,10 @@ void ManifestImport::doEncryptedKey(StringHashMap &) aKeyInfoSequence.resize(3); } -void ManifestImport::doEncryptionMethod(StringHashMap &rConvertedAttribs) +void ManifestImport::doEncryptionMethod(StringHashMap &rConvertedAttribs, + const OUString& rAlgoAttrName) { - OUString aString = rConvertedAttribs[sAlgorithmAttribute]; + OUString aString = rConvertedAttribs[rAlgoAttrName]; if ( aKeyInfoSequence.size() != 3 || aString != "http://www.w3.org/2001/04/xmlenc#rsa-oaep-mgf1p" ) { @@ -340,7 +351,9 @@ void SAL_CALL ManifestImport::startElement( const OUString& aName, const uno::Re case 2: { if (aConvertedName == sFileEntryElement) //manifest:file-entry doFileEntry(aConvertedAttribs); - else if (aConvertedName == sManifestKeyInfoElement) //loext:KeyInfo + else if (aConvertedName == sManifestKeyInfoElement) //loext:keyinfo + doKeyInfoEntry(aConvertedAttribs); + else if (aConvertedName == sManifestKeyInfoElement13) //manifest:keyinfo doKeyInfoEntry(aConvertedAttribs); else aStack.back().m_bValid = false; @@ -356,6 +369,8 @@ void SAL_CALL ManifestImport::startElement( const OUString& aName, const uno::Re doEncryptionData(aConvertedAttribs); else if (aConvertedName == sEncryptedKeyElement) //loext:encrypted-key doEncryptedKey(aConvertedAttribs); + else if (aConvertedName == sEncryptedKeyElement13) //manifest:encrypted-key + doEncryptedKey(aConvertedAttribs); else aStack.back().m_bValid = false; break; @@ -373,11 +388,17 @@ void SAL_CALL ManifestImport::startElement( const OUString& aName, const uno::Re else if (aConvertedName == sStartKeyAlgElement) //manifest:start-key-generation doStartKeyAlg(aConvertedAttribs); else if (aConvertedName == sEncryptionMethodElement) //loext:encryption-method - doEncryptionMethod(aConvertedAttribs); + doEncryptionMethod(aConvertedAttribs, sAlgorithmAttribute); + else if (aConvertedName == sEncryptionMethodElement13) //manifest:encryption-method + doEncryptionMethod(aConvertedAttribs, sAlgorithmAttribute13); else if (aConvertedName == sKeyInfoElement) //loext:KeyInfo doEncryptedKeyInfo(aConvertedAttribs); else if (aConvertedName == sCipherDataElement) //loext:CipherData doEncryptedCipherData(aConvertedAttribs); + else if (aConvertedName == sCipherDataElement13) //manifest:CipherData + doEncryptedCipherData(aConvertedAttribs); + else if (aConvertedName == sPgpDataElement13) //manifest:PGPData + doEncryptedPgpData(aConvertedAttribs); else aStack.back().m_bValid = false; break; @@ -393,6 +414,15 @@ void SAL_CALL ManifestImport::startElement( const OUString& aName, const uno::Re else if (aConvertedName == sCipherValueElement) //loext:CipherValue // ciphervalue action happens on endElement aCurrentCharacters = ""; + else if (aConvertedName == sCipherValueElement13) //manifest:CipherValue + // ciphervalue action happens on endElement + aCurrentCharacters = ""; + else if (aConvertedName == sPgpKeyIDElement13) //manifest:PGPKeyID + // ciphervalue action happens on endElement + aCurrentCharacters = ""; + else if (aConvertedName == sPGPKeyPacketElement13) //manifest:PGPKeyPacket + // ciphervalue action happens on endElement + aCurrentCharacters = ""; else aStack.back().m_bValid = false; break; @@ -451,7 +481,9 @@ void SAL_CALL ManifestImport::endElement( const OUString& aName ) aSequence.clear(); } - else if ( aConvertedName == sEncryptedKeyElement && aStack.back().m_bValid ) { + else if ( (aConvertedName == sEncryptedKeyElement + || aConvertedName == sEncryptedKeyElement13) + && aStack.back().m_bValid ) { if ( !bIgnoreEncryptData ) { aKeys.push_back( comphelper::containerToSequence(aKeyInfoSequence) ); @@ -465,6 +497,12 @@ void SAL_CALL ManifestImport::endElement( const OUString& aName ) case 5: { if (aConvertedName == sCipherValueElement) //loext:CipherValue doEncryptedCipherValue(); + else if (aConvertedName == sCipherValueElement13) //manifest:CipherValue + doEncryptedCipherValue(); + else if (aConvertedName == sPgpKeyIDElement13) //manifest:PGPKeyID + doEncryptedKeyId(); + else if (aConvertedName == sPGPKeyPacketElement13) //manifest:PGPKeyPacket + doEncryptedKeyPacket(); else aStack.back().m_bValid = false; break; diff --git a/package/source/manifest/ManifestImport.hxx b/package/source/manifest/ManifestImport.hxx index 26f692be9c5b..6661dc70b4e6 100644 --- a/package/source/manifest/ManifestImport.hxx +++ b/package/source/manifest/ManifestImport.hxx @@ -92,6 +92,16 @@ class ManifestImport final : public cppu::WeakImplHelper < css::xml::sax::XDocum 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; @@ -154,7 +164,7 @@ private: void doStartKeyAlg(StringHashMap &rConvertedAttribs); void doKeyInfoEntry(StringHashMap &); void doEncryptedKey(StringHashMap &); - void doEncryptionMethod(StringHashMap &); + void doEncryptionMethod(StringHashMap &, const OUString &); void doEncryptedKeyInfo(StringHashMap &); void doEncryptedCipherData(StringHashMap &); void doEncryptedPgpData(StringHashMap &); |