[Libreoffice-commits] core.git: package/source xmlsecurity/qa
Thorsten Behrens
Thorsten.Behrens at CIB.de
Fri Jun 29 11:06:53 UTC 2018
package/source/manifest/ManifestDefines.hxx | 9 +++
package/source/manifest/ManifestImport.cxx | 48 ++++++++++++++--
package/source/manifest/ManifestImport.hxx | 12 +++-
xmlsecurity/qa/unit/signing/data/encryptedGPG_odf13.odt |binary
xmlsecurity/qa/unit/signing/signing.cxx | 8 ++
5 files changed, 71 insertions(+), 6 deletions(-)
New commits:
commit a7bf6488ebb544e1efaed0a1e53073df9cc2064d
Author: Thorsten Behrens <Thorsten.Behrens at CIB.de>
Date: Thu Jun 28 15:17:40 2018 +0200
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 at CIB.de>
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 &);
diff --git a/xmlsecurity/qa/unit/signing/data/encryptedGPG_odf13.odt b/xmlsecurity/qa/unit/signing/data/encryptedGPG_odf13.odt
new file mode 100644
index 000000000000..6bcc43503267
Binary files /dev/null and b/xmlsecurity/qa/unit/signing/data/encryptedGPG_odf13.odt differ
diff --git a/xmlsecurity/qa/unit/signing/signing.cxx b/xmlsecurity/qa/unit/signing/signing.cxx
index d899024f5b0e..54920f5958b1 100644
--- a/xmlsecurity/qa/unit/signing/signing.cxx
+++ b/xmlsecurity/qa/unit/signing/signing.cxx
@@ -876,11 +876,19 @@ void SigningTest::testODFBrokenDsigGPG()
void SigningTest::testODFEncryptedGPG()
{
+ // ODF1.2 + loext flavour
createDoc(m_directories.getURLFromSrc(DATA_DIRECTORY) + "encryptedGPG.odt");
SfxBaseModel* pBaseModel = dynamic_cast<SfxBaseModel*>(mxComponent.get());
CPPUNIT_ASSERT(pBaseModel);
SfxObjectShell* pObjectShell = pBaseModel->GetObjectShell();
CPPUNIT_ASSERT(pObjectShell);
+
+ // ODF1.3 flavour
+ createDoc(m_directories.getURLFromSrc(DATA_DIRECTORY) + "encryptedGPG_odf13.odt");
+ pBaseModel = dynamic_cast<SfxBaseModel*>(mxComponent.get());
+ CPPUNIT_ASSERT(pBaseModel);
+ pObjectShell = pBaseModel->GetObjectShell();
+ CPPUNIT_ASSERT(pObjectShell);
}
#endif
More information about the Libreoffice-commits
mailing list