summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--package/source/manifest/ManifestDefines.hxx9
-rw-r--r--package/source/manifest/ManifestImport.cxx48
-rw-r--r--package/source/manifest/ManifestImport.hxx12
-rw-r--r--xmlsecurity/qa/unit/signing/data/encryptedGPG_odf13.odtbin0 -> 15981 bytes
-rw-r--r--xmlsecurity/qa/unit/signing/signing.cxx8
5 files changed, 71 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 &);
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
--- /dev/null
+++ b/xmlsecurity/qa/unit/signing/data/encryptedGPG_odf13.odt
Binary files differ
diff --git a/xmlsecurity/qa/unit/signing/signing.cxx b/xmlsecurity/qa/unit/signing/signing.cxx
index b7cc077d2097..265f0e5acbb0 100644
--- a/xmlsecurity/qa/unit/signing/signing.cxx
+++ b/xmlsecurity/qa/unit/signing/signing.cxx
@@ -751,11 +751,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