Compare commits

...

227 Commits

Author SHA1 Message Date
Ingo Klöcker
5c095553e4
build,qt: Fix include path in CMake files
* lang/qt/src/Makefile.am (QGpgmeConfig.cmake, QGpgmeQt6Config.cmake):
Use new variables includeprefix{5,6} instead of replaced variable
includeprefix.
--

GnuPG-bug-id: 7205
2024-07-22 10:32:00 +02:00
Ingo Klöcker
9ab2ce36f9
build,qt: Don't put generated camel-case headers in tarball
* lang/qt/src/Makefile.am: Change camelcase5include_HEADERS to
nodist_camelcase5include_HEADERS. Change camelcase6include_HEADERS to
nodist_camelcase6include_HEADERS.
--
2024-07-18 16:16:33 +02:00
Ingo Klöcker
c69240c843
core: Remove obsolete source files
* src/isascii.c, src/putc_unlocked.c: Remove.
--

I noticed those files when I compared the content of the dist tarball
with the repo.
2024-07-18 15:51:44 +02:00
Ingo Klöcker
42e151b34b
build,qt: Allow building Qt 5 bindings and Qt 6 bindings
* configure.ac: Remove "qt" from default_languages. Add "qt5 qt6" to
default_languages. Remove "qt" from help for --enable-languages. Don't
fail anymore if "qt5" and "qt6" are enabled. Warn that "qt" is
deprecated if it was enabled.
* lang/qt/src/Makefile.am (libqgpgme_la, libqgpgmeqt6_la): New.
(lib_LTLIBRARIES): Set Qt 5 and/or Qt 6 variant of libqgpgme.
(AM_CPPFLAGS): Replace with libqgpgme_la_CPPFLAGS for Qt 5 and
libqgpgmeqt6_la_CPPFLAGS for Qt 6.
--

This makes it possible to build QGpgME simultaneously for Qt 5 and Qt 6.
By default, QGpgME is now built for all versions of Qt that are found.
Specifying "qt" as language is deprecated.

GnuPG-bug-id: 7205
2024-07-18 14:42:30 +02:00
Ingo Klöcker
e6830b58b6
build,qt: Decouple generation of moc files
* m4/qt5.m4: Export moc for Qt 5 in variable MOC5. Unset temporary MOC2.
* m4/qt6.m4: Export moc for Qt 6 in variable MOC6.
* lang/qt/src/Makefile.am: Generate .moc5 files from .h files. Generate
.moc forwarding headers in moc5 subfolder. Add moc5 subfolder to include
paths for Qt 5-based qgpgme library. Ditto for Qt 6. Clean up moc5 and
moc6 subfolders.
* lang/qt/tests/Makefile.am: List tests and test runners for Qt 5 and
Qt 6. Generate .moc5 files from .cpp files of tests. Generate .moc
forwarding headers in moc5 subfolder. Generate .hmoc file from
t-support.h directly in moc5 subfolder. Add moc5 subfolder to include
paths for all Qt 5-based tests and runners. Ditto for Qt 6. Specify
sources, LDADD and CPPFLAGS for all tests and test runners for Qt 5 and
Qt 6. Clean up moc5 and moc6 subfolders.
--

The output of Qt 5's moc and Qt 6's moc is incompatible. Therefore, we
need to generate different .moc files for Qt 5 and Qt 6 to support
co-building of the Qt 5 and Qt 6 bindings. The duplication of the
listing of the tests couldn't be avoided because automake doesn't
understand `the_tests5 = $(the_tests:%=%5)` and couldn't match the
tests with their _SOURCES. Maybe some m4 programming would have helped,
but that would have made the Makefiles even more unreadable.

GnuPG-bug-id: 7205
2024-07-18 14:41:52 +02:00
Ingo Klöcker
899a572b33
build,qt: Remove include directories on uninstall
* lang/qt/src/Makefile.am (uninstall-include-dirs-qt5,
uninstall-include-dirs-qt6): New targets.
(uninstall_include_dirs_qt5, uninstall_include_dirs_qt6): New variables.
(uninstall-local): Replace with...
(uninstall-hook): ...this. Add new uninstall_include_dirs_qt* variables.
--

We have to use uninstall-hook because uninstall-local runs before the
header files have been removed from the include folders we want to
remove.

GnuPG-bug-id: 7205
2024-07-18 14:41:32 +02:00
Ingo Klöcker
69558f2c0b
build,qt: Decouple handling of include headers
* lang/qt/src/Makefile.am (includeprefix): Replace with...
(includeprefix5, includeprefix6): ...these.
(qgpgmeincludedir): Replace with...
(qgpgme5includedir, qgpgme6includedir): ...these.
(qgpgmeinclude_HEADERS): Replace with...
(qgpgme5include_HEADERS, qgpgme6include_HEADERS): ...these.
(nodist_qgpgmeinclude_HEADERS): Replace with...
(nodist_qgpgme5include_HEADERS, nodist_qgpgme6include_HEADERS): ..these.
(camelcaseincludedir): Replace with...
(camelcase5includedir, camelcase6includedir): ...these.
(camelcaseinclude_HEADERS): Replace with...
(camelcase5include_HEADERS, camelcase6include_HEADERS): ...these.
--

This prepares the code for the case that WANT_QT5 and WANT_QT6 are both
true.

GnuPG-bug-id: 7205
2024-07-18 14:40:37 +02:00
Ingo Klöcker
576d2db9dd
build,qt: Decouple (un)install of CMake files
* lang/qt/src/Makefile.am (install-cmake-files): Rename target to
install-cmake-files-qt5 and install-cmake-files-qt6.
(uninstall-cmake-files): Rename target to uninstall-cmake-files-qt5 and
uninstall-cmake-files-qt6.
(install_cmake_files_qt5, uninstall_cmake_files_qt5,
install_cmake_files_qt6, uninstall_cmake_files_qt6): New variables.
(install-data-local): Depend on both install-cmake-files-qt* targets.
(uninstall-local): Depend on both uninstall-cmake-files-qt* targets.
--

This prepares the targets for the case that WANT_QT5 and WANT_QT6 are
both true.

GnuPG-bug-id: 7205
2024-07-18 14:35:46 +02:00
Ingo Klöcker
aa15a664b3
core: Support all keylist modes and fix possible overrun
* src/gpgme-tool.c (gt_get_keylist_mode): Increase NR_KEYLIST_MODES to
number of keylist modes. Add support for GPGME_KEYLIST_MODE_WITH_TOFU,
GPGME_KEYLIST_MODE_WITH_KEYGRIP, GPGME_KEYLIST_MODE_WITH_V5FPR. Write
all modes.
(hlp_keylist_mode): List all supported keylist modes.
(cmd_keylist_mode): Add support for GPGME_KEYLIST_MODE_WITH_TOFU,
GPGME_KEYLIST_MODE_WITH_KEYGRIP, GPGME_KEYLIST_MODE_WITH_V5FPR.
--

This fixes the possible overrun reported by Michal Hlavinka and adds
support for all keylist modes.
2024-07-15 22:19:13 +02:00
Ingo Klöcker
e46748a0d1
build,cpp: Fix include paths in forwarding headers in gpgme++ folder
* lang/cpp/src/Makefile.am (build rule for copied headers): Write
abs_srcdir instead of srcdir in the generated headers.
--

The generated include paths lacked a "../" if srcdir was relative. This
lead to self-including includes for in-source builds. Including the real
headers with their absolute paths fixes this.

GnuPG-bug-id: 7110
2024-07-10 23:28:27 +02:00
Ingo Klöcker
f6d020e24f
qt: Replace usage of deprecated Error::asString
* lang/qt/src/debug.cpp (operator<<): Use Error::asStdString instead of
Error::asString.
* lang/qt/src/qgpgmedecryptverifyjob.cpp (decrypt_verify),
lang/qt/src/qgpgmenewcryptoconfig.cpp
(QGpgMENewCryptoConfigComponent::sync),
lang/qt/src/qgpgmewkdlookupjob.cpp (startDirmngr): Use QDebug operator
for Error instead of Error::asString.
* lang/qt/src/threadedjobmixin.cpp (_detail::audit_log_as_html): Use
errorAsString instead of Error::asString.
* lang/qt/src/util.h (errorAsString): New.

* lang/qt/tests/run-decryptverifyarchivejob.cpp (main),
lang/qt/tests/run-decryptverifyjob.cpp (main),
lang/qt/tests/run-encryptarchivejob.cpp (main),
lang/qt/tests/run-encryptjob.cpp (main),
lang/qt/tests/run-exportjob.cpp (main),
lang/qt/tests/run-importjob.cpp (main),
lang/qt/tests/run-receivekeysjob.cpp (main),
lang/qt/tests/run-refreshkeysjob.cpp (main),
lang/qt/tests/run-signarchivejob.cpp (main),
lang/qt/tests/run-signjob.cpp (main),
lang/qt/tests/run-verifydetachedjob.cpp (main),
lang/qt/tests/run-verifyopaquejob.cpp (main),
lang/qt/tests/run-wkdrefreshjob.cpp (main),
lang/qt/tests/t-ownertrust.cpp (testChangeOwnerTrust),
lang/qt/tests/t-remarks.cpp (testRemarkOwnKey),
lang/qt/tests/t-tofuinfo.cpp (testTofuPolicy): Use QDebug operator for
Error instead of Error::asString.
* lang/qt/tests/t-changeexpiryjob.cpp (all test functions),
lang/qt/tests/t-trustsignatures.cpp (all test functions),
lang/qt/tests/t-various.cpp (testSignKeyWithoutExpiration,
testSignKeyWithExpiration): Use errorAsString instead of
Error::asString.
--

GnuPG-bug-id: 7188
2024-07-05 10:05:51 +02:00
Ingo Klöcker
28542b14c4
cpp: Deprecate Error::asString and update users
* lang/cpp/src/error.h (Error::asString): Mark as deprecated.
* lang/cpp/src/context.cpp (operator<<),
lang/cpp/src/editinteractor.cpp (edit_interactor_callback_impl),
lang/cpp/tests/run-getkey.cpp (main),
lang/cpp/tests/run-keylist.cpp (main),
lang/cpp/tests/run-wkdlookup.cpp (main): Use Error::asStdString instead
of Error::asString.
--

GnuPG-bug-id: 7188
2024-07-05 10:05:51 +02:00
Ingo Klöcker
2656d3ee5b
cpp: Add safer member function returning text describing an error
* lang/cpp/src/error.h, lang/cpp/src/context.cpp (class Error): New
member function asStdString.
--

Unlike asString the new function doesn't cache the value returned by
gpgme_strerror_r. This ensures that on Windows the UTF-8 encoded text
is returned for the main thread even if the function was called before
for another thread. For other threads asStdString will still return the
natively encoded error description until UTF-8 encoded error
descriptions can be enabled for all threads (T7185).

GnuPG-bug-id: 7188
2024-07-05 10:05:51 +02:00
Ingo Klöcker
acf574af64
qt: Always include C++ binding headers with gpgme++/ prefix
* lang/qt/src/Makefile.am, lang/qt/tests/Makefile.am (AM_CPPFLAGS):
Add builddir instead of srcdir of C++ bindings as include path.
* lang/qt/src/changeexpiryjob.cpp, lang/qt/src/changeexpiryjob.h,
lang/qt/src/changeownertrustjob.h, lang/qt/src/dataprovider.cpp,
lang/qt/src/dataprovider.h, lang/qt/src/debug.cpp,
lang/qt/src/decryptverifyarchivejob.cpp,
lang/qt/src/decryptverifyarchivejob.h,
lang/qt/src/encryptarchivejob.cpp, lang/qt/src/encryptarchivejob.h,
lang/qt/src/encryptjob.h, lang/qt/src/encryptjob_p.h,
lang/qt/src/filelistdataprovider.cpp,
lang/qt/src/filelistdataprovider.h,
lang/qt/src/hierarchicalkeylistjob.h, lang/qt/src/importjob.cpp,
lang/qt/src/importjob.h, lang/qt/src/importjob_p.h, lang/qt/src/job.h,
lang/qt/src/keyformailboxjob.h, lang/qt/src/keylistjob.h,
lang/qt/src/listallkeysjob.h, lang/qt/src/multideletejob.cpp,
lang/qt/src/qgpgmeaddexistingsubkeyjob.cpp,
lang/qt/src/qgpgmeadduseridjob.cpp, lang/qt/src/qgpgmebackend.cpp,
lang/qt/src/qgpgmechangeexpiryjob.cpp,
lang/qt/src/qgpgmechangeownertrustjob.cpp,
lang/qt/src/qgpgmechangepasswdjob.cpp, lang/qt/src/qgpgmedecryptjob.cpp,
lang/qt/src/qgpgmedecryptjob.h,
lang/qt/src/qgpgmedecryptverifyarchivejob.cpp,
lang/qt/src/qgpgmedecryptverifyarchivejob.h,
lang/qt/src/qgpgmedecryptverifyjob.cpp,
lang/qt/src/qgpgmedecryptverifyjob.h, lang/qt/src/qgpgmedeletejob.cpp,
lang/qt/src/qgpgmedownloadjob.cpp,
lang/qt/src/qgpgmeencryptarchivejob.cpp,
lang/qt/src/qgpgmeencryptarchivejob.h, lang/qt/src/qgpgmeencryptjob.cpp,
lang/qt/src/qgpgmeencryptjob.h, lang/qt/src/qgpgmeexportjob.cpp,
lang/qt/src/qgpgmeimportfromkeyserverjob.cpp,
lang/qt/src/qgpgmeimportfromkeyserverjob.h,
lang/qt/src/qgpgmeimportjob.cpp, lang/qt/src/qgpgmeimportjob.h,
lang/qt/src/qgpgmekeyformailboxjob.h,
lang/qt/src/qgpgmekeygenerationjob.cpp,
lang/qt/src/qgpgmekeygenerationjob.h, lang/qt/src/qgpgmekeylistjob.cpp,
lang/qt/src/qgpgmekeylistjob.h, lang/qt/src/qgpgmelistallkeysjob.cpp,
lang/qt/src/qgpgmelistallkeysjob.h,
lang/qt/src/qgpgmenewcryptoconfig.cpp,
lang/qt/src/qgpgmenewcryptoconfig.h, lang/qt/src/qgpgmequickjob.cpp,
lang/qt/src/qgpgmereceivekeysjob.h,
lang/qt/src/qgpgmerefreshsmimekeysjob.cpp,
lang/qt/src/qgpgmerefreshsmimekeysjob.h,
lang/qt/src/qgpgmerevokekeyjob.cpp,
lang/qt/src/qgpgmesetprimaryuseridjob.cpp,
lang/qt/src/qgpgmesignarchivejob.cpp,
lang/qt/src/qgpgmesignarchivejob.h,
lang/qt/src/qgpgmesignencryptarchivejob.cpp,
lang/qt/src/qgpgmesignencryptarchivejob.h,
lang/qt/src/qgpgmesignencryptjob.cpp,
lang/qt/src/qgpgmesignencryptjob.h, lang/qt/src/qgpgmesignjob.cpp,
lang/qt/src/qgpgmesignjob.h, lang/qt/src/qgpgmesignkeyjob.cpp,
lang/qt/src/qgpgmetofupolicyjob.cpp,
lang/qt/src/qgpgmeverifydetachedjob.cpp,
lang/qt/src/qgpgmeverifydetachedjob.h,
lang/qt/src/qgpgmeverifyopaquejob.cpp,
lang/qt/src/qgpgmeverifyopaquejob.h, lang/qt/src/qgpgmewkdlookupjob.cpp,
lang/qt/src/qgpgmewkdrefreshjob.cpp, lang/qt/src/qgpgmewkdrefreshjob.h,
lang/qt/src/qgpgmewkspublishjob.cpp, lang/qt/src/quickjob.h,
lang/qt/src/signarchivejob.cpp, lang/qt/src/signarchivejob.h,
lang/qt/src/signencryptarchivejob.cpp,
lang/qt/src/signencryptarchivejob.h, lang/qt/src/signencryptjob.h,
lang/qt/src/signencryptjob_p.h, lang/qt/src/signjob.h,
lang/qt/src/signjob_p.h, lang/qt/src/threadedjobmixin.cpp,
lang/qt/src/threadedjobmixin.h, lang/qt/src/tofupolicyjob.h,
lang/qt/src/util.cpp, lang/qt/src/wkdlookupresult.cpp,
lang/qt/src/wkdlookupresult.h, lang/qt/src/wkdrefreshjob_p.h,
lang/qt/tests/run-decryptverifyarchivejob.cpp,
lang/qt/tests/run-decryptverifyjob.cpp,
lang/qt/tests/run-encryptarchivejob.cpp,
lang/qt/tests/run-encryptjob.cpp, lang/qt/tests/run-exportjob.cpp,
lang/qt/tests/run-importjob.cpp, lang/qt/tests/run-keyformailboxjob.cpp,
lang/qt/tests/run-receivekeysjob.cpp,
lang/qt/tests/run-refreshkeysjob.cpp,
lang/qt/tests/run-signarchivejob.cpp, lang/qt/tests/run-signjob.cpp,
lang/qt/tests/run-verifydetachedjob.cpp,
lang/qt/tests/run-verifyopaquejob.cpp,
lang/qt/tests/run-wkdrefreshjob.cpp,
lang/qt/tests/t-addexistingsubkey.cpp,
lang/qt/tests/t-changeexpiryjob.cpp, lang/qt/tests/t-config.cpp,
lang/qt/tests/t-decryptverify.cpp, lang/qt/tests/t-encrypt.cpp,
lang/qt/tests/t-import.cpp, lang/qt/tests/t-keylist.cpp,
lang/qt/tests/t-keylocate.cpp, lang/qt/tests/t-ownertrust.cpp,
lang/qt/tests/t-remarks.cpp, lang/qt/tests/t-revokekey.cpp,
lang/qt/tests/t-setprimaryuserid.cpp, lang/qt/tests/t-support.cpp,
lang/qt/tests/t-support.h, lang/qt/tests/t-tofuinfo.cpp,
lang/qt/tests/t-trustsignatures.cpp, lang/qt/tests/t-various.cpp,
lang/qt/tests/t-verify.cpp, lang/qt/tests/t-wkdlookup.cpp,
lang/qt/tests/t-wkspublish.cpp: Include GpgME++ headers with gpgme++/
prefix.
--

This prepares the Qt bindings for building them separately from the C++
bindings.

GnuPG-bug-id: 7110
2024-07-05 10:05:50 +02:00
Ingo Klöcker
b7435b31f6
build,cpp: Create forwarding headers in a gpgme++ folder
* lang/cpp/src/Makefile.am (copied_headers): New.
(build rule for all copied headers): New.
(BUILT_SOURCES): New.
(CLEANFILES): Add copied_headers.
--

The forwarding headers make it easier to use the headers from the Qt
bindings when building them against the built but not installed C++
bindings because we can always include the C++ headers with gpgme++/
prefix. This also helps to avoid including a C++ header with the same
name as a header in the Qt bindings (e.g. util.h).

GnuPG-bug-id: 7110
2024-07-05 10:02:45 +02:00
NIIBE Yutaka
95bd4fa813
Fix calling CancelSynchronousIo.
* src/w32-util.c (_gpgme_w32_cancel_synchronous_io): Use HANDLE.

--

GnuPG-bug-id: 6634
Signed-off-by: NIIBE Yutaka <gniibe@fsij.org>
2024-07-05 13:52:33 +09:00
NIIBE Yutaka
de60684500
Fix printing size_t and off_t value for LLP64 Windows.
* src/debug.h (_trace_sysres_off_t): Use 'z' length specifier.
* src/w32-io.c (_gpgme_io_read): Likewise.
(writer, _gpgme_io_write): Likewise.

--

GnuPG-bug-id: 7187
Signed-off-by: NIIBE Yutaka <gniibe@fsij.org>
2024-07-05 13:49:26 +09:00
NIIBE Yutaka
8b4171680c
Remove ath.h and ath.c.
* src/Makefile.am (system_components): We don't use ath.h any more.
(main_sources): Remove ath.h and ath.c.

--

Signed-off-by: NIIBE Yutaka <gniibe@fsij.org>
2024-07-05 11:48:11 +09:00
NIIBE Yutaka
9c276e762a
Don't use ath_self, but get thread ID directly.
* src/debug.c [HAVE_W32_SYSTEM or __linux] (tid_log_callback): Use
native thread ID call for Windows and Linux, ifdef-out-ed.
(debug_init): Only call gpgrt_log_set_pid_suffix_cb for relevant
systems.

--

Signed-off-by: NIIBE Yutaka <gniibe@fsij.org>
2024-07-05 11:36:26 +09:00
NIIBE Yutaka
ec2c6dd8bc
Use gpgrt_b64dec in libgpg-error.
* src/b64dec.c: Remove.
* src/Makefile.am (main_sources): Remove b64dec.c.
* src/data-identify.c (pgp_binary_detection): Use gpgrt_b64dec in
libgpg-error.

--

gpgrt_b64dec is available in libgpg-error 1.27 and it is already in
use by JSON support.

GnuPG-bug-id: 7180
Signed-off-by: NIIBE Yutaka <gniibe@fsij.org>
2024-07-01 11:52:25 +09:00
Ingo Klöcker
6ed5c9a38a
cpp: Remove obsolete files
* lang/cpp/src/context_glib.cpp, lang/cpp/src/context_qt.cpp: Remove.
--

These files have never been used since gpgmepp was imported into this
repo.
2024-06-28 11:11:14 +02:00
Ingo Klöcker
7d5df0bf0d
qt: Allow appending a detached signature to an existing file
* lang/qt/src/qgpgmesignjob.cpp (sign_to_filename): Add argument
"appendSignature". Append new detached signature to an existing file if
requested.
* lang/qt/src/signjob.cpp, lang/qt/src/signjob.h (class SignJob): Add
member functions setAppendSignature, appendSignatureEnabled.
* lang/qt/src/signjob_p.h (struct SignJobPrivate): Add member
m_appendSignature.

* lang/qt/tests/run-signjob.cpp (struct CommandLineOptions): Add members
signingFlags, appendSignature. Initialize armor.
(parseCommandLine): Add command line options --detach-sign and --append.
(main): Do not exit if output file exists and append is enabled.
Pass new options to the job.
--

This change simplifies cross-signing a document by appending additional
detached signatures to a file with already existing detached signatures.

GnuPG-bug-id: 6867
2024-06-18 16:36:40 +02:00
Ingo Klöcker
09827ffc77
qt,build: Install headers for Qt 5 and Qt 6 in different locations
* lang/qt/src/Makefile.am (includeprefix): New.
(qgpgmeincludedir, camelcaseincludedir): Add $(includeprefix).
(QGpgmeConfig.cmake, QGpgmeQt6Config.cmake): Add $(includeprefix) to
replacement for @resolved_includedir@.
--

This installs the headers for Qt 5 in $(includedir)/qgpgme-qt5 and the
headers for Qt 6 in $(includedir)/qgpgme-qt6. For users of the CMake
files the change will be transparent, i.e. they don't have to do
anything. Packagers will have to change their scripts but in the end
this change will make their lifes easier.

GnuPG-bug-id: 7161
2024-06-17 11:55:26 +02:00
NIIBE Yutaka
53c367629a
Update gpg-error.m4 again for spell fix.
Signed-off-by: NIIBE Yutaka <gniibe@fsij.org>
2024-06-14 13:52:19 +09:00
Ingo Klöcker
c52e1943a7
qt,tests: Fix deprecation warnings (in Qt 6 build)
* lang/qt/tests/t-tofuinfo.cpp (TofuInfoTest::signAndVerify,
TofuInfoTest::testTofuPolicy): Use range-based for loop instead of Qt's
deprecated foreach.
--
2024-06-13 10:23:49 +02:00
Ingo Klöcker
60b96d149c
qt: Specify import options as list of strings instead of as string
* lang/qt/src/importjob.cpp, lang/qt/src/importjob.h (setImportOptions):
Change type of argument "options" to QStringList.
(importOptions): Change return type to QStringList.
* lang/qt/src/importjob_p.h (struct ImportJobPrivate): Change type of
member m_importOptions to QStringList.
* lang/qt/src/qgpgmeimportjob.cpp (import_qba): Change type of argument
"importOptions" to QStringList. Join list of import options with ','
when setting the "import-options" context flag.

* lang/qt/tests/t-import.cpp (ImportTest::testImportWithImportOptions):
Adapt to API change.
--

This makes the API that was introduced with the previous commit easier
to use.

GnuPG-bug-id: 7152
2024-06-13 10:05:44 +02:00
NIIBE Yutaka
6c90ec7be2
m4: Update m4 files.
* m4/gpg-error.m4: Update libgpg-error master.
* m4/libassuan.m4: Update libassuan master.

--

Signed-off-by: NIIBE Yutaka <gniibe@fsij.org>
2024-06-13 14:47:39 +09:00
NIIBE Yutaka
14b035034a
gpgme.m4: Fix setting/using GPG_ERROR_CONFIG.
gpgm4.m4 (_AM_PATH_GPGRT_CONFIG): Don't set GPG_ERROR_CONFIG and
gpg_error_config_version.

--

Signed-off-by: NIIBE Yutaka <gniibe@fsij.org>
2024-06-13 14:46:08 +09:00
Ingo Klöcker
2187a4de8c
qt: Allow specifying import options when importing keys
* lang/qt/src/importjob.cpp, lang/qt/src/importjob.h (class ImportJob):
Add member functions setImportOptions and importOptions.
* lang/qt/src/importjob_p.h (struct ImportJobPrivate): Add member
m_importOptions.
* lang/qt/src/qgpgmeimportjob.cpp (import_qba): Add arg importOptions
and adjust the callers. Set import options context flag.

* lang/qt/tests/t-import.cpp (ImportTest): Add member function
testImportWithImportOptions.
--

GnuPG-bug-id: 7152
2024-06-12 11:34:41 +02:00
Ingo Klöcker
5b73b0722a
tests: Add --import-filter option to usage info of run-import
* tests/run-import.c (show_usage): Add option --import-filter.
--
2024-06-12 10:48:34 +02:00
Ingo Klöcker
3b9815bd8a
core: Allow setting import options when importing keys
* src/context.h (struct gpgme_context): New field import_options.
* src/engine-backend.h (struct engine_ops): Add arg import_options to
field 'import'.
* src/engine-gpg.c (gpg_import): Add arg import_options and pass option
--import-options with argument value to gpg.
* src/engine-gpgsm.c (gpgsm_import): Add dummy arg import_options.
* src/engine.c (_gpgme_engine_op_import): Add arg import_options and
pass option to import function of engine.
* src/engine.h (_gpgme_engine_op_import): Add arg import_options.
* src/gpgme.c (gpgme_release): Free 'import_options'.
(gpgme_set_ctx_flag, gpgme_get_ctx_flag): New flag "import-options".
* src/import.c (_gpgme_op_import_start, _gpgme_op_import_keys_start,
_gpgme_op_receive_keys_start): Pass import options stored in context to
_gpgme_engine_op_import.

* tests/run-import.c (show_usage, main): Add option --import-options.
--

This makes the --import-options option available in the GPGME API for
key imports.

GnuPG-bug-id: 7152
2024-06-12 10:45:11 +02:00
Ingo Klöcker
307256d277
qt,doc: Fix typos
* lang/qt/README: Fix typos.
--
2024-06-12 09:09:18 +02:00
Ingo Klöcker
87319b3fc7
qt: Align license of some Makefiles with license of other Makefiles
* lang/qt/doc/Makefile.am, lang/qt/tests/Makefile.am: Change license
from LGPL to GPL.
--

Both files are part of QGpgME (as lang/qt/Makefile.am and
lang/qt/src/Makefile.am). Hence, they should be licensed as other parts
of QGpgME.
2024-06-10 14:56:02 +02:00
Ingo Klöcker
29be63ae37
qt: Fix license headers of Makefiles
* lang/qt/Makefile.am, lang/qt/src/Makefile.am: Files are part of
QGpgme. Fix wrong package name (GPGME-CL -> QGpgME). Replace references
to LGPL with references to GPL.
--

The files were already licensed under the GPL but the license headers
contained multiple (copy&paste?) errors.
2024-06-10 14:55:50 +02:00
Ingo Klöcker
09cc0c81f7
qt: Fix license headers of CMake config files
* lang/qt/src/QGpgmeConfig-w32.cmake.in.in,
lang/qt/src/QGpgmeConfig.cmake.in.in,
lang/qt/src/QGpgmeConfigVersion.cmake.in: Files are part of QGpgME.
Fix copy&paste error (GPGME-CL -> QGpgME). Fix reference to license
to check for details.
* lang/qt/src/QGpgmeQt6Config-w32.cmake.in.in,
lang/qt/src/QGpgmeQt6Config.cmake.in.in,
lang/qt/src/QGpgmeQt6ConfigVersion.cmake.in: Files are part of QGpgME.
Fix reference to license to check for details.
--

The files were already licensed under the GPL but the license headers
contained multiple (copy&paste?) errors.
2024-06-10 14:55:42 +02:00
Ingo Klöcker
967b6b726e
qt: Fix license headers of dataprovider.*
* lang/qt/src/dataprovider.cpp, lang/qt/src/dataprovider.h: Change
license header from LGPL to GPL.
--

QGpgME is released under the GPL. As part of QGpgME these files (that
were originally licensed under the LGPL) are released under the GPL.
2024-06-10 14:55:26 +02:00
Ingo Klöcker
4136928f0d
cpp: Remove commented out and disabled code
* lang/cpp/src/configuration.cpp: Remove disabled, abandoned code.
* lang/cpp/src/context.cpp: Remove commented out, obsolete code.
--
2024-06-10 14:54:48 +02:00
Werner Koch
5d9269cb4f
doc: Extend description for GPGME_CREATE_ADSK
--
2024-06-05 13:50:17 +02:00
Ingo Klöcker
25dd284b0c
core,w32: Pass file names with forward slashes to gpg and gpgtar
src/conversion.c, src/util.h (_gpgme_replace_backslashes): New.
src/engine-gpg.c (_add_arg): Add argument file_name. On Windows, replace
backslashes in file name arguments with forward slashes.
(add_arg_ext, add_arg_with_locp, add_arg, add_arg_pfx, add_gpg_arg,
add_gpg_arg_with_value, add_arg_len): Adjust call of _add_arg.
(add_file_name_arg, add_file_name_arg_len, add_gpg_arg_with_file_name):
New.
(add_file_name_arg_or_data): Call add_file_name_arg for file name.
(gpg_new): Call add_gpg_arg_with_file_name for home directory.
(gpg_decrypt): Call add_file_name_arg for output directory and output
file name.
(append_args_from_recipients_string): Call add_file_name_arg_len for
recipients file name.
(gpg_encrypt): Call add_file_name_arg for output file name, base
directory and input file name. Call add_gpg_arg_with_file_name to set
file name stored in message.
(gpg_encrypt_sign): Call add_file_name_arg for output file name, base
directory and input file name. Call add_gpg_arg_with_file_name to set
file name stored in message.
(gpg_sign): Call add_file_name_arg for output file name, base directory
and input file name. Call add_gpg_arg_with_file_name to set file name
stored in message.
(gpg_verify): Call add_file_name_arg for output directory and output
file name.
--

By passing all file names with forward slashes to gpg and gpgtar we
avoid problems caused by the quoting of backslashes.

GnuPG-bug-id: 7141
2024-06-04 16:52:24 +02:00
Ingo Klöcker
1245b09012
build,python: Fix make distcheck for Python 3.9+
* lang/python/Makefile.am (uninstall-local): Remove installed .egg
folders.
--

Python 3.9+ install the module into a gpg-*.egg folder instead of in
"gpg" with accompanying gpg-*.egg-info file. Moreover, Python 3.9+
normalize version numbers, e.g. the version 1.24.0_beta576 is normalized
as 1.24.0b576.
2024-05-29 17:13:30 +02:00
Ingo Klöcker
09d81da665
build,python: Remove support for Python 3.4, 3.5, 3.7
* configure.ac: Don't look for Python 3.4, 3.5, 3.7 anymore.
--

This complements the previous commit where those versions where removed
from python.m4.
2024-05-29 17:06:16 +02:00
Ben Greiner
5844d9e700
build,python: Build Python bindings without distutils
* m4/python.m4: Add python3.12 and 3.11 as valid interpreters, remove
EOL 3.4, 3.5, 3.7 (keep 3.6 because some distributions still ship and
maintain it).
* lang/python/Makefile.am (clean-local): Remove dist and gpg.egg-info
created by Python 3.9+ on make install.
* lang/python/setup.py.in: switch from distutils to setuptools where
possible, remove obsolete and deprecated -py3 option of swig, add
classifiers up to 3.12, remove 3.4, 3.5, 3.7.
* lang/python/doc/src/gpgme-python-howto.org: replace distutils with
setuptools
* lang/python/examples/howto/advanced/cython/setup.py: replace distutils
with setuptools
--

This fixes building the Python bindings for Python 3.12 where distutils
has been removed.

Based on D545
2024-05-29 17:04:10 +02:00
Ingo Klöcker
986c5f0b94
tests: Add new files to distribution
* tests/json/Makefile.am (EXTRA_DIST): Add files added with f2575b63.
--

Fixes-commit: f2575b6313
GnuPG-bug-id: 7118
2024-05-24 13:46:55 +02:00
Ingo Klöcker
6aa359b1e8
cpp: Fix includes in public headers
* lang/cpp/src/defaultassuantransaction.h,
lang/cpp/src/gpgadduserideditinteractor.h,
lang/cpp/src/gpgagentgetinfoassuantransaction.h,
lang/cpp/src/gpggencardkeyinteractor.h,
lang/cpp/src/gpgsetexpirytimeeditinteractor.h,
lang/cpp/src/gpgsetownertrusteditinteractor.h,
lang/cpp/src/gpgsignkeyeditinteractor.h,
lang/cpp/src/interfaces/assuantransaction.h,
lang/cpp/src/interfaces/dataprovider.h,
lang/cpp/src/interfaces/statusconsumer.h,
lang/cpp/src/scdgetinfoassuantransaction.h,
lang/cpp/src/statusconsumerassuantransaction.h,
lang/cpp/src/trustitem.h: Use #include "foo.h" instead of
#include <foo.h> for own headers.
--

This fixes the build for projects that include the headers (as intended)
with #include <gpgme++/...> and that don't add the gpgme++ subdirectory
to the list of include paths for the compiler.

GnuPG-bug-id: 7110
2024-05-24 10:51:32 +02:00
Ingo Klöcker
f0d1f2c4c7
Merge branch 'ikloecker/t7118-revkeys' 2024-05-24 10:47:15 +02:00
Tobias Fella
15718cb295
qt,cpp: Implement adding ADSKs to existing keys
* lang/cpp/src/context.cpp: Add functions for adding ADSKs.
* lang/cpp/src/context.h: Ditto.
* lang/qt/src/qgpgmequickjob.cpp: Add implementation of ADSK job.
* lang/qt/src/qgpgmequickjob.h: Ditto.
* lang/qt/src/quickjob.h: Add job for adding ADSKs.
2024-05-22 13:08:50 +02:00
Tobias Fella
e42b72bc2b
core: Implement adding ADSKs through gpgme_createsubkey
* src/engine-gpg.c: Add and use function for adding ADSKs.
* src/genkey.c: Prevent error due to no status line.
* src/gpgme.h.in: Add flag GPGME_CREATE_ADSK
* doc/gpgme.texi: Add documentation for ADSKs
* tests/run-genkey.c: Add test for adding ADSKs
--

This adds the ability to add ADSKs through
the gpgme_createsubkey interface.
The function must be called with NULL userid,
the ADSK fingerprint in algo
and the GPGME_CREATE_ADSK flag.
2024-05-22 10:16:19 +02:00
Ingo Klöcker
90eb80134b
cpp: Add information about revocation keys to Key
* lang/cpp/src/gpgmefw.h (gpgme_revocation_key_t): New forward
declaration.
* lang/cpp/src/key.cpp, lang/cpp/src/key.h (class Key): New methods
revocationKey, numRevocationKeys, revocationKeys.
(class RevocationKey): New.
(swap): New overload for RevocationKey.
(operator<<): New overload for RevocationKey.
* lang/cpp/src/key.cpp (operator<<): Add information about revocation
keys to the output stream for Key.

* lang/cpp/tests/run-keylist.cpp (main): Don't output Key if nextKey
failed, e.g. at the end of the key listing.
--

GnuPG-bug-id: 7118
2024-05-21 16:38:59 +02:00
Ingo Klöcker
f2575b6313
json: Add information about revocation keys to key list result
* src/gpgme-json.c (revocation_key_to_json): New.
(key_to_json): Add list of revocation keys.

* tests/json/Makefile.am (pubring-stamp): Import new pub key.
* tests/json/key-with-revokers.asc: New.
* tests/json/t-json.c (tests): Add "t-keylist-revokers".
* tests/json/t-keylist-revokers.in.json,
tests/json/t-keylist-revokers.in.json: New.
--

GnuPG-bug-id: 7118
2024-05-21 16:38:59 +02:00
Ingo Klöcker
adadfac997
core: Add information about revocation keys to keys
* src/gpgme.h.in (struct _gpgme_revocation_key,
gpgme_revocation_key_t): New.
(struct _gpgme_key): Add fields 'revkeys', '_last_revkey'.
* src/key.c (_gpgme_key_add_rev_key): New.
(gpgme_key_unref): Free revkeys.
* src/keylist.c (keylist_colon_handler): Parse rvk lines.
* src/ops.h (_gpgme_key_add_rev_key): New.

* tests/run-keylist.c (main): Print revocation key info.
--

GnuPG-bug-id: 7118
2024-05-21 16:38:59 +02:00
Werner Koch
ac4bf86bb6
tests: Fix segv in t-json.c
* tests/json/t-json.c (test_contains): Avoid calling recusivly with no
child.
2024-05-21 14:36:07 +02:00
Werner Koch
55a1ae4163
tests: Avoid some compiler warnings.
* tests/gpg/t-support.h (fail_with_syserr): New.
(check_data): Use it to avoid compiler warnings.
* tests/run-support.h (fail_with_syserr): New.
--

I don't think that there is a way to tell gcc that
gpgme_err_code_from_errno will never return 0.  Thus we better use a
different macro.
2024-05-21 13:45:02 +02:00
Ingo Klöcker
c933269d3a
qt: Avoid bogus stringop-overread warning
* lang/qt/src/threadedjobmixin.cpp (_detail::audit_log_as_html): Use
QByteArray overload of QString::fromUtf8.
--

There's no need to make the code more complicated than necessary. Unless
we want to provoke weird compiler warnings. :-)
2024-05-21 12:36:11 +02:00
Ingo Klöcker
333241b286
qt: Fix warning about missing return
* lang/qt/src/qgpgmeexportjob.cpp (ExportJob::exec): Return a value and
remove unused argument names.
--

ExportJob::exec is never executed because its virtual overload is always
used. Therefore it doesn't matter what value we return.
2024-05-21 12:24:31 +02:00
Werner Koch
73403a8ba0
core: speedup gpgme_get_key
* src/engine.c (_gpgme_set_engine_info): Change engine_get_version.
--

GnuPG-bug-id: 6369
2024-05-21 10:59:43 +02:00
NIIBE Yutaka
0f5e8182e7
m4: Update libassuan.m4 from master.
* m4/libassuan.m4: Update.

--

Signed-off-by: NIIBE Yutaka <gniibe@fsij.org>
2024-05-17 14:22:36 +09:00
Ingo Klöcker
3e3db5784f
Require at least libgpg-error 1.47
* configure.ac (NEED_GPG_ERROR_VERSION): Require 1.47.
--

Libgpg-error 1.47 has been released more than 1 year ago and we use a
new error code defined in this version.

GnuPG-bug-id: 6971
2024-05-16 10:29:50 +02:00
NIIBE Yutaka
87061c0260
gpgme.m4: Set $host correctly always.
* src/gpgme.m4 (AM_PATH_GPGME): Add AC_CANONICAL_HOST.

--

GnuPG-bug-id: 7114
Reported-by: Andreas Metzler
Signed-off-by: NIIBE Yutaka <gniibe@fsij.org>
2024-05-16 09:27:58 +09:00
Ingo Klöcker
a73a41109f
tests: Fix test after changed behavior of gpgme_op_verify
* tests/gpg/t-verify.c (main): Change assertion of test.
--

The change introduced with 1dc44b7c makes gpg abort the verification
of a clear-signed message if it encounters garbage following the
signed data. We have to adapt the test to this change.

GnuPG-bug-id: 6907
2024-05-15 11:53:06 +02:00
NIIBE Yutaka
06db03ea9b
doc: Update use of Autoconf with PKG_CHECK_MODULES.
--

Signed-off-by: NIIBE Yutaka <gniibe@fsij.org>
2024-05-14 11:42:24 +09:00
NIIBE Yutaka
882ccc8ea7
gpgme.m4: Update _AM_PATH_GPGRT_CONFIG macro from gpg-error.m4.
* src/gpgme.m4 (_AM_PATH_GPGRT_CONFIG): Update.

--

Signed-off-by: NIIBE Yutaka <gniibe@fsij.org>
2024-05-14 10:30:47 +09:00
Ingo Klöcker
e4a95746ad
cpp: Handle smart card op failure status messages
* lang/cpp/src/editinteractor.cpp (parse_sc_op_failure): New.
(CallbackHelper::edit_interactor_callback_impl): Parse failure code on
GPGME_STATUS_SC_OP_FAILURE status.
(sc_op_failure_to_error): New.
--

This converts a SC_OP_FAILURE status message logged by gpg to a
corresponding error. Unfortunately, GPG_ERR_BAD_PIN and
GPG_ERR_BAD_RESET_CODE are mapped to the same SC_OP_FAILURE code, so
that we had to choose one.

GnuPG-bug-id: 6971
2024-04-05 15:08:01 +02:00
Andre Heinecke
67057d83f5
Qt: Fix windows build of new jobs
--
See git log for changes.
2024-03-13 13:15:41 +01:00
Ingo Klöcker
7158397c09
core: Check STATUS_FAILURE in import operations.
* src/import.c (op_data_t): Add failure_code.
(_gpgme_import_status_handler): Set it. Return it on EOF.
--

GnuPG-bug-id: 7036
2024-03-11 13:53:18 +01:00
Tobias Fella
47f3d92bf3
qt: Add function for synchronously executing ExportJob
* lang/qt/src/exportjob: Add exec function.
* lang/qt/src/qgpgmeexportjob.cpp: Implement exec function.
* lang/qt/src/qgpgmeexportjob.h: Override exec function.

--

GnuPG-Bug-Id: 6893
2024-01-22 11:24:49 +01:00
Ingo Klöcker
0011412193
qt: Remove superfluous virtual overrides and member variables
* lang/qt/src/qgpgmeaddexistingsubkeyjob.cpp
(QGpgMEAddExistingSubkeyJob::exec): Remove call of resultHook.
* lang/qt/src/qgpgmedecryptjob.cpp (QGpgMEDecryptJob::exec): Remove
call of resultHook.
(QGpgMEDecryptJob::resultHook): Remove.
* lang/qt/src/qgpgmedecryptjob.h (QGpgMEDecryptJob): Remove resultHook
override. Remove member mResult.
* lang/qt/src/qgpgmedecryptverifyjob.cpp (QGpgMEDecryptVerifyJob::exec):
Remove call of resultHook.
(QGpgMEDecryptVerifyJob::resultHook): Remove.
* lang/qt/src/qgpgmedecryptverifyjob.h (QGpgMEDecryptVerifyJob): Remove
resultHook override. Remove member mResult.
* lang/qt/src/qgpgmeencryptjob.cpp (QGpgMEEncryptJob::exec): Remove
call of resultHook.
(QGpgMEEncryptJob::resultHook): Remove.
* lang/qt/src/qgpgmeencryptjob.h (QGpgMEEncryptJob): Remove resultHook
override. Remove member mResult.
* lang/qt/src/qgpgmegpgcardjob.cpp (QGpgMEGpgCardJob::exec): Remove
call of resultHook.
* lang/qt/src/qgpgmeimportfromkeyserverjob.cpp
(QGpgMEImportFromKeyserverJob::exec): Remove call of resultHook.
(QGpgMEImportFromKeyserverJob::resultHook): Remove.
* lang/qt/src/qgpgmeimportfromkeyserverjob.h
(QGpgMEImportFromKeyserverJob): Remove resultHook override. Remove
member mResult.
* lang/qt/src/qgpgmeimportjob.cpp (QGpgMEImportJob::exec): Remove call
of resultHook.
(QGpgMEImportJob::resultHook): Remove.
* lang/qt/src/qgpgmeimportjob.h (QGpgMEImportJob): Remove resultHook
override. Remove member mResult.
* lang/qt/src/qgpgmekeyformailboxjob.cpp (QGpgMEKeyForMailboxJob::exec):
Remove call of resultHook.
* lang/qt/src/qgpgmekeylistjob.cpp (QGpgMEKeyListJob::QGpgMEKeyListJob):
Remove initialization of mResult.
(QGpgMEKeyListJob::resultHook): Do not set (removed) mResult.
* lang/qt/src/qgpgmekeylistjob.h (QGpgMEKeyListJob): Remove member
mResult.
* lang/qt/src/qgpgmelistallkeysjob.cpp
(QGpgMEListAllKeysJob::QGpgMEListAllKeysJob): Remove initialization of
mResult.
(QGpgMEListAllKeysJob::exec): Remove call of resultHook.
(QGpgMEListAllKeysJob::resultHook): Remove.
* lang/qt/src/qgpgmelistallkeysjob.h (QGpgMEListAllKeysJob): Remove
resultHook override. Remove member mResult.
* lang/qt/src/qgpgmereceivekeysjob.cpp (QGpgMEReceiveKeysJob::exec):
Remove call of resultHook.
(QGpgMEReceiveKeysJob::resultHook): Remove.
* lang/qt/src/qgpgmereceivekeysjob.h (QGpgMEReceiveKeysJob): Remove
resultHook override. Remove member mResult.
* lang/qt/src/qgpgmerevokekeyjob.cpp (QGpgMERevokeKeyJob::exec): Remove
call of resultHook.
* lang/qt/src/qgpgmesignencryptjob.cpp (QGpgMESignEncryptJob::exec):
Remove call of resultHook.
(QGpgMESignEncryptJob::resultHook): Remove.
* lang/qt/src/qgpgmesignencryptjob.h (QGpgMESignEncryptJob): Remove
resultHook override. Remove member mResult.
* lang/qt/src/qgpgmesignjob.cpp (QGpgMESignJob::exec): Remove call of
resultHook.
(QGpgMESignJob::resultHook): Remove.
* lang/qt/src/qgpgmesignjob.h (QGpgMESignJob): Remove resultHook
override. Remove member mResult.
* lang/qt/src/qgpgmeverifydetachedjob.cpp
(QGpgMEVerifyDetachedJob::exec): Remove call of resultHook.
(QGpgMEVerifyDetachedJob::resultHook): Remove.
* lang/qt/src/qgpgmeverifydetachedjob.h (QGpgMEVerifyDetachedJob):
Remove resultHook override. Remove member mResult.
* lang/qt/src/qgpgmeverifyopaquejob.cpp (QGpgMEVerifyOpaqueJob::exec):
Remove call of resultHook.
(QGpgMEVerifyOpaqueJob::resultHook): Remove.
* lang/qt/src/qgpgmeverifyopaquejob.h (QGpgMEVerifyOpaqueJob): Remove
resultHook override. Remove member mResult.
* lang/qt/src/qgpgmewkdlookupjob.cpp (QGpgMEWKDLookupJob::exec):
Remove call of resultHook.
--

All overrides of resultHook (except for the one of QGpgMEKeyListJob)
are superfluous. All the resultHook overrides do is store the result in
a member variable which is then returned in exec() (which just before
returning calls resultHook). The member variable the result is stored in
is only ever used by exec(). So exec() can simply return the result
directly. Some Job subclasses call resultHook without overriding it.
That's equally useless because the default implementation of resultHook
is empty. The only resultHook override that does anything useful is the
one of QGpgMEKeyListJob.
2024-01-19 16:07:14 +01:00
Ingo Klöcker
eae22d9a48
qt: Remove left-over mentions of showErrorDialog
* lang/qt/src/qgpgmedecryptjob.cpp,
lang/qt/src/qgpgmeimportfromkeyserverjob.cpp,
lang/qt/src/qgpgmeimportjob.cpp: Remove obsolete comment.
* lang/qt/src/qgpgmekeylistjob.cpp,
lang/qt/src/qgpgmelistallkeysjob.cpp: Remove long obsolete, #if 0'ed out
definitions of showErrorDialog.
--

Informing the users about errors is the responsibility of the users of
the QGpgME Job API since a long time.
2024-01-19 15:44:22 +01:00
Ingo Klöcker
cc1f2b5acb
build: Re-add still needed custom changes to Python autoconf macro
* m4/ax_python_devel.m4: Do not emit 'HAVE_PYTHON'.
--

This reapplies the changes made with 5189c08 that are still needed for
detecting multiple Python versions.
2024-01-16 09:58:33 +01:00
Ingo Klöcker
e3ae88267f
build: Update Python autoconf macro
* configure.ac: Call AX_PYTHON_DEVEL with new "optional" argument.
* m4/ax_python_devel.m4: Replace with current version from the autoconf
archive.
--

The new "optional" argument allows us to leave out one of our custom
changes.
2024-01-16 09:53:39 +01:00
Werner Koch
18388f93ab
doc: Add a deprecated warning to gpgme_op_delete. 2024-01-15 11:12:29 +01:00
Werner Koch
b37efb11be
doc: Fix minor typo.
--

Reported-by: Ming Kuang
2024-01-15 08:30:01 +01:00
Ingo Klöcker
85c7a94d63
cpp,tests: Launch dirmngr with gpg-conf
* lang/cpp/tests/run-wkdlookup.cpp (main): Replace backslashes with
forward slashes in homedir returned by GpgME::dirInfo. Use "gpgconf
--launch dirmngr" to start dirmngr.
--

With this change the same code as by QGpgMEWKDLookupJob is again used to
launch dirmngr. It also fixes the bad example of starting dirmngr
without the help of gpgconf.

GnuPG-bug-id: 6833
2024-01-09 11:22:43 +01:00
Ingo Klöcker
7e520213c0
qt: Pass home directory with forward slashes when launching dirmngr
* lang/qt/src/qgpgmewkdlookupjob.cpp (startDirmngr): Replace backslashes
with forward slashes in homedir returned by GpgME::dirInfo.
--

This works around a bug which causes backslashes to be escaped (doubled)
twice on Windows, once by gpgme_op_spawn and once by the spawn helper
gpgme-w32spawn. The next versions of GnuPG 2.2 and 2.4 also have a
workaround for this.

GnuPG-bug-id: 6833
2024-01-09 11:13:51 +01:00
Tobias Fella
d60d1b7f79
qt: Fix validity for (sub)keys generated using QGpgMEQuickJob
* lang/qt/src/qgpgmequickjob.cpp: Fix expiration calculation
--

The job calculates the validity as the seconds since epoch,
while GPG expects the seconds since the current time.
This leads to the validity being significantly longer than expected.

GnuPG-Bug-Id: 6889
2024-01-08 14:36:26 +01:00
Ingo Klöcker
18a0d72b1b
doc: Update NEWS
--

GnuPG-bug-id: 6550
2024-01-05 13:48:22 +01:00
Ingo Klöcker
c631622484
qt: Support verification of detached signatures directly from files
* lang/qt/src/Makefile.am: Add new files.
* lang/qt/src/job.cpp (VerifyDetachedJob): Move definition of
constructor and destructor and inclusion of the moc file to the
corresponding .cpp file.
* lang/qt/src/verifydetachedjob.cpp: New.
* lang/qt/src/verifydetachedjob.h (VerifyDetachedJob): Add member
functions setSignatureFile, signatureFile, setSignedFile, signedFile.
* lang/qt/src/verifydetachedjob_p.h: New.
* lang/qt/src/qgpgmeverifydetachedjob.cpp (class
QGpgMEVerifyDetachedJobPrivate): New.
(QGpgMEVerifyDetachedJob::QGpgMEVerifyDetachedJob): Instantiate private
job class.
(verify_from_filename): New.

* lang/qt/tests/Makefile.am: Add new test program.
* lang/qt/tests/run-verifydetachedjob.cpp: New.
--

This makes it possible to tell gpg to read the input directly from the
specified files bypassing GpgME's Data IO when verifying a detached
signature.

GnuPG-bug-id: 6550
2024-01-05 12:10:22 +01:00
Ingo Klöcker
1dc44b7c5b
core: Tell gpg that we want to verify signed data
* src/engine-gpg.c (gpg_verify): Add "--verify" to command line.
--

Since GnuPG 2.1.16 --verify writes the signed data to the file specified
by --output. Explicitly telling gpg that we want to verify signed data
frees gpg from guessing what we want and avoids the corresponding
warning "no command supplied.  Trying to guess what you mean ..."

GnuPG-bug-id: 6907
2023-12-22 10:37:34 +01:00
Ingo Klöcker
0b3c8709f7
qt,doc: Document that Job::startIt() doesn't self-destruct Job on error
--
GnuPG-bug-id: 6550
2023-12-22 10:35:15 +01:00
Ingo Klöcker
e77a8ac0cc
qt: Support verification of opaque signed data directly to/from files
* lang/qt/src/Makefile.am: Add new files.
* lang/qt/src/job.cpp (VerifyOpaqueJob): Move definition of constructor
and destructor and inclusion of the moc file to the corresponding .cpp
file.
* lang/qt/src/verifyopaquejob.cpp: New.
* lang/qt/src/verifyopaquejob.h (VerifyOpaqueJob): Add member
functions setInputFile, inputFile, setOutputFile, outputFile.
* lang/qt/src/verifyopaquejob_p.h: New.
* lang/qt/src/qgpgmeverifyopaquejob.cpp (class
QGpgMEVerifyOpaqueJobPrivate): New.
(QGpgMEVerifyOpaqueJob::QGpgMEVerifyOpaqueJob): Instantiate private
job class.
(verify_from_filename): New.

* lang/qt/tests/Makefile.am: Add new test program.
* lang/qt/tests/run-verifyopaquejob.cpp: New.
--

This makes it possible to tell gpg to read the input and write the
output directly to a specified file bypassing GpgME's Data IO when
verifying an opaque signed (or clear signed) file.

GnuPG-bug-id: 6550
2023-12-22 10:05:16 +01:00
Ingo Klöcker
20b32e0350
qt: Support decryption (with verification) directly to/from files
* lang/qt/src/Makefile.am: Add new files.
* lang/qt/src/job.cpp (DecryptVerifyJob): Move definition of constructor
and destructor and inclusion of the moc file to the corresponding .cpp
file.
* lang/qt/src/decryptverifyjob.cpp: New.
* lang/qt/src/decryptverifyjob.h (DecryptVerifyJob): Add member
functions setInputFile, inputFile, setOutputFile, outputFile.
* lang/qt/src/decryptverifyjob_p.h: New.
* lang/qt/src/qgpgmedecryptverifyjob.cpp (class
QGpgMEDecryptVerifyJobPrivate): New.
(QGpgMEDecryptVerifyJob::QGpgMEDecryptVerifyJob): Instantiate private
job class.
(decrypt_verify_from_filename): New.

* lang/qt/tests/Makefile.am: Add new test program.
* lang/qt/tests/run-decryptverifyjob.cpp: New.
--

This makes it possible to tell gpg to read the input and write the
output directly to a specified file bypassing GpgME's Data IO when
decrypting (and verifying) a file.

GnuPG-bug-id: 6550
2023-12-22 10:01:17 +01:00
Ingo Klöcker
a44d84772d
qt: Support writing/reading signed/encrypted files directly to/from file
* lang/qt/src/Makefile.am: Add new files.
* lang/qt/src/job.cpp (EncryptJob, SignJob, SignEncryptJob): Move
definition of constructor and destructor and inclusion of the moc file
to the corresponding .cpp files.
* lang/qt/src/encryptjob.cpp (EncryptJob): Define constructor. Define
destructor as default. Include moc file.
* lang/qt/src/encryptjob.cpp, lang/qt/src/encryptjob.h (EncryptJob):
Add member functions setRecipients, recipients, setInputFile, inputFile,
setOutputFile, outputFile, setEncryptionFlags, encryptionFlags.
* lang/qt/src/encryptjob_p.h (EncryptJobPrivate): Add members
m_recipients, m_inputFilePath, m_outputFilePath, m_encryptionFlags.
* lang/qt/src/qgpgmeencryptjob.cpp (encrypt_to_filename): New.
(QGpgMEEncryptJobPrivate::startIt): Start the job with the values
from the member variables.
* lang/qt/src/qgpgmesignencryptjob.cpp (sign_encrypt_to_filename): New.
(QGpgMESignEncryptJobPrivate::startIt): Start the job with the values
from the member variables.
* lang/qt/src/qgpgmesignjob.cpp (class QGpgMESignJobPrivate): New.
(QGpgMESignJob::QGpgMESignJob): Instantiate private job class.
(sign_to_filename): New.
* lang/qt/src/signencryptjob.cpp (SignEncryptJob): Define constructor.
Define destructor as default. Include moc file.
* lang/qt/src/signencryptjob.cpp, lang/qt/src/signencryptjob.h
(SignEncryptJob): Add member functions setSigners, signers,
setRecipients, recipients, setInputFile, inputFile, setOutputFile,
outputFile, setEncryptionFlags, encryptionFlags.
* lang/qt/src/signencryptjob_p.h (SignEncryptJobPrivate): Add members
m_signers, m_recipients, m_inputFilePath, m_outputFilePath,
m_encryptionFlags.
* lang/qt/src/signjob.cpp: New.
* lang/qt/src/signjob.h (SignJob): Add member functions setSigners,
signers, setInputFile, inputFile, setOutputFile, outputFile,
setSigningFlags, signingFlags.
* lang/qt/src/signjob_p.h: New.
* lang/qt/tests/Makefile.am: Add new test programs.
* lang/qt/tests/run-encryptjob.cpp: New.
* lang/qt/tests/run-signjob.cpp: New.
--

This makes it possible to tell gpg to read the input and write the
output directly to a specified file bypassing GpgME's Data IO when
signing and/or encrypting a file.

GnuPG-bug-id: 6550
2023-12-21 11:49:23 +01:00
Ingo Klöcker
b166958b86
qt: Remove dead code
* lang/qt/src/qgpgmeencryptjob.cpp,
lang/qt/src/qgpgmesignencryptjob.cpp, lang/qt/src/qgpgmesignjob.cpp:
Remove long commented out showErrorDialog member function definitions.
--

Displaying error messages is delegated to the job users since ages.
2023-12-21 09:12:43 +01:00
Ingo Klöcker
60c0fd7c95
cpp: Support new flags for direct signing/encryption of files
* lang/cpp/src/context.h (enum EncryptionFlags): Add constant
EncryptFile.
* lang/cpp/src/global.h (enum SignatureMode): Add constant SignFile.
* lang/cpp/src/context.cpp (sigflags2sigflags): Handle new flag
SignFile.
(encryptflags2encryptflags): Handle new flag EncryptFile.
(operator<<): Add new flags to the corresponding debug streams.
* lang/cpp/src/signingresult.cpp (CreatedSignature::mode): Handle
new flag SignFile (even if it cannot occur).
--

GnuPG-bug-id: 6550
2023-12-19 14:01:18 +01:00
Ingo Klöcker
5efd3486a9
core: Support writing the decrypt/verify output directly to a file
* src/engine-gpg.c (gpg_decrypt): Pass output file name to gpg if output
has file name set.
(gpg_verify): Ditto.

* tests/run-decrypt.c (show_usage): New option --output.
(main): Parse new option. Set file name on output if --output is given.
Do not print output if --output is given.
* tests/run-verify.c (show_usage): New option --output.
(main): Parse new option. Set file name on output if --output is given.
--

This change makes it possible to tell gpg to write the output (i.e. the
decrypted/verified data) directly to a file with given file name instead
of piping the output back to gpgme.

GnuPG-bug-id: 6550
2023-12-19 13:12:59 +01:00
Ingo Klöcker
963ace1f9f
core: Support direct signing of file with gpg
* src/gpgme.h.in (GPGME_SIG_MODE_FILE): New signature mode flag.
* src/engine-gpg.c (gpg_sign): Separate signature mode from additional
flags. Check for incompatible flags. Explicitly set output to stdout if
no output file is used. Pass filename instead of fd to gpg when new flag
is set.
* src/engine-gpgsm.c (gpgsm_sign): Return error if new flag is set.
* src/engine-uiserver.c (uiserver_sign): Ditto.
* src/sign.c (sign_start): Consider new flag on check for invalid flags.

* tests/run-sign.c (show_usage): New options --detach and
--direct-file-io.
(main): Parse new options. Create a detached signature if --detach is
given. Make gpg read the input file itself if --direct-file-io is given.
--

With this change the gpgme_op_sign* functions gain the possibility to
make gpg read the data to sign directly from a file instead of from an
input FD to which it is written by gpgme.

GnuPG-bug-id: 6550
2023-12-19 13:09:33 +01:00
Ingo Klöcker
0221d7f28a
core: Support direct encryption of file with gpg
* src/gpgme.h.in (GPGME_ENCRYPT_FILE): New encryption flag.
* src/engine-gpg.c (gpg_encrypt, gpg_encrypt_sign): Check for
incompatible flags. Pass filename instead of fd to gpg when new flag is
set.
* src/engine-gpgsm.c (gpgsm_encrypt): Return error if new flag is set.
* src/engine-uiserver.c (uiserver_encrypt): Ditto.

* tests/run-encrypt.c (show_usage): New option --direct-file-io.
(main): Parse new option. Make gpg read the input file itself if the
option is given.
--

With this change the gpgme_op_encrypt* and gpgme_op_encrypt_sign*
functions gain the possibility to make gpg read the data to (sign and)
encrypt directly from a file instead of from an input FD to which it is
written by gpgme.

GnuPG-bug-id: 6550
2023-12-19 13:07:45 +01:00
Ingo Klöcker
b35bcf0040
doc: Fix documentation for creating encrypted/signed archive
--

The previous paragraph already explains where/how the result is stored.
In particular, it's not always "returned in the data object ...".
2023-12-14 09:29:43 +01:00
Ingo Klöcker
d5dafb2ae3
qt: Replace Q_FOREACH with range-for
* lang/qt/src/qgpgmekeyformailboxjob.cpp (do_work): Replace Q_FOREACH
with range-for.
* lang/qt/src/qgpgmekeylistjob.cpp (QGpgMEKeyListJob::resultHook):
Ditto.
* lang/qt/src/threadedjobmixin.cpp (_detail::audit_log_as_html): Ditto.
* lang/qt/tests/t-keylist.cpp (KeyListTest::testPubkeyAlgoAsString):
Ditto.
* lang/qt/tests/t-keylocate.cpp (KeyLocateTest::testDaneKeyLocate,
KeyLocateTest::testKeyLocateSingle): Ditto.
* lang/qt/src/qgpgmesignencryptjob.cpp (sign_encrypt): Replace Q_FOREACH
with range-for. Add braces around single statement blocks.
* lang/qt/src/qgpgmesignjob.cpp (sign): Ditto.
* lang/qt/src/qgpgmenewcryptoconfig.cpp
(QGpgMENewCryptoConfig::reloadConfiguration,
QGpgMENewCryptoConfig::sync,
QGpgMENewCryptoConfigComponent::setComponent,
QGpgMENewCryptoConfigEntry::urlValueList,
QGpgMENewCryptoConfigEntry::setURLValueList): Replace Q_FOREACH with
range-for. Fix indentation. Add braces around single statement blocks.
--

Where necessary the iterated object is wrapped with qAsConst to avoid
deep copies of the iterated object.
2023-12-13 13:16:21 +01:00
Ingo Klöcker
f7d69de030
qt: Replace Q_NULLPTR with nullptr
* lang/qt/src/defaultkeygenerationjob.h, lang/qt/src/qgpgmebackend.h,
lang/qt/src/quickjob.h, lang/qt/src/threadedjobmixin.h: Replace all
occurrences of Q_NULLPTR with nullptr.
--
2023-12-13 13:04:32 +01:00
Andre Heinecke
6baccdc0c3
core: percent decode filename
* src/op-support.c (_gpgme_parse_plaintext): Decode filename
as percent string.

--
From gnupg/doc/DETAILS:

    If a filename is available it gets printed as the third
    argument, percent-escaped as usual.

so we can use the usual percent decode function here.

GnuPG-Bug-Id: T6852
2023-11-30 00:06:08 +01:00
Werner Koch
f212de4a9e
Post release updates
--
2023-11-28 16:48:37 +01:00
Werner Koch
1a26db7175
Release 1.23.2 2023-11-28 16:42:59 +01:00
Ingo Klöcker
1bbe2d4b70
qt: Start dirmngr with gpgconf to avoid multiple instances
* lang/qt/src/qgpgmewkdlookupjob.cpp (startDirmngr): Use "gpgconf
--launch dirmngr" to start dirmngr.
--

