comphelper/Library_comphelper.mk | 1 comphelper/source/misc/storagehelper.cxx | 63 ++++++++++++- package/source/manifest/ManifestExport.cxx | 118 +++++++++++++------------ xmlsecurity/source/gpg/SecurityEnvironment.cxx | 6 - 4 files changed, 126 insertions(+), 62 deletions(-)
New commits: commit 4a270c8931169fdd8d1f1dcffecc2c061b198f41 Author: Thorsten Behrens <thorsten.behr...@cib.de> Date: Mon Aug 21 09:24:32 2017 +0200 demo hack: list all certificates Change-Id: Ibc678cf9c0c8a0a8e8198516b8cbdebcc977c185 diff --git a/xmlsecurity/source/gpg/SecurityEnvironment.cxx b/xmlsecurity/source/gpg/SecurityEnvironment.cxx index 367fa35e76a3..ed498a4d424b 100644 --- a/xmlsecurity/source/gpg/SecurityEnvironment.cxx +++ b/xmlsecurity/source/gpg/SecurityEnvironment.cxx @@ -70,8 +70,8 @@ Sequence< Reference < XCertificate > > SecurityEnvironmentGpg::getPersonalCertif std::list< GpgME::Key > keyList; std::list< CertificateImpl* > certsList; - m_ctx->setKeyListMode(GPGME_KEYLIST_MODE_LOCAL); - GpgME::Error err = m_ctx->startKeyListing("", true); + m_ctx->addKeyListMode(GPGME_KEYLIST_MODE_LOCAL); + GpgME::Error err = m_ctx->startKeyListing("", false); while (!err) { GpgME::Key k = m_ctx->nextKey(err); if (err) @@ -109,7 +109,7 @@ Reference< XCertificate > SecurityEnvironmentGpg::getCertificate( const OUString if(xmlSecBase64Decode(strKeyId, const_cast<xmlSecByte*>(strKeyId), xmlStrlen(strKeyId)) < 0) throw RuntimeException("Base64 decode failed"); - m_ctx->setKeyListMode(GPGME_KEYLIST_MODE_LOCAL); + m_ctx->addKeyListMode(GPGME_KEYLIST_MODE_LOCAL); GpgME::Error err = m_ctx->startKeyListing("", false); while (!err) { GpgME::Key k = m_ctx->nextKey(err); commit 61f3957cf48eacbbce2a2d0829e471b1e4c5457e Author: Thorsten Behrens <thorsten.behr...@cib.de> Date: Mon Aug 21 09:22:49 2017 +0200 Make encrypt manifest writing actually work Change-Id: I65c05c62d507c0ba781520885f4d36a9b6313f8e diff --git a/comphelper/Library_comphelper.mk b/comphelper/Library_comphelper.mk index ec5ac9d3240c..25449f09d919 100644 --- a/comphelper/Library_comphelper.mk +++ b/comphelper/Library_comphelper.mk @@ -62,6 +62,7 @@ $(eval $(call gb_Library_use_libraries,comphelper,\ cppuhelper \ sal \ salhelper \ + sax \ ucbhelper \ i18nlangtag \ )) diff --git a/comphelper/source/misc/storagehelper.cxx b/comphelper/source/misc/storagehelper.cxx index 7df94b276e8a..5f3defa34bf1 100644 --- a/comphelper/source/misc/storagehelper.cxx +++ b/comphelper/source/misc/storagehelper.cxx @@ -35,6 +35,8 @@ #include <com/sun/star/xml/crypto/XDigestContext.hpp> #include <com/sun/star/xml/crypto/XDigestContextSupplier.hpp> #include <com/sun/star/xml/crypto/DigestID.hpp> +#include "com/sun/star/security/DocumentDigitalSignatures.hpp" +#include "com/sun/star/security/XCertificate.hpp" #include <vector> @@ -42,6 +44,7 @@ #include <rtl/random.h> #include <osl/time.h> #include <osl/diagnose.h> +#include <sax/tools/converter.hxx> #include <ucbhelper/content.hxx> @@ -50,6 +53,11 @@ #include <comphelper/documentconstants.hxx> #include <comphelper/storagehelper.hxx> +#include <gpgme.h> +#include <context.h> +#include <key.h> +#include <data.h> + using namespace ::com::sun::star; namespace comphelper { @@ -437,13 +445,58 @@ uno::Sequence< beans::NamedValue > OStorageHelper::CreateGpgPackageEncryptionDat uno::Sequence< beans::NamedValue > aGpgEncryptionData(3); uno::Sequence< beans::NamedValue > aEncryptionData(1); + // TODO fire certificate chooser dialog + uno::Reference< security::XDocumentDigitalSignatures > xSigner( + security::DocumentDigitalSignatures::createWithVersion( + comphelper::getProcessComponentContext(), "1.2" ) ); + + // The use may provide a description while choosing a certificate. + OUString aDescription; + uno::Reference< security::XCertificate > xSignCertificate= + xSigner->chooseCertificate(aDescription); + + uno::Sequence < sal_Int8 > aKeyID; + if (xSignCertificate.is()) + { + aKeyID = xSignCertificate->getSHA1Thumbprint(); + } + + std::unique_ptr<GpgME::Context> ctx; + GpgME::Error err = GpgME::checkEngine(GpgME::OpenPGP); + if (err) + throw RuntimeException("The GpgME library failed to initialize for the OpenPGP protocol."); + + ctx.reset( GpgME::Context::createForProtocol(GpgME::OpenPGP) ); + if (ctx == nullptr) + throw RuntimeException("The GpgME library failed to initialize for the OpenPGP protocol."); + ctx->setArmor(false); + ctx->setKeyListMode(GPGME_KEYLIST_MODE_LOCAL); + std::vector<GpgME::Key> keys; + keys.push_back( + ctx->key( + "0x909BE2575CEDBEA3", err, true)); + + // good, ctx is setup now, let's sign the lot + GpgME::Data data_in( + reinterpret_cast<char*>(xmlSecBufferGetData(pDsigCtx->transformCtx.result)), + xmlSecBufferGetSize(pDsigCtx->transformCtx.result), false); + GpgME::Data data_out; + + ctx->encrypt(keys, plain, cipher, GpgME::Context::NoCompress); + + SAL_INFO("xmlsecurity.xmlsec.gpg", "Generating signature for: " << xmlSecBufferGetData(pDsigCtx->transformCtx.result)); + // TODO perhaps rename that one - bit misleading name ... aGpgEncryptionData[0].Name = "KeyId"; - aGpgEncryptionData[0].Value <<= OUString("jypAUdH0E9c="); - aGpgEncryptionData[0].Name = "KeyPacket"; - aGpgEncryptionData[0].Value <<= OUString("LS0tLS1CRUdJTiBQR1AgUFJJVkFURSBLRVkgQkxPQ0stLS0tLQpWZXJzaW9uOiBHbnVQRyB2MQoKbFFJR0JGY3J4V3NCQkFDM1VBdko4Sk9PZWZZcVVYQVNzVHkrUHBjNHp3cU9YZlRZT2VTSk45V3RZWDVBdU9RNgpjdzZUTmhhbExwT1hLNlhLcUpoMklqSVh6cE1jUzEvQzg1QlNSK0V6dm51VXlhUCtZTXI4VzkyalZwNGo2OWJFCkR1Mnd2Nm5wTnFvRDhqY3NBMHJLeUFoVEg0c3lNL2RMcm1FOThEVXJibGRscE11R0VDUFg0L2tVSHdBUkFRQUIKL2djREFqbjhxQXJpdllBVVlLVGtxd1U5dTRseUdhUEFzOFZNc0ltWTRYUksxd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QTI2OUlqOApBUkhRaGpBSUFSSkM3MHNCaWVKK0xMMlZWa1ZYakVnYnpqdlNHTUE3dkRXRlBJOHovdHVxSnBKeW1zR0tEbFJ4CkptSVBkRFFOVlJtZGV6cnd1WlNlaVJabE43SjNNNnQvenJCNzFHVU9CakhLS2Jua2pKdUQKPXpyZG4KLS0tLS1FTkQgUEdQIFBSSVZBVEUgS0VZIEJMT0NLLS0tLS0K"); - aGpgEncryptionData[0].Name = "CipherValue"; - aGpgEncryptionData[0].Value <<= OUString("FAm4BDOfQRJ66/ecfIByCck3JxaKYYEWwms7z+Vsb+iqPWyPGdbgJNkRBAWH4V92JvMoc/QcD/1+z+iRvR6PMGdDHAyprIh5uGHs7mo+dqabJU0qOhHb16InW2XO1GqhmjzMDUw+q4ot28jpfIVSMKPlf6b8vnNUICMJjXn+aB8="); + aGpgEncryptionData[0].Value <<= aKeyID; + aGpgEncryptionData[1].Name = "KeyPacket"; + OUString packet("LS0tLS1CRUdJTiBQR1AgUFJJVkFURSBLRVkgQkxPQ0stLS0tLQpWZXJzaW9uOiBHbnVQRyB2MQoKbFFJR0JGY3J4V3NCQkFDM1VBdko4Sk9PZWZZcVVYQVNzVHkrUHBjNHp3cU9YZlRZT2VTSk45V3RZWDVBdU9RNgpjdzZUTmhhbExwT1hLNlhLcUpoMklqSVh6cE1jUzEvQzg1QlNSK0V6dm51VXlhUCtZTXI4VzkyalZwNGo2OWJFCkR1Mnd2Nm5wTnFvRDhqY3NBMHJLeUFoVEg0c3lNL2RMcm1FOThEVXJibGRscE11R0VDUFg0L2tVSHdBUkFRQUIKL2djREFqbjhxQXJpdllBVVlLVGtxd1U5dTRseUdhUEFzOFZNc0ltWTRYUksxd1hOWHNmVC9vaG44QWh4OHJWWQp3eCtQUnFVemxrS2xiNFhkcjBzL0VKSWp0bmx4c3ZPYWlsY1VFaFpEL0VkaHM5WEI2MUl0UFdSWm1OMW1lbGt0Ck1lZDBLL1hCdzVxejJUemZGcFBaaGIxdjZMY0IwR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LS2Jua2pKdUQKPXpyZG4KLS0tLS1FTkQgUEdQIFBSSVZBVEUgS0VZIEJMT0NLLS0tLS0K"); + ::sax::Converter::decodeBase64(aKeyID, packet); + aGpgEncryptionData[1].Value <<= aKeyID; + aGpgEncryptionData[2].Name = "CipherValue"; + OUString cipher("FAm4BDOfQRJ66/ecfIByCck3JxaKYYEWwms7z+Vsb+iqPWyPGdbgJNkRBAWH4V92JvMoc/QcD/1+z+iRvR6PMGdDHAyprIh5uGHs7mo+dqabJU0qOhHb16InW2XO1GqhmjzMDUw+q4ot28jpfIVSMKPlf6b8vnNUICMJjXn+aB8="); + ::sax::Converter::decodeBase64(aKeyID, cipher); + aGpgEncryptionData[2].Value <<= aKeyID; aEncryptionData[0].Name = PACKAGE_ENCRYPTIONDATA_SHA256UTF8; aEncryptionData[0].Value <<= aVector; diff --git a/package/source/manifest/ManifestExport.cxx b/package/source/manifest/ManifestExport.cxx index 88762d272021..622ac94aa5d2 100644 --- a/package/source/manifest/ManifestExport.cxx +++ b/package/source/manifest/ManifestExport.cxx @@ -210,61 +210,15 @@ ManifestExport::ManifestExport( uno::Reference< xml::sax::XDocumentHandler > con } xHandler->startElement( sManifestElement, xRootAttrList ); - for (sal_uInt32 i = 0 ; i < nManLength ; i++) + if (nManLength > 0) { - ::comphelper::AttributeList *pAttrList = new ::comphelper::AttributeList; - const beans::PropertyValue *pValue = pSequence[i].getConstArray(); + const beans::PropertyValue *pValue = pSequence[0].getConstArray(); OUString aString; - const uno::Any *pVector = nullptr, *pSalt = nullptr, - *pIterationCount = nullptr, *pDigest = nullptr, - *pDigestAlg = nullptr, *pEncryptAlg = nullptr, - *pStartKeyAlg = nullptr, *pDerivedKeySize = nullptr, - *pPgpKeyIDProperty = nullptr, *pPgpKeyPacketProperty = nullptr, + const uno::Any *pPgpKeyIDProperty = nullptr, *pPgpKeyPacketProperty = nullptr, *pCipherValueProperty = nullptr; - for (sal_uInt32 j = 0, nNum = pSequence[i].getLength(); j < nNum; j++, pValue++) + for (sal_uInt32 j = 0, nNum = pSequence[0].getLength(); j < nNum; j++, pValue++) { - if (pValue->Name == sMediaTypeProperty ) - { - pValue->Value >>= aString; - pAttrList->AddAttribute ( sMediaTypeAttribute, sCdataAttribute, aString ); - } - else if (pValue->Name == sVersionProperty ) - { - pValue->Value >>= aString; - // the version is stored only if it is not empty - if ( bAcceptNonemptyVersion && !aString.isEmpty() ) - pAttrList->AddAttribute ( sVersionAttribute, sCdataAttribute, aString ); - } - else if (pValue->Name == sFullPathProperty ) - { - pValue->Value >>= aString; - pAttrList->AddAttribute ( sFullPathAttribute, sCdataAttribute, aString ); - } - else if (pValue->Name == sSizeProperty ) - { - sal_Int64 nSize = 0; - pValue->Value >>= nSize; - OUStringBuffer aBuffer; - aBuffer.append ( nSize ); - pAttrList->AddAttribute ( sSizeAttribute, sCdataAttribute, aBuffer.makeStringAndClear() ); - } - else if (pValue->Name == sInitialisationVectorProperty ) - pVector = &pValue->Value; - else if (pValue->Name == sSaltProperty ) - pSalt = &pValue->Value; - else if (pValue->Name == sIterationCountProperty ) - pIterationCount = &pValue->Value; - else if (pValue->Name == sDigestProperty ) - pDigest = &pValue->Value; - else if (pValue->Name == sDigestAlgProperty ) - pDigestAlg = &pValue->Value; - else if (pValue->Name == sEncryptionAlgProperty ) - pEncryptAlg = &pValue->Value; - else if (pValue->Name == sStartKeyAlgProperty ) - pStartKeyAlg = &pValue->Value; - else if (pValue->Name == sDerivedKeySizeProperty ) - pDerivedKeySize = &pValue->Value; - else if (pValue->Name == sPgpKeyIDProperty ) + if (pValue->Name == sPgpKeyIDProperty ) pPgpKeyIDProperty = &pValue->Value; else if (pValue->Name == sPgpKeyPacketProperty ) pPgpKeyPacketProperty = &pValue->Value; @@ -272,9 +226,6 @@ ManifestExport::ManifestExport( uno::Reference< xml::sax::XDocumentHandler > con pCipherValueProperty = &pValue->Value; } - xHandler->ignorableWhitespace ( sWhiteSpace ); - uno::Reference < xml::sax::XAttributeList > xAttrList ( pAttrList ); - xHandler->startElement( sFileEntryElement , xAttrList); if ( pPgpKeyIDProperty && pPgpKeyPacketProperty && pCipherValueProperty ) { // TODO make this work for multiple recipients @@ -344,6 +295,65 @@ ManifestExport::ManifestExport( uno::Reference< xml::sax::XDocumentHandler > con xHandler->endElement( sKeyInfoElement ); xHandler->ignorableWhitespace ( sWhiteSpace ); } + } + + for (sal_uInt32 i = 0 ; i < nManLength ; i++) + { + ::comphelper::AttributeList *pAttrList = new ::comphelper::AttributeList; + const beans::PropertyValue *pValue = pSequence[i].getConstArray(); + OUString aString; + const uno::Any *pVector = nullptr, *pSalt = nullptr, + *pIterationCount = nullptr, *pDigest = nullptr, + *pDigestAlg = nullptr, *pEncryptAlg = nullptr, + *pStartKeyAlg = nullptr, *pDerivedKeySize = nullptr; + for (sal_uInt32 j = 0, nNum = pSequence[i].getLength(); j < nNum; j++, pValue++) + { + if (pValue->Name == sMediaTypeProperty ) + { + pValue->Value >>= aString; + pAttrList->AddAttribute ( sMediaTypeAttribute, sCdataAttribute, aString ); + } + else if (pValue->Name == sVersionProperty ) + { + pValue->Value >>= aString; + // the version is stored only if it is not empty + if ( bAcceptNonemptyVersion && !aString.isEmpty() ) + pAttrList->AddAttribute ( sVersionAttribute, sCdataAttribute, aString ); + } + else if (pValue->Name == sFullPathProperty ) + { + pValue->Value >>= aString; + pAttrList->AddAttribute ( sFullPathAttribute, sCdataAttribute, aString ); + } + else if (pValue->Name == sSizeProperty ) + { + sal_Int64 nSize = 0; + pValue->Value >>= nSize; + OUStringBuffer aBuffer; + aBuffer.append ( nSize ); + pAttrList->AddAttribute ( sSizeAttribute, sCdataAttribute, aBuffer.makeStringAndClear() ); + } + else if (pValue->Name == sInitialisationVectorProperty ) + pVector = &pValue->Value; + else if (pValue->Name == sSaltProperty ) + pSalt = &pValue->Value; + else if (pValue->Name == sIterationCountProperty ) + pIterationCount = &pValue->Value; + else if (pValue->Name == sDigestProperty ) + pDigest = &pValue->Value; + else if (pValue->Name == sDigestAlgProperty ) + pDigestAlg = &pValue->Value; + else if (pValue->Name == sEncryptionAlgProperty ) + pEncryptAlg = &pValue->Value; + else if (pValue->Name == sStartKeyAlgProperty ) + pStartKeyAlg = &pValue->Value; + else if (pValue->Name == sDerivedKeySizeProperty ) + pDerivedKeySize = &pValue->Value; + } + + xHandler->ignorableWhitespace ( sWhiteSpace ); + uno::Reference < xml::sax::XAttributeList > xAttrList ( pAttrList ); + xHandler->startElement( sFileEntryElement , xAttrList); if ( pVector && pSalt && pIterationCount && pDigest && pDigestAlg && pEncryptAlg && pStartKeyAlg && pDerivedKeySize ) { // ==== Encryption Data _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits