summaryrefslogtreecommitdiff
path: root/package
diff options
context:
space:
mode:
authorThorsten Behrens <Thorsten.Behrens@CIB.de>2018-06-28 15:17:40 +0200
committerAndras Timar <andras.timar@collabora.com>2018-07-02 10:52:31 +0200
commit8714906f5430525027bcfb84b90eb5b80e512c8c (patch)
treea6c2a67ffb80e73359fc67333a089d17a1bb3fef /package
parent3365c2b69d3500d5e9ce0967ec8479a453609d91 (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> (cherry picked from commit a7bf6488ebb544e1efaed0a1e53073df9cc2064d) Reviewed-on: https://gerrit.libreoffice.org/56678 Reviewed-by: Katarina Behrens <Katarina.Behrens@cib.de> (cherry picked from commit dd9232a6b2bcd32c7279e1476445214c6bb9e417)
Diffstat (limited to 'package')
-rw-r--r--package/source/manifest/ManifestDefines.hxx9
-rw-r--r--package/source/manifest/ManifestImport.cxx48
-rw-r--r--package/source/manifest/ManifestImport.hxx12
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 98a9d61128b5..fda529838214 100644
--- a/package/source/manifest/ManifestImport.cxx
+++ b/package/source/manifest/ManifestImport.cxx
@@ -69,6 +69,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" )
@@ -148,9 +158,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" )
{
@@ -339,7 +350,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;
@@ -355,6 +368,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;
@@ -372,11 +387,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;
@@ -392,6 +413,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;
@@ -450,7 +480,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) );
@@ -464,6 +496,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 &);