Using gpgconf to start dirmngr prevents multiple instances to be started
by the concurrently running keyserver lookup and WKD lookup.

GnuPG-bug-id: 6833
2023-11-23 16:13:39 +01:00
Ingo Klöcker
618fea9e20
qt: On Windows, use UTF-8 when logging the error text
* lang/qt/src/debug.cpp (operator<<): On Windows, interpret the error
text as UTF-8 instead of local 8-bit encoding.
--

GnuPG-bug-id: 5960
2023-11-15 11:57:18 +01:00
Ingo Klöcker
278f92b189
qt: Remove left-over partial files more persistently
* lang/qt/src/Makefile.am: Add new files.
* lang/qt/src/cleaner.cpp, lang/qt/src/cleaner.h: New.
* lang/qt/src/util.cpp (PartialFileGuard::~PartialFileGuard): Call
Cleaner::removeFile instead of removeFile.
* lang/qt/src/util.cpp, lang/qt/src/util.h (removeFile): Remove.
--

If the initial attempt to remove the file fails then a Cleaner is
created that tries to remove the file at regular intervals (10 s)
and on destruction (which happens on application shutdown).

GnuPG-bug-id: 6584
2023-11-15 11:57:18 +01:00
NIIBE Yutaka
185ab7d7ba
doc: Fix for e.g. and i.e.
--

Signed-off-by: NIIBE Yutaka <gniibe@fsij.org>
2023-11-15 15:21:07 +09:00
Ingo Klöcker
77e982579c
core: Preserve more specific existing failure code
* src/decrypt.c (_gpgme_decrypt_status_handler): Ignore received failure
code if we already have a specific failure code.
* src/encrypt.c (_gpgme_encrypt_status_handler): Ditto.
* src/export.c (export_status_handler): Ditto.
* src/genkey.c (genkey_status_handler): Ditto.
* src/keylist.c (keylist_status_handler): Ditto.
* src/keysign.c (keysign_status_handler): Ditto.
* src/passwd.c (passwd_status_handler): Ditto.
* src/revsig.c (revsig_status_handler): Ditto.
* src/setexpire.c (setexpire_status_handler): Ditto.
* src/sign.c (_gpgme_sign_status_handler): Ditto.
* src/tofupolicy.c (tofu_policy_status_handler): Ditto.
* src/verify.c (_gpgme_verify_status_handler): Ditto.
--

Usually, a process emits at most one failure code. But some operations
like the creation of an encrypted archive involve multiple chained
processes, so that multiple failure codes can be received. We want to
keep the first specific failure code we received. Further failure codes
are only parsed if we received just an unspecific "general error" so
far.

GnuPG-bug-id: 6575
2023-11-14 13:51:24 +01:00
Werner Koch
1bfd5e92d0
tests: Add option --chain to run-keylist
* tests/run-keylist.c (xstrdup): New.
(main): Add option.
--

This allows to list the entire chain.
2023-11-10 09:45:35 +01:00
Ingo Klöcker
52d59d75ca
qt: Deprecate DefaultKeyGenerationJob
* lang/qt/src/defaultkeygenerationjob.h (class DefaultKeyGenerationJob):
Deprecate.
--

GnuPG generates Ed25519 keys by default and has switched to 3072 bits as
default for RSA keys. DefaultKeyGenerationJob always generates RSA 2048
keys and uses the old parameter file API of GnuPG. It shouldn't be used
anymore.

GnuPG-bug-id: 6805
2023-11-10 08:55:07 +01:00
Ingo Klöcker
ae332749ee
build,qt: Build Qt with -fPIC if required or requested
* configure.ac: Add option to enable building the Qt 6 binding with
-fPIC. Fix typo and mention default for --enable-no-direct-extern-access
option.
* m4/qt6.m4: Add -fPIC to GPGME_QT6_CFLAGS if requested or if Qt 6 was
built with reduce_relocations.
--

GnuPG-bug-id: 6781
2023-10-30 09:42:09 +01:00
Ingo Klöcker
cf88690cf4
Update NEWS
--
2023-10-27 16:14:01 +02:00
Ingo Klöcker
46f5d5eeb3
qt: Use temporary .part file names when creating archives
* lang/qt/src/util.h, lang/qt/src/util.cpp (class PartialFileGuard):
New.
* lang/qt/src/util.cpp (getRandomCharacters, createPartFileName): New.
* lang/qt/src/qgpgmeencryptarchivejob.cpp (encrypt_to_filename): Use
PartialFileGuard.
* lang/qt/src/qgpgmesignarchivejob.cpp (sign_to_filename): Ditto.
* lang/qt/src/qgpgmesignencryptarchivejob.cpp
(sign_encrypt_to_filename): Ditto.
--

When creating signed and/or encrypted archives, gpgtar now writes the
result to a temporary file name. On success, the archive is renamed to
the final file name. Otherwise, the (partially written) temporary file
is removed (if possible).

GnuPG-bug-id: 6721
2023-10-27 16:07:34 +02:00
Ingo Klöcker
8d8985bda1
qt: Refactor removal of output file on cancel or error
* lang/qt/src/util.h, lang/qt/src/util.cpp (removeFile): New.
* lang/qt/src/qgpgmeencryptarchivejob.cpp (encrypt): Move removal of
output file from here
(encrypt_to_filename): ... to here and use new function.
* lang/qt/src/qgpgmesignarchivejob.cpp (sign): Move removal of output
file from here
(sign_to_filename): ... to here and use new function.
* lang/qt/src/qgpgmesignencryptarchivejob.cpp (sign_encrypt): Move
removal of output file from here
(sign_encrypt_to_filename): ... to here and use new function.
--

GnuPG-bug-id: 6721
2023-10-27 16:07:34 +02:00
Werner Koch
0a0a5906d5
Post release updates
--
2023-10-27 14:41:52 +02:00
Werner Koch
cadcb38469
Release 1.23.1
--

This is minor fix to the spawn helper.  No change to the library code.

GnuPG-bug-id: 6774
2023-10-27 14:36:15 +02:00
Andre Heinecke
a0a4cd411c
Change gpgme-w32-spawn to unicode
* src/Makefile.am (gpgme_w32spawn_CFLAGS): Add -municode.
* src/gpgme-w32-spawn.c (build_commandline, my_spawn)
(translate_handles): Convert to wchar_t API.
(main): Use wmain instead.

--
Some time ago we introduced an inconsistency that w32-util called
gpgme-w32-spawn through CreateProcessW but since gpgme-w32-spawn
internally worked with 8 bit the chars were mangled and the
arguments not passed correctly through the CreateProcessA of the
child process. Since the GnuPG processes use GetCommandLineW
this is the proper way to pass on Unicode command line arguments.

Please note that we did not pass UTF-8 before this patch but
rather some broken native encoding where Windows replaces
unicode characters with question marks etc.

GnuPG-Bug-Id: T6728
2023-10-25 17:42:27 +02:00
Werner Koch
8faaf7b72b
Post release updates
--
2023-10-25 11:16:19 +02:00
Werner Koch
aae967ec9c
Release 1.23.0 2023-10-25 11:05:29 +02:00
Andre Heinecke
ab25df8328
qt: Handle cancel in changeexpiryjob
* lang/qt/src/qgpgmechangeexpiryjob.cpp (change_expiry): Return
cancel error.

--
The classical "cancel is not an error" problem.
GnuPG-Bug-Id: T6754
2023-10-18 11:13:35 +02:00
Ingo Klöcker
5c7e4d252a
qt,doc: Fix typos in source code comments
--

Anonymous contribution

Signed-off-by: Ingo Klöcker <dev@ingo-kloecker.de>
2023-10-13 09:23:24 +02:00
Ingo Klöcker
131384b107
python,doc: Fix typos in documentation and source code comments
--

Anonymous contribution

Signed-off-by: Ingo Klöcker <dev@ingo-kloecker.de>
2023-10-13 09:22:36 +02:00
Ingo Klöcker
bd448c9cbf
cpp,doc: Fix typos in API documentation and source code comments
--

Anonymous contribution

Signed-off-by: Ingo Klöcker <dev@ingo-kloecker.de>
2023-10-13 09:21:47 +02:00
Ingo Klöcker
57205c1dfa
doc: Fix typos in documentation and source code comments
--

Anonymous contribution

Signed-off-by: Ingo Klöcker <dev@ingo-kloecker.de>
2023-10-13 09:18:12 +02:00
Marius P
959f976dfc
python,examples: Add missing word "License"
* lang/python/examples/howto/add-userid.py,
lang/python/examples/howto/clear-sign-file.py,
lang/python/examples/howto/create-key.py,
lang/python/examples/howto/decrypt-file.py,
lang/python/examples/howto/detach-sign-file.py,
lang/python/examples/howto/encrypt-file.py,
lang/python/examples/howto/encrypt-sign-file.py,
lang/python/examples/howto/encrypt-to-group-gullible.py,
lang/python/examples/howto/encrypt-to-group-trustno1.py,
lang/python/examples/howto/encrypt-to-group.py,
lang/python/examples/howto/export-key.py,
lang/python/examples/howto/export-minimised-key.py,
lang/python/examples/howto/export-secret-key.py,
lang/python/examples/howto/export-secret-keys.py,
lang/python/examples/howto/groups.py,
lang/python/examples/howto/import-key.py,
lang/python/examples/howto/import-keybasekey.py,
lang/python/examples/howto/import-keys-hkp.py,
lang/python/examples/howto/import-keys.py,
lang/python/examples/howto/import-mailvelope-keys.py,
lang/python/examples/howto/keycount.py,
lang/python/examples/howto/local-sign-group.py,
lang/python/examples/howto/mutt-groups.py,
lang/python/examples/howto/pmkey-import-alt.py,
lang/python/examples/howto/pmkey-import-hkp-alt.py,
lang/python/examples/howto/pmkey-import-hkp.py,
lang/python/examples/howto/pmkey-import.py,
lang/python/examples/howto/revoke-userid.py,
lang/python/examples/howto/send-key-to-keyserver.py,
lang/python/examples/howto/sign-file.py,
lang/python/examples/howto/sign-key.py,
lang/python/examples/howto/symcrypt-file.py,
lang/python/examples/howto/temp-homedir-config.py,
lang/python/examples/howto/verify-signatures.py,
lang/python/examples/howto/verify-signed-file.py: Add "License" after
"Lesser General Public"
--

Anonymous contribution

Signed-off-by: Ingo Klöcker <dev@ingo-kloecker.de>
2023-10-13 09:08:39 +02:00
Ingo Klöcker
a9e5a25b56
cpp: Support new key capability flags
* lang/cpp/src/key.cpp, lang/cpp/src/key.h (class Key): New methods
hasCertify, hasSign, hasEncrypt, hasAuthenticate.
--

GnuPG-bug-id: 6748
2023-10-05 15:27:52 +02:00
Ingo Klöcker
0132a1089f
doc: Fix typo
--
2023-10-05 15:12:29 +02:00
Werner Koch
b63d203d3b
core: Add key capability flags has_encrypt etc.
* src/gpgme.h.in (struct _gpgme_key): Add flags has_encrypt,
has_certify, has_sign, and has_authenticate.
* src/keylist.c (finish_key): Set these flags.
* tests/run-keylist.c (main): Print them.
--

GnuPG-bug-id: 6748
2023-10-05 14:18:03 +02:00
Werner Koch
349a69b5ea
core: Check STATUS_FAILURE in export operations.
* src/export.c (op_data_t): Add failure_code.
(export_status_handler): Set it.
(gpgme_op_export_ext, gpgme_op_export_keys): Also check the failure
code.
--

That is just in case we missed an error code.  For example with older
gpg versions (e.g. 2.3.8) and exporting to a keyserver.
2023-10-05 14:17:21 +02:00
NIIBE Yutaka
8ad22290df
gpgme-tool: Support use of Windows HANDLE for INPUT/OUTPUT/MESSAGE.
* src/gpgme-tool.c [HAVE_W32_SYSTEM] (server_data_obj): Implement for
Windows HANDLE.

--

GnuPG-bug-id: 6634
Signed-off-by: NIIBE Yutaka <gniibe@fsij.org>
2023-09-29 11:12:13 +09:00
Ingo Klöcker
d43d787e9a
qt: Use UTF-8 for file names on Windows
* lang/qt/src/qgpgmedecryptverifyarchivejob.cpp
(decrypt_verify_from_file_name): On Windows, convert Unicode file name
to UTF-8.
* lang/qt/src/qgpgmeencryptarchivejob.cpp (encrypt,
encrypt_to_filename): On Windows, convert Unicode file name from/to
UTF-8.
* lang/qt/src/qgpgmesignarchivejob.cpp (sign, sign_to_filename): Ditto.
* lang/qt/src/qgpgmesignencryptarchivejob.cpp (sign_encrypt,
sign_encrypt_to_filename): Ditto.
--

On Windows, GnuPG expects file names to be UTF-8-encoded. This fixes
encrypting and decrypting folders with umlauts in the folder name and
in the file name of the archive. Encrypting and decrypting folders
with kanji still fails.

GnuPG-bug-id: 6728
2023-09-22 10:22:18 +02:00
Ingo Klöcker
4e321a0f06
build,qt: Autodetect whether Qt was built with -mno-direct-extern-access
* m4/qt6.m4: Check the build configuration of Qt 6 for
no_direct_extern_access.
--

If building with -mno-direct-extern-access has been neither enabled nor
disabled explicitly, then check whether Qt 6 was built with this flag.
The check is skipped, if we build for Windows.

GnuPG-bug-id: 6696
2023-09-21 22:53:00 +02:00
Ingo Klöcker
927f129663
build,qt: Optionally build Qt 6 bindings with -mno-direct-extern-access
* configure.ac: Check if C++ compiler supports
-mno-direct-extern-access. Add option to enable building with
-mno-direct-extern-access.
* m4/ax_check_compile_flag.m4: New.
* m4/qt6.m4: Add -mno-direct-extern-access to GPGME_QT6_CFLAGS if
supported and requested.
--

This adds the possibility to build the Qt 6 bindings with the
-mno-direct-extern-access flag. This is required if Qt 6 was built with
this flag. This is a workaround for the lack of Qt 6's pkgconfig files
providing this flag if needed.

GnuPG-bug-id: 6696
2023-09-21 10:58:27 +02:00
Ingo Klöcker
3e64856208
build,qt: Drop broken check for -fPIC
* m4/qt6.m4: Remove attempt to build a Qt program with -fPIC.
--

libtool already takes care of adding -fPIC. Moreover, building without
-fPIC succeeded even if Qt was built with -fPIC, i.e. the check didn't
work as intended.

GnuPG-bug-id: 6696
2023-09-21 10:45:09 +02:00
Ingo Klöcker
8fde9cbe22
tests: Re-add --with-secret option
* tests/run-keylist.c (main): Handle option --with-secret again.
--

Re-add handling of --with-secret option that was accidentally removed
with the previous commit.

GnuPG-bug-id: 6705
2023-09-04 17:31:18 +02:00
Werner Koch
e36b2d1bce
New mode to list a v5 fingerprint for v4 packets.
* src/gpgme.h.in (GPGME_KEYLIST_MODE_WITH_V5FPR): New.
(struct _gpgme_subkey): Add field v5fpr.
* src/engine-gpg.c (gpg_keylist_build_options): Pass new option to
gpg.
* src/key.c (gpgme_key_unref): Free new field.
* src/keylist.c (op_data_t): Parse and add "fp2" line.

* tests/run-keylist.c (show_usage): Add option --v5fpr.

* src/keylist.c (op_data_t): Add field failure_code.
(keylist_status_handler): Handle special value.
(gpgme_op_keylist_end): Return an error if a FAILURE line has been
seen.
--

Note that the failure code part has been added to better diagnose
problems if a wrong gpg version is used.  If verything works right we
should not get this because we check that the gnupg version sis either
>= 2.4.4 or less than 2.3 and >= 2.2.42.

Note further that the v5fpr field may also be used to get the SHA-256
fingerprint of X.509 certificates (even without passing the new mode
flag).

GnuPG-bug-id: 6705
2023-09-04 17:03:52 +02:00
NIIBE Yutaka
b80d52a1f7
build: Change the default for --with-libtool-modification.
* configure.ac (--with-libtool-modification): default=never.

--

GnuPG-bug-id: 6619
Signed-off-by: NIIBE Yutaka <gniibe@fsij.org>
2023-09-01 14:06:25 +09:00
Werner Koch
d75b2a9151
Support GPGME_ENCRYPT_ALWAYS_TRUST also for S/MIME.
* src/engine-gpgsm.c (gpgsm_encrypt): Send the always-trust options.

* tests/run-encrypt.c: Add option --always-trust.
--

Note that the run-encrypt test tool used to assume always-trust for
OpenPGP since 1.7.0 This bug has also been fixed by introducing the
explicit option.

GnuPG-bug-id: 6559
2023-08-31 12:02:02 +02:00
Ingo Klöcker
3f297387bf
qt: Allow specifying user IDs to use when refreshing keys via WKD
* lang/qt/src/wkdrefreshjob.h, lang/qt/src/wkdrefreshjob.cpp
(WKDRefreshJob::start): New overload.
* lang/qt/src/wkdrefreshjob_p.h (WKDRefreshJobPrivate): Add field
m_userIds.
* lang/qt/src/qgpgmewkdrefreshjob.cpp (toEmailAddresses): New.
(locate_external_keys): Change return type and arguments.
(refresh_keys): Remove.
(QGpgMEWKDRefreshJobPrivate::startIt): Get emails from keys or user IDs.
Remove duplicates. Call locate_external_keys instead of refresh_keys.

* lang/qt/tests/run-wkdrefreshjob.cpp (CommandLineOptions,
parseCommandLine): New.
(main): Support new option --all-userids.
--

The new start() overload allows to specify the user IDs to use for the
WKD lookup explicitly. This allows updating user IDs via WKD which were
originally not retrieved via WKD.

GnuPG-bug-id: 6672
2023-08-23 12:00:26 +02:00
Christian Hesse
aee18a2ab2
qt,tests: Fix build in source directory, part 2
* lang/qt/tests/Makefile.am (AM_CPPFLAGS): Include Qt binding sources
before C++ binding sources and C sources.
--

This fixes the problem that the debug.h in the C sources was found
before the one in the Qt bindings.

Commit d23528cadf fixed it for Qt5, we
need Qt6 as well.

GnuPG-bug-id: 6673
2023-08-22 11:15:01 +02:00
Ingo Klöcker
24a8c279da
build: Suggest out-of-source build
* autogen.rc (final_info): Suggest to run configure from a build
subdirectory.
--

We recommend out-of-source builds. The suggestion what to do next shown
by autogen.sh should reflect this.

GnuPG-bug-id: 6673
2023-08-21 21:32:40 +02:00
Ingo Klöcker
d23528cadf
qt,tests: Fix build in source directory
* lang/qt/tests/Makefile.am (AM_CPPFLAGS): Include Qt binding sources
before C++ binding sources and C sources.
--

This fixes the problem that the debug.h in the C sources was found
before the one in the Qt bindings.

GnuPG-bug-id: 6673
2023-08-21 21:08:01 +02:00
Ingo Klöcker
2ad36f7114
qt: Add job for refreshing OpenPGP keys via WKD
* lang/qt/src/wkdrefreshjob.cpp, lang/qt/src/wkdrefreshjob.h,
lang/qt/src/wkdrefreshjob_p.h, lang/qt/src/qgpgmewkdrefreshjob.cpp,
lang/qt/src/qgpgmewkdrefreshjob.h: New.
* lang/qt/src/protocol.h (class Protocol): Add pure virtual member
function wkdRefreshJob
* lang/qt/src/protocol_p.h (Protocol::wkdRefreshJob): ... and
implement it.
* lang/qt/src/Makefile.am: Update accordingly.

* lang/qt/tests/run-wkdrefreshjob.cpp: New.
* lang/qt/tests/Makefile.am: Add new test runner.
--

This job allows updating keys via WKD. Only user IDs that were
originally retrieved via WKD (i.e. which have origin WKD) are
considered.

GnuPG-bug-id: 6672
2023-08-21 18:06:52 +02:00
Ingo Klöcker
fb03a5b3df
doc: Fix interface changes
--

toLogString is in the QGpgME namespace (as everything else in the qt
bindings).
2023-08-21 10:19:09 +02:00
Werner Koch
cfeb62d358
Post release updates
--
2023-08-21 09:54:04 +02:00
Werner Koch
8ea7015a23
Release 1.22.0 2023-08-21 09:41:39 +02:00
NIIBE Yutaka
dacbd51c3f
build: New configure option --with-libtool-modification.
* Makefile.am (EXTRA_DIST): Add build-aux/libtool-patch.sed.
* build-aux/libtool-patch.sed: New.
* configure.ac (--with-libtool-modification): New.
* build-aux/ltmain.sh: Revert our own local modification.

--

Fixes-commit: e622e36f1f
GnuPG-bug-id: 6619
Signed-off-by: NIIBE Yutaka <gniibe@fsij.org>
2023-08-17 14:03:09 +09:00
Ingo Klöcker
40ca3d5896
qt: Clean up after failure or cancel of sign/encrypt archive operation
* lang/qt/src/qgpgmeencryptarchivejob.cpp (encrypt): Remove output file
if operation was canceled or failed.
* lang/qt/src/qgpgmesignarchivejob.cpp (sign): Ditto.
* lang/qt/src/qgpgmesignencryptarchivejob.cpp (sign_encrypt): Ditto.

* lang/qt/tests/run-encryptarchivejob.cpp (CommandLineOptions): Add
field cancelTimeout.
(parseCommandLine): Add option --cancel-after. Parse option value.
(main): Check for invalid cancel timeout. Start timer for canceling
the job.
* lang/qt/tests/run-signarchivejob.cpp (CommandLineOptions): Add
field cancelTimeout.
(parseCommandLine): Add option --cancel-after. Parse option value.
(main): Check for invalid cancel timeout. Start timer for canceling
the job.
--

This change ensures that the output file is removed if the creation of
a signed or encrypted archive was canceled or failed. The new option
of the test runners enables testing the cancelation of the jobs.

GnuPG-bug-id: 6584
2023-08-16 14:23:15 +02:00
Ingo Klöcker
c3171d0cf1
qt: Make toLogString helper public
* lang/qt/src/util.h: Move toLogString ...
* lang/qt/src/debug.h: ... here.
* lang/qt/tests/run-importjob.cpp (main): Use toLogString.
--

This allows using the helper in dependent projects without duplicating
it everywhere.

GnuPG-bug-id: 6584
2023-08-15 11:56:40 +02:00
Ingo Klöcker
7a2a3f317b
cpp: Remove unused include
--
2023-08-15 11:50:28 +02:00
Ingo Klöcker
150a2f9e4e
tests: Support offline mode in run-import
* tests/run-import.c (show_usage): New option --offline.
(main): Parse new option. Set offline mode accordingly.
--

This allows testing gpgme_op_import with (and without) offline mode.

GnuPG-bug-id: 6648
2023-08-14 14:04:44 +02:00
Ingo Klöcker
bc98f01c85
core: Use offline mode for all operations of gpgsm engine
* src/engine-backend.h (keylist, keylist_ext): Remove engine_flags.
* src/engine-gpg.c (gpg_keylist, gpg_keylist_ext): Ditto.
* src/engine.c, src/engine.h (_gpgme_engine_op_keylist): Ditto.
(_gpgme_engine_op_keylist_ext): Ditto.
* src/engine.h (GPGME_ENGINE_FLAG_OFFLINE): Remove.
* src/engine-gpgsm.c (struct engine_gpgsm): New field flags with offline
flag.
(have_gpgsm_version): New.
(gpg_set_engine_flags): Set the offline flag.
(start): Send OPTION "offline".
(gpgsm_keylist, gpgsm_keylist_ext): Remove engine_flags.  Remove
sending of OPTION "offline".
* src/keylist.c (gpgme_op_keylist_start, gpgme_op_keylist_ext_start):
Remove setting of offline flag.
--

GnuPG-bug-id: 6648
2023-08-14 12:24:00 +02:00
Ingo Klöcker
d72811a2c0
core: Store engine's version string in gpgsm engine
* src/engine-gpgsm.c (struct engine_gpgsm): Add field 'version'.
(gpgsm_new): Copy version string.
(gpgsm_release): Free VERSION.
--

GnuPG-bug-id: 6648
2023-08-14 12:23:55 +02:00
Carl Schwan
8701e98937
cpp: Expose gpgme_decrypt_result_t.is_mime through cpp API
* lang/cpp/src/descriptionresult.cpp (DescriptionResult::isMime): New.
* lang/cpp/src/descriptionresult.h: Update accordingly.

--
This exposes the is_mime metadata from a decryption result to users
of the C++ library.

GnuPG-bug-id: 6199
Signed-off-by: Carl Schwan <carl.schwan@gnupg.com>
2023-08-04 11:34:27 +02:00
Carl Schwan
d91d037fc1
qt: Add setInputEncoding to QGpgMe::EncryptJob
* lang/qt/src/encryptjob.cpp, lang/qt/src/encryptjob.h,
lang/qt/src/encryptjob_p.h: Add inputEncoding/setInputEncoding
to EncryptJob
* lang/qt/src/qgpgmeencryptjob.cpp: Use newly added inputEncoding
to set encoding hint of the encrypted content
--

This allows applications like KMail to set the input encoding of the
encrypted content, which simplify and improve the performance of
identifying the content type then decrypting it.

GnuPG-bug-id: 6616
Signed-off-by: Carl Schwan <carl.schwan@gnupg.com>
2023-08-03 11:53:06 +02:00
Ingo Klöcker
a9b28c79e9
core: Prevent wrong plaintext when verifying clearsigned signature
* src/engine-gpg.c (gpg_verify): Use a separate pipe instead of stdout
for reading the plaintext.

* tests/gpg/t-support.h (PGM): Define if undefined.
(print_data): Undefine BUF_SIZE.
(check_data): New.
* tests/gpg/t-verify.c (clearsigned_plus_key_block): New.
(main): Add test.
--

Reading the plaintext from stdout is a bad idea because gpg can also
print other stuff on stdout, e.g. the keys contained in a public key
block. This is fixed by reading the plaintext via a special pipe.

GnuPG-bug-id: 6622
2023-07-28 16:15:12 +02:00
Ingo Klöcker
777cf7f2d1
core: Return bad data error instead of general error on unexpected data
* src/verify.c (_gpgme_verify_status_handler): Return GPG_ERR_BAD_DATA
instead of GPG_ERR_GENERAL.
--

This gives users trying to decrypt and/or verify for example a public
key block a more useful error.

GnuPG-bug-id: 6617
2023-07-28 14:18:21 +02:00
NIIBE Yutaka
0518ed32e2
build: Update libassuan.m4 for libassuan version 3 in future.
* m4/libassuan.m4: Update from libassuan master.

--

New libassuan 3 has backward compatible API.

Signed-off-by: NIIBE Yutaka <gniibe@fsij.org>
2023-07-28 14:07:06 +09:00
Ingo Klöcker
e3defc0adf
qt: Ensure that we check the correct paths
* lang/qt/src/QGpgmeConfig-w32.cmake.in.in,
lang/qt/src/QGpgmeQt6Config-w32.cmake.in.in: Get paths to check from
the target properties.
--

This avoids the error present in an older version where the files to
check used the correct path, but a wrong path of the DLL was set in the
target properties.
2023-07-08 21:49:12 +02:00
Ingo Klöcker
be0e653ce3
qt: Fix DLL version in cmake config files
* lang/qt/src/QGpgmeConfig-w32.cmake.in.in,
lang/qt/src/QGpgmeQt6Config-w32.cmake.in.in: Fix name and path of DLL.
--

Co-authored-by: Biswapriyo Nath <nathbappai@gmail.com>
Signed-off-by: Ingo Klöcker <dev@ingo-kloecker.de>
2023-07-08 21:49:12 +02:00
Ingo Klöcker
ad34fcbbec
qt: Fix check for required files
* lang/qt/src/QGpgmeConfig-w32.cmake.in.in: Fix typos in variable names.
--

Because of those typos the loop over the files to check was an empty
loops and therefore the wrong name of the DLL was never noticed.
2023-07-08 21:49:12 +02:00
Werner Koch
546d3a982d
Post release updates
--
2023-07-07 14:01:51 +02:00
Werner Koch
5bf3e6d075
Release 1.21.0 2023-07-07 13:35:14 +02:00
NIIBE Yutaka
05ac1ce09f
build: Add BUILT_SOURCE for better dependency.
* Makefile.am (BUILT_SOURCE): Add conf/config.h.

--

GnuPG-bug-id: 6547
Signed-off-by: NIIBE Yutaka <gniibe@fsij.org>
2023-06-23 10:38:24 +09:00
Ingo Klöcker
1c2459a592
qt: Support reading signed/encrypted archives directly from a file
* lang/qt/src/decryptverifyarchivejob.cpp,
lang/qt/src/decryptverifyarchivejob.h (DecryptVerifyArchiveJob): Add
member functions setInputFile, inputFile.
* lang/qt/src/decryptverifyarchivejob_p.h
(DecryptVerifyArchiveJobPrivate): Add member m_inputFilePath.
* lang/qt/src/qgpgmedecryptverifyarchivejob.cpp (decrypt_verify): Move
creation of indata to decrypt_verify_from_io_device.
(decrypt_verify_from_io_device, decrypt_verify_from_file_name): New.
(QGpgMEDecryptVerifyArchiveJob::start): Use
decrypt_verify_from_io_device instead of decrypt_verify.
(QGpgMEDecryptVerifyArchiveJobPrivate::startIt): Start the job with the
values from member variables.

* lang/qt/tests/run-decryptverifyarchivejob.cpp (createInput): Remove.
(main): Remove creation of input. Make the job read the archive directly
from the given archive name.
--

This makes it possible to tell gpgtar to read the signed/encrypted
archive directly from a specified file bypassing GpgME's Data IO.

GnuPG-bug-id: 6530
2023-06-21 15:25:11 +02:00
Ingo Klöcker
1a9f192ab4
core: Support reading the archive to decrypt/verify directly from a file
* src/engine-gpg.c (add_file_name_arg_or_data): New.
(gpg_decrypt): Use add_file_name_arg_or_data instead of add_data for the
ciphertext.
(gpg_verify): Use add_file_name_arg_or_data instead of add_data for the
signature and the signed text.

* tests/run-decrypt.c (show_usage): New option --direct-file-io.
(main): Parse new option. If option is given, then don't open input
file, create simple data object instead of data object from stream and
set input file name on input data.
* tests/run-verify.c (show_usage): New option --direct-file-io.
(main): Parse new option. If option is given, then don't open input
files, create simple data objects instead of data objects from stream
and set input file names on input data objects.
--

This change makes it possible to tell gpg (and gpgtar) to read the
input (i.e. the signed/encrypted data or the signature or the created
archive) directly from the files with given file names instead of from
streams piped through GpgME's Data IO.

GnuPG-bug-id: 6530
2023-06-21 14:38:50 +02:00
Ingo Klöcker
e608315392
qt: Support writing signed/encrypted archives directly to a file
* lang/qt/src/encryptarchivejob.cpp, lang/qt/src/encryptarchivejob.h
(EncryptArchiveJob): Add member functions setRecipients, recipients,
setInputPaths, inputPaths, setOutputFile, outputFile,
setEncryptionFlags, encryptionFlags.
* lang/qt/src/encryptarchivejob_p.h (EncryptArchiveJobPrivate): Add
members m_recipients, m_inputPaths, m_outputFilePath, m_encryptionFlags.
* lang/qt/src/qgpgmeencryptarchivejob.cpp (encrypt): Move creation of
outdata to encrypt_to_io_device.
(encrypt_to_io_device, encrypt_to_filename): New.
(QGpgMEEncryptArchiveJob::start): Use encrypt_to_io_device instead of
encrypt.
(QGpgMEEncryptArchiveJobPrivate::startIt): Start the job with the
values from member variables.
* lang/qt/src/qgpgmesignarchivejob.cpp (sign): Move creation of
outdata to sign_to_io_device.
(sign_to_io_device, sign_to_filename): New.
(QGpgMESignArchiveJob::start): Use sign_to_io_device instead of sign.
(QGpgMESignArchiveJobPrivate::startIt): Start the job with the
values from member variables.
* lang/qt/src/qgpgmesignencryptarchivejob.cpp (sign_encrypt): Move
creation of outdata to sign_encrypt_to_io_device.
(sign_encrypt_to_io_device, sign_encrypt_to_filename): New.
(QGpgMESignEncryptArchiveJob::start): Use sign_encrypt_to_io_device
instead of sign_encrypt.
(QGpgMESignEncryptArchiveJobPrivate::startIt): Start the job with the
values from member variables.
* lang/qt/src/signarchivejob.cpp, lang/qt/src/signarchivejob.h
(SignArchiveJob): Add member functions setSigner, signers,
setInputPaths, inputPaths, setOutputFile, outputFile.
* lang/qt/src/signarchivejob_p.h (SignArchiveJobPrivate): Add
members m_signers, m_inputPaths, m_outputFilePath.
* lang/qt/src/signencryptarchivejob.cpp,
lang/qt/src/signencryptarchivejob.h (SignEncryptArchiveJob): Add
member functions setSigner, signers, setRecipients, recipients,
setInputPaths, inputPaths, setOutputFile, outputFile,
setEncryptionFlags, encryptionFlags.
* lang/qt/src/signencryptarchivejob_p.h (SignEncryptArchiveJobPrivate):
Add members m_signers, m_recipients, m_inputPaths, m_outputFilePath,
m_encryptionFlags.

