[Libreoffice-commits] core.git: Branch 'feature/gpg4libre2' - comphelper/source
Thorsten Behrens
Thorsten.Behrens at CIB.de
Thu Dec 7 09:58:48 UTC 2017
comphelper/source/misc/storagehelper.cxx | 24 +++++++++++++++---------
1 file changed, 15 insertions(+), 9 deletions(-)
New commits:
commit 0f5bee1600928674d0d78b79617b9453f7639998
Author: Thorsten Behrens <Thorsten.Behrens at CIB.de>
Date: Thu Dec 7 10:56:59 2017 +0100
fixup windows build
Change-Id: I51c0a0a2d5ec3903332e4f981d08b78b2cac015e
diff --git a/comphelper/source/misc/storagehelper.cxx b/comphelper/source/misc/storagehelper.cxx
index e81f1f7e3dac..a05fb1358f3f 100644
--- a/comphelper/source/misc/storagehelper.cxx
+++ b/comphelper/source/misc/storagehelper.cxx
@@ -54,11 +54,13 @@
#include <comphelper/storagehelper.hxx>
#include <comphelper/sequence.hxx>
-#include <gpgme.h>
-#include <context.h>
-#include <encryptionresult.h>
-#include <key.h>
-#include <data.h>
+#if GPGME_HAVE_GPGME
+# include <gpgme.h>
+# include <context.h>
+# include <encryptionresult.h>
+# include <key.h>
+# include <data.h>
+#endif
using namespace ::com::sun::star;
@@ -428,6 +430,7 @@ uno::Sequence< beans::NamedValue > OStorageHelper::CreatePackageEncryptionData(
uno::Sequence< beans::NamedValue > OStorageHelper::CreateGpgPackageEncryptionData()
{
+#if GPGME_HAVE_GPGME
// generate session key
// --------------------
@@ -468,7 +471,6 @@ uno::Sequence< beans::NamedValue > OStorageHelper::CreateGpgPackageEncryptionDat
if (ctx == nullptr)
throw uno::RuntimeException("The GpgME library failed to initialize for the OpenPGP protocol.");
ctx->setArmor(false);
- ctx->setKeyListMode(GPGME_KEYLIST_MODE_LOCAL);
// TODO: add self-encryption key from user config
const uno::Reference< security::XCertificate >* pCerts=xSignCertificates.getConstArray();
@@ -476,7 +478,7 @@ uno::Sequence< beans::NamedValue > OStorageHelper::CreateGpgPackageEncryptionDat
{
uno::Sequence < sal_Int8 > aKeyID;
if (pCerts->is())
- aKeyID = (*pCerts)->getSHA1Thumbprint();
+ aKeyID = (*pCerts)->getSHA256Thumbprint();
std::vector<GpgME::Key> keys;
keys.push_back(
@@ -490,8 +492,9 @@ uno::Sequence< beans::NamedValue > OStorageHelper::CreateGpgPackageEncryptionDat
aVector.getLength(), false);
GpgME::Data cipher;
- GpgME::EncryptionResult crypt_res = ctx->encrypt(keys, plain,
- cipher, GpgME::Context::NoCompress);
+ GpgME::EncryptionResult crypt_res = ctx->encrypt(
+ keys, plain,
+ cipher, GpgME::Context::NoCompress);
off_t result = cipher.seek(0,SEEK_SET);
(void) result;
@@ -530,6 +533,9 @@ uno::Sequence< beans::NamedValue > OStorageHelper::CreateGpgPackageEncryptionDat
aContainer[1].Value <<= aEncryptionData;
return aContainer;
+#else
+ return uno::Sequence< beans::NamedValue >();
+#endif
}
bool OStorageHelper::IsValidZipEntryFileName( const OUString& aName, bool bSlashAllowed )
More information about the Libreoffice-commits
mailing list