* lang/qt/tests/run-encryptarchivejob.cpp (createOutput): Remove.
(checkOutputFilePath): New.
(main): Create file output writing to stdout if no archive name (or "-")
is given. Exit if file with given archive name already exists. Make
the jobs write the created archive directly to the given archive name.
* lang/qt/tests/run-signarchivejob.cpp (createOutput): Remove.
(checkOutputFilePath): New.
(main): Create file output writing to stdout if no archive name (or "-")
is given. Exit if file with given archive name already exists. Make
the jobs write the created archive directly to the given archive name.
--

This makes it possible to tell gpgtar to write the created archive
directly to a specified file bypassing GpgME's Data IO.

GnuPG-bug-id: 6530
2023-06-19 18:21:46 +02:00
Ingo Klöcker
c38b620039
core: Support writing the sign/encrypt output directly to a file
* src/engine-gpg.c (gpg_encrypt): Pass output file name to gpg if output
has file name set.
(gpg_encrypt_sign): Ditto.
(gpg_sign): Ditto.

* tests/run-encrypt.c (show_usage): New option --output.
(main): Parse new option. Set file name on output if --output is given.
Do not print output if --output is given.
* tests/run-sign.c (show_usage): New option --output.
(main): Parse new option. Set file name on output if --output is given.
Do not print output if --output is given.
--

This change makes it possible to tell gpg (and gpgtar) to write the
output (i.e. the signed/encrypted data or the signature or the created
archive) directly to a file with given file name instead of piping
the output back to gpgme.

GnuPG-bug-id: 6530
2023-06-19 18:08:47 +02:00
Ingo Klöcker
8b9fabf5d5
qt: Add a generic hook to start a job
* lang/qt/src/job.cpp, lang/qt/src/job.h (Job::startIt): New method.
* lang/qt/src/job_p.h (JobPrivate::startIt): New pure virtual method.
* lang/qt/src/qgpgmechangeexpiryjob.cpp
(QGpgMEChangeExpiryJobPrivate::startIt): New.
* lang/qt/src/qgpgmedecryptverifyarchivejob.cpp
(QGpgMEDecryptVerifyArchiveJobPrivate::startIt): New.
* lang/qt/src/qgpgmeencryptarchivejob.cpp
(QGpgMEEncryptArchiveJobPrivate::startIt): New.
* lang/qt/src/qgpgmeencryptjob.cpp (QGpgMEEncryptJobPrivate::startIt):
New.
* lang/qt/src/qgpgmeimportjob.cpp (QGpgMEImportJobPrivate::startIt):
New.
* lang/qt/src/qgpgmelistallkeysjob.cpp
(QGpgMEListAllKeysJobPrivate::startIt): New.
* lang/qt/src/qgpgmesignarchivejob.cpp
(QGpgMESignArchiveJobPrivate::startIt): New.
* lang/qt/src/qgpgmesignencryptarchivejob.cpp
(QGpgMESignEncryptArchiveJobPrivate::startIt): New.
* lang/qt/src/qgpgmesignencryptjob.cpp
(QGpgMESignEncryptJobPrivate::startIt): New.
--

startIt() starts a job if the necessary values have been set before.
This makes it possible to extend jobs with additional ways to start them
without having to worry about overloading existing virtual start()
methods. This will be used first for the different archive jobs.

GnuPG-bug-id: 6530
2023-06-19 18:08:47 +02:00
Ingo Klöcker
23526c3ff2
qt: Make the run methods of ThreadedJobMixin public
* lang/qt/src/threadedjobmixin.h (ThreadedJobMixin::run): Make all
overloads public.
--

This allows calling the run() functions from the JobPrivate subclasses.

GnuPG-bug-id: 6530
2023-06-19 17:58:23 +02:00
Ingo Klöcker
4655b2dc6b
qt: Rename JobPrivate::start to JobPrivate::startNow
* lang/qt/src/job_p.h (JobPrivate::start): Rename to startNow.
* lang/qt/src/job.cpp (Job::startNow): Adapt function call.
* lang/qt/src/qgpgmechangeexpiryjob.cpp
(QGpgMEChangeExpiryJobPrivate::start): Rename to startNow.
* lang/qt/src/qgpgmedecryptverifyarchivejob.cpp
(QGpgMEDecryptVerifyArchiveJobPrivate::start): Rename to startNow.
* lang/qt/src/qgpgmeencryptarchivejob.cpp
(QGpgMEEncryptArchiveJobPrivate::start): Rename to startNow.
* lang/qt/src/qgpgmeencryptjob.cpp (QGpgMEEncryptJobPrivate::start):
Rename to startNow.
* lang/qt/src/qgpgmeimportjob.cpp (QGpgMEImportJobPrivate::start):
Rename to startNow.
* lang/qt/src/qgpgmelistallkeysjob.cpp
(QGpgMEListAllKeysJobPrivate::start): Rename to startNow.
* lang/qt/src/qgpgmesignarchivejob.cpp
(QGpgMESignArchiveJobPrivate::start): Rename to startNow.
* lang/qt/src/qgpgmesignencryptarchivejob.cpp
(QGpgMESignEncryptArchiveJobPrivate::start): Rename to startNow.
* lang/qt/src/qgpgmesignencryptjob.cpp
(QGpgMESignEncryptJobPrivate::start): Rename to startNow.
--

Using the same name for the public and the private method avoids
confusion.

GnuPG-bug-id: 6530
2023-06-19 17:58:23 +02:00
Ingo Klöcker
6f6b35df50
qt: Return const pointer to JobPrivate class for const pointer to Job
* lang/qt/src/job.cpp, lang/qt/src/job_p.h (getJobPrivate): Replace with
two overloads for non-const pointer and const pointer to Job.
* lang/qt/src/job_p.h (jobPrivate): Replace with two template functions
for non-const pointer and const pointer to Job.
--

This helps avoid changing values stored in the JobPrivate class in
const functions (e.g. getters) of Job classes.

GnuPG-bug-id: 6530
2023-06-19 17:58:23 +02:00
Andre Heinecke
5811d069d3
qt, cpp: Support larger size-hint on 32 bit builds
* NEWS: Mention this.
* lang/cpp/src/data.h, lang/cpp/src/data.cpp (Data::setSizeHint): New.
* lang/qt/src/qgpgmedecryptjob.cpp,
 lang/qt/src/qgpgmedecryptverifyarchivejob.cpp,
 lang/qt/src/qgpgmedecryptverifyjob.cpp,
 lang/qt/src/qgpgmeencryptjob.cpp,
 lang/qt/src/qgpgmesignencryptjob.cpp,
 lang/qt/src/qgpgmesignjob.cpp,
 lang/qt/src/qgpgmeverifydetachedjob.cpp,
 lang/qt/src/qgpgmeverifyopaquejob.cpp: Set size for input IODevice.

--
This fixes the case where the old detection of the size of QIOdevice
using seek would overflow and instead explicitly uses QIODevice::size
to check for the size and pass it through as an uint64.

GnuPG-Bug-Id: T6534
2023-06-16 14:33:19 +02:00
Andre Heinecke
cbcea4a09b
cpp: Expose gpgme_data_set_flag through cpp API
* lang/cpp/src/data.cpp (Data::setFlag): New.
* lang/cpp/src/data.h: Update accordingly.
* NEWS: Mention this.

--
This exposes the generic flag mechanism for data to users
of the C++ library. It is similar to Context::setFlag but
has no getter.
2023-06-16 12:35:36 +02:00
Werner Koch
91bbb1e482
core: Send a input-size-hint for gpgsm.
* src/engine-gpgsm.c (send_input_size_hint): New.
(gpgsm_decrypt): Send hint.
(gpgsm_encrypt): Send hint.
(gpgsm_sign): Send hint.
(gpgsm_verify): Send hint.
--
GnuPG-bug-id: 6534
2023-06-15 13:00:01 +02:00
Werner Koch
8796456d23
tests: Add option --cancel to run-encrypt.
* tests/run-encrypt.c (cancel_after_progress): New.
(progress_cb): Take care of it.
(main): Add option --cancel.
--

This tool may now be used to test gpgme_cancel_async.
Releated to
GnuPG-bug-id: 6534
2023-06-15 11:01:46 +02:00
Werner Koch
eb68948c43
core: Use 64 bit instead of gpgme_off_t for some internal functions.
* src/conversion.c (_gpgme_string_to_off): Return an u64 value.
* src/data.c (_gpgme_data_get_size_hint): Ditto.
(gpgme_data_set_flag): Use u64 for io-buffer-size due to string_to_off
change.
* src/data.h (struct gpgme_data): Change size_hint to u64.
* src/engine-gpg.c (add_input_size_hint): Replace gpgme_off_t by u64.
--

GnuPG-bug-id: 6534
2023-06-15 11:01:46 +02:00
Andre Heinecke
7e6d51aa6f
Fix definition of GPG_ERR_ENABLE_GETTEXT_MACROS
* configure.ac: Add missing value.

--
Otherwise it would not be included in config.h
2023-06-13 12:45:08 +02:00
Ingo Klöcker
7990f70107
doc,cpp: Treat GPG_ERR_FULLY_CANCELED as canceled
* doc/gpgme.texi (GPG_ERR_FULLY_CANCELED): New.
* lang/cpp/src/context.cpp (Error::isCanceled): Also return true for
GPG_ERR_FULLY_CANCELED.
--

For internal purposes, GnuPG sometimes uses the error code
GPG_ERR_FULLY_CANCELED instead of GPG_ERR_CANCELED. From a user
perspective both values mean the same thing and should therefore be
treated identically.

GnuPG-bug-id: 6510
2023-06-01 09:37:41 +02:00
Biswapriyo Nath
e2103be390
cpp,python: Respect --disable-gpg-test for tests
lang/cpp/Makefile.am (SUBDIRS): Depend tests in RUN_GPG_TESTS.
lang/python/Makefile.am (SUBDIRS): Ditto.
--

This is similar to the core and qt switch to disable the tests.

Signed-off-by: Biswapriyo Nath <nathbappai@gmail.com>
ChangeLog entries added by wk.
2023-05-30 11:44:17 +02:00
Werner Koch
fbc3963d62
core: For key signing and uid revoking allow an empty user id.
* src/engine-gpg.c (gpg_keysign): Required USERID to be non-empty.
--

For some language bindings it is easier if the engine considers an
empty user id to be equivalent to NULL.
2023-05-30 11:20:34 +02:00
Werner Koch
36a68bc530
python: Fix wrong use of write.
* lang/python/helpers.c (pyPassphraseCb): Use gpgme_io_writen.
(_gpg_interact_cb): Ditto.
* lang/python/helpers.h (write) [W32]: Remove bad write macro.
--
GnuPG-bug-id: T6501

Using write(2) without checking for EINTR is a not a good idea.
Futher gpgme_io_writen is the correct way to send data from a
callback.  This also fixed the wrong use of a simple macro for
Windows.
2023-05-23 15:52:25 +02:00
NIIBE Yutaka
e622e36f1f
build: Sync to libtool from libgpg-error for 64-bit Windows.
* build-aux/ltmain.hs: Update from libgpg-error.

--

GnuPG-bug-id: 6484
Signed-off-by: NIIBE Yutaka <gniibe@fsij.org>
2023-05-16 10:52:51 +09:00
NIIBE Yutaka
d44a473e27
doc: Fix Python example code.
* lang/python/doc/src/gpgme-python-howto.org: Fix chmod race.
* lang/python/examples/howto/export-secret-key.py: Likewise.
* lang/python/examples/howto/export-secret-keys.py: Likewise.
* lang/python/examples/howto/temp-homedir-config.py: Likewise.

--

It's not for Python 2.7.

GnuPG-bug-id: 6466
Reported-by: Hanno Böck
Co-authored-by: Ingo Klöcker
Signed-off-by: NIIBE Yutaka <gniibe@fsij.org>
2023-04-26 08:46:45 +09:00
Werner Koch
d99156ff08
Post release updates
--
2023-04-20 14:02:34 +02:00
Werner Koch
451ed47434
Release 1.20.0 2023-04-20 13:48:17 +02:00
Werner Koch
7351ef32ce
core: Support the new macOS Homebrew location.
* src/posix-util.c (find_executable): Extend the path.
--

GnuPG-bug-id: 6440
2023-04-20 13:35:50 +02:00
Ingo Klöcker
a14155d2c1
build,qt: Simplify check for moc
m4/qt6.m4: Remove alternative checks for moc that were taken over from
Qt 5 and that are obsolete for Qt 6.
--
2023-04-19 09:23:05 +02:00
Ingo Klöcker
e80bf34bf8
Update NEWS
* NEWS: Add news for recent changes
--

GnuPG-bug-id: 5960, 6456
2023-04-19 09:18:04 +02:00
Ingo Klöcker
5bd84cfd3f
cpp: Fix Key::canSign()
* lang/cpp/src/key.h (canReallySign): Deprecate.
* lang/cpp/src/key.cpp (canSign): Remove workaround. Use implementation
of canReallySign.
(canReallySign): Use canSign().
(operator<<): Use canSign().
--

The workaround in canSign was added 19 years ago and canReallySign, the
workaround for the workaround, was added 13 years ago. Time to get rid
of those workarounds for a bug in gpgme which has been fixed long ago
and which cause bugs for any unsuspecting user of Key::canSign().

GnuPG-bug-id: 6456
2023-04-18 13:16:22 +02:00
Werner Koch
7d1159c1e9
core: Avoid printf format warnings due to gpgme_ssize_t.
* src/debug.h (_trace_sysres_ssize_t): Cast arg.
2023-04-17 15:05:22 +02:00
Werner Koch
0c29119e06
core,w32: Fix invocation of gpgtar
* src/dirinfo.c (EXEEXT_S): New.
(get_gpgconf_item): Append ".exe" to gpg-wks-client and gpgtar.

* src/gpgme-w32spawn.c (mystderr): Add code to ease debugging.
2023-04-17 14:05:35 +02:00
NIIBE Yutaka
806a5d18b9
build: Update gpg-error.m4.
* m4/gpg-error.m4: Update from libgpg-error master.

--

Signed-off-by: NIIBE Yutaka <gniibe@fsij.org>
2023-04-06 08:40:12 +09:00
Ingo Klöcker
d256ba7cc5
w32: Always use UTF-8 for localized texts
* configure.ac: Define GPG_ERR_ENABLE_GETTEXT_MACROS.
* src/version.c (do_subsystem_inits) [W32]: Switch gettext to UTF-8.
--

On Windows, applications using GpgME can now rely on localized texts
returned by GpgME, e.g. the texts for error codes, to be UTF-8 encoded.
In particular, this saves a useless and possibly lossy conversion to
native encoding and back to UTF-8. On other OSes, where we use the
system provided gettext, we assume that UTF-8 is used nowadays.

GnuPG-bug-id: 5960
2023-04-04 12:11:15 +02:00
Werner Koch
34cc7daba1
core: Minor code cleanup.
* src/engine-gpg.c (build_argv): Remove superfluous tes.
--

gpg_error_from_syserror is guaranteed not to return 0 even if errno is
not set.
2023-03-27 16:56:29 +02:00
Ingo Klöcker
b608c084b9
core: Initialize error variable
* src/engine-gpg.c (build_argv): Initialize err.
--

Fixes-commit: fbce7deb3b
2023-03-27 16:49:24 +02:00
Werner Koch
6d21256c92
core,cpp: Add new key flags to gpgme_subkey_t
* src/gpgme.h.in (struct _gpgme_subkey): Add bit flags can_renc,
can_timestamp, adn is_group_owned. Reduce size of _unused.
* src/keylist.c (set_subkey_capability): Set them.
* tests/run-keylist.c (main): Print them.

* lang/cpp/src/key.h (Subkey::canRenc): New.
(Subkey::canTimestamp): New.
(Subkey::isGroupOwned): New.
* lang/cpp/src/key.cpp: Implement new methods.
(Subkey::isQualified): Print them.
(std::ostream &operator<<): Print them.
--

GnuPG-bug-id: 6395
2023-03-21 08:37:47 +01:00
Werner Koch
18e09b15d5
Post release updates
--
2023-03-17 11:42:33 +01:00
Werner Koch
96a30fdf30
Release 1.19.0 2023-03-17 10:34:42 +01:00
Ben Greiner (bnavigator)
d086653cc3
python: Update python.m4 configure script.
* configure.ac: Unset PYTHON_LIBS.  Support python 3.10.
* m4/python.m4: Find correct version string for python >= 3.10.
--

See-also: https://dev.gnupg.org/D546

Also test for 3.11 and 3.12 (wk).
2023-03-17 10:06:55 +01:00
Ingo Klöcker
e50724e1bb
tests: Package the ownertrust file
tests/gpg/Makefile.am (EXTRA_DIST): Add ownertrust.txt.
--

This fixes `make distcheck`.

GnuPG-bug-id: 6342
2023-03-17 09:20:08 +01:00
Werner Koch
98a159eb5e
build: Update autogen.sh from libgpg-error
--

This fixes hopefully issues with the beta numbering.  Also removes the
Windows-CE support
2023-03-15 16:07:57 +01:00
Werner Koch
c1f6535f14
core: Also detect legacy X.509 v0 certificates.
* src/data-identify.c (basic_detection): Loose the detection of X.509
certs.
2023-03-08 15:54:54 +01:00
Werner Koch
76351c4877
tests: Add option --binary to run-verify
* tests/run-verify.c (main): Set encoding.
--

gpgsm usually used autodetection of the input format.  But sometimes
it is required to tell gpgsm that the input is binary encoded.  In
particular, this allows to strip trailing zeroes from a detached
signature.
2023-03-08 10:50:15 +01:00
Ingo Klöcker
73e46b3465
qt: Add signals for file-based and data-based progress
* lang/qt/src/decryptverifyarchivejob.h (DecryptVerifyArchiveJob): Add
signals fileProgress and dataProgress.
* lang/qt/src/encryptarchivejob.h (EncryptArchiveJob): Ditto.
* lang/qt/src/signarchivejob.h (SignArchiveJob): Ditto.
* lang/qt/src/signencryptarchivejob.h (SignEncryptArchiveJob): Ditto.
* lang/qt/src/job_p.h (emitArchiveProgressSignals): New.
* lang/qt/src/qgpgmedecryptverifyarchivejob.cpp
(QGpgMEDecryptVerifyArchiveJob::QGpgMEDecryptVerifyArchiveJob): Emit
appropriate signal when receiving Job::rawProgress signal.
* lang/qt/src/qgpgmeencryptarchivejob.cpp
(QGpgMEEncryptArchiveJob::QGpgMEEncryptArchiveJob): Ditto.
* lang/qt/src/qgpgmesignarchivejob.cpp
(QGpgMESignArchiveJob::QGpgMESignArchiveJob): Ditto.
* lang/qt/src/qgpgmesignencryptarchivejob.cpp
(QGpgMESignEncryptArchiveJob::QGpgMESignEncryptArchiveJob): Ditto.
--

GnuPG-bug-id: 6342
2023-02-14 09:25:21 +01:00
Ingo Klöcker
ccff6a96fc
qt: Remove commented out code
--

GnuPG-bug-id: 6342
2023-02-14 09:25:21 +01:00
Ingo Klöcker
ea6f15ed60
qt: Add simple and extended progress signals replacing old signal
* lang/qt/src/job.h (Job): Add signals jobProgress and rawProgress.
Deprecate signal progress.
* lang/qt/src/multideletejob.cpp (MultiDeleteJob::slotResult): Emit
new progress signals.
* lang/qt/src/qgpgmerefreshsmimekeysjob.cpp
(QGpgMERefreshSMIMEKeysJob::slotStatus): Ditto.
* lang/qt/src/threadedjobmixin.h (ThreadedJobMixin::showProgress): Use
modern overload of QMetaObject::invokeMethod to forward the progress
signal and add the value of what. Add forwarding of progress to the new
signals.

* lang/qt/tests/t-encrypt.cpp (EncryptionTest::testProgress): Test
the new signals instead of the deprecated one.
--

The new signal jobProgress omits the what value which is useless for
most consumers. The new signal rawProgress makes all information
provided by the backend available to consumers. The latter is not
really meant to be used by users of gpgme. It will be used by the
archive jobs to provide more user-friendly signals.

GnuPG-bug-id: 6342
2023-02-14 09:25:21 +01:00
Werner Koch
9c5506fde7
core: Switch to logging via gpgrt
* src/debug.c (errfp): Remove.
(debug_init): Factor some code out to ...
(safe_to_use_debug_file): new.
(tid_log_callback): New.
(debug_init): Rewrite to make use of gpgrt logging.
(_gpgme_debug): Ditto.
(_gpgme_debug_end): Remove extra LF testing code.
* src/dirinfo.c (get_gpgconf_item): Remove now unneeded LFs.  Realign
output.
2023-02-10 11:12:52 +01:00
Werner Koch
c0da6f77c6
core: Update copyright notices
--
2023-02-10 11:12:52 +01:00
Ingo Klöcker
21283dfd1b
tests: Fix cleaning up at the end of the test
* tests/gpg/t-import.c (main): Unref key and release context.
--

This fixes leaks found with -fsanitize=address.
2023-02-10 10:00:56 +01:00
Ingo Klöcker
41dc3bd22a
core: Allow finalization of signature verification of unencrypted data
* src/decrypt-verify.c (decrypt_verify_status_handler): Call
_gpgme_verify_status_handler on EOF even if
_gpgme_decrypt_status_handler returned NO DATA error.

* tests/gpg/t-decrypt-verify.c (normal_signed_message): New.
(main): Add test with signed, but not encrypted data.
--

This allows the verify status handler to finalize the verification of
the last signature even if the decrypt status handler returned a NO DATA
error because the input data wasn't encrypted.

GnuPG-bug-id: 6368
2023-02-10 09:54:03 +01:00
Ingo Klöcker
3aaed9cfbf
cpp: Improve debug output of some enums
* lang/cpp/src/verificationresult.cpp (operator<<): Fix output of
Signature::PKAStatus which doesn't represent flags. Print corresponding
name of enum value if Signature::Summary or Notation::Flags are 0.
--

GnuPG-bug-id: 6368
2023-02-09 09:56:18 +01:00
Ingo Klöcker
7098c14b23
tests: Stop daemons after setting up test environment
* lang/python/tests/Makefile.am, lang/qt/tests/Makefile.am,
tests/gpg/Makefile.am, tests/json/Makefile.am (pubring-stamp): Call
`gpgconf --kill all` after importing test keys.
--

This ensures that no gpg-agents or other daemons are running after
"make".
2023-02-09 09:33:07 +01:00
Ingo Klöcker
fcefc78f74
tests: Extend tests with an ultimately trusted key
* tests/gpg/Makefile.am (gpg-sample.stamp, pubring-stamp): Unify usage
of tabs.
(pubring-stamp): Import owner trust values.
* tests/gpg/ownertrust.txt: New.
* tests/gpg/t-decrypt-verify.c, tests/gpg/t-verify.c: Update expected
values for signature summary and validity.
* tests/gpg/t-keylist-secret-sig.c, tests/gpg/t-keylist-sig.c,
tests/gpg/t-keylist.c: Update expected values of owner trust and uid
validity.
--

This change marks the "Alpha Test" test key as ultimately trusted which
makes it possible to check for correct values derived from this, i.e.
key owner trust, user id validity, signature summary and signature
validity.

GnuPG-bug-id: 6342
2023-02-08 13:46:17 +01:00
Ingo Klöcker
844e6cd3b9
tests: Make t-edit-sign idempotent
* tests/gpg/t-edit-sign.c (test_key, test_key_fpr, import_key,
delete_key): New.
(main): Remove key_fpr. Import test key to sign. Delete test key after
test.
--

Using a dedicated test key for testing key signing, which is imported
before the test and deleted after the test, makes sure that the
keys in the test key ring don't change. This is important for stable
results of the key listing tests.

GnuPG-bug-id: 6342
2023-02-08 13:25:27 +01:00
Ingo Klöcker
e0778ed910
doc: Add new flags
--

GnuPG-bug-id: 6342
2023-02-02 12:22:00 +01:00
Ingo Klöcker
52fd0bcde4
qt,tests: Add test for the previous commit
* lang/qt/tests/t-decryptverify.cpp: New.
* lang/qt/tests/Makefile.am: Add new test.
--

GnuPG-bug-id: 6342
2023-02-02 12:11:30 +01:00
Ingo Klöcker
1698eec2ae
cpp: Return successful verification for signed but not encrypted data
* lang/cpp/src/context.cpp (Context::decrypt): Use decryptionResult().
(Context::verifyDetachedSignature, Context::verifyOpaqueSignature):
Use verificationResult().
(Context::verificationResult): Ignore "no data" error for signed but
not encrypted data.
(Context::decryptAndVerify): Use decryptionResult() and
verificationResult().
--

gpgme's decrypt operations set the error to GPG_ERR_NO_DATA if no
encrypted data was found. It makes sense to use this error for the
encryption result, but it doesn't make sense to use it also for the
verfication result if signed data was found.
This way using the combined decrypt-verify operations on data that
may be encrypted and/or signed doesn't produce confusing results.

GnuPG-bug-id: 6342
2023-02-02 12:11:29 +01:00
Ingo Klöcker
c407728064
qt: Add job for extracting encrypted and signed archives
* lang/qt/src/decryptverifyarchivejob.cpp,
lang/qt/src/decryptverifyarchivejob.h,
lang/qt/src/decryptverifyarchivejob_p.h,
lang/qt/src/qgpgmedecryptverifyarchivejob.cpp,
lang/qt/src/qgpgmedecryptverifyarchivejob.h: New.
* lang/qt/src/protocol.h (class Protocol): Add pure virtual member
function decryptVerifyArchiveJob
* lang/qt/src/protocol_p.h (Protocol::decryptVerifyArchiveJob): ... and
implement it.
* lang/qt/src/Makefile.am: Update accordingly.

* lang/qt/tests/run-decryptverifyarchivejob.cpp: New.
* lang/qt/tests/Makefile.am: Add new test runner.
--

GnuPG-bug-id: 6342
2023-02-02 12:11:29 +01:00
Ingo Klöcker
7ad717f6ba
core: Make usage of input size hint compatible with gpgtar
* src/engine-gpg.c (add_input_size_hint): Use add_gpg_arg_with_value
to add the --input-size-hint option.
--

GnuPG-bug-id: 6342
2023-02-02 09:59:01 +01:00
Ingo Klöcker
b3bdf14b37
cpp: Update decryption flags
* lang/cpp/src/context.h (DecryptArchive): New flag.
--

This flag corresponds to the GPGME_DECRYPT_ARCHIVE flag in gpgme.

GnuPG-bug-id: 6342
2023-02-02 09:56:22 +01:00
Ingo Klöcker
55c948866f
qt: Allow checking if the sign/encrypt archive jobs are supported
* lang/qt/src/encryptarchivejob.cpp, lang/qt/src/encryptarchivejob.h
(isSupported): New.
* lang/qt/src/signarchivejob.cpp, lang/qt/src/signarchivejob.h
(isSupported): New.
* lang/qt/src/signencryptarchivejob.cpp,
lang/qt/src/signencryptarchivejob.h (isSupported): New.

* lang/qt/tests/run-encryptarchivejob.cpp (main),
lang/qt/tests/run-signarchivejob.cpp (main): Check if jobs are
supported.
--

GnuPG-bug-id: 6342
2023-02-02 09:47:11 +01:00
Ingo Klöcker
8478064691
cpp: Add const-overloads of version comparison operators
* lang/cpp/src/engineinfo.h (EngineInfo::Version): Add const-overloads
of all comparison operators.
--

We keep the non-const overloads for binary compatibility.

GnuPG-bug-id: 6342
2023-02-02 09:47:10 +01:00
Ingo Klöcker
7f541547fc
core: Allow usage of gpgtar also for new enough gpg 2.2
* src/engine-gpg.c (have_usable_gpgtar): New.
(start): Always pass --status-fd to the called process.
(gpg_decrypt, gpg_encrypt, gpg_encrypt_sign, gpg_sign, gpg_verify):
Use have_usable_gpgtar() to check for suitable gpg.
--

The version check in start() is not needed because versions of gpg
that are unsuitable for the usage of gpgtar are rejected already by
the callers.

GnuPG-bug-id: 6342
2023-02-02 09:47:10 +01:00
Werner Koch
5ab9c234d6
core,w32: More robust detection of GnuPG Desktop dir layout
* src/w32-util.c (INST_TYPE_GPG4WIN, INST_TYPE_GPGDESK): New to
replace the numeric constants.
(find_version_file): New.
(_gpgme_get_gpgconf_path): Guess a default for inst_type.
--

GnuPG-bug-id: 6362
2023-02-01 17:29:24 +01:00
Ingo Klöcker
343fb33bf0
qt: Fix build without installed gpgme++ headers
* lang/qt/src/filelistdataprovider.cpp: Include error.h without
folder prefix.
--

GnuPG-bug-id: 6342
2023-01-31 21:13:07 +01:00
Ingo Klöcker
472f109138
doc: Update "since" version
--
2023-01-31 12:13:29 +01:00
Ingo Klöcker
7b2188aca1
doc: Update NEWS
--

GnuPG-bug-id: 6342
2023-01-31 12:01:33 +01:00
Ingo Klöcker
d3a8c2c8b6
qt: Remove unused and commented-out code
* lang/qt/src/qgpgmeencryptarchivejob.cpp,
lang/qt/src/qgpgmeencryptarchivejob.h (QGpgMEEncryptArchiveJob):
Remove member function resultHook and member mResult.
* lang/qt/src/qgpgmesignarchivejob.cpp,
lang/qt/src/qgpgmesignarchivejob.h (QGpgMESignArchiveJob):
Remove member function resultHook and member mResult.
--

GnuPG-bug-id: 6342
2023-01-31 12:01:33 +01:00
Ingo Klöcker
41a30f6d9f
cpp: Fix debug output of SignatureMode
* lang/cpp/src/context.cpp (operator<<): Treat signature mode as
combination of a 2-bit flag and a 1-bit flag.
--

This fixes the output for normal signature mode.

GnuPG-bug-id: 6342
2023-01-31 12:01:33 +01:00
Ingo Klöcker
8c4436e73a
qt: Add job for creating encrypted signed archives
* lang/qt/src/signencryptarchivejob.cpp,
lang/qt/src/signencryptarchivejob.h,
lang/qt/src/signencryptarchivejob_p.h,
lang/qt/src/qgpgmesignencryptarchivejob.cpp,
lang/qt/src/qgpgmesignencryptarchivejob.h: New.
* lang/qt/src/protocol.h (class Protocol): Add pure virtual member
function signEncryptArchiveJob
* lang/qt/src/protocol_p.h (Protocol::signEncryptArchiveJob): ... and
implement it.
* lang/qt/src/Makefile.am: Update accordingly.

* lang/qt/tests/run-encryptarchivejob.cpp (displayName): Remove.
(CommandLineOptions): Initialize member armor. Add member sign.
(parseCommandLine): Update application description. Add and parse option
-s/--sign.
(main): Use SignEncryptArchiveJob if sign option is set.
--

GnuPG-bug-id: 6342
2023-01-31 12:01:33 +01:00
Ingo Klöcker
2b98585c89
qt,tests: Avoid leaking Context
* lang/qt/tests/t-import.cpp: Wrap Context*s in unique_ptr.
--

This fixes leaks found with -fsanitize=address.
2023-01-31 12:01:33 +01:00
Werner Koch
5d07f8db77
doc: Fix description of gpgme_data_identify
--
GnuPG-bug-id: 5887
2023-01-31 09:53:20 +01:00
Werner Koch
359378c5b3
json: New operation "identify" and convenience option --identify.
* src/gpgme-json.c (data_type_to_string): New.
(op_identify): New.
(process_request): Add to command list.
(cmd_identify): New.
(main): Add option --identify.
--
2023-01-31 09:52:04 +01:00
Werner Koch
577562dd4c
Update NEWS and set version to 1.19.0
--
2023-01-31 08:10:29 +01:00
Werner Koch
3cdcfa33f7
Merge branch 'ikloecker/t6342-gpgtar' into master
--
Solved conflicts:
	NEWS
	lang/cpp/src/context.cpp
	lang/cpp/src/context.h
2023-01-31 07:59:50 +01:00
Ingo Klöcker
3e31f648e5
cpp: Support all encryption flags
* lang/cpp/src/context.h (WantAddress): New flag.
* lang/cpp/src/context.cpp (encryptflags2encryptflags): Convert
WantAddress to corresponding gpgme encrypt flags.
(operator<<): Add new flag to debug stream.
--

GnuPG-bug-id: 6359
2023-01-26 12:01:28 +01:00
Ingo Klöcker
70aaf05a6a
cpp: Pass ThrowKeyIds and EncryptWrap flags to GpgME
* lang/cpp/src/context.cpp (encryptflags2encryptflags): Convert
ThrowKeyIds and EncryptWrap to corresponding gpgme encrypt flags.
(operator<<): Add flags to debug stream.
--

GnuPG-bug-id: 6359
2023-01-26 12:01:10 +01:00
354 changed files with 10499 additions and 3069 deletions

View File

@ -22,7 +22,7 @@ List of Copyright holders
Copyright (C) 1991-2013 Free Software Foundation, Inc.
Copyright (C) 2000-2001 Werner Koch
Copyright (C) 2001-2021 g10 Code GmbH
Copyright (C) 2001-2023 g10 Code GmbH
Copyright (C) 2002 Klarälvdalens Datakonsult AB
Copyright (C) 2004-2008 Igor Belyi
Copyright (C) 2002 John Goerzen
@ -43,7 +43,7 @@ FSF <gnu@gnu.org>
src/stpcpy.c, src/w32-ce.c.
g10 Code GmbH <code@g10code.com>
- All stuff since mid march 2001.
- All stuff since mid March 2001.
Werner Koch <wk@gnupg.org>
- Design and most stuff.

View File

@ -36,8 +36,11 @@ DISTCHECK_CONFIGURE_FLAGS =
EXTRA_DIST = autogen.sh autogen.rc gpgme.spec.in \
ChangeLog-2011 m4/ChangeLog-2011 \
build-aux/libtool-patch.sed \
conf/whatisthis VERSION LICENSES
# This artificial line is to put a dependency to conf/config.h for 'all'
BUILT_SOURCES = conf/config.h
if RUN_GPG_TESTS
tests = tests

324
NEWS
View File

@ -1,6 +1,304 @@
Noteworthy changes in version 1.18.1 (unreleased)
Noteworthy changes in version 1.24.0 (unrelease)
-------------------------------------------------
* Extended gpgme_op_decrypt* and gpgme_op_verify* to allow writing the
output directly to a file. [T6550]
* Extended gpgme_op_encrypt*, gpgme_op_encrypt_sign*, and gpgme_op_sign*
to allow reading the input data directly from a file. [T6550]
* Add information about designated revocation keys. [T7118]
* New context flag "import-options". [T7152]
* cpp: Provide information about designated revocation keys for a Key.
[T7118]
* cpp: Add safer member function returning text describing an error.
[T5960]
* qt: Build QGpgME for Qt 5 and Qt 6 simultaneously. [T7205]
* qt: Install headers for Qt 5 and Qt 6 in separate folders. [T7161]
* qt: Allow reading the data to decrypt/encrypt/sign/verify directly from
files. [T6550]
* qt: Allow writing the decrypted/encrypted/signed/verified data directly
to files. [T6550]
* qt: Allow specifying import options when importing keys. [T7152]
* qt: Allow appending a detached signature to an existing file. [T6867]
* Interface changes relative to the 1.23.2 release:
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
GPGME_ENCRYPT_FILE NEW.
GPGME_SIG_MODE_FILE NEW.
gpgme_key_t EXTENDED: New field 'revkeys'.
gpgme_revocation_key_t NEW.
gpgme_set_ctx_flag EXTENDED: New flag 'import-options'.
cpp: Context::EncryptFile NEW.
cpp: SignatureMode::SignFile NEW.
cpp: RevocationKey NEW.
cpp: Key::revocationKey NEW.
cpp: Key::numRevocationKeys NEW.
cpp: Key::revocationKeys NEW.
cpp: Error::asStdString NEW.
cpp: Error::asString DEPRECATED.
qt: DecryptVerifyJob::setInputFile NEW.
qt: DecryptVerifyJob::inputFile NEW.
qt: DecryptVerifyJob::setOutputFile NEW.
qt: DecryptVerifyJob::outputFile NEW.
qt: EncryptJob::setRecipients NEW.
qt: EncryptJob::recipients NEW.
qt: EncryptJob::setInputFile NEW.
qt: EncryptJob::inputFile NEW.
qt: EncryptJob::setOutputFile NEW.
qt: EncryptJob::outputFile NEW.
qt: EncryptJob::setEncryptionFlags NEW.
qt: EncryptJob::encryptionFlags NEW.
qt: SignEncryptJob::setSigners NEW.
qt: SignEncryptJob::signers NEW.
qt: SignEncryptJob::setRecipients NEW.
qt: SignEncryptJob::recipients NEW.
qt: SignEncryptJob::setInputFile NEW.
qt: SignEncryptJob::inputFile NEW.
qt: SignEncryptJob::setOutputFile NEW.
qt: SignEncryptJob::outputFile NEW.
qt: SignEncryptJob::setEncryptionFlags NEW.
qt: SignEncryptJob::encryptionFlags NEW.
qt: SignJob::setSigners NEW.
qt: SignJob::signers NEW.
qt: SignJob::setInputFile NEW.
qt: SignJob::inputFile NEW.
qt: SignJob::setOutputFile NEW.
qt: SignJob::outputFile NEW.
qt: SignJob::setSigningFlags NEW.
qt: SignJob::signingFlags NEW.
qt: SignJob::setAppendSignature NEW.
qt: SignJob::appendSignatureEnabled NEW.
qt: VerifyDetachedJob::setSignatureFile NEW.
qt: VerifyDetachedJob::signatureFile NEW.
qt: VerifyDetachedJob::setSignedFile NEW.
qt: VerifyDetachedJob::signedFile NEW.
qt: VerifyOpaqueJob::setInputFile NEW.
qt: VerifyOpaqueJob::inputFile NEW.
qt: VerifyOpaqueJob::setOutputFile NEW.
qt: VerifyOpaqueJob::outputFile NEW.
qt: ImportJob::setImportOptions NEW.
qt: ImportJob::importOptions NEW.
Noteworthy changes in version 1.23.2 (2023-11-28)
-------------------------------------------------
* Preserve more specific existing failure code. [T6575]
* qt: Start dirmngr with gpgconf to avoid multiple instances. [T6833]
* qt: On Windows, use UTF-8 when logging the error text. [T5960]
* qt: Remove left-over partial files more persistently. [T6584]
* qt: Use a temporary file name when creating signed or encrypted
archives. [T6721]
* qt: Build Qt 6 bindings with -fPIC if requested or Qt 6 was built with
this flag. [T6781]
Notes:
~~~~~~
qt: DefaultKeyGenerationJob DEPRECATED.
[c=C43/A32/R1 cpp=C26/A20/R1 qt=C20/A5/R1]
Release-info: https://dev.gnupg.org/T6782
Noteworthy changes in version 1.23.1 (2023-10-27)
-------------------------------------------------
* w32: Change gpgme-w32-spawn to use Unicode arguments. [T6728]
[c=C43/A32/R0 cpp=C26/A20/R0 qt=C20/A5/R0]
Release-info: https://dev.gnupg.org/T6774
Noteworthy changes in version 1.23.0 (2023-10-25)
-------------------------------------------------
* Support GPGME_ENCRYPT_ALWAYS_TRUST also for S/MIME. [T6559]
* New keylist mode GPGME_KEYLIST_MODE_WITH_V5FPR. [T6705]
* New key capability flags has_*. [T6748]
* gpgme-tool: Support use of Windows HANDLE. [T6634]
* qt: Support refreshing keys via WKD. [T6672]
* qt: Handle cancel in changeexpiryjob. [T6754]
* Interface changes relative to the 1.22.0 release:
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
GPGME_KEYLIST_MODE_WITH_V5FPR NEW.
gpgme_key_t EXTENDED: New field has_encrypt.
gpgme_key_t EXTENDED: New field has_sign.
gpgme_key_t EXTENDED: New field has_certify.
gpgme_key_t EXTENDED: New field has_authenticate.
cpp: Key::canCertify NEW.
cpp: Key::canSign NEW.
cpp: Key::canEncrypt NEW.
cpp: Key::canAuthenticate NEW.
qt: Protocol::wkdRefreshJob NEW.
qt: WKDRefreshJob NEW.
[c=C43/A32/R0 cpp=C26/A20/R0 qt=C20/A5/R0]
Release-info: https://dev.gnupg.org/T6774
Noteworthy changes in version 1.22.0 (2023-08-21)
-------------------------------------------------
* Prevent wrong plaintext when verifying clearsigned signature. [T6622]
* Return bad data error instead of general error on unexpected data.
[T6617]
* Take care of offline mode for all operations of gpgsm engine.
[T6648]
* Prepare the use of the forthcoming libassuan version 3.
* New configure option --with-libtool-modification. [T6619]
* cpp: Expose gpgme_decrypt_result_t.is_mime. [T6199]
* qt: Clean up after failure or cancel of sign/encrypt archive
operation. [T6584]
* qt: Add setInputEncoding to QGpgMe::EncryptJob. [T6166]
* qt: Make toLogString helper public. [T6584]
* Interface changes relative to the 1.21.0 release:
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
qt: EncryptJob::setInputEncoding NEW.
qt: DecryptionResult::isMime NEW.
qt: toLogString NEW.
[c=C42/A31/R0 cpp=C25/A19/R0 qt=C19/A4/R0]
Release-info: https://dev.gnupg.org/T6668
Noteworthy changes in version 1.21.0 (2023-07-07)
-------------------------------------------------
* Extended gpgme_op_encrypt, gpgme_op_encrypt_sign, and gpgme_op_sign
to allow writing the output directly to a file. [T6530]
* Extended gpgme_op_decrypt and gpgme_op_verify to allow reading the
input data directly from files. [T6530]
* For key signing and uid revoking allow an empty user id.
[rMfbc3963d62]
* Pass an input-size-hint also to the gpgsm engine. [T6534]
* qt: Allow writing the created archives directly to a
file. [T6530]
* qt: Allow reading the signed/encrypted archive to decrypt
or verify directly from a file. [T6530]
* qt: Qt Jobs working with QIODeviceDataProvider now properly
handle input-size hints and progress for files larger.
2^32 bytes in 32 bit builds. [T6534]
* cpp: Error::isCanceled now also returns true for error code
GPG_ERR_FULLY_CANCELED. [T6510]
* python: Fix wrong use of write. [T6501]
* Interface changes relative to the 1.20.0 release:
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
cpp: Data::setFlag NEW.
cpp: Data::setSizeHint NEW.
qt: Job::startIt NEW.
qt: DecryptVerifyArchiveJob::setInputFile NEW.
qt: DecryptVerifyArchiveJob::inputFile NEW.
qt: EncryptArchiveJob::setRecipients NEW.
qt: EncryptArchiveJob::recipients NEW.
qt: EncryptArchiveJob::setInputPaths NEW.
qt: EncryptArchiveJob::inputPaths NEW.
qt: EncryptArchiveJob::setOutputFile NEW.
qt: EncryptArchiveJob::outputFile NEW.
qt: EncryptArchiveJob::setEncryptionFlags NEW.
qt: EncryptArchiveJob::encryptionFlags NEW.
qt: SignArchiveJob::setSigners NEW.
qt: SignArchiveJob::signers NEW.
qt: SignArchiveJob::setInputPaths NEW.
qt: SignArchiveJob::inputPaths NEW.
qt: SignArchiveJob::setOutputFile NEW.
qt: SignArchiveJob::outputFile NEW.
qt: SignEncryptArchiveJob::setSigners NEW.
qt: SignEncryptArchiveJob::signers NEW.
qt: SignEncryptArchiveJob::setRecipients NEW.
qt: SignEncryptArchiveJob::recipients NEW.
qt: SignEncryptArchiveJob::setInputPaths NEW.
qt: SignEncryptArchiveJob::inputPaths NEW.
qt: SignEncryptArchiveJob::setOutputFile NEW.
qt: SignEncryptArchiveJob::outputFile NEW.
qt: SignEncryptArchiveJob::setEncryptionFlags NEW.
qt: SignEncryptArchiveJob::encryptionFlags NEW.
[c=C41/A30/R0 cpp=C24/A18/R0 qt=C18/A3/R0]
Release-info: https://dev.gnupg.org/T6585
Noteworthy changes in version 1.20.0 (2023-04-20)
-------------------------------------------------
* On Windows, the gettext functions provided by gpgrt are switched
into utf8 mode, so that all localized texts returned by GpgME or
gpgrt, e.g. the texts for error codes are now UTF-8 encoded.
[T5960]
* Key::canSign now returns false for OpenPGP keys without signing
(sub)key. [T6456]
* The new macOS Homebrew location is now by default supported.
[T6440]
* Fix regression in 1.19.0. [rMb608c084b9]
* Fix invocation of gpgtar on Windows. [rM0c29119e06]
* Interface changes relative to the 1.19.0 release:
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
gpgme_subkey_t EXTENDED: New field 'can_renc'.
gpgme_subkey_t EXTENDED: New field 'can_timestamp'.
gpgme_subkey_t EXTENDED: New field 'is_group_owned'.
cpp: Subkey::canRenc NEW.
cpp: Subkey::canTimestamp NEW.
cpp: Subkey::isGroupOwned NEW.
cpp: Key::canReallySign DEPRECATED.
[c=C40/A29/R0 cpp=C23/A17/R0 qt=C17/A2/R1]
Release-info: https://dev.gnupg.org/T6463
Noteworthy changes in version 1.19.0 (2023-03-17)
-------------------------------------------------
* New convenience option --identify for gpgme-json.
* New context flag "no-auto-check-trustdb". [T6261]
* Optionally, build QGpgME for Qt 6
@ -16,6 +314,9 @@ Noteworthy changes in version 1.18.1 (unreleased)
* cpp: Handle error when trying to sign expired keys. [T6155]
* cpp: Support encryption flags ThrowKeyIds, EncryptWrap, and WantAddress.
[T6359]
* cpp, qt: Fix building with C++11. [T6141]
* qt: Fix problem with expiration dates after 2038-01-19 on 32-bit systems
@ -29,7 +330,7 @@ Noteworthy changes in version 1.18.1 (unreleased)
* qt: Allow deferred start of import jobs. [T6323]
* qt: Support creating encrypted archives. [T6342]
* qt: Support creating and extracting signed and encrypted archives. [T6342]
* Interface changes relative to the 1.18.0 release:
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
@ -44,6 +345,10 @@ Noteworthy changes in version 1.18.1 (unreleased)
gpgme_op_verify_ext NEW.
cpp: GpgGenCardKeyInteractor::Curve NEW.
cpp: GpgGenCardKeyInteractor::setCurve NEW.
cpp: Context::WantAddress NEW.
cpp: Context::DecryptArchive NEW.
cpp: Context::EncryptArchive NEW.
cpp: SignArchive NEW.
cpp: Data::setFileName EXTENDED: New overload
qt: ListAllKeysJob::Option NEW.
qt: ListAllKeysJob::Options NEW.
@ -52,8 +357,21 @@ Noteworthy changes in version 1.18.1 (unreleased)
qt: Job::startNow NEW.
qt: ImportJob::startLater NEW.
qt: FileListDataProvider NEW.
qt: DecryptVerifyArchiveJob NEW.
qt: EncryptArchiveJob NEW.
qt: SignArchiveJob NEW.
qt: SignEncryptArchiveJob NEW.
qt: Protocol::decryptVerifyArchiveJob NEW.
qt: Protocol::encryptArchiveJob NEW.
qt: Protocol::signArchiveJob NEW.
qt: Protocol::signEncryptArchiveJob NEW.
qt: Job::jobProgress NEW.
qt: Job::rawProgress NEW.
qt: Job::progress DEPRECATED.
[c=C39/A28/R0 cpp=C22/A16/R0 qt=C17/A2/R0]
Release-info: https://dev.gnupg.org/T6341
Noteworthy changes in version 1.18.0 (2022-08-10)
@ -425,7 +743,7 @@ Noteworthy changes in version 1.13.0 (2019-03-26)
* Several fixes to the Common Lisp bindings.
* Fixed minor bugs in gpgme-json. [#4331,#4341,#4342,#4343
* Fixed minor bugs in gpgme-json. [#4331,#4341,#4342,#4343]
* Require trace level 8 to dump all I/O data.

8
README
View File

@ -1,7 +1,7 @@
GPGME - GnuPG Made Easy
---------------------------
Copyright 2001-2021 g10 Code GmbH
Copyright 2001-2023 g10 Code GmbH
This file is free software; as a special exception the author gives
unlimited permission to copy and/or distribute it, with or without
@ -41,11 +41,11 @@ See the file INSTALL for generic installation instructions.
Check that you have unmodified sources. See below on how to do this.
Don't skip it - this is an important step!
To build GPGME, you need to install libgpg-error (>= 1.24) and
To build GPGME, you need to install libgpg-error (>= 1.36) and
Libassuan (>= 2.4.2).
For support of the OpenPGP and the CMS protocols, you should use the
latest version of GnuPG (>= 2.1.18) , available at:
For support of the OpenPGP and the CMS protocols, you should use at
least GnuPG version 2.2.41 or 2.4.3, available at:
https://gnupg.org/ftp/gcrypt/gnupg/.
For building the Git version of GPGME please see the file README.GIT

View File

@ -11,4 +11,4 @@ case "$myhost" in
esac
final_info="./configure --enable-maintainer-mode && make"
final_info="mkdir build && cd build && ../configure --enable-maintainer-mode && make"

View File

@ -1,6 +1,6 @@
#! /bin/sh
# autogen.sh
# Copyright (C) 2003, 2014, 2017, 2018 g10 Code GmbH
# Copyright (C) 2003, 2014, 2017, 2018, 2022 g10 Code GmbH
#
# This file is free software; as a special exception the author gives
# unlimited permission to copy and/or distribute it, with or without
@ -15,7 +15,7 @@
# configure it for the respective package. It is maintained as part of
# GnuPG and source copied by other packages.
#
# Version: 2018-07-10
# Version: 2023-03-15
configure_ac="configure.ac"
@ -137,8 +137,6 @@ extraoptions=
# List of optional variables sourced from autogen.rc and ~/.gnupg-autogen.rc
w32_toolprefixes=
w32_extraoptions=
w32ce_toolprefixes=
w32ce_extraoptions=
w64_toolprefixes=
w64_extraoptions=
amd64_toolprefixes=
@ -146,7 +144,6 @@ amd64_toolprefixes=
# What follows are variables which are sourced but default to
# environment variables or lacking them hardcoded values.
#w32root=
#w32ce_root=
#w64root=
#amd64root=
@ -167,11 +164,6 @@ case "$1" in
myhost="w32"
shift
;;
--build-w32ce)
myhost="w32"
myhostsub="ce"
shift
;;
--build-w64)
myhost="w32"
myhostsub="64"
@ -203,7 +195,7 @@ if [ "$myhost" = "git-build" ]; then
die_p
make || fatal "error running make"
die_p
make check || fatal "error running male check"
make check || fatal "error running make check"
die_p
exit 0
fi
@ -241,10 +233,12 @@ if [ "$myhost" = "find-version" ]; then
if [ -z "$micro" ]; then
matchstr1="$package-$major.[0-9]*"
matchstr2="$package-$major-base"
matchstr3=""
vers="$major.$minor"
else
matchstr1="$package-$major.$minor.[0-9]*"
matchstr2="$package-$major.$minor-base"
matchstr2="$package-$major.[0-9]*-base"
matchstr3="$package-$major-base"
vers="$major.$minor.$micro"
fi
@ -252,13 +246,22 @@ if [ "$myhost" = "find-version" ]; then
if [ -e .git ]; then
ingit=yes
tmp=$(git describe --match "${matchstr1}" --long 2>/dev/null)
tmp=$(echo "$tmp" | sed s/^"$package"//)
if [ -n "$tmp" ]; then
tmp=$(echo "$tmp" | sed s/^"$package"// \
| awk -F- '$3!=0 && $3 !~ /^beta/ {print"-beta"$3}')
else
tmp=$(git describe --match "${matchstr2}" --long 2>/dev/null \
| awk -F- '$4!=0{print"-beta"$4}')
# (due tof "-base" in the tag we need to take the 4th field)
tmp=$(git describe --match "${matchstr2}" --long 2>/dev/null)
if [ -n "$tmp" ]; then
tmp=$(echo "$tmp" | sed s/^"$package"// \
| awk -F- '$4!=0 && $4 !~ /^beta/ {print"-beta"$4}')
elif [ -n "${matchstr3}" ]; then
tmp=$(git describe --match "${matchstr3}" --long 2>/dev/null)
if [ -n "$tmp" ]; then
tmp=$(echo "$tmp" | sed s/^"$package"// \
| awk -F- '$4!=0 && $4 !~ /^beta/ {print"-beta"$4}')
fi
fi
fi
[ -n "$tmp" ] && beta=yes
rev=$(git rev-parse --short HEAD | tr -d '\n\r')
@ -294,12 +297,6 @@ fi
# ******************
if [ "$myhost" = "w32" ]; then
case $myhostsub in
ce)
w32root="$w32ce_root"
[ -z "$w32root" ] && w32root="$HOME/w32ce_root"
toolprefixes="$w32ce_toolprefixes arm-mingw32ce"
extraoptions="$extraoptions $w32ce_extraoptions"
;;
64)
w32root="$w64root"
[ -z "$w32root" ] && w32root="$HOME/w64root"

View File

@ -0,0 +1,68 @@
#
# This is a sed script to patch the generated libtool,
# which works well against both of libtool 2.4.2 and 2.4.7.
#
# You may use this work under the terms of a Creative Commons CC0 1.0
# License/Waiver.
#
# CC0 Public Domain Dedication
# https://creativecommons.org/publicdomain/zero/1.0/
#
# This sed script applys two hunks of the patch:
#
# Part1: after the comment "# bleh windows"
# Part2: after the comment "#extension on DOS 8.3..."
#
# Only when those two parts are patched correctly, it exits with 0 or
# else, it exits with 1
#
# Find the part 1, by the comment
/^[ \t]*# bleh windows$/b part1_start
# Not found the part1, raise an error
$ q1
b
:part1_start
n
# The first line in the part 1 must be the begining of the case statement.
/^[ \t]*case \$host in$/! q1
n
# Insert the entry for x86_64-*mingw32*, for modified versuffix.
i\
x86_64-*mingw32*)
i\
func_arith $current - $age
i\
major=$func_arith_result
i\
versuffix="6-$major"
i\
;;
:part1_0
# Find the end of the case statement
/^[ \t]*esac$/b find_part2
# Not found the end of the case statement, raise an error
$ q1
n
b part1_0
:find_part2
/^[ \t]*# extension on DOS 8.3 file.*systems.$/b part2_process
# Not found the part2, raise an error
$ q1
n
b find_part2
:part2_process
$ q1
s/^[ \t]*\(versuffix=\)\(.*\)\(-$major\)\(.*\)$/\t case \$host in\n\t x86_64-*mingw32*)\n\t \1\26\3\4\n\t ;;\n\t *)\n\t \1\2\3\4\n\t ;;\n\t esac/
t part2_done
n
b part2_process
:part2_done
$ q0
n
b part2_done

View File

@ -482,7 +482,7 @@
% \def\foo{\parsearg\Xfoo}
% \def\Xfoo#1{...}
%
% Actually, I use \csname\string\foo\endcsname, ie. \\foo, as it is my
% Actually, I use \csname\string\foo\endcsname, i.e. \\foo, as it is my
% favourite TeX trick. --kasal, 16nov03
\def\parseargdef#1{%

View File

@ -31,8 +31,8 @@ min_automake_version="1.14"
# for the LT versions.
m4_define([mym4_package],[gpgme])
m4_define([mym4_major], [1])
m4_define([mym4_minor], [18])
m4_define([mym4_micro], [1])
m4_define([mym4_minor], [24])
m4_define([mym4_micro], [0])
# Below is m4 magic to extract and compute the git revision number,
# the decimalized short revision number, a beta version string and a
@ -53,20 +53,20 @@ AC_INIT([mym4_package],[mym4_version],[https://bugs.gnupg.org])
# (Interfaces added: AGE++)
# (Interfaces removed: AGE=0)
#
LIBGPGME_LT_CURRENT=38
LIBGPGME_LT_AGE=27
LIBGPGME_LT_REVISION=0
LIBGPGME_LT_CURRENT=43
LIBGPGME_LT_AGE=32
LIBGPGME_LT_REVISION=1
# If there is an ABI break in gpgmepp or qgpgme also bump the
# version in IMPORTED_LOCATION in the GpgmeppConfig-w32.cmake.in.in
LIBGPGMEPP_LT_CURRENT=21
LIBGPGMEPP_LT_AGE=15
LIBGPGMEPP_LT_REVISION=0
LIBGPGMEPP_LT_CURRENT=26
LIBGPGMEPP_LT_AGE=20
LIBGPGMEPP_LT_REVISION=1
LIBQGPGME_LT_CURRENT=16
LIBQGPGME_LT_AGE=1
LIBQGPGME_LT_REVISION=0
LIBQGPGME_LT_CURRENT=20
LIBQGPGME_LT_AGE=5
LIBQGPGME_LT_REVISION=1
################################################
AC_SUBST(LIBGPGME_LT_CURRENT)
@ -85,7 +85,7 @@ AC_SUBST(LIBQGPGME_LT_REVISION)
GPGME_CONFIG_API_VERSION=1
##############################################
NEED_GPG_ERROR_VERSION=1.36
NEED_GPG_ERROR_VERSION=1.47
NEED_LIBASSUAN_API=2
NEED_LIBASSUAN_VERSION=2.4.2
@ -206,6 +206,44 @@ esac
AM_CONDITIONAL(HAVE_LD_VERSION_SCRIPT, test "$have_ld_version_script" = "yes")
#
# Specify how we support our local modification of libtool for Windows
# 64-bit. Options are:
#
# (1) apply: when appying patch fails, it results failure of entire build
# (2) never: never apply the patch (no try)
# (3) try: use patched if it goes well, use original if fails
#
AC_ARG_WITH([libtool-modification],
AS_HELP_STRING([--with-libtool-modification=apply|never|try],
[how to handle libtool modification (default=never)]),
build_libtool_modification=$withval,
build_libtool_modification=never)
#
# Apply a patch (locally maintained one of ours) to libtool
#
case $host in
x86_64-*mingw32*)
AC_CONFIG_COMMANDS([libtool-patch],[[
if test "$build_selection" = never; then
echo "patch not applied"
elif (mv -f libtool libtool.orig; \
sed -f $srcdir/build-aux/libtool-patch.sed libtool.orig >libtool); then
echo "applied successfully"
elif test "$build_selection" = try; then
mv -f libtool.orig libtool
echo "patch failed, thus, using original"
else
echo "patch failed"
as_fn_exit 1
fi
]],[build_selection=$build_libtool_modification])
;;
*)
;;
esac
GPG_DEFAULT=no
GPGSM_DEFAULT=no
GPGCONF_DEFAULT=no
@ -219,7 +257,7 @@ have_macos_system=no
build_w32_glib=no
build_w32_qt=no
available_languages="cl cpp python qt qt5 qt6"
default_languages="cl cpp python qt"
default_languages="cl cpp python qt5 qt6"
case "${host}" in
x86_64-*mingw32*)
have_w64_system=yes
@ -300,14 +338,44 @@ if test x$fixed_search_path != x ; then
[Locate binaries only via this PATH])
fi
# Option --enable-reduce-relocations
#
# Allow building the Qt 6 bindings explicitly with -fPIC if the automatic
# detection fails. Note: We assume that this flag is always available (unless
# we built for Windows).
AC_ARG_ENABLE([reduce-relocations],
AS_HELP_STRING([--enable-reduce-relocations],
[build Qt 6 bindings with -fPIC (default is
auto)]),
[use_reduce_relocations="$enableval"],
[use_reduce_relocations=""])
# Option --enable-no-direct-extern-access
#
# Some distributions build Qt 6 with -mno-direct-extern-access. Libraries and
# applications using Qt then must also be build with this flag. As workaround
# for a bug in Qt's pkgconfig files which don't have this flag we allow
# building with this flag explicitly.
AC_LANG_PUSH(C++)
AX_CHECK_COMPILE_FLAG([-mno-direct-extern-access],
[have_no_direct_extern_access="yes"],
[have_no_direct_extern_access="no"],
[-Werror])
AC_LANG_POP()
AC_ARG_ENABLE([no-direct-extern-access],
AS_HELP_STRING([--enable-no-direct-extern-access],
[build Qt 6 bindings with
-mno-direct-extern-access (default is auto)]),
[use_no_direct_extern_access="$enableval"],
[use_no_direct_extern_access=""])
# Note: You need to declare all possible languages also in
# lang/Makefile.am's DIST_SUBDIRS.
AC_ARG_ENABLE([languages],
AS_HELP_STRING([--enable-languages=languages],
[enable only specific language bindings:
cl cpp python qt qt5 qt6 (qt selects qt5 or qt6,
and qt5 and qt6 exclude each other)]),
cl cpp python qt5 qt6]),
[enabled_languages=`echo $enableval | \
tr ',:' ' ' | tr '[A-Z]' '[a-z]' | \
sed 's/c++/cpp/'`],
@ -333,76 +401,95 @@ for language in $enabled_languages; do
fi
done
# Check whether Qt5 and/or Qt6 are enabled explicitly
want_qt5="no";
# Check whether qt5 and/or qt6 are enabled
want_qt5="no"
LIST_MEMBER("qt5", $enabled_languages)
if test "$found" = "1"; then
want_qt5="yes";
if test "$explicit_languages" = "1"; then
want_qt5="yes"
else
want_qt5="maybe"
fi
# Remove qt5; further down qt will be added
enabled_languages=$(echo $enabled_languages | sed 's/qt5//')
fi
want_qt6="no";
want_qt6="no"
LIST_MEMBER("qt6", $enabled_languages)
if test "$found" = "1"; then
want_qt6="yes";
if test "$explicit_languages" = "1"; then
want_qt6="yes"
else
want_qt6="maybe"
fi
# Remove qt6; further down qt will be added
enabled_languages=$(echo $enabled_languages | sed 's/qt6//')
fi
if test "$want_qt5" = "yes" -a "$want_qt6" = "yes"; then
AC_MSG_ERROR([[
# Check whether qt is enabled; if yes then it has been enabled explicitly
want_qt="no"
LIST_MEMBER("qt", $enabled_languages)
if test "$found" = "1"; then
# Ignore qt if specified together with qt5 or qt6
if test "$want_qt5" = "no" -a "$want_qt6" = "no"; then
want_qt="yes"
fi
# Remove qt
enabled_languages=$(echo $enabled_languages | sed 's/qt//')
AC_MSG_WARN([[
***
*** The bindings for Qt5 and Qt6 cannot be built simultaneously.
*** Language binding "qt" is deprecated and will be removed in a future version.
*** Use "qt5" and/or "qt6" instead.
***]])
fi
# Ensure that pkg-config is available for all calls of FIND_QT5/FIND_QT6
PKG_PROG_PKG_CONFIG
# If the generic qt is enabled, then check for Qt5 or Qt6 (in this order)
LIST_MEMBER("qt", $enabled_languages)
if test "$found" = "1"; then
# Remove the generic qt (qt5 and qt6 have already been removed)
enabled_languages=$(echo $enabled_languages | sed 's/qt//')
# Check for Qt 5 (if qt5 or qt is enabled)
if test "$want_qt" = "yes"; then
want_qt5="maybe"
fi
if test "$want_qt5" != "no"; then
FIND_QT5
if test "$have_qt5_libs" = "yes"; then
want_qt5="yes";
else
FIND_QT6
if test "$have_qt6_libs" = "yes"; then
want_qt6="yes";
else
if test "$explicit_languages" = "1"; then
AC_MSG_ERROR([[
***
*** Qt5 (Qt5Core) or Qt6 (Qt6Core) is required for the Qt binding.
***]])
else
AC_MSG_WARN([[
***
*** Qt5 (Qt5Core) and Qt6 (Qt6Core) not found. Qt Binding will be disabled.
***]])
fi
fi
fi
want_qt5="yes"
elif test "$want_qt5" = "yes"; then
FIND_QT5
if test "$have_qt5_libs" != "yes"; then
AC_MSG_ERROR([[
***
*** Qt5 (Qt5Core) is required for the Qt 5 binding.
***]])
else
want_qt5="no"
fi
elif test "$want_qt6" = "yes"; then
fi
# Check for Qt 6 (if qt6 is enabled or if qt is enabled and Qt 5 wasn't found)
if test "$want_qt" = "yes" -a "$have_qt5_libs" != "yes"; then
want_qt6="maybe"
fi
if test "$want_qt6" != "no"; then
FIND_QT6
if test "$have_qt6_libs" != "yes"; then
if test "$have_qt6_libs" = "yes"; then
want_qt6="yes";
elif test "$want_qt6" = "yes"; then
AC_MSG_ERROR([[
***
*** Qt6 (Qt6Core) is required for the Qt 6 binding.
***]])
else
want_qt6="no"
fi
fi
# Check that cpp is enabled if qt5 or qt6 is enabled
# Check if any Qt was found (if qt is enabled)
if test "$want_qt" = "yes" -a "$have_qt5_libs" != "yes" -a "$have_qt6_libs" != "yes"; then
AC_MSG_ERROR([[
***
*** Qt5 (Qt5Core) or Qt6 (Qt6Core) is required for the Qt bindings.
***]])
fi
# Check that cpp is enabled if qt5 or qt6 is enabled and was found
if test "$want_qt5" = "yes" -o "$want_qt6" = "yes"; then
LIST_MEMBER("cpp", $enabled_languages)
if test "$found" = "0"; then
@ -453,7 +540,7 @@ if test "$found" = "1" -a "$HAVE_CXX17" != "1"; then
fi
fi
# Now append qt to the list of language bindings
# Now append qt to the list of language bindings (to enable the subdir in lang)
if test "$want_qt5" = "yes" -o "$want_qt6" = "yes"; then
enabled_languages=$(echo $enabled_languages qt)
fi
@ -521,11 +608,12 @@ if test "$found_py" = "1"; then
if test "$found_py" = "1" -o "$found_py3" = "1"; then
# Reset everything, so that we can look for another Python.
m4_foreach([mym4pythonver],
[[2.7],[3.4],[3.5],[3.6],[3.7],[3.8],[3.9],[all]],
[[2.7],[3.6],[3.8],[3.9],[3.10],[3.11],[3.12],[all]],
[unset PYTHON
unset PYTHON_VERSION
unset PYTHON_CPPFLAGS
unset PYTHON_LDFLAGS
unset PYTHON_LIBS
unset PYTHON_SITE_PKG
unset PYTHON_EXTRA_LIBS
unset PYTHON_EXTRA_LDFLAGS
@ -536,7 +624,7 @@ if test "$found_py" = "1"; then
unset am_cv_python_pythondir
unset am_cv_python_pyexecdir
AM_PATH_PYTHON(mym4pythonver, [
AX_PYTHON_DEVEL
AX_PYTHON_DEVEL([], [true])
if test "$PYTHON_VERSION"; then
PYTHONS="$(echo $PYTHONS $PYTHON)"
PYTHON_VERSIONS="$(echo $PYTHON_VERSIONS $PYTHON_VERSION)"
@ -920,6 +1008,9 @@ AH_BOTTOM([
# define GPGME_GCC_A_PURE
#endif
/* Under Windows we use the gettext code from gpgrt. */
#define GPG_ERR_ENABLE_GETTEXT_MACROS 1
/* Under WindowsCE we need gpg-error's strerror macro. */
#define GPG_ERR_ENABLE_ERRNO_MACROS 1
@ -1072,7 +1163,9 @@ AC_CONFIG_FILES([lang/python/Makefile
AC_CONFIG_FILES([lang/python/setup.py], [chmod a+x lang/python/setup.py])
AC_OUTPUT
if test "$want_qt5" = "yes"; then
if test "$want_qt5" = "yes" -a "$want_qt6" = "yes"; then
enabled_languages_v=$(echo ${enabled_languages_v:-$enabled_languages} | sed "s/qt/qt (Qt 5, Qt 6)/")
elif test "$want_qt5" = "yes"; then
enabled_languages_v=$(echo ${enabled_languages_v:-$enabled_languages} | sed "s/qt/qt (Qt 5)/")
elif test "$want_qt6" = "yes"; then
enabled_languages_v=$(echo ${enabled_languages_v:-$enabled_languages} | sed "s/qt/qt (Qt 6)/")

View File

@ -551,7 +551,7 @@ convention for 32 bit Windows by using @code{long} there.
and thus we are able to use @code{int64_t} instead of @code{off_t}
there. For easier migration the typedef @code{gpgme_off_t} has been
defined. The reason we cannot use @code{off_t} directly is that some
toolchains (e.g. mingw64) introduce a POSIX compatible hack for
toolchains (e.g., mingw64) introduce a POSIX compatible hack for
@code{off_t}. Some widely used toolkits make use of this hack and in
turn @acronym{GPGME} would need to use it also. However, this would
introduce an ABI break and existing software making use of libgpgme
@ -589,10 +589,16 @@ mode (@code{_LARGEFILE64_SOURCE}).
@cindex automake
@cindex autoconf
It is much easier if you use GNU Automake instead of writing your own
Makefiles. If you do that you do not have to worry about finding and
invoking the @command{pkg-config} script at all. @acronym{GPGME}
provides an extension to Automake that does all the work for you.
You can simply use @code{PKG_CHECK_MODULES} macro with @command{pkg-config}:
@example
PKG_CHECK_MODULES([GPGME], [gpgme >= 1.23.1])
@end example
Alternatively, instead of using @command{pkg-config}, for building on
an environment with no pkg-config, @acronym{GPGME} provides an
extension to Automake that does all the work for you. Please note
that it is required to have gpgrt-config from libgpg-error installed
in this case.
@c A simple macro for optional variables.
@macro ovar{varname}
@ -1304,8 +1310,8 @@ returned.
The function @code{gpgme_pubkey_algo_string} is a convenience function
to build and return an algorithm string in the same way GnuPG does
(e.g. ``rsa2048'' or ``ed25519''). The caller must free the result
using @code{gpgme_free}. On error (e.g. invalid argument or memory
(e.g., ``rsa2048'' or ``ed25519''). The caller must free the result
using @code{gpgme_free}. On error (e.g., invalid argument or memory
exhausted), the function returns NULL and sets @code{ERRNO}.
@end deftypefun
@ -1649,6 +1655,11 @@ when requested.
@item GPG_ERR_CANCELED
This value means that the operation was canceled.
@item GPG_ERR_FULLY_CANCELED
This value means that the operation was canceled. It is sometimes returned
instead of @code{GPG_ERR_CANCELED} for internal reasons in GnuPG. You should
treat both values identically.
@item GPG_ERR_INV_ENGINE
This value means that the engine that implements the desired protocol
is currently not available. This can either be because the sources
@ -1790,7 +1801,7 @@ is used.
On POSIX platforms the @code{gpgme_off_t} type is an alias for
@code{off_t}; it may be used interchangeable. On Windows platforms
@code{gpgme_off_t} is defined as a long (i.e. 32 bit) for 32 bit
@code{gpgme_off_t} is defined as a long (i.e., 32 bit) for 32 bit
Windows and as a 64 bit signed integer for 64 bit Windows.
@end deftp
@ -2226,7 +2237,7 @@ for a new data object. The backend will try its best to detect the
encoding automatically.
@item GPGME_DATA_ENCODING_BINARY
This specifies that the data is encoding in binary form; i.e. there is
This specifies that the data is encoding in binary form; i.e., there is
no special encoding.
@item GPGME_DATA_ENCODING_BASE64
@ -2266,7 +2277,7 @@ characters percent escaped. This mode is is not yet implemented.
@deftypefun gpgme_data_encoding_t gpgme_data_get_encoding (@w{gpgme_data_t @var{dh}})
The function @code{gpgme_data_get_encoding} returns the encoding of
the data object with the handle @var{dh}. If @var{dh} is not a valid
pointer (e.g. @code{NULL}) @code{GPGME_DATA_ENCODING_NONE} is
pointer (e.g., @code{NULL}) @code{GPGME_DATA_ENCODING_NONE} is
returned.
@end deftypefun
@ -2367,7 +2378,7 @@ The data is a PKCS#12 message. This is commonly used to exchange
private keys for X.509.
@end table
@deftypefun gpgme_data_type_t gpgme_data_identify (@w{gpgme_data_t @var{dh}})
@deftypefun gpgme_data_type_t gpgme_data_identify (@w{gpgme_data_t @var{dh}, int @var{reserved}})
@since{1.4.3}
The function @code{gpgme_data_identify} returns the type of the data
@ -2377,6 +2388,7 @@ identification, the function returns zero
object has been created the identification may not be possible or the
data object may change its internal state (file pointer moved). For
file or memory based data object, the state should not change.
@var{reserved} should be zero.
@end deftypefun
@ -2595,7 +2607,7 @@ addresses is not supported.
The function @code{gpgme_set_sender} specifies the sender address for
use in sign and verify operations. @var{address} is expected to be
the ``addr-spec'' part of an address but my also be a complete mailbox
the ``addr-spec'' part of an address but may also be a complete mailbox
address, in which case this function extracts the ``addr-spec'' from
it. Using @code{NULL} for @var{address} clears the sender address.
@ -2688,8 +2700,9 @@ for example completely disable the use of Dirmngr for any engine.
For the CMS protocol the offline mode specifies whether Dirmngr shall
be used to do additional validation that might require connecting
external services (e.g. CRL / OCSP checks). Here the offline mode
only affects the keylist mode @code{GPGME_KEYLIST_MODE_VALIDATE}.
external services (e.g., CRL / OCSP checks). The offline mode is used
for all operations on this context. It has only an effect with
GnuPG versions 2.1.6 or later.
For the OpenPGP protocol offline mode entirely disables the use of the
Dirmngr and will thus guarantee that no network connections are done
@ -2894,6 +2907,12 @@ option also makes sure that the keygrip is available in the output.
The @code{GPGME_KEYLIST_MODE_EPHEMERAL} symbol specifies that keys
flagged as ephemeral are included in the listing.
@item GPGME_KEYLIST_MODE_WITH_V5FPR
@since{1.23.0}
The @code{GPGME_KEYLIST_MODE_WITH_V5FPR} symbol specifies that key
listings shall also provide v5 style fingerprints for v4 OpenPGp keys.
@item GPGME_KEYLIST_MODE_VALIDATE
@since{0.4.5}
@ -3260,8 +3279,14 @@ The string given in @var{value} is passed to the GnuPG engine to use as
filter when importing keys. Valid values are documented in the GnuPG
manual and the gpg man page under the option @option{--import-filter}.
@item "import-options"
@since{1.24.0}
The string given in @var{value} is passed to the GnuPG engine to use as
options when importing keys. Valid values are documented in the GnuPG
manual and the gpg man page under the option @option{--import-options}.
@item "no-auto-check-trustdb"
@since{1.18.1}
@since{1.19.0}
Setting the @var{value} to "1" forces the GPG backend to disable the
automatic check of the trust database.
@ -3448,22 +3473,47 @@ listings if the key could not be validated due to missing
certificates or unmatched policies.
@item unsigned int can_encrypt : 1
This is true if the key (ie one of its subkeys) can be used for
encryption.
This is true if the key or one of its subkeys can be used for
encryption and the encryption will likely succeed.
@item unsigned int can_sign : 1
This is true if the key (ie one of its subkeys) can be used to create
data signatures.
This is true if the key or one of its subkeys can be used to create
data signatures and the signing will likely succeed.
@item unsigned int can_certify : 1
This is true if the key (ie one of its subkeys) can be used to create
This is true if the key or one of its subkeys can be used to create
key certificates.
@item unsigned int can_authenticate : 1
@since{0.4.5}
This is true if the key (ie one of its subkeys) can be used for
authentication.
authentication and the authentication will likely succeed.
@item unsigned int has_encrypt : 1
@since{1.23.0}
This is true if the key or one of its subkeys is capable of encryption.
Note that this flag is set even if the key is expired.
@item unsigned int has_sign : 1
@since{1.23.0}
This is true if the key or one of its subkeys is capable of signing.
Note that this flag is set even if the key is expired.
@item unsigned int has_certify : 1
@since{1.23.0}
This is true if the key or one of its subkeys is capable of
certification. Note that this flag is set even if the key is expired.
@item unsigned int has_authenticate : 1
@since{1.23.0}
This is true if the key or one of its subkeys is capable of
authentication. Note that this flag is set even if the key is
expired.
@item unsigned int is_qualified : 1
@since{1.1.0}
@ -3522,6 +3572,10 @@ be missing but this field may be set nevertheless.
Reserved for the time of the last update of this key.
@item gpgme_revocation_key_t revkeys
@since{1.24.0}
This is a linked list with the revocation keys for the key.
@end table
@end deftp
@ -3585,7 +3639,7 @@ Brainpool curve.
@item unsigned int secret : 1
This is true if the subkey is a secret key. Note that it will be
false if the key is actually a stub key; i.e. a secret key operation
false if the key is actually a stub key; i.e., a secret key operation
is currently not possible (offline-key). This is only set if a
listing of secret keys has been requested or if
@code{GPGME_KEYLIST_MODE_WITH_SECRET} is active.
@ -3603,6 +3657,10 @@ This is the key ID of the subkey in hexadecimal digits.
This is the fingerprint of the subkey in hexadecimal digits, if
available.
@item char *v5fpr
For a v4 OpenPGP key this is its v5 style fingerprint of the subkey in
hexadecimal digits, if available.
@item char *keygrip
@since{1.7.0}
@ -3860,6 +3918,37 @@ This is a linked list with the notation data and policy URLs.
@end deftp
@deftp {Data type} gpgme_revocation_key_t
@since{1.24.0}
The @code{gpgme_revocation_key_t} type is a pointer to a revocation key
structure. Revocation key structures are one component of a
@code{gpgme_key_t} object. They provide information about the designated
revocation keys for a key.
The revocation key structure has the following members:
@table @code
@item gpgme_revocation_key_t next
This is a pointer to the next revocation key structure in the linked list,
or @code{NULL} if this is the last element.
@item gpgme_pubkey_algo_t pubkey_algo
This is the public key algorithm of the revocation key.
@item char *fpr
This is the fingerprint of the revocation_key in hexadecimal digits.
@item unsigned int key_class
This is the class of the revocation key signature subpacket.
@item unsigned int sensitive : 1
This is true if the revocation key is marked as sensitive.
@end table
@end deftp
@node Listing Keys
@subsection Listing Keys
@ -4224,7 +4313,7 @@ GnuPG.
@var{userid} is commonly the mail address associated with the key.
GPGME does not require a specific syntax but if more than a mail
address is given, RFC-822 style format is suggested. The value is
expected to be in UTF-8 encoding (i.e. no IDN encoding for mail
expected to be in UTF-8 encoding (i.e., no IDN encoding for mail
addresses). This is a required parameter.
@var{algo} specifies the algorithm for the new key (actually a keypair
@ -4307,6 +4396,14 @@ override this check.
Request generation of keys that do not expire.
@item GPGME_CREATE_ADSK
@since{1.24.0}
Add an ADSK to the key. With this flag @var{algo} is expected to be
the hexified fingerprint of the ADSK to be added; this must be a
subkey. If the string "default" is used for @var{algo} the engine
will add all ADSK as it would do for new keys.
@end table
After the operation completed successfully, information about the
@ -4382,6 +4479,10 @@ values for timestamps and thus can only encode dates up to the year
@var{flags} takes the same values as described above for
@code{gpgme_op_createkey}.
If the @code{GPGME_CREATE_ADSK} flag is set, the subkey fingerprint
given in the @code{algo} parameter is added as an ADSK
to the key.
After the operation completed successfully, information about the
created key can be retrieved with @code{gpgme_op_genkey_result}.
@ -4433,7 +4534,7 @@ requires at least version 2.1.13 of GnuPG.
the mail address to be associated with the key. GPGME does not
require a specific syntax but if more than a mail address is given,
RFC-822 style format is suggested. The value is expected to be in
UTF-8 encoding (i.e. no IDN encoding for mail addresses). This is a
UTF-8 encoding (i.e., no IDN encoding for mail addresses). This is a
required parameter.
@var{flags} are currently not used and must be set to zero.
@ -4642,7 +4743,7 @@ retrieved with @code{gpgme_op_genkey_result}.
The function returns the error code @code{GPG_ERR_NO_ERROR} if the
operation could be started successfully, @code{GPG_ERR_INV_VALUE} if
@var{parms} is not a well-formed string (e.g. does not have the
@var{parms} is not a well-formed string (e.g., does not have the
expected tag-like headers and footers), @code{GPG_ERR_NOT_SUPPORTED}
if @var{public} or @var{secret} is not valid, and
@code{GPG_ERR_GENERAL} if no key was created by the backend.
@ -5105,7 +5206,7 @@ The function @code{gpgme_op_import_keys} adds the keys described by
the @code{NULL} terminated array @var{keys} to the key ring of the
crypto engine used by @var{ctx}. It is used to actually import and
make keys permanent which have been retrieved from an external source
(i.e. using @code{GPGME_KEYLIST_MODE_EXTERN}) earlier. The external
(i.e., using @code{GPGME_KEYLIST_MODE_EXTERN}) earlier. The external
keylisting must have been made with the same context configuration (in
particular the same home directory). @footnote{Thus it is a
replacement for the usual workaround of exporting and then importing a
@ -5115,7 +5216,7 @@ require another access to the keyserver over the network.
Only keys of the currently selected protocol of @var{ctx} are
considered for import. Other keys specified by the @var{keys} are
ignored. As of now all considered keys must have been retrieved using
the same method, i.e. the used key listing mode must be identical.
the same method, i.e., the used key listing mode must be identical.
After the operation completed successfully, the result can be
retrieved with @code{gpgme_op_import_result}.
@ -5187,7 +5288,7 @@ This is a pointer to the next status structure in the linked list, or
@item char *fpr
This is the fingerprint of the key that was considered, or @code{NULL}
if the fingerprint of the key is not known, e.g. because the key to
if the fingerprint of the key is not known, e.g., because the key to
import was encrypted and decryption failed.
@item gpgme_error_t result
@ -5335,16 +5436,19 @@ operation was started successfully, and @code{GPG_ERR_INV_VALUE} if
@var{ctx} or @var{key} is not a valid pointer.
@end deftypefun
The following functions allow only to use one particular flag.
The following functions allow only to use one particular flag. Their
use is thus deprecated.
@deftypefun gpgme_error_t gpgme_op_delete (@w{gpgme_ctx_t @var{ctx}}, @w{const gpgme_key_t @var{key}}, @w{int @var{allow_secret}})
Similar to @code{gpgme_op_delete_ext}, but only the flag
@code{GPGME_DELETE_ALLOW_SECRET} can be provided.
@code{GPGME_DELETE_ALLOW_SECRET} can be provided. Actually all true
values are mapped to this flag.
@end deftypefun
@deftypefun gpgme_error_t gpgme_op_delete_start (@w{gpgme_ctx_t @var{ctx}}, @w{const gpgme_key_t @var{key}}, @w{int @var{allow_secret}})
Similar to @code{gpgme_op_delete_ext_start}, but only the flag
@code{GPGME_DELETE_ALLOW_SECRET} can be provided.
@code{GPGME_DELETE_ALLOW_SECRET} can be provided. Actually all true
values are mapped to this flag.
@end deftypefun
@ -5586,7 +5690,10 @@ An error code describing the reason why the key was found invalid.
@deftypefun gpgme_error_t gpgme_op_decrypt (@w{gpgme_ctx_t @var{ctx}}, @w{gpgme_data_t @var{cipher}}, @w{gpgme_data_t @var{plain}})
The function @code{gpgme_op_decrypt} decrypts the ciphertext in the
data object @var{cipher} and stores it into the data object
data object @var{cipher} or, if a file name is set on the data object,
the ciphertext stored in the corresponding file. The decrypted
ciphertext is stored into the data object @var{plain} or written to
the file set with @code{gpgme_data_set_file_name} for the data object
@var{plain}.
The function returns the error code @code{GPG_ERR_NO_ERROR} if the
@ -5800,7 +5907,12 @@ detached signature, then the signed text should be provided in
Otherwise, if @var{sig} is a normal (or cleartext) signature,
@var{signed_text} should be a null pointer and @var{plain} should be a
writable data object that will contain the plaintext after successful
verification.
verification. If a file name is set on the data object @var{sig} (or
on the data object @var{signed_text}), then the data of the signature
(resp. the data of the signed text) is not read from the data object
but from the file with the given file name. If a file name is set on
the data object @var{plain} then the plaintext is not stored in the
data object but it is written to a file with the given file name.
The results of the individual signature verifications can be retrieved
with @code{gpgme_op_verify_result}.
@ -5979,7 +6091,7 @@ The defined bits are:
@item GPGME_SIGSUM_RED
The signature is bad. It might be useful to check other bits and
display more information, i.e. a revoked certificate might not render a
display more information, i.e., a revoked certificate might not render a
signature invalid when the message was received prior to the cause for
the revocation.
@ -6225,7 +6337,7 @@ functions in GPGME and GnuPG:
Return the mail address (called ``addr-spec'' in RFC-5322) from the
string @var{uid} which is assumed to be a user id (called ``address''
in RFC-5322). All plain ASCII characters (i.e. those with bit 7
in RFC-5322). All plain ASCII characters (i.e., those with bit 7
cleared) in the result are converted to lowercase. Caller must free
the result using @code{gpgme_free}. Returns @code{NULL} if no valid
address was found (in which case @code{ERRNO} is set to @code{EINVAL})
@ -6320,23 +6432,40 @@ A signed archive is created from the given files and directories. This
feature is currently only supported for the OpenPGP crypto engine and requires
GnuPG 2.4.1.
@item GPGME_SIG_MODE_FILE
@since{1.24.0}
The filename set with @code{gpgme_data_set_file_name} for the data object
@var{plain} is passed to gpg, so that gpg reads the plaintext directly from
this file instead of from the data object @var{plain}. This flag can be
combined with @code{GPGME_SIG_MODE_NORMAL}, @code{GPGME_SIG_MODE_DETACH},
and @code{GPGME_SIG_MODE_CLEAR}, but not with @code{GPGME_SIG_MODE_ARCHIVE}.
This feature is currently only supported for the OpenPGP crypto engine.
@end table
@end deftp
@deftypefun gpgme_error_t gpgme_op_sign (@w{gpgme_ctx_t @var{ctx}}, @w{gpgme_data_t @var{plain}}, @w{gpgme_data_t @var{sig}}, @w{gpgme_sig_mode_t @var{mode}})
The function @code{gpgme_op_sign} creates a signature for the text in
the data object @var{plain} and returns it in the data object
@var{sig}. The type of the signature created is determined by the
@acronym{ASCII} armor (or, if that is not set, by the encoding
specified for @var{sig}), the text mode attributes set for the context
@var{ctx} and the requested signature mode @var{mode}.
@var{sig} or writes it directly to the file set with
@code{gpgme_data_set_file_name} for the data object @var{sig}. The type
of the signature created is determined by the @acronym{ASCII} armor (or,
if that is not set, by the encoding specified for @var{sig}), the text
mode attributes set for the context @var{ctx} and the requested signature
mode @var{mode}.
If signature mode @code{GPGME_SIG_MODE_ARCHIVE} is requested, then a
If the signature mode flag @code{GPGME_SIG_MODE_FILE} is set and a filename
has been set with @code{gpgme_data_set_file_name} for the data object
@var{plain}, then this filename is passed to gpg, so that gpg reads the
plaintext directly from this file instead of from the data object @var{plain}.
If signature mode @code{GPGME_SIG_MODE_ARCHIVE} is requested then a
signed archive is created from the files and directories given as
NUL-separated list in the data object @var{plain} and returned in the
data object @var{sig}. The paths of the files and directories have to
be given as paths relative to the current working directory or relative
to the base directory set with @code{gpgme_data_set_file_name}.
NUL-separated list in the data object @var{plain}. The paths of the files
and directories have to be given as paths relative to the current working
directory or relative to the base directory set with
@code{gpgme_data_set_file_name} for the data object @var{plain}.
After the operation completed successfully, the result can be
retrieved with @code{gpgme_op_sign_result}.
@ -6504,17 +6633,26 @@ and then passed to the encryption operation.
@deftypefun gpgme_error_t gpgme_op_encrypt (@w{gpgme_ctx_t @var{ctx}}, @w{gpgme_key_t @var{recp}[]}, @w{gpgme_encrypt_flags_t @var{flags}}, @w{gpgme_data_t @var{plain}}, @w{gpgme_data_t @var{cipher}})
The function @code{gpgme_op_encrypt} encrypts the plaintext in the
data object @var{plain} for the recipients @var{recp} and stores the
ciphertext in the data object @var{cipher}. The type of the
ciphertext created is determined by the @acronym{ASCII} armor (or, if
that is not set, by the encoding specified for @var{cipher}) and the
text mode attributes set for the context @var{ctx}.
ciphertext in the data object @var{cipher} or writes it directly to the
file set with @code{gpgme_data_set_file_name} for the data object
@var{cipher}. The type of the ciphertext created is determined by the
@acronym{ASCII} armor (or, if that is not set, by the encoding specified
for @var{cipher}) and the text mode attributes set for the context
@var{ctx}. If a filename has been set with @code{gpgme_data_set_file_name}
for the data object @var{plain} then this filename is stored in the
ciphertext.
If the flag @code{GPGME_ENCRYPT_FILE} is set and a filename has been set
with @code{gpgme_data_set_file_name} for the data object @var{plain},
then this filename is passed to gpg, so that gpg reads the plaintext
directly from this file instead of from the data object @var{plain}.
If the flag @code{GPGME_ENCRYPT_ARCHIVE} is set, then an encrypted
archive is created from the files and directories given as NUL-separated
list in the data object @var{plain} and returned in the data object
@var{cipher}. The paths of the files and directories have to
be given as paths relative to the current working directory or relative
to the base directory set with @code{gpgme_data_set_file_name}.
list in the data object @var{plain}. The paths of the files and
directories have to be given as paths relative to the current working
directory or relative to the base directory set with
@code{gpgme_data_set_file_name} for the data object @var{plain}.
@var{recp} must be a @code{NULL}-terminated array of keys. The user
must keep references for all keys during the whole duration of the
@ -6531,6 +6669,10 @@ recipients in @var{recp} should be trusted, even if the keys do not
have a high enough validity in the keyring. This flag should be used
with care; in general it is not a good idea to use any untrusted keys.
For the S/MIME (CMS) protocol this flag allows to encrypt to a
certificate without running any checks on the validity of the
certificate.
@item GPGME_ENCRYPT_NO_ENCRYPT_TO
@since{1.2.0}
@ -6550,7 +6692,7 @@ may reveal information about the plaintext.
@item GPGME_ENCRYPT_PREPARE
@itemx GPGME_ENCRYPT_EXPECT_SIGN
The @code{GPGME_ENCRYPT_PREPARE} symbol is used with the UI Server
protocol to prepare an encryption (i.e. sending the
protocol to prepare an encryption (i.e., sending the
@code{PREP_ENCRYPT} command). With the
@code{GPGME_ENCRYPT_EXPECT_SIGN} symbol the UI Server is advised to
also expect a sign command.
@ -6599,6 +6741,15 @@ NUL-separated list of file paths and directory paths that shall be
encrypted into an archive. This feature is currently only supported
for the OpenPGP crypto engine and requires GnuPG 2.4.1.
@item GPGME_ENCRYPT_FILE
@since{1.24.0}
The @code{GPGME_ENCRYPT_FILE} symbol specifies that the filename set
with @code{gpgme_data_set_file_name} for the data object @var{plain}
is passed to gpg, so that gpg reads the plaintext directly from this
file instead of from the data object @var{plain}. This feature is
currently only supported for the OpenPGP crypto engine.
@end table
If @code{GPG_ERR_UNUSABLE_PUBKEY} is returned, some recipients in
@ -7934,6 +8085,15 @@ reveal sensitive details like passphrases or other data you use in
your application. If you are asked to send a log file, make sure that
you run your tests only with play data.
The trace function makes use of gpgrt's logging function and thus the
special @file{socket://} and @file{tcp://} files may be used. Because
this conflicts with the use of colons to separate fields, the following
hack is used: If the file name contains the string @code{^//} all
carets are replaced by colons. For example to log to TCP port 42042
this can be used:
@smallexample
GPGME_DEBUG=5:tcp^//127.0.0.1^42042
@end smallexample
@node Deprecated Functions
@appendix Deprecated Functions

View File

@ -498,7 +498,7 @@
% \def\foo{\parsearg\Xfoo}
% \def\Xfoo#1{...}
%
% Actually, I use \csname\string\foo\endcsname, ie. \\foo, as it is my
% Actually, I use \csname\string\foo\endcsname, i.e. \\foo, as it is my
% favourite TeX trick. --kasal, 16nov03
\def\parseargdef#1{%

View File

@ -18,6 +18,12 @@
# License along with this program; if not, see <https://gnu.org/licenses/>.
# SPDX-License-Identifier: LGPL-2.1-or-later
SUBDIRS = src tests
if RUN_GPG_TESTS
tests = tests
else
tests =
endif
SUBDIRS = src ${tests}
EXTRA_DIST = README

View File

@ -88,6 +88,14 @@ else
libsuffix=.so
endif
copied_headers = $(gpgmepp_headers:%=gpgme++/%) $(interface_headers:%=gpgme++/%)
$(copied_headers): Makefile.am
mkdir -p $(builddir)/gpgme++/interfaces
echo -n "#include \"$(abs_srcdir)" > "$@"
echo -n "$@" | sed "s/gpgme++//" >> "$@"
echo "\"" >> "$@"
if HAVE_W32_SYSTEM
GpgmeppConfig.cmake: GpgmeppConfig-w32.cmake.in
sed -e 's|[@]resolved_bindir@|$(bindir)|g' < "$<" | \
@ -115,5 +123,8 @@ install-data-local: install-cmake-files
uninstall-local: uninstall-cmake-files
BUILT_SOURCES = $(copied_headers)
CLEANFILES = GpgmeppConfig.cmake GpgmeppConfigVersion.cmake \
gpgmepp_version.h GpgmeppConfig.cmake.in
gpgmepp_version.h GpgmeppConfig.cmake.in \
$(copied_headers)

View File

@ -257,158 +257,6 @@ Type Option::alternateType() const
return isNull() ? NoType : static_cast<Type>(opt->alt_type) ;
}
#if 0
static Option::Variant argument_to_variant(gpgme_conf_type_t type, bool list, gpgme_conf_arg_t arg)
{
assert(arg);
switch (type) {
case GPGME_CONF_NONE:
if (list) {
// return the count (number of times set):
return arg->value.count;
} else {
return none;
}
case GPGME_CONF_INT32:
if (list) {
std::vector<int> result;
for (gpgme_conf_arg_t a = arg ; a ; a = a->next) {
result.push_back(a->value.int32);
}
return result;
} else {
return arg->value.int32;
}
case GPGME_CONF_UINT32:
if (list) {
std::vector<unsigned int> result;
for (gpgme_conf_arg_t a = arg ; a ; a = a->next) {
result.push_back(a->value.uint32);
}
return result;
} else {
return arg->value.uint32;
}
case GPGME_CONF_FILENAME:
case GPGME_CONF_LDAP_SERVER:
case GPGME_CONF_KEY_FPR:
case GPGME_CONF_PUB_KEY:
case GPGME_CONF_SEC_KEY:
case GPGME_CONF_ALIAS_LIST:
// these should not happen in alt_type, but fall through
case GPGME_CONF_STRING:
if (list) {
std::vector<const char *> result;
for (gpgme_conf_arg_t a = arg ; a ; a = a->next) {
result.push_back(a->value.string);
}
return result;
} else {
return arg->value.string;
}
}
assert(!"Option: unknown alt_type!");
return Option::Variant();
}
namespace
{
inline const void *to_void_star(const char *s)
{
return s;
}
inline const void *to_void_star(const std::string &s)
{
return s.c_str();
}
inline const void *to_void_star(const int &i)
{
return &i; // const-&: sic!
}
inline const void *to_void_star(const unsigned int &i)
{
return &i; // const-&: sic!
}
struct VariantToArgumentVisitor : boost::static_visitor<gpgme_conf_arg_t> {
static gpgme_conf_arg_t make_argument(gpgme_conf_type_t type, const void *value)
{
gpgme_conf_arg_t arg = 0;
#ifdef HAVE_GPGME_CONF_ARG_NEW_WITH_CONST_VALUE
if (const gpgme_error_t err = gpgme_conf_arg_new(&arg, type, value)) {
return 0;
}
#else
if (const gpgme_error_t err = gpgme_conf_arg_new(&arg, type, const_cast<void *>(value))) {
return 0;
}
#endif
else {
return arg;
}
}
gpgme_conf_arg_t operator()(bool v) const
{
return v ? make_argument(0) : 0 ;
}
gpgme_conf_arg_t operator()(const char *s) const
{
return make_argument(s ? s : "");
}
gpgme_conf_arg_t operator()(const std::string &s) const
{
return operator()(s.c_str());
}
gpgme_conf_arg_t operator()(int i) const
{
return make_argument(&i);
}
gpgme_conf_arg_t operator()(unsigned int i) const
{
return make_argument(&i);
}
template <typename T>
gpgme_conf_arg_t operator()(const std::vector<T> &value) const
{
gpgme_conf_arg_t result = 0;
gpgme_conf_arg_t last = 0;
for (typename std::vector<T>::const_iterator it = value.begin(), end = value.end() ; it != end ; ++it) {
if (gpgme_conf_arg_t arg = make_argument(to_void_star(*it))) {
if (last) {
last = last->next = arg;
} else {
result = last = arg;
}
}
}
return result;
}
};
}
static gpgme_conf_arg_t variant_to_argument(const Option::Variant &value)
{
VariantToArgumentVisitor v;
return apply_visitor(v, value);
}
optional<Option::Variant> Option::defaultValue() const
{
if (isNull()) {
return optional<Variant>();
} else {
return argument_to_variant(opt->alt_type, opt->flags & GPGME_CONF_LIST, opt->default_value);
}
}
#endif
Argument Option::defaultValue() const
{
if (isNull()) {

View File

@ -190,7 +190,7 @@ public:
/*! The value that is in the config file (or null, if it's not set). */
Argument activeValue() const;
/*! The value that is in this object, ie. either activeValue(), newValue(), or defaultValue() */
/*! The value that is in this object, i.e. either activeValue(), newValue(), or defaultValue() */
Argument currentValue() const;
Argument newValue() const;

View File

@ -130,6 +130,13 @@ const char *Error::asString() const
return mMessage.c_str();
}
std::string Error::asStdString() const
{
std::string message;
format_error(static_cast<gpgme_error_t>(mErr), message);
return message;
}
int Error::code() const
{
return gpgme_err_code(mErr);
@ -142,16 +149,12 @@ int Error::sourceID() const
bool Error::isCanceled() const
{
return code() == GPG_ERR_CANCELED;
return code() == GPG_ERR_CANCELED || code() == GPG_ERR_FULLY_CANCELED;
}
int Error::toErrno() const
{
//#ifdef HAVE_GPGME_GPG_ERROR_WRAPPERS
return gpgme_err_code_to_errno(static_cast<gpgme_err_code_t>(code()));
//#else
// return gpg_err_code_to_errno( static_cast<gpg_err_code_t>( code() ) );
//#endif
}
// static
@ -192,7 +195,7 @@ Error Error::fromCode(unsigned int err, unsigned int src)
std::ostream &operator<<(std::ostream &os, const Error &err)
{
return os << "GpgME::Error(" << err.encodedError() << " (" << err.asString() << "))";
return os << "GpgME::Error(" << err.encodedError() << " (" << err.asStdString() << "))";
}
Context::KeyListModeSaver::KeyListModeSaver(Context *ctx)
@ -1070,7 +1073,7 @@ DecryptionResult Context::decrypt(const Data &cipherText, Data &plainText, const
const Data::Private *const cdp = cipherText.impl();
Data::Private *const pdp = plainText.impl();
d->lasterr = gpgme_op_decrypt_ext(d->ctx, static_cast<gpgme_decrypt_flags_t> (d->decryptFlags | flags), cdp ? cdp->data : nullptr, pdp ? pdp->data : nullptr);
return DecryptionResult(d->ctx, Error(d->lasterr));
return decryptionResult();
}
DecryptionResult Context::decrypt(const Data &cipherText, Data &plainText)
@ -1107,7 +1110,7 @@ VerificationResult Context::verifyDetachedSignature(const Data &signature, const
const Data::Private *const sdp = signature.impl();
const Data::Private *const tdp = signedText.impl();
d->lasterr = gpgme_op_verify(d->ctx, sdp ? sdp->data : nullptr, tdp ? tdp->data : nullptr, nullptr);
return VerificationResult(d->ctx, Error(d->lasterr));
return verificationResult();
}
VerificationResult Context::verifyOpaqueSignature(const Data &signedData, Data &plainText)
@ -1116,7 +1119,7 @@ VerificationResult Context::verifyOpaqueSignature(const Data &signedData, Data &
const Data::Private *const sdp = signedData.impl();
Data::Private *const pdp = plainText.impl();
d->lasterr = gpgme_op_verify(d->ctx, sdp ? sdp->data : nullptr, nullptr, pdp ? pdp->data : nullptr);
return VerificationResult(d->ctx, Error(d->lasterr));
return verificationResult();
}
Error Context::startDetachedSignatureVerification(const Data &signature, const Data &signedText)
@ -1138,9 +1141,18 @@ Error Context::startOpaqueSignatureVerification(const Data &signedData, Data &pl
VerificationResult Context::verificationResult() const
{
if (d->lastop & Private::Verify) {
return VerificationResult(d->ctx, Error(d->lasterr));
const auto res = VerificationResult{d->ctx, Error(d->lasterr)};
if ((d->lastop == Private::DecryptAndVerify)
&& (res.error().code() == GPG_ERR_NO_DATA)
&& (res.numSignatures() > 0)) {
// ignore "no data" error for verification if there are signatures and
// the operation was a combined (tentative) decryption and verification
// because then "no data" just indicates that there was nothing to decrypt
return VerificationResult{d->ctx, Error{}};
}
return res;
} else {
return VerificationResult();
return {};
}
}
@ -1151,8 +1163,7 @@ std::pair<DecryptionResult, VerificationResult> Context::decryptAndVerify(const
Data::Private *const pdp = plainText.impl();
d->lasterr = gpgme_op_decrypt_ext(d->ctx, static_cast<gpgme_decrypt_flags_t> (d->decryptFlags | flags | DecryptVerify),
cdp ? cdp->data : nullptr, pdp ? pdp->data : nullptr);
return std::make_pair(DecryptionResult(d->ctx, Error(d->lasterr)),
VerificationResult(d->ctx, Error(d->lasterr)));
return std::make_pair(decryptionResult(), verificationResult());
}
std::pair<DecryptionResult, VerificationResult> Context::decryptAndVerify(const Data &cipherText, Data &plainText)
@ -1293,6 +1304,9 @@ static gpgme_sig_mode_t sigflags2sigflags(SignatureMode flags)
if (flags & SignatureMode::SignArchive) {
result |= GPGME_SIG_MODE_ARCHIVE;
}
if (flags & SignatureMode::SignFile) {
result |= GPGME_SIG_MODE_FILE;
}
return static_cast<gpgme_sig_mode_t>(result);
}
@ -1343,9 +1357,21 @@ static gpgme_encrypt_flags_t encryptflags2encryptflags(Context::EncryptionFlags
if (flags & Context::Symmetric) {
result |= GPGME_ENCRYPT_SYMMETRIC;
}
if (flags & Context::ThrowKeyIds) {
result |= GPGME_ENCRYPT_THROW_KEYIDS;
}
if (flags & Context::EncryptWrap) {
result |= GPGME_ENCRYPT_WRAP;
}
if (flags & Context::WantAddress) {
result |= GPGME_ENCRYPT_WANT_ADDRESS;
}
if (flags & Context::EncryptArchive) {
result |= GPGME_ENCRYPT_ARCHIVE;
}
if (flags & Context::EncryptFile) {
result |= GPGME_ENCRYPT_FILE;
}
return static_cast<gpgme_encrypt_flags_t>(result);
}
@ -1776,6 +1802,16 @@ Error Context::startRevokeSignature(const Key &key, const Key &signingKey,
key.impl(), signingKey.impl(), uids.c_str(), flags));
}
Error Context::addAdsk(const Key &k, const char *adsk)
{
return Error(d->lasterr = gpgme_op_createsubkey(d->ctx, k.impl(), adsk, 0, 0, GPGME_CREATE_ADSK));
}
Error Context::startAddAdsk(const Key &k, const char *adsk)
{
return Error(d->lasterr = gpgme_op_createsubkey_start(d->ctx, k.impl(), adsk, 0, 0, GPGME_CREATE_ADSK));
}
Error Context::setFlag(const char *name, const char *value)
{
return Error(d->lasterr = gpgme_set_ctx_flag(d->ctx, name, value));
@ -1897,11 +1933,20 @@ std::ostream &operator<<(std::ostream &os, KeyListMode mode)
std::ostream &operator<<(std::ostream &os, SignatureMode mode)
{
os << "GpgME::SignatureMode(";
#define CHECK( x ) if ( !(mode & (x)) ) {} else do { os << #x " "; } while (0)
#undef CHECK
switch (mode & (NormalSignatureMode|Detached|Clearsigned)) {
#define CHECK( x ) case x: os << #x; break
CHECK(NormalSignatureMode);
CHECK(Detached);
CHECK(Clearsigned);
#undef CHECK
default:
os << "???" "(" << static_cast<int>(mode) << ')';
break;
}
#define CHECK( x ) if ( !(mode & (x)) ) {} else do { os << #x " "; } while (0)
CHECK(SignArchive);
CHECK(SignFile);
#undef CHECK
return os << ')';
}
@ -1916,7 +1961,11 @@ std::ostream &operator<<(std::ostream &os, Context::EncryptionFlags flags)
CHECK(ExpectSign);
CHECK(NoCompress);
CHECK(Symmetric);
CHECK(ThrowKeyIds);
CHECK(EncryptWrap);
CHECK(WantAddress);
CHECK(EncryptArchive);
CHECK(EncryptFile);
#undef CHECK
return os << ')';
}

View File

@ -324,6 +324,9 @@ public:
Error startRevokeSignature(const Key &key, const Key &signingKey,
const std::vector<UserID> &userIds = std::vector<UserID>());
Error addAdsk(const Key &k, const char *adsk);
Error startAddAdsk(const Key &k, const char *adsk);
// using TofuInfo::Policy
Error setTofuPolicy(const Key &k, unsigned int policy);
Error setTofuPolicyStart(const Key &k, unsigned int policy);
@ -370,6 +373,7 @@ public:
// Keep in line with core's flags
DecryptNone = 0,
DecryptVerify = 1,
DecryptArchive = 2,
DecryptUnwrap = 128,
DecryptMaxValue = 0x80000000
};
@ -448,7 +452,9 @@ public:
Symmetric = 32,
ThrowKeyIds = 64,
EncryptWrap = 128,
WantAddress = 256,
EncryptArchive = 512,
EncryptFile = 1024
};
EncryptionResult encrypt(const std::vector<Key> &recipients, const Data &plainText, Data &cipherText, EncryptionFlags flags);
GpgME::Error encryptSymmetrically(const Data &plainText, Data &cipherText);

View File

@ -1,41 +0,0 @@
/*
context_glib.cpp - wraps a gpgme key context, gpgme-glib-specific functions
Copyright (C) 2007 Klarälvdalens Datakonsult AB
2016 Bundesamt für Sicherheit in der Informationstechnik
Software engineering by Intevation GmbH
This file is part of GPGME++.
GPGME++ is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public
License as published by the Free Software Foundation; either
version 2 of the License, or (at your option) any later version.
GPGME++ is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Library General Public License for more details.
You should have received a copy of the GNU Library General Public License
along with GPGME++; see the file COPYING.LIB. If not, write to the
Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
Boston, MA 02110-1301, USA.
*/
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#include <global.h>
extern "C" GIOChannel *gpgme_get_fdptr(int);
GIOChannel *GpgME::getGIOChannel(int fd)
{
return gpgme_get_fdptr(fd);
}
QIODevice *GpgME::getQIODevice(int fd)
{
return 0;
}

View File

@ -1,41 +0,0 @@
/*
context_qt.cpp - wraps a gpgme key context, gpgme-qt-specific functions
Copyright (C) 2007 Klarälvdalens Datakonsult AB
2016 Bundesamt für Sicherheit in der Informationstechnik
Software engineering by Intevation GmbH
This file is part of GPGME++.
GPGME++ is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public
License as published by the Free Software Foundation; either
version 2 of the License, or (at your option) any later version.
GPGME++ is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Library General Public License for more details.
You should have received a copy of the GNU Library General Public License
along with GPGME++; see the file COPYING.LIB. If not, write to the
Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
Boston, MA 02110-1301, USA.
*/
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#include <global.h>
extern "C" QIODevice *gpgme_get_fdptr(int);
GIOChannel *GpgME::getGIOChannel(int)
{
return 0;
}
QIODevice *GpgME::getQIODevice(int fd)
{
return gpgme_get_fdptr(fd);
}

View File

@ -280,3 +280,14 @@ std::string GpgME::Data::toString()
seek (0, SEEK_SET);
return ret;
}
GpgME::Error GpgME::Data::setFlag(const char *name, const char *value)
{
return Error(gpgme_data_set_flag(d->data, name, value));
}
GpgME::Error GpgME::Data::setSizeHint(uint64_t size)
{
const std::string val = std::to_string(size);
return Error(gpgme_data_set_flag(d->data, "size-hint", val.c_str()));
}

View File

@ -27,6 +27,7 @@
#include "key.h"
#include <sys/types.h> // for size_t, off_t
#include <cstdint> // unit64_t
#include <cstdio> // FILE
#include <algorithm>
#include <memory>
@ -122,6 +123,12 @@ public:
/** Return a copy of the data as std::string. Sets seek pos to 0 */
std::string toString();
/** See gpgme_data_set_flag */
Error setFlag(const char *name, const char *value);
/** Set a size hint for this data e.g. for progress calculations. */
Error setSizeHint(uint64_t size);
class Private;
Private *impl()
{

View File

@ -122,6 +122,11 @@ bool GpgME::DecryptionResult::isDeVs() const
return d && d->res.is_de_vs;
}
bool GpgME::DecryptionResult::isMime() const
{
return d && d->res.is_mime;
}
const char *GpgME::DecryptionResult::fileName() const
{
return d ? d->res.file_name : nullptr ;

View File

@ -75,6 +75,7 @@ public:
}
bool isWrongKeyUsage() const;
bool isDeVs() const;
bool isMime() const;
const char *fileName() const;

View File

@ -30,8 +30,6 @@
#include "error.h"
#include "data.h"
#include <sstream>
using namespace GpgME;
DefaultAssuanTransaction::DefaultAssuanTransaction()

View File

@ -25,7 +25,7 @@
#ifndef __GPGMEPP_DEFAULTASSUANTRANSACTION_H__
#define __GPGMEPP_DEFAULTASSUANTRANSACTION_H__
#include <interfaces/assuantransaction.h>
#include "interfaces/assuantransaction.h"
#include <string>
#include <vector>

View File

@ -52,6 +52,7 @@ using namespace GpgME;
static const char *status_to_string(unsigned int status);
static Error status_to_error(unsigned int status);
static Error parse_sc_op_failure(const char *args);
class EditInteractor::Private
{
@ -102,6 +103,9 @@ public:
} else if (status == GPGME_STATUS_ERROR) {
err = ei->q->parseStatusError(args);
ei->state = EditInteractor::ErrorState;
} else if (status == GPGME_STATUS_SC_OP_FAILURE) {
err = parse_sc_op_failure(args);
ei->state = EditInteractor::ErrorState;
} else {
ei->state = ei->q->nextState(status, args, err);
}
@ -134,7 +138,7 @@ public:
if (writeAll(fd, result, len) != len) {
err = Error::fromSystemError();
if (ei->debug) {
std::fprintf(ei->debug, "EditInteractor: Could not write to fd %d (%s)\n", fd, err.asString());
std::fprintf(ei->debug, "EditInteractor: Could not write to fd %d (%s)\n", fd, err.asStdString().c_str());
}
goto error;
}
@ -143,7 +147,7 @@ public:
if (writeAll(fd, "\n", 1) != 1) {
err = Error::fromSystemError();
if (ei->debug) {
std::fprintf(ei->debug, "EditInteractor: Could not write to fd %d (%s)\n", fd, err.asString());
std::fprintf(ei->debug, "EditInteractor: Could not write to fd %d (%s)\n", fd, err.asStdString().c_str());
}
goto error;
}
@ -280,6 +284,38 @@ GpgME::Error EditInteractor::parseStatusError(const char *args)
return err;
}
static Error sc_op_failure_to_error(unsigned int status)
{
switch (status) {
case 1:
// GPG_ERR_CANCELED or GPG_ERR_FULLY_CANCELED
return Error::fromCode(GPG_ERR_CANCELED);
case 2:
// GPG_ERR_BAD_PIN or GPG_ERR_BAD_RESET_CODE [sic]
return Error::fromCode(GPG_ERR_BAD_PIN);
case 3:
return Error::fromCode(GPG_ERR_PIN_BLOCKED);
case 4:
return Error::fromCode(GPG_ERR_NO_RESET_CODE);
}
return Error::fromCode(GPG_ERR_CARD);
}
// static
Error parse_sc_op_failure(const char *args)
{
Error err;
const auto fields = split(args, ' ');
if (fields.size() >= 1) {
err = sc_op_failure_to_error(static_cast<unsigned int>(std::stoul(fields[0])));
} else {
err = Error::fromCode(GPG_ERR_CARD);
}
return err;
}
static const char *const status_strings[] = {
"EOF",
/* mkstatus processing starts here */

View File

@ -69,6 +69,76 @@ public:
}
}
bool operator < (const Version& other) const
{
if (major > other.major ||
(major == other.major && minor > other.minor) ||
(major == other.major && minor == other.minor && patch > other.patch) ||
(major >= other.major && minor >= other.minor && patch >= other.patch)) {
return false;
}
return true;
}
bool operator < (const char* other) const
{
return operator<(Version(other));
}
bool operator <= (const Version &other) const
{
return !operator>(other);
}
bool operator <= (const char *other) const
{
return operator<=(Version(other));
}
bool operator > (const char* other) const
{
return operator>(Version(other));
}
bool operator > (const Version & other) const
{
return !operator<(other) && !operator==(other);
}
bool operator >= (const Version &other) const
{
return !operator<(other);
}
bool operator >= (const char *other) const
{
return operator>=(Version(other));
}
bool operator == (const Version& other) const
{
return major == other.major
&& minor == other.minor
&& patch == other.patch;
}
bool operator == (const char* other) const
{
return operator==(Version(other));
}
bool operator != (const Version &other) const
{
return !operator==(other);
}
bool operator != (const char *other) const
{
return operator!=(Version(other));
}
// the non-const overloads of the comparison operators are kept for
// binary compatibility
bool operator < (const Version& other)
{
if (major > other.major ||

View File

@ -47,7 +47,11 @@ public:
explicit Error(unsigned int e) : mErr(e), mMessage() {}
const char *source() const;
const char *asString() const;
/* This function is deprecated. Use asStdString() instead. asString() may
* return wrongly encoded (i.e. not UTF-8) results on Windows for the main
* thread if the function was first called from a secondary thread. */
GPGMEPP_DEPRECATED const char *asString() const;
std::string asStdString() const;
int code() const;
int sourceID() const;

View File

@ -79,6 +79,7 @@ enum SignatureMode {
Detached = 1,
Clearsigned = 2,
SignArchive = 4,
SignFile = 8,
};
enum class RevocationReason {

View File

@ -25,7 +25,7 @@
#ifndef __GPGMEPP_GPGADDUSERIDEDITINTERACTOR_H__
#define __GPGMEPP_GPGADDUSERIDEDITINTERACTOR_H__
#include <editinteractor.h>
#include "editinteractor.h"
#include <string>

View File

@ -33,8 +33,6 @@
#include <assert.h>
#include <sstream>
using namespace GpgME;
GpgAgentGetInfoAssuanTransaction::GpgAgentGetInfoAssuanTransaction(InfoItem item)

View File

@ -25,7 +25,7 @@
#ifndef __GPGMEPP_GPGAGENTGETINFOASSUANTRANSACTION_H__
#define __GPGMEPP_GPGAGENTGETINFOASSUANTRANSACTION_H__
#include <interfaces/assuantransaction.h>
#include "interfaces/assuantransaction.h"
#include <string>
#include <vector>

View File

@ -24,7 +24,7 @@
#ifndef __GPGMEPP_GPGGENCARDKEYEDITINTERACTOR_H__
#define __GPGMEPP_GPGGENCARDKEYEDITINTERACTOR_H__
#include <editinteractor.h>
#include "editinteractor.h"
#include <string>
#include <memory>

View File

@ -75,4 +75,7 @@ typedef struct _gpgme_tofu_info *gpgme_tofu_info_t;
struct _gpgme_op_query_swdb_result;
typedef struct _gpgme_op_query_swdb_result *gpgme_query_swdb_result_t;
struct _gpgme_revocation_key;
typedef struct _gpgme_revocation_key *gpgme_revocation_key_t;
#endif // __GPGMEPP_GPGMEFW_H__

View File

@ -31,7 +31,6 @@
#include <gpgme.h>
#include <sstream>
#include <vector>
// avoid conflict (msvc)

View File

@ -25,7 +25,7 @@
#ifndef __GPGMEPP_GPGSETEXPIRYTIMEEDITINTERACTOR_H__
#define __GPGMEPP_GPGSETEXPIRYTIMEEDITINTERACTOR_H__
#include <editinteractor.h>
#include "editinteractor.h"
#include <string>

View File

@ -25,8 +25,8 @@
#ifndef __GPGMEPP_GPGSETOWNERTRUSTEDITINTERACTOR_H__
#define __GPGMEPP_GPGSETOWNERTRUSTEDITINTERACTOR_H__
#include <editinteractor.h>
#include <key.h>
#include "editinteractor.h"
#include "key.h"
#include <string>

View File

@ -25,7 +25,7 @@
#ifndef __GPGMEPP_GPGSIGNKEYEDITINTERACTOR_H__
#define __GPGMEPP_GPGSIGNKEYEDITINTERACTOR_H__
#include <editinteractor.h>
#include "editinteractor.h"
#include <string>
#include <vector>

View File

@ -26,7 +26,7 @@
#ifndef __GPGMEPP_INTERFACES_ASSUANTRANSACTION_H__
#define __GPGMEPP_INTERFACES_ASSUANTRANSACTION_H__
#include "gpgmepp_export.h"
#include "../gpgmepp_export.h"
#include <stddef.h>

View File

@ -27,7 +27,7 @@
#include <sys/types.h>
#include "gpgmepp_export.h"
#include "../gpgmepp_export.h"
#include <gpg-error.h>

View File

@ -24,7 +24,7 @@
#ifndef __GPGMEPP_INTERFACES_STATUSCONSUMER_H__
#define __GPGMEPP_INTERFACES_STATUSCONSUMER_H__
#include "gpgmepp_export.h"
#include "../gpgmepp_export.h"
namespace GpgME
{

View File

@ -122,6 +122,37 @@ std::vector<Subkey> Key::subkeys() const
return v;
}
RevocationKey Key::revocationKey(unsigned int index) const
{
return RevocationKey(key, index);
}
unsigned int Key::numRevocationKeys() const
{
if (!key) {
return 0;
}
unsigned int count = 0;
for (auto revkey = key->revocation_keys; revkey; revkey = revkey->next) {
++count;
}
return count;
}
std::vector<RevocationKey> Key::revocationKeys() const
{
if (!key) {
return std::vector<RevocationKey>();
}
std::vector<RevocationKey> v;
v.reserve(numRevocationKeys());
for (auto revkey = key->revocation_keys; revkey; revkey = revkey->next) {
v.push_back(RevocationKey(key, revkey));
}
return v;
}
Key::OwnerTrust Key::ownerTrust() const
{
if (!key) {
@ -208,17 +239,12 @@ bool Key::canEncrypt() const
bool Key::canSign() const
{
#ifndef GPGME_CAN_SIGN_ON_SECRET_OPENPGP_KEYLISTING_NOT_BROKEN
if (key && key->protocol == GPGME_PROTOCOL_OpenPGP) {
return true;
}
#endif
return canReallySign();
return key && key->can_sign;
}
bool Key::canReallySign() const
{
return key && key->can_sign;
return canSign();
}
bool Key::canCertify() const
@ -252,6 +278,26 @@ bool Key::isDeVs() const
return true;
}
bool Key::hasCertify() const
{
return key && key->has_certify;
}
bool Key::hasSign() const
{
return key && key->has_sign;
}
bool Key::hasEncrypt() const
{
return key && key->has_encrypt;
}
bool Key::hasAuthenticate() const
{
return key && key->has_authenticate;
}
const char *Key::issuerSerial() const
{
return key ? key->issuer_serial : nullptr ;
@ -515,6 +561,21 @@ bool Subkey::canAuthenticate() const
return subkey && subkey->can_authenticate;
}
bool Subkey::canRenc() const
{
return subkey && subkey->can_renc;
}
bool Subkey::canTimestamp() const
{
return subkey && subkey->can_timestamp;
}
bool Subkey::isGroupOwned() const
{
return subkey && subkey->is_group_owned;
}
bool Subkey::isQualified() const
{
return subkey && subkey->is_qualified;
@ -1226,6 +1287,68 @@ bool UserID::Signature::isBad() const
return isNull() || isExpired() || isInvalid();
}
//
//
// class RevocationKey
//
//
static gpgme_revocation_key_t find_revkey(const shared_gpgme_key_t &key, unsigned int idx)
{
if (key) {
for (gpgme_revocation_key_t s = key->revocation_keys; s; s = s->next, --idx) {
if (idx == 0) {
return s;
}
}
}
return nullptr;
}
static gpgme_revocation_key_t verify_revkey(const shared_gpgme_key_t &key, gpgme_revocation_key_t revkey)
{
if (key) {
for (gpgme_revocation_key_t s = key->revocation_keys; s; s = s->next) {
if (s == revkey) {
return revkey;
}
}
}
return nullptr;
}
RevocationKey::RevocationKey() : key(), revkey(nullptr) {}
RevocationKey::RevocationKey(const shared_gpgme_key_t &k, unsigned int idx)
: key(k), revkey(find_revkey(k, idx))
{
}
RevocationKey::RevocationKey(const shared_gpgme_key_t &k, gpgme_revocation_key_t sk)
: key(k), revkey(verify_revkey(k, sk))
{
}
Key RevocationKey::parent() const
{
return Key(key);
}
const char *RevocationKey::fingerprint() const
{
return revkey ? revkey->fpr : nullptr;
}
bool RevocationKey::isSensitive() const
{
return revkey ? revkey->sensitive : false;
}
int RevocationKey::algorithm() const
{
return revkey ? revkey->pubkey_algo : 0;
}
std::ostream &operator<<(std::ostream &os, const UserID &uid)
{
os << "GpgME::UserID(";
@ -1261,7 +1384,10 @@ std::ostream &operator<<(std::ostream &os, const Subkey &subkey)
<< "\n canEncrypt: " << subkey.canEncrypt()
<< "\n canCertify: " << subkey.canCertify()
<< "\n canAuth: " << subkey.canAuthenticate()
<< "\n canRenc: " << subkey.canRenc()
<< "\n canTimestanp: " << subkey.canTimestamp()
<< "\n isSecret: " << subkey.isSecret()
<< "\n isGroupOwned: " << subkey.isGroupOwned()
<< "\n isQualified: " << subkey.isQualified()
<< "\n isDeVs: " << subkey.isDeVs()
<< "\n isCardKey: " << subkey.isCardKey()
@ -1279,7 +1405,7 @@ std::ostream &operator<<(std::ostream &os, const Key &key)
<< "\n issuer: " << protect(key.issuerName())
<< "\n fingerprint:" << protect(key.primaryFingerprint())
<< "\n listmode: " << key.keyListMode()
<< "\n canSign: " << key.canReallySign()
<< "\n canSign: " << key.canSign()
<< "\n canEncrypt: " << key.canEncrypt()
<< "\n canCertify: " << key.canCertify()
<< "\n canAuth: " << key.canAuthenticate()
@ -1292,6 +1418,20 @@ std::ostream &operator<<(std::ostream &os, const Key &key)
const std::vector<Subkey> subkeys = key.subkeys();
std::copy(subkeys.begin(), subkeys.end(),
std::ostream_iterator<Subkey>(os, "\n"));
os << " revocationKeys:\n";
const std::vector<RevocationKey> revkeys = key.revocationKeys();
std::copy(revkeys.begin(), revkeys.end(),
std::ostream_iterator<RevocationKey>(os, "\n"));
}
return os << ')';
}
std::ostream &operator<<(std::ostream &os, const RevocationKey &revkey)
{
os << "GpgME::RevocationKey(";
if (!revkey.isNull()) {
os << "\n fingerprint: " << protect(revkey.fingerprint())
<< "\n isSensitive: " << revkey.isSensitive();
}
return os << ')';
}

View File

@ -44,6 +44,7 @@ class Context;
class Subkey;
class UserID;
class TofuInfo;
class RevocationKey;
typedef std::shared_ptr< std::remove_pointer<gpgme_key_t>::type > shared_gpgme_key_t;
@ -100,6 +101,10 @@ public:
std::vector<UserID> userIDs() const;
std::vector<Subkey> subkeys() const;
RevocationKey revocationKey(unsigned int index) const;
unsigned int numRevocationKeys() const;
std::vector<RevocationKey> revocationKeys() const;
bool isRevoked() const;
bool isExpired() const;
bool isDisabled() const;
@ -109,22 +114,31 @@ public:
* isDisabled || isInvalid */
bool isBad() const;
/** Returns true, if the key can be used for encryption (i.e. it's not bad
* and has an encryption subkey) or if the primary subkey can encrypt. */
bool canEncrypt() const;
/*!
This function contains a workaround for old gpgme's: all secret
OpenPGP keys canSign() == true, which canReallySign() doesn't
have. I don't have time to find what breaks when I remove this
workaround, but since Kleopatra merges secret into public keys,
the workaround is not necessary there (and actively harms), I've
added a new function instead.
*/
/** Returns true, if the key can be used for signing (i.e. it's not bad
* and has a signing subkey) or if the primary subkey can sign. */
bool canSign() const;
bool canReallySign() const;
GPGMEPP_DEPRECATED bool canReallySign() const;
/** Returns true, if the key can be used for certification (i.e. it's not bad
* and has a certification subkey) or if the primary subkey can certify. */
bool canCertify() const;
/** Returns true, if the key can be used for authentication (i.e. it's not bad
* and has a authentication subkey) or if the primary subkey can authenticate. */
bool canAuthenticate() const;
bool isQualified() const;
bool isDeVs() const;
/** Returns true, if the key has a certification subkey. */
bool hasCertify() const;
/** Returns true, if the key has a signing subkey. */
bool hasSign() const;
/** Returns true, if the key has an encryption subkey. */
bool hasEncrypt() const;
/** Returns true, if the key has an authentication subkey. */
bool hasAuthenticate() const;
bool hasSecret() const;
GPGMEPP_DEPRECATED bool isSecret() const
{
@ -270,6 +284,9 @@ public:
bool canSign() const;
bool canCertify() const;
bool canAuthenticate() const;
bool canRenc() const;
bool canTimestamp() const;
bool isGroupOwned() const;
bool isQualified() const;
bool isDeVs() const;
bool isCardKey() const;
@ -535,9 +552,53 @@ private:
gpgme_key_sig_t sig;
};
//
// class RevocationKey
//
class GPGMEPP_EXPORT RevocationKey
{
public:
RevocationKey();
RevocationKey(const shared_gpgme_key_t &key, gpgme_revocation_key_t revkey);
RevocationKey(const shared_gpgme_key_t &key, unsigned int idx);
// Rule of Zero
void swap(RevocationKey &other)
{
using std::swap;
swap(this->key, other.key);
swap(this->revkey, other.revkey);
}
bool isNull() const
{
return !key || !revkey;
}
Key parent() const;
const char *fingerprint() const;
bool isSensitive() const;
int algorithm() const;
private:
shared_gpgme_key_t key;
gpgme_revocation_key_t revkey;
};
inline void swap(RevocationKey& v1, RevocationKey& v2)
{
v1.swap(v2);
}
GPGMEPP_EXPORT std::ostream &operator<<(std::ostream &os, const UserID &uid);
GPGMEPP_EXPORT std::ostream &operator<<(std::ostream &os, const Subkey &subkey);
GPGMEPP_EXPORT std::ostream &operator<<(std::ostream &os, const Key &key);
GPGMEPP_EXPORT std::ostream &operator<<(std::ostream &os, const RevocationKey &revkey);
} // namespace GpgME

View File

@ -31,7 +31,6 @@
#include "data.h"
#include "util.h"
#include <sstream>
#include <assert.h>
using namespace GpgME;

View File

@ -25,7 +25,7 @@
#ifndef __GPGMEPP_SCDGETINFOASSUANTRANSACTION_H__
#define __GPGMEPP_SCDGETINFOASSUANTRANSACTION_H__
#include <interfaces/assuantransaction.h>
#include "interfaces/assuantransaction.h"
#include <string>
#include <vector>

View File

@ -200,6 +200,7 @@ GpgME::SignatureMode GpgME::CreatedSignature::mode() const
case GPGME_SIG_MODE_DETACH: return Detached;
case GPGME_SIG_MODE_CLEAR: return Clearsigned;
case GPGME_SIG_MODE_ARCHIVE: return SignArchive; // cannot happen
case GPGME_SIG_MODE_FILE: return SignFile; // cannot happen
}
}

View File

@ -24,7 +24,7 @@
#ifndef __GPGMEPP_STATUSCONSUMERASSUANTRANSACTION_H__
#define __GPGMEPP_STATUSCONSUMERASSUANTRANSACTION_H__
#include <interfaces/assuantransaction.h>
#include "interfaces/assuantransaction.h"
namespace GpgME
{

View File

@ -27,7 +27,7 @@
#define __GPGMEPP_TRUSTITEM_H__
#include "gpgmefw.h"
#include <key.h>
#include "key.h"
#include "gpgmepp_export.h"
#include <algorithm>

View File

@ -544,19 +544,27 @@ std::ostream &GpgME::operator<<(std::ostream &os, const VerificationResult &resu
std::ostream &GpgME::operator<<(std::ostream &os, Signature::PKAStatus pkaStatus)
{
#define OUTPUT( x ) if ( !(pkaStatus & (GpgME::Signature:: x)) ) {} else do { os << #x " "; } while(0)
os << "GpgME::Signature::PKAStatus(";
switch (pkaStatus) {
#define OUTPUT( x ) case GpgME::Signature:: x: os << #x; break
OUTPUT(UnknownPKAStatus);
OUTPUT(PKAVerificationFailed);
OUTPUT(PKAVerificationSucceeded);
#undef OUTPUT
default:
os << "??? (" << static_cast<int>(pkaStatus) << ')';
break;
}
return os << ')';
}
std::ostream &GpgME::operator<<(std::ostream &os, Signature::Summary summary)
{
#define OUTPUT( x ) if ( !(summary & (GpgME::Signature:: x)) ) {} else do { os << #x " "; } while(0)
os << "GpgME::Signature::Summary(";
if (summary == Signature::None) {
os << "None";
} else {
#define OUTPUT( x ) if ( !(summary & (GpgME::Signature:: x)) ) {} else do { os << #x " "; } while(0)
OUTPUT(Valid);
OUTPUT(Green);
OUTPUT(Red);
@ -570,6 +578,7 @@ std::ostream &GpgME::operator<<(std::ostream &os, Signature::Summary summary)
OUTPUT(SysError);
OUTPUT(TofuConflict);
#undef OUTPUT
}
return os << ')';
}
@ -603,10 +612,14 @@ std::ostream &GpgME::operator<<(std::ostream &os, const Signature &sig)
std::ostream &GpgME::operator<<(std::ostream &os, Notation::Flags flags)
{
os << "GpgME::Notation::Flags(";
if (flags == Notation::NoFlags) {
os << "NoFlags";
} else {
#define OUTPUT( x ) if ( !(flags & (GpgME::Notation:: x)) ) {} else do { os << #x " "; } while(0)
OUTPUT(HumanReadable);
OUTPUT(Critical);
#undef OUTPUT
}
return os << ')';
}

View File

@ -150,7 +150,7 @@ main (int argc, char **argv)
const GpgME::Key key = ctx->key (*argv, err, only_secret);
std::stringstream ss;
ss << "Key " << key << " Err: " << err.asString() << "\n";
ss << "Key " << key << " Err: " << err.asStdString() << "\n";
std::cout << ss.str();

View File

@ -153,14 +153,17 @@ main (int argc, char **argv)
}
Error err = ctx->startKeyListing (*argv, only_secret);
if (err) {
std::cout << "Error: " << err.asString() << "\n";
std::cout << "Error: " << err.asStdString() << "\n";
return -1;
}
GpgME::Key key;
std::stringstream ss;
do {
key = ctx->nextKey(err);
if (!err)
{
ss << key << "\n\n";
}
} while (!err && !key.isNull());
std::cout << ss.str();

View File

@ -38,7 +38,6 @@
#include "verificationresult.h"
#include <memory>
#include <sstream>
#include <iostream>
using namespace GpgME;

View File

@ -31,7 +31,6 @@
#include "key.h"
#include <memory>
#include <sstream>
#include <iostream>
#include <thread>
@ -76,49 +75,52 @@ main (int argc, char **argv)
Error err;
auto ctx = std::unique_ptr<Context>{Context::createForEngine(AssuanEngine, &err)};
if (!ctx) {
std::cerr << "Failed to get context (Error: " << err.asString() << ")\n";
std::cerr << "Failed to get context (Error: " << err.asStdString() << ")\n";
return -1;
}
const std::string dirmngrSocket = GpgME::dirInfo("dirmngr-socket");
if ((err = ctx->setEngineFileName(dirmngrSocket.c_str()))) {
std::cerr << "Failed to set engine file name (Error: " << err.asString() << ")\n";
std::cerr << "Failed to set engine file name (Error: " << err.asStdString() << ")\n";
return -1;
}
if ((err = ctx->setEngineHomeDirectory(""))) {
std::cerr << "Failed to set engine home directory (Error: " << err.asString() << ")\n";
std::cerr << "Failed to set engine home directory (Error: " << err.asStdString() << ")\n";
return -1;
}
// try do connect to dirmngr
// try to connect to dirmngr
err = ctx->assuanTransact("GETINFO version");
if (err && err.code() != GPG_ERR_ASS_CONNECT_FAILED) {
std::cerr << "Failed to start assuan transaction (Error: " << err.asString() << ")\n";
std::cerr << "Failed to start assuan transaction (Error: " << err.asStdString() << ")\n";
return -1;
}
if (err.code() == GPG_ERR_ASS_CONNECT_FAILED) {
std::cerr << "Starting dirmngr ...\n";
auto spawnCtx = std::unique_ptr<Context>{Context::createForEngine(SpawnEngine, &err)};
if (!spawnCtx) {
std::cerr << "Failed to get context for spawn engine (Error: " << err.asString() << ")\n";
std::cerr << "Failed to get context for spawn engine (Error: " << err.asStdString() << ")\n";
return -1;
}
const auto dirmngrProgram = GpgME::dirInfo("dirmngr-name");
const auto homedir = GpgME::dirInfo("homedir");
const auto gpgconfProgram = GpgME::dirInfo("gpgconf-name");
// replace backslashes with forward slashes in homedir to work around bug T6833
std::string homedir{GpgME::dirInfo("homedir")};
std::replace(homedir.begin(), homedir.end(), '\\', '/');
const char *argv[] = {
dirmngrProgram,
gpgconfProgram,
"--homedir",
homedir,
"--daemon",
homedir.c_str(),
"--launch",
"dirmngr",
NULL
};
auto ignoreIO = Data{Data::null};
err = spawnCtx->spawnAsync(dirmngrProgram, argv,
err = spawnCtx->spawn(gpgconfProgram, argv,
ignoreIO, ignoreIO, ignoreIO,
Context::SpawnDetached);
if (err) {
std::cerr << "Failed to start dirmngr (Error: " << err.asString() << ")\n";
std::cerr << "Failed to start dirmngr (Error: " << err.asStdString() << ")\n";
return -1;
}
@ -135,7 +137,7 @@ main (int argc, char **argv)
const auto cmd = std::string{"WKD_GET "} + email;
err = ctx->assuanTransact(cmd.c_str());
if (err && err.code() != GPG_ERR_NO_NAME && err.code() != GPG_ERR_NO_DATA) {
std::cerr << "Error: WKD_GET returned " << err.asString() << "\n";
std::cerr << "Error: WKD_GET returned " << err.asStdString() << "\n";
return -1;
}

View File

@ -23,7 +23,13 @@ EXTRA_DIST = \
gpgme.i \
helpers.c helpers.h private.h
SUBDIRS = . tests examples doc src
if RUN_GPG_TESTS
tests = tests
else
tests =
endif
SUBDIRS = . ${tests} examples doc src
.PHONY: prepare
prepare: copystamp
@ -74,7 +80,7 @@ CLEANFILES = copystamp \
# 'make distclean' clears the write bit, breaking rm -rf. Fix the
# permissions.
clean-local:
rm -rf -- build
rm -rf -- build dist gpg.egg-info
for PYTHON in $(PYTHONS); do \
find "$$(basename "$${PYTHON}")-gpg" -type d ! -perm -200 -exec chmod u+w {} ';' ; \
rm -rf -- "$$(basename "$${PYTHON}")-gpg" ; \
@ -95,8 +101,12 @@ install-exec-local:
done
uninstall-local:
set -x; GV=$$(echo $(VERSION) | tr - _); for PYTHON in $(PYTHONS); do \
set -x; \
GV=$$(echo $(VERSION) | tr - _); \
normalizedGV=$$(echo $$GV | sed s/_beta/b/); \
for PYTHON in $(PYTHONS); do \
PLATLIB="$(prefix)/$$("$${PYTHON}" -c 'import sysconfig, os; print(os.path.relpath(sysconfig.get_path("platlib", scheme="posix_prefix"), sysconfig.get_config_var("prefix")))')" ; \
rm -rf -- "$(DESTDIR)$${PLATLIB}/gpg" \
"$(DESTDIR)$${PLATLIB}"/gpg-$$GV-py*.egg-info ; \
"$(DESTDIR)$${PLATLIB}"/gpg-$$GV-py*.egg-info \
"$(DESTDIR)$${PLATLIB}"/gpg-$$normalizedGV-py*.egg ; \
done

View File

@ -1612,6 +1612,7 @@ of the entire public keybox.
#+BEGIN_SRC python -i
import gpg
import os
import os.path
import sys
@ -1619,6 +1620,9 @@ print("""
This script exports one or more public keys in minimised form.
""")
def open_0o600(path, flags):
return os.open(path, flags, mode=0o600)
c = gpg.Context(armor=True)
if len(sys.argv) >= 4:
@ -1654,7 +1658,7 @@ except:
result = c.key_export_minimal(pattern=None)
if result is not None:
with open(keyfile, "wb") as f:
with open(keyfile, "wb", opener=open_0o600) as f:
f.write(result)
else:
pass
@ -1686,6 +1690,9 @@ This script exports one or more secret keys.
The gpg-agent and pinentry are invoked to authorise the export.
""")
def open_0o600(path, flags):
return os.open(path, flags, mode=0o600)
c = gpg.Context(armor=True)
if len(sys.argv) >= 4:
@ -1735,9 +1742,8 @@ except:
result = c.key_export_secret(pattern=None)
if result is not None:
with open(keyfile, "wb") as f:
with open(keyfile, "wb", opener=open_0o600)) as f:
f.write(result)
os.chmod(keyfile, 0o600)
else:
pass
#+END_SRC
@ -2939,7 +2945,7 @@ Save that into a file called =keycount.pyx= and then create a
=setup.py= file which contains this:
#+BEGIN_SRC python -i
from distutils.core import setup
from setuptools import setup
from Cython.Build import cythonize
setup(

View File

@ -498,7 +498,7 @@
% \def\foo{\parsearg\Xfoo}
% \def\Xfoo#1{...}
%
% Actually, I use \csname\string\foo\endcsname, ie. \\foo, as it is my
% Actually, I use \csname\string\foo\endcsname, i.e. \\foo, as it is my
% favourite TeX trick. --kasal, 16nov03
\def\parseargdef#1{%

View File

@ -21,7 +21,7 @@ from __future__ import absolute_import, division, unicode_literals
# Lesser General Public License for more details.
#
# You should have received a copy of the GNU General Public License and the GNU
# Lesser General Public along with this program; if not, see
# Lesser General Public License along with this program; if not, see
# <https://www.gnu.org/licenses/>.
import gpg

View File

@ -1,4 +1,4 @@
from distutils.core import setup
from setuptools import setup
from Cython.Build import cythonize
setup(

View File

@ -21,7 +21,7 @@ from __future__ import absolute_import, division, unicode_literals
# Lesser General Public License for more details.
#
# You should have received a copy of the GNU General Public License and the GNU
# Lesser General Public along with this program; if not, see
# Lesser General Public License along with this program; if not, see
# <https://www.gnu.org/licenses/>.
import gpg

View File

@ -21,7 +21,7 @@ from __future__ import absolute_import, division, unicode_literals
# Lesser General Public License for more details.
#
# You should have received a copy of the GNU General Public License and the GNU
# Lesser General Public along with this program; if not, see
# Lesser General Public License along with this program; if not, see
# <https://www.gnu.org/licenses/>.
import gpg

View File

@ -21,7 +21,7 @@ from __future__ import absolute_import, division, unicode_literals
# Lesser General Public License for more details.
#
# You should have received a copy of the GNU General Public License and the GNU
# Lesser General Public along with this program; if not, see
# Lesser General Public License along with this program; if not, see
# <https://www.gnu.org/licenses/>.
import gpg

View File

@ -21,7 +21,7 @@ from __future__ import absolute_import, division, unicode_literals
# Lesser General Public License for more details.
#
# You should have received a copy of the GNU General Public License and the GNU
# Lesser General Public along with this program; if not, see
# Lesser General Public License along with this program; if not, see
# <https://www.gnu.org/licenses/>.
import gpg

View File

@ -24,7 +24,7 @@ import sys
# Lesser General Public License for more details.
#
# You should have received a copy of the GNU General Public License and the GNU
# Lesser General Public along with this program; if not, see
# Lesser General Public License along with this program; if not, see
# <https://www.gnu.org/licenses/>.
"""

View File

@ -24,7 +24,7 @@ import sys
# Lesser General Public License for more details.
#
# You should have received a copy of the GNU General Public License and the GNU
# Lesser General Public along with this program; if not, see
# Lesser General Public License along with this program; if not, see
# <https://www.gnu.org/licenses/>.
"""

View File

@ -25,7 +25,7 @@ from groups import group_lists
# Lesser General Public License for more details.
#
# You should have received a copy of the GNU General Public License and the GNU
# Lesser General Public along with this program; if not, see
# Lesser General Public License along with this program; if not, see
# <https://www.gnu.org/licenses/>.
"""

View File

@ -25,7 +25,7 @@ from groups import group_lists
# Lesser General Public License for more details.
#
# You should have received a copy of the GNU General Public License and the GNU
# Lesser General Public along with this program; if not, see
# Lesser General Public License along with this program; if not, see
# <https://www.gnu.org/licenses/>.
"""

View File

@ -25,7 +25,7 @@ from groups import group_lists
# Lesser General Public License for more details.
#
# You should have received a copy of the GNU General Public License and the GNU
# Lesser General Public along with this program; if not, see
# Lesser General Public License along with this program; if not, see
# <https://www.gnu.org/licenses/>.
"""

View File

@ -25,7 +25,7 @@ import sys
# Lesser General Public License for more details.
#
# You should have received a copy of the GNU General Public License and the GNU
# Lesser General Public along with this program; if not, see
# Lesser General Public License along with this program; if not, see
# <https://www.gnu.org/licenses/>.
print("""

View File

@ -25,7 +25,7 @@ import sys
# Lesser General Public License for more details.
#
# You should have received a copy of the GNU General Public License and the GNU
# Lesser General Public along with this program; if not, see
# Lesser General Public License along with this program; if not, see
# <https://www.gnu.org/licenses/>.
print("""

View File

@ -26,7 +26,7 @@ import sys
# Lesser General Public License for more details.
#
# You should have received a copy of the GNU General Public License and the GNU
# Lesser General Public along with this program; if not, see
# Lesser General Public License along with this program; if not, see
# <https://www.gnu.org/licenses/>.
print("""
@ -35,6 +35,9 @@ This script exports one or more secret keys.
The gpg-agent and pinentry are invoked to authorise the export.
""")
def open_0o600(path, flags):
return os.open(path, flags, mode=0o600)
c = gpg.Context(armor=True)
if len(sys.argv) >= 4:
@ -84,8 +87,7 @@ except:
result = c.key_export_secret(pattern=None)
if result is not None:
with open(keyfile, "wb") as f:
with open(keyfile, "wb", opener=open_0o600) as f:
f.write(result)
os.chmod(keyfile, 0o600)
else:
pass

View File

@ -27,7 +27,7 @@ import sys
# Lesser General Public License for more details.
#
# You should have received a copy of the GNU General Public License and the GNU
# Lesser General Public along with this program; if not, see
# Lesser General Public License along with this program; if not, see
# <https://www.gnu.org/licenses/>.
print("""
@ -37,6 +37,9 @@ file formats, saved in files within the user's GPG home directory.
The gpg-agent and pinentry are invoked to authorise the export.
""")
def open_0o600(path, flags):
return os.open(path, flags, mode=0o600)
if sys.platform == "win32":
gpgconfcmd = "gpgconf.exe --list-dirs homedir"
else:
@ -119,15 +122,13 @@ except:
b_result = b.key_export_secret(pattern=None)
if a_result is not None:
with open(ascfile, "wb") as f:
with open(ascfile, "wb", opener=open_0o600) as f:
f.write(a_result)
os.chmod(ascfile, 0o600)
else:
pass
if b_result is not None:
with open(gpgfile, "wb") as f:
with open(gpgfile, "wb", opener=open_0o600) as f:
f.write(b_result)
os.chmod(gpgfile, 0o600)
else:
pass

View File

@ -20,7 +20,7 @@ from __future__ import absolute_import, division, unicode_literals
# Lesser General Public License for more details.
#
# You should have received a copy of the GNU General Public License and the GNU
# Lesser General Public along with this program; if not, see
# Lesser General Public License along with this program; if not, see
# <https://www.gnu.org/licenses/>.
import subprocess

View File

@ -27,7 +27,7 @@ del absolute_import, division, unicode_literals
# Lesser General Public License for more details.
#
# You should have received a copy of the GNU General Public License and the GNU
# Lesser General Public along with this program; if not, see
# Lesser General Public License along with this program; if not, see
# <https://www.gnu.org/licenses/>.
print("""

View File

@ -25,7 +25,7 @@ import sys
# Lesser General Public License for more details.
#
# You should have received a copy of the GNU General Public License and the GNU
# Lesser General Public along with this program; if not, see
# Lesser General Public License along with this program; if not, see
# <https://www.gnu.org/licenses/>.
print("""

View File

@ -25,7 +25,7 @@ import sys
# Lesser General Public License for more details.
#
# You should have received a copy of the GNU General Public License and the GNU
# Lesser General Public along with this program; if not, see
# Lesser General Public License along with this program; if not, see
# <https://www.gnu.org/licenses/>.
print("""

View File

@ -25,7 +25,7 @@ import requests
# Lesser General Public License for more details.
#
# You should have received a copy of the GNU General Public License and the GNU
# Lesser General Public along with this program; if not, see
# Lesser General Public License along with this program; if not, see
# <https://www.gnu.org/licenses/>.
print("""

View File

@ -25,7 +25,7 @@ import sys
# Lesser General Public License for more details.
#
# You should have received a copy of the GNU General Public License and the GNU
# Lesser General Public along with this program; if not, see
# Lesser General Public License along with this program; if not, see
# <https://www.gnu.org/licenses/>.
print("""

View File

@ -21,7 +21,7 @@ from __future__ import absolute_import, division, unicode_literals
# Lesser General Public License for more details.
#
# You should have received a copy of the GNU General Public License and the GNU
# Lesser General Public along with this program; if not, see
# Lesser General Public License along with this program; if not, see
# <https://www.gnu.org/licenses/>.
import gpg

View File

@ -28,7 +28,7 @@ from groups import group_lists
# Lesser General Public License for more details.
#
# You should have received a copy of the GNU General Public License and the GNU
# Lesser General Public along with this program; if not, see
# Lesser General Public License along with this program; if not, see
# <https://www.gnu.org/licenses/>.
print("""

View File

@ -21,7 +21,7 @@ from __future__ import absolute_import, division, unicode_literals
# Lesser General Public License for more details.
#
# You should have received a copy of the GNU General Public License and the GNU
# Lesser General Public along with this program; if not, see
# Lesser General Public License along with this program; if not, see
# <https://www.gnu.org/licenses/>.
import sys

View File

@ -28,7 +28,7 @@ del absolute_import, division, unicode_literals
# Lesser General Public License for more details.
#
# You should have received a copy of the GNU General Public License and the GNU
# Lesser General Public along with this program; if not, see
# Lesser General Public License along with this program; if not, see
# <https://www.gnu.org/licenses/>.
print("""

View File

@ -28,7 +28,7 @@ del absolute_import, division, unicode_literals
# Lesser General Public License for more details.
#
# You should have received a copy of the GNU General Public License and the GNU
# Lesser General Public along with this program; if not, see
# Lesser General Public License along with this program; if not, see
# <https://www.gnu.org/licenses/>.
print("""

View File

@ -28,7 +28,7 @@ del absolute_import, division, unicode_literals
# Lesser General Public License for more details.
#
# You should have received a copy of the GNU General Public License and the GNU
# Lesser General Public along with this program; if not, see
# Lesser General Public License along with this program; if not, see
# <https://www.gnu.org/licenses/>.
print("""

View File

@ -27,7 +27,7 @@ del absolute_import, division, unicode_literals
# Lesser General Public License for more details.
#
# You should have received a copy of the GNU General Public License and the GNU
# Lesser General Public along with this program; if not, see
# Lesser General Public License along with this program; if not, see
# <https://www.gnu.org/licenses/>.
print("""

View File

@ -21,7 +21,7 @@ from __future__ import absolute_import, division, unicode_literals
# Lesser General Public License for more details.
#
# You should have received a copy of the GNU General Public License and the GNU
# Lesser General Public along with this program; if not, see
# Lesser General Public License along with this program; if not, see
# <https://www.gnu.org/licenses/>.
import gpg

View File

@ -26,7 +26,7 @@ import sys
# Lesser General Public License for more details.
#
# You should have received a copy of the GNU General Public License and the GNU
# Lesser General Public along with this program; if not, see
# Lesser General Public License along with this program; if not, see
# <https://www.gnu.org/licenses/>.
print("""

View File

@ -21,7 +21,7 @@ from __future__ import absolute_import, division, unicode_literals
# Lesser General Public License for more details.
#
# You should have received a copy of the GNU General Public License and the GNU
# Lesser General Public along with this program; if not, see
# Lesser General Public License along with this program; if not, see
# <https://www.gnu.org/licenses/>.
import gpg

View File

@ -21,7 +21,7 @@ from __future__ import absolute_import, division, unicode_literals
# Lesser General Public License for more details.
#
# You should have received a copy of the GNU General Public License and the GNU
# Lesser General Public along with this program; if not, see
# Lesser General Public License along with this program; if not, see
# <https://www.gnu.org/licenses/>.
import gpg

View File

@ -24,7 +24,7 @@ import sys
# Lesser General Public License for more details.
#
# You should have received a copy of the GNU General Public License and the GNU
# Lesser General Public along with this program; if not, see
# Lesser General Public License along with this program; if not, see
# <https://www.gnu.org/licenses/>.
"""

View File

@ -25,7 +25,7 @@ import sys
# Lesser General Public License for more details.
#
# You should have received a copy of the GNU General Public License and the GNU
# Lesser General Public along with this program; if not, see
# Lesser General Public License along with this program; if not, see
# <https://www.gnu.org/licenses/>.
intro = """
@ -112,18 +112,18 @@ else:
nh = "{0}/.{1}".format(userdir, new_homedir)
def open_0o600(path, flags):
return os.open(path, flags, mode=0o600)
if os.path.exists(nh) is True:
print("The {0} directory already exists.".format(nh))
else:
print("Creating the {0} directory.".format(nh))
os.mkdir(nh)
os.chmod(nh, 0o700)
with open("{0}/{1}".format(nh, "gpg.conf"), "w") as f1:
os.mkdir(nh, 0o700)
with open("{0}/{1}".format(nh, "gpg.conf"), "w", opener=open_0o600) as f1:
f1.write(gpgconf)
os.chmod("{0}/{1}".format(nh, "gpg.conf"), 0o600)
with open("{0}/{1}".format(nh, "gpg-agent.conf"), "w") as f2:
with open("{0}/{1}".format(nh, "gpg-agent.conf"), "w", opener=open_0o600) as f2:
f2.write(gpgconf)
os.chmod("{0}/{1}".format(nh, "gpg-agent.conf"), 0o600)
print("""You may now use the {0} directory as an alternative GPG homedir:
gpg --homedir {0}

View File

@ -21,7 +21,7 @@ from __future__ import absolute_import, division, unicode_literals
# Lesser General Public License for more details.
#
# You should have received a copy of the GNU General Public License and the GNU
# Lesser General Public along with this program; if not, see
# Lesser General Public License along with this program; if not, see
# <https://www.gnu.org/licenses/>.
import gpg

View File

@ -21,7 +21,7 @@ from __future__ import absolute_import, division, unicode_literals
# Lesser General Public License for more details.
#
# You should have received a copy of the GNU General Public License and the GNU
# Lesser General Public along with this program; if not, see
# Lesser General Public License along with this program; if not, see
# <https://www.gnu.org/licenses/>.
import gpg

View File

@ -26,7 +26,7 @@
%ignore HAVE_CXX11;
%{
/* We use public symbols (eg. "_obsolete_class") which are marked as
/* We use public symbols (e.g. "_obsolete_class") which are marked as
* deprecated but we need to keep them. Silence the warning. */
#pragma GCC diagnostic ignored "-Wdeprecated-declarations"
%}

View File

@ -404,7 +404,7 @@ static gpgme_error_t pyPassphraseCb(void *hook,
err_status = _gpg_exception2code();
} else {
if (!retval) {
if (write(fd, "\n", 1) < 0) {
if (gpgme_io_writen (fd, "\n", 1) < 0) {
err_status = gpgme_error_from_syserror ();
_gpg_raise_exception (err_status);
}
@ -439,11 +439,11 @@ static gpgme_error_t pyPassphraseCb(void *hook,
goto leave;
}
if (write(fd, buf, len) < 0) {
if (gpgme_io_writen (fd, buf, len) < 0) {
err_status = gpgme_error_from_syserror ();
_gpg_raise_exception (err_status);
}
if (! err_status && write(fd, "\n", 1) < 0) {
if (! err_status && gpgme_io_writen (fd, "\n", 1) < 0) {
err_status = gpgme_error_from_syserror ();
_gpg_raise_exception (err_status);
}
@ -761,11 +761,11 @@ _gpg_interact_cb(void *opaque, const char *keyword,
goto leave;
}
if (write(fd, buffer, size) < 0) {
if (gpgme_io_writen (fd, buffer, size) < 0) {
err_status = gpgme_error_from_syserror ();
_gpg_raise_exception (err_status);
}
if (! err_status && write(fd, "\n", 1) < 0) {
if (! err_status && gpgme_io_writen (fd, "\n", 1) < 0) {
err_status = gpgme_error_from_syserror ();
_gpg_raise_exception (err_status);
}

View File

@ -25,11 +25,6 @@
#include <gpgme.h>
#include "Python.h"
#ifdef _WIN32
#include <windows.h>
#define write(fd, str, sz) {DWORD written; WriteFile((HANDLE) fd, str, sz, &written, 0);}
#endif
/* Flag specifying whether this is an in-tree build. */
extern int gpg_in_tree_build;

View File

@ -18,6 +18,10 @@
# License along with this library; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
try:
from setuptools import setup, Extension
from setuptools.command.build import build
except ImportError:
from distutils.core import setup, Extension
from distutils.command.build import build
@ -225,9 +229,8 @@ class BuildExtFirstHack(build):
build.run(self)
py3 = [] if sys.version_info.major < 3 else ['-py3']
swig_sources = []
swig_opts = ['-threads'] + py3 + extra_swig_opts
swig_opts = ['-threads'] + extra_swig_opts
swige = Extension(
'gpg._gpgme',
sources=swig_sources,
@ -282,10 +285,12 @@ GPGME and these bindings is available here:
'Programming Language :: Python :: 2',
'Programming Language :: Python :: 2.7',
'Programming Language :: Python :: 3',
'Programming Language :: Python :: 3.4',
'Programming Language :: Python :: 3.5',
'Programming Language :: Python :: 3.6',
'Programming Language :: Python :: 3.7',
'Programming Language :: Python :: 3.8',
'Programming Language :: Python :: 3.9',
'Programming Language :: Python :: 3.10',
'Programming Language :: Python :: 3.11',
'Programming Language :: Python :: 3.12',
'Operating System :: POSIX',
'Operating System :: Microsoft :: Windows',
'Topic :: Communications :: Email',

View File

@ -813,7 +813,7 @@ class Context(GpgmeWrapper):
Keyword arguments:
algorithm -- public key algorithm, see above (default: reasonable)
expires_in -- expiration time in seconds (default: reasonable)
expires -- whether or not the key should expire (default: True)
expires -- whether the key should expire (default: True)
sign -- request the signing capability (see above)
encrypt -- request the encryption capability (see above)
certify -- request the certification capability (see above)
@ -901,7 +901,7 @@ class Context(GpgmeWrapper):
Keyword arguments:
algorithm -- public key algorithm, see above (default: reasonable)
expires_in -- expiration time in seconds (default: reasonable)
expires -- whether or not the subkey should expire (default: True)
expires -- whether the subkey should expire (default: True)
sign -- request the signing capability (see above)
encrypt -- request the encryption capability (see above)
authenticate -- request the authentication capability (see above)
@ -1032,7 +1032,7 @@ class Context(GpgmeWrapper):
If command is a string or bytes, it will be used as-is. If it
is an iterable of strings, it will be properly escaped and
joined into an well-formed assuan command.
joined into a well-formed assuan command.
Keyword arguments:
data_cb -- a callback receiving data lines

View File

@ -107,6 +107,7 @@ pubring-stamp: $(test_srcdir)/pubdemo.asc gpg-sample.stamp
--import $(test_srcdir)/pubdemo.asc
-$(TESTS_ENVIRONMENT) $(GPG) --batch --no-permission-warning \
--import $(test_srcdir)/secdemo.asc
-$(TESTS_ENVIRONMENT) gpgconf --kill all
echo x > ./pubring-stamp
gpg.conf:

View File

@ -88,7 +88,7 @@ with support.EphemeralContext() as ctx:
except gpg.errors.GpgError:
pass
# try to add an pre-existent UID
# try to add a pre-existent UID
try:
ctx.key_add_uid(key, bravo)
assert False, "Expected an error but got none"

View File

@ -1,22 +1,22 @@
# Makefile.am for GPGMEPP.
# Makefile.am - Makefile for QGpgME.
# Copyright (C) 2016 Bundesamt für Sicherheit in der Informationstechnik
# Software engineering by Intevation GmbH
#
# This file is part of GPGMEPP.
# This file is part of QGpgME, the Qt API binding for GpgME.
#
# GPGME-CL is free software; you can redistribute it and/or modify it
# QGpgME is free software; you can redistribute it and/or modify it
# under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# GPGME-CL is distributed in the hope that it will be useful,
# QGpgME is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Lesser General Public License for more details.
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
# General Public License for more details.
#
# You should have received a copy of the GNU Lesser General Public
# License along with this program; if not, see <https://gnu.org/licenses/>.
# SPDX-License-Identifier: LGPL-2.1-or-later
# You should have received a copy of the GNU General Public License
# along with this program; if not, see <https://gnu.org/licenses/>.
# SPDX-License-Identifier: GPL-2.0-or-later
if RUN_GPG_TESTS
tests = tests

Some files were not shown because too many files have changed in this diff Show More