diff --git a/Makefile.am b/Makefile.am index 7b35128d..52639b75 100644 --- a/Makefile.am +++ b/Makefile.am @@ -1,128 +1,128 @@ # Makefile.am - Top level Makefile for GPGME. # Copyright (C) 2000 Werner Koch (dd9jn) # Copyright (C) 2001, 2002, 2004, 2005, 2008, 2009 g10 Code 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 Lesser General Public License as # published by the Free Software Foundation; either version 2.1 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 Lesser 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 . ## Process this file with automake to produce Makefile.in # Location of the released tarball archives. Note that this is an # internal archive and before uploading this to the public server, # manual tests should be run and the git release tat set and pushed. # Adjust as needed. RELEASE_ARCHIVE_DIR = wk@vigenere:tarballs/gpgme/ # The key used to sign the released sources. Adjust as needed. RELEASE_SIGNING_KEY = D8692123C4065DEA5E0F3AB5249B39D24F25E3B6 # Autoconf flags ACLOCAL_AMFLAGS = -I m4 DISTCHECK_CONFIGURE_FLAGS = EXTRA_DIST = autogen.sh autogen.rc gpgme.spec.in \ ChangeLog-2011 m4/ChangeLog-2011 \ conf/whatisthis VERSION if RUN_GPG_TESTS tests = tests else tests = endif SUBDIRS = src ${tests} doc lang # Fix the version of the spec file. dist-hook: gen-ChangeLog @set -e; \ sed -e 's/@pkg_version@/$(PACKAGE_VERSION)/g' \ $(top_srcdir)/gpgme.spec.in > $(distdir)/gpgme.spec distcheck-hook: set -e; ( \ pref="#+macro: gpgme_" ;\ reldate="$$(date -u +%Y-%m-%d)" ;\ echo "$${pref}ver $(PACKAGE_VERSION)" ;\ echo "$${pref}date $${reldate}" ;\ list='$(DIST_ARCHIVES)'; for i in $$list; do \ case "$$i" in *.tar.bz2) \ echo "$${pref}size $$(wc -c <$$i|awk '{print int($$1/1024)}')k" ;\ echo "$${pref}sha1 $$(sha1sum <$$i|cut -d' ' -f1)" ;\ echo "$${pref}sha2 $$(sha256sum <$$i|cut -d' ' -f1)" ;;\ esac;\ done ) | tee $(distdir).swdb .PHONY: gen-ChangeLog release sign-release gen_start_date = 2011-12-01T00:00:00 gen-ChangeLog: if test -d $(top_srcdir)/.git; then \ (cd $(top_srcdir) && \ $(GITLOG_TO_CHANGELOG) --append-dot --tear-off \ --amend=build-aux/git-log-fix \ --since=$(gen_start_date) ) > $(distdir)/cl-t; \ cat $(top_srcdir)/build-aux/git-log-footer >> $(distdir)/cl-t;\ rm -f $(distdir)/ChangeLog; \ mv $(distdir)/cl-t $(distdir)/ChangeLog; \ fi # Macro to help the release target. RELEASE_NAME = $(PACKAGE_TARNAME)-$(PACKAGE_VERSION) release: +(set -e;\ if [ "$(abs_top_builddir)" = "$(abs_top_srcdir)" ]; then \ echo "error: build directory must not be the source directory" >&2;\ exit 2;\ fi ;\ echo "/* Build started at $$(date -uIseconds) */" ;\ cd $(top_srcdir); \ ./autogen.sh --force; \ cd $(abs_top_builddir); \ rm -rf dist; mkdir dist ; cd dist ; \ $(abs_top_srcdir)/configure --enable-maintainer-mode; \ $(MAKE) distcheck TESTFLAGS=--parallel; \ echo "/* Build finished at $$(date -uIseconds) */" ;\ echo "/*" ;\ - echo " * Please run the final step interactivly:" ;\ + echo " * Please run the final step interactively:" ;\ echo " * make sign-release" ;\ echo " */" ;\ ) 2>&1 | tee "$(RELEASE_NAME).buildlog" sign-release: +(set -e; \ cd dist; \ files1="$(RELEASE_NAME).tar.bz2" ;\ files2="$(RELEASE_NAME).tar.bz2.sig \ $(RELEASE_NAME).swdb \ $(RELEASE_NAME).buildlog" ;\ echo "/* Signing the source tarball ..." ;\ gpg -sbu $(RELEASE_SIGNING_KEY) $(RELEASE_NAME).tar.bz2 ;\ cat $(RELEASE_NAME).swdb >swdb.snippet;\ echo >>swdb.snippet ;\ sha1sum $${files1} >>swdb.snippet ;\ cat "../$(RELEASE_NAME).buildlog" swdb.snippet \ | gzip >$(RELEASE_NAME).buildlog ;\ echo "Copying to local archive ..." ;\ scp -p $${files1} $${files2} $(RELEASE_ARCHIVE_DIR)/ || true;\ echo "Uploading documentation ..." ;\ $(MAKE) -C doc online; \ echo '/*' ;\ echo ' * All done; for checksums see dist/swdb.snippet' ;\ echo ' */' ;\ ) diff --git a/NEWS b/NEWS index 69fe066b..9c11df34 100644 --- a/NEWS +++ b/NEWS @@ -1,2016 +1,2016 @@ Noteworthy changes in version 1.12.1 (unreleased) ------------------------------------------------- * Interface changes relative to the 1.12.0 release: ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ cpp: Context::create NEW. cpp: Key::isBad NEW. cpp: Subkey::isBad NEW. cpp: UserID::isBad NEW. cpp: UserID::Signature::isBad NEW. Noteworthy changes in version 1.12.0 (2018-10-08) ------------------------------------------------- * Enhanced the JSON based interface tool gpgme-json to support Native Messaging as well as new Javascript code to support the browser site. See lang/js/README for details. * Major overhaul of the Python language bindings documentation. * Even for old versions of gpg a missing MDC will now lead to a decryption failure. * Added context flag "auto-key-locate" to control the behavior of GPGME_KEYLIST_MODE_LOCATE. * New data function to create a data object from an estream. * Add more interfaces to the C++ bindings. * Improved error codes on decryption failure. * Lots of minor fixes. * Interface changes relative to the 1.11.1 release: ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ gpgme_data_new_from_estream NEW. gpgme_decrypt_result_t EXTENDED: New field legacy_cipher_nomdc. gpgme_set_ctx_flag EXTENDED: New flag 'ignore-mdc-error'. GPGME_AUDITLOG_DEFAULT NEW. GPGME_AUDITLOG_DIAG NEW. gpgme_set_ctx_flag EXTENDED: New flag 'auto-key-locate'. cpp: DecryptionResult::sessionKey NEW. cpp: DecryptionResult::symkeyAlgo NEW. cpp: DecryptionResult::isLegacyCipherNoMDC New. cpp: Data::rewind NEW. cpp: Context::setFlag NEW. cpp: Context::getFlag NEW. cpp: Context::createKeyEx NEW. [c=C32/A21/R0 cpp=C14/A8/R0 qt=C10/A3/R2] Release-info: https://dev.gnupg.org/T4109 Noteworthy changes in version 1.11.1 (2018-04-20) ------------------------------------------------- * Fixed build problems in the 1.11.0 release. * Added C++ interfaces which were planned for 1.11.0. * Interface changes relative to the 1.10.0 release: ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ cpp: Key::origin NEW. cpp: Key::lastUpdate NEW. cpp: UserID::origin NEW. cpp: UserID::lastUpdate NEW. [c=C31/A20/R1 cpp=C13/A7/R0 qt=C10/A3/R2] Noteworthy changes in version 1.11.0 (2018-04-18) ------------------------------------------------- * New encryption API to support direct key specification including hidden recipients option and taking keys from a file. This also allows to enforce the use of a subkey. * New encryption flag for the new API to enforce the use of plain mail addresses (addr-spec). * The import API can now tell whether v3 keys are skipped. These old and basically broken keys are not anymore supported by GnuPG 2.1. * The decrypt and verify API will now return the MIME flag as specified by RFC-4880bis. * The offline mode now has an effect on gpg by disabling all network access. [#3831] * A failed OpenPGP verification how returns the fingerprint of the intended key if a recent gpg version was used for signature creation. * New tool gpgme-json as native messaging server for web browsers. As of now public key encryption and decryption is supported. Requires Libgpg-error 1.29. * New context flag "request-origin" which has an effect when used with GnuPG 2.2.6 or later. * New context flag "no-symkey-cache" which has an effect when used with GnuPG 2.2.7 or later. * New convenience constant GPGME_KEYLIST_MODE_LOCATE. * Improved the Python documentation. * Fixed a potential regression with GnuPG 2.2.6 or later. * Fixed a crash in the Python bindings on 32 bit platforms. [#3892] * Various minor fixes. * Interface changes relative to the 1.10.0 release: ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ gpgme_op_encrypt_ext NEW. gpgme_op_encrypt_ext_start NEW. gpgme_op_encrypt_sign_ext NEW. gpgme_op_encrypt_sign_ext_start NEW. GPGME_ENCRYPT_WANT_ADDRESS NEW. GPGME_KEYLIST_MODE_LOCATE NEW. gpgme_import_result_t EXTENDED: New field 'skipped_v3_keys'. gpgme_decrypt_result_t EXTENDED: New field 'symkey_algo'. gpgme_decrypt_result_t EXTENDED: New field 'is_mime'. gpgme_verify_result_t EXTENDED: New field 'is_mime'. cpp: Key::locate NEW. cpp: Data::toString NEW. cpp: ImportResult::numV3KeysSkipped NEW. [c=C31/A20/R0 cpp=C12/A6/R0 qt=C10/A3/R1] Noteworthy changes in version 1.10.0 (2017-12-12) ------------------------------------------------- * Now returns more specific error codes for decryption to distinguish between bad passphrase, user canceled, and no secret key. * Now returns key origin information if available. * Added context flag "auto-key-retrieve" to selectively enable the corresponding gpg option. * Added flag is_de_vs to decryption and verify results. * py: Use SEEK_SET as default for data.seek. * cpp: Various new APIs. * Reduced spawn overhead on Linux again. Added new configure option --disable-linux-getdents to disable this feature for very old Linux versions. * Improved the Python bindings build system. * Made the test suite less fragile. * Interface changes relative to the 1.9.0 release: ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ gpgme_decrypt_result_t EXTENDED: New field 'is_de_vs'. gpgme_signature_t EXTENDED: New field 'is_de_vs'. gpgme_keyorg_t NEW. gpgme_op_delete_ext NEW. gpgme_op_delete_ext_start NEW. GPGME_DELETE_ALLOW_SECRET NEW. GPGME_DELETE_FORCE NEW. gpgme_op_conf_dir NEW. gpgme_set_ctx_flag EXTENDED: New flag 'auto-key-retrieve'. cpp: DecryptionResult::isDeVs NEW. cpp: Signature::isDeVs NEW. cpp: EngineInfo::Version::operator> NEW. cpp: Context::createKey NEW. cpp: Context::startCreateKey NEW. cpp: Context::createSubkey NEW. cpp: Context::startCreateSubkey NEW. qt: QuickJob NEW. py: DecryptResult EXTENDED: New boolean field 'is_de_vs'. py: Signature EXTENDED: New boolean field 'is_de_vs'. py: GpgError EXTENDED: Partial results in 'results'. [c=C30/A19/R0 cpp=C11/A5/R0 qt=C10/A3/R0] Noteworthy changes in version 1.9.0 (2017-03-28) ------------------------------------------------ * Clarified meaning of the 'expire' parameter of gpgme_op_createkey and gpgme_op_createsubkey. New flag to force a key without an expiration date. * New function gpgme_op_keylist_from_data_start to list keys from data objects without importing them. * New function gpgme_op_set_uid_flag to flag a key as primary. * New function gpgme_op_decrypt_ext to run decryption with special flags. This can for example be used to unwrap keys (remove only the encryption layer). * New encryption flags to wrap a key (adding an encryption layer to an OpenPGP message) or to create anonymously encrypted messages. * Support for adduid and revuid operations in the C++ bindings. * Support for smartcard key generation in the C++ bindings. * Several new functions for the Python binding. * Many smaller bug fixes. * Interface changes relative to the 1.8.0 release: ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ gpgme_op_createkey CHANGED: Meaning of 'expire' parameter. gpgme_op_createsubkey CHANGED: Meaning of 'expire' parameter. GPGME_CREATE_NOEXPIRE NEW. gpgme_key_t EXTENDED: New field 'origin'. gpgme_key_t EXTENDED: New field 'last_update'. gpgme_subkey_t EXTENDED: New field 'is_de_vs'. gpgme_user_id_t EXTENDED: New field 'origin'. gpgme_user_id_t EXTENDED: New field 'last_update'. gpgme_op_keylist_from_data_start NEW. gpgme_op_set_uid_flag_start NEW. gpgme_op_set_uid_flag NEW. gpgme_op_decrypt_ext_start NEW. gpgme_op_decrypt_ext NEW. GPGME_ENCRYPT_THROW_KEYIDS NEW. GPGME_ENCRYPT_WRAP NEW. GPGME_DECRYPT_VERIFY NEW. GPGME_DECRYPT_UNWRAP NEW. gpgme_data_rewind UN-DEPRECATE. cpp: Context::revUid(const Key&, const char*) NEW. cpp: Context::startRevUid(const Key&, const char*) NEW. cpp: Context::addUid(const Key&, const char*) NEW. cpp: Context::startAddUid(const Key&, const char*) NEW. cpp: Key::UserID::revoke() NEW. cpp: Key::addUid() NEW. cpp: Key::isDeVs NEW. cpp: GpgGenCardKeyInteractor NEW. cpp: Subkey::keyGrip NEW. cpp: Subkey::isDeVs NEW. cpp: Data::toKeys NEW. cpp: Context::setDecryptFlags NEW. cpp: Context::decrypt EXTENDED: Flags added. cpp: Context::startDecrypt EXTENDED: Flags added. cpp: Context::decryptAndVerify EXTENDED: Flags added. cpp: Context::startCombinedDecryptionAndVerification EXTENDED: Flags. cpp: Context::encryptFlags EXTENDED: New flags. qt: CryptoConfig::stringValueList() NEW. py: Context.__init__ EXTENDED: New keyword arg home_dir. py: Context.home_dir NEW. py: Context.keylist EXTENDED: New keyword arg mode. py: Context.keylist EXTENDED: New keyword arg source. py: Context.create_key NEW. py: Context.create_subkey NEW. py: Context.key_add_uid NEW. py: Context.key_revoke_uid NEW. py: Context.key_sign NEW. py: Context.key_tofu_policy NEW. py: core.pubkey_algo_string NEW. py: core.addrspec_from_uid NEW. [c=C29/A18/R0 cpp=C10/A4/R0 qt=C9/A2/R0] Noteworthy changes in version 1.8.0 (2016-11-16) ------------------------------------------------ * The module of the Python bindings has been renamed to 'gpg'. * New interface to query current software versions. * New feature to use gpg's --{show,override}session-key options. * New interface to set the sender of a mail. * qt: Added Distinguished Name parser from libkleo * The --homedir option is now used with recent gpgconf versions. * On 64 bit Windows systems gpgconf is now properly located. * The internal locking functions have been replaced by libgpg-error locking functions. * Interface changes relative to the 1.7.1 release: ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ gpgme_set_sender NEW. gpgme_get_sender NEW. gpgme_op_query_swdb NEW. gpgme_op_query_swdb_result NEW. gpgme_query_swdb_result_t NEW. gpgme_get_ctx_flag NEW. gpgme_decrypt_result_t EXTENDED: New field session_key. qt: DN NEW. qt: DN::Attribute NEW. qt: Job::context(Job*) NEW. cpp: EngineInfo::Version::Version(const char*) NEW. cpp: EngineInfo::Version::Version() NEW. cpp: SwdbResult NEW. cpp: Context::setSender(const char*) NEW. cpp: Context::getSender() NEW. [c=C28/A17/R0 cpp=C9/A3/R0 qt=C8/A1/R0] Noteworthy changes in version 1.7.1 (2016-10-18) ------------------------------------------------ * Fixed problems with the new language bindings. * New helper function gpgme_addrspec_from_uid. * Use option --exit-on-status-write-error with newer gpg versions. * qt: Missed API from the Qt Binding inclusion has been added again. * qt: abstractimportjob.h is now installed to that ImportJobs can be used again. * qt: Fixed spelling error in API (startReceive). * Interface changes relative to the 1.7.0 release: ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ gpgme_addrspec_from_uid NEW. qt: WksPublishJob::startRecieve RENAMED to ::startReceive. qt: MultiDeleteJob NEW. qt: AbstractImportJob NEW. qt: SpecialJob NEW. cpp: Signature::key(bool, bool) NEW. cpp: UserID::addrSpecFromString(const char*) NEW. cpp: UserID::addrSpec() NEW. [c=C27/A16/R0 cpp=C8/A2/R0 qt=C7/A0/R0] Noteworthy changes in version 1.7.0 (2016-09-21) ------------------------------------------------ * New language bindings for Python 2 and 3. * New language Bindings for C++ and the Qt-Framework API. * New functions gpgme_op_createkey and gpgme_op_createsubkey to make key creation easier (requires GnuPG 2.1). * New functions gpgme_op_adduid and gpgme_op_revuid to make user id management easier (requires GnuPG 2.1). * New function gpgme_op_keysign to make key signing easier (requires GnuPG 2.1). * New function gpgme_op_interact to replace the now deprecated functions gpgme_op_edit and gpgme_op_card_edit. * New function gpgme_pubkey_algo_string to convert a public key algorithm into a GnuPG 2.1 style string. * Support for GnuPG 2.1's TOFU trust model. * Notation flags are now correctly set on verify. * New global flag "require-gnupg" to set a minimal gnupg version. * More supported items in gpgme_get_dirinfo. * New function gpgme_data_set_flag and flag "size-hint". * New function gpgme_set_ctx_flag and flags "full-status" and "raw-description". * Improved gpgme_data_identify to distinguish more file types. * New flag GPGME_ENCRYPT_SYMMETRIC for gpgme_op_encrypt to allow mixed public key and symmetric encryption. * New field KEYGRIP in gpgme_subkey_t. New fields FPR in gpgme_key_t. * New flag GPGME_DATA_ENCODING_MIME to declare that the encrypted or signed data is a valid MIME part. This is to support future GnuPG versions. * Interface changes relative to the 1.6.0 release: ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ gpgme_pubkey_algo_string NEW. GPGME_PK_EDDSA NEW. gpgme_set_ctx_flag NEW. gpgme_data_set_flag NEW. gpgme_op_createkey NEW. gpgme_op_createkey_start NEW. gpgme_op_createsubkey NEW. gpgme_op_createsubkey_start NEW. gpgme_op_adduid_start NEW. gpgme_op_adduid NEW. gpgme_op_revuid_start NEW. gpgme_op_revuid NEW. gpgme_op_keysign_start NEW. gpgme_op_keysign NEW. gpgme_op_tofu_policy_start NEW. gpgme_op_tofu_policy NEW. gpgme_op_interact_start NEW. gpgme_op_interact NEW. gpgme_interact_cb_t NEW. gpgme_op_edit_start DEPRECATED. gpgme_op_edit DEPRECATED. gpgme_op_card_edit_start DEPRECATED. gpgme_op_card_edit DEPRECATED. gpgme_edit_cb_t DEPRECATED. gpgme_status_code_t DEPRECATED. gpgme_genkey_result_t EXTENDED: New fields pubkey and seckey. gpgme_signature_t EXTENDED: New field key. gpgme_key_t EXTENDED: New field fpr. gpgme_subkey_t EXTENDED: New field keygrip. gpgme_user_id_t EXTENDED: New field tofu. gpgme_tofu_policy_t NEW. gpgme_tofu_info_t NEW. GPGME_STATUS_KEY_CONSIDERED NEW. GPGME_STATUS_TOFU_USER NEW. GPGME_STATUS_TOFU_STATS NEW. GPGME_STATUS_TOFU_STATS_LONG NEW. GPGME_STATUS_NOTATION_FLAGS NEW. GPGME_KEYLIST_MODE_WITH_TOFU NEW. GPGME_DATA_TYPE_PGP_ENCRYPTED NEW. GPGME_DATA_TYPE_PGP_SIGNATURE NEW. GPGME_DATA_ENCODING_MIME NEW. GPGME_ENCRYPT_SYMMETRIC NEW. GPGME_CREATE_SIGN NEW. GPGME_CREATE_ENCR NEW. GPGME_CREATE_CERT NEW. GPGME_CREATE_AUTH NEW. GPGME_CREATE_NOPASSWD NEW. GPGME_CREATE_SELFSIGNED NEW. GPGME_CREATE_NOSTORE NEW. GPGME_CREATE_WANTPUB NEW. GPGME_CREATE_WANTSEC NEW. GPGME_CREATE_FORCE NEW. GPGME_KEYSIGN_LOCAL NEW. GPGME_KEYSIGN_LFSEP NEW. GPGME_INTERACT_CARD NEW. [c=C26/A15/R0 cpp=C6/A0/R1 qt=C6/A0/R1] Noteworthy changes in version 1.6.0 (2015-08-26) [C25/A14/R0] ------------------------------------------------ * Added gpgme_set_offline to do a key listinging w/o requiring CRL. * Added gpgme_set_status_cb to allow a user to see some status messages. * Added an export mode for secret keys. * More precise error codes are returned if GnuPG >= 2.1.8 is used. * The passphrase handler for the loopback mode has been improved and may also be used with genkey. - * [w32] The standard GnuPG 2.1 install directory is now seached for + * [w32] The standard GnuPG 2.1 install directory is now searched for gpgconf.exe before a registry specified directory and the Gpg4win install directory. * [w32] gpgme-w32spawn.exe will now only be searched in the gpgme DLL directory. * Interface changes relative to the 1.5.1 release: ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ gpgme_set_offline NEW. gpgme_get_offline NEW. gpgme_set_status_cb NEW. gpgme_get_status_cb NEW. GPGME_EXPORT_MODE_SECRET NEW GPGME_EXPORT_MODE_RAW NEW. GPGME_EXPORT_MODE_PKCS12 NEW. Noteworthy changes in version 1.5.5 (2015-06-08) [C24/A13/R4] ------------------------------------------------ * Fixed crash in key listings for user ids with a backslash. * Fixed regression for GPGSM use with GnuPG < 2.1. * Properly set signature summary for revoked OpenPGP keys. Noteworthy changes in version 1.5.4 (2015-04-13) [C24/A13/R3] ------------------------------------------------ * Fixed a possible crash in the debug code. * Fixed building for Windows with newer versions of Mingw. Noteworthy changes in version 1.5.3 (2014-12-11) [C24/A13/R2] ------------------------------------------------------------- * The export key functions do now return an error if used with the latest GnuPG version. Noteworthy changes in version 1.5.2 (2014-11-21) [C24/A13/R1] ------------------------------------------------------------- * gpgme-tool is now installed. * Fix external listing for modern keyservers. * Minor other fixes. Noteworthy changes in version 1.5.1 (2014-07-30) [C24/A13/R0] ------------------------------------------------------------- * Fixed possible overflow in gpgsm and uiserver engines. [CVE-2014-3564] * Added support for GnuPG 2.1's --with-secret option. * Interface changes relative to the 1.5.0 release: ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ GPGME_KEYLIST_MODE_WITH_SECRET NEW. Noteworthy changes in version 1.5.0 (2014-05-21) [C23/A12/R0] ------------------------------------------------------------- * On Unices the engine file names are not not anymore hardwired but located via the envvar PATH. All options to set the name of the engines for the configure run are removed. * If GPGME finds the gpgconf binary it defaults to using gpg2 or whatever gpgconf tells as name for the OpenPGP engine. If gpgconf is not found, GPGME looks for an engine named "gpg". * New feature to use the gpgme I/O subsystem to run arbitrary commands. * New flag to use encryption without the default compression step. * New function to access "gpg-conf --list-dirs" * New configure option --enable-fixed-path for use by Android. * Support ECC algorithms. * Interface changes relative to the 1.4.3 release: ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ gpgme_get_dirinfo NEW. gpgme_op_spawn_start NEW. gpgme_op_spawn NEW. GPGME_PROTOCOL_SPAWN NEW. GPGME_SPAWN_DETACHED NEW. GPGME_SPAWN_ALLOW_SET_FG NEW. GPGME_ENCRYPT_NO_COMPRESS NEW. GPGME_PK_ECC NEW. GPGME_MD_SHA224 NEW. gpgme_subkey_t EXTENDED: New field curve. GPGME_STATUS_PLAINTEXT_LENGTH NEW. GPGME_STATUS_MOUNTPOINT NEW. GPGME_STATUS_PINENTRY_LAUNCHED NEW. GPGME_STATUS_ATTRIBUTE NEW. GPGME_STATUS_BEGIN_SIGNING NEW. GPGME_STATUS_KEY_NOT_CREATED NEW. Noteworthy changes in version 1.4.3 (2013-08-12) [C22/A11/R0] ------------------------------------------------------------- * The default engine names are now taken from the output of gpgconf. If gpgconf is not found the use of gpg 1 is assumed. * Under Windows the default engines names are first searched in the installation directory of the gpgme DLL. * New function gpgme_data_identify to detect the type of a message. * Interface changes relative to the 1.4.2 release: ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ gpgme_signers_count NEW. gpgme_data_type_t NEW. gpgme_data_identify NEW. Noteworthy changes in version 1.4.2 (2013-05-28) [C21/A10/R0] ------------------------------------------------------------- * Allow symmetric encryption with gpgme_op_encrypt_sign. * Fixed mismatching off_t definitions on Windows. * Interface changes relative to the 1.4.1 release: ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ gpgme_off_t NEW. gpgme_size_t NEW. GPGME_PROTOCOL_OPENPGP NEW alias. Noteworthy changes in version 1.4.1 (2013-05-01) [C20/A9/R1] ------------------------------------------------------------ * Fixed reading of gpg.conf files with excessive use of the group option. * Fixed building with the i686-w64-mingw32 toolchain. * Disabled FD passing by default for Apple. Noteworthy changes in version 1.4.0 (2013-02-26) [C20/A9/R0] ------------------------------------------------------------ * New function gpgme_set_global_flag to help debugging on Android. * New function gpgme_io_writen as a convenience wrapper around gpgme_io_write. * New functions to support the pinentry mode feature of GnuPG 2.1. * New macro GPGME_VERSION_NUMBER to allow supporting different API versions without the need for a configure test. * Several improvements for gpgme-tool. * Better logging of the common "invalid engine" error code. * Support for FD passing is now enabled by default. The configure option --disable-fd-passing may be used to disable this. * Interface changes relative to the 1.3.1 release: ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ GPGME_VERSION_NUMBER NEW. gpgme_io_writen NEW. gpgme_set_global_flag NEW. gpgme_set_pinentry_mode NEW. gpgme_get_pinentry_mode NEW. gpgme_pinentry_mode_t NEW. GPGME_PINENTRY_MODE_DEFAULT NEW. GPGME_PINENTRY_MODE_ASK NEW. GPGME_PINENTRY_MODE_CANCEL NEW. GPGME_PINENTRY_MODE_ERROR NEW. GPGME_PINENTRY_MODE_LOOPBACK NEW. Noteworthy changes in version 1.3.2 (2012-05-02) ------------------------------------------------ * Remove support for libgpgme-pth. As far as we know, this was never used, and GnuPG is going to use our own npth in the future. * Fix signature summary information for a missing X.509 key. * Fix parsing of dates >= year 2038. Noteworthy changes in version 1.3.1 (2011-06-16) ------------------------------------------------ * Ported to Windows CE. * Detect GPG versions not supporting ---passwd. * Interface changes relative to the 1.3.0 release: ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ GPGME_EXPORT_MODE_MINIMAL NEW GPGME_STATUS_SUCCESS NEW gpgme_err_code_from_syserror NEW gpgme_err_set_errno NEW gpgme_error_from_errno CHANGED: Return gpgme_error_t (compatible type). gpgme_error_from_syserror NEW ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Noteworthy changes in version 1.3.0 (2010-01-11) ------------------------------------------------ * GPGME does not come with an internal libassuan version anymore. The external libassuan 1.1.0 release or later is required. For application programmers on systems that can resolve inter-library dependencies at runtime, this is a transparent change. * New engine GPGME_PROTOCOL_G13 to support the new g13 tool. * New engine GPGME_PROTOCOL_UISERVER to support UI Servers. * New API to change the passphrase of a key. * Interface changes relative to the 1.2.0 release: ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ GPGME_STATUS_INV_SGNR NEW. GPGME_STATUS_NO_SGNR NEW. GPGME_PROTOCOL_G13 NEW. gpgme_op_g13_mount NEW. gpgme_g13_result_t NEW. GPGME_PK_ECDSA NEW. GPGME_PK_ECDH NEW. gpgme_op_passwd_start NEW. gpgme_op_passwd NEW. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Noteworthy changes in version 1.2.0 (2009-06-18) ------------------------------------------------ * New encryption flag GPGME_ENCRYPT_NO_ENCRYPT_TO to disable default recipients. * gpgme_new will fail if gpgme_check_version was not called, or a selftest failed (for example, if -mms-bitfields was not used on MingW32 targets). * New functions gpgme_io_read and gpgme_io_write for use with gpgme_passphrase_cb_t and gpgme_edit_cb_t functions. * New functions gpgme_result_ref and gpgme_result_unref to detach result structures from a context. * New functions gpgme_op_export_keys_start and gpgme_op_export_keys that allow to specify exported keys through gpgme_key_t objects instead of patterns. * New mode of operation gpgme_export_mode_t that allows exporting external keys. * Interface changes relative to the 1.1.7 release: ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ GPGME_KEYLIST_MODE_EPHEMERAL NEW. GPGME_PROTOCOL_ASSUAN NEW. gpgme_assuan_data_cb_t NEW. gpgme_assuan_inquire_cb_t NEW. gpgme_assuan_status_cb_t NEW. gpgme_op_assuan_transact_start NEW. gpgme_op_assuan_transact NEW. gpgme_op_assuan_result NEW. gpgme_op_import_keys NEW. gpgme_op_import_keys_start NEW. gpgme_subkey_t EXTENDED: New fields is_cardkey, card_number. GPGME_ENCRYPT_NO_ENCRYPT_TO NEW. gpgme_check_version CHANGED: Is now a macro. gpgme_new EXTENDED: More failure codes. gpgme_io_read NEW. gpgme_io_write NEW. gpgme_result_ref NEW. gpgme_result_unref NEW. gpgme_export_mode_t NEW. gpgme_export_ext_start EXTENDED: Arg RESERVED is now a MODE flag. gpgme_op_export EXTENDED: Arg RESERVED is now a MODE flag. gpgme_op_export_ext_start EXTENDED: Arg RESERVED is now a MODE flag. gpgme_op_export_ext EXTENDED: Arg RESERVED is now a MODE flag. gpgme_op_export_keys_start NEW. gpgme_op_export_keys NEW. GPGME_DATA_ENCODING_URL NEW. GPGME_DATA_ENCODING_URL0 NEW. GPGME_DATA_ENCODING_URLESC NEW. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Noteworthy changes in version 1.1.8 (2008-12-08) ------------------------------------------------ * SIGPIPE is now again ignored as described in the manual. Fixes - regresion introduced with 1.1.6. + regression introduced with 1.1.6. Noteworthy changes in version 1.1.7 (2008-10-17) ------------------------------------------------ * Using GPGME_KEYLIST_MODE_LOCAL combined with GPGME_KEYLIST_MODE_EXTERN is now supported; it uses the --locate-keys feature of gpg (>= 2.0.10). * The encoding of gpgme_data_t objects can affect the output encoding of export, sign and encrypt operations now (the same operations that are also affected by the ASCII mode switch). We believe this change in the ABI is innocent enough not to break existing applications (it only affects the S/MIME backend on certain operations). * The reference manual now includes the specification of "The GnuPG UI Server protocol". * A new function gpgme_cancel_async can be used to asynchronously cancel any pending operation at any time, from any thread. * Interface changes relative to the 1.1.6 release: ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ gpgme_op_encrypt CHANGED: Output encoding can affect result. gpgme_op_encrypt_start CHANGED: Output encoding can affect result. gpgme_op_encrypt_sign CHANGED: Output encoding can affect result. gpgme_op_encrypt_sign_start CHANGED: Output encoding can affect result. gpgme_op_sign CHANGED: Output encoding can affect result. gpgme_op_sign_start CHANGED: Output encoding can affect result. gpgme_op_export CHANGED: Output encoding can affect result. gpgme_op_export_start CHANGED: Output encoding can affect result. gpgme_op_export_ext CHANGED: Output encoding can affect result. gpgme_op_export_ext_start CHANGED: Output encoding can affect result. gpgme_cancel_async NEW ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Noteworthy changes in version 1.1.6 (2008-01-04) ------------------------------------------------ * Bug fixes for for W32. * A new, experimental (and thus undocumented and potentially unstable) interface for accessing gpg-conf through GPGME has been added. * Interface changes relative to the 1.1.1 release: ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ gpgme_signature_t EXTENDED: New field chain_model. gpgme_op_getauditlog_start NEW. gpgme_op_getauditlog NEW. GPGME_AUDITLOG_HTML NEW. GPGME_AUDITLOG_WITH_HELP NEW. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Noteworthy changes in version 1.1.5 (2007-07-09) ------------------------------------------------ * Bug and portability fixes (mainly for W32). Noteworthy changes in version 1.1.4 (2007-03-05) ------------------------------------------------ * Detect and bail out on double plaintext messages. This is required so that applications can properly detect the signed parts of a message. Actual there is now a double protection as GnuPG 1.4.7 will detect this case too. Noteworthy changes in version 1.1.3 (2007-01-29) ------------------------------------------------ * Fixed a memory leak in gpgme_data_release_and_get_mem. * Fixed a bug in Windows command line quoting. Noteworthy changes in version 1.1.2 (2006-03-02) ------------------------------------------------ * Fixed a bug in the W32 glib backend. Noteworthy changes in version 1.1.1 (2006-02-23) ------------------------------------------------ * Fixed a bug in that the fingerprints of subkeys are not available. * Clarified usage of the SECRET flag in key listings. It is now reset for stub keys. * Reading signature notations and policy URLs on key signatures is supported. They can be found in the new field notations of the gpgme_key_sig_t structure. This has to be enabled with the keylist mode flag GPGME_KEYLIST_MODE_SIG_NOTATIONS. * A new gpgme_free() function solves the problem of using different allocators in a single program. This function should now be used instead calling free() to release the buffer returned by gpgme_data_release_and_get_mem. It is recommended that you always do this, but it is only necessary on certain platforms, so backwards compatibility is provided. In other words: If free() worked for you before, it will keep working. * New status codes GPGME_PKA_TRUST_GOOD and GPGME_PKA_TRUST_BAD. They are analyzed by the verify handlers and made available in the new PKA_TRUST and PKA_ADDRESS fields of the signature result structure. * Interface changes relative to the 1.1.0 release: ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ gpgme_key_sig_t EXTENDED: New field notations. GPGME_KEYLIST_MODE_SIG_NOTATIONS NEW gpgme_free NEW GPGME_STATUS_PKA_TRUST_BAD NEW GPGME_STATUS_PKA_TRUST_GOOD NEW gpgme_signature_t EXTENDED: New field pka_trust. gpgme_signature_t EXTENDED: New field pka_address. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Noteworthy changes in version 1.1.0 (2005-10-01) ------------------------------------------------ * You can now configure the backend engine file name and home directory to be used, as default and per context. * Information about the recipients of an encrypted text is now available at decryption time. * New status GPGME_STATUS_PLAINTEXT. This is analyzed by the decrypt and verify handlers, the information about the plaintext filename, if available is made available in the new field file_name of the respective result structure. * The code for "automagically detecting the thread library" has been removed from libgpgme. It is deprecated since version 0.4.3. Since then, you had to link against libgpgme-pthread for applications using pthread and libgpgme-pth for applications using GNU Pth. The code was removed because it caused compilation problems on systems where the pthread.h header from GNU Pth is available in addition to the system header (FreeBSD 6 and later for example). * "./autogen.sh --build-w32" does now build gpgme.dll. * [W32] The environment variable GPGME_DEBUG now uses a semicolon as delimiter. The standard install directory is used when locating gpg or gpgsm before finally falling back to the hardwired name. * There is a new flag for keys and subkeys, is_qualified, which indicates if a key can be used for qualified signatures according to local government regulations. * You can associate a filename with a data object using the new function gpgme_data_set_file_name(). This filename will be stored in the output when encrypting or signing the data and will be returned when decrypting or verifying the output data. * You can now set notation data at signature creation with the new function gpgme_sig_notation_add(). * Interface changes relative to the 1.0.3 release: ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ gpgme_set_engine_info NEW gpgme_ctx_get_engine_info NEW gpgme_ctx_set_engine_info NEW gpgme_recipient_t NEW gpgme_decrypt_result_t EXTENDED: New field recipients. gpgme_verify_result_t EXTENDED: New fields pubkey_algo, hash_algo. gpgme_decrypt_result_t EXTENDED: New field plaintext_filename. gpgme_verify_result_t EXTENDED: New field plaintext_filename. GPGME_STATUS_PLAINTEXT NEW gpgme_key_t EXTENDED: New field is_qualified. gpgme_subkey_t EXTENDED: New field is_qualified. gpgme_data_get_file_name NEW gpgme_data_set_file_name NEW gpgme_sig_notation_flags_t NEW GPGME_SIG_NOTATION_HUMAN_READABLE NEW GPGME_SIG_NOTATAION_CRITICAL NEW gpgme_sig_notation_clear NEW gpgme_sig_notation_add NEW gpgme_sig_notation_get NEW ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Noteworthy changes in version 1.0.3 (2005-06-20) ------------------------------------------------ * Previousy, GPGME would use a default "include certs" of 1. This has been changed. Now GPGME will use the crypto backend engines default unless you set the value with gpgme_set_include_certs() - explicitely. A new macro GPGME_INCLUDE_CERTS_DEFAULT can be used - as a value to explicitely request the new default behaviour. + explicitly. A new macro GPGME_INCLUDE_CERTS_DEFAULT can be used + as a value to explicitly request the new default behaviour. Because the default changes, this is a slight change of the API semantics. We consider it to be a bug fix. * A bug which made GPGME hang has been fixed. If you have experienced hanging before, please try out this version and let me know if you still experience hanging problems. * Interface changes relative to the 0.9.0 release: ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ gpgme_set_include_certs CHANGED DEFAULT GPGME_INCLUDE_CERTS_DEFAULT NEW GPGME_STATUS_SIG_SUBPACKET NEW GPGME_STATUS_NEED_PASSPHRASE_PIN NEW GPGME_STATUS_SC_OP_FAILURE NEW GPGME_STATUS_SC_OP_SUCCESS NEW GPGME_STATUS_CARDCTRL NEW GPGME_STATUS_BACKUP_KEY_CREATED NEW ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Noteworthy changes in version 1.0.2 (2004-12-28) ------------------------------------------------ * Changed the license of the library to the GNU Lesser General Public License (LGPL), version 2.1 or later. Noteworthy changes in version 1.0.1 (2004-10-22) ------------------------------------------------ * Only bug fixes. Noteworthy changes in version 1.0.0 (2004-09-30) ------------------------------------------------ * Version 1.0.0! We are proud to present you with a thoroughly tested and stable version of the GPGME library. A big Thank You! to all the people who made this possible. The development will be branched into a stable 1.x.y series and the head. * The gpgme.m4 macro supports checking the API version. Just prepend it to the required version string, separated by a colon. For example, this release has the version "1:1.0.0". The last release to which this version is (mostly) ABI compatible is "1:0.4.2", which is the default required version. Noteworthy changes in version 0.9.0 (2004-06-08) ------------------------------------------------ * The type gpgme_key_t has now a new field keylist_mode that contains the keylist mode that was active at the time the key was retrieved. * The type gpgme_decrypt_result_t has a new field "wrong_key_usage" that contains a flag indicating that the key should not have been used for encryption. * Verifying a signature of a revoked key gives the correct result now (GPG_ERR_CERT_REVOKED error code). * Clarified that the error code GPG_ERR_NO_DATA from the decrypt & verify operations still allows you to look at the signature verification result. * Clarified that patterns in keylisting operations have an upper limit, and thus are not suited to list many keys at once by their fingerprint. Also improve the error message if the pattern is too long for the CMS protocol to handle. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ gpgme_key_t EXTENDED: New field keylist_mode. gpgme_decrypt_result_t EXTENDED: New field wrong_key_usage. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Noteworthy changes in version 0.4.7 (2004-04-29) ------------------------------------------------ * Correctly initialize the fields expired, revoked, invalid, and disabled in the gpgme_key_t structures. * A bug fix: The flag wrong_key_usage of gpgme_signature_t was - accidently of type int instead unsigned int. + accidentally of type int instead unsigned int. * Interface changes relative to the 0.4.5 release: ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ gpgme_signature_t CHANGED: wrong_key_usage is unsigned int now. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Noteworthy changes in version 0.4.6 (2004-04-06) ------------------------------------------------ * Bug fixes Noteworthy changes in version 0.4.5 (2004-03-07) ------------------------------------------------ * GPGME is now compiled with LFS (large file support) by default. This means that _all_ programs using GPGME must be compiled with LFS support enabled by default. You can do this easily with autoconf, by using the AC_SYS_LARGEFILE macro. Or you can do this without autoconf by defining the preprocessor symbol _FILE_OFFSET_BITS to 64 (by passing the -D_FILE_OFFSET_BITS=64 to the C compiler command line, or by defining this preprocessor symbol before including any system header files). For more details, read the section on LFS in the manual. Up to now, it was undocumented that GPGME was not using LFS. But the public interfaces use off_t, and file descriptors are exchanged between the application and GPGME. This was an oversight, and bound to cause troubles in the future. Writing GPGME as a dual mode library that seamlessly supports LFS while keeping backwards compatibility is possible, but does not solve the problem: Many applications already expect GPGME to have LFS (they are compiled with off_t being a 64bit value). This is true in particular for the popular Gtk+ and Qt programs. So, although this is an ABI (but not an API) break, we will not change the library version to reflect that. Because the interfaces affected are probably not used yet in any GPGME 0.4 based application, we don't expect any real failures from this change. In fact, applications already using LFS will have some subtle bugs fixed. However, if you encounter an application using GPGME 0.4.x that does _not_ use LFS by default (off_t is a 32bit value), _and_ uses at least one of the functions gpgme_data_seek, gpgme_data_new_from_filepart, or a gpgme_data_seek_cb_t with gpgme_data_new_from_cbs, then indeed this library will be ABI incompatible with the program. As said above, we don't believe such a program exists. If we are in error, then you have two options: As a quick hack, you can configure GPGME with the --disable-largefile option. This will revert the change, and GPGME will not use LFS. However, GPGME will be incompatible with programs that expect GPGME to use LFS. All applications are required to use LFS when using GPGME, so this is only good as a temporary local work-around. The other option is to change the versioning of the library and recompile all applications. We have reserved a special version of the library for that, so you can do that without expecting a version clash in the future. Furthermore, everyone who does this will agree on the version to use (this is important for distribution makers). Read the comment in configure.ac (before LIBGPGME_LT_AGE) if you want to do this. Please don't do this blindly: As stated above, we think it is unlikely this measure is needed. Still, it is there if necessary. If in doubt, contact us and we will give our advise for your specific situation. * New key listing mode GPGME_KEYLIST_MODE_VALIDATE for validation of the listed keys. * New interface gpgme_cancel() that can be used to cancel asynchronous operations. * Interface changes relative to the 0.4.4 release: ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ gpgme_data_seek_cb_t CHANGED: off_t is now a largefile type. gpgme_data_seek CHANGED: off_t is now a largefile type. gpgme_data_new_from_filepart CHANGED: off_t is now a largefile type. GPGME_KEYLIST_MODE_VALIDATE NEW gpgme_cancel NEW ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Noteworthy changes in version 0.4.4 (2004-01-12) ------------------------------------------------ * The member "class" in gpgme_key_sig_t and gpgme_new_signature_t has been renamed to "sig_class", to avoid clash with C++ compilers. In the C API, the old name "class" has been preserved for backwards compatibility, but is deprecated. * Interface changes relative to the 0.4.3 release: ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ gpgme_key_sig_t CHANGED: class deprecated, use new sig_class. gpgme_new_signature_t CHANGED: class deprecated, use new sig_class. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Noteworthy changes in version 0.4.3 (2003-10-06) ------------------------------------------------ * libgpgme should not be used for threaded programs anymore. This never worked reliably in all cases, because you had to be careful about the linking order and libtool wouldn't do that for you automatically. Instead, now you have to link against libgpgme-pthread for applications using pthread and libgpgme-pth for applications using GNU Pth. The old code for automagically detecting the thread library is still part of libgpgme, but it is DEPRECATED. * There are new automake macros AM_PATH_GPGME_PTH and AM_PATH_GPGME_PTHREAD, which support checking for thread-enabled versions of GPGME. They define GPGME_PTH_CFLAGS, GPGME_PTH_LIBS, GPGME_PTHREAD_CFLAGS and GPGME_PTHREAD_LIBS respectively. These variables of course also include the configuration for the thread package itself. Alternatively, use libtool. * gpgme_strerror_r as a thread safe variant of gpgme_strerror was added. * gpgme-config doesn't support setting the prefix or exec prefix anymore. I don't think it ever worked correctly, and it seems to be pointless. * gpgme_get_key fails with GPG_ERR_AMBIGUOUS_NAME if the key ID provided was not unique, instead returning the first matching key. * gpgme_key_t and gpgme_subkey_t have a new field, can_authenticate, that indicates if the key can be used for authentication. * gpgme_signature_t's status field is now correctly set to an error with error code GPG_ERR_NO_PUBKEY if public key is not found. * gpgme_new_signature_t's class field is now an unsigned int, rather than an unsigned long (the old class field is preserved for backwards compatibility). * A new function gpgme_set_locale() is provided to allow configuring the locale for the crypto backend. This is necessary for text terminals so that programs like the pinentry can be started with the right locale settings for the terminal the application is running on, in case the terminal has different settings than the system default (for example, if it is a remote terminal). You are highly recommended to call the following functions directly after gpgme_check_version: #include setlocale (LC_ALL, ""); gpgme_set_locale (NULL, LC_CTYPE, setlocale (LC_CTYPE, NULL)); gpgme_set_locale (NULL, LC_MESSAGES, setlocale (LC_MESSAGES, NULL)); GPGME can not do this for you, as setlocale is not thread safe, and there is no alternative. * The signal action for SIGPIPE is now set to SIG_IGN by gpgme_check_version, instead the first time a crypto engine is started (which is not well defined). * In the output of gpgme_hash_algo_name, change RMD160 to RIPEMD160, TIGER to TIGER192, CRC32-RFC1510 to CRC32RFC1510, and CRC24-RFC2440 to CRC24RFC2440. For now, these strings can be used as the MIC parameter for PGP/MIME (if appropriately modified). * Interface changes relative to the 0.4.2 release: ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ gpgme_strerror_t NEW gpgme_get_key CHANGED: Fails correctly if key ID not unique. gpgme_key_t EXTENDED: New field can_authenticate. gpgme_subkey_t EXTENDED: New field can_authenticate. gpgme_new_signature_t CHANGED: New type for class field. gpgme_set_locale NEW gpgme_hash_algo_name CHANGED: Slight adjustment of algo names. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Noteworthy changes in version 0.4.2 (2003-07-30) ------------------------------------------------ * Allow gpg-error to be in non-standard place when linking the test suite. * Configure will fail now if gpg-error can not be found. * Fixed initialized memory backed data objects for writing, which caused the test program to crash (but only on Mac OS, surprisingly). * Eliminate use of C99 constructs. * Small improvements to the manual. Noteworthy changes in version 0.4.1 (2003-06-06) ------------------------------------------------ This is the release that 0.4.0 should have been. There are many interface changes, please see below for the details. The changes are sometimes the result of new functionality, but more often express a paradigm shift. Others are an overdue cleanup to get GPGME in line with the GNU coding standards and to make the interface more self-consistent. Here is an overview on the changes: All types have been renamed to conform to the GNU coding standards, most of the time by keeping the whole name in lowercase and inserting underscores between words. All operations consistently only accept input parameters in their invocation function, and return only an error code directly. Further information about the result of the operation has to be retrieved afterwards by calling one of the result functions. This unifies the synchronous and the asynchronous interface. The error values have been completely replaced by a more sophisticated model that allows GPGME to transparently and accurately - report all errors from the other GnuPG components, irregardless of + report all errors from the other GnuPG components, regardless of process boundaries. This is achieved by using the library libgpg-errors, which is shared by all GnuPG components. This library is now required for GPGME. The results of all operations are now provided by pointers to C structs rather than by XML structs or in other ways. Objects which used to be opaque (for example a key) are now pointers to accessible structs, so no accessor functions are necessary. Backward compatibility is provided where it was possible without too much effort and did not collide with the overall sanitization effort. However, this is only for ease of transition. NO DEPRECATED FUNCTION OR DATA TYPE IS CONSIDERED A PART OF THE API OR ABI AND WILL BE DROPPED IN THE FUTURE WITHOUT CHANGING THE SONAME OF THE LIBRARY. Recommendations how to replace deprecated or removed functionality can be found within the description of each change. What follows are all changes to the interface and behaviour of GPGME in detail. * If gpgme.h is included in sources compiled by GCC 3.1 or later, deprecated attributes will warn about use of obsolete functions and type definitions. You can suppress these warnings by passing -Wno-deprecated-declarations to the gcc command. * The following types have been renamed. The old types are still available as aliases, but they are deprecated now: Old name: New name: GpgmeCtx gpgme_ctx_t GpgmeData gpgme_data_t GpgmeError gpgme_error_t GpgmeDataEncoding gpgme_data_encoding_t GpgmeSigStat gpgme_sig_stat_t GpgmeSigMode gpgme_sig_mode_t GpgmeAttr gpgme_attr_t GpgmeValidity gpgme_validity_t GpgmeProtocol gpgme_protocol_t GpgmeKey gpgme_key_t GpgmePassphraseCb gpgme_passphrase_cb_t GpgmeProgressCb gpgme_progress_cb_t GpgmeIOCb gpgme_io_cb_t GpgmeRegisterIOCb gpgme_register_io_cb_t GpgmeRemoveIOCb gpgme_remove_io_cb_t GpgmeEventIO gpgme_event_io_t GpgmeEventIOCb gpgme_event_io_cb_t GpgmeIOCbs gpgme_io_cbs GpgmeDataReadCb gpgme_data_read_cb_t GpgmeDataWriteCb gpgme_data_write_cb_t GpgmeDataSeekCb gpgme_data_seek_cb_t GpgmeDataReleaseCb gpgme_data_release_cb_t GpgmeDataCbs gpgme_data_cbs_t GpgmeTrustItem gpgme_trust_item_t GpgmeStatusCode gpgme_status_code_t * gpgme_error_t is now identical to gpg_error_t, the error type provided by libgpg-error. More about using libgpg-error with GPGME can be found in the manual. All error symbols have been removed! * All functions and types in libgpg-error have been wrapped in GPGME. The new types are gpgme_err_code_t and gpgme_err_source_t. The new functions are gpgme_err_code, gpgme_err_source, gpgme_error, gpgme_err_make, gpgme_error_from_errno, gpgme_err_make_from_errno, gpgme_err_code_from_errno, gpgme_err_code_to_errno, gpgme_strsource. * GPGME_ATTR_IS_SECRET is not anymore representable as a string. * GnuPG 1.2.2 is required. The progress callback is now also invoked for encrypt, sign, encrypt-sign, decrypt, verify, and decrypt-verify operations. For verify operations on detached signatures, the progress callback is invoked for both the detached signature and the plaintext message, though. * gpgme_passphrase_cb_t has been changed to not provide a complete description, but the UID hint, passphrase info and a flag indicating if this is a repeated attempt individually, so the user can compose his own description from this information. The passphrase is not returned as a C string, but must be written to a file descriptor directly. This allows for secure passphrase entries. The return type has been changed to gpgme_error_t value. This allowed to remove the gpgme_cancel function; just return the error code GPG_ERR_CANCELED in the passphrase callback directly. * gpgme_edit_cb_t has been changed to take a file descriptor argument. The user is expected to write the response to the file descriptor, followed by a newline. * The recipients interface has been removed. Instead, you use NULL-terminated lists of keys for specifying the recipients of an encryption operation. Use the new encryption flag GPGME_ENCRYPT_ALWAYS_TRUST if you want to override the validity of the keys (but note that in general this is not a good idea). This change has been made to the prototypes of gpgme_op_encrypt, gpgme_op_encrypt_start, gpgme_op_encrypt_sign and gpgme_op_encrypt_sign_start. The export interface has been changed to use pattern strings like the keylist interface. Thus, new functions gpgme_op_export_ext and gpgme_op_export_ext_start have been added as well. Now the prototypes of gpgme_op_export_start and gpgme_op_export finally make sense. * gpgme_op_verify and gpgme_op_decrypt_verify don't return a status summary anymore. Use gpgme_get_sig_status to retrieve the individual stati. * gpgme_io_cb_t changed from a void function to a function returning a gpgme_error_t value. However, it will always return 0, so you can safely ignore the return value. * A new I/O callback event GPGME_EVENT_START has been added. The new requirement is that you must wait until this event until you are allowed to call the I/O callback handlers previously registered for this context operation. Calling I/O callback functions for this context operation before the start event happened is unsafe because it can lead to race conditions in a multi-threaded environment. * The idle function feature has been removed. It was not precisely defined in a multi-threaded environment and is obsoleted by the user I/O callback functions. If you still need a simple way to call something while waiting on one or multiple asynchronous operations to complete, don't set the HANG flag in gpgme_wait (note that this will return to your program more often than the idle function did). * gpgme_wait can return NULL even if hang is true, if an error occurs. In that case *status contains the error code. * gpgme_get_engine_info was radically changed. Instead an XML string, an info structure of the new type gpgme_engine_info_t is returned. This makes it easier and more robust to evaluate the information in an application. * The new function gpgme_get_protocol_name can be used to convert a gpgme_protocol_t value into a string. * The status of a context operation is not checked anymore. Starting a new operation will silently cancel the previous one. Calling a function that requires you to have started an operation before without doing so is undefined. * The FPR argument to gpgme_op_genkey was removed. Instead, use the gpgme_op_genkey_result function to retrieve a gpgme_genkey_result_t pointer to a structure which contains the fingerprint. This also works with gpgme_op_genkey_start. The structure also provides other information about the generated keys. So, instead: char *fpr; err = gpgme_op_genkey (ctx, NULL, NULL, &fpr); if (!err && fpr) printf ("%s\n", fpr); you should now do: gpgme_genkey_result_t result; err = gpgme_op_genkey (ctx, NULL, NULL); if (!err) { result = gpgme_op_genkey_result (ctx); if (result->fpr) printf ("%s\n", result->fpr); } * The new gpgme_op_import_result function provides detailed information about the result of an import operation in gpgme_import_result_t and gpgme_import_status_t objects. Thus, the gpgme_op_import_ext variant is deprecated. * The new gpgme_op_sign_result function provides detailed information about the result of a signing operation in gpgme_sign_result_t, gpgme_invalid_key_t and gpgme_new_signature_t objects. * The new gpgme_op_encrypt_result function provides detailed information about the result of an encryption operation in a GpgmeEncryptResult object. * The new gpgme_op_decrypt_result function provides detailed information about the result of a decryption operation in a GpgmeDecryptResult object. * The new gpgme_op_verify_result function provides detailed information about the result of an verify operation in a GpgmeVerifyResult object. Because of this, the GPGME_SIG_STAT_* values, gpgme_get_sig_status, gpgme_get_sig_ulong_attr, gpgme_get_sig_string_attr and gpgme_get_sig_key are now deprecated, and gpgme_get_notation is removed. * GpgmeTrustItem objects have now directly accessible data, so the gpgme_trust_item_get_string_attr and gpgme_trust_item_get_ulong_attr accessor functions are deprecated. Also, reference counting is available through gpgme_trust_item_ref and gpgme_trust_item_unref (the gpgme_trust_item_release alias for the latter is deprecated). * Keys are not cached internally anymore, so the force_update argument to gpgme_get_key has been removed. * GpgmeKey objects have now directly accessible data so the gpgme_key_get_string_attr, gpgme_key_get_ulong_attr, gpgme_key_sig_get_string_attr and gpgme_key_sig_get_ulong_attr functions are deprecated. Also, gpgme_key_release is now deprecated. The gpgme_key_get_as_xml function has been dropped. * Because all interfaces using attributes are deprecated, the GpgmeAttr data type is also deprecated. * The new gpgme_op_keylist_result function provides detailed information about the result of a key listing operation in a GpgmeKeyListResult object. * Now that each function comes with its own result retrieval interface, the generic gpgme_get_op_info interface is not useful anymore and dropped. * The type and mode of data objects is not available anymore. * Interface changes relative to the 0.4.0 release: ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ GpgmeCtx DEPRECATED: Use gpgme_ctx_t. GpgmeData DEPRECATED: Use gpgme_data_t. GpgmeError DEPRECATED: Use gpgme_error_t. GpgmeDataEncoding DEPRECATED: Use gpgme_data_encoding_t. GpgmeSigStat DEPRECATED: Use gpgme_sig_stat_t. GpgmeSigMode DEPRECATED: Use gpgme_sig_mode_t. GpgmeAttr DEPRECATED: Use gpgme_attr_t. GpgmeValidity DEPRECATED: Use gpgme_validity_t. GpgmeProtocol DEPRECATED: Use gpgme_protocol_t. GpgmeKey DEPRECATED: Use gpgme_key_t. GpgmePassphraseCb DEPRECATED: Use gpgme_passphrase_cb_t. GpgmeProgressCb DEPRECATED: Use gpgme_progress_cb_t. GpgmeIOCb DEPRECATED: Use gpgme_io_cb_t. GpgmeRegisterIOCb DEPRECATED: Use gpgme_register_io_cb_t. GpgmeRemoveIOCb DEPRECATED: Use gpgme_remove_io_cb_t. GpgmeEventIO DEPRECATED: Use gpgme_event_io_t. GpgmeEventIOCb DEPRECATED: Use gpgme_event_io_cb_t. GpgmeIOCbs DEPRECATED: Use gpgme_io_cbs. GpgmeDataReadCb DEPRECATED: Use gpgme_data_read_cb_t. GpgmeDataWriteCb DEPRECATED: Use gpgme_data_write_cb_t. GpgmeDataSeekCb DEPRECATED: Use gpgme_data_seek_cb_t. GpgmeDataReleaseCb DEPRECATED: Use gpgme_data_release_cb_t. GpgmeDataCbs DEPRECATED: Use gpgme_data_cbs_t. GpgmeTrustItem DEPRECATED: Use gpgme_trust_item_t. GpgmeStatusCode DEPRECATED: Use gpgme_status_code_t. gpgme_ctx_t NEW gpgme_data_t NEW gpgme_recipients_t NEW gpgme_error_t NEW gpgme_data_encoding_t NEW gpgme_sig_stat_t NEW gpgme_sig_mode_t NEW gpgme_attr_t NEW gpgme_validity_t NEW gpgme_protocol_t NEW gpgme_key_t NEW gpgme_passphrase_cb_t NEW gpgme_progress_cb_t NEW gpgme_io_cb_t NEW gpgme_register_io_cb_t NEW gpgme_remove_io_cb_t NEW gpgme_event_io_t NEW gpgme_event_io_cb_t NEW gpgme_io_cbs NEW gpgme_data_read_cb_t NEW gpgme_data_write_cb_t NEW gpgme_data_seek_cb_t NEW gpgme_data_release_cb_t NEW gpgme_data_cbs_t NEW gpgme_trust_item_t NEW gpgme_status_code_t NEW GPGME_{some error code} REMOVED! Use GPG_ERR_* from libgpg-error. gpgme_err_code_t NEW gpgme_err_source_t NEW gpgme_err_code NEW gpgme_err_source NEW gpgme_error NEW gpgme_err_make NEW gpgme_error_from_errno NEW gpgme_err_make_from_errno NEW gpgme_err_code_from_errno NEW gpgme_err_code_to_errno NEW gpgme_strsource NEW gpgme_io_cb_t CHANGED: Return type from void to GpgmeError. gpgme_event_io_t CHANGED: New event type (all numbers changed). gpgme_passphrase_cb_t CHANGED: Desc decomposed, write directly to FD. gpgme_edit_cb_t CHANGED: Write directly to FD. gpgme_key_get_string_attr CHANGED: Don't handle GPGME_ATTR_IS_SECRET. gpgme_op_verify CHANGED: Drop R_STAT argument. gpgme_op_decrypt_verify CHANGED: Drop R_STAT argument. gpgme_wait CHANGED: Can return NULL even if hang is true. GpgmeIdleFunc REMOVED gpgme_register_idle REMOVED GpgmeRecipients REMOVED gpgme_recipients_new REMOVED gpgme_recipients_release REMOVED gpgme_recipients_add_name REMOVED gpgme_recipients_add_name_with_validity REMOVED gpgme_recipients_count REMOVED gpgme_recipients_enum_open REMOVED gpgme_recipients_enum_read REMOVED gpgme_recipients_enum_close REMOVED gpgme_encrypt_flags_t NEW GPGME_ENCRYPT_ALWAYS_TRUST NEW gpgme_op_encrypt CHANGED: Recipients passed as gpgme_key_t[]. gpgme_op_encrypt_start CHANGED: Recipients passed as gpgme_key_t[]. gpgme_op_encrypt_sign CHANGED: Recipients passed as gpgme_key_t[]. gpgme_op_encrypt_sign_start CHANGED: Recipients passed as gpgme_key_t[]. gpgme_op_export_start CHANGED: User IDs passed as patterns. gpgme_op_export CHANGED: User IDs passed as patterns. gpgme_op_export_ext_start NEW gpgme_op_export_ext NEW gpgme_keylist_mode_t NEW gpgme_sigsum_t NEW gpgme_engine_info_t NEW gpgme_get_engine_info CHANGED: Return info structure instead XML. gpgme_get_protocol_name NEW gpgme_cancel REMOVED: Return error in callback directly. gpgme_op_genkey CHANGED: FPR argument dropped. gpgme_op_genkey_result NEW gpgme_genkey_result_t NEW gpgme_op_import_ext DEPRECATED: Use gpgme_op_import_result. gpgme_op_import_result NEW gpgme_import_status_t NEW gpgme_import_result_t NEW gpgme_pubkey_algo_t NEW gpgme_hash_algo_t NEW gpgme_invalid_key_t NEW gpgme_new_signature_t NEW gpgme_sign_result_t NEW gpgme_op_sign_result NEW gpgme_pubkey_algo_name NEW gpgme_hash_algo_name NEW gpgme_encrypt_result_t NEW gpgme_op_encrypt_result NEW gpgme_decrypt_result_t NEW gpgme_op_decrypt_result NEW gpgme_verify_result_t NEW gpgme_op_verify_result NEW gpgme_get_notation REMOVED: Access verify result directly instead. gpgme_get_sig_key DEPRECATED: Use gpgme_get_key with fingerprint. gpgme_get_sig_ulong_attr DEPRECATED: Use verify result directly. gpgme_get_sig_string_attr DEPRECATED: Use verify result directly. GPGME_SIG_STAT_* DEPRECATED: Use error value in sig status. gpgme_get_sig_status DEPRECATED: Use verify result directly. gpgme_trust_item_t CHANGED: Now has user accessible data members. gpgme_trust_item_ref NEW gpgme_trust_item_unref NEW gpgme_trust_item_release DEPRECATED: Use gpgme_trust_item_unref. gpgme_trust_item_get_string_attr DEPRECATED gpgme_trust_item_get_ulong_attr DEPRECATED gpgme_get_key CHANGED: Removed force_update argument. gpgme_subkey_t NEW gpgme_key_sig_t NEW gpgme_user_id_t NEW gpgme_key_t CHANGED: Now has user accessible data members. gpgme_key_get_string_attr DEPRECATED gpgme_key_get_ulong_attr DEPRECATED gpgme_key_sig_get_string_attr DEPRECATED gpgme_key_sig_get_ulong_attr DEPRECATED gpgme_key_get_as_xml REMOVED gpgme_key_list_result_t NEW gpgme_op_keylist_result NEW gpgme_get_op_info REMOVED ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Noteworthy changes in version 0.4.0 (2002-12-23) ------------------------------------------------ * Key generation returns the fingerprint of the generated key. * New convenience function gpgme_get_key. * Supports signatures of user IDs in keys via the new GPGME_KEYLIST_MODE_SIGS keylist mode and the gpgme_key_sig_get_string_attr and gpgme_key_sig_get_ulong_attr interfaces. The XML info about a key also includes the signatures if available. * New data object interface, which is more flexible and transparent. * Interface changes relative to the 0.3.9 release: ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ GpgmeDataReadCb NEW GpgmeDataWriteCb NEW GpgmeDataSeekCb NEW GpgmeDataReleaseCb NEW GpgmeDataCbs NEW gpgme_data_read CHANGED: Match read() closely. gpgme_data_write CHANGED: Match write() closely. gpgme_data_seek NEW gpgme_data_new_from_fd NEW gpgme_data_new_from_stream NEW gpgme_data_new_from_cbs NEW gpgme_data_rewind DEPRECATED: Replaced by gpgme_data_seek(). gpgme_data_new_from_read_cb DEPRECATED: Replaced by gpgme_data_from_cbs(). gpgme_data_get_type REMOVED: No replacement. gpgme_op_verify CHANGED: Take different data objects for signed text and plain text. gpgme_op_verify_start CHANGED: See gpgme_op_verify. gpgme_check_engine REMOVED: Deprecated since 0.3.0. gpgme_op_genkey CHANGED: New parameter FPR. GPGME_KEYLIST_MODE_SIGS NEW gpgme_key_sig_get_string_attr NEW gpgme_key_sig_get_ulong_attr NEW gpgme_get_key NEW GPGME_ATTR_SIG_CLASS NEW ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Noteworthy changes in version 0.3.16 (2003-11-19) ------------------------------------------------- * Compatibility fixes for GnuPG 1.9.x Noteworthy changes in version 0.3.15 (2003-02-18) ------------------------------------------------- * The progress status is sent via the progress callbacks in gpgme_op_edit. * Bug fix for signing operations with explicit signer settings for the CMS protocol. Noteworthy changes in version 0.3.14 (2002-12-04) ------------------------------------------------- * GPGME-Plug is now in its own package "cryptplug". * Workaround for a setlocale problem. Fixed a segv related to not correctly as closed marked file descriptors. Noteworthy changes in version 0.3.13 (2002-11-20) ------------------------------------------------- * Release due to changes in gpgmeplug. Noteworthy changes in version 0.3.12 (2002-10-15) ------------------------------------------------- * Fixed some bux with key listings. * The development has been branched to clean up some API issues. This 0.3 series will be kept for compatibility reasons; so do don't expect new features. Noteworthy changes in version 0.3.11 (2002-09-20) ------------------------------------------------- * Bug fixes. Noteworthy changes in version 0.3.10 (2002-09-02) ------------------------------------------------- * Setting the signing keys for the CMS protocol does now work. * The signers setting is honoured by gpgme_op_edit. Noteworthy changes in version 0.3.9 (2002-08-21) ------------------------------------------------ * A spec file for creating RPMs has been added. * An experimental interface to GnuPG's --edit-key functionality is introduced, see gpgme_op_edit. * The new gpgme_import_ext function provides a convenient access to the number of processed keys. * Interface changes relative to the 0.3.8 release: ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ GpgmeStatusCode NEW GpgmeEditCb NEW gpgme_op_edit_start NEW gpgme_op_edit NEW gpgme_op_import_ext NEW ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Noteworthy changes in version 0.3.8 (2002-06-25) ------------------------------------------------ * It is possible to use an outside event loop for the I/O to the crypto engine by setting the I/O callbacks with gpgme_set_io_cbs. * Interface changes relative to the 0.3.6 release: ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ GpgmeIOCb NEW GpgmeRegisterIOCb NEW GpgmeRemoveIOCb NEW GpgmeEventIO NEW GpgmeEventIOCb NEW struct GpgmeIOCbs NEW gpgme_set_io_cbs NEW gpgme_get_io_cbs NEW GPGME_ATTR_ERRTOK NEW ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Noteworthy changes in version 0.3.7 (2002-06-04) ------------------------------------------------ * GPGME_ATTR_OTRUST is implemented now. * A first step toward thread safeness has been achieved, see the documentation for details. Supported thread libraries are pthread and Pth. Noteworthy changes in version 0.3.6 (2002-05-03) ------------------------------------------------ * All error output of the gpgsm backend is send to the bit bucket. * The signature verification functions are extended. Instead of always returning GPGME_SIG_STATUS_GOOD, the functions new codes for expired signatures. 2 new functions may be used to retrieve more detailed information like the signature expiration time and a validity information of the key without an extra key looking. * The current passphrase callback and progress meter callback can be retrieved with the new functions gpgme_get_passphrase_cb and gpgme_get_progress_cb respectively. * Interface changes relative to the 0.3.5 release: ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ gpgme_get_passphrase_cb NEW gpgme_get_progress_cb NEW GpgmeDataEncoding NEW gpgme_data_set_encoding NEW gpgme_data_get_encoding NEW GPGME_SIG_STAT_GOOD_EXP NEW GPGME_SIG_STAT_GOOD_EXPKEY NEW gpgme_op_verify CHANGED: Returns more status codes. GPGME_ATTR_SIG_STATUS NEW gpgme_get_sig_string_attr NEW gpgme_get_sig_ulong_attr NEW gpgme_get_protocol NEW ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Noteworthy changes in version 0.3.5 (2002-04-01) ------------------------------------------------ * gpgme_op_encrypt can be called with RECIPIENTS being 0. In this case, symmetric encryption is performed. Note that this requires a passphrase from the user. * More information is returned for X.509 certificates. * Interface changes relative to the 0.3.4 release: ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ gpgme_op_encrypt EXTENDED: Symmetric encryption possible ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Noteworthy changes in version 0.3.4 (2002-03-04) ------------------------------------------------ * gpgme_op_encrypt does now fail with GPGME_Invalid_Recipients if some recipients have been invalid, whereas earlier versions succeeded in this case. The plaintext is still encrypted for all valid recipients, so the application might take this error as a hint that the ciphertext is not usable for all requested recipients. Information about invalid recipients is available with gpgme_get_op_info. * gpgme_op_verify now allows to pass an uninitialized data object as its plaintext argument to check for normal and cleartext signatures. The plaintext is then returned in the data object. * New interfaces gpgme_set_include_certs and gpgme_get_include_certs to set and get the number of certifications to include in S/MIME signed messages. * New interfaces gpgme_op_encrypt_sign and gpgme_op_encrypt_sign_start to encrypt and sign a message in a combined operation. * New interface gpgme_op_keylist_ext_start to search for multiple patterns. * gpgme_key_get_ulong_attr supports the GPGME_ATTR_EXPIRE attribute. * Interface changes relative to the 0.3.3 release: ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ gpgme_op_encrypt CHANGED: Can fail with GPGME_Invalid_Recipients gpgme_op_verify EXTENDED: Accepts uninitialized text argument gpgme_key_get_ulong_attr EXTENDED: Supports GPGME_ATTR_EXPIRE gpgme_set_include_certs NEW gpgme_get_include_certs NEW gpgme_op_encrypt_sign NEW gpgme_op_encrypt_sign_start NEW gpgme_op_keylist_ext_start NEW ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Noteworthy changes in version 0.3.3 (2002-02-12) ------------------------------------------------ * Fix the Makefile in jnlib. * Fix the test suite (hopefully). It should clean up all its state with `make check' now. Noteworthy changes in version 0.3.2 (2002-02-10) ------------------------------------------------ * Remove erroneous dependency on libgcrypt in jnlib. Noteworthy changes in version 0.3.1 (2002-02-09) ------------------------------------------------ * There is a Texinfo manual documenting the API. * The gpgme_set_keylist_mode function returns an error, and changed its meaning. It is no longer usable to select between normal and fast mode (newer versions of GnuPG will always be fast), but selects between local keyring, remote keyserver, or both. For this, two new macros are defined, GPGME_KEYLIST_MODE_LOCAL and GPGME_KEYLIST_MODE_EXTERN. To make it possible to modify the - current setting, a fucntion gpgme_get_keylist_mode was added to + current setting, a function gpgme_get_keylist_mode was added to retrieve the current mode. * gpgme_wait accepts a new argument STATUS to return the error status of the operation on the context. Its definition is closer to waitpid() now than before. * The LENGTH argument to gpgme_data_new_from_filepart changed its type from off_t to the unsigned size_t. * The R_HD argument to the GpgmePassphraseCb type changed its type from void* to void**. * New interface gpgme_op_trustlist_end() to match gpgme_op_keylist_end(). * The CryptPlug modules have been renamed to gpgme-openpgp and gpgme-smime, and they are installed in pkglibdir by `make install'. * An idle function can be registered with gpgme_register_idle(). * The GpgSM backend supports key generation with gpgme_op_genkey(). * Interface changes relative to the 0.3.0 release: ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ gpgme_data_new_from_filepart CHANGED: Type of LENGTH is size_t. GpgmePassphraseCb CHANGED: Type of R_HD is void **. gpgme_wait CHANGED: New argument STATUS. gpgme_set_keylist_mode CHANGED: Type of return value is GpgmeError. The function has a new meaning! gpgme_get_keylist_mode NEW GPGME_KEYLIST_MODE_LOCAL NEW GPGME_KEYLIST_MODE_EXTERN NEW gpgme_op_trustlist_next NEW GpgmeIdleFunc NEW gpgme_register_idle NEW ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Noteworthy changes in version 0.3.0 (2001-12-19) ------------------------------------------------ * New interface gpgme_set_protocol() to set the protocol and thus the crypto engine to be used by the context. Currently, the OpenPGP and the CMS protocols are supported. They are specified by the new preprocessor symbols GPGME_PROTOCOL_OpenPGP and GPGME_PROTOCOL_CMS. A new context uses the OpenPGP engine by default. * gpgme_get_engine_info() returns information for all crypto engines compiled into the library. The XML format has changed. To reliably get the version of a crypto engine, the tag after the appropriate tag has to be looked for. * New interface gpgme_engine_check_version(), obsoleting gpgme_check_engine(). Check the version of all engines you are supporting in your software. * GpgmeKey lists the user ids in the order as they are returned by GnuPG, first the primary key with index 0, then the sub-user ids. * New operation gpgme_op_decrypt_verify() to decrypt and verify signatures simultaneously. * The new interface gpgme_op_keylist_end() terminates a pending keylist operation. A keylist operation is also terminated when gpgme_op_keylist_next() returns GPGME_EOF. * GPGME can be compiled without GnuPG being installed (`--with-gpg=PATH'), cross-compiled, or even compiled without support for GnuPG (`--without-gpg'). * GPGME can be compiled with support for GpgSM (GnuPG for S/MIME, `--with-gpgsm=PATH'). It is enabled by default if the `gpgsm' is found in the path, but it can also be compiled without support for GpgSM (`--without-gpgsm'). * CryptPlug modules for GPGME are included and can be enabled at configure time (`--enable-gpgmeplug'). There is one module which uses the GnuPG engine (`gpgmeplug') and one module which uses the GpgSM engine (`gpgsmplug'). * Interface changes relative to the latest 0.2.x release: ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ gpgme_key_get_as_xml CHANGED: Sub-user ids reversed in order. gpgme_key_get_string_attr CHANGED: User ids reversed in order. gpgme_key_get_ulong_attr CHANGED: User ids reversed in order. gpgme_get_engine_info CHANGED: New format, extended content. gpgme_engine_check_version NEW gpgme_decrypt_verify_start NEW gpgme_decrypt_verify NEW gpgme_op_keylist_next NEW gpgme_set_protocol NEW ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Noteworthy changes in version 0.2.3 (2001-09-17) ------------------------------------------------ * New function gpgme_get_op_info which can be used to get the micalg parameter needed for MOSS. * New functions gpgme_get_armor and gpgme_get_textmode. * The usual bug fixes and some minor functionality improvements. * Added a simple encryption component for MS-Windows; however the build procedure might have some problems. Noteworthy changes in version 0.2.2 (2001-06-12) ------------------------------------------------ * Implemented a key cache. * Fixed a race condition under W32 and some other bug fixes. Noteworthy changes in version 0.2.1 (2001-04-02) ------------------------------------------------ * Changed debug output and GPGME_DEBUG variable (gpgme/debug.c) * Handle GnuPG's new key capabilities output and support revocation et al. attributes * Made the W32 support more robust. Copyright 2001, 2002, 2003, 2004, 2005, 2007, 2008, 2009, 2010 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 modifications, as long as this notice is preserved. This file is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY, to the extent permitted by law; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. diff --git a/TODO b/TODO index a915ed7c..121ced21 100644 --- a/TODO +++ b/TODO @@ -1,706 +1,706 @@ #+TITLE: TODO List Hey Emacs, this is -*- org -*- mode! * IMPORTANT! :PROPERTIES: :CUSTOM_ID: dev-gnupg-org :END: There was a nine year gap (2009 to 2018) between edits of this file, so it is likely that much of the old information in it is wrong or no longer applicable. Bugs, feature requests and other development related work will be tracked through the [[https://dev.gnupg.org/][dev.gnupg.org]] site. * Documentation :PROPERTIES: :CUSTOM_ID: documentation :END: ** Document all the new stuff. :PROPERTIES: :CUSTOM_ID: more-docs-is-better :END: *** TODO Fix this TODO list. :PROPERTIES: :CUSTOM_ID: fix-todo :END: Clean up the current TODO list. Include properties as relevant (so if someone does make a PDF or HTML version the TOC will work). - Also check ans see if some of these ancient things can be removed + Also check to see if some of these ancient things can be removed (e.g. do we really need to fix things that were broken in GPG 1.3.x? I'm thinking not so much). **** DONE fix TODO items CLOSED: [2018-03-04 Sun 08:55] :PROPERTIES: :CUSTOM_ID: fix-todo-items :END: Adjust todo items so each can now be referenced by custom-id and checked off as necessary. ** TODO Document validity and trust issues. :PROPERTIES: :CUSTOM_ID: valid-trust-issues :END: ** In gpgme.texi: Register callbacks under the right letter in the index. :PROPERTIES: :CUSTOM_ID: gpgme-texi :END: * Fix the remaining UI Server problems: :PROPERTIES: :CUSTOM_ID: ui-server-fix :END: ** VERIFY --silent support. :PROPERTIES: :CUSTOM_ID: verify-silent :END: ** ENCRYPT/DECRYPT/VERIFY/SIGN reset the engine, shouldn't be done with UISERVER? :PROPERTIES: :CUSTOM_ID: reset-engine-not-ui :END: * IMPORTANT :PROPERTIES: :CUSTOM_ID: important-stuff-really :END: ** When using descriptor passing, we need to set the fd to blocking before :PROPERTIES: :CUSTOM_ID: set-fd-blocking :END: - issueing simple commands, because we are mixing synchronous + issuing simple commands, because we are mixing synchronous commands into potentially asynchronous operations. ** Might want to implement nonblock for w32 native backend! :PROPERTIES: :CUSTOM_ID: nonblock-win32 :END: Right now we block reading the next line with assuan. * Before release: :PROPERTIES: :CUSTOM_ID: pre-release :END: ** CANCELLED Some gpg tests fail with gpg 1.3.4-cvs (gpg/t-keylist-sig) CLOSED: [2018-03-09 Fri 08:16] :PROPERTIES: :CUSTOM_ID: gpg-1-3-4-really :END: - State "CANCELLED" from "TODO" [2018-03-09 Fri 08:16] \\ WON'T FIX — too old or no longer applies. The test is currently disabled there and in gpg/t-import. ** When gpg supports it, write binary subpackets directly, :PROPERTIES: :CUSTOM_ID: binary-subpackets :END: and parse SUBPACKET status lines. * ABI's to break: :PROPERTIES: :CUSTOM_ID: abi-breakage-apparently-on-purpose :END: ** Old opassuan interface. :PROPERTIES: :CUSTOM_ID: old-opassuan :END: ** Implementation: Remove support for old style error codes in :PROPERTIES: :CUSTOM_ID: remove-old-error-codes :END: conversion.c::_gpgme_map_gnupg_error. ** gpgme_edit_cb_t: Add "processed" return argument :PROPERTIES: :CUSTOM_ID: add-processed-return :END: (see edit.c::command_handler). ** I/O and User Data could be made extensible. But this can be done :PROPERTIES: :CUSTOM_ID: add-io-user-data :END: without breaking the ABI hopefully. ** All enums should be replaced by ints and simple macros for :PROPERTIES: :CUSTOM_ID: enums-should-be-ints :END: maximum compatibility. ** Compatibility interfaces that can be removed in future versions: :PROPERTIES: :CUSTOM_ID: compat-interfaces-to-go :END: *** gpgme_data_new_from_filepart :PROPERTIES: :CUSTOM_ID: gpgme-data-new-from-filepart :END: *** gpgme_data_new_from_file :PROPERTIES: :CUSTOM_ID: gpgme-data-new-from-file :END: *** gpgme_data_new_with_read_cb :PROPERTIES: :CUSTOM_ID: gpgme-data-new-with-read-cb :END: *** gpgme_data_rewind :PROPERTIES: :CUSTOM_ID: gpgme-data-rewind :END: *** gpgme_op_import_ext :PROPERTIES: :CUSTOM_ID: gpgme-op-import-ext :END: *** gpgme_get_sig_key :PROPERTIES: :CUSTOM_ID: gpgme-get-sig-key :END: *** gpgme_get_sig_ulong_attr :PROPERTIES: :CUSTOM_ID: gpgme-get-sig-ulong-attr :END: *** gpgme_get_sig_string_attr :PROPERTIES: :CUSTOM_ID: gpgme-get-sig-string-attr :END: *** GPGME_SIG_STAT_* :PROPERTIES: :CUSTOM_ID: gpgme-sig-stat :END: *** gpgme_get_sig_status :PROPERTIES: :CUSTOM_ID: gpgme-get-sig-status :END: *** gpgme_trust_item_release :PROPERTIES: :CUSTOM_ID: gpgme-trust-item-release :END: *** gpgme_trust_item_get_string_attr :PROPERTIES: :CUSTOM_ID: gpgme-trust-item-get-string-attr :END: *** gpgme_trust_item_get_ulong_attr :PROPERTIES: :CUSTOM_ID: gpgme-trust-item-get-ulong-attr :END: *** gpgme_attr_t :PROPERTIES: :CUSTOM_ID: gpgme-attr-t :END: *** All Gpgme* typedefs. :PROPERTIES: :CUSTOM_ID: all-gpgme-typedefs :END: * Thread support: :PROPERTIES: :CUSTOM_ID: threads :END: ** When GNU Pth supports sendmsg/recvmsg, wrap them properly. :PROPERTIES: :CUSTOM_ID: wrap-oth :END: ** Without timegm (3) support our ISO time parser is not thread safe. :PROPERTIES: :CUSTOM_ID: time-threads :END: There is a configure time warning, though. * New features: :PROPERTIES: :CUSTOM_ID: new-features :END: ** Flow control for data objects. :PROPERTIES: :CUSTOM_ID: flow-control-is-not-a-euphemism-for-an-s-bend :END: Currently, gpgme_data_t objects are assumed to be blocking. To break this assumption, we need either (A) a way for an user I/O callback to store the current operation in a continuation that can be resumed later. While the continuation exists, file descriptors associated with this operation must be removed from their respective event loop. or (B) a way for gpgme data objects to be associated with a waitable object, that can be registered with the user event loop. Neither is particularly simple. ** Extended notation support. When gpg supports arbitrary binary :PROPERTIES: :CUSTOM_ID: extended-notation :END: notation data, provide a user interface for that. ** notification system :PROPERTIES: :CUSTOM_ID: notification-system :END: We need a simple notification system, probably a simple callback with a string and some optional arguments. This is for example required to notify an application of a changed smartcard, The application can then do whatever is required. There are other - usages too. This notfication system should be independent of any + usages too. This notification system should be independent of any contextes of course. Not sure whether this is still required. GPGME_PROTOCOL_ASSUAN is sufficient for this. ** --learn-code support :PROPERTIES: :CUSTOM_ID: learn-code :END: This might be integrated with import. we still need to work out how to learn a card when gpg and gpgsm have support for smartcards. In GPA we currently invoke gpg directly. ** Might need a stat() for data objects and use it for length param to gpg. :PROPERTIES: :CUSTOM_ID: stat-data :END: ** Implement support for photo ids. :PROPERTIES: :CUSTOM_ID: photo-id :END: ** Allow selection of subkeys :PROPERTIES: :CUSTOM_ID: subkey-selection :END: ** Allow to return time stamps in ISO format :PROPERTIES: :CUSTOM_ID: iso-format-datetime :END: This allows us to handle years later than 2037 properly. With the time_t interface they are all mapped to 2037-12-31 ** New features requested by our dear users, but rejected or left for :PROPERTIES: :CUSTOM_ID: feature-requests :END: later consideration: *** Allow to export secret keys. :PROPERTIES: :CUSTOM_ID: export-secret-keys :END: Rejected because this is conceptually flawed. Secret keys on a smart card can not be exported, for example. May eventually e supproted with a keywrapping system. *** Selecting the key ring, setting the version or comment in output. :PROPERTIES: :CUSTOM_ID: select-keyring-version :END: Rejected because the naive implementation is engine specific, the configuration is part of the engine's configuration or readily worked around in a different way *** Selecting the symmetric cipher. :PROPERTIES: :CUSTOM_ID: symmetric-cipher-selection :END: *** Exchanging keys with key servers. :PROPERTIES: :CUSTOM_ID: key-server-exchange :END: * Engines :PROPERTIES: :CUSTOM_ID: engines :END: ** Do not create/destroy engines, but create engine and then reset it. :PROPERTIES: :CUSTOM_ID: reset-engine-is-not-quite-just-ignition :END: Internally the reset operation still spawns a new engine process, but this can be replaced with a reset later. Also, be very sure to release everything properly at a reset and at an error. Think hard about where to guarantee what (ie, what happens if start fails, are the fds unregistered immediately - i think so?) Note that we need support in gpgsm to set include-certs to default as RESET does not reset it, also for no_encrypt_to and probably other options. ** Optimize the case where a data object has an underlying fd we can pass :PROPERTIES: :CUSTOM_ID: optimus-data-cousin-of-optimus-prime :END: directly to the engine. This will be automatic with socket I/O and descriptor passing. ** Move code common to all engines up from gpg to engine. :PROPERTIES: :CUSTOM_ID: move-code-common-to-engines-out-of-gpg :END: ** engine operations can return General Error on unknown protocol :PROPERTIES: :CUSTOM_ID: general-error-looking-to-be-court-martialled :END: (it's an internal error, as select_protocol checks already). ** When server mode is implemented properly, more care has to be taken to :PROPERTIES: :CUSTOM_ID: server-mode :END: release all resources on error (for example to free assuan_cmd). ** op_import_keys and op_export_keys have a limit in the number of keys. :PROPERTIES: :CUSTOM_ID: import-export-problems :END: This is because we pass them in gpg via the command line and gpgsm via an assuan control line. We should pipe them instead and maybe change gpg/gpgsm to not put them in memory. * GPG breakage: :PROPERTIES: :CUSTOM_ID: gpg-breakage :END: ** CANCELLED gpg 1.4.2 lacks error reporting if sign/encrypt with revoked key. CLOSED: [2018-03-09 Fri 08:19] :PROPERTIES: :CUSTOM_ID: gpg-classic-lacks-stuff :END: - State "CANCELLED" from "TODO" [2018-03-09 Fri 08:19] \\ WON'T FIX. ** CANCELLED gpg 1.4.2 does crappy error reporting (namely none at all) when CLOSED: [2018-03-09 Fri 08:20] :PROPERTIES: :CUSTOM_ID: gpg-classic-problems-but-do-we-care :END: - State "CANCELLED" from "TODO" [2018-03-09 Fri 08:20] \\ WON'T FIX. smart card is missing for sign operation: [GNUPG:] CARDCTRL 4 gpg: selecting openpgp failed: ec=6.110 gpg: signing failed: general error [GNUPG:] BEGIN_ENCRYPTION 2 10 gpg: test: sign+encrypt failed: general error ** DONE Without agent and with wrong passphrase, gpg 1.4.2 enters into an CLOSED: [2018-03-09 Fri 08:20] :PROPERTIES: :CUSTOM_ID: recursive-gpg-classic :END: - State "DONE" from "TODO" [2018-03-09 Fri 08:20] \\ Must have been fixed in a subsequent release. infinite loop. ** CANCELLED Use correct argv[0] CLOSED: [2018-03-09 Fri 08:24] :PROPERTIES: :CUSTOM_ID: correct-argv :END: - State "CANCELLED" from "TODO" [2018-03-09 Fri 08:24] \\ WON'T FIX. Also, there is no rungpg.c file in GPGME (or in GPG or most, if not all of the rest of the libs and packages; I suspect there hasn't been for a very long time). In rungpg.c:build_argv we use argv[argc] = strdup ("gpg"); /* argv[0] */ This should be changed to take the real file name used in account. * Operations :PROPERTIES: :CUSTOM_ID: operations-are-not-surgical :END: ** Include cert values -2, -1, 0 and 1 should be defined as macros. :PROPERTIES: :CUSTOM_ID: certified-macros :END: ** If an operation failed, make sure that the result functions don't return :PROPERTIES: :CUSTOM_ID: operation-failure :END: corrupt partial information. !!! NOTE: The EOF status handler is not called in this case !!! ** Verify must not fail on NODATA premature if auto-key-retrieval failed. :PROPERTIES: :CUSTOM_ID: autobot-key-retrieval :END: It should not fail silently if it knows there is an error. !!! ** All operations: Better error reporting. !! :PROPERTIES: :CUSTOM_ID: better-reporting-not-like-fox-news :END: ** Export status handler need much more work. !!! :PROPERTIES: :CUSTOM_ID: export-status-handler :END: ** Import should return a useful error when one happened. :PROPERTIES: :CUSTOM_ID: import-useful-stuff-even-wrong-stuff :END: *** Import does not take notice of NODATA status report. :PROPERTIES: :CUSTOM_ID: import-no-data :END: *** When GPGSM does issue IMPORT_OK status reports, make sure to check for :PROPERTIES: :CUSTOM_ID: gpgsm-import-ok :END: them in tests/gpgs m/t-import.c. ** Verify can include info about version/algo/class, but currently :PROPERTIES: :CUSTOM_ID: verify-class :END: this is only available for gpg, not gpgsm. ** Return ENC_TO output in verify result. Again, this is not available :PROPERTIES: :CUSTOM_ID: return-to-enc :END: for gpgsm. ** Genkey should return something more useful than General_Error. :PROPERTIES: :CUSTOM_ID: general-key-assumed-command-from-general-error :END: ** If possible, use --file-setsize to set the file size for proper progress :PROPERTIES: :CUSTOM_ID: file-setsize :END: callback handling. Write data interface for file size. ** Optimize the file descriptor list, so the number of open fds is :PROPERTIES: :CUSTOM_ID: optimus-descriptus-younger-brother-of-optimus-prime :END: always known easily. ** Encryption: It should be verified that the behaviour for partially untrusted :PROPERTIES: :CUSTOM_ID: only-mostly-dead-means-partially-alive :END: recipients is correct. ** When GPG issues INV_something for invalid signers, catch them. :PROPERTIES: :CUSTOM_ID: invalid-sig :END: * Error Values :PROPERTIES: :CUSTOM_ID: error-value :END: ** Map ASSUAN/GpgSM ERR error values in a better way than is done now. !! :PROPERTIES: :CUSTOM_ID: map-ass-error :END: ** Some error values should identify the source more correctly (mostly error :PROPERTIES: :CUSTOM_ID: source-errors :END: values derived from status messages). ** In rungpg.c we need to check the version of the engine :PROPERTIES: :CUSTOM_ID: rungpg-c-engine-ver :END: This requires a way to get the cached version number from the engine layer. * Tests :PROPERTIES: :CUSTOM_ID: tests :END: ** TODO Write a fake gpg-agent so that we can supply known passphrases to :PROPERTIES: :CUSTOM_ID: test-fake-gpg-agent :END: gpgsm and setup the configuration files to use the agent. Without this we are testing a currently running gpg-agent which is not a clever idea. ! ** t-data :PROPERTIES: :CUSTOM_ID: test-data :END: *** Test gpgme_data_release_and_get_mem. :PROPERTIES: :CUSTOM_ID: test-gpgme-data-release-mem :END: *** Test gpgme_data_seek for invalid types. :PROPERTIES: :CUSTOM_ID: test-gpgme-data-seek :END: ** t-keylist :PROPERTIES: :CUSTOM_ID: test-keylist :END: Write a test for ext_keylist. ** Test reading key signatures. :PROPERTIES: :CUSTOM_ID: test-key-sig :END: * Debug :PROPERTIES: :CUSTOM_ID: debug :END: ** Tracepoints should be added at: Every public interface enter/leave, :PROPERTIES: :CUSTOM_ID: tracepoint-pub-int :END: before and in every callback, at major decision points, at every internal data point which might easily be observed by the outside (system handles). We also trace handles and I/O support threads in the w32 implementation because that's fragile code. Files left to do: data-fd.c data-mem.c data-stream.c data-user.c debug.c rungpg.c engine.c engine-gpgsm.c funopen.c w32-glib-io.c wait.c wait-global.c wait-private.c wait-user.c op-support.c decrypt.c decrypt-verify.c delete.c edit.c encrypt.c encrypt-sign.c export.c genkey.c import.c key.c keylist.c passphrase.c progress.c signers.c sig-notation.c trust-item.c trustlist.c verify.c ** TODO Handle malloc and vasprintf errors. But decide first if they should be :PROPERTIES: :CUSTOM_ID: malloc-vasprintf :END: ignored (and logged with 255?!), or really be assertions. ! * Build suite :PROPERTIES: :CUSTOM_ID: build-suite :END: ** TODO Make sure everything is cleaned correctly (esp. test area). :PROPERTIES: :CUSTOM_ID: clean-tests :END: ** TODO Enable AC_CONFIG_MACRO_DIR and bump up autoconf version requirement. :PROPERTIES: :CUSTOM_ID: autoconf-macros :END: (To fix "./autogen.sh; ./configure --enable-maintainer-mode; touch configure.ac; make"). Currently worked around with ACLOCAL_AMFLAGS??? * Error checking :PROPERTIES: :CUSTOM_ID: error-checking :END: ** TODO engine-gpgsm, with-validation :PROPERTIES: :CUSTOM_ID: gpgsm-validation :END: Add error checking some time after releasing a new gpgsm. * Language bindings and related components :PROPERTIES: :CUSTOM_ID: language-bindings-and-related-stuff :END: ** TODO Emacs and elisp binding :PROPERTIES: :CUSTOM_ID: emacs-and-elisp :END: Currently GNU Emacs uses EPA and EPG to provide GnuPG support. EPG does this by calling the GPG executable and wrapping the commands with elisp functions. A more preferable solution would be to implement an epgme.el which integrated with GPGME, then if it could not to attempt calling the gpgme-tool and only if those failed to fall back to the current epg.el and calling the command line binaries. ** TODO API of an API :PROPERTIES: :CUSTOM_ID: api-squared :END: See the more detailed notes on this in the [[lang/python/docs/TODO.org][python TODO]]. ** TODO GPGME installation and package management guide :PROPERTIES: :CUSTOM_ID: package-management :END: Write a guide/best practices for maintainers of GPGME packages with third party package management systems. * Copyright 2004, 2005, 2018 g10 Code GmbH :PROPERTIES: :CUSTOM_ID: copyright-and-license :END: This file is free software; as a special exception the author gives unlimited permission to copy and/or distribute it, with or without modifications, as long as this notice is preserved. This file is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY, to the extent permitted by law; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. diff --git a/configure.ac b/configure.ac index 13989931..688a4b38 100644 --- a/configure.ac +++ b/configure.ac @@ -1,903 +1,903 @@ # configure.ac for GPGME # Copyright (C) 2000 Werner Koch (dd9jn) # Copyright (C) 2001-2018 g10 Code 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 Lesser General Public License as # published by the Free Software Foundation; either version 2.1 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 Lesser General # Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program; if not, see . # (Process this file with autoconf to produce a configure script.) AC_PREREQ(2.59) min_automake_version="1.14" # To build a release you need to create a tag with the version number # (git tag -s gpgme-n.m.k) and run "./autogen.sh --force". Please # bump the version number immediately after the release and do another # commit and push so that the git magic is able to work. See below # for the LT versions. m4_define([mym4_package],[gpgme]) m4_define([mym4_major], [1]) m4_define([mym4_minor], [12]) m4_define([mym4_micro], [1]) # Below is m4 magic to extract and compute the git revision number, # the decimalized short revision number, a beta version string and a # flag indicating a development version (mym4_isbeta). Note that the # m4 processing is done by autoconf and not during the configure run. m4_define([mym4_verslist], m4_split(m4_esyscmd([./autogen.sh --find-version] \ mym4_package mym4_major mym4_minor mym4_micro),[:])) m4_define([mym4_isbeta], m4_argn(2, mym4_verslist)) m4_define([mym4_version], m4_argn(4, mym4_verslist)) m4_define([mym4_revision], m4_argn(7, mym4_verslist)) m4_define([mym4_revision_dec], m4_argn(8, mym4_verslist)) m4_esyscmd([echo ]mym4_version[>VERSION]) AC_INIT([mym4_package],[mym4_version], [https://bugs.gnupg.org]) # LT Version numbers, remember to change them just *before* a release. # (Code changed: REVISION++) # (Interfaces added/removed/changed: CURRENT++, REVISION=0) # (Interfaces added: AGE++) # (Interfaces removed: AGE=0) # LIBGPGME_LT_CURRENT=32 LIBGPGME_LT_AGE=21 LIBGPGME_LT_REVISION=0 # 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=14 LIBGPGMEPP_LT_AGE=8 LIBGPGMEPP_LT_REVISION=0 LIBQGPGME_LT_CURRENT=10 LIBQGPGME_LT_AGE=3 LIBQGPGME_LT_REVISION=2 ################################################ AC_SUBST(LIBGPGME_LT_CURRENT) AC_SUBST(LIBGPGME_LT_AGE) AC_SUBST(LIBGPGME_LT_REVISION) AC_SUBST(LIBGPGMEPP_LT_CURRENT) AC_SUBST(LIBGPGMEPP_LT_AGE) AC_SUBST(LIBGPGMEPP_LT_REVISION) AC_SUBST(LIBQGPGME_LT_CURRENT) AC_SUBST(LIBQGPGME_LT_AGE) AC_SUBST(LIBQGPGME_LT_REVISION) # If the API is changed in an incompatible way: increment the next counter. GPGME_CONFIG_API_VERSION=1 ############################################## NEED_GPG_ERROR_VERSION=1.24 NEED_LIBASSUAN_API=2 NEED_LIBASSUAN_VERSION=2.4.2 VERSION_MAJOR=mym4_major VERSION_MINOR=mym4_minor VERSION_MICRO=mym4_micro AC_CONFIG_AUX_DIR([build-aux]) AC_CONFIG_MACRO_DIR([m4]) AC_CONFIG_SRCDIR(src/gpgme.h.in) AC_CONFIG_HEADER(conf/config.h) AM_INIT_AUTOMAKE([serial-tests dist-bzip2 no-dist-gzip]) AM_MAINTAINER_MODE AC_CANONICAL_HOST AM_SILENT_RULES AC_ARG_VAR(SYSROOT,[locate config scripts also below that directory]) # Enable GNU extensions on systems that have them. AC_GNU_SOURCE AH_VERBATIM([_REENTRANT], [/* To allow the use of GPGME in multithreaded programs we have to use special features from the library. IMPORTANT: gpgme is not yet fully reentrant and you should use it only from one thread. */ #ifndef _REENTRANT # define _REENTRANT 1 #endif]) AC_PROG_CC AC_PROG_CPP AC_PROG_CXX # Note: A suitable gitlog-to-changelog script can be found in GnuPG master. AC_CHECK_PROGS(GITLOG_TO_CHANGELOG, gitlog-to-changelog, [gitlog-to-changelog]) AC_SUBST(VERSION_MAJOR) AC_SUBST(VERSION_MINOR) AC_SUBST(VERSION_MICRO) VERSION_NUMBER=m4_esyscmd(printf "0x%02x%02x%02x" mym4_major \ mym4_minor mym4_micro) AC_SUBST(VERSION_NUMBER) # We need to compile and run a program on the build machine. A # comment in libgpg-error says that the AC_PROG_CC_FOR_BUILD macro in # the AC archive is broken for autoconf 2.57. Given that there is no # newer version of that macro, we assume that it is also broken for # autoconf 2.61 and thus we use a simple but usually sufficient # approach. AC_MSG_CHECKING(for cc for build) if test "$cross_compiling" = "yes"; then CC_FOR_BUILD="${CC_FOR_BUILD-cc}" else CC_FOR_BUILD="${CC_FOR_BUILD-$CC}" fi AC_MSG_RESULT($CC_FOR_BUILD) AC_ARG_VAR(CC_FOR_BUILD,[build system C compiler]) # Don't default to build static libs. LT_PREREQ([2.2.6]) LT_INIT([win32-dll disable-static]) LT_LANG([Windows Resource]) # For now we hardcode the use of version scripts. It would be better # to write a test for this or even implement this within libtool. have_ld_version_script=no case "${host}" in *-*-linux*) have_ld_version_script=yes ;; *-*-gnu*) have_ld_version_script=yes ;; *-apple-darwin*) AC_DEFINE(_DARWIN_C_SOURCE, 900000L, Expose all libc features (__DARWIN_C_FULL).) AC_DEFINE(_XOPEN_SOURCE, 500, Activate POSIX interface on MacOS X) ;; esac AM_CONDITIONAL(HAVE_LD_VERSION_SCRIPT, test "$have_ld_version_script" = "yes") GPG_DEFAULT=no GPGSM_DEFAULT=no GPGCONF_DEFAULT=no G13_DEFAULT=no component_system=None have_dosish_system=no have_android_system=no have_w32_system=no have_w64_system=no have_macos_system=no build_w32_glib=no build_w32_qt=no available_languages="cl cpp python qt" default_languages="cl cpp python qt" case "${host}" in x86_64-*mingw32*) have_w64_system=yes ;; *-linux-androideabi) have_android_system=yes ;; *-apple-darwin*) have_macos_system=yes ;; esac case "${host}" in *-mingw32*) have_dosish_system=yes have_w32_system=yes GPG_DEFAULT='c:\\gnupg\\gpg.exe' GPGSM_DEFAULT='c:\\gnupg\\gpgsm.exe' GPGCONF_DEFAULT='c:\\gnupg\\gpgconf.exe' G13_DEFAULT='c:\\gnupg\\g13.exe' #component_system='COM+' AM_PATH_GLIB_2_0 AC_ARG_ENABLE(w32-glib, AC_HELP_STRING([--enable-w32-glib], [build GPGME Glib for W32]), build_w32_glib=$enableval) ;; *) # XXX: Probably use exec-prefix here? # GPG_DEFAULT='/usr/bin/gpg' # GPGSM_DEFAULT='/usr/bin/gpgsm' # GPGCONF_DEFAULT='/usr/bin/gpgconf' # G13_DEFAULT='/usr/bin/g13' ;; esac if test "$have_dosish_system" = yes; then AC_DEFINE(HAVE_DOSISH_SYSTEM,1, [Defined if we run on some of the PCDOS like systems (DOS, Windoze. OS/2) with special properties like no file modes]) fi AM_CONDITIONAL(HAVE_DOSISH_SYSTEM, test "$have_dosish_system" = yes) if test "$have_w32_system" = yes; then AC_DEFINE(HAVE_W32_SYSTEM,1, [Defined if we run on any kind of W32 API based system]) fi AM_CONDITIONAL(HAVE_W32_SYSTEM, test "$have_w32_system" = yes) if test "$have_w64_system" = yes; then AC_DEFINE(HAVE_W64_SYSTEM,1, [Defined if we run on a 64 bit W32 API based system]) fi AM_CONDITIONAL(HAVE_W64_SYSTEM, test "$have_w64_system" = yes) if test "$have_android_system" = yes; then AC_DEFINE(HAVE_ANDROID_SYSTEM,1, [Defined if we build for an Android system]) fi AM_CONDITIONAL(HAVE_ANDROID_SYSTEM, test "$have_android_system" = yes) if test "$have_macos_system" = yes; then AC_DEFINE(HAVE_MACOS_SYSTEM,1, [Defined if we build for an MacOS system]) fi AM_CONDITIONAL(HAVE_MACOS_SYSTEM, test "$have_macos_system" = yes) AM_CONDITIONAL(BUILD_W32_GLIB, test "$build_w32_glib" = yes) AC_ARG_ENABLE([fixed-path], AC_HELP_STRING([--enable-fixed-path=PATH], [locate binaries only via this PATH]), [fixed_search_path="$enableval"], [fixed_search_path=""]) if test x$fixed_search_path != x ; then AC_DEFINE_UNQUOTED(FIXED_SEARCH_PATH, "$fixed_search_path", [Locate binaries only via this PATH]) fi # Note: You need to declare all possible languages also in # lang/Makefile.am's DIST_SUBDIRS. AC_ARG_ENABLE([languages], AC_HELP_STRING([--enable-languages=languages], [enable only specific language bindings]), [enabled_languages=`echo $enableval | \ tr ',:' ' ' | tr '[A-Z]' '[a-z]' | \ sed 's/c++/cpp/'`], [enabled_languages="maybe"]) if test "x$enabled_languages" = "x" \ -o "$enabled_languages" = "no"; then enabled_languages= fi # If languages are explicitly set missing requirements # for the languages are treated as errors otherwise # there will be a warning. explicit_languages=1 if test "x$enabled_languages" = "xmaybe"; then explicit_languages=0 enabled_languages="$default_languages" fi for language in $enabled_languages; do LIST_MEMBER($language, $available_languages) if test "$found" = "0"; then AC_MSG_ERROR([unsupported language binding specified]) fi done # Enable C++ 11 if cpp language is requested LIST_MEMBER("cpp", $enabled_languages) if test "$found" = "1"; then AX_CXX_COMPILE_STDCXX(11, noext, optional) if test "$HAVE_CXX11" != "1"; then if test "$explicit_languages" = "1"; then AC_MSG_ERROR([[ *** *** A compiler with c++11 support is required for the c++ binding. ***]]) else enabled_languages=$(echo $enabled_languages | sed 's/cpp//') enabled_languages=$(echo $enabled_languages | sed 's/qt//') AC_MSG_WARN([[ *** *** No c++11 support detected. C++ and Qt bindings will be disabled. ***]]) fi fi fi # Check that if qt is enabled cpp also is enabled LIST_MEMBER("qt", $enabled_languages) if test "$found" = "1"; then # We need to ensure that in the language order qt comes after cpp # so we remove qt first and explicitly add it as last list member. enabled_languages=$(echo $enabled_languages | sed 's/qt//') LIST_MEMBER("cpp", $enabled_languages) if test "$found" = "0"; then AC_MSG_ERROR([[ *** *** Qt language binding depends on cpp binding. ***]]) fi FIND_QT if test "$have_qt5_libs" != "yes"; then if test "$explicit_languages" = "1"; then AC_MSG_ERROR([[ *** *** Qt5 (Qt5Core) is required for Qt binding. ***]]) else AC_MSG_WARN([[ *** *** Qt5 (Qt5Core) not found Qt Binding will be disabled. ***]]) fi else enabled_languages=`echo $enabled_languages qt` AC_CHECK_PROGS([DOXYGEN], [doxygen]) if test -z "$DOXYGEN"; - # This is not highlighted becase it's not really important. + # This is not highlighted because it's not really important. then AC_MSG_WARN([Doxygen not found - Qt binding doc will not be built.]) fi AC_CHECK_PROGS([GRAPHVIZ], [dot]) if test -z "$GRAPHVIZ"; then AC_MSG_WARN([Graphviz not found - Qt binding doc will not have diagrams.]) fi fi fi AM_CONDITIONAL([HAVE_DOXYGEN], [test -n "$DOXYGEN"]) if test -n "$GRAPHVIZ"; then HAVE_DOT="YES" else HAVE_DOT="NO" fi AC_SUBST(HAVE_DOT) # Python bindings. LIST_MEMBER("python", $enabled_languages) found_py=$found if test "$found_py" = "1"; then AX_PKG_SWIG if test -z "$SWIG"; then if test "$explicit_languages" = "1"; then AC_MSG_ERROR([[ *** *** You need SWIG to build the Python bindings. ***]]) else enabled_languages=$(echo $enabled_languages | sed 's/python//') fi else # Reset the version collecting vars. PYTHONS= PYTHON_VERSIONS= 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],[all]], [unset PYTHON unset PYTHON_VERSION unset PYTHON_CPPFLAGS unset PYTHON_LDFLAGS unset PYTHON_SITE_PKG unset PYTHON_EXTRA_LIBS unset PYTHON_EXTRA_LDFLAGS unset ac_cv_path_PYTHON unset am_cv_pathless_PYTHON unset am_cv_python_version unset am_cv_python_platform unset am_cv_python_pythondir unset am_cv_python_pyexecdir AM_PATH_PYTHON(mym4pythonver, [ AX_PYTHON_DEVEL if test "$PYTHON_VERSION"; then PYTHONS="$(echo $PYTHONS $PYTHON)" PYTHON_VERSIONS="$(echo $PYTHON_VERSIONS $PYTHON_VERSION)" fi ], :, m4_if([mym4pythonver],[all],[],[python]mym4pythonver)) ]) fi # Recover some values lost in the second attempt to find Python. PYTHON="$(echo $PYTHONS | cut -d ' ' -f 1)" PYTHON_VERSION="$(echo $PYTHON_VERSIONS | cut -d ' ' -f 1)" # Remove duplicates. PYTHONS="$(echo $PYTHONS | tr '[[:space:]]' '\n' | sort | uniq | tr '\n' ' ' | sed -e 's/ $//')" PYTHON_VERSIONS="$(echo $PYTHON_VERSIONS | tr '[[:space:]]' '\n' | sort | uniq | tr '\n' ' ' | sed -e 's/ $//')" if test "$PYTHON_VERSIONS"; then enabled_languages_v=$(echo $enabled_languages | sed -Ee "s/python[[23]]?/python ($PYTHON_VERSIONS)/") enabled_languages=$(echo $enabled_languages | sed -Ee "s/python[[23]]?/python/") else if test "$explicit_languages" = "1"; then AC_MSG_ERROR([[ *** *** Please install the python development packages. ***]]) else enabled_languages=$(echo $enabled_languages | sed 's/python//') fi fi AC_SUBST(PYTHONS, $PYTHONS) fi fi AC_SUBST(ENABLED_LANGUAGES, $enabled_languages) # # Provide information about the build. # BUILD_REVISION="mym4_revision" AC_SUBST(BUILD_REVISION) AC_DEFINE_UNQUOTED(BUILD_REVISION, "$BUILD_REVISION", [GIT commit id revision used to build this package]) changequote(,)dnl BUILD_VERSION=`echo "$PACKAGE_VERSION" | sed 's/\([0-9.]*\).*/\1./'` changequote([,])dnl BUILD_VERSION="${BUILD_VERSION}mym4_revision_dec" BUILD_FILEVERSION=`echo "${BUILD_VERSION}" | tr . ,` AC_SUBST(BUILD_VERSION) AC_SUBST(BUILD_FILEVERSION) AC_ARG_ENABLE([build-timestamp], AC_HELP_STRING([--enable-build-timestamp], [set an explicit build timestamp for reproducibility. (default is the current time in ISO-8601 format)]), [if test "$enableval" = "yes"; then BUILD_TIMESTAMP=`date -u +%Y-%m-%dT%H:%M+0000 2>/dev/null || date` else BUILD_TIMESTAMP="$enableval" fi], [BUILD_TIMESTAMP=""]) AC_SUBST(BUILD_TIMESTAMP) AC_DEFINE_UNQUOTED(BUILD_TIMESTAMP, "$BUILD_TIMESTAMP", [The time this package was configured for a build]) # # Options to disable some regression tests # run_gpgconf_test="yes" AC_ARG_ENABLE(gpgconf-test, AC_HELP_STRING([--disable-gpgconf-test], [disable GPGCONF regression test]), run_gpgconf_test=$enableval) AM_CONDITIONAL(RUN_GPGCONF_TESTS, test "$run_gpgconf_test" = "yes") run_gpg_test="yes" AC_ARG_ENABLE(gpg-test, AC_HELP_STRING([--disable-gpg-test], [disable GPG regression test]), run_gpg_test=$enableval) AM_CONDITIONAL(RUN_GPG_TESTS, test "$run_gpg_test" = "yes") run_gpgsm_test="yes" AC_ARG_ENABLE(gpgsm-test, AC_HELP_STRING([--disable-gpgsm-test], [disable GPGSM regression test]), run_gpgsm_test=$enableval) AM_CONDITIONAL(RUN_GPGSM_TESTS, test "$run_gpgsm_test" = "yes") run_g13_test="yes" AC_ARG_ENABLE(g13-test, AC_HELP_STRING([--disable-g13-test], [disable G13 regression test]), run_g13_test=$enableval) AM_CONDITIONAL(RUN_G13_TESTS, test "$run_g13_test" = "yes") # Checks for header files. AC_CHECK_HEADERS_ONCE([locale.h sys/select.h sys/uio.h argp.h stdint.h unistd.h sys/time.h sys/types.h sys/stat.h]) # Type checks. AC_C_INLINE AC_CHECK_SIZEOF(unsigned int) AC_SYS_LARGEFILE AC_TYPE_OFF_T AC_TYPE_UINTPTR_T # We require uint64_t if test "$ac_cv_header_stdint_h" != yes; then AC_MSG_ERROR([[ *** *** No stdint.h and thus no uint64_t type. Can't build this library. ***]]) fi # A simple compile time check in gpgme.h for GNU/Linux systems that # prevents a file offset bits mismatch between gpgme and the application. NEED__FILE_OFFSET_BITS=0 if test "$have_w32_system" != yes; then case "$ac_cv_sys_file_offset_bits" in "" | no | unknown) ;; *) NEED__FILE_OFFSET_BITS=$ac_cv_sys_file_offset_bits ;; esac fi AC_SUBST(NEED__FILE_OFFSET_BITS) # Figure out platform dependent typedefs for gpgme.h if test "$have_w32_system" = yes; then INSERT__TYPEDEFS_FOR_GPGME_H=" #ifdef _WIN64 # include typedef int64_t gpgme_off_t; typedef int64_t gpgme_ssize_t; #else /* _WIN32 */ typedef long gpgme_off_t; typedef long gpgme_ssize_t; #endif /* _WIN32 */" API__OFF_T="gpgme_off_t" API__SSIZE_T="gpgme_ssize_t" else INSERT__TYPEDEFS_FOR_GPGME_H=" #include typedef off_t gpgme_off_t; typedef ssize_t gpgme_ssize_t;" API__OFF_T="off_t" API__SSIZE_T="ssize_t" fi AC_SUBST(INSERT__TYPEDEFS_FOR_GPGME_H) AM_SUBST_NOTMAKE(INSERT__TYPEDEFS_FOR_GPGME_H) AC_SUBST(API__OFF_T) AM_SUBST_NOTMAKE(API__OFF_T) AC_SUBST(API__SSIZE_T) AM_SUBST_NOTMAKE(API__SSIZE_T) # Checks for compiler features. if test "$GCC" = yes; then CFLAGS="$CFLAGS -Wall -Wcast-align -Wshadow -Wstrict-prototypes" if test "$USE_MAINTAINER_MODE" = "yes"; then CFLAGS="$CFLAGS -Wformat -Wno-format-y2k -Wformat-security" # If -Wno-missing-field-initializers is supported we can enable a # a bunch of really useful warnings. AC_MSG_CHECKING([if gcc supports -Wno-missing-field-initializers]) _gcc_cflags_save=$CFLAGS CFLAGS="-Wno-missing-field-initializers" AC_COMPILE_IFELSE([AC_LANG_PROGRAM([],[])],_gcc_wopt=yes,_gcc_wopt=no) AC_MSG_RESULT($_gcc_wopt) CFLAGS=$_gcc_cflags_save; if test x"$_gcc_wopt" = xyes ; then CFLAGS="$CFLAGS -W -Wextra -Wbad-function-cast" CFLAGS="$CFLAGS -Wwrite-strings" CFLAGS="$CFLAGS -Wdeclaration-after-statement" CFLAGS="$CFLAGS -Wno-missing-field-initializers" CFLAGS="$CFLAGS -Wno-sign-compare" fi CXXFLAGS="$CXXFLAGS -Wall -Wextra -Wno-shadow" AC_MSG_CHECKING([if gcc supports -Wpointer-arith]) _gcc_cflags_save=$CFLAGS CFLAGS="-Wpointer-arith" AC_COMPILE_IFELSE([AC_LANG_PROGRAM([],[])],_gcc_wopt=yes,_gcc_wopt=no) AC_MSG_RESULT($_gcc_wopt) CFLAGS=$_gcc_cflags_save; if test x"$_gcc_wopt" = xyes ; then CFLAGS="$CFLAGS -Wpointer-arith" fi fi if test "$have_w32_system" = yes; then CFLAGS="$CFLAGS -mms-bitfields" fi fi # Only used for debugging, so no serious test needed (for actual # functionality you have to test libc as well, this only tests the # compiler). AC_CACHE_CHECK([for __thread],[gpgme_cv_tls_works], AC_COMPILE_IFELSE([AC_LANG_PROGRAM([__thread int foo;])], gpgme_cv_tls_works=yes,gpgme_cv_tls_works=no)) if test "$gpgme_cv_tls_works" = yes; then AC_DEFINE(HAVE_TLS, [1], [Define if __thread is supported]) fi # Checks for library functions. AC_MSG_NOTICE([checking for libraries]) AC_FUNC_FSEEKO # Try to find a thread-safe version of ttyname(). gnupg_REPLACE_TTYNAME_R if test "$ac_cv_func_ttyname_r" != yes; then AC_MSG_WARN([ *** *** ttyname() is not thread-safe and ttyname_r() does not exist ***]) fi # Try to find a thread-safe version of getenv(). have_thread_safe_getenv=no jm_GLIBC21 if test $GLIBC21 = yes -o $have_w32_system = yes; then have_thread_safe_getenv=yes fi if test $have_thread_safe_getenv = yes; then AC_DEFINE(HAVE_THREAD_SAFE_GETENV, [1], [Define if getenv() is thread-safe]) fi have_getenv_r=no AC_CHECK_FUNCS(getenv_r, have_getenv_r=yes) if test $have_getenv_r = no && test $have_thread_safe_getenv = no; then AC_MSG_WARN([ *** *** getenv() is not thread-safe and getenv_r() does not exist ***]) fi # For converting time strings to seconds since Epoch, we need the timegm # function. AC_CHECK_FUNCS(timegm) if test "$ac_cv_func_timegm" != yes; then AC_MSG_WARN([ *** *** timegm() not available - a non-thread-safe kludge will be used *** and the TZ variable might be changed at runtime. ***]) fi AC_CHECK_FUNCS(setlocale) # Checking for libgpg-error. have_gpg_error=no AM_PATH_GPG_ERROR("$NEED_GPG_ERROR_VERSION", have_gpg_error=yes, have_gpg_error=no) AC_DEFINE(GPG_ERR_SOURCE_DEFAULT, GPG_ERR_SOURCE_GPGME, [The default error source for GPGME.]) # And for libassuan. have_libassuan=no AM_PATH_LIBASSUAN("$NEED_LIBASSUAN_API:$NEED_LIBASSUAN_VERSION", have_libassuan=yes, have_libassuan=no) if test "$have_libassuan" = "yes"; then AC_DEFINE_UNQUOTED(GPGME_LIBASSUAN_VERSION, "$libassuan_version", [version of the libassuan library]) fi # # Other checks # # Check for getgid etc AC_CHECK_FUNCS(getgid getegid closefrom) # Replacement functions. AC_REPLACE_FUNCS(stpcpy) AC_REPLACE_FUNCS(setenv) # Assuan check for descriptor passing. AC_CHECK_MEMBER(struct cmsghdr.cmsg_len, [supports_descriptor_passing=yes], [supports_descriptor_passing=no AC_MSG_WARN([ *** *** Data structure for sending ancillary data missing. *** Descriptor passing won't work. ***])],[ #include #include #include #include #include #include #if HAVE_SYS_UIO_H #include #endif #include ]) use_descriptor_passing=yes AC_ARG_ENABLE(fd-passing, AC_HELP_STRING([--disable-fd-passing], [do not use FD passing]), use_descriptor_passing=$enableval) if test "$supports_descriptor_passing" != "yes"; then use_descriptor_passing=no fi if test "$use_descriptor_passing" = "yes"; then AC_DEFINE(USE_DESCRIPTOR_PASSING,1, [Defined if descriptor passing is enabled and supported]) fi AM_CONDITIONAL(USE_DESCRIPTOR_PASSING, test "$use_descriptor_passing" = "yes") uiserver=no if test "$use_descriptor_passing" = "yes" && test "$have_libassuan" = "yes"; then uiserver=yes fi if test "$uiserver" != "no"; then AC_DEFINE(ENABLE_UISERVER, 1, [Defined if we are building with uiserver support.]) fi AM_CONDITIONAL(HAVE_UISERVER, test "$uiserver" != "no") # Option --disable-linux-getdents # # By default we use SYS_getdents on Linux to optimize fd closing # before an exec. This option allows to switch this optimization off. use_linux_getdents=yes AC_ARG_ENABLE(linux-getdents, AC_HELP_STRING([--disable-linux-getdents], [do not use SYS_getdents on Linux]), use_linux_getdents=$enableval) if test "$use_linux_getdents" = "yes"; then case "${host}" in *-*-linux*) AC_DEFINE(USE_LINUX_GETDENTS,1, [Defined if SYS_getdents can be used on Linux]) ;; esac fi # # Add a few constants to help porting to W32 # AH_VERBATIM([SEPCONSTANTS], [ /* Separators as used in $PATH and file name. */ #ifdef HAVE_DOSISH_SYSTEM #define PATHSEP_C ';' #define DIRSEP_C '\\' #define DIRSEP_S "\\" #else #define PATHSEP_C ':' #define DIRSEP_C '/' #define DIRSEP_S "/" #endif ]) AH_BOTTOM([ /* Definition of GCC specific attributes. */ #if __GNUC__ > 2 # define GPGME_GCC_A_PURE __attribute__ ((__pure__)) #else # define GPGME_GCC_A_PURE #endif /* Under WindowsCE we need gpg-error's strerror macro. */ #define GPG_ERR_ENABLE_ERRNO_MACROS 1 #define CRIGHTBLURB "Copyright (C) 2000 Werner Koch\n" \ "Copyright (C) 2001--2018 g10 Code GmbH\n" ]) # Substitution used for gpgme-config GPGME_CONFIG_LIBS="-lgpgme" GPGME_CONFIG_CFLAGS="" GPGME_CONFIG_HOST="$host" GPGME_CONFIG_AVAIL_LANG="$enabled_languages" AC_SUBST(GPGME_CONFIG_API_VERSION) AC_SUBST(GPGME_CONFIG_LIBS) AC_SUBST(GPGME_CONFIG_CFLAGS) AC_SUBST(GPGME_CONFIG_HOST) AC_SUBST(GPGME_CONFIG_AVAIL_LANG) # Frob'da Variables LTLIBOBJS=`echo "$LIB@&t@OBJS" | sed 's,\.[[^.]]* ,.lo ,g;s,\.[[^.]]*$,.lo,'` AC_SUBST(LTLIBOBJS) # Some checks for gpgme-tool # Done at top: AC_CHECK_HEADER([argp.h]) AC_CHECK_TYPES([error_t], [], [AC_DEFINE([error_t], [int], [Define to a type to use for `error_t' if it is not otherwise available.])], [#include ]) # A substitution to set generated files in a Emacs buffer to read-only. AC_SUBST(emacs_local_vars_begin, [['Local][ ][Variables:']]) AC_SUBST(emacs_local_vars_read_only, ['buffer-read-only: t']) AC_SUBST(emacs_local_vars_end, ['End:']) # Last check. die=no if test "$have_gpg_error" = "no"; then die=yes AC_MSG_NOTICE([[ *** *** You need libgpg-error to build this program. ** This library is for example available at *** https://www.gnupg.org/ftp/gcrypt/libgpg-error/ *** (at least version $NEED_GPG_ERROR_VERSION is required.) ***]]) fi if test "$have_libassuan" = "no"; then die=yes AC_MSG_NOTICE([[ *** *** You need libassuan to build this program. *** This library is for example available at *** https://www.gnupg.org/ftp/gcrypt/libassuan/ *** (at least version $NEED_LIBASSUAN_VERSION (API $NEED_LIBASSUAN_API) is required). ***]]) fi if test "$die" = "yes"; then AC_MSG_ERROR([[ *** *** Required libraries not found. Please consult the above messages *** and install them before running configure again. ***]]) fi # # Create config files AC_CONFIG_FILES(Makefile src/Makefile tests/Makefile tests/gpg/Makefile tests/gpgsm/Makefile tests/opassuan/Makefile doc/Makefile src/versioninfo.rc src/gpgme.h) AC_CONFIG_FILES(src/gpgme-config, chmod +x src/gpgme-config) AC_CONFIG_FILES(lang/cpp/Makefile lang/cpp/src/Makefile) AC_CONFIG_FILES(lang/cpp/tests/Makefile) AC_CONFIG_FILES(lang/cpp/src/GpgmeppConfig-w32.cmake.in) AC_CONFIG_FILES(lang/cpp/src/GpgmeppConfig.cmake.in) AC_CONFIG_FILES(lang/cpp/src/GpgmeppConfigVersion.cmake) AC_CONFIG_FILES(lang/cpp/src/gpgmepp_version.h) AC_CONFIG_FILES(lang/qt/Makefile lang/qt/src/Makefile) AC_CONFIG_FILES(lang/qt/src/QGpgmeConfig-w32.cmake.in) AC_CONFIG_FILES(lang/qt/src/QGpgmeConfig.cmake.in) AC_CONFIG_FILES(lang/qt/src/QGpgmeConfigVersion.cmake) AC_CONFIG_FILES(lang/qt/tests/Makefile) AC_CONFIG_FILES(lang/qt/src/qgpgme_version.h) AC_CONFIG_FILES([lang/Makefile lang/cl/Makefile lang/cl/gpgme.asd]) AM_COND_IF([HAVE_DOXYGEN], [AC_CONFIG_FILES([lang/qt/doc/Doxyfile])]) AC_CONFIG_FILES([lang/js/Makefile lang/js/src/Makefile lang/js/BrowserTestExtension/Makefile lang/js/DemoExtension/Makefile]) AC_CONFIG_FILES(lang/qt/doc/Makefile) AC_CONFIG_FILES([lang/python/Makefile lang/python/version.py lang/python/tests/Makefile]) AC_CONFIG_FILES([lang/python/setup.py], [chmod a+x lang/python/setup.py]) AC_OUTPUT echo " GPGME v${VERSION} has been configured as follows: Revision: mym4_revision (mym4_revision_dec) Platform: $host UI Server: $uiserver FD Passing: $use_descriptor_passing Language bindings: ${enabled_languages_v:-$enabled_languages} " if test "x${gpg_config_script_warn}" != x; then cat < NB: ChangeLog files are no longer manually maintained. Starting on December 1st, 2011 we put change information only in the GIT commit log, and generate a top-level ChangeLog file from logs at "make dist". See doc/HACKING for details. 2011-05-12 Marcus Brinkmann * gpgme.texi (I/O Callback Example): Fix example code. * gpgme.texi (Generating Keys): Fix OpenPGP parameters and reference GPG and GPGSM manual. 2010-01-05 Werner Koch * gpgme.texi (Changing Passphrases): New. 2009-07-21 Werner Koch * uiserver.texi (UI Server Encrypt): Add --expect-sign option to PREP_ENCRYPT. 2009-06-16 Marcus Brinkmann * gpgme.texi (Result Management): New section. 2009-06-16 Werner Koch * gpgme.texi (Exporting Keys): Document gpgme_op_export_keys. (Importing Keys): Document gpgme_op_import_keys. (Data Buffer Meta-Data): Document URL encodings. 2009-05-28 Marcus Brinkmann * gpgme.texi (Library Version Check): Document selftest error. (Creating Contexts): Likewise. 2009-05-18 Marcus Brinkmann * gpgme.texi (Encrypting a Plaintext): Document GPGME_ENCRYPT_NO_ENCRYPT_TO. 2009-05-05 Marcus Brinkmann * gpgme.texi (Engine Information): Replace path by file_name. 2008-11-28 Werner Koch * gpgme.texi (Listing Keys): Change description of the return value to match the code. Spotted by Colin Leroy. 2008-10-15 Werner Koch * uiserver.texi (Miscellaneous UI Server Commands): Add option --protocol to the SENDER command. 2008-07-17 Werner Koch * module-overview.sk: New. 2008-07-04 Werner Koch * gpgme.texi (Algorithms): Add a hint on symmetric only encryption. 2008-06-27 Marcus Brinkmann * gpgme.texi (Cancellation): Document gpgme_cancel_async. 2008-06-25 Werner Koch * gpgme.texi (Listing Keys): Updated example to the current API. Noted by Nico Schottelius. 2008-06-05 Werner Koch * uiserver.texi (Miscellaneous UI Server Commands): Describe START_CONFDIALOG. 2008-06-04 Werner Koch * gpgme.texi: Use @copying command. Change license to GPLv3. Include protocol specis from GpgOL and GPGEx. Minor cleanups. 2008-03-11 Marcus Brinkmann * gpgme.texi (File Based Data Buffers): Document the need for blocking operations. (Callback Based Data Buffers): Likewise. 2008-03-05 Marcus Brinkmann * gpgme.texi (Library Version Check): Rename snippet function to init_gpgme. (I/O Callback Example): Call it here. 2008-01-28 Marcus Brinkmann * gpgme.texi: Document that data encoding affects some output data objects now. 2007-09-27 Marcus Brinkmann * gpgme.texi (Protocols and Engines): Document GPGME_PROTOCOL_UNKNOWN. 2007-09-11 Werner Koch * gpgme.texi (I/O Callback Example): Typo fix. 2007-08-07 Werner Koch * gpgme.texi (Verify): Describe chain_model. 2007-07-12 Werner Koch * gpgme.texi (Library Version Check): Add remark that the socket layer will get initialized. 2007-06-05 Marcus Brinkmann * gpgme.texi (Advanced Key Editing): New section. 2007-05-21 Werner Koch * Makefile.am (online): New target. 2007-05-18 Marcus Brinkmann * gpgme.texi (Error Strings): Fix documentation of gpgme_strerror_r. 2006-11-01 Moritz Schulte * gpgme.texi (Data Buffer I/O Operations): Fixed entry for gpgme_data_seek: OFFSET is not a pointer; some s/whence/offset/. 2006-09-25 Marcus Brinkmann * gpgme.texi (Destroying Data Buffers): Clarify that gpgme_data_release_and_get_mem destroys DH unconditionally. 2005-03-24 Marcus Brinkmann * gpgme.texi (Library Version Check): Make example code compatible to W32 systems. 2006-06-21 Marcus Brinkmann * gpgme.texi (Passphrase Callback): Fix inverted condition in description. 2005-12-20 Werner Koch * gpgme.texi (Verify): Document pka_trust. 2005-12-06 Werner Koch * gpgme.texi (Key Management): Updated to match the fixes for subkey fingerprints and theg secret flag. 2005-10-06 Marcus Brinkmann * gpgme.texi (Destroying Data Buffers): Document gpgme_free. 2005-10-02 Marcus Brinkmann * gpgme.texi (Key Management): Add the new member notations of gpgme_sig_key_t. (Key Listing Mode): Document GPGME_KEYLIST_MODE_SIG_NOTATIONS. 2005-10-01 Marcus Brinkmann * gpgme.texi: Enclose all return parameters of deftypefuns in curly brackets. * gpgme.texi (Signature Notation Data): New section. (Verify): Added more about the notation data structure. 2005-09-30 Marcus Brinkmann * gpgme.texi (Data Buffer I/O Operations, Data Buffer Meta-Data): New subsections. * gpgme.texi: Replace plaintext_filename with file_name. * gpgme.texi (Key Management): Document is_qualified. 2005-07-27 Marcus Brinkmann * gpgme.texi (Decrypt): Add plaintext_filename to gpgme_decrypt_result_t. (Verify): Likewise for gpgme_verify_result_t. 2005-06-03 Marcus Brinkmann * gpgme.texi (Verify): Add information about new fields in gpgme_signature_t. * gpgme.texi (Decrypt): Add gpgme_recipient_t. 2005-05-28 Marcus Brinkmann * gpgme.texi (Key Listing Mode): Fix return type of gpgme_set_keylist_mode. Reported by "Sergio" . 2005-04-28 Marcus Brinkmann * gpgme.texi (Included Certificates): Document GPGME_INCLUDE_CERTS_DEFAULT. 2005-01-12 Marcus Brinkmann * gpgme.texi (Engine Configuration): New section. (Crypto Engine): New subsection. 2004-12-07 Marcus Brinkmann * lesser.texi (Library Copying): Change from @appendixsec to @appendix. * gpgme.texi (Features): Change reference to GPL to one to LGPL. * Makefile.am: Change license to LGPL. (gpgme_TEXINFOS): Replace gpl.texi with lesser.texi. * gpgme.texi: Change license to LGPL (also for documentation of GPGME's license). * lesser.texi: New file. * gpl.texi: File removed. * gpgme.texi (Creating Contexts): Fix cut&paste error. Reported by Noel Torres . 2004-09-30 Marcus Brinkmann * Makefile.am (gpgme_TEXINFOS): Remove fdl.texi. * gpgme.texi: Do not include fdl.texi. Change license to GPL. * fdl.texi: File removed. 2004-09-29 Marcus Brinkmann * gpgme.texi (Key Management): Change type of keylist_mode in gpgme_key_t to gpgme_keylist_mode_t. 2004-09-28 Marcus Brinkmann * gpgme.texi (Passphrase Callback): Fix last change. 2004-09-27 Marcus Brinkmann * gpgme.texi (Passphrase Callback): Document GPG_ERR_NOT_IMPLEMENTED. * gpgme.texi: Update copyright year for tex version. 2004-07-29 Moritz Schulte * gpgme.texi (Verify): Fix gpgme_get_key example (ancient force_update argument was still there). 2004-06-08 Marcus Brinkmann * gpgme.texi (Listing Keys): Elaborate on the length restrictions on search patterns. * gpgme.texi (Decrypt and Verify): Document the NO_DATA error code. (Verify): Document the relationship between gpgme_op_verify_result and the decrypt and verify operations. 2004-05-21 Marcus Brinkmann * gpgme.text (Verify): Document GPG_ERR_CERT_REVOKED status. * gpgme.texi (Decrypt): Add note about new field wrong_key_usage of gpgme_decrypt_result_t. * gpgme.texi (Key Management): Add note about new field keylist_mode of gpgme_key_t. 2004-04-29 Marcus Brinkmann * gpgme.texi (Verify): Correct type of member wrong_key_usage. 2004-03-29 Moritz Schulte * gpgme.texi (Verify): Fix type of gpgme_op_verify_result. * gpgme.texi (Key Listing Mode): Typo fix. 2004-03-23 Marcus Brinkmann * gpgme.texi (Library Version Check): Fix the instruction when to set the locale. 2004-03-03 Marcus Brinkmann * gpgme.texi (I/O Callback Example Qt): New section by Marc Mutz. 2004-02-24 Marcus Brinkmann * gpgme.texi (cancellation): New section. 2004-02-17 Werner Koch * gpgme.texi (Key Listing Mode): Doc KEYLIST_MODE_VALIDATE. 2004-02-06 Moritz Schulte * gpgme.texi: A couple of small fixes regarding the Largfile Support section. 2004-02-01 Marcus Brinkmann * gpgme.texi (Largefile Support): New section. 2004-01-13 Marcus Brinkmann * gpgme.texi (Key Management): Fix exportable field. 2003-12-25 Marcus Brinkmann * gpgme.texi (Key Management): Rename member class in gpgme_key_sig_t to sig_class. (Creating a Signature): Likewise for gpgme_signature_t. 2003-12-23 Moritz Schulte * gpgme.texi (Listing Keys): Minor clarification for gpgme_get_key. 2003-10-06 Marcus Brinkmann * gpgme.texi (Signal Handling): New section. 2003-09-14 Marcus Brinkmann * gpgme.texi (Multi Threading): Correct documentation on memory synchronization requirement. * gpgme.texi (Locale): New section. (Multi Threading): Set locale in example. 2003-09-13 Marcus Brinkmann * gpgme.texi (Error Strings): Add gpgme_strerror_r. 2003-09-13 Marcus Brinkmann * gpgme.texi (Multi Threading): Update documentation. 2003-09-03 Marcus Brinkmann * gpgme.texi (Header): We don't use the assuan namespace anymore. Document new thread options. 2003-08-14 Marcus Brinkmann * gpgme.texi (Creating a Signature): Change type of member class to unsigned int. 2003-08-04 Marcus Brinkmann * gpgme.texi (Verify): Get error code from SIG->status in the code for gpgme_get_sig_status. 2003-07-31 Marcus Brinkmann * gpgme.texi (Key Management): Add can_authenticate flag. * gpgme.texi (Listing Keys): Document GPG_ERR_AMBIGUOUS_NAME for gpgme_get_key. 2003-07-29 Marcus Brinkmann * Makefile.am (EXTRA_DIST): Remove variable. * gpgme.texi (Encrypting a Plaintext): Bad passphrase is only possible with symmetric encryption, change the wording to reflect that. * gpgme.texi (Creating a Signature): Document GPG_ERR_UNUSABLE_SECKEY. * gpgme.texi (Encrypting a Plaintext): Mention encrypt and sign operations in result function. (Creating a Signature): Likewise. 2003-07-23 Marcus Brinkmann * gpgme.texi (Key Listing Mode): Remove word duplication. (Listing Keys): Remove mentioning of force argument. (Verify): Don't mention r_stat. Fix some typos. (Decrypt and Verify): Correct info how to get the result. Don't mention r_stat. (Manipulating Data Buffers): Fix documentation of return value. (Listing Keys): Update examples. (Decrypt): Result might also be available when operation failed. (Verify): Result might also be available when operation failed. All spotted by Stéphane Corthésy. 2003-07-22 Marcus Brinkmann * gpgme.texi (Error Sources): Fix cut and paste error. 2003-07-09 Marcus Brinkmann * gpgme.texi (Key Management): Clarify difference between can_sign and can_certify. (Information About Keys): Likewise for GPGME_ATTR_CAN_SIGN and GPGME_ATTR_CAN_CERTIFY. 2003-07-08 Marcus Brinkmann * gpgme.texi (Progress Meter Callback): Change return type of gpgme_progress_cb_t to void. 2003-06-22 Marcus Brinkmann * gpgme.texi: Add 2003 to copyright notice. * gpgme.texi (Header): Fix name space documentation on libgpg-error. 2003-06-22 Marcus Brinkmann * gpgme.texi (Multi Threading): Remove reference to gpgme_recipients_t. 2003-06-06 Marcus Brinkmann * gpgme.texi (Crypto Operations): Rename gpgme_invalid_user_id_t to gpgme_invalid_key_t. 2003-06-06 Marcus Brinkmann * gpgme.texi: Change error codes to GPG_ERR_* variants. (Error Handling): Rewritten. 2003-05-29 Marcus Brinkmann * gpgme.texi (Exporting Keys): Change and document prototypes. Add new gpgme_op_export_ext and gpgme_op_export_ext_start variants. (Selecting Recipients): Section removed. (Encrypting a Plaintext): Change prototypes and document the changes. 2003-05-28 Marcus Brinkmann * gpgme.texi (Exporting Keys): Change argument type from gpgme_recipient_t to gpgme_user_id_t. (Encrypting a Plaintext): Likewise. (Selecting Recipients): Rewritten. 2003-05-27 Marcus Brinkmann * gpgme.texi (Protocol Selection): Do not use @acronym in @node because that breaks texi2dvi. * gpgme.texi (Passphrase Callback): Document new prototype. 2003-05-18 Marcus Brinkmann * gpgme.texi (Header): Remove Gpgme as namespace prefix. Add _GPGME to namespace prefix. * gpgme.texi (Multi Threading): Add note about link order. 2003-05-04 Marcus Brinkmann * gpgme.texi (Listing Keys): Document what happens if key is not found. * gpgme.texi (Importing Keys): Fix cut and paste error. 2003-04-30 Marcus Brinkmann * gpgme.texi (Encrypting a Plaintext): Remove reference to gpgme_get_op_info. (Detailed Results): Subsection removed. * gpgme.texi (Key Listing Mode): Add GPGME_KEYLIST_MODE_SIGS. (Manipulating Keys): Add obsoleteness note. (Key Signatures): Likewise. (Information About Keys): Likewise. (Key Management): Add new data types GpgmeSubkey, GpgmeKeySig, GpgmeUserID, and all the information about GpgmeKey. 2003-04-29 Marcus Brinkmann * gpgme.texi (Listing Keys): Remove force_update argument from gpgme_get_key. * gpgme.texi (Trust Item Management): Add data members of GpgmeTrustItem type. (Information About Trust Items): Add note about obsoleteness. (Manipulating Trust Items): Add gpgme_trust_item_ref and gpgme_trust_item_unref. 2003-04-28 Marcus Brinkmann * gpgme.texi (Verify): Rewritten to take into account new and deprecated functions and data types. * gpgme.texi (Decrypt): Descript gpgme_op_decrypt_result and GpgmeDecryptResult. 2003-04-27 Marcus Brinkmann * gpgme.texi (Encrypting a Plaintext): Add info about GpgmeEncryptResult and gpgme_op_encrypt_result. * gpgme.texi (Creating a Signature): Add info about GpgmeNewSignature, GpgmeSignResult and gpgme_op_sign_result. (Crypto Operations): Add GpgmeInvalidUserID. (Algorithms): New chapter. * gpgme.texi (Deleting Keys): Document GPGME_Ambiguous_Specification. (Error Values): Remove GPGME_Invalid_Type and GPGME_Invalid_Mode. Add GPGME_Unknown_Reason, GPGME_Not_Found, GPGME_Ambiguous_Specification, GPGME_Wrong_Key_Usage, GPGME_Key_Revoked, GPGME_Key_Expired, GPGME_No_CRL_Known, GPGME_CRL_Too_Old, GPGME_Policy_Mismatch, GPGME_No_Secret_Key, GPGME_Key_Not_Trusted, GPGME_Issuer_Missing, GPGME_Chain_Too_Long, GPGME_Unsupported_Algorithm, GPGME_Sig_Expired, GPGME_Bad_Signature, GPGME_No_Public_Key. 2003-04-25 Marcus Brinkmann * gpgme.texi (Importing Keys): Change GPGME_IMPORT_PRIVATE to GPGME_IMPORT_SECRET. * gpgme.texi (Importing Keys): Remove note about gpgme_get_op_info. (Detailed Results): Remove note about import. * gpgme.texi (Importing Keys): Add documentation for GpgmeImportStatus, GpgmeImportResult and gpgme_op_import_result. * gpgme.texi (Generating Keys): Fix documentation of public and secret arguments. 2003-04-24 Marcus Brinkmann * gpgme.texi (Generating Keys): Document changed gpgme_op_genkey and new gpgme_op_genkey_result function. Document GpgmeGenKeyResult data type. * gpgme.texi (Error Values): Rename GPGME_No_Passphrase to GPGME_Bad_Passphrase. * gpgme.texi (Decrypt): Likewise. (Decrypt and Verify): Likewise. (Creating a Signature): Likewise. (Encrypting a Plaintext): Likewise. * gpgme.texi (Error Values): Rename GPGME_No_Recipients to GPGME_No_UserID and GPGME_Invalid_Recipient to GPGME_Invalid_UserID. (Encrypting a Plaintext): Likewise. * gpgme.texi (Error Values): Remove GPGME_Busy and GPGME_No_Request. (Listing Keys): Likewise. (Listing Trust Items): Likewise. 2003-02-06 Marcus Brinkmann * gpgme.texi (Cancelling an Operation): Removed. (Passphrase Callback): Document new type for GpgmePassphraseCb. 2003-01-30 Marcus Brinkmann * gpgme.texi (Engine Information): Rename member part to file_name. * gpgme.texi (Protocols and Engines): Document gpgme_get_protocol_name. * gpgme.texi (Engine Information): Rewritten. 2003-01-29 Marcus Brinkmann * gpgme.texi (I/O Callback Interface): Document new even GPGME_EVENT_START. (Waiting For Completion): Document new possible return values. (I/O Callback Interface): Document return type of GpgmeIOCb. 2003-01-29 Marcus Brinkmann * gpgme.texi (Hooking Up Into Idle Time): Section removed. 2002-12-24 Marcus Brinkmann * gpgme.texi (Verify): Drop R_STAT argument in gpgme_op_verify. * gpgme.texi (Decrypt and Verify): Likewise for gpgme_op_decrypt_verify. 2002-12-23 Marcus Brinkmann * gpgme.texi (Information About Keys): Document that GPGME_ATTR_IS_SECRET is not representable as a string anymore. 2002-12-22 Marcus Brinkmann * gpgme.texi (Key Signatures): New section. (Listing Keys): Add gpgme_get_key. 2002-12-06 Marcus Brinkmann * gpgme.texi (Memory Based Data Buffers): New subsection. (File Based Data Buffers): Likewise. (Callback Based Data Buffers): Likewise. (Manipulating Data Buffers): Update interfaces. Add gpgme_data_seek. * gpgme.texi (Engine Version Check): Remove gpgme_check_engine. 2002-11-21 Marcus Brinkmann * gpgme.texi (Verify): Document the new interface. 2002-11-19 Marcus Brinkmann * gpgme.texi (Generating Keys): Document new argument to gpgme_op_genkey. 2002-11-05 Marcus Brinkmann * gpgme.texi (Verify): Fix prototype of gpgme_get_sig_key. Reported by Miguel Coca . 2002-08-30 Marcus Brinkmann * gpgme.texi (Selecting Signers): Fix reference count. 2002-08-21 Marcus Brinkmann * gpgme.texi (Header): Document name space. 2002-08-20 Marcus Brinkmann * gpgme.texi (Importing Keys): Document gpgme_op_import_ext. * gpgme.texi (Importing Keys): Undocument EOF. 2002-08-14 Werner Koch * gpgme.texi (Information About Keys): Changed GPGME_ATTR_TYPE. 2002-07-25 Marcus Brinkmann * gpgme.texi (Deleting Keys): Say that secret keys might not be deleted. 2002-07-25 Marcus Brinkmann * gpgme.texi (Information About Keys): Document (badly) the new key attributes. * gpgme.texi (Manipulating Data Buffers): Mention that backend tries to detect encoding automatically. 2002-07-03 Marcus Brinkmann * gpgme.texi (Run Control): Update this section. (Waiting For Completion): Likewise for this subsection. (Cancelling an Operation): Likewise for this subsection. (Using External Event Loops): New subsection with several subsubsections. 2002-06-28 Marcus Brinkmann * gpgme.texi (Multi Threading): Remove item about the need to synchronize anything against gpgme_wait (except gpgme_wait itself). 2002-06-27 Marcus Brinkmann * gpgme.texi (Information About Keys): Fix documentation for IDX. (Information About Trust Items): Likewise. 2002-06-26 Werner Koch * gpgme.texi (Importing Keys): Document the return value -1 of gpgme_op_import. 2002-06-20 Werner Koch * gpgme.texi (Verify): Explain the new whatidx variable. 2002-06-10 Werner Koch * gpgme.texi (Verify): Document attribute GPGME_ATTR_ERRTOK. 2002-06-04 Marcus Brinkmann * gpgme.texi (Multi Threading): Document new autodetection. 2002-06-04 Marcus Brinkmann * Makefile.am (DISTCLEANFILES): New variable. 2002-05-26 Marcus Brinkmann - * gpgme.texi: Some typographical correctons throughout. + * gpgme.texi: Some typographical corrections throughout. 2002-05-09 Marcus Brinkmann * gpgme.texi (Using Automake): New section. 2002-05-09 Marcus Brinkmann * gpgme.texi (Multi Threading): Escape { and }. 2002-05-09 Marcus Brinkmann * gpgme.texi (Overview): Replace note about thread-safeness. (Multi Threading): New section. 2002-05-03 Werner Koch * gpgme.texi (Manipulating Data Buffers): Changed some data types to void*. (Protocol Selection): Added gpgme_get_protocol. - (Verify): Updated to include the new attribute fucntions and + (Verify): Updated to include the new attribute functions and status codes. 2002-04-27 Werner Koch * gpgme.texi (Manipulating Data Buffers): New type GpgmeDataEncoding. 2002-04-23 Marcus Brinkmann * gpgme.texi (Passphrase Callback): Document that either return argument can be NULL. (Progress Meter Callback): Likewise. 2002-04-22 Marcus Brinkmann * gpgme.texi (Passphrase Callback): Fix small typo. Document the new function gpgme_get_passphrase_cb. (Progress Meter Callback): Document the new function gpgme_get_progress_cb. 2002-04-16 Marcus Brinkmann * gpgme.texi (Creating a Signature): Fix function name. Reported by Wichert Ackerman . 2002-03-29 Marcus Brinkmann * gpgme.texi (direntry): End index entry with a full stop. Patch submitted by Jose Carlos Garcia Sogo . 2002-03-17 Marcus Brinkmann * gpgme.texi (Detailed Results): Fix syntax error in last change. 2002-03-08 Werner Koch * gpgme.texi (Detailed Results): Import does also return info. 2002-03-06 Marcus Brinkmann * gpgme.texi (Encrypting a Plaintext): Document symmetric encryption. 2002-03-06 Marcus Brinkmann * gpgme.texi (Error Strings): Add example. * gpgme.texi (Listing Keys): Likewise. 2002-03-03 Marcus Brinkmann * gpgme.texi (Information About Keys): Document GPGME_ATTR_EXPIRE. 2002-03-03 Marcus Brinkmann * gpgme.texi (Verify): Document verification of normal and cleartext signatures. 2002-02-27 Marcus Brinkmann * gpgme.texi (Listing Keys): Document gpgme_op_keylist_ext_start. 2002-02-27 Marcus Brinkmann * gpgme.texi (Encrypting a Plaintext): Document GPGME_Invalid_Recipients. (Error Values): Likewise. 2002-02-26 Marcus Brinkmann * gpgme.texi (Encrypting a Plaintext): Document gpgme_op_encrypt_sign and gpgme_op_encrypt_sign_start. 2002-02-25 Marcus Brinkmann * gpgme.texi (Creating a Signature): Add a note about certificates to include. (Included Certificates): New section. 2002-02-09 Marcus Brinkmann * gpgme.texi (Detailed Results): Remove literal tags. (Generating Keys): Update documentation. * gpgme.texi (Generating Keys): Fix syntax error. 2002-02-06 Marcus Brinkmann * gpgme.texi (Waiting For Completion): Adjust doc to changes in the code. 2002-02-06 Marcus Brinkmann * gpgme.texi (Key Listing Mode): Update documentation. 2002-01-31 Marcus Brinkmann * gpgme.texi (Generating Keys): Document error at creation failure. 2002-01-30 Marcus Brinkmann * gpgme.texi (Deleting Keys): Document new error values. 2002-01-30 Marcus Brinkmann * gpgme.texi (Importing Keys): Add reference to gpgme_get_op_info. 2002-01-30 Marcus Brinkmann * gpgme.texi: Some spell checking. 2002-01-30 Marcus Brinkmann * gpgme.texi: Add all the gpgme_op_*_start functions. Fill the concept index with many, many entries. 2002-01-29 Marcus Brinkmann * gpgme.texi (Run Control): New section. - (Verify): Docuent gpgme_get_notation. + (Verify): Document gpgme_get_notation. (More Information): New section describing gpgme_get_op_info. 2002-01-22 Marcus Brinkmann * gpgme.texi (Passphrase callback): Change GpgmePassphraseCb's R_HD type from void* to void**. 2002-01-22 Marcus Brinkmann * gpgme.texi (Creating data buffers): Change gpgme_data_new_from_filepart's LENGTH type from off_t to size_t. 2002-01-22 Marcus Brinkmann * gpgme.texi (Generating keys): New subsection. (Exporting keys): Likewise. (Importing keys): Likewise. (Deleting keys): Likewise. 2002-01-16 Marcus Brinkmann * gpgme.texi: g10Code -> g10 Code * gpgme.texi (Top): Complete detailmenu. - * gpgme.texi: Convert embarassing cruft to the real thing. + * gpgme.texi: Convert embarrassing cruft to the real thing. 2002-01-16 Marcus Brinkmann * ChangeLog: New file. * gpgme.texi: Likewise. * gpl.texi: Likewise. * fdl.texi: Likewise. * Makefile.am (info_TEXINFOS): New variable. (gpgme_TEXINFOS): Likewise. Copyright (C) 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011 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 modifications, as long as this notice is preserved. This file is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY, to the extent permitted by law; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. diff --git a/doc/examples/show-group-options.c b/doc/examples/show-group-options.c index 48ca260e..3e102079 100644 --- a/doc/examples/show-group-options.c +++ b/doc/examples/show-group-options.c @@ -1,153 +1,153 @@ -/* show-group-options.c - Example code to retriev the group option. +/* show-group-options.c - Example code to retrieve the group option. Copyright (C) 2008 g10 Code 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 Lesser General Public License as published by the Free Software Foundation; either version 2.1 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 Lesser 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 . */ #include #include #include #include #include #include #define fail_if_err(err) \ do \ { \ if (err) \ { \ fprintf (stderr, "%s:%d: gpgme_error_t %s\n", \ __FILE__, __LINE__, gpgme_strerror (err)); \ exit (1); \ } \ } \ while (0) static void print_one_alias (const char *string) { const char *value, *s; size_t namelen; int first = 1; int any = 0; while (isascii (*string) && isspace (*string)) string++; value = strchr (string, '='); if (value) { for (s=value-1; s > string ; s--) if (!isascii (*s) || !isspace (*s)) break; } if (!value || s == value ) { printf ("# error: invalid group definition!\n"); return; } value++; namelen = (s + 1 - string); printf ("%.*s: ", (int)namelen, string); for (;;) { while (isascii (*value) && isspace (*value)) value++; if (!*value) break; for (s = value; *s && !(isascii (*s) && isspace (*s)); s++) ; printf ("%s%*s%.*s", first? "":",\n", any? (int)namelen+2:0, "", (int)(s-value), value); first = 0; any = 1; value = s; } putchar ('\n'); } static void print_gpgconf_string (const char *cname, const char *name) { gpg_error_t err; gpgme_ctx_t ctx; gpgme_conf_comp_t conf_list, conf; gpgme_conf_opt_t opt; gpgme_conf_arg_t value; err = gpgme_new (&ctx); fail_if_err (err); err = gpgme_op_conf_load (ctx, &conf_list); fail_if_err (err); for (conf = conf_list; conf; conf = conf->next) { if ( !strcmp (conf->name, cname) ) { for (opt = conf->options; opt; opt = opt->next) if ( !(opt->flags & GPGME_CONF_GROUP) && !strcmp (opt->name, name)) { for (value = opt->value; value; value = value->next) { if (opt->type == GPGME_CONF_ALIAS_LIST) print_one_alias (value->value.string); } break; } break; } } gpgme_conf_release (conf_list); gpgme_release (ctx); } int main (int argc, char **argv ) { gpgme_check_version (NULL); setlocale (LC_ALL, ""); gpgme_set_locale (NULL, LC_CTYPE, setlocale (LC_CTYPE, NULL)); #ifndef HAVE_W32_SYSTEM gpgme_set_locale (NULL, LC_MESSAGES, setlocale (LC_MESSAGES, NULL)); #endif print_gpgconf_string ("gpg", "group"); return 0; } /* Local Variables: compile-command: "cc -o show-group-options show-group-options.c -lgpgme" End: */ diff --git a/doc/gpgme.texi b/doc/gpgme.texi index fc4840ee..7d410f83 100644 --- a/doc/gpgme.texi +++ b/doc/gpgme.texi @@ -1,8337 +1,8337 @@ \input texinfo @c -*- mode: texinfo; coding: utf-8; -*- @documentencoding UTF-8 @setfilename gpgme.info @include defs.inc @settitle The `GnuPG Made Easy' Reference Manual @dircategory GNU Libraries @direntry * @acronym{GPGME}: (gpgme). Adding support for cryptography to your program. @end direntry @c Unify some of the indices. @syncodeindex tp fn @syncodeindex pg fn @copying Copyright @copyright{} 2002--2008, 2010, 2012--2018 g10 Code GmbH. @quotation Permission is granted to copy, distribute and/or modify this document under the terms of the GNU General Public License as published by the Free Software Foundation; either version 3 of the License, or (at your option) any later version. The text of the license can be found in the section entitled ``Copying''. @end quotation This document 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 General Public License for more details. @end copying @c Macros used by the description of the UI server protocol @macro clnt{string} @sc{c:} \string\ @end macro @macro srvr{string} @sc{s:} \string\ @end macro @c API version. @macro since{string} @sc{Since:} \string\ @end macro @c @c T I T L E P A G E @c @ifinfo This file documents the @acronym{GPGME} library. This is Edition @value{EDITION}, last updated @value{UPDATED}, of @cite{The `GnuPG Made Easy' Reference Manual}, for Version @value{VERSION}. @c NOTE: Don't forget to update the year for the TeX version, too. @insertcopying @end ifinfo @c We do not want that bastard short titlepage. @c @iftex @c @shorttitlepage The `GnuPG Made Easy' Reference Manual @c @end iftex @titlepage @center @titlefont{The `GnuPG Made Easy'} @sp 1 @center @titlefont{Reference Manual} @sp 6 @center Edition @value{EDITION} @sp 1 @center last updated @value{UPDATED} @sp 1 @center for version @value{VERSION} @page @vskip 0pt plus 1filll Published by The GnuPG Project@* c/o g10 Code GmbH@* Hüttenstr. 61@* 40699 Erkrath, Germany @insertcopying @end titlepage @page @summarycontents @contents @ifnottex @node Top @top Main Menu This is Edition @value{EDITION}, last updated @value{UPDATED}, of @cite{The `GnuPG Made Easy' Reference Manual}, for Version @value{VERSION} of the @acronym{GPGME} library. @end ifnottex @menu * Introduction:: How to use this manual. * Preparation:: What you should do before using the library. * Protocols and Engines:: Supported crypto protocols. * Algorithms:: Supported algorithms. * Error Handling:: Error numbers and their meanings. * Exchanging Data:: Passing data to and from @acronym{GPGME}. * Contexts:: Handling @acronym{GPGME} contexts. Appendices * UI Server Protocol:: The GnuPG UI Server Protocol. * Debugging:: How to solve problems. * Deprecated Functions:: Documentation of deprecated functions. * Library Copying:: The GNU Lesser General Public License says how you can copy and share `GnuPG Made Easy'. * Copying:: The GNU General Public License says how you can copy and share this manual. Indices * Concept Index:: Index of concepts and programs. * Function and Data Index:: Index of functions, variables and data types. @detailmenu --- The Detailed Node Listing --- Introduction * Getting Started:: Purpose of the manual, and how to use it. * Features:: Reasons to install and use @acronym{GPGME}. * Overview:: Basic architecture of the @acronym{GPGME} library. Preparation * Header:: What header file you need to include. * Building the Source:: Compiler options to be used. * Largefile Support (LFS):: How to use @acronym{GPGME} with LFS. * Using Automake:: Compiler options to be used the easy way. * Using Libtool:: Avoiding compiler options entirely. * Library Version Check:: Getting and verifying the library version. * Signal Handling:: How @acronym{GPGME} affects signal handling. * Multi-Threading:: How @acronym{GPGME} can be used in an MT environment. Protocols and Engines * Engine Version Check:: Verifying the engine version. * Engine Information:: Obtaining more information about the engines. * Engine Configuration:: Changing the engine configuration. * OpenPGP:: Support for the OpenPGP protocol. * Cryptographic Message Syntax:: Support for the CMS. Algorithms * Public Key Algorithms:: A list of all public key algorithms. * Hash Algorithms:: A list of all hash algorithms. Error Handling * Error Values:: The error value and what it means. * Error Codes:: A list of important error codes. * Error Sources:: A list of important error sources. * Error Strings:: How to get a descriptive string from a value. Exchanging Data * Creating Data Buffers:: Creating new data buffers. * Destroying Data Buffers:: Releasing data buffers. * Manipulating Data Buffers:: Operations on data buffers. Creating Data Buffers * Memory Based Data Buffers:: Creating memory based data buffers. * File Based Data Buffers:: Creating file based data buffers. * Callback Based Data Buffers:: Creating callback based data buffers. Manipulating Data Buffers * Data Buffer I/O Operations:: I/O operations on data buffers. * Data Buffer Meta-Data:: Meta-data manipulation of data buffers. * Data Buffer Convenience:: Convenience function for data buffers. Contexts * Creating Contexts:: Creating new @acronym{GPGME} contexts. * Destroying Contexts:: Releasing @acronym{GPGME} contexts. * Result Management:: Managing the result of crypto operations. * Context Attributes:: Setting properties of a context. * Key Management:: Managing keys with @acronym{GPGME}. * Trust Item Management:: Managing trust items with @acronym{GPGME}. * Crypto Operations:: Using a context for cryptography. * Miscellaneous:: Miscellaneous operations. * Run Control:: Controlling how operations are run. Context Attributes * Protocol Selection:: Selecting the protocol used by a context. * Crypto Engine:: Configuring the crypto engine. * Setting the Sender:: How to tell the engine the sender. * ASCII Armor:: Requesting @acronym{ASCII} armored output. * Text Mode:: Choosing canonical text mode. * Offline Mode:: Choosing offline mode. * Included Certificates:: Including a number of certificates. * Key Listing Mode:: Selecting key listing mode. * Passphrase Callback:: Getting the passphrase from the user. * Progress Meter Callback:: Being informed about the progress. * Status Message Callback:: Status messages received from gpg. * Locale:: Setting the locale of a context. Key Management * Key objects:: Description of the key structures. * Listing Keys:: Browsing the list of available keys. * Information About Keys:: Requesting detailed information about keys. * Manipulating Keys:: Operations on keys. * Generating Keys:: Creating new key pairs. * Signing Keys:: Adding key signatures to public keys. * Exporting Keys:: Retrieving key data from the key ring. * Importing Keys:: Adding keys to the key ring. * Deleting Keys:: Removing keys from the key ring. * Changing Passphrases:: Change the passphrase of a key. * Changing TOFU Data:: Changing data pertaining to TOFU. * Advanced Key Editing:: Advanced key edit operation. Trust Item Management * Listing Trust Items:: Browsing the list of available trust items. * Manipulating Trust Items:: Operations on trust items. Crypto Operations * Decrypt:: Decrypting a ciphertext. * Verify:: Verifying a signature. * Decrypt and Verify:: Decrypting a signed ciphertext. * Sign:: Creating a signature. * Encrypt:: Encrypting a plaintext. Sign * Selecting Signers:: How to choose the keys to sign with. * Creating a Signature:: How to create a signature. * Signature Notation Data:: How to add notation data to a signature. Encrypt * Encrypting a Plaintext:: How to encrypt a plaintext. Miscellaneous * Running other Programs:: Running other Programs. * Using the Assuan protocol:: Using the Assuan protocol. * Checking for updates:: How to check for software updates. Run Control * Waiting For Completion:: Waiting until an operation is completed. * Using External Event Loops:: Advanced control over what happens when. * Cancellation:: How to end pending operations prematurely. Using External Event Loops * I/O Callback Interface:: How I/O callbacks are registered. * Registering I/O Callbacks:: How to use I/O callbacks for a context. * I/O Callback Example:: An example how to use I/O callbacks. * I/O Callback Example GTK+:: How to integrate @acronym{GPGME} in GTK+. * I/O Callback Example GDK:: How to integrate @acronym{GPGME} in GDK. * I/O Callback Example Qt:: How to integrate @acronym{GPGME} in Qt. @end detailmenu @end menu @node Introduction @chapter Introduction `GnuPG Made Easy' (@acronym{GPGME}) is a C language library that allows to add support for cryptography to a program. It is designed to make access to public key crypto engines like GnuPG or GpgSM easier for applications. @acronym{GPGME} provides a high-level crypto API for encryption, decryption, signing, signature verification and key management. @acronym{GPGME} uses GnuPG and GpgSM as its backends to support OpenPGP and the Cryptographic Message Syntax (CMS). @menu * Getting Started:: Purpose of the manual, and how to use it. * Features:: Reasons to install and use @acronym{GPGME}. * Overview:: Basic architecture of the @acronym{GPGME} library. @end menu @node Getting Started @section Getting Started This manual documents the @acronym{GPGME} library programming interface. All functions and data types provided by the library are explained. The reader is assumed to possess basic knowledge about cryptography in general, and public key cryptography in particular. The underlying cryptographic engines that are used by the library are not explained, but where necessary, special features or requirements by an engine are mentioned as far as they are relevant to @acronym{GPGME} or its users. This manual can be used in several ways. If read from the beginning to the end, it gives a good introduction into the library and how it can be used in an application. Forward references are included where necessary. Later on, the manual can be used as a reference manual to get just the information needed about any particular interface of the library. Experienced programmers might want to start looking at the examples at the end of the manual, and then only read up those parts of the interface which are unclear. The documentation for the language bindings is currently not included in this manual. Those languages bindings follow the general programming model of @acronym{GPGME} but may provide some extra high level abstraction on top of the @acronym{GPGME} style API. For now please see the README files in the @file{lang/} directory of the source distribution. @node Features @section Features @acronym{GPGME} has a couple of advantages over other libraries doing a similar job, and over implementing support for GnuPG or other crypto engines into your application directly. @table @asis @item it's free software Anybody can use, modify, and redistribute it under the terms of the GNU Lesser General Public License (@pxref{Library Copying}). @item it's flexible @acronym{GPGME} provides transparent support for several cryptographic protocols by different engines. Currently, @acronym{GPGME} supports the OpenPGP protocol using GnuPG as the backend, and the Cryptographic Message Syntax using GpgSM as the backend. @item it's easy @acronym{GPGME} hides the differences between the protocols and engines from the programmer behind an easy-to-use interface. This way the programmer can focus on the other parts of the program, and still integrate strong cryptography in his application. Once support for @acronym{GPGME} has been added to a program, it is easy to add support for other crypto protocols once @acronym{GPGME} backends provide them. @item it's language friendly @acronym{GPGME} comes with languages bindings for several common programming languages: Common Lisp, C++, Python 2, and Python 3. @end table @node Overview @section Overview @acronym{GPGME} provides a data abstraction that is used to pass data to the crypto engine, and receive returned data from it. Data can be read from memory or from files, but it can also be provided by a callback function. The actual cryptographic operations are always set within a context. A context provides configuration parameters that define the behaviour of all operations performed within it. Only one operation per context is allowed at any time, but when one operation is finished, you can run the next operation in the same context. There can be more than one context, and all can run different operations at the same time. Furthermore, @acronym{GPGME} has rich key management facilities including listing keys, querying their attributes, generating, importing, exporting and deleting keys, and acquiring information about the trust path. With some precautions, @acronym{GPGME} can be used in a multi-threaded environment, although it is not completely thread safe and thus needs the support of the application. @node Preparation @chapter Preparation To use @acronym{GPGME}, you have to perform some changes to your sources and the build system. The necessary changes are small and explained in the following sections. At the end of this chapter, it is described how the library is initialized, and how the requirements of the library are verified. @menu * Header:: What header file you need to include. * Building the Source:: Compiler options to be used. * Largefile Support (LFS):: How to use @acronym{GPGME} with LFS. * Using Automake:: Compiler options to be used the easy way. * Using Libtool:: Avoiding compiler options entirely. * Library Version Check:: Getting and verifying the library version. * Signal Handling:: How @acronym{GPGME} affects signal handling. * Multi-Threading:: How @acronym{GPGME} can be used in an MT environment. @end menu @node Header @section Header @cindex header file @cindex include file All interfaces (data types and functions) of the library are defined in the header file `gpgme.h'. You must include this in all programs using the library, either directly or through some other header file, like this: @example #include @end example The name space of @acronym{GPGME} is @code{gpgme_*} for function names and data types and @code{GPGME_*} for other symbols. Symbols internal to @acronym{GPGME} take the form @code{_gpgme_*} and @code{_GPGME_*}. Because @acronym{GPGME} makes use of the GPG Error library, using @acronym{GPGME} will also use the @code{GPG_ERR_*} name space directly, and the @code{gpg_err*}, @code{gpg_str*}, and @code{gpgrt_*} name space indirectly. @node Building the Source @section Building the Source @cindex compiler options @cindex compiler flags If you want to compile a source file including the `gpgme.h' header file, you must make sure that the compiler can find it in the directory hierarchy. This is accomplished by adding the path to the directory in which the header file is located to the compilers include file search path (via the @option{-I} option). However, the path to the include file is determined at the time the source is configured. To solve this problem, gpgme ships with a small helper program @command{gpgme-config} that knows about the path to the include file and other configuration options. The options that need to be added to the compiler invocation at compile time are output by the @option{--cflags} option to @command{gpgme-config}. The following example shows how it can be used at the command line: @example gcc -c foo.c `gpgme-config --cflags` @end example Adding the output of @samp{gpgme-config --cflags} to the compiler command line will ensure that the compiler can find the @acronym{GPGME} header file. A similar problem occurs when linking the program with the library. Again, the compiler has to find the library files. For this to work, the path to the library files has to be added to the library search path (via the @option{-L} option). For this, the option @option{--libs} to @command{gpgme-config} can be used. For convenience, this option also outputs all other options that are required to link the program with @acronym{GPGME} (in particular, the @samp{-lgpgme} option). The example shows how to link @file{foo.o} with the @acronym{GPGME} library to a program @command{foo}. @example gcc -o foo foo.o `gpgme-config --libs` @end example Of course you can also combine both examples to a single command by specifying both options to @command{gpgme-config}: @example gcc -o foo foo.c `gpgme-config --cflags --libs` @end example If you need to detect the installed language bindings you can use list them using: @example gpgme-config --print-lang @end example or test for the availability using @example gpgme-config --have-lang=python && echo 'Bindings for Pythons available' @end example @node Largefile Support (LFS) @section Largefile Support (LFS) @cindex largefile support @cindex LFS @acronym{GPGME} is compiled with largefile support by default, if it is available on the system. This means that GPGME supports files larger than two gigabyte in size, if the underlying operating system can. On some systems, largefile support is already the default. On such systems, nothing special is required. However, some systems provide only support for files up to two gigabyte in size by default. Support for larger file sizes has to be specifically enabled. To make a difficult situation even more complex, such systems provide two different types of largefile support. You can either get all relevant functions replaced with alternatives that are largefile capable, or you can get new functions and data types for largefile support added. Those new functions have the same name as their smallfile counterparts, but with a suffix of 64. An example: The data type @code{off_t} is 32 bit wide on GNU/Linux PC systems. To address offsets in large files, you can either enable largefile support add-on. Then a new data type @code{off64_t} is provided, which is 64 bit wide. Or you can replace the existing @code{off_t} data type with its 64 bit wide counterpart. All occurrences of @code{off_t} are then automagically replaced. As if matters were not complex enough, there are also two different types of file descriptors in such systems. This is important because if file descriptors are exchanged between programs that use a different maximum file size, certain errors must be produced on some file descriptors to prevent subtle overflow bugs from occurring. As you can see, supporting two different maximum file sizes at the same time is not at all an easy task. However, the maximum file size does matter for @acronym{GPGME}, because some data types it uses in its interfaces are affected by that. For example, the @code{off_t} data type is used in the @code{gpgme_data_seek} function, to match its @acronym{POSIX} counterpart. This affects the call-frame of the function, and thus the ABI of the library. Furthermore, file descriptors can be exchanged between GPGME and the application. For you as the user of the library, this means that your program must be compiled in the same file size mode as the library. Luckily, there is absolutely no valid reason for new programs to not enable largefile support by default and just use that. The compatibility modes (small file sizes or dual mode) can be considered an historic artefact, only useful to allow for a transitional period. On POSIX platforms @acronym{GPGME} is compiled using largefile support by default. This means that your application must do the same, at least as far as it is relevant for using the @file{gpgme.h} header file. All types in this header files refer to their largefile counterparts, if they are different from any default types on the system. On 32 and 64 bit Windows platforms @code{off_t} is declared as 32 bit signed integer. There is no specific support for LFS in the C library. The recommendation from Microsoft is to use the native interface (@code{CreateFile} et al.) for large files. Released binary versions of @acronym{GPGME} (libgpgme-11.dll) have always been build with a 32 bit @code{off_t}. To avoid an ABI break we stick to this convention for 32 bit Windows by using @code{long} there. @acronym{GPGME} versions for 64 bit Windows have never been released 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 @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 might suffer from a severe break. Thus with version 1.4.2 we redefined all functions using @code{off_t} to use @code{gpgme_off_t} which is defined as explained above. This way we keep the ABI well defined and independent of any toolchain hacks. The bottom line is that LFS support in @acronym{GPGME} is only available on 64 bit versions of Windows. On POSIX platforms you can enable largefile support, if it is different from the default on the system the application is compiled on, by using the Autoconf macro @code{AC_SYS_LARGEFILE}. If you do this, then you don't need to worry about anything else: It will just work. In this case you might also want to use @code{AC_FUNC_FSEEKO} to take advantage of some new interfaces, and @code{AC_TYPE_OFF_T} (just in case). If you do not use Autoconf, you can define the preprocessor symbol @code{_FILE_OFFSET_BITS} to 64 @emph{before} including any header files, for example by specifying the option @code{-D_FILE_OFFSET_BITS=64} on the compiler command line. You will also want to define the preprocessor symbol @code{LARGEFILE_SOURCE} to 1 in this case, to take advantage of some new interfaces. If you do not want to do either of the above, you probably know enough about the issue to invent your own solution. Just keep in mind that the @acronym{GPGME} header file expects that largefile support is enabled, if it is available. In particular, we do not support dual mode (@code{_LARGEFILE64_SOURCE}). @node Using Automake @section Using Automake @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{gpgme-config} script at all. @acronym{GPGME} provides an extension to Automake that does all the work for you. @c A simple macro for optional variables. @macro ovar{varname} @r{[}@var{\varname\}@r{]} @end macro @defmac AM_PATH_GPGME (@ovar{minimum-version}, @ovar{action-if-found}, @ovar{action-if-not-found}) @defmacx AM_PATH_GPGME_PTH (@ovar{minimum-version}, @ovar{action-if-found}, @ovar{action-if-not-found}) @defmacx AM_PATH_GPGME_PTHREAD (@ovar{minimum-version}, @ovar{action-if-found}, @ovar{action-if-not-found}) Check whether @acronym{GPGME} (at least version @var{minimum-version}, if given) exists on the host system. If it is found, execute @var{action-if-found}, otherwise do @var{action-if-not-found}, if given. Additionally, the function defines @code{GPGME_CFLAGS} to the flags needed for compilation of the program to find the @file{gpgme.h} header file, and @code{GPGME_LIBS} to the linker flags needed to link the program to the @acronym{GPGME} library. If the used helper script does not match the target type you are building for a warning is printed and the string @code{libgcrypt} is appended to the variable @code{gpg_config_script_warn}. @code{AM_PATH_GPGME_PTH} checks for the version of @acronym{GPGME} that can be used with GNU Pth, and defines @code{GPGME_PTH_CFLAGS} and @code{GPGME_PTH_LIBS}. @code{AM_PATH_GPGME_PTHREAD} checks for the version of @acronym{GPGME} that can be used with the native pthread implementation, and defines @code{GPGME_PTHREAD_CFLAGS} and @code{GPGME_PTHREAD_LIBS}. Since version 1.8.0 this is no longer required to GPGME_PTHREAD as @acronym{GPGME} itself is thread safe. This macro searches for @command{gpgme-config} along the PATH. If you are cross-compiling, it is useful to set the environment variable @code{SYSROOT} to the top directory of your target. The macro will then first look for the helper program in the @file{bin} directory below that top directory. An absolute directory name must be used for @code{SYSROOT}. Finally, if the configure command line option @code{--with-gpgme-prefix} is used, only its value is used for the top directory below which the helper script is expected. @end defmac You can use the defined Autoconf variables like this in your @file{Makefile.am}: @example AM_CPPFLAGS = $(GPGME_CFLAGS) LDADD = $(GPGME_LIBS) @end example @node Using Libtool @section Using Libtool @cindex libtool The easiest way is to just use GNU Libtool. If you use libtool, and link to @code{libgpgme.la}, @code{libgpgme-pth.la} or @code{libgpgme-pthread.la} respectively, everything will be done automatically by Libtool. @node Library Version Check @section Library Version Check @cindex version check, of the library @deftypefun {const char *} gpgme_check_version (@w{const char *@var{required_version}}) The function @code{gpgme_check_version} has four purposes. It can be used to retrieve the version number of the library. In addition it can verify that the version number is higher than a certain required version number. In either case, the function initializes some sub-systems, and for this reason alone it must be invoked early in your program, before you make use of the other functions in @acronym{GPGME}. The last purpose is to run selftests. As a side effect for W32 based systems, the socket layer will get initialized. If @var{required_version} is @code{NULL}, the function returns a pointer to a statically allocated string containing the version number of the library. If @var{required_version} is not @code{NULL}, it should point to a string containing a version number, and the function checks that the version of the library is at least as high as the version number provided. In this case, the function returns a pointer to a statically allocated string containing the version number of the library. If @var{REQUIRED_VERSION} is not a valid version number, or if the version requirement is not met, the function returns @code{NULL}. If you use a version of a library that is backwards compatible with older releases, but contains additional interfaces which your program uses, this function provides a run-time check if the necessary features are provided by the installed version of the library. If a selftest fails, the function may still succeed. Selftest errors are returned later when invoking @code{gpgme_new} or @code{gpgme-data_new}, so that a detailed error code can be returned (historically, @code{gpgme_check_version} does not return a detailed error code). @end deftypefun @deftypefun {int} gpgme_set_global_flag @ (@w{const char *@var{name}}, @ @w{const char *@var{value}}) @since{1.4.0} On some systems it is not easy to set environment variables and thus hard to use @acronym{GPGME}'s internal trace facility for debugging. This function has been introduced as an alternative way to enable debugging and for a couple of other rarely used tweaks. It is important to assure that only one thread accesses @acronym{GPGME} functions between a call to this function and after the return from the call to @code{gpgme_check_version}. All currently supported features require that this function is called as early as possible --- even before @code{gpgme_check_version}. The features are identified by the following values for @var{name}: @table @code @item debug To enable debugging use the string ``debug'' for @var{name} and @var{value} identical to the value used with the environment variable @code{GPGME_DEBUG}. @item disable-gpgconf Using this feature with any @var{value} disables the detection of the gpgconf program and thus forces GPGME to fallback into the simple OpenPGP only mode. It may be used to force the use of GnuPG-1 on systems which have both GPG versions installed. Note that in general the use of @code{gpgme_set_engine_info} is a better way to select a specific engine version. @item gpgconf-name @itemx gpg-name Set the name of the gpgconf respective gpg binary. The defaults are @code{GNU/GnuPG/gpgconf} and @code{GNU/GnuPG/gpg}. Under Unix the leading directory part is ignored. Under Windows the leading directory part is used as the default installation directory; the @code{.exe} suffix is added by GPGME. Use forward slashed even under Windows. @item require-gnupg -Set the mimimum version of the required GnuPG engine. If that version +Set the minimum version of the required GnuPG engine. If that version is not met, GPGME fails early instead of trying to use the existent version. The given version must be a string with major, minor, and micro number. Example: "2.1.0". @item w32-inst-dir On Windows GPGME needs to know its installation directory to find its spawn helper. This is in general no problem because a DLL has this information. Some applications however link statically to GPGME and thus GPGME can only figure out the installation directory of this application which may be wrong in certain cases. By supplying an installation directory as value to this flag, GPGME will assume that that directory is the installation directory. This flag has no effect on non-Windows platforms. @end table This function returns @code{0} on success. In contrast to other functions the non-zero return value on failure does not convey any error code. For setting ``debug'' the only possible error cause is an out of memory condition; which would exhibit itself later anyway. Thus the return value may be ignored. @end deftypefun After initializing @acronym{GPGME}, you should set the locale information to the locale required for your output terminal. This locale information is needed for example for the curses and Gtk pinentry. Here is an example of a complete initialization: @example #include #include void init_gpgme (void) @{ /* Initialize the locale environment. */ setlocale (LC_ALL, ""); gpgme_check_version (NULL); gpgme_set_locale (NULL, LC_CTYPE, setlocale (LC_CTYPE, NULL)); #ifdef LC_MESSAGES gpgme_set_locale (NULL, LC_MESSAGES, setlocale (LC_MESSAGES, NULL)); #endif @} @end example Note that you are highly recommended to initialize the locale settings like this. @acronym{GPGME} can not do this for you because it would not be thread safe. The conditional on LC_MESSAGES is only necessary for portability to W32 systems. @node Signal Handling @section Signal Handling @cindex signals @cindex signal handling The @acronym{GPGME} library communicates with child processes (the crypto engines). If a child process dies unexpectedly, for example due to a bug, or system problem, a @code{SIGPIPE} signal will be delivered to the application. The default action is to abort the program. To protect against this, @code{gpgme_check_version} sets the @code{SIGPIPE} signal action to @code{SIG_IGN}, which means that the signal will be ignored. @acronym{GPGME} will only do that if the signal action for @code{SIGPIPE} is @code{SIG_DEF} at the time @code{gpgme_check_version} is called. If it is something different, @code{GPGME} will take no action. This means that if your application does not install any signal handler for @code{SIGPIPE}, you don't need to take any precautions. If you do install a signal handler for @code{SIGPIPE}, you must be prepared to handle any @code{SIGPIPE} events that occur due to @acronym{GPGME} writing to a defunct pipe. Furthermore, if your application is multi-threaded, and you install a signal action for @code{SIGPIPE}, you must make sure you do this either before @code{gpgme_check_version} is called or afterwards. @node Multi-Threading @section Multi-Threading @cindex thread-safeness @cindex multi-threading The @acronym{GPGME} library is mostly thread-safe, and can be used in a multi-threaded environment but there are some requirements for multi-threaded use: @itemize @bullet @item The function @code{gpgme_check_version} must be called before any other function in the library, because it initializes the thread support subsystem in @acronym{GPGME}. To achieve this in multi-threaded programs, you must synchronize the memory with respect to other threads that also want to use @acronym{GPGME}. For this, it is sufficient to call @code{gpgme_check_version} before creating the other threads using @acronym{GPGME}@footnote{At least this is true for POSIX threads, as @code{pthread_create} is a function that synchronizes memory with respects to other threads. There are many functions which have this property, a complete list can be found in POSIX, IEEE Std 1003.1-2003, Base Definitions, Issue 6, in the definition of the term ``Memory Synchronization''. For other thread packages other, more relaxed or more strict rules may apply.}. @item Any @code{gpgme_data_t} and @code{gpgme_ctx_t} object must only be accessed by one thread at a time. If multiple threads want to deal with the same object, the caller has to make sure that operations on that object are fully synchronized. @item Only one thread at any time is allowed to call @code{gpgme_wait}. If multiple threads call this function, the caller must make sure that all invocations are fully synchronized. It is safe to start asynchronous operations while a thread is running in gpgme_wait. @item The function @code{gpgme_strerror} is not thread safe. You have to use @code{gpgme_strerror_r} instead. @end itemize @node Protocols and Engines @chapter Protocols and Engines @cindex protocol @cindex engine @cindex crypto engine @cindex backend @cindex crypto backend @acronym{GPGME} supports several cryptographic protocols, however, it does not implement them. Rather it uses backends (also called engines) which implement the protocol. @acronym{GPGME} uses inter-process communication to pass data back and forth between the application and the backend, but the details of the communication protocol and invocation of the backend is completely hidden by the interface. All complexity is handled by @acronym{GPGME}. Where an exchange of information between the application and the backend is necessary, @acronym{GPGME} provides the necessary callback function hooks and further interfaces. @deftp {Data type} {enum gpgme_protocol_t} @tindex gpgme_protocol_t The @code{gpgme_protocol_t} type specifies the set of possible protocol values that are supported by @acronym{GPGME}. The following protocols are supported: @table @code @item GPGME_PROTOCOL_OpenPGP @itemx GPGME_PROTOCOL_OPENPGP This specifies the OpenPGP protocol. @item GPGME_PROTOCOL_CMS This specifies the Cryptographic Message Syntax. @item GPGME_PROTOCOL_GPGCONF Under development. Please ask on @email{gnupg-devel@@gnupg.org} for help. @item GPGME_PROTOCOL_ASSUAN @since{1.2.0} This specifies the raw Assuan protocol. @item GPGME_PROTOCOL_G13 @since{1.3.0} Under development. Please ask on @email{gnupg-devel@@gnupg.org} for help. @item GPGME_PROTOCOL_UISERVER Under development. Please ask on @email{gnupg-devel@@gnupg.org} for help. @item GPGME_PROTOCOL_SPAWN @since{1.5.0} Special protocol for use with @code{gpgme_op_spawn}. @item GPGME_PROTOCOL_UNKNOWN Reserved for future extension. You may use this to indicate that the used protocol is not known to the application. Currently, @acronym{GPGME} does not accept this value in any operation, though, except for @code{gpgme_get_protocol_name}. @end table @end deftp @deftypefun {const char *} gpgme_get_protocol_name (@w{gpgme_protocol_t @var{protocol}}) The function @code{gpgme_get_protocol_name} returns a statically allocated string describing the protocol @var{protocol}, or @code{NULL} if the protocol number is not valid. @end deftypefun @menu * Engine Version Check:: Verifying the engine version. * Engine Information:: Obtaining more information about the engines. * Engine Configuration:: Changing the engine configuration. * OpenPGP:: Support for the OpenPGP protocol. * Cryptographic Message Syntax:: Support for the CMS. * Assuan:: Support for the raw Assuan protocol. @end menu @node Engine Version Check @section Engine Version Check @cindex version check, of the engines @deftypefun @w{const char *} gpgme_get_dirinfo (@w{cons char *@var{what}}) @since{1.5.0} The function @code{gpgme_get_dirinfo} returns a statically allocated string with the value associated to @var{what}. The returned values are the defaults and won't change even after @code{gpgme_set_engine_info} has been used to configure a different engine. @code{NULL} is returned if no value is available. Commonly supported values for @var{what} are: @table @code @item homedir Return the default home directory. @item sysconfdir Return the name of the system configuration directory @item bindir Return the name of the directory with GnuPG program files. @item libdir Return the name of the directory with GnuPG related library files. @item libexecdir Return the name of the directory with GnuPG helper program files. @item datadir Return the name of the directory with GnuPG shared data. @item localedir Return the name of the directory with GnuPG locale data. @item agent-socket Return the name of the socket to connect to the gpg-agent. @item agent-ssh-socket Return the name of the socket to connect to the ssh-agent component of gpg-agent. @item dirmngr-socket Return the name of the socket to connect to the dirmngr. @item uiserver-socket Return the name of the socket to connect to the user interface server. @item gpgconf-name Return the file name of the engine configuration tool. @item gpg-name Return the file name of the OpenPGP engine. @item gpgsm-name Return the file name of the CMS engine. @item g13-name Return the name of the file container encryption engine. @item gpg-wks-client-name Return the name of the Web Key Service tool. @end table @end deftypefun @deftypefun gpgme_error_t gpgme_engine_check_version (@w{gpgme_protocol_t @var{protocol}}) The function @code{gpgme_engine_check_version} verifies that the engine implementing the protocol @var{PROTOCOL} is installed in the expected path and meets the version requirement of @acronym{GPGME}. This function returns the error code @code{GPG_ERR_NO_ERROR} if the engine is available and @code{GPG_ERR_INV_ENGINE} if it is not. @end deftypefun @node Engine Information @section Engine Information @cindex engine, information about @deftp {Data type} {gpgme_engine_info_t} @tindex gpgme_protocol_t The @code{gpgme_engine_info_t} type specifies a pointer to a structure describing a crypto engine. The structure contains the following elements: @table @code @item gpgme_engine_info_t next This is a pointer to the next engine info structure in the linked list, or @code{NULL} if this is the last element. @item gpgme_protocol_t protocol This is the protocol for which the crypto engine is used. You can convert this to a string with @code{gpgme_get_protocol_name} for printing. @item const char *file_name This is a string holding the file name of the executable of the crypto engine. Currently, it is never @code{NULL}, but using @code{NULL} is reserved for future use, so always check before you use it. @item const char *home_dir This is a string holding the directory name of the crypto engine's configuration directory. If it is @code{NULL}, then the default directory is used. See @code{gpgme_get_dirinfo} on how to get the default directory. @item const char *version This is a string containing the version number of the crypto engine. It might be @code{NULL} if the version number can not be determined, for example because the executable doesn't exist or is invalid. @item const char *req_version This is a string containing the minimum required version number of the crypto engine for @acronym{GPGME} to work correctly. This is the version number that @code{gpgme_engine_check_version} verifies against. Currently, it is never @code{NULL}, but using @code{NULL} is reserved for future use, so always check before you use it. @end table @end deftp @deftypefun gpgme_error_t gpgme_get_engine_info (@w{gpgme_engine_info_t *@var{info}}) The function @code{gpgme_get_engine_info} returns a linked list of engine info structures in @var{info}. Each info structure describes the defaults of one configured backend. The memory for the info structures is allocated the first time this function is invoked, and must not be freed by the caller. This function returns the error code @code{GPG_ERR_NO_ERROR} if successful, and a system error if the memory could not be allocated. @end deftypefun Here is an example how you can provide more diagnostics if you receive an error message which indicates that the crypto engine is invalid. @example gpgme_ctx_t ctx; gpgme_error_t err; [...] if (gpgme_err_code (err) == GPG_ERR_INV_ENGINE) @{ gpgme_engine_info_t info; err = gpgme_get_engine_info (&info); if (!err) @{ while (info && info->protocol != gpgme_get_protocol (ctx)) info = info->next; if (!info) fprintf (stderr, "GPGME compiled without support for protocol %s", gpgme_get_protocol_name (info->protocol)); else if (info->file_name && !info->version) fprintf (stderr, "Engine %s not installed properly", info->file_name); else if (info->file_name && info->version && info->req_version) fprintf (stderr, "Engine %s version %s installed, " "but at least version %s required", info->file_name, info->version, info->req_version); else fprintf (stderr, "Unknown problem with engine for protocol %s", gpgme_get_protocol_name (info->protocol)); @} @} @end example @node Engine Configuration @section Engine Configuration @cindex engine, configuration of @cindex configuration of crypto backend You can change the configuration of a backend engine, and thus change the executable program and configuration directory to be used. You can make these changes the default or set them for some contexts individually. @deftypefun gpgme_error_t gpgme_set_engine_info (@w{gpgme_protocol_t @var{proto}}, @w{const char *@var{file_name}}, @w{const char *@var{home_dir}}) @since{1.1.0} The function @code{gpgme_set_engine_info} changes the default configuration of the crypto engine implementing the protocol @var{proto}. @var{file_name} is the file name of the executable program implementing this protocol, and @var{home_dir} is the directory name of the configuration directory for this crypto engine. If @var{home_dir} is @code{NULL}, the engine's default will be used. The new defaults are not applied to already created GPGME contexts. This function returns the error code @code{GPG_ERR_NO_ERROR} if successful, or an error code on failure. @end deftypefun The functions @code{gpgme_ctx_get_engine_info} and @code{gpgme_ctx_set_engine_info} can be used to change the engine configuration per context. @xref{Crypto Engine}. @node OpenPGP @section OpenPGP @cindex OpenPGP @cindex GnuPG @cindex protocol, GnuPG @cindex engine, GnuPG OpenPGP is implemented by GnuPG, the @acronym{GNU} Privacy Guard. This is the first protocol that was supported by @acronym{GPGME}. The OpenPGP protocol is specified by @code{GPGME_PROTOCOL_OpenPGP}. @node Cryptographic Message Syntax @section Cryptographic Message Syntax @cindex CMS @cindex cryptographic message syntax @cindex GpgSM @cindex protocol, CMS @cindex engine, GpgSM @cindex S/MIME @cindex protocol, S/MIME @acronym{CMS} is implemented by GpgSM, the S/MIME implementation for GnuPG. The @acronym{CMS} protocol is specified by @code{GPGME_PROTOCOL_CMS}. @node Assuan @section Assuan @cindex ASSUAN @cindex protocol, ASSUAN @cindex engine, ASSUAN Assuan is the RPC library used by the various @acronym{GnuPG} components. The Assuan protocol allows one to talk to arbitrary Assuan servers using @acronym{GPGME}. @xref{Using the Assuan protocol}. The ASSUAN protocol is specified by @code{GPGME_PROTOCOL_ASSUAN}. @node Algorithms @chapter Algorithms @cindex algorithms The crypto backends support a variety of algorithms used in public key cryptography.@footnote{Some engines also provide symmetric only encryption; see the description of the encryption function on how to use this.} The following sections list the identifiers used to denote such an algorithm. @menu * Public Key Algorithms:: A list of all public key algorithms. * Hash Algorithms:: A list of all hash algorithms. @end menu @node Public Key Algorithms @section Public Key Algorithms @cindex algorithms, public key @cindex public key algorithms Public key algorithms are used for encryption, decryption, signing and verification of signatures. @deftp {Data type} {enum gpgme_pubkey_algo_t} @tindex gpgme_pubkey_algo_t The @code{gpgme_pubkey_algo_t} type specifies the set of all public key algorithms that are supported by @acronym{GPGME}. Possible values are: @table @code @item GPGME_PK_RSA This value indicates the RSA (Rivest, Shamir, Adleman) algorithm. @item GPGME_PK_RSA_E Deprecated. This value indicates the RSA (Rivest, Shamir, Adleman) algorithm for encryption and decryption only. @item GPGME_PK_RSA_S Deprecated. This value indicates the RSA (Rivest, Shamir, Adleman) algorithm for signing and verification only. @item GPGME_PK_DSA This value indicates DSA, the Digital Signature Algorithm. @item GPGME_PK_ELG This value indicates ElGamal. @item GPGME_PK_ELG_E This value also indicates ElGamal and is used specifically in GnuPG. @item GPGME_PK_ECC @since{1.5.0} This value is a generic indicator for ellipic curve algorithms. @item GPGME_PK_ECDSA @since{1.3.0} This value indicates ECDSA, the Elliptic Curve Digital Signature Algorithm as defined by FIPS 186-2 and RFC-6637. @item GPGME_PK_ECDH @since{1.3.0} This value indicates ECDH, the Eliptic Curve Diffie-Hellmann encryption algorithm as defined by RFC-6637. @item GPGME_PK_EDDSA @since{1.7.0} This value indicates the EdDSA algorithm. @end table @end deftp @deftypefun {const char *} gpgme_pubkey_algo_name (@w{gpgme_pubkey_algo_t @var{algo}}) The function @code{gpgme_pubkey_algo_name} returns a pointer to a statically allocated string containing a description of the public key algorithm @var{algo}. This string can be used to output the name of the public key algorithm to the user. If @var{algo} is not a valid public key algorithm, @code{NULL} is returned. @end deftypefun @deftypefun {char *} gpgme_pubkey_algo_string (@w{gpgme_subkey_t @var{key}}) @since{1.7.0} 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 exhausted), the function returns NULL and sets @code{ERRNO}. @end deftypefun @node Hash Algorithms @section Hash Algorithms @cindex algorithms, hash @cindex algorithms, message digest @cindex hash algorithms @cindex message digest algorithms Hash (message digest) algorithms are used to compress a long message to make it suitable for public key cryptography. @deftp {Data type} {enum gpgme_hash_algo_t} @tindex gpgme_hash_algo_t The @code{gpgme_hash_algo_t} type specifies the set of all hash algorithms that are supported by @acronym{GPGME}. Possible values are: @table @code @item GPGME_MD_MD5 @item GPGME_MD_SHA1 @item GPGME_MD_RMD160 @item GPGME_MD_MD2 @item GPGME_MD_TIGER @item GPGME_MD_HAVAL @item GPGME_MD_SHA256 @item GPGME_MD_SHA384 @item GPGME_MD_SHA512 @item GPGME_MD_SHA224 @since{1.5.0} @item GPGME_MD_MD4 @item GPGME_MD_CRC32 @item GPGME_MD_CRC32_RFC1510 @item GPGME_MD_CRC24_RFC2440 @end table @end deftp @deftypefun {const char *} gpgme_hash_algo_name (@w{gpgme_hash_algo_t @var{algo}}) The function @code{gpgme_hash_algo_name} returns a pointer to a statically allocated string containing a description of the hash algorithm @var{algo}. This string can be used to output the name of the hash algorithm to the user. If @var{algo} is not a valid hash algorithm, @code{NULL} is returned. @end deftypefun @node Error Handling @chapter Error Handling @cindex error handling Many functions in @acronym{GPGME} can return an error if they fail. For this reason, the application should always catch the error condition and take appropriate measures, for example by releasing the resources and passing the error up to the caller, or by displaying a descriptive message to the user and cancelling the operation. Some error values do not indicate a system error or an error in the operation, but the result of an operation that failed properly. For example, if you try to decrypt a tempered message, the decryption will fail. Another error value actually means that the end of a data buffer or list has been reached. The following descriptions explain for many error codes what they mean usually. Some error values have specific meanings if returned by a certain functions. Such cases are described in the documentation of those functions. @acronym{GPGME} uses the @code{libgpg-error} library. This allows to share the error codes with other components of the GnuPG system, and thus pass error values transparently from the crypto engine, or some helper application of the crypto engine, to the user. This way no information is lost. As a consequence, @acronym{GPGME} does not use its own identifiers for error codes, but uses those provided by @code{libgpg-error}. They usually start with @code{GPG_ERR_}. However, @acronym{GPGME} does provide aliases for the functions defined in libgpg-error, which might be preferred for name space consistency. @menu * Error Values:: The error value and what it means. * Error Sources:: A list of important error sources. * Error Codes:: A list of important error codes. * Error Strings:: How to get a descriptive string from a value. @end menu @node Error Values @section Error Values @cindex error values @cindex error codes @cindex error sources @deftp {Data type} {gpgme_err_code_t} The @code{gpgme_err_code_t} type is an alias for the @code{libgpg-error} type @code{gpg_err_code_t}. The error code indicates the type of an error, or the reason why an operation failed. A list of important error codes can be found in the next section. @end deftp @deftp {Data type} {gpgme_err_source_t} The @code{gpgme_err_source_t} type is an alias for the @code{libgpg-error} type @code{gpg_err_source_t}. The error source has not a precisely defined meaning. Sometimes it is the place where the error happened, sometimes it is the place where an error was encoded into an error value. Usually the error source will give an indication to where to look for the problem. This is not always true, but it is attempted to achieve this goal. A list of important error sources can be found in the next section. @end deftp @deftp {Data type} {gpgme_error_t} The @code{gpgme_error_t} type is an alias for the @code{libgpg-error} type @code{gpg_error_t}. An error value like this has always two components, an error code and an error source. Both together form the error value. Thus, the error value can not be directly compared against an error code, but the accessor functions described below must be used. However, it is guaranteed that only 0 is used to indicate success (@code{GPG_ERR_NO_ERROR}), and that in this case all other parts of the error value are set to 0, too. Note that in @acronym{GPGME}, the error source is used purely for diagnostical purposes. Only the error code should be checked to test for a certain outcome of a function. The manual only documents the error code part of an error value. The error source is left unspecified and might be anything. @end deftp @deftypefun {static inline gpgme_err_code_t} gpgme_err_code (@w{gpgme_error_t @var{err}}) The static inline function @code{gpgme_err_code} returns the @code{gpgme_err_code_t} component of the error value @var{err}. This function must be used to extract the error code from an error value in order to compare it with the @code{GPG_ERR_*} error code macros. @end deftypefun @deftypefun {static inline gpgme_err_source_t} gpgme_err_source (@w{gpgme_error_t @var{err}}) The static inline function @code{gpgme_err_source} returns the @code{gpgme_err_source_t} component of the error value @var{err}. This function must be used to extract the error source from an error value in order to compare it with the @code{GPG_ERR_SOURCE_*} error source macros. @end deftypefun @deftypefun {static inline gpgme_error_t} gpgme_err_make (@w{gpgme_err_source_t @var{source}}, @w{gpgme_err_code_t @var{code}}) The static inline function @code{gpgme_err_make} returns the error value consisting of the error source @var{source} and the error code @var{code}. This function can be used in callback functions to construct an error value to return it to the library. @end deftypefun @deftypefun {static inline gpgme_error_t} gpgme_error (@w{gpgme_err_code_t @var{code}}) The static inline function @code{gpgme_error} returns the error value consisting of the default error source and the error code @var{code}. For @acronym{GPGME} applications, the default error source is @code{GPG_ERR_SOURCE_USER_1}. You can define @code{GPGME_ERR_SOURCE_DEFAULT} before including @file{gpgme.h} to change this default. This function can be used in callback functions to construct an error value to return it to the library. @end deftypefun The @code{libgpg-error} library provides error codes for all system error numbers it knows about. If @var{err} is an unknown error number, the error code @code{GPG_ERR_UNKNOWN_ERRNO} is used. The following functions can be used to construct error values from system errnor numbers. @deftypefun {gpgme_error_t} gpgme_err_make_from_errno (@w{gpgme_err_source_t @var{source}}, @w{int @var{err}}) The function @code{gpgme_err_make_from_errno} is like @code{gpgme_err_make}, but it takes a system error like @code{errno} instead of a @code{gpgme_err_code_t} error code. @end deftypefun @deftypefun {gpgme_error_t} gpgme_error_from_errno (@w{int @var{err}}) The function @code{gpgme_error_from_errno} is like @code{gpgme_error}, but it takes a system error like @code{errno} instead of a @code{gpgme_err_code_t} error code. @end deftypefun Sometimes you might want to map system error numbers to error codes directly, or map an error code representing a system error back to the system error number. The following functions can be used to do that. @deftypefun {gpgme_err_code_t} gpgme_err_code_from_errno (@w{int @var{err}}) The function @code{gpgme_err_code_from_errno} returns the error code for the system error @var{err}. If @var{err} is not a known system error, the function returns @code{GPG_ERR_UNKNOWN_ERRNO}. @end deftypefun @deftypefun {int} gpgme_err_code_to_errno (@w{gpgme_err_code_t @var{err}}) The function @code{gpgme_err_code_to_errno} returns the system error for the error code @var{err}. If @var{err} is not an error code representing a system error, or if this system error is not defined on this system, the function returns @code{0}. @end deftypefun @node Error Sources @section Error Sources @cindex error codes, list of The library @code{libgpg-error} defines an error source for every component of the GnuPG system. The error source part of an error value is not well defined. As such it is mainly useful to improve the diagnostic error message for the user. If the error code part of an error value is @code{0}, the whole error value will be @code{0}. In this case the error source part is of course @code{GPG_ERR_SOURCE_UNKNOWN}. The list of error sources that might occur in applications using @acronym{GPGME} is: @table @code @item GPG_ERR_SOURCE_UNKNOWN The error source is not known. The value of this error source is @code{0}. @item GPG_ERR_SOURCE_GPGME The error source is @acronym{GPGME} itself. This is the default for errors that occur in the @acronym{GPGME} library. @item GPG_ERR_SOURCE_GPG The error source is GnuPG, which is the crypto engine used for the OpenPGP protocol. @item GPG_ERR_SOURCE_GPGSM The error source is GPGSM, which is the crypto engine used for the CMS protocol. @item GPG_ERR_SOURCE_GCRYPT The error source is @code{libgcrypt}, which is used by crypto engines to perform cryptographic operations. @item GPG_ERR_SOURCE_GPGAGENT The error source is @command{gpg-agent}, which is used by crypto engines to perform operations with the secret key. @item GPG_ERR_SOURCE_PINENTRY The error source is @command{pinentry}, which is used by @command{gpg-agent} to query the passphrase to unlock a secret key. @item GPG_ERR_SOURCE_SCD The error source is the SmartCard Daemon, which is used by @command{gpg-agent} to delegate operations with the secret key to a SmartCard. @item GPG_ERR_SOURCE_KEYBOX The error source is @code{libkbx}, a library used by the crypto engines to manage local keyrings. @item GPG_ERR_SOURCE_USER_1 @item GPG_ERR_SOURCE_USER_2 @item GPG_ERR_SOURCE_USER_3 @item GPG_ERR_SOURCE_USER_4 These error sources are not used by any GnuPG component and can be used by other software. For example, applications using @acronym{GPGME} can use them to mark error values coming from callback handlers. Thus @code{GPG_ERR_SOURCE_USER_1} is the default for errors created with @code{gpgme_error} and @code{gpgme_error_from_errno}, unless you define @code{GPGME_ERR_SOURCE_DEFAULT} before including @file{gpgme.h}. @end table @node Error Codes @section Error Codes @cindex error codes, list of The library @code{libgpg-error} defines many error values. Most of them are not used by @code{GPGME} directly, but might be returned by @acronym{GPGME} because it received them from the crypto engine. The below list only includes such error codes that have a specific meaning in @code{GPGME}, or which are so common that you should know about them. @table @code @item GPG_ERR_EOF This value indicates the end of a list, buffer or file. @item GPG_ERR_NO_ERROR This value indicates success. The value of this error code is @code{0}. Also, it is guaranteed that an error value made from the error code @code{0} will be @code{0} itself (as a whole). This means that the error source information is lost for this error code, however, as this error code indicates that no error occurred, this is generally not a problem. @item GPG_ERR_GENERAL This value means that something went wrong, but either there is not enough information about the problem to return a more useful error value, or there is no separate error value for this type of problem. @item GPG_ERR_ENOMEM This value means that an out-of-memory condition occurred. @item GPG_ERR_E... System errors are mapped to GPG_ERR_FOO where FOO is the symbol for the system error. @item GPG_ERR_INV_VALUE This value means that some user provided data was out of range. This can also refer to objects. For example, if an empty @code{gpgme_data_t} object was expected, but one containing data was provided, this error value is returned. @item GPG_ERR_UNUSABLE_PUBKEY This value means that some recipients for a message were invalid. @item GPG_ERR_UNUSABLE_SECKEY This value means that some signers were invalid. @item GPG_ERR_NO_DATA This value means that a @code{gpgme_data_t} object which was expected to have content was found empty. @item GPG_ERR_CONFLICT This value means that a conflict of some sort occurred. @item GPG_ERR_NOT_IMPLEMENTED This value indicates that the specific function (or operation) is not implemented. This error should never happen. It can only occur if you use certain values or configuration options which do not work, but for which we think that they should work at some later time. @item GPG_ERR_DECRYPT_FAILED This value indicates that a decryption operation was unsuccessful. @item GPG_ERR_BAD_PASSPHRASE This value means that the user did not provide a correct passphrase when requested. @item GPG_ERR_CANCELED This value means that the operation was canceled. @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 were configured to exclude support for this engine, or because the engine is not installed properly. @item GPG_ERR_AMBIGUOUS_NAME This value indicates that a user ID or other specifier did not specify a unique key. @item GPG_ERR_WRONG_KEY_USAGE This value indicates that a key is not used appropriately. @item GPG_ERR_CERT_REVOKED This value indicates that a key signature was revoced. @item GPG_ERR_CERT_EXPIRED This value indicates that a key signature expired. @item GPG_ERR_NO_CRL_KNOWN This value indicates that no certificate revocation list is known for the certificate. @item GPG_ERR_NO_POLICY_MATCH This value indicates that a policy issue occurred. @item GPG_ERR_NO_SECKEY This value indicates that no secret key for the user ID is available. @item GPG_ERR_MISSING_CERT This value indicates that a key could not be imported because the issuer certificate is missing. @item GPG_ERR_BAD_CERT_CHAIN This value indicates that a key could not be imported because its certificate chain is not good, for example it could be too long. @item GPG_ERR_UNSUPPORTED_ALGORITHM This value means a verification failed because the cryptographic algorithm is not supported by the crypto backend. @item GPG_ERR_BAD_SIGNATURE This value means a verification failed because the signature is bad. @item GPG_ERR_NO_PUBKEY This value means a verification failed because the public key is not available. @item GPG_ERR_USER_1 @item GPG_ERR_USER_2 @item ... @item GPG_ERR_USER_16 These error codes are not used by any GnuPG component and can be freely used by other software. Applications using @acronym{GPGME} might use them to mark specific errors returned by callback handlers if no suitable error codes (including the system errors) for these errors exist already. @end table @node Error Strings @section Error Strings @cindex error values, printing of @cindex error codes, printing of @cindex error sources, printing of @cindex error strings @deftypefun {const char *} gpgme_strerror (@w{gpgme_error_t @var{err}}) The function @code{gpgme_strerror} returns a pointer to a statically allocated string containing a description of the error code contained in the error value @var{err}. This string can be used to output a diagnostic message to the user. This function is not thread safe. Use @code{gpgme_strerror_r} in multi-threaded programs. @end deftypefun @deftypefun {int} gpgme_strerror_r (@w{gpgme_error_t @var{err}}, @w{char *@var{buf}}, @w{size_t @var{buflen}}) The function @code{gpgme_strerror_r} returns the error string for @var{err} in the user-supplied buffer @var{buf} of size @var{buflen}. This function is, in contrast to @code{gpgme_strerror}, thread-safe if a thread-safe @code{strerror_r} function is provided by the system. If the function succeeds, 0 is returned and @var{buf} contains the string describing the error. If the buffer was not large enough, ERANGE is returned and @var{buf} contains as much of the beginning of the error string as fits into the buffer. @end deftypefun @deftypefun {const char *} gpgme_strsource (@w{gpgme_error_t @var{err}}) The function @code{gpgme_strerror} returns a pointer to a statically allocated string containing a description of the error source contained in the error value @var{err}. This string can be used to output a diagnostic message to the user. @end deftypefun The following example illustrates the use of @code{gpgme_strerror}: @example gpgme_ctx_t ctx; gpgme_error_t err = gpgme_new (&ctx); if (err) @{ fprintf (stderr, "%s: creating GpgME context failed: %s: %s\n", argv[0], gpgme_strsource (err), gpgme_strerror (err)); exit (1); @} @end example @node Exchanging Data @chapter Exchanging Data @cindex data, exchanging A lot of data has to be exchanged between the user and the crypto engine, like plaintext messages, ciphertext, signatures and information about the keys. The technical details about exchanging the data information are completely abstracted by @acronym{GPGME}. The user provides and receives the data via @code{gpgme_data_t} objects, regardless of the communication protocol between @acronym{GPGME} and the crypto engine in use. @deftp {Data type} {gpgme_data_t} The @code{gpgme_data_t} type is a handle for a container for generic data, which is used by @acronym{GPGME} to exchange data with the user. @end deftp @code{gpgme_data_t} objects do not provide notifications on events. It is assumed that read and write operations are blocking until data is available. If this is undesirable, the application must ensure that all GPGME data operations always have data available, for example by using memory buffers or files rather than pipes or sockets. This might be relevant, for example, if the external event loop mechanism is used. @deftp {Data type} {gpgme_off_t} @since{1.4.1} 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 Windows and as a 64 bit signed integer for 64 bit Windows. @end deftp @deftp {Data type} {gpgme_ssize_t} The @code{gpgme_ssize_t} type is an alias for @code{ssize_t}. It has only been introduced to overcome portability problems pertaining to the declaration of @code{ssize_t} by different toolchains. @end deftp @menu * Creating Data Buffers:: Creating new data buffers. * Destroying Data Buffers:: Releasing data buffers. * Manipulating Data Buffers:: Operations on data buffers. @end menu @node Creating Data Buffers @section Creating Data Buffers @cindex data buffer, creation Data objects can be based on memory, files, or callback functions provided by the user. Not all operations are supported by all objects. @menu * Memory Based Data Buffers:: Creating memory based data buffers. * File Based Data Buffers:: Creating file based data buffers. * Callback Based Data Buffers:: Creating callback based data buffers. @end menu @node Memory Based Data Buffers @subsection Memory Based Data Buffers Memory based data objects store all data in allocated memory. This is convenient, but only practical for an amount of data that is a fraction of the available physical memory. The data has to be copied from its source and to its destination, which can often be avoided by using one of the other data object @deftypefun gpgme_error_t gpgme_data_new (@w{gpgme_data_t *@var{dh}}) The function @code{gpgme_data_new} creates a new @code{gpgme_data_t} object and returns a handle for it in @var{dh}. The data object is memory based and initially empty. The function returns the error code @code{GPG_ERR_NO_ERROR} if the data object was successfully created, @code{GPG_ERR_INV_VALUE} if @var{dh} is not a valid pointer, and @code{GPG_ERR_ENOMEM} if not enough memory is available. @end deftypefun @deftypefun gpgme_error_t gpgme_data_new_from_mem (@w{gpgme_data_t *@var{dh}}, @w{const char *@var{buffer}}, @w{size_t @var{size}}, @w{int @var{copy}}) The function @code{gpgme_data_new_from_mem} creates a new @code{gpgme_data_t} object and fills it with @var{size} bytes starting from @var{buffer}. If @var{copy} is not zero, a private copy of the data is made. If @var{copy} is zero, the data is taken from the specified buffer as needed, and the user has to ensure that the buffer remains valid for the whole life span of the data object. The function returns the error code @code{GPG_ERR_NO_ERROR} if the data object was successfully created, @code{GPG_ERR_INV_VALUE} if @var{dh} or @var{buffer} is not a valid pointer, and @code{GPG_ERR_ENOMEM} if not enough memory is available. @end deftypefun @deftypefun gpgme_error_t gpgme_data_new_from_file (@w{gpgme_data_t *@var{dh}}, @w{const char *@var{filename}}, @w{int @var{copy}}) The function @code{gpgme_data_new_from_file} creates a new @code{gpgme_data_t} object and fills it with the content of the file @var{filename}. If @var{copy} is not zero, the whole file is read in at initialization time and the file is not used anymore after that. This is the only mode supported currently. Later, a value of zero for @var{copy} might cause all reads to be delayed until the data is needed, but this is not yet implemented. The function returns the error code @code{GPG_ERR_NO_ERROR} if the data object was successfully created, @code{GPG_ERR_INV_VALUE} if @var{dh} or @var{filename} is not a valid pointer, @code{GPG_ERR_NOT_IMPLEMENTED} if @var{code} is zero, and @code{GPG_ERR_ENOMEM} if not enough memory is available. @end deftypefun @deftypefun gpgme_error_t gpgme_data_new_from_filepart (@w{gpgme_data_t *@var{dh}}, @w{const char *@var{filename}}, @w{FILE *@var{fp}}, @w{off_t @var{offset}}, @w{size_t @var{length}}) The function @code{gpgme_data_new_from_filepart} creates a new @code{gpgme_data_t} object and fills it with a part of the file specified by @var{filename} or @var{fp}. Exactly one of @var{filename} and @var{fp} must be non-zero, the other must be zero. The argument that is not zero specifies the file from which @var{length} bytes are read into the data object, starting from @var{offset}. The function returns the error code @code{GPG_ERR_NO_ERROR} if the data object was successfully created, @code{GPG_ERR_INV_VALUE} if @var{dh} and exactly one of @var{filename} and @var{fp} is not a valid pointer, and @code{GPG_ERR_ENOMEM} if not enough memory is available. @end deftypefun @node File Based Data Buffers @subsection File Based Data Buffers File based data objects operate directly on file descriptors or streams. Only a small amount of data is stored in core at any time, so the size of the data objects is not limited by @acronym{GPGME}. @deftypefun gpgme_error_t gpgme_data_new_from_fd (@w{gpgme_data_t *@var{dh}}, @w{int @var{fd}}) The function @code{gpgme_data_new_from_fd} creates a new @code{gpgme_data_t} object and uses the file descriptor @var{fd} to read from (if used as an input data object) and write to (if used as an output data object). When using the data object as an input buffer, the function might read a bit more from the file descriptor than is actually needed by the crypto engine in the desired operation because of internal buffering. Note that GPGME assumes that the file descriptor is set to blocking mode. Errors during I/O operations, except for EINTR, are usually fatal for crypto operations. The function returns the error code @code{GPG_ERR_NO_ERROR} if the data object was successfully created, and @code{GPG_ERR_ENOMEM} if not enough memory is available. @end deftypefun @deftypefun gpgme_error_t gpgme_data_new_from_stream (@w{gpgme_data_t *@var{dh}}, @w{FILE *@var{stream}}) The function @code{gpgme_data_new_from_stream} creates a new @code{gpgme_data_t} object and uses the I/O stream @var{stream} to read from (if used as an input data object) and write to (if used as an output data object). When using the data object as an input buffer, the function might read a bit more from the stream than is actually needed by the crypto engine in the desired operation because of internal buffering. Note that GPGME assumes that the stream is in blocking mode. Errors during I/O operations, except for EINTR, are usually fatal for crypto operations. The function returns the error code @code{GPG_ERR_NO_ERROR} if the data object was successfully created, and @code{GPG_ERR_ENOMEM} if not enough memory is available. @end deftypefun @deftypefun gpgme_error_t gpgme_data_new_from_estream (@w{gpgme_data_t *@var{dh}}, @w{gpgrt_stream_t @var{stream}}) The function @code{gpgme_data_new_from_estream} creates a new @code{gpgme_data_t} object and uses the gpgrt stream @var{stream} to read from (if used as an input data object) and write to (if used as an output data object). When using the data object as an input buffer, the function might read a bit more from the stream than is actually needed by the crypto engine in the desired operation because of internal buffering. Note that GPGME assumes that the stream is in blocking mode. Errors during I/O operations, except for EINTR, are usually fatal for crypto operations. The function returns the error code @code{GPG_ERR_NO_ERROR} if the data object was successfully created, and @code{GPG_ERR_ENOMEM} if not enough memory is available. @end deftypefun @node Callback Based Data Buffers @subsection Callback Based Data Buffers If neither memory nor file based data objects are a good fit for your application, you can implement the functions a data object provides yourself and create a data object from these callback functions. @deftp {Data type} {ssize_t (*gpgme_data_read_cb_t) (@w{void *@var{handle}}, @w{void @var{*buffer}}, @w{size_t @var{size}})} @tindex gpgme_data_read_cb_t The @code{gpgme_data_read_cb_t} type is the type of functions which @acronym{GPGME} calls if it wants to read data from a user-implemented data object. The function should read up to @var{size} bytes from the current read position into the space starting at @var{buffer}. The @var{handle} is provided by the user at data object creation time. Note that GPGME assumes that the read blocks until data is available. Errors during I/O operations, except for EINTR, are usually fatal for crypto operations. The function should return the number of bytes read, 0 on EOF, and -1 on error. If an error occurs, @var{errno} should be set to describe the type of the error. @end deftp @deftp {Data type} {ssize_t (*gpgme_data_write_cb_t) (@w{void *@var{handle}}, @w{const void @var{*buffer}}, @w{size_t @var{size}})} @tindex gpgme_data_write_cb_t The @code{gpgme_data_write_cb_t} type is the type of functions which @acronym{GPGME} calls if it wants to write data to a user-implemented data object. The function should write up to @var{size} bytes to the current write position from the space starting at @var{buffer}. The @var{handle} is provided by the user at data object creation time. Note that GPGME assumes that the write blocks until data is available. Errors during I/O operations, except for EINTR, are usually fatal for crypto operations. The function should return the number of bytes written, and -1 on error. If an error occurs, @var{errno} should be set to describe the type of the error. @end deftp @deftp {Data type} {off_t (*gpgme_data_seek_cb_t) (@w{void *@var{handle}}, @w{off_t @var{offset}}, @w{int @var{whence}})} @tindex gpgme_data_seek_cb_t The @code{gpgme_data_seek_cb_t} type is the type of functions which @acronym{GPGME} calls if it wants to change the current read/write position in a user-implemented data object, just like the @code{lseek} function. The function should return the new read/write position, and -1 on error. If an error occurs, @var{errno} should be set to describe the type of the error. @end deftp @deftp {Data type} {void (*gpgme_data_release_cb_t) (@w{void *@var{handle}})} @tindex gpgme_data_release_cb_t The @code{gpgme_data_release_cb_t} type is the type of functions which @acronym{GPGME} calls if it wants to destroy a user-implemented data object. The @var{handle} is provided by the user at data object creation time. @end deftp @deftp {Data type} {struct gpgme_data_cbs} This structure is used to store the data callback interface functions described above. It has the following members: @table @code @item gpgme_data_read_cb_t read This is the function called by @acronym{GPGME} to read data from the data object. It is only required for input data object. @item gpgme_data_write_cb_t write This is the function called by @acronym{GPGME} to write data to the data object. It is only required for output data object. @item gpgme_data_seek_cb_t seek This is the function called by @acronym{GPGME} to change the current read/write pointer in the data object (if available). It is optional. @item gpgme_data_release_cb_t release This is the function called by @acronym{GPGME} to release a data object. It is optional. @end table @end deftp @deftypefun gpgme_error_t gpgme_data_new_from_cbs (@w{gpgme_data_t *@var{dh}}, @w{gpgme_data_cbs_t @var{cbs}}, @w{void *@var{handle}}) The function @code{gpgme_data_new_from_cbs} creates a new @code{gpgme_data_t} object and uses the user-provided callback functions to operate on the data object. The handle @var{handle} is passed as first argument to the callback functions. This can be used to identify this data object. The function returns the error code @code{GPG_ERR_NO_ERROR} if the data object was successfully created, and @code{GPG_ERR_ENOMEM} if not enough memory is available. @end deftypefun @node Destroying Data Buffers @section Destroying Data Buffers @cindex data buffer, destruction @deftypefun void gpgme_data_release (@w{gpgme_data_t @var{dh}}) The function @code{gpgme_data_release} destroys the data object with the handle @var{dh}. It releases all associated resources that were not provided by the user in the first place. @end deftypefun @deftypefun {char *} gpgme_data_release_and_get_mem (@w{gpgme_data_t @var{dh}}, @w{size_t *@var{length}}) The function @code{gpgme_data_release_and_get_mem} is like @code{gpgme_data_release}, except that it returns the data buffer and its length that was provided by the object. The user has to release the buffer with @code{gpgme_free}. In case the user provided the data buffer in non-copy mode, a copy will be made for this purpose. In case an error returns, or there is no suitable data buffer that can be returned to the user, the function will return @code{NULL}. In any case, the data object @var{dh} is destroyed. @end deftypefun @deftypefun void gpgme_free (@w{void *@var{buffer}}) @since{1.1.1} The function @code{gpgme_free} releases the memory returned by @code{gpgme_data_release_and_get_mem} and @code{gpgme_pubkey_algo_string}. It should be used instead of the system libraries @code{free} function in case different allocators are used by a program. This is often the case if gpgme is used under Windows as a DLL. @end deftypefun @node Manipulating Data Buffers @section Manipulating Data Buffers @cindex data buffer, manipulation Data buffers contain data and meta-data. The following operations can be used to manipulate both. @menu * Data Buffer I/O Operations:: I/O operations on data buffers. * Data Buffer Meta-Data:: Meta-data manipulation of data buffers. * Data Buffer Convenience:: Convenience function for data buffers. @end menu @node Data Buffer I/O Operations @subsection Data Buffer I/O Operations @cindex data buffer, I/O operations @cindex data buffer, read @cindex data buffer, write @cindex data buffer, seek @deftypefun ssize_t gpgme_data_read (@w{gpgme_data_t @var{dh}}, @w{void *@var{buffer}}, @w{size_t @var{length}}) The function @code{gpgme_data_read} reads up to @var{length} bytes from the data object with the handle @var{dh} into the space starting at @var{buffer}. If no error occurs, the actual amount read is returned. If the end of the data object is reached, the function returns 0. In all other cases, the function returns -1 and sets @var{errno}. @end deftypefun @deftypefun ssize_t gpgme_data_write (@w{gpgme_data_t @var{dh}}, @w{const void *@var{buffer}}, @w{size_t @var{size}}) The function @code{gpgme_data_write} writes up to @var{size} bytes starting from @var{buffer} into the data object with the handle @var{dh} at the current write position. The function returns the number of bytes actually written, or -1 if an error occurs. If an error occurs, @var{errno} is set. @end deftypefun @deftypefun off_t gpgme_data_seek (@w{gpgme_data_t @var{dh}}, @w{off_t @var{offset}}, @w{int @var{whence}}) The function @code{gpgme_data_seek} changes the current read/write position. The @var{whence} argument specifies how the @var{offset} should be interpreted. It must be one of the following symbolic constants: @table @code @item SEEK_SET Specifies that @var{offset} is a count of characters from the beginning of the data object. @item SEEK_CUR Specifies that @var{offset} is a count of characters from the current file position. This count may be positive or negative. @item SEEK_END Specifies that @var{offset} is a count of characters from the end of the data object. A negative count specifies a position within the current extent of the data object; a positive count specifies a position past the current end. If you set the position past the current end, and actually write data, you will extend the data object with zeros up to that position. @end table If successful, the function returns the resulting file position, measured in bytes from the beginning of the data object. You can use this feature together with @code{SEEK_CUR} to read the current read/write position. If the function fails, -1 is returned and @var{errno} is set. @end deftypefun @node Data Buffer Meta-Data @subsection Data Buffer Meta-Data @cindex data buffer, meta-data @cindex data buffer, file name @cindex data buffer, encoding @deftypefun {char *} gpgme_data_get_file_name (@w{gpgme_data_t @var{dh}}) @since{1.1.0} The function @code{gpgme_data_get_file_name} returns a pointer to a string containing the file name associated with the data object. The file name will be stored in the output when encrypting or signing the data and will be returned to the user when decrypting or verifying the output data. If no error occurs, the string containing the file name is returned. Otherwise, @code{NULL} will be returned. @end deftypefun @deftypefun gpgme_error_t gpgme_data_set_file_name (@w{gpgme_data_t @var{dh}}, @w{const char *@var{file_name}}) @since{1.1.0} The function @code{gpgme_data_set_file_name} sets the file name associated with the data object. The file name will be stored in the output when encrypting or signing the data and will be returned to the user when decrypting or verifying the output data. The function returns the error code @code{GPG_ERR_INV_VALUE} if @var{dh} is not a valid pointer and @code{GPG_ERR_ENOMEM} if not enough memory is available. @end deftypefun @deftp {Data type} {enum gpgme_data_encoding_t} @tindex gpgme_data_encoding_t The @code{gpgme_data_encoding_t} type specifies the encoding of a @code{gpgme_data_t} object. For input data objects, the encoding is useful to give the backend a hint on the type of data. For output data objects, the encoding can specify the output data format on certain operations. Please note that not all backends support all encodings on all operations. The following data types are available: @table @code @item GPGME_DATA_ENCODING_NONE This specifies that the encoding is not known. This is the default 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 no special encoding. @item GPGME_DATA_ENCODING_BASE64 This specifies that the data is encoded using the Base-64 encoding scheme as used by @acronym{MIME} and other protocols. @item GPGME_DATA_ENCODING_ARMOR This specifies that the data is encoded in an armored form as used by OpenPGP and PEM. @item GPGME_DATA_ENCODING_MIME @since{1.7.0} This specifies that the data is encoded as a MIME part. @item GPGME_DATA_ENCODING_URL @since{1.2.0} The data is a list of linefeed delimited URLs. This is only useful with @code{gpgme_op_import}. @item GPGME_DATA_ENCODING_URL0 @since{1.2.0} The data is a list of binary zero delimited URLs. This is only useful with @code{gpgme_op_import}. @item GPGME_DATA_ENCODING_URLESC @since{1.2.0} The data is a list of linefeed delimited URLs with all control and space characters percent escaped. This mode is is not yet implemented. @end table @end deftp @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 returned. @end deftypefun @deftypefun gpgme_error_t gpgme_data_set_encoding (@w{gpgme_data_t @var{dh}, gpgme_data_encoding_t @var{enc}}) The function @code{gpgme_data_set_encoding} changes the encoding of the data object with the handle @var{dh} to @var{enc}. @end deftypefun @deftypefun {gpgme_error_t} gpgme_data_set_flag @ (@w{gpgme_data_t @var{dh}}, @ @w{const char *@var{name}}, @ @w{const char *@var{value}}) @since{1.7.0} Some minor properties of the data object can be controlled with flags set by this function. The properties are identified by the following values for @var{name}: @table @code @item size-hint The value is a decimal number with the length gpgme shall assume for this data object. This is useful if the data is provided by callbacks or via file descriptors but the applications knows the total size of the data. If this is set the OpenPGP engine may use this to decide on buffer allocation strategies and to provide a total value for its progress information. @end table This function returns @code{0} on success. @end deftypefun @node Data Buffer Convenience @subsection Data Buffer Convenience Functions @cindex data buffer, convenience @cindex type of data @cindex identify @deftp {Data type} {enum gpgme_data_type_t} @tindex gpgme_data_type_t @since{1.4.3} The @code{gpgme_data_type_t} type is used to return the detected type of the content of a data buffer. @end deftp @table @code @item GPGME_DATA_TYPE_INVALID This is returned by @code{gpgme_data_identify} if it was not possible to identify the data. Reasons for this might be a non-seekable stream or a memory problem. The value is 0. @item GPGME_DATA_TYPE_UNKNOWN The type of the data is not known. @item GPGME_DATA_TYPE_PGP_SIGNED The data is an OpenPGP signed message. This may be a binary signature, a detached one or a cleartext signature. @item GPGME_DATA_TYPE_PGP_ENCRYPTED @since{1.7.0} The data is an OpenPGP encrypted message. @item GPGME_DATA_TYPE_PGP_SIGNATURE @since{1.7.0} The data is an OpenPGP detached signature. @item GPGME_DATA_TYPE_PGP_OTHER This is a generic OpenPGP message. In most cases this will be encrypted data. @item GPGME_DATA_TYPE_PGP_KEY This is an OpenPGP key (private or public). @item GPGME_DATA_TYPE_CMS_SIGNED This is a CMS signed message. @item GPGME_DATA_TYPE_CMS_ENCRYPTED This is a CMS encrypted (enveloped data) message. @item GPGME_DATA_TYPE_CMS_OTHER This is used for other CMS message types. @item GPGME_DATA_TYPE_X509_CERT The data is a X.509 certificate @item GPGME_DATA_TYPE_PKCS12 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}}) @since{1.4.3} The function @code{gpgme_data_identify} returns the type of the data with the handle @var{dh}. If it is not possible to perform the identification, the function returns zero (@code{GPGME_DATA_TYPE_INVALID}). Note that depending on how the data 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. @end deftypefun @c @c Chapter Contexts @c @node Contexts @chapter Contexts @cindex context All cryptographic operations in @acronym{GPGME} are performed within a context, which contains the internal state of the operation as well as configuration parameters. By using several contexts you can run several cryptographic operations in parallel, with different configuration. @deftp {Data type} {gpgme_ctx_t} The @code{gpgme_ctx_t} type is a handle for a @acronym{GPGME} context, which is used to hold the configuration, status and result of cryptographic operations. @end deftp @menu * Creating Contexts:: Creating new @acronym{GPGME} contexts. * Destroying Contexts:: Releasing @acronym{GPGME} contexts. * Result Management:: Managing the result of crypto operations. * Context Attributes:: Setting properties of a context. * Key Management:: Managing keys with @acronym{GPGME}. * Trust Item Management:: Managing trust items with @acronym{GPGME}. * Crypto Operations:: Using a context for cryptography. * Miscellaneous:: Miscellaneous operations * Run Control:: Controlling how operations are run. @end menu @node Creating Contexts @section Creating Contexts @cindex context, creation @deftypefun gpgme_error_t gpgme_new (@w{gpgme_ctx_t *@var{ctx}}) The function @code{gpgme_new} creates a new @code{gpgme_ctx_t} object and returns a handle for it in @var{ctx}. The function returns the error code @code{GPG_ERR_NO_ERROR} if the context was successfully created, @code{GPG_ERR_INV_VALUE} if @var{ctx} is not a valid pointer, and @code{GPG_ERR_ENOMEM} if not enough memory is available. Also, it returns @code{GPG_ERR_NOT_OPERATIONAL} if @code{gpgme_check_version} was not called to initialize GPGME, and @code{GPG_ERR_SELFTEST_FAILED} if a selftest failed. Currently, the only selftest is for Windows MingW32 targets to see if @code{-mms-bitfields} was used (as required). @end deftypefun @node Destroying Contexts @section Destroying Contexts @cindex context, destruction @deftypefun void gpgme_release (@w{gpgme_ctx_t @var{ctx}}) The function @code{gpgme_release} destroys the context with the handle @var{ctx} and releases all associated resources. @end deftypefun @node Result Management @section Result Management @cindex context, result of operation The detailed result of an operation is returned in operation-specific structures such as @code{gpgme_decrypt_result_t}. The corresponding retrieval functions such as @code{gpgme_op_decrypt_result} provide static access to the results after an operation completes. Those structures shall be considered read-only and an application must not allocate such a structure on its own. The following interfaces make it possible to detach a result structure from its associated context and give it a lifetime beyond that of the current operation or context. @deftypefun void gpgme_result_ref (@w{void *@var{result}}) @since{1.2.0} The function @code{gpgme_result_ref} acquires an additional reference for the result @var{result}, which may be of any type @code{gpgme_*_result_t}. As long as the user holds a reference, the result structure is guaranteed to be valid and unmodified. @end deftypefun @deftypefun void gpgme_result_unref (@w{void *@var{result}}) @since{1.2.0} The function @code{gpgme_result_unref} releases a reference for the result @var{result}. If this was the last reference, the result structure will be destroyed and all resources associated to it will be released. @end deftypefun Note that a context may hold its own references to result structures, typically until the context is destroyed or the next operation is started. In fact, these references are accessed through the @code{gpgme_op_*_result} functions. @node Context Attributes @section Context Attributes @cindex context, attributes @menu * Protocol Selection:: Selecting the protocol used by a context. * Crypto Engine:: Configuring the crypto engine. * Setting the Sender:: How to tell the engine the sender. * ASCII Armor:: Requesting @acronym{ASCII} armored output. * Text Mode:: Choosing canonical text mode. * Offline Mode:: Choosing offline mode. * Pinentry Mode:: Choosing the pinentry mode. * Included Certificates:: Including a number of certificates. * Key Listing Mode:: Selecting key listing mode. * Passphrase Callback:: Getting the passphrase from the user. * Progress Meter Callback:: Being informed about the progress. * Status Message Callback:: Status messages received from gpg. * Context Flags:: Additional flags for a context. * Locale:: Setting the locale of a context. * Additional Logs:: Additional logs of a context. @end menu @node Protocol Selection @subsection Protocol Selection @cindex context, selecting protocol @cindex protocol, selecting @deftypefun gpgme_error_t gpgme_set_protocol (@w{gpgme_ctx_t @var{ctx}}, @w{gpgme_protocol_t @var{proto}}) The function @code{gpgme_set_protocol} sets the protocol used within the context @var{ctx} to @var{proto}. All crypto operations will be performed by the crypto engine configured for that protocol. @xref{Protocols and Engines}. Setting the protocol with @code{gpgme_set_protocol} does not check if the crypto engine for that protocol is available and installed correctly. @xref{Engine Version Check}. The function returns the error code @code{GPG_ERR_NO_ERROR} if the protocol could be set successfully, and @code{GPG_ERR_INV_VALUE} if @var{protocol} is not a valid protocol. @end deftypefun @deftypefun gpgme_protocol_t gpgme_get_protocol (@w{gpgme_ctx_t @var{ctx}}) The function @code{gpgme_get_protocol} retrieves the protocol currently use with the context @var{ctx}. @end deftypefun @node Crypto Engine @subsection Crypto Engine @cindex context, configuring engine @cindex engine, configuration per context The following functions can be used to set and retrieve the configuration of the crypto engines of a specific context. The default can also be retrieved without any particular context. @xref{Engine Information}. The default can also be changed globally. @xref{Engine Configuration}. @deftypefun gpgme_engine_info_t gpgme_ctx_get_engine_info (@w{gpgme_ctx_t @var{ctx}}) @since{1.1.0} The function @code{gpgme_ctx_get_engine_info} returns a linked list of engine info structures. Each info structure describes the configuration of one configured backend, as used by the context @var{ctx}. The result is valid until the next invocation of @code{gpgme_ctx_set_engine_info} for this particular context. This function can not fail. @end deftypefun @deftypefun gpgme_error_t gpgme_ctx_set_engine_info (@w{gpgme_ctx_t @var{ctx}}, @w{gpgme_protocol_t @var{proto}}, @w{const char *@var{file_name}}, @w{const char *@var{home_dir}}) @since{1.1.0} The function @code{gpgme_ctx_set_engine_info} changes the configuration of the crypto engine implementing the protocol @var{proto} for the context @var{ctx}. @var{file_name} is the file name of the executable program implementing this protocol, and @var{home_dir} is the directory name of the configuration directory for this crypto engine. If @var{home_dir} is @code{NULL}, the engine's default will be used. Currently this function must be used before starting the first crypto operation. It is unspecified if and when the changes will take effect if the function is called after starting the first operation on the context @var{ctx}. This function returns the error code @code{GPG_ERR_NO_ERROR} if successful, or an error code on failure. @end deftypefun @node Setting the Sender @subsection How to tell the engine the sender. @cindex context, sender @cindex sender @cindex From: Some engines can make use of the sender’s address, for example to figure out the best user id in certain trust models. For verification and signing of mails, it is thus suggested to let the engine know the sender ("From:") address. @acronym{GPGME} provides two functions to accomplish that. Note that the esoteric use of multiple "From:" addresses is not supported. @deftypefun gpgme_error_t gpgme_set_sender @ (@w{gpgme_ctx_t @var{ctx}}, @ @w{int @var{address}}) @since{1.8.0} 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 address, in which case this function extracts the ``addr-spec'' from it. Using @code{NULL} for @var{address} clears the sender address. The function returns 0 on success or an error code on failure. The most likely failure is that no valid ``addr-spec'' was found in @var{address}. @end deftypefun @deftypefun @w{const char *} gpgme_get_sender @ (@w{gpgme_ctx_t @var{ctx}}) @since{1.8.0} The function @code{gpgme_get_sender} returns the current sender address from the context, or NULL if none was set. The returned value is valid as long as the @var{ctx} is valid and @code{gpgme_set_sender} has not been called again. @end deftypefun @c FIXME: Unfortunately, using @acronym here breaks texi2dvi. @node ASCII Armor @subsection @acronym{ASCII} Armor @cindex context, armor mode @cindex @acronym{ASCII} armor @cindex armor mode @deftypefun void gpgme_set_armor (@w{gpgme_ctx_t @var{ctx}}, @w{int @var{yes}}) The function @code{gpgme_set_armor} specifies if the output should be @acronym{ASCII} armored. By default, output is not @acronym{ASCII} armored. @acronym{ASCII} armored output is disabled if @var{yes} is zero, and enabled otherwise. @end deftypefun @deftypefun int gpgme_get_armor (@w{gpgme_ctx_t @var{ctx}}) The function @code{gpgme_get_armor} returns 1 if the output is @acronym{ASCII} armored, and @code{0} if it is not, or if @var{ctx} is not a valid pointer. @end deftypefun @node Text Mode @subsection Text Mode @cindex context, text mode @cindex text mode @cindex canonical text mode @deftypefun void gpgme_set_textmode (@w{gpgme_ctx_t @var{ctx}}, @w{int @var{yes}}) The function @code{gpgme_set_textmode} specifies if canonical text mode should be used. By default, text mode is not used. Text mode is for example used for the RFC2015 signatures; note that the updated RFC 3156 mandates that the mail user agent does some preparations so that text mode is not needed anymore. This option is only relevant to the OpenPGP crypto engine, and ignored by all other engines. Canonical text mode is disabled if @var{yes} is zero, and enabled otherwise. @end deftypefun @deftypefun int gpgme_get_textmode (@w{gpgme_ctx_t @var{ctx}}) The function @code{gpgme_get_textmode} returns 1 if canonical text mode is enabled, and @code{0} if it is not, or if @var{ctx} is not a valid pointer. @end deftypefun @node Offline Mode @subsection Offline Mode @cindex context, offline mode @cindex offline mode @deftypefun void gpgme_set_offline (@w{gpgme_ctx_t @var{ctx}}, @w{int @var{yes}}) @since{1.6.0} The function @code{gpgme_set_offline} specifies if offline mode should be used. Offline mode is disabled if @var{yes} is zero, and enabled otherwise. By default, offline mode is disabled. The details of the offline mode depend on the used protocol and its backend engine. It may eventually be extended to be more stricter and 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}. For the OpenPGP protocol offline mode entirely disables the use of the Dirmngr and will thus guarantee that no network connections are done as part of an operation on this context. It has only an effect with GnuPG versions 2.1.23 or later. For all other protocols the offline mode is currently ignored. @end deftypefun @deftypefun int gpgme_get_offline (@w{gpgme_ctx_t @var{ctx}}) @since{1.6.0} The function @code{gpgme_get_offline} returns 1 if offline mode is enabled, and @code{0} if it is not, or if @var{ctx} is not a valid pointer. @end deftypefun @node Pinentry Mode @subsection Pinentry Mode @cindex context, pinentry mode @cindex pinentry mode @deftypefun gpgme_error_t gpgme_set_pinentry_mode (@w{gpgme_ctx_t @var{ctx}}, @w{gpgme_pinentry_mode_t @var{mode}}) @since{1.4.0} The function @code{gpgme_set_pinentry_mode} specifies the pinentry mode to be used. For GnuPG >= 2.1 this option is required to be set to @code{GPGME_PINENTRY_MODE_LOOPBACK} to enable the passphrase callback mechanism in GPGME through @code{gpgme_set_passphrase_cb}. @end deftypefun @deftypefun gpgme_pinentry_mode_t gpgme_get_pinentry_mode (@w{gpgme_ctx_t @var{ctx}}) @since{1.4.0} The function @code{gpgme_get_pinenty_mode} returns the mode set for the context. @end deftypefun @deftp {Data type} {enum gpgme_pinentry_mode_t} @tindex gpgme_pinentry_mode_t @since{1.4.0} The @code{gpgme_minentry_mode_t} type specifies the set of possible pinentry modes that are supported by @acronym{GPGME} if GnuPG >= 2.1 is used. The following modes are supported: @table @code @item GPGME_PINENTRY_MODE_DEFAULT @since{1.4.0} Use the default of the agent, which is ask. @item GPGME_PINENTRY_MODE_ASK @since{1.4.0} Force the use of the Pinentry. @item GPGME_PINENTRY_MODE_CANCEL @since{1.4.0} Emulate use of Pinentry's cancel button. @item GPGME_PINENTRY_MODE_ERROR @since{1.4.0} Return a Pinentry error @code{No Pinentry}. @item GPGME_PINENTRY_MODE_LOOPBACK @since{1.4.0} Redirect Pinentry queries to the caller. This enables the use of @code{gpgme_set_passphrase_cb} because pinentry queries are redirected to gpgme. Note: For 2.1.0 - 2.1.12 this mode requires @code{allow-loopback-pinentry} to be enabled in the @file{gpg-agent.conf} or an agent started with that option. @end table @end deftp @node Included Certificates @subsection Included Certificates @cindex certificates, included @deftypefun void gpgme_set_include_certs (@w{gpgme_ctx_t @var{ctx}}, @w{int @var{nr_of_certs}}) The function @code{gpgme_set_include_certs} specifies how many certificates should be included in an S/MIME signed message. By default, only the sender's certificate is included. The possible values of @var{nr_of_certs} are: @table @code @item GPGME_INCLUDE_CERTS_DEFAULT @since{1.0.3} Fall back to the default of the crypto backend. This is the default for GPGME. @item -2 Include all certificates except the root certificate. @item -1 Include all certificates. @item 0 Include no certificates. @item 1 Include the sender's certificate only. @item n Include the first n certificates of the certificates path, starting from the sender's certificate. The number @code{n} must be positive. @end table Values of @var{nr_of_certs} smaller than -2 are undefined. This option is only relevant to the CMS crypto engine, and ignored by all other engines. @end deftypefun @deftypefun int gpgme_get_include_certs (@w{gpgme_ctx_t @var{ctx}}) The function @code{gpgme_get_include_certs} returns the number of certificates to include into an S/MIME signed message. @end deftypefun @node Key Listing Mode @subsection Key Listing Mode @cindex key listing mode @cindex key listing, mode of @deftypefun gpgme_error_t gpgme_set_keylist_mode (@w{gpgme_ctx_t @var{ctx}}, @w{gpgme_keylist_mode_t @var{mode}}) The function @code{gpgme_set_keylist_mode} changes the default behaviour of the key listing functions. The value in @var{mode} is a bitwise-or combination of one or multiple of the following bit values: @table @code @item GPGME_KEYLIST_MODE_LOCAL The @code{GPGME_KEYLIST_MODE_LOCAL} symbol specifies that the local keyring should be searched for keys in the keylisting operation. This is the default. Using only this option results in a @code{--list-keys}. @item GPGME_KEYLIST_MODE_EXTERN The @code{GPGME_KEYLIST_MODE_EXTERN} symbol specifies that an external source should be searched for keys in the keylisting operation. The type of external source is dependent on the crypto engine used and whether it is combined with @code{GPGME_KEYLIST_MODE_LOCAL}. For example, it can be a remote keyserver or LDAP certificate server. Using only this option results in a @code{--search-keys} for @code{GPGME_PROTOCOL_OpenPGP} and something similar to @code{--list-external-keys} for @code{GPGME_PROTOCOL_CMS}. @item GPGME_KEYLIST_MODE_LOCATE This is a shortcut for the combination of @code{GPGME_KEYLIST_MODE_LOCAL} and @code{GPGME_KEYLIST_MODE_EXTERN}, which results in a @code{--locate-keys} for @code{GPGME_PROTOCOL_OpenPGP}. @item GPGME_KEYLIST_MODE_SIGS The @code{GPGME_KEYLIST_MODE_SIGS} symbol specifies that the key signatures should be included in the listed keys. @item GPGME_KEYLIST_MODE_SIG_NOTATIONS @since{1.1.1} The @code{GPGME_KEYLIST_MODE_SIG_NOTATIONS} symbol specifies that the signature notations on key signatures should be included in the listed keys. This only works if @code{GPGME_KEYLIST_MODE_SIGS} is also enabled. @item GPGME_KEYLIST_MODE_WITH_TOFU @since{1.7.0} The @code{GPGME_KEYLIST_MODE_WITH_TOFU} symbol specifies that information pertaining to the TOFU trust model should be included in the listed keys. @item GPGME_KEYLIST_MODE_WITH_SECRET @since{1.5.1} The @code{GPGME_KEYLIST_MODE_WITH_SECRET} returns information about the presence of a corresponding secret key in a public key listing. A public key listing with this mode is slower than a standard listing but can be used instead of a second run to list the secret keys. This is only supported for GnuPG versions >= 2.1. @item GPGME_KEYLIST_MODE_EPHEMERAL @since{1.2.0} The @code{GPGME_KEYLIST_MODE_EPHEMERAL} symbol specifies that keys flagged as ephemeral are included in the listing. @item GPGME_KEYLIST_MODE_VALIDATE @since{0.4.5} The @code{GPGME_KEYLIST_MODE_VALIDATE} symbol specifies that the backend should do key or certificate validation and not just get the validity information from an internal cache. This might be an expensive operation and is in general not useful. Currently only implemented for the S/MIME backend and ignored for other backends. @end table At least one of @code{GPGME_KEYLIST_MODE_LOCAL} and @code{GPGME_KEYLIST_MODE_EXTERN} must be specified. For future binary compatibility, you should get the current mode with @code{gpgme_get_keylist_mode} and modify it by setting or clearing the appropriate bits, and then using that calculated value in the @code{gpgme_set_keylisting_mode} operation. This will leave all other bits in the mode value intact (in particular those that are not used in the current version of the library). The function returns the error code @code{GPG_ERR_NO_ERROR} if the mode could be set correctly, and @code{GPG_ERR_INV_VALUE} if @var{ctx} is not a valid pointer or @var{mode} is not a valid mode. @end deftypefun @deftypefun gpgme_keylist_mode_t gpgme_get_keylist_mode (@w{gpgme_ctx_t @var{ctx}}) The function @code{gpgme_get_keylist_mode} returns the current key listing mode of the context @var{ctx}. This value can then be modified and used in a subsequent @code{gpgme_set_keylist_mode} operation to only affect the desired bits (and leave all others intact). The function returns 0 if @var{ctx} is not a valid pointer, and the current mode otherwise. Note that 0 is not a valid mode value. @end deftypefun @node Passphrase Callback @subsection Passphrase Callback @cindex callback, passphrase @cindex passphrase callback @deftp {Data type} {gpgme_error_t (*gpgme_passphrase_cb_t)(void *@var{hook}, const char *@var{uid_hint}, const char *@var{passphrase_info}, @w{int @var{prev_was_bad}}, @w{int @var{fd}})} @tindex gpgme_passphrase_cb_t The @code{gpgme_passphrase_cb_t} type is the type of functions usable as passphrase callback function. The argument @var{uid_hint} might contain a string that gives an indication for which user ID the passphrase is required. If this is not available, or not applicable (in the case of symmetric encryption, for example), @var{uid_hint} will be @code{NULL}. The argument @var{passphrase_info}, if not @code{NULL}, will give further information about the context in which the passphrase is required. This information is engine and operation specific. If this is the repeated attempt to get the passphrase, because previous attempts failed, then @var{prev_was_bad} is 1, otherwise it will be 0. The user must write the passphrase, followed by a newline character, to the file descriptor @var{fd}. The function @code{gpgme_io_writen} should be used for the write operation. Note that if the user returns 0 to indicate success, the user must at least write a newline character before returning from the callback. If an error occurs, return the corresponding @code{gpgme_error_t} value. You can use the error code @code{GPG_ERR_CANCELED} to abort the operation. Otherwise, return @code{0}. Note: The passphrase_cb only works with GnuPG 1.x and 2.1.x and not with the 2.0.x series. See @code{gpgme_set_pinentry_mode} for more details on 2.1.x usage. @end deftp @deftypefun void gpgme_set_passphrase_cb (@w{gpgme_ctx_t @var{ctx}}, @w{gpgme_passphrase_cb_t @var{passfunc}}, @w{void *@var{hook_value}}) The function @code{gpgme_set_passphrase_cb} sets the function that is used when a passphrase needs to be provided by the user to @var{passfunc}. The function @var{passfunc} needs to implemented by the user, and whenever it is called, it is called with its first argument being @var{hook_value}. By default, no passphrase callback function is set. Not all crypto engines require this callback to retrieve the passphrase. It is better if the engine retrieves the passphrase from a trusted agent (a daemon process), rather than having each user to implement their own passphrase query. Some engines do not even support an external passphrase callback at all, in this case the error code @code{GPG_ERR_NOT_SUPPORTED} is returned. For GnuPG >= 2.1 the pinentry mode has to be set to @code{GPGME_PINENTRY_MODE_LOOPBACK} to enable the passphrase callback. See @code{gpgme_set_pinentry_mode}. The user can disable the use of a passphrase callback function by calling @code{gpgme_set_passphrase_cb} with @var{passfunc} being @code{NULL}. @end deftypefun @deftypefun void gpgme_get_passphrase_cb (@w{gpgme_ctx_t @var{ctx}}, @w{gpgme_passphrase_cb_t *@var{passfunc}}, @w{void **@var{hook_value}}) The function @code{gpgme_get_passphrase_cb} returns the function that is used when a passphrase needs to be provided by the user in @var{*passfunc}, and the first argument for this function in @var{*hook_value}. If no passphrase callback is set, or @var{ctx} is not a valid pointer, @code{NULL} is returned in both variables. @var{passfunc} or @var{hook_value} can be @code{NULL}. In this case, the corresponding value will not be returned. @end deftypefun @node Progress Meter Callback @subsection Progress Meter Callback @cindex callback, progress meter @cindex progress meter callback @deftp {Data type} {void (*gpgme_progress_cb_t)(void *@var{hook}, const char *@var{what}, int @var{type}, int @var{current}, int @var{total})} @tindex gpgme_progress_cb_t The @code{gpgme_progress_cb_t} type is the type of functions usable as progress callback function. The arguments are specific to the crypto engine. More information about the progress information returned from the GnuPG engine can be found in the GnuPG source code in the file @file{doc/DETAILS} in the section PROGRESS. @end deftp @deftypefun void gpgme_set_progress_cb (@w{gpgme_ctx_t @var{ctx}}, @w{gpgme_progress_cb_t @var{progfunc}}, @w{void *@var{hook_value}}) The function @code{gpgme_set_progress_cb} sets the function that is used when progress information about a cryptographic operation is available. The function @var{progfunc} needs to implemented by the user, and whenever it is called, it is called with its first argument being @var{hook_value}. By default, no progress callback function is set. Setting a callback function allows an interactive program to display progress information about a long operation to the user. The user can disable the use of a progress callback function by calling @code{gpgme_set_progress_cb} with @var{progfunc} being @code{NULL}. @end deftypefun @deftypefun void gpgme_get_progress_cb (@w{gpgme_ctx_t @var{ctx}}, @w{gpgme_progress_cb_t *@var{progfunc}}, @w{void **@var{hook_value}}) The function @code{gpgme_get_progress_cb} returns the function that is used to inform the user about the progress made in @var{*progfunc}, and the first argument for this function in @var{*hook_value}. If no progress callback is set, or @var{ctx} is not a valid pointer, @code{NULL} is returned in both variables. @var{progfunc} or @var{hook_value} can be @code{NULL}. In this case, the corresponding value will not be returned. @end deftypefun @node Status Message Callback @subsection Status Message Callback @cindex callback, status message @cindex status message callback @deftp {Data type} {gpgme_error_t (*gpgme_status_cb_t)(void *@var{hook}, const char *@var{keyword}, const char *@var{args})} @tindex gpgme_status_cb_t The @code{gpgme_status_cb_t} type is the type of function usable as a status message callback function. The argument @var{keyword} is the name of the status message while the @var{args} argument contains any arguments for the status message. If an error occurs, return the corresponding @code{gpgme_error_t} value. Otherwise, return @code{0}. @end deftp @deftypefun void gpgme_set_status_cb (@w{gpgme_ctx_t @var{ctx}}, @w{gpgme_status_cb_t @var{statusfunc}}, @w{void *@var{hook_value}}) @since{1.6.0} The function @code{gpgme_set_status_cb} sets the function that is used when a status message is received from gpg to @var{statusfunc}. The function @var{statusfunc} needs to be implemented by the user, and whenever it is called, it is called with its first argument being @var{hook_value}. By default, no status message callback function is set. The user can disable the use of a status message callback function by calling @code{gpgme_set_status_cb} with @var{statusfunc} being @code{NULL}. @end deftypefun @deftypefun void gpgme_get_status_cb (@w{gpgme_ctx_t @var{ctx}}, @w{gpgme_status_cb_t *@var{statusfunc}}, @w{void **@var{hook_value}}) @since{1.6.0} The function @code{gpgme_get_status_cb} returns the function that is used to process status messages from gpg in @var{*statusfunc}, and the first argument for this function in @var{*hook_value}. If no status message callback is set, or @var{ctx} is not a valid pointer, @code{NULL} is returned in both variables. @end deftypefun @node Context Flags @subsection Context Flags @cindex flags, of a context @deftypefun {gpgme_error_t} gpgme_set_ctx_flag @ (@w{gpgme_ctx_t @var{ctx}}, @ @w{const char *@var{name}}, @ @w{const char *@var{value}}) @since{1.7.0} Some minor properties of the context can be controlled with flags set by this function. The properties are identified by the following values for @var{name}: @table @code @item "redraw" This flag is normally not changed by the caller because GPGME sets and clears it automatically: The flag is cleared before an operation and set if an operation noticed that the engine has launched a Pinentry. A Curses based application may use this information to redraw the screen; for example: @example err = gpgme_op_keylist_start (ctx, "foo@@example.org", 0); while (!err) @{ err = gpgme_op_keylist_next (ctx, &key); if (err) break; show_key (key); gpgme_key_release (key); @} if ((s = gpgme_get_ctx_flag (ctx, "redraw")) && *s) redraw_screen (); gpgme_release (ctx); @end example @item "full-status" Using a @var{value} of "1" the status callback set by gpgme_set_status_cb returns all status lines with the exception of PROGRESS lines. With the default of "0" the status callback is only called in certain situations. @item "raw-description" Setting the @var{value} to "1" returns human readable strings in a raw format. For example the non breaking space characters ("~") will not be removed from the @code{description} field of the @code{gpgme_tofu_info_t} object. @item "export-session-key" Using a @var{value} of "1" specifies that the context should try to export the symmetric session key when decrypting data. By default, or when using an empty string or "0" for @var{value}, session keys are not exported. @item "override-session-key" The string given in @var{value} is passed to the GnuPG engine to override the session key for decryption. The format of that session key is specific to GnuPG and can be retrieved during a decrypt operation when the context flag "export-session-key" is enabled. Please be aware that using this feature with GnuPG < 2.1.16 will leak the session key on many platforms via ps(1). @item "auto-key-retrieve" Setting the @var{value} to "1" asks the backend to automatically retrieve a key for signature verification if possible. Note that this option makes a "web bug" like behavior possible. Keyserver or Web Key Directory operators can see which keys you request, so by sending you a message signed by a brand new key (which you naturally will not have on your local keyring), the operator can tell both your IP address and the time when you verified the signature. @item "request-origin" The string given in @var{value} is passed to the GnuPG engines to request restrictions based on the origin of the request. Valid values are documented in the GnuPG manual and the gpg man page under the option @option{--request-origin}. Requires at least GnuPG 2.2.6 to have an effect. @item "no-symkey-cache" For OpenPGP disable the passphrase cache used for symmetrical en- and decryption. This cache is based on the message specific salt value. Requires at least GnuPG 2.2.7 to have an effect. @item "ignore-mdc-error" This flag passes the option @option{--ignore-mdc-error} to gpg. This can be used to force decryption of a message which failed due to a missing integrity check. This flag must be used with great caution and only if it is a known non-corrupted old message and the decryption result of the former try had the decryption result flag @code{legacy_cipher_nomdc} set. For failsafe reasons this flag is reset after each operation. @item "auto-key-locate" The string given in @var{value} is passed to gpg. This can be used to change the behavior of a @code{GPGME_KEYLIST_MODE_LOCATE} keylisting. Valid values are documented in the GnuPG manual and the gpg man page under the option @option{--auto-key-locate}. Requires at least GnuPG 2.1.18. Note: Keys retrieved through @code{auto-key-locate} are automatically imported in the keyring. @item trust-model @since{1.11.2} Change the trust-model for all GnuPG engine operations. An empty string sets the trust-model back to the users default. If the trust-model is not supported by GnuPG the behavior is undefined and will likely cause all operations to fail. Example: "tofu+pgp". This options should be used carefully with a strict version requirement. In some versions of GnuPG setting the trust-model changes the default trust-model for future operations. A change in the trust-model also can have unintended side effects, like rebuilding the trust-db. @end table This function returns @code{0} on success. @end deftypefun @deftypefun {const char *} gpgme_get_ctx_flag @ (@w{gpgme_ctx_t @var{ctx}}, @ @w{const char *@var{name}}) @since{1.8.0} The value of flags settable by @code{gpgme_set_ctx_flag} can be retrieved by this function. If @var{name} is unknown the function returns @code{NULL}. For boolean flags an empty string is returned for False and the string "1" is returned for True; either atoi(3) or a test for an empty string can be used to get the boolean value. @end deftypefun @node Locale @subsection Locale @cindex locale, default @cindex locale, of a context A locale setting can be associated with a context. This locale is passed to the crypto engine, and used for applications like the PIN entry, which is displayed to the user when entering a passphrase is required. The default locale is used to initialize the locale setting of all contexts created afterwards. @deftypefun gpgme_error_t gpgme_set_locale (@w{gpgme_ctx_t @var{ctx}}, @w{int @var{category}}, @w{const char *@var{value}}) @since{0.4.3} The function @code{gpgme_set_locale} sets the locale of the context @var{ctx}, or the default locale if @var{ctx} is a null pointer. The locale settings that should be changed are specified by @var{category}. Supported categories are @code{LC_CTYPE}, @code{LC_MESSAGES}, and @code{LC_ALL}, which is a wildcard you can use if you want to change all the categories at once. The value to be used for the locale setting is @var{value}, which will be copied to @acronym{GPGME}'s internal data structures. @var{value} can be a null pointer, which disables setting the locale, and will make PIN entry and other applications use their default setting, which is usually not what you want. Note that the settings are only used if the application runs on a text terminal, and that the settings should fit the configuration of the output terminal. Normally, it is sufficient to initialize the default value at startup. The function returns an error if not enough memory is available. @end deftypefun @node Additional Logs @subsection Additional Logs @cindex auditlog, of the engine @cindex auditlog Additional logs can be associated with a context. These logs are engine specific and can be be obtained with @code{gpgme_op_getauditlog}. @deftypefun gpgme_error_t gpgme_op_getauditlog @ (@w{gpgme_ctx_t @var{ctx}}, @w{gpgme_data_t @var{output}}, @ @w{unsigned int @var{flags}}) @since{1.1.1} The function @code{gpgme_op_getauditlog} is used to obtain additional logs as specified by @var{flags} into the @var{output} data. If The function returns the error code @code{GPG_ERR_NO_ERROR} if a log could be queried from the engine, and @code{GPG_ERR_NOT_IMPLEMENTED} if the log specified in @var{flags} is not available for this engine. If no log is available @code{GPG_ERR_NO_DATA} is returned. The value in @var{flags} is a bitwise-or combination of one or multiple of the following bit values: @table @code @item GPGME_AUDITLOG_DIAG @since{1.11.2} Obtain diagnostic output which would be written to @code{stderr} in interactive use of the engine. This can be used to provide additional diagnostic information in case of errors in other operations. Note: If log-file has been set in the configuration the log will be empty and @code{GPG_ERR_NO_DATA} will be returned. Implemented for: @code{GPGME_PROTOCOL_OpenPGP} @item GPGME_AUDITLOG_DEFAULT @since{1.11.2} This flag has the value 0 for compatibility reasons. Obtains additional information from the engine by issuing the @code{GETAUDITLOG} command. For @code{GPGME_PROTOCOL_CMS} this provides additional information about the X509 certificate chain. Implemented for: @code{GPGME_PROTOCOL_CMS} @item GPGME_AUDITLOG_HTML @since{1.1.1} Same as @code{GPGME_AUDITLOG_DEFAULT} but in HTML. Implemented for: @code{GPGME_PROTOCOL_CMS} @end table @end deftypefun @deftypefun gpgme_error_t gpgme_op_getauditlog_start @ (@w{gpgme_ctx_t @var{ctx}}, @w{gpgme_data_t @var{output}}, @ @w{unsigned int @var{flags}}) @since{1.1.1} This is the asynchronous variant of @code{gpgme_op_getauditlog}. @end deftypefun @node Key Management @section Key Management @cindex key management Some of the cryptographic operations require that recipients or signers are specified. This is always done by specifying the respective keys that should be used for the operation. The following section describes how such keys can be selected and manipulated. @menu * Key objects:: Description of the key structures. * Listing Keys:: Browsing the list of available keys. * Information About Keys:: Requesting detailed information about keys. * Manipulating Keys:: Operations on keys. * Generating Keys:: Creating new key pairs. * Signing Keys:: Adding key signatures to public keys. * Exporting Keys:: Retrieving key data from the key ring. * Importing Keys:: Adding keys to the key ring. * Deleting Keys:: Removing keys from the key ring. * Changing Passphrases:: Change the passphrase of a key. * Changing TOFU Data:: Changing data pertaining to TOFU. * Advanced Key Editing:: Advanced key edit operation. @end menu @node Key objects @subsection Key objects The keys are represented in GPGME by structures which may only be read by the application but never be allocated or changed. They are valid as long as the key object itself is valid. @deftp {Data type} gpgme_key_t The @code{gpgme_key_t} type is a pointer to a key object. It has the following members: @table @code @item gpgme_keylist_mode_t keylist_mode @since{0.9.0} The keylist mode that was active when the key was retrieved. @item unsigned int revoked : 1 This is true if the key is revoked. @item unsigned int expired : 1 This is true if the key is expired. @item unsigned int disabled : 1 This is true if the key is disabled. @item unsigned int invalid : 1 This is true if the key is invalid. This might have several reasons, for a example for the S/MIME backend, it will be set during key 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. @item unsigned int can_sign : 1 This is true if the key (ie one of its subkeys) can be used to create data signatures. @item unsigned int can_certify : 1 This is true if the key (ie 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. @item unsigned int is_qualified : 1 @since{1.1.0} This is true if the key can be used for qualified signatures according to local government regulations. @item unsigned int secret : 1 This is true if the key is a secret key. Note, that this will always be true even if the corresponding subkey flag may be false (offline/stub keys). This is only set if a listing of secret keys has been requested or if @code{GPGME_KEYLIST_MODE_WITH_SECRET} is active. @item unsigned int origin : 5 @since{1.8.0} Reserved for the origin of this key. @item gpgme_protocol_t protocol This is the protocol supported by this key. @item char *issuer_serial If @code{protocol} is @code{GPGME_PROTOCOL_CMS}, then this is the issuer serial. @item char *issuer_name If @code{protocol} is @code{GPGME_PROTOCOL_CMS}, then this is the issuer name. @item char *chain_id If @code{protocol} is @code{GPGME_PROTOCOL_CMS}, then this is the chain ID, which can be used to built the certificate chain. @item gpgme_validity_t owner_trust If @code{protocol} is @code{GPGME_PROTOCOL_OpenPGP}, then this is the owner trust. @item gpgme_subkey_t subkeys This is a linked list with the subkeys of the key. The first subkey in the list is the primary key and usually available. @item gpgme_user_id_t uids This is a linked list with the user IDs of the key. The first user ID in the list is the main (or primary) user ID. @item char *fpr @since{1.7.0} This field gives the fingerprint of the primary key. Note that this is a copy of the fingerprint of the first subkey. For an incomplete key (for example from a verification result) a subkey may be missing but this field may be set nevertheless. @item unsigned long last_update @since{1.8.0} Reserved for the time of the last update of this key. @end table @end deftp @deftp {Data type} gpgme_subkey_t @since{1.5.0} The @code{gpgme_subkey_t} type is a pointer to a subkey structure. Subkeys are one component of a @code{gpgme_key_t} object. In fact, subkeys are those parts that contains the real information about the individual cryptographic keys that belong to the same key object. One @code{gpgme_key_t} can contain several subkeys. The first subkey in the linked list is also called the primary key. The subkey structure has the following members: @table @code @item gpgme_subkey_t next This is a pointer to the next subkey structure in the linked list, or @code{NULL} if this is the last element. @item unsigned int revoked : 1 This is true if the subkey is revoked. @item unsigned int expired : 1 This is true if the subkey is expired. @item unsigned int disabled : 1 This is true if the subkey is disabled. @item unsigned int invalid : 1 This is true if the subkey is invalid. @item unsigned int can_encrypt : 1 This is true if the subkey can be used for encryption. @item unsigned int can_sign : 1 This is true if the subkey can be used to create data signatures. @item unsigned int can_certify : 1 This is true if the subkey can be used to create key certificates. @item unsigned int can_authenticate : 1 @since{0.4.5} This is true if the subkey can be used for authentication. @item unsigned int is_qualified : 1 @since{1.1.0} This is true if the subkey can be used for qualified signatures according to local government regulations. @item unsigned int is_de_vs : 1 @since{1.8.0} This is true if the subkey complies with the rules for classified information in Germany at the restricted level (VS-NfD). This are currently RSA keys of at least 2048 bits or ECDH/ECDSA keys using a 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 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. @item gpgme_pubkey_algo_t pubkey_algo This is the public key algorithm supported by this subkey. @item unsigned int length This is the length of the subkey (in bits). @item char *keyid This is the key ID of the subkey in hexadecimal digits. @item char *fpr This is the fingerprint of the subkey in hexadecimal digits, if available. @item char *keygrip @since{1.7.0} The keygrip of the subkey in hex digit form or @code{NULL} if not availabale. @item long int timestamp This is the creation timestamp of the subkey. This is -1 if the timestamp is invalid, and 0 if it is not available. @item long int expires This is the expiration timestamp of the subkey, or 0 if the subkey does not expire. @item unsigned int is_cardkey : 1 @since{1.2.0} True if the secret key is stored on a smart card. @item char *card_number @since{1.2.0} The serial number of a smart card holding this key or @code{NULL}. @item char *curve For ECC algorithms the name of the curve. @end table @end deftp @deftp {Data type} gpgme_user_id_t A user ID is a component of a @code{gpgme_key_t} object. One key can have many user IDs. The first one in the list is the main (or primary) user ID. The user ID structure has the following members. @table @code @item gpgme_user_id_t next This is a pointer to the next user ID structure in the linked list, or @code{NULL} if this is the last element. @item unsigned int revoked : 1 This is true if the user ID is revoked. @item unsigned int invalid : 1 This is true if the user ID is invalid. @item gpgme_validity_t validity This specifies the validity of the user ID. @item char *uid This is the user ID string. @item char *name This is the name component of @code{uid}, if available. @item char *comment This is the comment component of @code{uid}, if available. @item char *email This is the email component of @code{uid}, if available. @item char *address; The mail address (addr-spec from RFC-5322) of the user ID string. This is general the same as the @code{email} part of this structure but might be slightly different. If no mail address is available @code{NULL} is stored. @item gpgme_tofu_info_t tofu @since{1.7.0} If not @code{NULL} information from the TOFU database pertaining to this user id. @item gpgme_key_sig_t signatures This is a linked list with the signatures on this user ID. @item unsigned int origin : 5 @since{1.8.0} Reserved for the origin of this user ID. @item unsigned long last_update @since{1.8.0} Reserved for the time of the last update of this user ID. @end table @end deftp @deftp {Data type} gpgme_tofu_info_t @since{1.7.0} The @code{gpgme_tofu_info_t} type is a pointer to a tofu info structure. Tofu info structures are one component of a @code{gpgme_user_id_t} object, and provide information from the TOFU database pertaining to the user ID. The tofu info structure has the following members: @table @code @item gpgme_key_sig_t next This is a pointer to the next tofu info structure in the linked list, or @code{NULL} if this is the last element. @item unsigned int validity : 3 This is the TOFU validity. It can have the following values: @table @code @item 0 The value @code{0} indicates a conflict. @item 1 The value @code{1} indicates a key without history. @item 2 The value @code{2} indicates a key with too little history. @item 3 The value @code{3} indicates a key with enough history for basic trust. @item 4 The value @code{4} indicates a key with a lot of history. @end table @item unsigned int policy : 4 This is the TOFU policy, see @code{gpgme_tofu_policy_t}. @item unsigned short signcount This is the number of signatures seen for this binding (or @code{USHRT_MAX} if there are more than that). @item unsigned short encrcount This is the number of encryptions done with this binding (or @code{USHRT_MAX} if there are more than that). @item unsigned long signfirst Number of seconds since Epoch when the first signature was seen with this binding. @item unsigned long signlast Number of seconds since Epoch when the last signature was seen with this binding. @item unsigned long encrfirst Number of seconds since Epoch when the first encryption was done with this binding. @item unsigned long encrlast Number of seconds since Epoch when the last encryption was done with this binding. @item char *description A human-readable string summarizing the TOFU data (or NULL). @end table @end deftp @deftp {Data type} gpgme_key_sig_t The @code{gpgme_key_sig_t} type is a pointer to a key signature structure. Key signatures are one component of a @code{gpgme_key_t} object, and validate user IDs on the key in the OpenPGP protocol. The signatures on a key are only available if the key was retrieved via a listing operation with the @code{GPGME_KEYLIST_MODE_SIGS} mode enabled, because it can be expensive to retrieve all signatures of a key. The signature notations on a key signature are only available if the key was retrieved via a listing operation with the @code{GPGME_KEYLIST_MODE_SIG_NOTATIONS} mode enabled, because it can be expensive to retrieve all signature notations. The key signature structure has the following members: @table @code @item gpgme_key_sig_t next This is a pointer to the next key signature structure in the linked list, or @code{NULL} if this is the last element. @item unsigned int revoked : 1 This is true if the key signature is a revocation signature. @item unsigned int expired : 1 This is true if the key signature is expired. @item unsigned int invalid : 1 This is true if the key signature is invalid. @item unsigned int exportable : 1 This is true if the key signature is exportable. @item gpgme_pubkey_algo_t pubkey_algo This is the public key algorithm used to create the signature. @item char *keyid This is the key ID of the key (in hexadecimal digits) used to create the signature. @item long int timestamp This is the creation timestamp of the key signature. This is -1 if the timestamp is invalid, and 0 if it is not available. @item long int expires This is the expiration timestamp of the key signature, or 0 if the key signature does not expire. @item gpgme_error_t status This is the status of the signature and has the same meaning as the member of the same name in a @code{gpgme_signature_t} object. @item unsigned int sig_class This specifies the signature class of the key signature. The meaning is specific to the crypto engine. @item char *uid This is the main user ID of the key used to create the signature. @item char *name This is the name component of @code{uid}, if available. @item char *comment This is the comment component of @code{uid}, if available. @item char *email This is the email component of @code{uid}, if available. @item gpgme_sig_notation_t notations This is a linked list with the notation data and policy URLs. @end table @end deftp @node Listing Keys @subsection Listing Keys @cindex listing keys @cindex key listing @cindex key listing, start @cindex key ring, list @cindex key ring, search @deftypefun gpgme_error_t gpgme_op_keylist_start (@w{gpgme_ctx_t @var{ctx}}, @w{const char *@var{pattern}}, @w{int @var{secret_only}}) The function @code{gpgme_op_keylist_start} initiates a key listing operation inside the context @var{ctx}. It sets everything up so that subsequent invocations of @code{gpgme_op_keylist_next} return the keys in the list. If @var{pattern} is @code{NULL}, all available keys are returned. Otherwise, @var{pattern} contains an engine specific expression that is used to limit the list to all keys matching the pattern. Note that the total length of the pattern is restricted to an engine-specific maximum (a couple of hundred characters are usually accepted). The pattern should be used to restrict the search to a certain common name or user, not to list many specific keys at once by listing their fingerprints or key IDs. If @var{secret_only} is not @code{0}, the list is restricted to secret keys only. The context will be busy until either all keys are received (and @code{gpgme_op_keylist_next} returns @code{GPG_ERR_EOF}), or @code{gpgme_op_keylist_end} is called to finish the operation. The function returns the error code @code{GPG_ERR_INV_VALUE} if @var{ctx} is not a valid pointer, and passes through any errors that are reported by the crypto engine support routines. @end deftypefun @deftypefun gpgme_error_t gpgme_op_keylist_ext_start (@w{gpgme_ctx_t @var{ctx}}, @w{const char *@var{pattern}[]}, @w{int @var{secret_only}}, @w{int @var{reserved}}) The function @code{gpgme_op_keylist_ext_start} initiates an extended key listing operation inside the context @var{ctx}. It sets everything up so that subsequent invocations of @code{gpgme_op_keylist_next} return the keys in the list. If @var{pattern} or @var{*pattern} is @code{NULL}, all available keys are returned. Otherwise, @var{pattern} is a @code{NULL} terminated array of strings that are used to limit the list to all keys matching at least one of the patterns verbatim. Note that the total length of all patterns is restricted to an engine-specific maximum (the exact limit also depends on the number of patterns and amount of quoting required, but a couple of hundred characters are usually accepted). Patterns should be used to restrict the search to a certain common name or user, not to list many specific keys at once by listing their fingerprints or key IDs. If @var{secret_only} is not @code{0}, the list is restricted to secret keys only. The value of @var{reserved} must be @code{0}. The context will be busy until either all keys are received (and @code{gpgme_op_keylist_next} returns @code{GPG_ERR_EOF}), or @code{gpgme_op_keylist_end} is called to finish the operation. The function returns the error code @code{GPG_ERR_INV_VALUE} if @var{ctx} is not a valid pointer, and passes through any errors that are reported by the crypto engine support routines. @end deftypefun @deftypefun gpgme_error_t gpgme_op_keylist_from_data_start @ (@w{gpgme_ctx_t @var{ctx}}, @ @w{gpgme_data_t @var{data}}, @ @w{int @var{reserved}}) @since{1.8.0} The function @code{gpgme_op_keylist_from_data_start} initiates a key listing operation inside the context @var{ctx}. In contrast to the other key listing operation the keys are read from the supplied @var{data} and not from the local key database. The keys are also not imported into the local key database. The function sets everything up so that subsequent invocations of @code{gpgme_op_keylist_next} return the keys from @var{data}. The value of @var{reserved} must be @code{0}. This function requires at least GnuPG version 2.1.14 and currently works only with OpenPGP keys. The context will be busy until either all keys are received (and @code{gpgme_op_keylist_next} returns @code{GPG_ERR_EOF}), or @code{gpgme_op_keylist_end} is called to finish the operation. While the context is busy @var{data} may not be released. The function returns the error code @code{GPG_ERR_INV_VALUE} if @var{ctx} is not a valid pointer, and passes through any errors that are reported by the crypto engine support routines. @end deftypefun @deftypefun gpgme_error_t gpgme_op_keylist_next (@w{gpgme_ctx_t @var{ctx}}, @w{gpgme_key_t *@var{r_key}}) The function @code{gpgme_op_keylist_next} returns the next key in the list created by a previous @code{gpgme_op_keylist_start} operation in the context @var{ctx}. The key will have one reference for the user. @xref{Manipulating Keys}. This is the only way to get at @code{gpgme_key_t} objects in @acronym{GPGME}. If the last key in the list has already been returned, @code{gpgme_op_keylist_next} returns @code{GPG_ERR_EOF}. The function returns the error code @code{GPG_ERR_INV_VALUE} if @var{ctx} or @var{r_key} is not a valid pointer, and @code{GPG_ERR_ENOMEM} if there is not enough memory for the operation. @end deftypefun @deftypefun gpgme_error_t gpgme_op_keylist_end (@w{gpgme_ctx_t @var{ctx}}) The function @code{gpgme_op_keylist_end} ends a pending key list operation in the context @var{ctx}. After the operation completed successfully, the result of the key listing operation can be retrieved with @code{gpgme_op_keylist_result}. The function returns the error code @code{GPG_ERR_INV_VALUE} if @var{ctx} is not a valid pointer, and @code{GPG_ERR_ENOMEM} if at some time during the operation there was not enough memory available. @end deftypefun The following example illustrates how all keys containing a certain string (@code{g10code}) can be listed with their key ID and the name and email address of the main user ID: @example gpgme_ctx_t ctx; gpgme_key_t key; gpgme_error_t err = gpgme_new (&ctx); if (!err) @{ err = gpgme_op_keylist_start (ctx, "g10code", 0); while (!err) @{ err = gpgme_op_keylist_next (ctx, &key); if (err) break; printf ("%s:", key->subkeys->keyid); if (key->uids && key->uids->name) printf (" %s", key->uids->name); if (key->uids && key->uids->email) printf (" <%s>", key->uids->email); putchar ('\n'); gpgme_key_release (key); @} gpgme_release (ctx); @} if (gpg_err_code (err) != GPG_ERR_EOF) @{ fprintf (stderr, "can not list keys: %s\n", gpgme_strerror (err)); exit (1); @} @end example @deftp {Data type} {gpgme_keylist_result_t} This is a pointer to a structure used to store the result of a @code{gpgme_op_keylist_*} operation. After successfully ending a key listing operation, you can retrieve the pointer to the result with @code{gpgme_op_keylist_result}. The structure contains the following member: @table @code @item unsigned int truncated : 1 This is true if the crypto backend had to truncate the result, and less than the desired keys could be listed. @end table @end deftp @deftypefun gpgme_keylist_result_t gpgme_op_keylist_result (@w{gpgme_ctx_t @var{ctx}}) The function @code{gpgme_op_keylist_result} returns a @code{gpgme_keylist_result_t} pointer to a structure holding the result of a @code{gpgme_op_keylist_*} operation. The pointer is only valid if the last operation on the context was a key listing operation, and if this operation finished successfully. The returned pointer is only valid until the next operation is started on the context. @end deftypefun In a simple program, for which a blocking operation is acceptable, the following function can be used to retrieve a single key. @deftypefun gpgme_error_t gpgme_get_key (@w{gpgme_ctx_t @var{ctx}}, @w{const char *@var{fpr}}, @w{gpgme_key_t *@var{r_key}}, @w{int @var{secret}}) The function @code{gpgme_get_key} gets the key with the fingerprint (or key ID) @var{fpr} from the crypto backend and return it in @var{r_key}. If @var{secret} is true, get the secret key. The currently active keylist mode is used to retrieve the key. The key will have one reference for the user. If the key is not found in the keyring, @code{gpgme_get_key} returns the error code @code{GPG_ERR_EOF} and *@var{r_key} will be set to @code{NULL}. The function returns the error code @code{GPG_ERR_INV_VALUE} if @var{ctx} or @var{r_key} is not a valid pointer or @var{fpr} is not a fingerprint or key ID, @code{GPG_ERR_AMBIGUOUS_NAME} if the key ID was not a unique specifier for a key, and @code{GPG_ERR_ENOMEM} if at some time during the operation there was not enough memory available. @end deftypefun @node Information About Keys @subsection Information About Keys @cindex key, information about @cindex key, attributes @cindex attributes, of a key Please see the beginning of this section for more information about @code{gpgme_key_t} objects. @deftp {Data type} gpgme_validity_t The @code{gpgme_validity_t} type is used to specify the validity of a user ID in a key. The following validities are defined: @table @code @item GPGME_VALIDITY_UNKNOWN The user ID is of unknown validity. The string representation of this validity is ``?''. @item GPGME_VALIDITY_UNDEFINED The validity of the user ID is undefined. The string representation of this validity is ``q''. @item GPGME_VALIDITY_NEVER The user ID is never valid. The string representation of this validity is ``n''. @item GPGME_VALIDITY_MARGINAL The user ID is marginally valid. The string representation of this validity is ``m''. @item GPGME_VALIDITY_FULL The user ID is fully valid. The string representation of this validity is ``f''. @item GPGME_VALIDITY_ULTIMATE The user ID is ultimately valid. The string representation of this validity is ``u''. @end table @end deftp @node Manipulating Keys @subsection Manipulating Keys @cindex key, manipulation @deftypefun void gpgme_key_ref (@w{gpgme_key_t @var{key}}) The function @code{gpgme_key_ref} acquires an additional reference for the key @var{key}. @end deftypefun @deftypefun void gpgme_key_unref (@w{gpgme_key_t @var{key}}) The function @code{gpgme_key_unref} releases a reference for the key @var{key}. If this was the last reference, the key will be destroyed and all resources associated to it will be released. @end deftypefun @node Generating Keys @subsection Generating Keys @cindex key, creation @cindex key ring, add GPGME provides a set of functions to create public key pairs. Most of these functions require the use of GnuPG 2.1 and later; for older GnuPG versions the @code{gpgme_op_genkey} function can be used. Existing code which wants to update to the new functions or new code which shall supports older GnuPG versions may try the new functions first and provide a fallback to the old function if the error code @code{GPG_ERR_NOT_SUPPORTED} is received. @c @c gpgme_op_createkey @c @deftypefun gpgme_error_t gpgme_op_createkey @ (@w{gpgme_ctx_t @var{ctx}}, @ @w{const char *@var{userid}}, @ @w{const char *@var{algo}}, @ @w{unsigned long @var{reserved}}, @ @w{unsigned long @var{expires}}, @ @w{gpgme_key_t @var{extrakey}}, @ @w{unsigned int @var{flags}}); @since{1.7.0} The function @code{gpgme_op_createkey} generates a new key for the procotol active in the context @var{ctx}. As of now this function does only work for OpenPGP and requires at least version 2.1.13 of GnuPG. @var{userid} is commonly the mail address associated with the key. -GPGME does not require a specificy syntax but if more than a mail +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 required parameter. @var{algo} specifies the algorithm for the new key (actually a keypair of public and private key). For a list of supported algorithms, see the GnuPG manual. If @var{algo} is @code{NULL} or the string "default", the key is generated using the default algorithm of the engine. If the string "future-default" is used the engine may use an algorithm which is planned to be the default in a future release of the engine; however existing implementation of the protocol may not be able to already handle such future algorithms. For the OpenPGP protocol, the specification of a default algorithm, without requesting a non-default usage via @var{flags}, triggers the creation of a primary key plus a secondary key (subkey). @var{reserved} must be set to zero. @var{expires} specifies the expiration time in seconds. If you supply 0, a reasonable expiration time is chosen. Use the flag @code{GPGME_CREATE_NOEXPIRE} to create keys that do not expire. Note that this parameter takes an unsigned long value and not a @code{time_t} to avoid problems on systems which use a signed 32 bit @code{time_t}. Note further that the OpenPGP protocol uses 32 bit values for timestamps and thus can only encode dates up to the year 2106. @var{extrakey} is currently not used and must be set to @code{NULL}. A future version of GPGME may use this parameter to create X.509 keys. @var{flags} can be set to the bit-wise OR of the following flags: @table @code @item GPGME_CREATE_SIGN @itemx GPGME_CREATE_ENCR @itemx GPGME_CREATE_CERT @itemx GPGME_CREATE_AUTH @since{1.7.0} Do not create the key with the default capabilities (key usage) of the requested algorithm but use those explicitly given by these flags: ``signing'', ``encryption'', ``certification'', or ``authentication''. The allowed combinations depend on the algorithm. If any of these flags are set and a default algorithm has been selected only one key is created in the case of the OpenPGP protocol. @item GPGME_CREATE_NOPASSWD @since{1.7.0} Request generation of the key without password protection. @item GPGME_CREATE_SELFSIGNED @since{1.7.0} For an X.509 key do not create a CSR but a self-signed certificate. This has not yet been implemented. @item GPGME_CREATE_NOSTORE @since{1.7.0} Do not store the created key in the local key database. This has not yet been implemented. @item GPGME_CREATE_WANTPUB @itemx GPGME_CREATE_WANTSEC @since{1.7.0} Return the public or secret key as part of the result structure. This has not yet been implemented. @item GPGME_CREATE_FORCE @since{1.7.0} The engine does not allow the creation of a key with a user ID already existing in the local key database. This flag can be used to override this check. @item GPGME_CREATE_NOEXPIRE @since{1.8.0} Request generation of keys that do not expire. @end table After the operation completed successfully, information about the created key can be retrieved with @code{gpgme_op_genkey_result}. The function returns zero on success, @code{GPG_ERR_NOT_SUPPORTED} if the engine does not support the command, or a bunch of other error codes. @end deftypefun @deftypefun gpgme_error_t gpgme_op_createkey_start @ (@w{gpgme_ctx_t @var{ctx}}, @ @w{const char *@var{userid}}, @ @w{const char *@var{algo}}, @ @w{unsigned long @var{reserved}}, @ @w{unsigned long @var{expires}}, @ @w{gpgme_key_t @var{extrakey}}, @ @w{unsigned int @var{flags}}); @since{1.7.0} The function @code{gpgme_op_createkey_start} initiates a @code{gpgme_op_createkey} operation; see there for details. It must be completed by calling @code{gpgme_wait} on the context. @xref{Waiting For Completion}. @end deftypefun @c @c gpgme_op_createsubkey @c @deftypefun gpgme_error_t gpgme_op_createsubkey @ (@w{gpgme_ctx_t @var{ctx}}, @ @w{gpgme_key_t @var{key}}, @ @w{const char *@var{algo}}, @ @w{unsigned long @var{reserved}}, @ @w{unsigned long @var{expires}}, @ @w{unsigned int @var{flags}}); @since{1.7.0} The function @code{gpgme_op_createsubkey} creates and adds a new subkey to the primary OpenPGP key given by @var{KEY}. The only allowed protocol in @var{ctx} is @code{GPGME_PROTOCOL_OPENPGP}. Subkeys (aka secondary keys) are a concept in the OpenPGP protocol to bind several keys to a primary key. As of now this function requires at least version 2.1.13 of GnuPG. @var{key} specifies the key to operate on. @var{algo} specifies the algorithm for the new subkey. For a list of supported algorithms, see the GnuPG manual. If @var{algo} is @code{NULL} or the string "default", the subkey is generated using the default algorithm for an encryption subkey of the engine. If the string "future-default" is used the engine may use an encryption algorithm which is planned to be the default in a future release of the engine; however existing implementation of the protocol may not be able to already handle such future algorithms. @var{reserved} must be set to zero. @var{expires} specifies the expiration time in seconds. If you supply 0, a reasonable expiration time is chosen. Use the flag @code{GPGME_CREATE_NOEXPIRE} to create keys that do not expire. Note that this parameter takes an unsigned long value and not a @code{time_t} to avoid problems on systems which use a signed 32 bit @code{time_t}. Note further that the OpenPGP protocol uses 32 bit values for timestamps and thus can only encode dates up to the year 2106. @var{flags} takes the same values as described above for @code{gpgme_op_createkey}. After the operation completed successfully, information about the created key can be retrieved with @code{gpgme_op_genkey_result}. The function returns zero on success, @code{GPG_ERR_NOT_SUPPORTED} if the engine does not support the command, or a bunch of other error codes. @end deftypefun @deftypefun gpgme_error_t gpgme_op_createsubkey_start @ (@w{gpgme_ctx_t @var{ctx}}, @ @w{gpgme_key_t @var{key}}, @ @w{const char *@var{algo}}, @ @w{unsigned long @var{reserved}}, @ @w{unsigned long @var{expires}}, @ @w{unsigned int @var{flags}}); @since{1.7.0} The function @code{gpgme_op_createsubkey_start} initiates a @code{gpgme_op_createsubkey} operation; see there for details. It must be completed by calling @code{gpgme_wait} on the context. @xref{Waiting For Completion}. @end deftypefun @c @c gpgme_op_adduid @c @deftypefun gpgme_error_t gpgme_op_adduid @ (@w{gpgme_ctx_t @var{ctx}}, @ @w{gpgme_key_t @var{key}}, @ @w{const char *@var{userid}}, @ @w{unsigned int @var{flags}}); @since{1.7.0} The function @code{gpgme_op_adduid} adds a new user ID to the OpenPGP key given by @var{KEY}. Adding additional user IDs after key creation is a feature of the OpenPGP protocol and thus the protocol for the context @var{ctx} must be set to OpenPGP. As of now this function requires at least version 2.1.13 of GnuPG. @var{key} specifies the key to operate on. @var{userid} is the user ID to add to the key. A user ID is commonly the mail address to be associated with the key. GPGME does not -require a specificy syntax but if more than a mail address is given, +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 required parameter. @var{flags} are currently not used and must be set to zero. The function returns zero on success, @code{GPG_ERR_NOT_SUPPORTED} if the engine does not support the command, or a bunch of other error codes. @end deftypefun @deftypefun gpgme_error_t gpgme_op_adduid_start @ (@w{gpgme_ctx_t @var{ctx}}, @ @w{gpgme_key_t @var{key}}, @ @w{const char *@var{userid}}, @ @w{unsigned int @var{flags}}); @since{1.7.0} The function @code{gpgme_op_adduid_start} initiates a @code{gpgme_op_adduid} operation; see there for details. It must be completed by calling @code{gpgme_wait} on the context. @xref{Waiting For Completion}. @end deftypefun @c @c gpgme_op_revuid @c @deftypefun gpgme_error_t gpgme_op_revuid @ (@w{gpgme_ctx_t @var{ctx}}, @ @w{gpgme_key_t @var{key}}, @ @w{const char *@var{userid}}, @ @w{unsigned int @var{flags}}); @since{1.7.0} The function @code{gpgme_op_revuid} revokes a user ID from the OpenPGP key given by @var{KEY}. Revoking user IDs after key creation is a feature of the OpenPGP protocol and thus the protocol for the context @var{ctx} must be set to OpenPGP. As of now this function requires at least version 2.1.13 of GnuPG. @var{key} specifies the key to operate on. @var{userid} is the user ID to be revoked from the key. The user ID must be given verbatim because the engine does an exact and case sensitive match. Thus the @code{uid} field from the user ID object (@code{gpgme_user_id_t}) is to be used. This is a required parameter. @var{flags} are currently not used and must be set to zero. Note that the engine won't allow to revoke the last valid user ID. To change a user ID is better to first add the new user ID, then revoke the old one, and finally publish the key. The function returns zero on success, @code{GPG_ERR_NOT_SUPPORTED} if the engine does not support the command, or a bunch of other error codes. @end deftypefun @deftypefun gpgme_error_t gpgme_op_revuid_start @ (@w{gpgme_ctx_t @var{ctx}}, @ @w{gpgme_key_t @var{key}}, @ @w{const char *@var{userid}}, @ @w{unsigned int @var{flags}}); @since{1.7.0} The function @code{gpgme_op_revuid_start} initiates a @code{gpgme_op_revuid} operation; see there for details. It must be completed by calling @code{gpgme_wait} on the context. @xref{Waiting For Completion}. @end deftypefun @c @c gpgme_op_set_uid_flag @c @deftypefun gpgme_error_t gpgme_op_set_ui_flag @ (@w{gpgme_ctx_t @var{ctx}}, @ @w{gpgme_key_t @var{key}}, @ @w{const char *@var{userid}}, @ @w{cons char * @var{name}}, @ @w{cons char * @var{value}}); @since{1.8.0} The function @code{gpgme_op_set_uid_flag} is used to set flags on a user ID from the OpenPGP key given by @var{KEY}. Setting flags on user IDs after key creation is a feature of the OpenPGP protocol and thus the protocol for the context @var{ctx} must be set to OpenPGP. @var{key} specifies the key to operate on. This parameters is required. @var{userid} is the user ID of the key to be manipulated. This user ID must be given verbatim because the engine does an exact and case sensitive match. Thus the @code{uid} field from the user ID object (@code{gpgme_user_id_t}) is to be used. This is a required parameter. @var{name} names the flag which is to be changed. The only currently supported flag is: @table @code @item primary This sets the primary key flag on the given user ID. All other primary key flag on other user IDs are removed. @var{value} must be given as NULL. For technical reasons this functions bumps the creation timestamp of all affected self-signatures up by one second. At least GnuPG version 2.1.20 is required. @end table The function returns zero on success, @code{GPG_ERR_NOT_SUPPORTED} if the engine does not support the command, or a bunch of other error codes. @end deftypefun @deftypefun gpgme_error_t gpgme_op_set_uid_flag_start @ (@w{gpgme_ctx_t @var{ctx}}, @ @w{gpgme_key_t @var{key}}, @ @w{const char *@var{userid}}, @ @w{cons char * @var{name}}, @ @w{cons char * @var{value}}); @since{1.8.0} The function @code{gpgme_op_set_uid_flag_start} initiates a @code{gpgme_op_set_uid_flag} operation; see there for details. It must be completed by calling @code{gpgme_wait} on the context. @xref{Waiting For Completion}. @end deftypefun @c @c gpgme_op_genkey @c @deftypefun gpgme_error_t gpgme_op_genkey @ (@w{gpgme_ctx_t @var{ctx}}, @ @w{const char *@var{parms}}, @ @w{gpgme_data_t @var{public}}, @ @w{gpgme_data_t @var{secret}}) The function @code{gpgme_op_genkey} generates a new key pair in the context @var{ctx}. The meaning of @var{public} and @var{secret} depends on the crypto backend. GPG does not support @var{public} and @var{secret}, they should be @code{NULL}. GnuPG will generate a key pair and add it to the standard key ring. The fingerprint of the generated key is available with @code{gpgme_op_genkey_result}. GpgSM requires @var{public} to be a writable data object. GpgSM will generate a secret key (which will be stored by @command{gpg-agent}, and return a certificate request in @var{public}, which then needs to be signed by the certification authority and imported before it can be used. GpgSM does not make the fingerprint available. The argument @var{parms} specifies parameters for the key in an string that looks something like XML. The details about the format of @var{parms} are specific to the crypto engine used by @var{ctx}. The first line of the parameters must be @code{} and the last line must be @code{}. Every line in between the first and last lines is treated as a Header: Value pair. In particular, no XML escaping is necessary if you need to include the characters @code{<}, @code{>}, or @code{&}. Here is an example for GnuPG as the crypto engine (all parameters of OpenPGP key generation are documented in the GPG manual): @example Key-Type: default Subkey-Type: default Name-Real: Joe Tester Name-Comment: with stupid passphrase Name-Email: joe@@foo.bar Expire-Date: 0 Passphrase: abc @end example Here is an example for GpgSM as the crypto engine (all parameters of OpenPGP key generation are documented in the GPGSM manual): @example Key-Type: RSA Key-Length: 1024 Name-DN: C=de,O=g10 code,OU=Testlab,CN=Joe 2 Tester Name-Email: joe@@foo.bar @end example Strings should be given in UTF-8 encoding. The only format supported for now is ``internal''. The content of the @code{GnupgKeyParms} container is passed verbatim to the crypto backend. Control statements are not allowed. After the operation completed successfully, the result can be 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 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. @end deftypefun @deftypefun gpgme_error_t gpgme_op_genkey_start (@w{gpgme_ctx_t @var{ctx}}, @w{const char *@var{parms}}, @w{gpgme_data_t @var{public}}, @w{gpgme_data_t @var{secret}}) The function @code{gpgme_op_genkey_start} initiates a @code{gpgme_op_genkey} operation. It can be completed by calling @code{gpgme_wait} on the context. @xref{Waiting For Completion}. 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 valid XML string, and @code{GPG_ERR_NOT_SUPPORTED} if @var{public} or @var{secret} is not @code{NULL}. @end deftypefun @c @c gpgme_op_genkey_result @c @deftp {Data type} {gpgme_genkey_result_t} This is a pointer to a structure used to store the result of a @code{gpgme_op_genkey} operation. After successfully generating a key, you can retrieve the pointer to the result with @code{gpgme_op_genkey_result}. The structure contains the following members: @table @code @item unsigned int primary : 1 This flag is set to 1 if a primary key was created and to 0 if not. @item unsigned int sub : 1 This flag is set to 1 if a subkey was created and to 0 if not. @item unsigned int uid : 1 This flag is set to 1 if a user ID was created and to 0 if not. @item char *fpr This is the fingerprint of the key that was created. If both a primary and a subkey were generated, the fingerprint of the primary key will be returned. If the crypto engine does not provide the fingerprint, @code{fpr} will be a null pointer. @item gpgme_data_t pubkey @since{1.7.0} This will eventually be used to return the public key. It is currently not used. @item gpgme_data_t seckey @since{1.7.0} This will eventually be used to return the secret key. It is currently not used. @end table @end deftp @deftypefun gpgme_genkey_result_t gpgme_op_genkey_result (@w{gpgme_ctx_t @var{ctx}}) The function @code{gpgme_op_genkey_result} returns a @code{gpgme_genkey_result_t} pointer to a structure holding the result of a @code{gpgme_op_genkey} operation. The pointer is only valid if the last operation on the context was a @code{gpgme_op_genkey} or @code{gpgme_op_genkey_start} operation, and if this operation finished successfully. The returned pointer is only valid until the next operation is started on the context. @end deftypefun @c @c SIGNING KEYS @c @node Signing Keys @subsection Signing Keys @cindex key, signing Key signatures are a unique concept of the OpenPGP protocol. They can be used to certify the validity of a key and are used to create the Web-of-Trust (WoT). Instead of using the @code{gpgme_op_interact} function along with a finite state machine, GPGME provides a convenient function to create key signatures when using modern GnuPG versions. @c @c gpgme_op_keysign @c @deftypefun gpgme_error_t gpgme_op_keysign @ (@w{gpgme_ctx_t @var{ctx}}, @ @w{gpgme_key_t @var{key}}, @ @w{const char *@var{userid}}, @ @w{unsigned long @var{expires}}, @ @w{unsigned int @var{flags}}); @since{1.7.0} The function @code{gpgme_op_keysign} adds a new key signature to the public key @var{KEY}. This function requires at least version 2.1.12 of GnuPG. @var{CTX} is the usual context which describes the protocol to use (which must be OpenPGP) and has also the list of signer keys to be used for the signature. The common case is to use the default key for signing other keys. If another key or more than one key shall be used for a key signature, @code{gpgme_signers_add} can be used. @xref{Selecting Signers}. @var{key} specifies the key to operate on. @var{userid} selects the user ID or user IDs to be signed. If @var{userid} is set to @code{NULL} all valid user IDs are signed. The user ID must be given verbatim because the engine does an exact and case sensitive match. Thus the @code{uid} field from the user ID object (@code{gpgme_user_id_t}) is to be used. To select more than one user ID put them all into one string separated by linefeeds characters (@code{\n}) and set the flag @code{GPGME_KEYSIGN_LFSEP}. @var{expires} specifies the expiration time of the new signature in seconds. The common case is to use 0 to not set an expiration date. However, if the configuration of the engine defines a default expiration for key signatures, that is still used unless the flag @code{GPGME_KEYSIGN_NOEXPIRE} is used. Note that this parameter takes an unsigned long value and not a @code{time_t} to avoid problems on systems which use a signed 32 bit @code{time_t}. Note further that the OpenPGP protocol uses 32 bit values for timestamps and thus can only encode dates up to the year 2106. @var{flags} can be set to the bit-wise OR of the following flags: @table @code @item GPGME_KEYSIGN_LOCAL @since{1.7.0} Instead of creating an exportable key signature, create a key signature which is is marked as non-exportable. @item GPGME_KEYSIGN_LFSEP @since{1.7.0} Although linefeeds are uncommon in user IDs this flag is required to explicitly declare that @var{userid} may contain several linefeed separated user IDs. @item GPGME_KEYSIGN_NOEXPIRE Force the creation of a key signature without an expiration date. This overrides @var{expire} and any local configuration of the engine. @end table The function returns zero on success, @code{GPG_ERR_NOT_SUPPORTED} if the engine does not support the command, or a bunch of other error codes. @end deftypefun @deftypefun gpgme_error_t gpgme_op_keysign_start @ (@w{gpgme_ctx_t @var{ctx}}, @ @w{gpgme_key_t @var{key}}, @ @w{const char *@var{userid}}, @ @w{unsigned long @var{expires}}, @ @w{unsigned int @var{flags}}); @since{1.7.0} The function @code{gpgme_op_keysign_start} initiates a @code{gpgme_op_keysign} operation; see there for details. It must be completed by calling @code{gpgme_wait} on the context. @xref{Waiting For Completion}. @end deftypefun @c @c EXPORTING KEYS @c @node Exporting Keys @subsection Exporting Keys @cindex key, export @cindex key ring, export from Exporting keys means the same as running @command{gpg} with the command @option{--export}. However, a mode flag can be used to change the way the export works. The available mode flags are described below, they may be or-ed together. @table @code @item GPGME_EXPORT_MODE_EXTERN If this bit is set, the output is send directly to the default keyserver. This is currently only allowed for OpenPGP keys. It is good practise to not send more than a few dozens key to a keyserver at one time. Using this flag requires that the @var{keydata} argument of the export function is set to @code{NULL}. @item GPGME_EXPORT_MODE_MINIMAL @since{1.3.1} If this bit is set, the smallest possible key is exported. For OpenPGP keys it removes all signatures except for the latest self-signatures. For X.509 keys it has no effect. @item GPGME_EXPORT_MODE_SECRET @since{1.6.0} Instead of exporting the public key, the secret key is exported. This may not be combined with @code{GPGME_EXPORT_MODE_EXTERN}. For X.509 the export format is PKCS#8. @item GPGME_EXPORT_MODE_RAW @since{1.6.0} If this flag is used with @code{GPGME_EXPORT_MODE_SECRET} for an X.509 key the export format will be changed to PKCS#1. This flag may not be used with OpenPGP. @item GPGME_EXPORT_MODE_PKCS12 @since{1.6.0} If this flag is used with @code{GPGME_EXPORT_MODE_SECRET} for an X.509 key the export format will be changed to PKCS#12 which also includes the certificate. This flag may not be used with OpenPGP. @item GPGME_EXPORT_MODE_NOUID @since{1.12.0 - experimental} Do not export user ids. Works only with certain gpg version. @end table @deftypefun gpgme_error_t gpgme_op_export (@w{gpgme_ctx_t @var{ctx}}, @w{const char *@var{pattern}}, @w{gpgme_export_mode_t @var{mode}}, @w{gpgme_data_t @var{keydata}}) The function @code{gpgme_op_export} extracts public keys and returns them in the data buffer @var{keydata}. The output format of the key data returned is determined by the @acronym{ASCII} armor attribute set for the context @var{ctx}, or, if that is not set, by the encoding specified for @var{keydata}. If @var{pattern} is @code{NULL}, all available keys are returned. Otherwise, @var{pattern} contains an engine specific expression that is used to limit the list to all keys matching the pattern. @var{mode} is usually 0; other values are described above. The function returns the error code @code{GPG_ERR_NO_ERROR} if the operation completed successfully, @code{GPG_ERR_INV_VALUE} if @var{keydata} is not a valid empty data buffer, and passes through any errors that are reported by the crypto engine support routines. @end deftypefun @deftypefun gpgme_error_t gpgme_op_export_start (@w{gpgme_ctx_t @var{ctx}}, @w{const char *@var{pattern}}, @w{gpgme_export_mode_t @var{mode}}, @w{gpgme_data_t @var{keydata}}) The function @code{gpgme_op_export_start} initiates a @code{gpgme_op_export} operation. It can be completed by calling @code{gpgme_wait} on the context. @xref{Waiting For Completion}. The function returns the error code @code{GPG_ERR_NO_ERROR} if the operation could be started successfully, and @code{GPG_ERR_INV_VALUE} if @var{keydata} is not a valid empty data buffer. @end deftypefun @deftypefun gpgme_error_t gpgme_op_export_ext (@w{gpgme_ctx_t @var{ctx}}, @w{const char *@var{pattern}[]}, @w{gpgme_export_mode_t @var{mode}}, @w{gpgme_data_t @var{keydata}}) The function @code{gpgme_op_export} extracts public keys and returns them in the data buffer @var{keydata}. The output format of the key data returned is determined by the @acronym{ASCII} armor attribute set for the context @var{ctx}, or, if that is not set, by the encoding specified for @var{keydata}. If @var{pattern} or @var{*pattern} is @code{NULL}, all available keys are returned. Otherwise, @var{pattern} is a @code{NULL} terminated array of strings that are used to limit the list to all keys matching at least one of the patterns verbatim. @var{mode} is usually 0; other values are described above. The function returns the error code @code{GPG_ERR_NO_ERROR} if the operation completed successfully, @code{GPG_ERR_INV_VALUE} if @var{keydata} is not a valid empty data buffer, and passes through any errors that are reported by the crypto engine support routines. @end deftypefun @deftypefun gpgme_error_t gpgme_op_export_ext_start (@w{gpgme_ctx_t @var{ctx}}, @w{const char *@var{pattern}[]}, @w{gpgme_export_mode_t @var{mode}}, @w{gpgme_data_t @var{keydata}}) The function @code{gpgme_op_export_ext_start} initiates a @code{gpgme_op_export_ext} operation. It can be completed by calling @code{gpgme_wait} on the context. @xref{Waiting For Completion}. The function returns the error code @code{GPG_ERR_NO_ERROR} if the operation could be started successfully, and @code{GPG_ERR_INV_VALUE} if @var{keydata} is not a valid empty data buffer. @end deftypefun @deftypefun gpgme_error_t gpgme_op_export_keys (@w{gpgme_ctx_t @var{ctx}}, @w{gpgme_key_t keys[]}, @w{gpgme_export_mode_t @var{mode}}, @w{gpgme_data_t @var{keydata}}) @since{1.2.0} The function @code{gpgme_op_export_keys} extracts public keys and returns them in the data buffer @var{keydata}. The output format of the key data returned is determined by the @acronym{ASCII} armor attribute set for the context @var{ctx}, or, if that is not set, by the encoding specified for @var{keydata}. The keys to export are taken form the @code{NULL} terminated array @var{keys}. Only keys of the currently selected protocol of @var{ctx} which do have a fingerprint set are considered for export. Other keys specified by the @var{keys} are ignored. In particular OpenPGP keys retrieved via an external key listing are not included. @var{mode} is usually 0; other values are described above. The function returns the error code @code{GPG_ERR_NO_ERROR} if the operation completed successfully, @code{GPG_ERR_INV_VALUE} if @var{keydata} is not a valid empty data buffer, @code{GPG_ERR_NO_DATA} if no useful keys are in @var{keys} and passes through any errors that are reported by the crypto engine support routines. @end deftypefun @deftypefun gpgme_error_t gpgme_op_export_keys_start (@w{gpgme_ctx_t @var{ctx}}, @w{gpgme_key_t @var{keys}[]}, @w{gpgme_export_mode_t @var{mode}}, @w{gpgme_data_t @var{keydata}}) @since{1.2.0} The function @code{gpgme_op_export_keys_start} initiates a @code{gpgme_op_export_ext} operation. It can be completed by calling @code{gpgme_wait} on the context. @xref{Waiting For Completion}. The function returns the error code @code{GPG_ERR_NO_ERROR} if the operation could be started successfully, and @code{GPG_ERR_INV_VALUE} if @var{keydata} is not a valid empty data buffer, @code{GPG_ERR_NO_DATA} if no useful keys are in @var{keys} and passes through any errors that are reported by the crypto engine support routines. @end deftypefun @node Importing Keys @subsection Importing Keys @cindex key, import @cindex key ring, import to Importing keys means the same as running @command{gpg} with the command @option{--import}. @deftypefun gpgme_error_t gpgme_op_import (@w{gpgme_ctx_t @var{ctx}}, @w{gpgme_data_t @var{keydata}}) The function @code{gpgme_op_import} adds the keys in the data buffer @var{keydata} to the key ring of the crypto engine used by @var{ctx}. The format of @var{keydata} can be @acronym{ASCII} armored, for example, but the details are specific to the crypto engine. After the operation completed successfully, the result can be retrieved with @code{gpgme_op_import_result}. The function returns the error code @code{GPG_ERR_NO_ERROR} if the import was completed successfully, @code{GPG_ERR_INV_VALUE} if @var{keydata} if @var{ctx} or @var{keydata} is not a valid pointer, and @code{GPG_ERR_NO_DATA} if @var{keydata} is an empty data buffer. @end deftypefun @deftypefun gpgme_error_t gpgme_op_import_start (@w{gpgme_ctx_t @var{ctx}}, @w{gpgme_data_t @var{keydata}}) The function @code{gpgme_op_import_start} initiates a @code{gpgme_op_import} operation. It can be completed by calling @code{gpgme_wait} on the context. @xref{Waiting For Completion}. The function returns the error code @code{GPG_ERR_NO_ERROR} if the import could be started successfully, @code{GPG_ERR_INV_VALUE} if @var{ctx} or @var{keydata} is not a valid pointer, and @code{GPG_ERR_NO_DATA} if @var{keydata} is an empty data buffer. @end deftypefun @deftypefun gpgme_error_t gpgme_op_import_keys (@w{gpgme_ctx_t @var{ctx}}, @w{gpgme_key_t *@var{keys}}) @since{1.2.0} 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 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 key to make an X.509 key permanent.} Note that for OpenPGP this may 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. After the operation completed successfully, the result can be retrieved with @code{gpgme_op_import_result}. To move keys from one home directory to another, export and import the keydata using @code{gpgme_op_export} and @code{gpgme_op_import}. The function returns the error code @code{GPG_ERR_NO_ERROR} if the import was completed successfully, @code{GPG_ERR_INV_VALUE} if @var{ctx} is not a valid pointer, @code{GPG_ERR_CONFLICT} if the key listing mode does not match, and @code{GPG_ERR_NO_DATA} if no keys are considered for export. @end deftypefun @deftypefun gpgme_error_t gpgme_op_import_keys_start (@w{gpgme_ctx_t @var{ctx}}, @w{gpgme_key_t *@var{keys}}) @since{1.2.0} The function @code{gpgme_op_import_keys_start} initiates a @code{gpgme_op_import_keys} operation. It can be completed by calling @code{gpgme_wait} on the context. @xref{Waiting For Completion}. The function returns the error code @code{GPG_ERR_NO_ERROR} if the import was completed successfully, @code{GPG_ERR_INV_VALUE} if @var{keydata} if @var{ctx} or @var{keydata} is not a valid pointer, @code{GPG_ERR_CONFLICT} if the key listing mode does not match, and @code{GPG_ERR_NO_DATA} if no keys are considered for export. @end deftypefun @deftp {Data type} {gpgme_import_status_t} This is a pointer to a structure used to store a part of the result of a @code{gpgme_op_import} operation. For each considered key one status is added that contains information about the result of the import. The structure contains the following members: @table @code @item gpgme_import_status_t next This is a pointer to the next status structure in the linked list, or @code{NULL} if this is the last element. @item char *fpr This is the fingerprint of the key that was considered. @item gpgme_error_t result If the import was not successful, this is the error value that caused the import to fail. Otherwise the error code is @code{GPG_ERR_NO_ERROR}. @item unsigned int status This is a bit-wise OR of the following flags that give more information about what part of the key was imported. If the key was already known, this might be 0. @table @code @item GPGME_IMPORT_NEW The key was new. @item GPGME_IMPORT_UID The key contained new user IDs. @item GPGME_IMPORT_SIG The key contained new signatures. @item GPGME_IMPORT_SUBKEY The key contained new sub keys. @item GPGME_IMPORT_SECRET The key contained a secret key. @end table @end table @end deftp @deftp {Data type} {gpgme_import_result_t} This is a pointer to a structure used to store the result of a @code{gpgme_op_import} operation. After a successful import operation, you can retrieve the pointer to the result with @code{gpgme_op_import_result}. The structure contains the following members: @table @code @item int considered The total number of considered keys. @item int no_user_id The number of keys without user ID. @item int imported The total number of imported keys. @item int imported_rsa The number of imported RSA keys. @item int unchanged The number of unchanged keys. @item int new_user_ids The number of new user IDs. @item int new_sub_keys The number of new sub keys. @item int new_signatures The number of new signatures. @item int new_revocations The number of new revocations. @item int secret_read The total number of secret keys read. @item int secret_imported The number of imported secret keys. @item int secret_unchanged The number of unchanged secret keys. @item int not_imported The number of keys not imported. @item gpgme_import_status_t imports A list of gpgme_import_status_t objects which contain more information about the keys for which an import was attempted. @item int skipped_v3_keys For security reasons modern versions of GnuPG do not anymore support v3 keys (created with PGP 2.x) and ignores them on import. This counter provides the number of such skipped v3 keys. @end table @end deftp @deftypefun gpgme_import_result_t gpgme_op_import_result (@w{gpgme_ctx_t @var{ctx}}) The function @code{gpgme_op_import_result} returns a @code{gpgme_import_result_t} pointer to a structure holding the result of a @code{gpgme_op_import} operation. The pointer is only valid if the last operation on the context was a @code{gpgme_op_import} or @code{gpgme_op_import_start} operation, and if this operation finished successfully. The returned pointer is only valid until the next operation is started on the context. @end deftypefun @node Deleting Keys @subsection Deleting Keys @cindex key, delete @cindex key ring, delete from @deftypefun gpgme_error_t gpgme_op_delete_ext (@w{gpgme_ctx_t @var{ctx}}, @w{const gpgme_key_t @var{key}}, @w{unsigned int @var{flags}}) @since{1.9.1} The function @code{gpgme_op_delete_ext} deletes the key @var{key} from the key ring of the crypto engine used by @var{ctx}. @var{flags} can be set to the bit-wise OR of the following flags: @table @code @item GPGME_DELETE_ALLOW_SECRET @since{1.9.1} If not set, only public keys are deleted. If set, secret keys are deleted as well, if that is supported. @item GPGME_DELETE_FORCE @since{1.9.1} If set, the user is not asked to confirm the deletion. @end table The function returns the error code @code{GPG_ERR_NO_ERROR} if the key was deleted successfully, @code{GPG_ERR_INV_VALUE} if @var{ctx} or @var{key} is not a valid pointer, @code{GPG_ERR_NO_PUBKEY} if @var{key} could not be found in the keyring, @code{GPG_ERR_AMBIGUOUS_NAME} if the key was not specified unambiguously, and @code{GPG_ERR_CONFLICT} if the secret key for @var{key} is available, but @var{allow_secret} is zero. @end deftypefun @deftypefun gpgme_error_t gpgme_op_delete_ext_start (@w{gpgme_ctx_t @var{ctx}}, @w{const gpgme_key_t @var{key}}, @w{unsigned int @var{flags}}) @since{1.9.1} The function @code{gpgme_op_delete_ext_start} initiates a @code{gpgme_op_delete} operation. It can be completed by calling @code{gpgme_wait} on the context. @xref{Waiting For Completion}. The function returns the error code @code{GPG_ERR_NO_ERROR} if the 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. @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. @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. @end deftypefun @node Changing Passphrases @subsection Changing Passphrases @cindex passphrase, change @deftypefun gpgme_error_t gpgme_op_passwd @ (@w{gpgme_ctx_t @var{ctx}}, @ @w{const gpgme_key_t @var{key}}, @ @w{unsigned int @var{flags}}) @since{1.3.0} The function @code{gpgme_op_passwd} changes the passphrase of the private key associated with @var{key}. The only allowed value for @var{flags} is @code{0}. The backend engine will usually popup a window to ask for the old and the new passphrase. Thus this function is not useful in a server application (where passphrases are not required anyway). Note that old @code{gpg} engines (before version 2.0.15) do not support this command and will silently ignore it. @end deftypefun @deftypefun gpgme_error_t gpgme_op_passwd_start @ (@w{gpgme_ctx_t @var{ctx}}, @ @w{const gpgme_key_t @var{key}}, @ @w{unsigned int @var{flags}}) @since{1.3.0} The function @code{gpgme_op_passwd_start} initiates a @code{gpgme_op_passwd} operation. It can be completed by calling @code{gpgme_wait} on the context. @xref{Waiting For Completion}. The function returns @code{0} if the operation was started successfully, and an error code if one of the arguments is not valid or the oepration could not be started. @end deftypefun @c @c CHANGING TOFU DATA @c @node Changing TOFU Data @subsection Changing TOFU Data @cindex validity, TOFU The OpenPGP engine features a Trust-On-First-Use (TOFU) key validation model. For resolving conflicts it is necessary to declare the policy for a key. See the GnuPG manual for details on the TOFU implementation. @deftp {Data type} {enum gpgme_tofu_policy_t} @since{1.7.0} @tindex gpgme_tofu_policy_t The @code{gpgme_tofu_policy_t} type specifies the set of possible policy values that are supported by @acronym{GPGME}: @table @code @item GPGME_TOFU_POLICY_AUTO Set the policy to ``auto''. @item GPGME_TOFU_POLICY_GOOD Set the policy to ``good''. @item GPGME_TOFU_POLICY_BAD Set the policy to ``bad''. @item GPGME_TOFU_POLICY_ASK Set the policy to ``ask''. @item GPGME_TOFU_POLICY_UNKNOWN Set the policy to ``unknown''. @end table @end deftp To change the policy for a key the following functions can be used: @deftypefun gpgme_error_t gpgme_op_tofu_policy @ (@w{gpgme_ctx_t @var{ctx}}, @ @w{const gpgme_key_t @var{key}}, @ @w{gpgme_tofu_policy_t @var{policy}}) @since{1.7.0} The function @code{gpgme_op_tofu_policy} changes the TOFU policy of @var{key}. The valid values for @var{policy} are listed above. As of now this function does only work for OpenPGP and requires at least version 2.1.10 of GnuPG. The function returns zero on success, @code{GPG_ERR_NOT_SUPPORTED} if the engine does not support the command, or a bunch of other error codes. @end deftypefun @deftypefun gpgme_error_t gpgme_op_tofu_policy_start @ (@w{gpgme_ctx_t @var{ctx}}, @ @w{const gpgme_key_t @var{key}}, @ @w{gpgme_tofu_policy_t @var{policy}}) @since{1.7.0} The function @code{gpgme_op_tofu_policy_start} initiates a @code{gpgme_op_tofu_policy} operation. It can be completed by calling @code{gpgme_wait} on the context. @xref{Waiting For Completion}. The function returns @code{0} if the operation was started successfully, and an error code if one of the arguments is not valid or the oepration could not be started. @end deftypefun @node Advanced Key Editing @subsection Advanced Key Editing @cindex key, edit @deftp {Data type} {gpgme_error_t (*gpgme_interact_cb_t) @ (@w{void *@var{handle}}, @ @w{const char *@var{status}}, @ @w{const char *@var{args}}, @ @w{int @var{fd}})} @since{1.7.0} @tindex gpgme_interact_cb_t The @code{gpgme_interact_cb_t} type is the type of functions which @acronym{GPGME} calls if it a key interact operation is on-going. The status keyword @var{status} and the argument line @var{args} are passed through by @acronym{GPGME} from the crypto engine. An empty string represents EOF. The file descriptor @var{fd} is -1 for normal status messages. If @var{status} indicates a command rather than a status message, the response to the command should be written to @var{fd}. The @var{handle} is provided by the user at start of operation. The function should return @code{GPG_ERR_FALSE} if it did not handle the status code, @code{0} for success, or any other error value. @end deftp @deftypefun gpgme_error_t gpgme_op_interact (@w{gpgme_ctx_t @var{ctx}}, @ @w{gpgme_key_t @var{key}}, @ @w{unsigned int @var{flags}}, @ @w{gpgme_interact_cb_t @var{fnc}}, @ @w{void *@var{handle}}, @ @w{gpgme_data_t @var{out}}) @since{1.7.0} The function @code{gpgme_op_interact} processes the key @var{KEY} interactively, using the interact callback function @var{FNC} with the handle @var{HANDLE}. The callback is invoked for every status and command request from the crypto engine. The output of the crypto engine is written to the data object @var{out}. Note that the protocol between the callback function and the crypto engine is specific to the crypto engine and no further support in implementing this protocol correctly is provided by @acronym{GPGME}. @var{flags} modifies the behaviour of the function; the only defined bit value is: @table @code @item GPGME_INTERACT_CARD @since{1.7.0} This is used for smartcard based keys and uses gpg’s @code{--card-edit} command. @end table The function returns @code{0} if the edit operation completes successfully, @code{GPG_ERR_INV_VALUE} if @var{ctx} or @var{key} is not a valid pointer, and any error returned by the crypto engine or the edit callback handler. @end deftypefun @deftypefun gpgme_error_t gpgme_op_interact_start (@w{gpgme_ctx_t @var{ctx}}, @ @w{gpgme_key_t @var{key}}, @ @w{unsigned int @var{flags}}, @ @w{gpgme_interact_cb_t @var{fnc}}, @ @w{void *@var{handle}}, @ @w{gpgme_data_t @var{out}}) @since{1.7.0} The function @code{gpgme_op_interact_start} initiates a @code{gpgme_op_interact} operation. It can be completed by calling @code{gpgme_wait} on the context. @xref{Waiting For Completion}. The function returns @code{0} if the operation was started successfully, and @code{GPG_ERR_INV_VALUE} if @var{ctx} or @var{key} is not a valid pointer. @end deftypefun @node Trust Item Management @section Trust Item Management @cindex trust item @strong{Caution:} The trust items interface is experimental. @deftp {Data type} gpgme_trust_item_t The @code{gpgme_trust_item_t} type is a pointer to a trust item object. It has the following members: @table @code @item char *keyid This is a string describing the key to which this trust items belongs. @item int type This is the type of the trust item. A value of 1 refers to a key, a value of 2 refers to a user ID. @item int level This is the trust level. @item char *owner_trust The owner trust if @code{type} is 1. @item char *validity The calculated validity. @item char *name The user name if @code{type} is 2. @end table @end deftp @menu * Listing Trust Items:: Browsing the list of available trust items. * Manipulating Trust Items:: Operations on trust items. @end menu @node Listing Trust Items @subsection Listing Trust Items @cindex trust item list @deftypefun gpgme_error_t gpgme_op_trustlist_start (@w{gpgme_ctx_t @var{ctx}}, @w{const char *@var{pattern}}, @w{int @var{max_level}}) The function @code{gpgme_op_trustlist_start} initiates a trust item listing operation inside the context @var{ctx}. It sets everything up so that subsequent invocations of @code{gpgme_op_trustlist_next} return the trust items in the list. The string @var{pattern} contains an engine specific expression that is used to limit the list to all trust items matching the pattern. It can not be the empty string. The argument @var{max_level} is currently ignored. The context will be busy until either all trust items are received (and @code{gpgme_op_trustlist_next} returns @code{GPG_ERR_EOF}), or @code{gpgme_op_trustlist_end} is called to finish the operation. The function returns the error code @code{GPG_ERR_INV_VALUE} if @var{ctx} is not a valid pointer, and passes through any errors that are reported by the crypto engine support routines. @end deftypefun @deftypefun gpgme_error_t gpgme_op_trustlist_next (@w{gpgme_ctx_t @var{ctx}}, @w{gpgme_trust_item_t *@var{r_item}}) The function @code{gpgme_op_trustlist_next} returns the next trust item in the list created by a previous @code{gpgme_op_trustlist_start} operation in the context @var{ctx}. The trust item can be destroyed with @code{gpgme_trust_item_release}. @xref{Manipulating Trust Items}. This is the only way to get at @code{gpgme_trust_item_t} objects in @acronym{GPGME}. If the last trust item in the list has already been returned, @code{gpgme_op_trustlist_next} returns @code{GPG_ERR_EOF}. The function returns the error code @code{GPG_ERR_INV_VALUE} if @var{ctx} or @var{r_item} is not a valid pointer, and @code{GPG_ERR_ENOMEM} if there is not enough memory for the operation. @end deftypefun @deftypefun gpgme_error_t gpgme_op_trustlist_end (@w{gpgme_ctx_t @var{ctx}}) The function @code{gpgme_op_trustlist_end} ends a pending trust list operation in the context @var{ctx}. The function returns the error code @code{GPG_ERR_INV_VALUE} if @var{ctx} is not a valid pointer, and @code{GPG_ERR_ENOMEM} if at some time during the operation there was not enough memory available. @end deftypefun @node Manipulating Trust Items @subsection Manipulating Trust Items @cindex trust item, manipulation @deftypefun void gpgme_trust_item_ref (@w{gpgme_trust_item_t @var{item}}) The function @code{gpgme_trust_item_ref} acquires an additional reference for the trust item @var{item}. @end deftypefun @deftypefun void gpgme_trust_item_unref (@w{gpgme_trust_item_t @var{item}}) The function @code{gpgme_trust_item_unref} releases a reference for the trust item @var{item}. If this was the last reference, the trust item will be destroyed and all resources associated to it will be released. @end deftypefun @node Crypto Operations @section Crypto Operations @cindex cryptographic operation Sometimes, the result of a crypto operation returns a list of invalid keys encountered in processing the request. The following structure is used to hold information about such a key. @deftp {Data type} {gpgme_invalid_key_t} This is a pointer to a structure used to store a part of the result of a crypto operation which takes user IDs as one input parameter. The structure contains the following members: @table @code @item gpgme_invalid_key_t next This is a pointer to the next invalid key structure in the linked list, or @code{NULL} if this is the last element. @item char *fpr The fingerprint or key ID of the invalid key encountered. @item gpgme_error_t reason An error code describing the reason why the key was found invalid. @end table @end deftp @menu * Decrypt:: Decrypting a ciphertext. * Verify:: Verifying a signature. * Decrypt and Verify:: Decrypting a signed ciphertext. * Sign:: Creating a signature. * Encrypt:: Encrypting a plaintext. @end menu @node Decrypt @subsection Decrypt @cindex decryption @cindex cryptographic operation, decryption @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 @var{plain}. The function returns the error code @code{GPG_ERR_NO_ERROR} if the ciphertext could be decrypted successfully, @code{GPG_ERR_INV_VALUE} if @var{ctx}, @var{cipher} or @var{plain} is not a valid pointer, @code{GPG_ERR_NO_DATA} if @var{cipher} does not contain any data to decrypt, @code{GPG_ERR_DECRYPT_FAILED} if @var{cipher} is not a valid cipher text, @code{GPG_ERR_BAD_PASSPHRASE} if the passphrase for the secret key could not be retrieved, and passes through some errors that are reported by the crypto engine support routines. @end deftypefun @deftypefun gpgme_error_t gpgme_op_decrypt_start (@w{gpgme_ctx_t @var{ctx}}, @w{gpgme_data_t @var{cipher}}, @w{gpgme_data_t @var{plain}}) The function @code{gpgme_op_decrypt_start} initiates a @code{gpgme_op_decrypt} operation. It can be completed by calling @code{gpgme_wait} on the context. @xref{Waiting For Completion}. The function returns the error code @code{GPG_ERR_NO_ERROR} if the operation could be started successfully, and @code{GPG_ERR_INV_VALUE} if @var{cipher} or @var{plain} is not a valid pointer. @end deftypefun @deftypefun gpgme_error_t gpgme_op_decrypt_ext ( @ @w{gpgme_ctx_t @var{ctx}}, @ @w{gpgme_decrypt_flags_t @var{flags}}, @ @w{gpgme_data_t @var{cipher}}, @ @w{gpgme_data_t @var{plain}}) @since{1.8.0} The function @code{gpgme_op_decrypt_ext} is the same as @code{gpgme_op_decrypt} but has an additional argument @var{flags}. If @var{flags} is 0 both function behave identically. The value in @var{flags} is a bitwise-or combination of one or multiple of the following bit values: @table @code @item GPGME_DECRYPT_VERIFY @since{1.8.0} The @code{GPGME_DECRYPT_VERIFY} symbol specifies that this function -shall exacty act as @code{gpgme_op_decrypt_verify}. +shall exactly act as @code{gpgme_op_decrypt_verify}. @item GPGME_DECRYPT_UNWRAP @since{1.8.0} The @code{GPGME_DECRYPT_UNWRAP} symbol specifies that the output shall be an OpenPGP message with only the encryption layer removed. This requires GnuPG 2.1.12 and works only for OpenPGP. This is the counterpart to @code{GPGME_ENCRYPT_WRAP}. @end table -The function returns the error codes as descriped for +The function returns the error codes as described for @code{gpgme_op_decrypt} respective @code{gpgme_op_encrypt}. @end deftypefun @deftypefun gpgme_error_t gpgme_op_decrypt_ext_start ( @ @w{gpgme_ctx_t @var{ctx}}, @ @w{gpgme_decrypt_flags_t @var{flags}}, @ @w{gpgme_data_t @var{cipher}}, @ @w{gpgme_data_t @var{plain}}) @since{1.8.0} The function @code{gpgme_op_decrypt_ext_start} initiates a @code{gpgme_op_decrypt_ext} operation. It can be completed by calling @code{gpgme_wait} on the context. @xref{Waiting For Completion}. The function returns the error code @code{GPG_ERR_NO_ERROR} if the operation could be started successfully, and @code{GPG_ERR_INV_VALUE} if @var{cipher} or @var{plain} is not a valid pointer. @end deftypefun @deftp {Data type} {gpgme_recipient_t} @since{1.1.0} This is a pointer to a structure used to store information about the recipient of an encrypted text which is decrypted in a @code{gpgme_op_decrypt} operation. This information (except for the status field) is even available before the operation finished successfully, for example in a passphrase callback. The structure contains the following members: @table @code @item gpgme_recipient_t next This is a pointer to the next recipient structure in the linked list, or @code{NULL} if this is the last element. @item gpgme_pubkey_algo_t The public key algorithm used in the encryption. @item char *keyid This is the key ID of the key (in hexadecimal digits) used as recipient. @item gpgme_error_t status This is an error number with the error code GPG_ERR_NO_SECKEY if the secret key for this recipient is not available, and 0 otherwise. @end table @end deftp @deftp {Data type} {gpgme_decrypt_result_t} This is a pointer to a structure used to store the result of a @code{gpgme_op_decrypt} operation. After successfully decrypting data, you can retrieve the pointer to the result with @code{gpgme_op_decrypt_result}. As with all result structures, it this structure shall be considered read-only and an application must not allocate such a strucure on its own. The structure contains the following members: @table @code @item char *unsupported_algorithm If an unsupported algorithm was encountered, this string describes the algorithm that is not supported. @item unsigned int wrong_key_usage : 1 @since{0.9.0} This is true if the key was not used according to its policy. @item unsigned int legacy_cipher_nomdc : 1 @since{1.11.2} The message was made by a legacy algorithm without any integrity protection. This might be an old but legitimate message. @item unsigned int is_mime : 1; @since{1.11.0} The message claims that the content is a MIME object. @item unsigned int is_de_vs : 1; @since{1.10.0} The message was encrypted in a VS-NfD compliant way. This is a specification in Germany for a restricted communication level. @item gpgme_recipient_t recipients @since{1.1.0} This is a linked list of recipients to which this message was encrypted. @item char *file_name This is the filename of the original plaintext message file if it is known, otherwise this is a null pointer. @item char *session_key @since{1.8.0} A textual representation (nul-terminated string) of the session key used in symmetric encryption of the message, if the context has been set to export session keys (see @code{gpgme_set_ctx_flag, "export-session-key"}), and a session key was available for the most recent decryption operation. Otherwise, this is a null pointer. You must not try to access this member of the struct unless @code{gpgme_set_ctx_flag (ctx, "export-session-key")} returns success or @code{gpgme_get_ctx_flag (ctx, "export-session-key")} returns true (non-empty string). @item char *symkey_algo @since{1.11.0} A string with the symmetric encryption algorithm and mode using the format ".". Note that the deprecated non-MDC encryption mode of OpenPGP is given as "PGPCFB". @end table @end deftp @deftypefun gpgme_decrypt_result_t gpgme_op_decrypt_result (@w{gpgme_ctx_t @var{ctx}}) The function @code{gpgme_op_decrypt_result} returns a @code{gpgme_decrypt_result_t} pointer to a structure holding the result of a @code{gpgme_op_decrypt} operation. The pointer is only valid if the last operation on the context was a @code{gpgme_op_decrypt} or @code{gpgme_op_decrypt_start} operation. If the operation failed this might be a @code{NULL} pointer. The returned pointer is only valid until the next operation is started on the context. @end deftypefun @node Verify @subsection Verify @cindex verification @cindex signature, verification @cindex cryptographic operation, verification @cindex cryptographic operation, signature check @cindex signature notation data @cindex notation data @deftypefun gpgme_error_t gpgme_op_verify (@w{gpgme_ctx_t @var{ctx}}, @w{gpgme_data_t @var{sig}}, @w{gpgme_data_t @var{signed_text}}, @w{gpgme_data_t @var{plain}}) The function @code{gpgme_op_verify} verifies that the signature in the data object @var{sig} is a valid signature. If @var{sig} is a detached signature, then the signed text should be provided in @var{signed_text} and @var{plain} should be a null pointer. 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. The results of the individual signature verifications can be retrieved with @code{gpgme_op_verify_result}. The function returns the error code @code{GPG_ERR_NO_ERROR} if the operation could be completed successfully, @code{GPG_ERR_INV_VALUE} if @var{ctx}, @var{sig} or @var{plain} is not a valid pointer, @code{GPG_ERR_NO_DATA} if @var{sig} does not contain any data to verify, and passes through any errors that are reported by the crypto engine support routines. @end deftypefun @deftypefun gpgme_error_t gpgme_op_verify_start (@w{gpgme_ctx_t @var{ctx}}, @w{gpgme_data_t @var{sig}}, @w{gpgme_data_t @var{signed_text}}, @w{gpgme_data_t @var{plain}}) The function @code{gpgme_op_verify_start} initiates a @code{gpgme_op_verify} operation. It can be completed by calling @code{gpgme_wait} on the context. @xref{Waiting For Completion}. 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{ctx}, @var{sig} or @var{plain} is not a valid pointer, and @code{GPG_ERR_NO_DATA} if @var{sig} or @var{plain} does not contain any data to verify. @end deftypefun @deftp {Data type} {gpgme_sig_notation_t} This is a pointer to a structure used to store a part of the result of a @code{gpgme_op_verify} operation. The structure contains the following members: @table @code @item gpgme_sig_notation_t next This is a pointer to the next new signature notation structure in the linked list, or @code{NULL} if this is the last element. @item char *name The name of the notation field. If this is @code{NULL}, then the member @code{value} will contain a policy URL. @item int name_len The length of the @code{name} field. For strings the length is counted without the trailing binary zero. @item char *value The value of the notation field. If @code{name} is @code{NULL}, then this is a policy URL. @item int value_len The length of the @code{value} field. For strings the length is counted without the trailing binary zero. @item gpgme_sig_notation_flags_t flags The accumulated flags field. This field contains the flags associated with the notation data in an accumulated form which can be used as an argument to the function @code{gpgme_sig_notation_add}. The value @code{flags} is a bitwise-or combination of one or multiple of the following bit values: @table @code @item GPGME_SIG_NOTATION_HUMAN_READABLE @since{1.1.0} The @code{GPGME_SIG_NOTATION_HUMAN_READABLE} symbol specifies that the notation data is in human readable form @item GPGME_SIG_NOTATION_CRITICAL @since{1.1.0} The @code{GPGME_SIG_NOTATION_CRITICAL} symbol specifies that the notation data is critical. @end table @item unsigned int human_readable : 1 This is true if the @code{GPGME_SIG_NOTATION_HUMAN_READABLE} flag is set and false otherwise. This flag is only valid for notation data, not for policy URLs. @item unsigned int critical : 1 This is true if the @code{GPGME_SIG_NOTATION_CRITICAL} flag is set and false otherwise. This flag is valid for notation data and policy URLs. @end table @end deftp @deftp {Data type} {gpgme_signature_t} This is a pointer to a structure used to store a part of the result of a @code{gpgme_op_verify} operation. The structure contains the following members: @table @code @item gpgme_signature_t next This is a pointer to the next new signature structure in the linked list, or @code{NULL} if this is the last element. @item gpgme_sigsum_t summary This is a bit vector giving a summary of the signature status. It provides an easy interface to a defined semantic of the signature status. Checking just one bit is sufficient to see whether a signature is valid without any restrictions. This means that you can check for GPGME_SIGSUM_VALID like this: @example if ((sig.summary & GPGME_SIGSUM_VALID)) @{ ..do stuff if valid.. @} else @{ ..do stuff if not fully valid.. @} @end example The defined bits are: @table @code @item GPGME_SIGSUM_VALID The signature is fully valid. @item GPGME_SIGSUM_GREEN The signature is good but one might want to display some extra information. Check the other bits. @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 signature invalid when the message was received prior to the cause for the revocation. @item GPGME_SIGSUM_KEY_REVOKED The key or at least one certificate has been revoked. @item GPGME_SIGSUM_KEY_EXPIRED The key or one of the certificates has expired. It is probably a good idea to display the date of the expiration. @item GPGME_SIGSUM_SIG_EXPIRED The signature has expired. @item GPGME_SIGSUM_KEY_MISSING Can't verify due to a missing key or certificate. @item GPGME_SIGSUM_CRL_MISSING The CRL (or an equivalent mechanism) is not available. @item GPGME_SIGSUM_CRL_TOO_OLD Available CRL is too old. @item GPGME_SIGSUM_BAD_POLICY A policy requirement was not met. @item GPGME_SIGSUM_SYS_ERROR - A system error occured. + A system error occurred. @item GPGME_SIGSUM_TOFU_CONFLICT A TOFU conflict was detected. @end table @item char *fpr This is the fingerprint or key ID of the signature. @item gpgme_error_t status This is the status of the signature. In particular, the following status codes are of interest: @table @code @item GPG_ERR_NO_ERROR This status indicates that the signature is valid. For the combined result this status means that all signatures are valid. @item GPG_ERR_SIG_EXPIRED This status indicates that the signature is valid but expired. For the combined result this status means that all signatures are valid and expired. @item GPG_ERR_KEY_EXPIRED This status indicates that the signature is valid but the key used to verify the signature has expired. For the combined result this status means that all signatures are valid and all keys are expired. @item GPG_ERR_CERT_REVOKED This status indicates that the signature is valid but the key used to verify the signature has been revoked. For the combined result this status means that all signatures are valid and all keys are revoked. @item GPG_ERR_BAD_SIGNATURE This status indicates that the signature is invalid. For the combined result this status means that all signatures are invalid. @item GPG_ERR_NO_PUBKEY This status indicates that the signature could not be verified due to a missing key. For the combined result this status means that all signatures could not be checked due to missing keys. @item GPG_ERR_GENERAL This status indicates that there was some other error which prevented the signature verification. @end table @item gpgme_sig_notation_t notations This is a linked list with the notation data and policy URLs. @item unsigned long timestamp The creation timestamp of this signature. @item unsigned long exp_timestamp The expiration timestamp of this signature, or 0 if the signature does not expire. @item unsigned int wrong_key_usage : 1 This is true if the key was not used according to its policy. @item unsigned int pka_trust : 2 This is set to the trust information gained by means of the PKA system. Values are: @table @code @item 0 No PKA information available or verification not possible. @item 1 PKA verification failed. @item 2 PKA verification succeeded. @item 3 Reserved for future use. @end table Depending on the configuration of the engine, this metric may also be reflected by the validity of the signature. @item unsigned int chain_model : 1 @since{1.1.6} This is true if the validity of the signature has been checked using the chain model. In the chain model the time the signature has been created must be within the validity period of the certificate and the time the certificate itself has been created must be within the validity period of the issuing certificate. In contrast the default validation model checks the validity of signature as well at the entire certificate chain at the current time. @item gpgme_validity_t validity The validity of the signature. @item gpgme_error_t validity_reason If a signature is not valid, this provides a reason why. @item gpgme_pubkey_algo_t The public key algorithm used to create this signature. @item gpgme_hash_algo_t The hash algorithm used to create this signature. @item char *pka_address The mailbox from the PKA information or @code{NULL}. @item gpgme_key_t key @since{1.7.0} An object describing the key used to create the signature. This key object may be incomplete in that it only conveys information availabale directly with a signature. It may also be @code{NULL} if such information is not readily available. @end table @end deftp @deftp {Data type} {gpgme_verify_result_t} This is a pointer to a structure used to store the result of a @code{gpgme_op_verify} operation. After verifying a signature, you can retrieve the pointer to the result with @code{gpgme_op_verify_result}. If the operation failed this might be a @code{NULL} pointer. The structure contains the following member: @table @code @item gpgme_signature_t signatures A linked list with information about all signatures for which a verification was attempted. @item char *file_name This is the filename of the original plaintext message file if it is known, otherwise this is a null pointer. Warning: The filename is not covered by the signature. @item unsigned int is_mime : 1; @since{1.11.0} The message claims that the content is a MIME object. Warning: This flag is not covered by the signature. @end table @end deftp @deftypefun gpgme_verify_result_t gpgme_op_verify_result (@w{gpgme_ctx_t @var{ctx}}) The function @code{gpgme_op_verify_result} returns a @code{gpgme_verify_result_t} pointer to a structure holding the result of a @code{gpgme_op_verify} operation. The pointer is only valid if the last operation on the context was a @code{gpgme_op_verify}, @code{gpgme_op_verify_start}, @code{gpgme_op_decrypt_verify} or @code{gpgme_op_decrypt_verify_start} operation, and if this operation finished successfully (for @code{gpgme_op_decrypt_verify} and @code{gpgme_op_decrypt_verify_start}, the error code @code{GPG_ERR_NO_DATA} counts as successful in this context). The returned pointer is only valid until the next operation is started on the context. @end deftypefun @node Decrypt and Verify @subsection Decrypt and Verify @cindex decryption and verification @cindex verification and decryption @cindex signature check @cindex cryptographic operation, decryption and verification @deftypefun gpgme_error_t gpgme_op_decrypt_verify (@w{gpgme_ctx_t @var{ctx}}, @w{gpgme_data_t @var{cipher}}, @w{gpgme_data_t @var{plain}}) The function @code{gpgme_op_decrypt_verify} decrypts the ciphertext in the data object @var{cipher} and stores it into the data object @var{plain}. If @var{cipher} contains signatures, they will be verified. After the operation completed, @code{gpgme_op_decrypt_result} and @code{gpgme_op_verify_result} can be used to retrieve more information about the signatures. If the error code @code{GPG_ERR_NO_DATA} is returned, @var{cipher} does not contain any data to decrypt. However, it might still be signed. The information about detected signatures is available with @code{gpgme_op_verify_result} in this case. The function returns the error code @code{GPG_ERR_NO_ERROR} if the ciphertext could be decrypted successfully, @code{GPG_ERR_INV_VALUE} if @var{ctx}, @var{cipher} or @var{plain} is not a valid pointer, @code{GPG_ERR_NO_DATA} if @var{cipher} does not contain any data to decrypt, @code{GPG_ERR_DECRYPT_FAILED} if @var{cipher} is not a valid cipher text, @code{GPG_ERR_BAD_PASSPHRASE} if the passphrase for the secret key could not be retrieved, and passes through any errors that are reported by the crypto engine support routines. @end deftypefun @deftypefun gpgme_error_t gpgme_op_decrypt_verify_start (@w{gpgme_ctx_t @var{ctx}}, @w{gpgme_data_t @var{cipher}}, @w{gpgme_data_t @var{plain}}) The function @code{gpgme_op_decrypt_verify_start} initiates a @code{gpgme_op_decrypt_verify} operation. It can be completed by calling @code{gpgme_wait} on the context. @xref{Waiting For Completion}. 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{ctx}, @var{cipher}, @var{plain} or @var{r_stat} is not a valid pointer, and @code{GPG_ERR_NO_DATA} if @var{cipher} does not contain any data to decrypt. @end deftypefun When processing mails it is sometimes useful to extract the actual mail address (the ``addr-spec'') from a string. GPGME provides this helper function which uses the same semantics as the internal functions in GPGME and GnuPG: @deftypefun @w{char *} gpgme_addrspec_from_uid (@w{const char *@var{uid}}) @since{1.7.1} 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 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}) or for other errors. @end deftypefun @node Sign @subsection Sign @cindex signature, creation @cindex sign @cindex cryptographic operation, signing A signature can contain signatures by one or more keys. The set of keys used to create a signatures is contained in a context, and is applied to all following signing operations in this context (until the set is changed). @menu * Selecting Signers:: How to choose the keys to sign with. * Creating a Signature:: How to create a signature. * Signature Notation Data:: How to add notation data to a signature. @end menu @node Selecting Signers @subsubsection Selecting Signers @cindex signature, selecting signers @cindex signers, selecting The key or the keys used to create a signature are stored in the context. The following functions can be used to manipulate this list. If no signer has been set into the context a default key is used for signing. @deftypefun void gpgme_signers_clear (@w{gpgme_ctx_t @var{ctx}}) The function @code{gpgme_signers_clear} releases a reference for each key on the signers list and removes the list of signers from the context @var{ctx}. Every context starts with an empty list. @end deftypefun @deftypefun gpgme_error_t gpgme_signers_add (@w{gpgme_ctx_t @var{ctx}}, @w{const gpgme_key_t @var{key}}) The function @code{gpgme_signers_add} adds the key @var{key} to the list of signers in the context @var{ctx}. Calling this function acquires an additional reference for the key. @end deftypefun @deftypefun @w{unsigned int} gpgme_signers_count (@w{const gpgme_ctx_t @var{ctx}}) @since{1.4.3} The function @code{gpgme_signers_count} returns the number of signer keys in the context @var{ctx}. @end deftypefun @deftypefun gpgme_key_t gpgme_signers_enum (@w{const gpgme_ctx_t @var{ctx}}, @w{int @var{seq}}) The function @code{gpgme_signers_enum} returns the @var{seq}th key in the list of signers in the context @var{ctx}. An additional reference is acquired for the user. If @var{seq} is out of range, @code{NULL} is returned. @end deftypefun @node Creating a Signature @subsubsection Creating a Signature @deftp {Data type} {enum gpgme_sig_mode_t} @tindex gpgme_sig_mode_t The @code{gpgme_sig_mode_t} type is used to specify the desired type of a signature. The following modes are available: @table @code @item GPGME_SIG_MODE_NORMAL A normal signature is made, the output includes the plaintext and the signature. @item GPGME_SIG_MODE_DETACH A detached signature is made. @item GPGME_SIG_MODE_CLEAR A clear text signature is made. The @acronym{ASCII} armor and text mode settings of the context are ignored. @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}. After the operation completed successfully, the result can be retrieved with @code{gpgme_op_sign_result}. If an S/MIME signed message is created using the CMS crypto engine, the number of certificates to include in the message can be specified with @code{gpgme_set_include_certs}. @xref{Included Certificates}. The function returns the error code @code{GPG_ERR_NO_ERROR} if the signature could be created successfully, @code{GPG_ERR_INV_VALUE} if @var{ctx}, @var{plain} or @var{sig} is not a valid pointer, @code{GPG_ERR_NO_DATA} if the signature could not be created, @code{GPG_ERR_BAD_PASSPHRASE} if the passphrase for the secret key could not be retrieved, @code{GPG_ERR_UNUSABLE_SECKEY} if there are invalid signers, and passes through any errors that are reported by the crypto engine support routines. @end deftypefun @deftypefun gpgme_error_t gpgme_op_sign_start (@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_start} initiates a @code{gpgme_op_sign} operation. It can be completed by calling @code{gpgme_wait} on the context. @xref{Waiting For Completion}. The function returns the error code @code{GPG_ERR_NO_ERROR} if the operation could be started successfully, and @code{GPG_ERR_INV_VALUE} if @var{ctx}, @var{plain} or @var{sig} is not a valid pointer. @end deftypefun @deftp {Data type} {gpgme_new_signature_t} This is a pointer to a structure used to store a part of the result of a @code{gpgme_op_sign} operation. The structure contains the following members: @table @code @item gpgme_new_signature_t next This is a pointer to the next new signature structure in the linked list, or @code{NULL} if this is the last element. @item gpgme_sig_mode_t type The type of this signature. @item gpgme_pubkey_algo_t pubkey_algo The public key algorithm used to create this signature. @item gpgme_hash_algo_t hash_algo The hash algorithm used to create this signature. @item unsigned int sig_class The signature class of this signature. @item long int timestamp The creation timestamp of this signature. @item char *fpr The fingerprint of the key which was used to create this signature. @end table @end deftp @deftp {Data type} {gpgme_sign_result_t} This is a pointer to a structure used to store the result of a @code{gpgme_op_sign} operation. After successfully generating a signature, you can retrieve the pointer to the result with @code{gpgme_op_sign_result}. The structure contains the following members: @table @code @item gpgme_invalid_key_t invalid_signers A linked list with information about all invalid keys for which a signature could not be created. @item gpgme_new_signature_t signatures A linked list with information about all signatures created. @end table @end deftp @deftypefun gpgme_sign_result_t gpgme_op_sign_result (@w{gpgme_ctx_t @var{ctx}}) The function @code{gpgme_op_sign_result} returns a @code{gpgme_sign_result_t} pointer to a structure holding the result of a @code{gpgme_op_sign} operation. The pointer is only valid if the last operation on the context was a @code{gpgme_op_sign}, @code{gpgme_op_sign_start}, @code{gpgme_op_encrypt_sign} or @code{gpgme_op_encrypt_sign_start} operation. If that operation failed, the function might return a @code{NULL} pointer. The returned pointer is only valid until the next operation is started on the context. @end deftypefun @node Signature Notation Data @subsubsection Signature Notation Data @cindex notation data @cindex signature notation data @cindex policy URL Using the following functions, you can attach arbitrary notation data to a signature. This information is then available to the user when the signature is verified. @deftypefun void gpgme_sig_notation_clear (@w{gpgme_ctx_t @var{ctx}}) @since{1.1.0} The function @code{gpgme_sig_notation_clear} removes the notation data from the context @var{ctx}. Subsequent signing operations from this context will not include any notation data. Every context starts with an empty notation data list. @end deftypefun @deftypefun gpgme_error_t gpgme_sig_notation_add (@w{gpgme_ctx_t @var{ctx}}, @w{const char *@var{name}}, @w{const char *@var{value}}, @w{gpgme_sig_notation_flags_t @var{flags}}) @since{1.1.0} The function @code{gpgme_sig_notation_add} adds the notation data with the name @var{name} and the value @var{value} to the context @var{ctx}. Subsequent signing operations will include this notation data, as well as any other notation data that was added since the creation of the context or the last @code{gpgme_sig_notation_clear} operation. The arguments @var{name} and @var{value} must be @code{NUL}-terminated strings in human-readable form. The flag @code{GPGME_SIG_NOTATION_HUMAN_READABLE} is implied (non-human-readable notation data is currently not supported). The strings must be in UTF-8 encoding. If @var{name} is @code{NULL}, then @var{value} should be a policy URL. The function @code{gpgme_sig_notation_add} returns the error code @code{GPG_ERR_NO_ERROR} if the notation data could be added successfully, @code{GPG_ERR_INV_VALUE} if @var{ctx} is not a valid pointer, or if @var{name}, @var{value} and @var{flags} are an invalid combination. The function also passes through any errors that are reported by the crypto engine support routines. @end deftypefun @deftypefun gpgme_sig_notation_t gpgme_sig_notation_get (@w{const gpgme_ctx_t @var{ctx}}) @since{1.1.0} The function @code{gpgme_sig_notation_get} returns the linked list of notation data structures that are contained in the context @var{ctx}. If @var{ctx} is not a valid pointer, or there is no notation data added for this context, @code{NULL} is returned. @end deftypefun @node Encrypt @subsection Encrypt @cindex encryption @cindex cryptographic operation, encryption One plaintext can be encrypted for several recipients at the same time. The list of recipients is created independently of any context, and then passed to the encryption operation. @menu * Encrypting a Plaintext:: How to encrypt a plaintext. @end menu @node Encrypting a Plaintext @subsubsection Encrypting a Plaintext @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}. @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 call (but see @code{gpgme_op_encrypt_start} for the requirements with the asynchronous variant). The value in @var{flags} is a bitwise-or combination of one or multiple of the following bit values: @table @code @item GPGME_ENCRYPT_ALWAYS_TRUST The @code{GPGME_ENCRYPT_ALWAYS_TRUST} symbol specifies that all the 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. @item GPGME_ENCRYPT_NO_ENCRYPT_TO @since{1.2.0} The @code{GPGME_ENCRYPT_NO_ENCRYPT_TO} symbol specifies that no default or hidden default recipients as configured in the crypto backend should be included. This can be useful for managing different user profiles. @item GPGME_ENCRYPT_NO_COMPRESS @since{1.5.0} The @code{GPGME_ENCRYPT_NO_COMPRESS} symbol specifies that the plaintext shall not be compressed before it is encrypted. This is in some cases useful if the length of the encrypted message 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 @code{PREP_ENCRYPT} command). With the @code{GPGME_ENCRYPT_EXPECT_SIGN} symbol the UI Server is advised to also expect a sign command. @item GPGME_ENCRYPT_SYMMETRIC @since{1.7.0} The @code{GPGME_ENCRYPT_SYMMETRIC} symbol specifies that the output should be additionally encrypted symmetrically even if recipients are provided. This feature is only supported for the OpenPGP crypto engine. @item GPGME_ENCRYPT_THROW_KEYIDS @since{1.8.0} The @code{GPGME_ENCRYPT_THROW_KEYIDS} symbols requests that the identifiers for the decrption keys are not included in the ciphertext. On the receiving side, the use of this flag may slow down the decryption process because all available secret keys must be tried. This flag is only honored for OpenPGP encryption. @item GPGME_ENCRYPT_WRAP @since{1.8.0} The @code{GPGME_ENCRYPT_WRAP} symbol specifies that the input is an OpenPGP message and not a plain data. This is the counterpart to @code{GPGME_DECRYPT_UNWRAP}. @item GPGME_ENCRYPT_WANT_ADDRESS @since{1.11.0} The @code{GPGME_ENCRYPT_WANT_ADDRESS} symbol requests that all supplied keys or key specifications include a syntactically valid mail address. If this is not the case the operation is not even tried and the error code @code{GPG_ERR_INV_USER_ID} is returned. Only the address part of the key specification is conveyed to the backend. As of now the key must be specified using the @var{recpstring} argument of the extended encrypt functions. This feature is currently only supported for the OpenPGP crypto engine. @end table If @code{GPG_ERR_UNUSABLE_PUBKEY} is returned, some recipients in @var{recp} are invalid, but not all. In this case the plaintext might be encrypted for all valid recipients and returned in @var{cipher} (if this happens depends on the crypto engine). More information about the invalid recipients is available with @code{gpgme_op_encrypt_result}. If @var{recp} is @code{NULL}, symmetric rather than public key encryption is performed. Symmetrically encrypted cipher text can be deciphered with @code{gpgme_op_decrypt}. Note that in this case the crypto backend needs to retrieve a passphrase from the user. Symmetric encryption is currently only supported for the OpenPGP crypto backend. The function returns the error code @code{GPG_ERR_NO_ERROR} if the ciphertext could be created successfully, @code{GPG_ERR_INV_VALUE} if @var{ctx}, @var{recp}, @var{plain} or @var{cipher} is not a valid pointer, @code{GPG_ERR_UNUSABLE_PUBKEY} if @var{recp} contains some invalid recipients, @code{GPG_ERR_BAD_PASSPHRASE} if the passphrase for the symmetric key could not be retrieved, and passes through any errors that are reported by the crypto engine support routines. @end deftypefun @deftypefun gpgme_error_t gpgme_op_encrypt_start (@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_start} initiates a @code{gpgme_op_encrypt} operation. It can be completed by calling @code{gpgme_wait} on the context. @xref{Waiting For Completion}. References to the keys only need to be held for the duration of this call. The user can release its references to the keys after this function returns, even if the operation is not yet finished. 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{ctx}, @var{rset}, @var{plain} or @var{cipher} is not a valid pointer, and @code{GPG_ERR_UNUSABLE_PUBKEY} if @var{rset} does not contain any valid recipients. @end deftypefun @deftypefun gpgme_error_t gpgme_op_encrypt_ext @ (@w{gpgme_ctx_t @var{ctx}}, @ @w{gpgme_key_t @var{recp}[]}, @ @w{const char *@var{recpstring}}, @ @w{gpgme_encrypt_flags_t @var{flags}}, @ @w{gpgme_data_t @var{plain}}, @w{gpgme_data_t @var{cipher}}) @since{1.11.0} This is an extended version of @code{gpgme_op_encrypt} with @var{recpstring} as additional parameter. If @var{recp} is NULL and @var{recpstring} is not NULL, the latter is expected to be a linefeed delimited string with the set of key specifications. In contrast to @var{recp} the keys are given directly as strings and there is no need to first create key objects. Leading and trailing white space is remove from each line in @var{recpstring}. The keys are then passed verbatim to the backend engine. For the OpenPGP backend several special keywords are supported to modify the operation. These keywords are given instead of a key specification. The currently supported keywords are: @table @code @item --hidden @itemx --no-hidden These keywords toggle between normal and hidden recipients for all following key specifications. When a hidden recipient is requested the gpg option @option{-R} (or @option{-F} in file mode) is used instead of @option{-r} (@option{-f} in file mode). @item --file @itemx --no-file These keywords toggle between regular and file mode for all following key specification. In file mode the option @option{-f} or @option{-F} is passed to gpg. At least GnuPG version 2.1.14 is required to handle these options. The @code{GPGME_ENCRYPT_WANT_ADDRESS} flag is ignored in file mode. @item -- This keyword disables all keyword detection up to the end of the string. All keywords are treated as verbatim arguments. @end table To create a @var{recpstring} it is often useful to employ a strconcat style function. For example this function creates a string to encrypt to two keys: @example char * xbuild_recpstring (const char *key1, const char *key2) @{ char *result = gpgrt_strconcat ("--\n", key1, "\n", key2, NULL); if (!result) @{ perror ("strconcat failed"); exit (2); @} return result; @} @end example Note the use of the double dash here; unless you want to specify a keyword, it is a good idea to avoid any possible trouble with key specifications starting with a double dash. The used strconcat function is available in Libgpg-error 1.28 and later; Libgpg-error (aka Gpgrt) is a dependency of GPGME. The number of arguments to @code{gpgrt_strconcat} is limited to 47 but that should always be sufficient. In case a larger and non-fixed number of keys are to be supplied the following code can be used: @example char * xbuild_long_recpstring (void) @{ gpgrt_stream_t memfp; const char *s; void *result; memfp = gpgrt_fopenmem (0, "w+b"); if (!memfp) @{ perror ("fopenmem failed"); exit (2); @} gpgrt_fputs ("--", memfp); while ((s = get_next_keyspec ())) @{ gpgrt_fputc ('\n', memfp); gpgrt_fputs (s, memfp); @} gpgrt_fputc (0, memfp); if (gpgrt_ferror (memfp)) @{ perror ("writing to memstream failed"); exit (2); @} if (gpgrt_fclose_snatch (memfp, &result, NULL)) @{ perror ("fclose_snatch failed"); exit (2); @} return result; @} @end example In this example @code{get_next_keyspec} is expected to return the next key to be added to the string. Please take care: Encrypting to a large number of recipients is often questionable due to security reasons and also for the technicality that all keys are currently passed on the command line to @command{gpg} which has as a platform specific length limitation. @end deftypefun @deftypefun gpgme_error_t gpgme_op_encrypt_ext_start @ (@w{gpgme_ctx_t @var{ctx}}, @ @w{gpgme_key_t @var{recp}[]}, @ @w{const char *@var{recpstring}}, @ @w{gpgme_encrypt_flags_t @var{flags}}, @ @w{gpgme_data_t @var{plain}}, @w{gpgme_data_t @var{cipher}}) @since{1.11.0} This is an extended version of @code{gpgme_op_encrypt_start} with @var{recpstring} as additional parameter. If @var{recp} is NULL and @var{recpstring} is not NULL, the latter is expected to be a linefeed delimited string with the set of key specifications. In contrast to @var{recp} the keys are given directly as strings and there is no need to first create key objects. The keys are passed verbatim to the backend engine. @end deftypefun @deftp {Data type} {gpgme_encrypt_result_t} This is a pointer to a structure used to store the result of a @code{gpgme_op_encrypt} operation. After successfully encrypting data, you can retrieve the pointer to the result with @code{gpgme_op_encrypt_result}. The structure contains the following members: @table @code @item gpgme_invalid_key_t invalid_recipients A linked list with information about all invalid keys for which the data could not be encrypted. @end table @end deftp @deftypefun gpgme_encrypt_result_t gpgme_op_encrypt_result (@w{gpgme_ctx_t @var{ctx}}) The function @code{gpgme_op_encrypt_result} returns a @code{gpgme_encrypt_result_t} pointer to a structure holding the result of a @code{gpgme_op_encrypt} operation. The pointer is only valid if the last operation on the context was a @code{gpgme_op_encrypt}, @code{gpgme_op_encrypt_start}, @code{gpgme_op_sign} or @code{gpgme_op_sign_start} operation. If this operation failed, this might be a @code{NULL} pointer. The returned pointer is only valid until the next operation is started on the context. @end deftypefun @deftypefun gpgme_error_t gpgme_op_encrypt_sign (@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_sign} does a combined encrypt and sign operation. It is used like @code{gpgme_op_encrypt}, but the ciphertext also contains signatures for the signers listed in @var{ctx}. The combined encrypt and sign operation is currently only available for the OpenPGP crypto engine. @end deftypefun @deftypefun gpgme_error_t gpgme_op_encrypt_sign_start (@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_sign_start} initiates a @code{gpgme_op_encrypt_sign} operation. It can be completed by calling @code{gpgme_wait} on the context. @xref{Waiting For Completion}. The function returns the error code @code{GPG_ERR_NO_ERROR} if the operation could be started successfully, and @code{GPG_ERR_INV_VALUE} if @var{ctx}, @var{rset}, @var{plain} or @var{cipher} is not a valid pointer. @end deftypefun @deftypefun gpgme_error_t gpgme_op_encrypt_sign_ext @ (@w{gpgme_ctx_t @var{ctx}}, @ @w{gpgme_key_t @var{recp}[]}, @ @w{const char *@var{recpstring}}, @ @w{gpgme_encrypt_flags_t @var{flags}}, @ @w{gpgme_data_t @var{plain}}, @w{gpgme_data_t @var{cipher}}) @since{1.11.0} This is an extended version of @code{gpgme_op_encrypt_sign} with @var{recpstring} as additional parameter. If @var{recp} is NULL and @var{recpstring} is not NULL, the latter is expected to be a linefeed delimited string with the set of key specifications. In contrast to @var{recp} the keys are given directly as strings and there is no need to first create the key objects. The keys are passed verbatim to the backend engine. @end deftypefun @deftypefun gpgme_error_t gpgme_op_encrypt_sign_ext_start @ (@w{gpgme_ctx_t @var{ctx}}, @ @w{gpgme_key_t @var{recp}[]}, @ @w{const char *@var{recpstring}}, @ @w{gpgme_encrypt_flags_t @var{flags}}, @ @w{gpgme_data_t @var{plain}}, @w{gpgme_data_t @var{cipher}}) @since{1.11.0} This is an extended version of @code{gpgme_op_encrypt_sign_start} with @var{recpstring} as additional parameter. If @var{recp} is NULL and @var{recpstring} is not NULL, the latter is expected to be a linefeed delimited string with the set of key specifications. In contrast to @var{recp} the keys are given directly as strings and there is no need to first create the key objects. The keys are passed verbatim to the backend engine. @end deftypefun @node Miscellaneous @section Miscellaneous operations Here are some support functions which are sometimes useful. @menu * Running other Programs:: Running other Programs * Using the Assuan protocol:: Using the Assuan protocol * Checking for updates:: How to check for software updates @end menu @node Running other Programs @subsection Running other Programs GPGME features an internal subsystem to run the actual backend engines. Along with data abstraction object this subsystem can be used to run arbitrary simple programs which even need not be related to cryptographic features. It may for example be used to run tools which are part of the GnuPG system but are not directly accessible with the GPGME API. @deftypefun gpgme_error_t gpgme_op_spawn @ (@w{gpgme_ctx_t @var{ctx}}, @w{const char *@var{file}}, @ @w{const char *@var{argv}[]}, @w{gpgme_data_t @var{datain}}, @ @w{gpgme_data_t @var{dataout}}, @w{gpgme_data_t @var{dataerr}}, @ @w{unsigned int @var{flags}}) @since{1.5.0} The function @code{gpgme_op_spawn} runs the program @var{file} with the arguments taken from the NULL terminated array @var{argv}. If no arguments are required @var{argv} may be given as @code{NULL}. In the latter case or if @code{argv[0]} is the empty string, GPGME uses the basename of @var{file} for @code{argv[0]}. The file descriptors @code{stdin}, @code{stdout}, and @code{stderr} are connected to the data objects @var{datain}, @var{dataout}, and @var{dataerr}. If NULL is passed for one of these data objects the corresponding file descriptor is connected to @file{/dev/null}. The value in @var{flags} is a bitwise-or combination of one or multiple of the following bit values: @table @code @item GPGME_SPAWN_DETACHED @since{1.5.0} Under Windows this flag inhibits the allocation of a new console for the program. This is useful for a GUI application which needs to call a command line helper tool. @item GPGME_SPAWN_ALLOW_SET_FG @since{1.5.0} Under Windows this flag allows the called program to put itself into the foreground. @end table @end deftypefun @deftypefun gpgme_error_t gpgme_op_spawn_start @ (@w{gpgme_ctx_t @var{ctx}}, @w{const char *@var{file}}, @ @w{const char *@var{argv}[]}, @w{gpgme_data_t @var{datain}}, @ @w{gpgme_data_t @var{dataout}}, @w{gpgme_data_t @var{dataerr}}, @ @w{unsigned int @var{flags}}) @since{1.5.0} This is the asynchronous variant of @code{gpgme_op_spawn}. @end deftypefun @node Using the Assuan protocol @subsection Using the Assuan protocol The Assuan protocol can be used to talk to arbitrary Assuan servers. By default it is connected to the GnuPG agent, but it may be connected to arbitrary servers by using @code{gpgme_ctx_set_engine_info}, passing the location of the servers socket as @var{file_name} argument, and an empty string as @var{home_dir} argument. The Assuan protocol functions use three kinds of callbacks to transfer data: @deftp {Data type} {gpgme_error_t (*gpgme_assuan_data_cb_t) @ (@w{void *@var{opaque}}, @w{const void *@var{data}}, @ @w{size_t @var{datalen}})} @since{1.2.0} This callback receives any data sent by the server. @var{opaque} is the pointer passed to @code{gpgme_op_assuan_transact_start}, @var{data} of length @var{datalen} refers to the data sent. @end deftp @deftp {Data type} {gpgme_error_t (*gpgme_assuan_inquire_cb_t) @ (@w{void *@var{opaque}}, @w{const char *@var{name}}, @ @w{const char *@var{args}}, @w{gpgme_data_t *@var{r_data}})} @since{1.2.0} This callback is used to provide additional data to the Assuan server. @var{opaque} is the pointer passed to @code{gpgme_op_assuan_transact_start}, @var{name} and @var{args} specify what kind of data the server requested, and @var{r_data} is used to return the actual data. Note: Returning data is currently not implemented in @acronym{GPGME}. @end deftp @deftp {Data type} {gpgme_error_t (*gpgme_assuan_status_cb_t) @ (@w{void *@var{opaque}}, @w{const char *@var{status}}, @ @w{const char *@var{args}})} @since{1.2.0} This callback receives any status lines sent by the server. @var{opaque} is the pointer passed to @code{gpgme_op_assuan_transact_start}, @var{status} and @var{args} denote the status update sent. @end deftp @deftypefun gpgme_error_t gpgme_op_assuan_transact_start @ (@w{gpgme_ctx_t @var{ctx}}, @w{const char *@var{command}}, @ @w{gpgme_assuan_data_cb_t @var{data_cb}}, @ @w{void * @var{data_cb_value}}, @ @w{gpgme_assuan_inquire_cb_t @var{inquire_cb}}, @ @w{void * @var{inquire_cb_value}}, @ @w{gpgme_assuan_status_cb_t @var{status_cb}}, @ @w{void * @var{status_cb_value}}) @since{1.2.0} Send the Assuan @var{command} and return results via the callbacks. Any callback may be @code{NULL}. The result of the operation may be retrieved using @code{gpgme_wait_ext}. Asynchronous variant. @end deftypefun @deftypefun gpgme_error_t gpgme_op_assuan_transact_ext @ (@w{gpgme_ctx_t @var{ctx}}, @w{const char *@var{command}}, @ @w{gpgme_assuan_data_cb_t @var{data_cb}}, @ @w{void * @var{data_cb_value}}, @ @w{gpgme_assuan_inquire_cb_t @var{inquire_cb}}, @ @w{void * @var{inquire_cb_value}}, @ @w{gpgme_assuan_status_cb_t @var{status_cb}}, @ @w{void * @var{status_cb_value}}, @ @w{gpgme_error_t *@var{op_err}}) Send the Assuan @var{command} and return results via the callbacks. The result of the operation is returned in @var{op_err}. Synchronous variant. @end deftypefun @node Checking for updates @subsection How to check for software updates The GnuPG Project operates a server to query the current versions of software packages related to GnuPG. GPGME can be used to access this online database and check whether a new version of a software package is available. @deftp {Data type} {gpgme_query_swdb_result_t} @since{1.8.0} This is a pointer to a structure used to store the result of a @code{gpgme_op_query_swdb} operation. After success full call to that function, you can retrieve the pointer to the result with @code{gpgme_op_query_swdb_result}. The structure contains the following member: @table @code @item name This is the name of the package. @item iversion The currently installed version or an empty string. This value is either a copy of the argument given to @code{gpgme_op_query_swdb} or the version of the installed software as figured out by GPGME or GnuPG. @item created This gives the date the file with the list of version numbers has originally be created by the GnuPG project. @item retrieved This gives the date the file was downloaded. @item warning If this flag is set either an error has occurred or some of the information in this structure are not properly set. For example if the version number of the installed software could not be figured out, the @code{update} flag may not reflect a required update status. @item update If this flag is set an update of the software is available. @item urgent If this flag is set an available update is important. @item noinfo If this flag is set, no valid information could be retrieved. @item unknown If this flag is set the given @code{name} is not known. @item tooold If this flag is set the available information is not fresh enough. @item error If this flag is set some other error has occurred. @item version The version string of the latest released version. @item reldate The release date of the latest released version. @end table @end deftp @deftypefun gpgme_error_t gpgme_op_query_swdb @ (@w{gpgme_ctx_t @var{ctx}}, @ @w{const char *@var{name}}, @ @w{const char *@var{iversion}}, @ @w{gpgme_data_t @var{reserved}}) @since{1.8.0} Query the software version database for software package @var{name} and check against the installed version given by @var{iversion}. If @var{iversion} is given as @code{NULL} a check is only done if GPGME can figure out the version by itself (for example when using "gpgme" or "gnupg"). If @code{NULL} is used for @var{name} the current gpgme version is checked. @var{reserved} must be set to 0. @end deftypefun @deftypefun gpgme_query_swdb_result_t gpgme_op_query_swdb_result @ (@w{gpgme_ctx_t @var{ctx}}) @since{1.8.0} The function @code{gpgme_op_query_swdb_result} returns a @code{gpgme_query_swdb_result_t} pointer to a structure holding the result of a @code{gpgme_op_query_swdb} operation. The pointer is only valid if the last operation on the context was a successful call to @code{gpgme_op_query_swdb}. If that call failed, the result might be a @code{NULL} pointer. The returned pointer is only valid until the next operation is started on the context @var{ctx}. @end deftypefun @noindent Here is an example on how to check whether GnuPG is current: @example #include int main (void) @{ gpg_error_t err; gpgme_ctx_t ctx; gpgme_query_swdb_result_t result; gpgme_check_version (NULL); err = gpgme_new (&ctx); if (err) fprintf (stderr, "error creating context: %s\n", gpg_strerror (err)); else @{ gpgme_set_protocol (ctx, GPGME_PROTOCOL_GPGCONF); err = gpgme_op_query_swdb (ctx, "gnupg", NULL, 0); if (err) fprintf (stderr, "error querying swdb: %s\n", gpg_strerror (err)); else @{ result = gpgme_op_query_swdb_result (ctx); if (!result) fprintf (stderr, "error querying swdb\n"); if (!result->warning && !result->update) printf ("GnuPG version %s is current\n", result->iversion); else if (!result->warning && result->update) printf ("GnuPG version %s can be updated to %s\n", result->iversion, result->version); else fprintf (stderr, "error finding the update status\n"); @} gpgme_release (ctx); @} return 0; @} @end example @node Run Control @section Run Control @cindex run control @cindex cryptographic operation, running @acronym{GPGME} supports running operations synchronously and asynchronously. You can use asynchronous operation to set up a context up to initiating the desired operation, but delay performing it to a later point. Furthermore, you can use an external event loop to control exactly when @acronym{GPGME} runs. This ensures that @acronym{GPGME} only runs when necessary and also prevents it from blocking for a long time. @menu * Waiting For Completion:: Waiting until an operation is completed. * Using External Event Loops:: Advanced control over what happens when. * Cancellation:: How to end pending operations prematurely. @end menu @node Waiting For Completion @subsection Waiting For Completion @cindex cryptographic operation, wait for @cindex wait for completion @deftypefun gpgme_ctx_t gpgme_wait (@w{gpgme_ctx_t @var{ctx}}, @w{gpgme_error_t *@var{status}}, @w{int @var{hang}}) The function @code{gpgme_wait} continues the pending operation within the context @var{ctx}. In particular, it ensures the data exchange between @acronym{GPGME} and the crypto backend and watches over the run time status of the backend process. If @var{hang} is true, the function does not return until the operation is completed or cancelled. Otherwise the function will not block for a long time. The error status of the finished operation is returned in @var{status} if @code{gpgme_wait} does not return @code{NULL}. The @var{ctx} argument can be @code{NULL}. In that case, @code{gpgme_wait} waits for any context to complete its operation. @code{gpgme_wait} can be used only in conjunction with any context that has a pending operation initiated with one of the @code{gpgme_op_*_start} functions except @code{gpgme_op_keylist_start} and @code{gpgme_op_trustlist_start} (for which you should use the corresponding @code{gpgme_op_*_next} functions). If @var{ctx} is @code{NULL}, all of such contexts are waited upon and possibly returned. Synchronous operations running in parallel, as well as key and trust item list operations, do not affect @code{gpgme_wait}. In a multi-threaded environment, only one thread should ever call -@code{gpgme_wait} at any time, irregardless if @var{ctx} is specified +@code{gpgme_wait} at any time, regardless of whether @var{ctx} is specified or not. This means that all calls to this function should be fully synchronized by locking primitives. It is safe to start asynchronous operations while a thread is running in @code{gpgme_wait}. The function returns the @var{ctx} of the context which has finished the operation. If @var{hang} is false, and the timeout expires, @code{NULL} is returned and @code{*status} will be set to 0. If an error occurs, @code{NULL} is returned and the error is returned in @code{*status}. @end deftypefun @node Using External Event Loops @subsection Using External Event Loops @cindex event loop, external @acronym{GPGME} hides the complexity of the communication between the library and the crypto engine. The price of this convenience is that the calling thread can block arbitrary long waiting for the data returned by the crypto engine. In single-threaded programs, in particular if they are interactive, this is an unwanted side-effect. OTOH, if @code{gpgme_wait} is used without the @var{hang} option being enabled, it might be called unnecessarily often, wasting CPU time that could be used otherwise. The I/O callback interface described in this section lets the user take control over what happens when. @acronym{GPGME} will provide the user with the file descriptors that should be monitored, and the callback functions that should be invoked when a file descriptor is ready for reading or writing. It is then the user's responsibility to decide when to check the file descriptors and when to invoke the callback functions. Usually this is done in an event loop, that also checks for events in other parts of the program. If the callback functions are only called when the file descriptors are ready, @acronym{GPGME} will never block. This gives the user more control over the program flow, and allows to perform other tasks when @acronym{GPGME} would block otherwise. By using this advanced mechanism, @acronym{GPGME} can be integrated smoothly into GUI toolkits like GTK+ even for single-threaded programs. @menu * I/O Callback Interface:: How I/O callbacks are registered. * Registering I/O Callbacks:: How to use I/O callbacks for a context. * I/O Callback Example:: An example how to use I/O callbacks. * I/O Callback Example GTK+:: How to use @acronym{GPGME} with GTK+. * I/O Callback Example GDK:: How to use @acronym{GPGME} with GDK. * I/O Callback Example Qt:: How to use @acronym{GPGME} with Qt. @end menu @node I/O Callback Interface @subsubsection I/O Callback Interface @deftp {Data type} {gpgme_error_t (*gpgme_io_cb_t) (@w{void *@var{data}}, @w{int @var{fd}})} @tindex gpgme_io_cb_t The @code{gpgme_io_cb_t} type is the type of functions which @acronym{GPGME} wants to register as I/O callback handlers using the @code{gpgme_register_io_cb_t} functions provided by the user. @var{data} and @var{fd} are provided by @acronym{GPGME} when the I/O callback handler is registered, and should be passed through to the handler when it is invoked by the user because it noticed activity on the file descriptor @var{fd}. The callback handler always returns @code{0}, but you should consider the return value to be reserved for later use. @end deftp @deftp {Data type} {gpgme_error_t (*gpgme_register_io_cb_t) (@w{void *@var{data}}, @w{int @var{fd}}, @w{int @var{dir}}, @w{gpgme_io_cb_t @var{fnc}}, @w{void *@var{fnc_data}}, @w{void **@var{tag}})} @tindex gpgme_register_io_cb_t The @code{gpgme_register_io_cb_t} type is the type of functions which can be called by @acronym{GPGME} to register an I/O callback function @var{fnc} for the file descriptor @var{fd} with the user. @var{fnc_data} should be passed as the first argument to @var{fnc} when the handler is invoked (the second argument should be @var{fd}). If @var{dir} is 0, @var{fnc} should be called by the user when @var{fd} is ready for writing. If @var{dir} is 1, @var{fnc} should be called when @var{fd} is ready for reading. @var{data} was provided by the user when registering the @code{gpgme_register_io_cb_t} function with @acronym{GPGME} and will always be passed as the first argument when registering a callback function. For example, the user can use this to determine the event loop to which the file descriptor should be added. @acronym{GPGME} will call this function when a crypto operation is initiated in a context for which the user has registered I/O callback handler functions with @code{gpgme_set_io_cbs}. It can also call this function when it is in an I/O callback handler for a file descriptor associated to this context. The user should return a unique handle in @var{tag} identifying this I/O callback registration, which will be passed to the @code{gpgme_register_io_cb_t} function without interpretation when the file descriptor should not be monitored anymore. @end deftp @deftp {Data type} {void (*gpgme_remove_io_cb_t) (@w{void *@var{tag}})} The @code{gpgme_remove_io_cb_t} type is the type of functions which can be called by @acronym{GPGME} to remove an I/O callback handler that was registered before. @var{tag} is the handle that was returned by the @code{gpgme_register_io_cb_t} for this I/O callback. @acronym{GPGME} can call this function when a crypto operation is in an I/O callback. It will also call this function when the context is destroyed while an operation is pending. @end deftp @deftp {Data type} {enum gpgme_event_io_t} @tindex gpgme_event_io_t The @code{gpgme_event_io_t} type specifies the type of an event that is reported to the user by @acronym{GPGME} as a consequence of an I/O operation. The following events are defined: @table @code @item GPGME_EVENT_START The operation is fully initialized now, and you can start to run the registered I/O callback handlers now. Note that registered I/O callback handlers must not be run before this event is signalled. @var{type_data} is @code{NULL} and reserved for later use. @item GPGME_EVENT_DONE The operation is finished, the last I/O callback for this operation was removed. The accompanying @var{type_data} points to a @code{struct gpgme_io_event_done_data} variable that contains the status of the operation that finished. This event is signalled after the last I/O callback has been removed. @item GPGME_EVENT_NEXT_KEY In a @code{gpgme_op_keylist_start} operation, the next key was received from the crypto engine. The accompanying @var{type_data} is a @code{gpgme_key_t} variable that contains the key with one reference for the user. @item GPGME_EVENT_NEXT_TRUSTITEM In a @code{gpgme_op_trustlist_start} operation, the next trust item was received from the crypto engine. The accompanying @var{type_data} is a @code{gpgme_trust_item_t} variable that contains the trust item with one reference for the user. @end table @end deftp @deftp {Data type} {void (*gpgme_event_io_cb_t) (@w{void *@var{data}}, @w{gpgme_event_io_t @var{type}}, @w{void *@var{type_data}})} The @code{gpgme_event_io_cb_t} type is the type of functions which can be called by @acronym{GPGME} to signal an event for an operation running in a context which has I/O callback functions registered by the user. @var{data} was provided by the user when registering the @code{gpgme_event_io_cb_t} function with @acronym{GPGME} and will always be passed as the first argument when registering a callback function. For example, the user can use this to determine the context in which this event has occurred. @var{type} will specify the type of event that has occurred. @var{type_data} specifies the event further, as described in the above list of possible @code{gpgme_event_io_t} types. @acronym{GPGME} can call this function in an I/O callback handler. @end deftp @node Registering I/O Callbacks @subsubsection Registering I/O Callbacks @deftp {Data type} {struct gpgme_io_cbs} @tindex gpgme_event_io_t This structure is used to store the I/O callback interface functions described in the previous section. It has the following members: @table @code @item gpgme_register_io_cb_t add This is the function called by @acronym{GPGME} to register an I/O callback handler. It must be specified. @item void *add_priv This is passed as the first argument to the @code{add} function when it is called by @acronym{GPGME}. For example, it can be used to determine the event loop to which the file descriptor should be added. @item gpgme_remove_io_cb_t remove This is the function called by @acronym{GPGME} to remove an I/O callback handler. It must be specified. @item gpgme_event_io_cb_t event This is the function called by @acronym{GPGME} to signal an event for an operation. It must be specified, because at least the start event must be processed. @item void *event_priv This is passed as the first argument to the @code{event} function when it is called by @acronym{GPGME}. For example, it can be used to determine the context in which the event has occurred. @end table @end deftp @deftypefun void gpgme_set_io_cbs (@w{gpgme_ctx_t @var{ctx}}, @w{struct gpgme_io_cbs *@var{io_cbs}}) The function @code{gpgme_set_io_cbs} enables the I/O callback interface for the context @var{ctx}. The I/O callback functions are specified by @var{io_cbs}. If @var{io_cbs}->@code{add} is @code{NULL}, the I/O callback interface is disabled for the context, and normal operation is restored. @end deftypefun @deftypefun void gpgme_get_io_cbs (@w{gpgme_ctx_t @var{ctx}}, @w{struct gpgme_io_cbs *@var{io_cbs}}) The function @code{gpgme_get_io_cbs} returns the I/O callback functions set with @code{gpgme_set_io_cbs} in @var{io_cbs}. @end deftypefun @node I/O Callback Example @subsubsection I/O Callback Example To actually use an external event loop, you have to implement the I/O callback functions that are used by @acronym{GPGME} to register and unregister file descriptors. Furthermore, you have to actually monitor these file descriptors for activity and call the appropriate I/O callbacks. The following example illustrates how to do that. The example uses locking to show in which way the callbacks and the event loop can run concurrently. For the event loop, we use a fixed array. For a real-world implementation, you should use a dynamically sized structure because the number of file descriptors needed for a crypto operation in @acronym{GPGME} is not predictable. @example #include #include #include #include #include #include /* The following structure holds the result of a crypto operation. */ struct op_result @{ int done; gpgme_error_t err; @}; /* The following structure holds the data associated with one I/O callback. */ struct one_fd @{ int fd; int dir; gpgme_io_cb_t fnc; void *fnc_data; void *loop; @}; struct event_loop @{ pthread_mutex_t lock; #define MAX_FDS 32 /* Unused slots are marked with FD being -1. */ struct one_fd fds[MAX_FDS]; @}; @end example The following functions implement the I/O callback interface. @example gpgme_error_t add_io_cb (void *data, int fd, int dir, gpgme_io_cb_t fnc, void *fnc_data, void **r_tag) @{ struct event_loop *loop = data; struct one_fd *fds = loop->fds; int i; pthread_mutex_lock (&loop->lock); for (i = 0; i < MAX_FDS; i++) @{ if (fds[i].fd == -1) @{ fds[i].fd = fd; fds[i].dir = dir; fds[i].fnc = fnc; fds[i].fnc_data = fnc_data; fds[i].loop = loop; break; @} @} pthread_mutex_unlock (&loop->lock); if (i == MAX_FDS) return gpg_error (GPG_ERR_GENERAL); *r_tag = &fds[i]; return 0; @} void remove_io_cb (void *tag) @{ struct one_fd *fd = tag; struct event_loop *loop = fd->loop; pthread_mutex_lock (&loop->lock); fd->fd = -1; pthread_mutex_unlock (&loop->lock); @} void event_io_cb (void *data, gpgme_event_io_t type, void *type_data) @{ struct op_result *result = data; /* We don't support list operations here. */ if (type == GPGME_EVENT_DONE) @{ result->done = 1; result->err = *type_data; @} @} @end example The final missing piece is the event loop, which will be presented next. We only support waiting for the success of a single operation. @example int do_select (struct event_loop *loop) @{ fd_set rfds; fd_set wfds; int i, n; int any = 0; struct timeval tv; struct one_fd *fdlist = loop->fds; pthread_mutex_lock (&loop->lock); FD_ZERO (&rfds); FD_ZERO (&wfds); for (i = 0; i < MAX_FDS; i++) if (fdlist[i].fd != -1) FD_SET (fdlist[i].fd, fdlist[i].dir ? &rfds : &wfds); pthread_mutex_unlock (&loop->lock); tv.tv_sec = 0; tv.tv_usec = 1000; do @{ n = select (FD_SETSIZE, &rfds, &wfds, NULL, &tv); @} while (n < 0 && errno == EINTR); if (n < 0) return n; /* Error or timeout. */ pthread_mutex_lock (&loop->lock); for (i = 0; i < MAX_FDS && n; i++) @{ if (fdlist[i].fd != -1) @{ if (FD_ISSET (fdlist[i].fd, fdlist[i].dir ? &rfds : &wfds)) @{ assert (n); n--; any = 1; /* The I/O callback handler can register/remove callbacks, so we have to unlock the file descriptor list. */ pthread_mutex_unlock (&loop->lock); (*fdlist[i].fnc) (fdlist[i].fnc_data, fdlist[i].fd); pthread_mutex_lock (&loop->lock); @} @} @} pthread_mutex_unlock (&loop->lock); return any; @} void wait_for_op (struct event_loop *loop, struct op_result *result) @{ int ret; do @{ ret = do_select (loop); @} while (ret >= 0 && !result->done); @} @end example The main function shows how to put it all together. @example int main (int argc, char *argv[]) @{ struct event_loop loop; struct op_result result; gpgme_ctx_t ctx; gpgme_error_t err; gpgme_data_t sig, text; int i; pthread_mutexattr_t attr; struct gpgme_io_cbs io_cbs = @{ add_io_cb, &loop, remove_io_cb, event_io_cb, &result @}; init_gpgme (); /* Initialize the loop structure. */ /* The mutex must be recursive, since remove_io_cb (which acquires a lock) can be called while holding a lock acquired in do_select. */ pthread_mutexattr_init (&attr); pthread_mutexattr_settype (&attr, PTHREAD_MUTEX_RECURSIVE); pthread_mutex_init (&loop.lock, &attr); pthread_mutexattr_destroy (&attr); for (i = 0; i < MAX_FDS; i++) loop.fds[i].fd = -1; /* Initialize the result structure. */ result.done = 0; err = gpgme_data_new_from_file (&sig, "signature", 1); if (!err) err = gpgme_data_new_from_file (&text, "text", 1); if (!err) err = gpgme_new (&ctx); if (!err) @{ gpgme_set_io_cbs (ctx, &io_cbs); err = gpgme_op_verify_start (ctx, sig, text, NULL); @} if (err) @{ fprintf (stderr, "gpgme error: %s: %s\n", gpgme_strsource (err), gpgme_strerror (err)); exit (1); @} wait_for_op (&loop, &result); if (!result.done) @{ fprintf (stderr, "select error\n"); exit (1); @} if (!result.err) @{ fprintf (stderr, "verification failed: %s: %s\n", gpgme_strsource (result.err), gpgme_strerror (result.err)); exit (1); @} /* Evaluate verify result. */ @dots{} return 0; @} @end example @node I/O Callback Example GTK+ @subsubsection I/O Callback Example GTK+ @cindex GTK+, using @acronym{GPGME} with The I/O callback interface can be used to integrate @acronym{GPGME} with the GTK+ event loop. The following code snippets shows how this can be done using the appropriate register and remove I/O callback functions. In this example, the private data of the register I/O callback function is unused. The event notifications is missing because it does not require any GTK+ specific setup. @example #include struct my_gpgme_io_cb @{ gpgme_io_cb_t fnc; void *fnc_data; guint input_handler_id @}; void my_gpgme_io_cb (gpointer data, gint source, GdkInputCondition condition) @{ struct my_gpgme_io_cb *iocb = data; (*(iocb->fnc)) (iocb->data, source); @} void my_gpgme_remove_io_cb (void *data) @{ struct my_gpgme_io_cb *iocb = data; gtk_input_remove (data->input_handler_id); @} void my_gpgme_register_io_callback (void *data, int fd, int dir, gpgme_io_cb_t fnc, void *fnc_data, void **tag) @{ struct my_gpgme_io_cb *iocb = g_malloc (sizeof (struct my_gpgme_io_cb)); iocb->fnc = fnc; iocb->data = fnc_data; iocb->input_handler_id = gtk_input_add_full (fd, dir ? GDK_INPUT_READ : GDK_INPUT_WRITE, my_gpgme_io_callback, 0, iocb, NULL); *tag = iocb; return 0; @} @end example @node I/O Callback Example GDK @subsubsection I/O Callback Example GDK @cindex GDK, using @acronym{GPGME} with The I/O callback interface can also be used to integrate @acronym{GPGME} with the GDK event loop. The following code snippets shows how this can be done using the appropriate register and remove I/O callback functions. In this example, the private data of the register I/O callback function is unused. The event notifications is missing because it does not require any GDK specific setup. It is very similar to the GTK+ example in the previous section. @example #include struct my_gpgme_io_cb @{ gpgme_io_cb_t fnc; void *fnc_data; gint tag; @}; void my_gpgme_io_cb (gpointer data, gint source, GdkInputCondition condition) @{ struct my_gpgme_io_cb *iocb = data; (*(iocb->fnc)) (iocb->data, source); @} void my_gpgme_remove_io_cb (void *data) @{ struct my_gpgme_io_cb *iocb = data; gdk_input_remove (data->tag); @} void my_gpgme_register_io_callback (void *data, int fd, int dir, gpgme_io_cb_t fnc, void *fnc_data, void **tag) @{ struct my_gpgme_io_cb *iocb = g_malloc (sizeof (struct my_gpgme_io_cb)); iocb->fnc = fnc; iocb->data = fnc_data; iocb->tag = gtk_input_add_full (fd, dir ? GDK_INPUT_READ : GDK_INPUT_WRITE, my_gpgme_io_callback, iocb, NULL); *tag = iocb; return 0; @} @end example @node I/O Callback Example Qt @subsubsection I/O Callback Example Qt @cindex Qt, using @acronym{GPGME} with The I/O callback interface can also be used to integrate @acronym{GPGME} with the Qt event loop. The following code snippets show how this can be done using the appropriate register and remove I/O callback functions. In this example, the private data of the register I/O callback function is unused. The event notifications is missing because it does not require any Qt specific setup. @example #include #include struct IOCB @{ IOCB( GpgmeIOCb f, void * d, QSocketNotifier * n ) : func( f ), data( d ), notifier( n ) @{@} GpgmeIOCb func; void * data; QSocketNotifier * notifier; @} class MyApp : public QApplication @{ // ... static void registerGpgmeIOCallback( void * data, int fd, int dir, GpgmeIOCb func, void * func_data, void ** tag ) @{ QSocketNotifier * n = new QSocketNotifier( fd, dir ? QSocketNotifier::Read : QSocketNotifier::Write ); connect( n, SIGNAL(activated(int)), qApp, SLOT(slotGpgmeIOCallback(int)) ); qApp->mIOCBs.push_back( IOCB( func, func_data, n ) ); *tag = (void*)n; @} static void removeGpgmeIOCallback( void * tag ) @{ if ( !tag ) return; QSocketNotifier * n = static_cast( tag ); for ( QValueList::iterator it = qApp->mIOCBs.begin() ; it != qApp->mIOCBs.end() ; ++it ) if ( it->notifier == n ) @{ delete it->notifier; qApp->mIOCBs.erase( it ); return; @} @} public slots: void slotGpgmeIOCallback( int fd ) @{ for ( QValueList::const_iterator it = mIOCBs.begin() ; it != mIOCBs.end() ; ++it ) if ( it->notifier && it->notifier->socket() == fd ) (*(it->func)) ( it->func_data, fd ); @} // ... private: QValueList mIOCBs; // ... @}; @end example @node Cancellation @subsection Cancellation @cindex cryptographic operation, aborting @cindex cryptographic operation, cancelling @cindex aborting operations @cindex cancelling operations Sometimes you do not want to wait for an operation to finish. @acronym{GPGME} provides two different functions to achieve that. The function @code{gpgme_cancel} takes effect immediately. When it returns, the operation is effectively canceled. However, it has some limitations and can not be used with synchronous operations. In contrast, the function @code{gpgme_cancel_async} can be used with any context and from any thread, but it is not guaranteed to take effect immediately. Instead, cancellation occurs at the next possible time (typically the next time I/O occurs in the target context). @deftypefun gpgme_ctx_t gpgme_cancel (@w{gpgme_ctx_t @var{ctx}}) @since{0.4.5} The function @code{gpgme_cancel} attempts to cancel a pending operation in the context @var{ctx}. This only works if you use the global event loop or your own event loop. If you use the global event loop, you must not call @code{gpgme_wait} during cancellation. After successful cancellation, you can call @code{gpgme_wait} (optionally waiting on @var{ctx}), and the context @var{ctx} will appear as if it had finished with the error code @code{GPG_ERR_CANCEL}. If you use an external event loop, you must ensure that no I/O callbacks are invoked for this context (for example by halting the event loop). On successful cancellation, all registered I/O callbacks for this context will be unregistered, and a @code{GPGME_EVENT_DONE} event with the error code @code{GPG_ERR_CANCEL} will be signalled. The function returns an error code if the cancellation failed (in this case the state of @var{ctx} is not modified). @end deftypefun @deftypefun gpgme_ctx_t gpgme_cancel_async (@w{gpgme_ctx_t @var{ctx}}) @since{1.1.7} The function @code{gpgme_cancel_async} attempts to cancel a pending operation in the context @var{ctx}. This can be called by any thread at any time after starting an operation on the context, but will not take effect immediately. The actual cancellation happens at the next time GPGME processes I/O in that context. The function returns an error code if the cancellation failed (in this case the state of @var{ctx} is not modified). @end deftypefun @c ********************************************************** @c ******************* Appendices ************************* @c ********************************************************** @include uiserver.texi @node Debugging @appendix How to solve problems @cindex debug @cindex GPGME_DEBUG Everyone knows that software often does not do what it should do and thus there is a need to track down problems. This is in particular true for applications using a complex library like @acronym{GPGME} and of course also for the library itself. Here we give a few hints on how to solve such problems. First of all you should make sure that the keys you want to use are installed in the GnuPG engine and are usable. Thus the first test is to run the desired operation using @command{gpg} or @command{gpgsm} on the command line. If you can't figure out why things don't work, you may use @acronym{GPGME}'s built in trace feature. This feature is either enabled using the environment variable @code{GPGME_DEBUG} or, if this is not possible, by calling the function @code{gpgme_set_global_flag}. The value is the trace level and an optional file name. If no file name is given the trace output is printed to @code{stderr}. @noindent For example @smallexample GPGME_DEBUG=9:/home/user/mygpgme.log @end smallexample @noindent (Note that under Windows you use a semicolon in place of the colon to separate the fields.) A trace level of 9 is pretty verbose and thus you may want to start off with a lower level. The exact definition of the trace levels and the output format may change with any release; you need to check the source code for details. In any case the trace log should be helpful to understand what is going going on. Warning: The trace log may 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. @node Deprecated Functions @appendix Deprecated Functions @cindex deprecated For backward compatibility @acronym{GPGME} has a number of functions, data types and constants which are deprecated and should not be used anymore. We document here those which are really old to help understanding old code and to allow migration to their modern counterparts. @strong{Warning:} These interfaces will be removed in a future version of @acronym{GPGME}. @deftypefun void gpgme_key_release (@w{gpgme_key_t @var{key}}) The function @code{gpgme_key_release} is equivalent to @code{gpgme_key_unref}. @end deftypefun @deftypefun void gpgme_trust_item_release (@w{gpgme_trust_item_t @var{item}}) The function @code{gpgme_trust_item_release} is an alias for @code{gpgme_trust_item_unref}. @end deftypefun @deftypefun gpgme_error_t gpgme_op_import_ext (@w{gpgme_ctx_t @var{ctx}}, @w{gpgme_data_t @var{keydata}}, @w{int *@var{nr}}) @since{0.3.9} The function @code{gpgme_op_import_ext} is equivalent to: @example gpgme_error_t err = gpgme_op_import (ctx, keydata); if (!err) @{ gpgme_import_result_t result = gpgme_op_import_result (ctx); *nr = result->considered; @} @end example @end deftypefun @deftp {Data type} {gpgme_error_t (*gpgme_edit_cb_t) @ (@w{void *@var{handle}}, @ @w{gpgme_status_code_t @var{status}}, @ @w{const char *@var{args}}, @ @w{int @var{fd}})} @tindex gpgme_edit_cb_t The @code{gpgme_edit_cb_t} type is the type of functions which @acronym{GPGME} calls if it a key edit operation is on-going. The status code @var{status} and the argument line @var{args} are passed through by @acronym{GPGME} from the crypto engine. The file descriptor @var{fd} is -1 for normal status messages. If @var{status} indicates a command rather than a status message, the response to the command should be written to @var{fd}. The @var{handle} is provided by the user at start of operation. The function should return @code{GPG_ERR_FALSE} if it did not handle the status code, @code{0} for success, or any other error value. @end deftp @deftypefun gpgme_error_t gpgme_op_edit (@w{gpgme_ctx_t @var{ctx}}, @w{gpgme_key_t @var{key}}, @w{gpgme_edit_cb_t @var{fnc}}, @w{void *@var{handle}}, @w{gpgme_data_t @var{out}}) @since{0.3.9} Note: This function is deprecated, please use @code{gpgme_op_interact} instead. The function @code{gpgme_op_edit} processes the key @var{KEY} interactively, using the edit callback function @var{FNC} with the handle @var{HANDLE}. The callback is invoked for every status and command request from the crypto engine. The output of the crypto engine is written to the data object @var{out}. Note that the protocol between the callback function and the crypto engine is specific to the crypto engine and no further support in implementing this protocol correctly is provided by @acronym{GPGME}. The function returns the error code @code{GPG_ERR_NO_ERROR} if the edit operation completes successfully, @code{GPG_ERR_INV_VALUE} if @var{ctx} or @var{key} is not a valid pointer, and any error returned by the crypto engine or the edit callback handler. @end deftypefun @deftypefun gpgme_error_t gpgme_op_edit_start (@w{gpgme_ctx_t @var{ctx}}, @w{gpgme_key_t @var{key}}, @w{gpgme_edit_cb_t @var{fnc}}, @w{void *@var{handle}}, @w{gpgme_data_t @var{out}}) @since{0.3.9} Note: This function is deprecated, please use @code{gpgme_op_interact_start} instead. The function @code{gpgme_op_edit_start} initiates a @code{gpgme_op_edit} operation. It can be completed by calling @code{gpgme_wait} on the context. @xref{Waiting For Completion}. The function returns the error code @code{GPG_ERR_NO_ERROR} if the operation was started successfully, and @code{GPG_ERR_INV_VALUE} if @var{ctx} or @var{key} is not a valid pointer. @end deftypefun @deftypefun gpgme_error_t gpgme_op_card_edit (@w{gpgme_ctx_t @var{ctx}}, @w{gpgme_key_t @var{key}}, @w{gpgme_edit_cb_t @var{fnc}}, @w{void *@var{handle}}, @w{gpgme_data_t @var{out}}) Note: This function is deprecated, please use @code{gpgme_op_interact} with the flag @code{GPGME_INTERACT_CARD} instead. The function @code{gpgme_op_card_edit} is analogous to @code{gpgme_op_edit}, but should be used to process the smart card corresponding to the key @var{key}. @end deftypefun @deftypefun gpgme_error_t gpgme_op_card_edit_start (@w{gpgme_ctx_t @var{ctx}}, @w{gpgme_key_t @var{key}}, @w{gpgme_edit_cb_t @var{fnc}}, @w{void *@var{handle}}, @w{gpgme_data_t @var{out}}) Note: This function is deprecated, please use @code{gpgme_op_interact_start} with the flag @code{GPGME_INTERACT_CARD} instead. The function @code{gpgme_op_card_edit_start} initiates a @code{gpgme_op_card_edit} operation. It can be completed by calling @code{gpgme_wait} on the context. @xref{Waiting For Completion}. The function returns the error code @code{GPG_ERR_NO_ERROR} if the operation was started successfully, and @code{GPG_ERR_INV_VALUE} if @var{ctx} or @var{key} is not a valid pointer. @end deftypefun @deftypefun gpgme_error_t gpgme_data_new_with_read_cb (@w{gpgme_data_t *@var{dh}}, @w{int (*@var{readfunc})} (@w{void *@var{hook}}, @w{char *@var{buffer}}, @w{size_t @var{count}}, @w{size_t *@var{nread}}), @w{void *@var{hook_value}}) The function @code{gpgme_data_new_with_read_cb} creates a new @code{gpgme_data_t} object and uses the callback function @var{readfunc} to retrieve the data on demand. As the callback function can supply the data in any way it wants, this is the most flexible data type @acronym{GPGME} provides. However, it can not be used to write data. The callback function receives @var{hook_value} as its first argument whenever it is invoked. It should return up to @var{count} bytes in @var{buffer}, and return the number of bytes actually read in @var{nread}. It may return @code{0} in @var{nread} if no data is currently available. To indicate @code{EOF} the function should return with an error code of @code{-1} and set @var{nread} to @code{0}. The callback function may support to reset its internal read pointer if it is invoked with @var{buffer} and @var{nread} being @code{NULL} and @var{count} being @code{0}. The function returns the error code @code{GPG_ERR_NO_ERROR} if the data object was successfully created, @code{GPG_ERR_INV_VALUE} if @var{dh} or @var{readfunc} is not a valid pointer, and @code{GPG_ERR_ENOMEM} if not enough memory is available. @end deftypefun @deftypefun gpgme_error_t gpgme_data_rewind (@w{gpgme_data_t @var{dh}}) The function @code{gpgme_data_rewind} is equivalent to: @example return (gpgme_data_seek (dh, 0, SEEK_SET) == -1) ? gpgme_error_from_errno (errno) : 0; @end example @end deftypefun @deftp {Data type} gpgme_attr_t The @code{gpgme_attr_t} type is used to specify a key or trust item attribute. The following attributes are defined: @table @code @item GPGME_ATTR_KEYID This is the key ID of a sub key. It is representable as a string. For trust items, the trust item refers to the key with this ID. @item GPGME_ATTR_FPR This is the fingerprint of a sub key. It is representable as a string. @item GPGME_ATTR_ALGO This is the crypto algorithm for which the sub key can be used. It is representable as a string and as a number. The numbers correspond to the @code{enum gcry_pk_algos} values in the gcrypt library. @item GPGME_ATTR_LEN This is the key length of a sub key. It is representable as a number. @item GPGME_ATTR_CREATED This is the timestamp at creation time of a sub key. It is representable as a number. @item GPGME_ATTR_EXPIRE This is the expiration time of a sub key. It is representable as a number. @item GPGME_ATTR_OTRUST XXX FIXME (also for trust items) @item GPGME_ATTR_USERID This is a user ID. There can be more than one user IDs in a @var{gpgme_key_t} object. The first one (with index 0) is the primary user ID. The user ID is representable as a number. For trust items, this is the user ID associated with this trust item. @item GPGME_ATTR_NAME This is the name belonging to a user ID. It is representable as a string. @item GPGME_ATTR_EMAIL This is the email address belonging to a user ID. It is representable as a string. @item GPGME_ATTR_COMMENT This is the comment belonging to a user ID. It is representable as a string. @item GPGME_ATTR_VALIDITY This is the validity belonging to a user ID. It is representable as a string and as a number. See below for a list of available validities. For trust items, this is the validity that is associated with this trust item. @item GPGME_ATTR_UID_REVOKED This specifies if a user ID is revoked. It is representable as a number, and is @code{1} if the user ID is revoked, and @code{0} otherwise. @item GPGME_ATTR_UID_INVALID This specifies if a user ID is invalid. It is representable as a number, and is @code{1} if the user ID is invalid, and @code{0} otherwise. @item GPGME_ATTR_LEVEL This is the trust level of a trust item. @item GPGME_ATTR_TYPE This returns information about the type of key. For the string function this will eother be "PGP" or "X.509". The integer function returns 0 for PGP and 1 for X.509. It is also used for the type of a trust item. @item GPGME_ATTR_IS_SECRET This specifies if the key is a secret key. It is representable as a number, and is @code{1} if the key is revoked, and @code{0} otherwise. @item GPGME_ATTR_KEY_REVOKED This specifies if a sub key is revoked. It is representable as a number, and is @code{1} if the key is revoked, and @code{0} otherwise. @item GPGME_ATTR_KEY_INVALID This specifies if a sub key is invalid. It is representable as a number, and is @code{1} if the key is invalid, and @code{0} otherwise. @item GPGME_ATTR_KEY_EXPIRED This specifies if a sub key is expired. It is representable as a number, and is @code{1} if the key is expired, and @code{0} otherwise. @item GPGME_ATTR_KEY_DISABLED This specifies if a sub key is disabled. It is representable as a number, and is @code{1} if the key is disabled, and @code{0} otherwise. @item GPGME_ATTR_KEY_CAPS This is a description of the capabilities of a sub key. It is representable as a string. The string contains the letter ``e'' if the key can be used for encryption, ``s'' if the key can be used for signatures, and ``c'' if the key can be used for certifications. @item GPGME_ATTR_CAN_ENCRYPT This specifies if a sub key can be used for encryption. It is representable as a number, and is @code{1} if the sub key can be used for encryption, and @code{0} otherwise. @item GPGME_ATTR_CAN_SIGN This specifies if a sub key can be used to create data signatures. It is representable as a number, and is @code{1} if the sub key can be used for signatures, and @code{0} otherwise. @item GPGME_ATTR_CAN_CERTIFY This specifies if a sub key can be used to create key certificates. It is representable as a number, and is @code{1} if the sub key can be used for certifications, and @code{0} otherwise. @item GPGME_ATTR_SERIAL The X.509 issuer serial attribute of the key. It is representable as a string. @item GPGME_ATTR_ISSUE The X.509 issuer name attribute of the key. It is representable as a string. @item GPGME_ATTR_CHAINID The X.509 chain ID can be used to build the certification chain. It is representable as a string. @end table @end deftp @deftypefun {const char *} gpgme_key_get_string_attr (@w{gpgme_key_t @var{key}}, @w{gpgme_attr_t @var{what}}, @w{const void *@var{reserved}}, @w{int @var{idx}}) The function @code{gpgme_key_get_string_attr} returns the value of the string-representable attribute @var{what} of key @var{key}. If the attribute is an attribute of a sub key or an user ID, @var{idx} specifies the sub key or user ID of which the attribute value is returned. The argument @var{reserved} is reserved for later use and should be @code{NULL}. The string returned is only valid as long as the key is valid. The function returns @code{0} if an attribute can't be returned as a string, @var{key} is not a valid pointer, @var{idx} out of range, or @var{reserved} not @code{NULL}. @end deftypefun @deftypefun {unsigned long} gpgme_key_get_ulong_attr (@w{gpgme_key_t @var{key}}, @w{gpgme_attr_t @var{what}}, @w{const void *@var{reserved}}, @w{int @var{idx}}) The function @code{gpgme_key_get_ulong_attr} returns the value of the number-representable attribute @var{what} of key @var{key}. If the attribute is an attribute of a sub key or an user ID, @var{idx} specifies the sub key or user ID of which the attribute value is returned. The argument @var{reserved} is reserved for later use and should be @code{NULL}. The function returns @code{0} if the attribute can't be returned as a number, @var{key} is not a valid pointer, @var{idx} out of range, or @var{reserved} not @code{NULL}. @end deftypefun @c @c Key Signatures @c The signatures on a key are only available if the key was retrieved via a listing operation with the @code{GPGME_KEYLIST_MODE_SIGS} mode enabled, because it is expensive to retrieve all signatures of a key. So, before using the below interfaces to retrieve the signatures on a key, you have to make sure that the key was listed with signatures enabled. One convenient, but blocking, way to do this is to use the function @code{gpgme_get_key}. @deftp {Data type} gpgme_attr_t The @code{gpgme_attr_t} type is used to specify a key signature attribute. The following attributes are defined: @table @code @item GPGME_ATTR_KEYID This is the key ID of the key which was used for the signature. It is representable as a string. @item GPGME_ATTR_ALGO This is the crypto algorithm used to create the signature. It is representable as a string and as a number. The numbers correspond to the @code{enum gcry_pk_algos} values in the gcrypt library. @item GPGME_ATTR_CREATED This is the timestamp at creation time of the signature. It is representable as a number. @item GPGME_ATTR_EXPIRE This is the expiration time of the signature. It is representable as a number. @item GPGME_ATTR_USERID This is the user ID associated with the signing key. The user ID is representable as a number. @item GPGME_ATTR_NAME This is the name belonging to a user ID. It is representable as a string. @item GPGME_ATTR_EMAIL This is the email address belonging to a user ID. It is representable as a string. @item GPGME_ATTR_COMMENT This is the comment belonging to a user ID. It is representable as a string. @item GPGME_ATTR_KEY_REVOKED This specifies if a key signature is a revocation signature. It is representable as a number, and is @code{1} if the key is revoked, and @code{0} otherwise. @c @item GPGME_ATTR_KEY_EXPIRED @c This specifies if a key signature is expired. It is representable as @c a number, and is @code{1} if the key is revoked, and @code{0} @c otherwise. @c @item GPGME_ATTR_SIG_CLASS This specifies the signature class of a key signature. It is representable as a number. The meaning is specific to the crypto engine. @item GPGME_ATTR_SIG_CLASS This specifies the signature class of a key signature. It is representable as a number. The meaning is specific to the crypto engine. @item GPGME_ATTR_SIG_STATUS This is the same value as returned by @code{gpgme_get_sig_status}. @end table @end deftp @deftypefun {const char *} gpgme_key_sig_get_string_attr (@w{gpgme_key_t @var{key}}, @w{int @var{uid_idx}}, @w{gpgme_attr_t @var{what}}, @w{const void *@var{reserved}}, @w{int @var{idx}}) The function @code{gpgme_key_sig_get_string_attr} returns the value of the string-representable attribute @var{what} of the signature @var{idx} on the user ID @var{uid_idx} in the key @var{key}. The argument @var{reserved} is reserved for later use and should be @code{NULL}. The string returned is only valid as long as the key is valid. The function returns @code{0} if an attribute can't be returned as a string, @var{key} is not a valid pointer, @var{uid_idx} or @var{idx} out of range, or @var{reserved} not @code{NULL}. @end deftypefun @deftypefun {unsigned long} gpgme_key_sig_get_ulong_attr (@w{gpgme_key_t @var{key}}, @w{int @var{uid_idx}}, @w{gpgme_attr_t @var{what}}, @w{const void *@var{reserved}}, @w{int @var{idx}}) The function @code{gpgme_key_sig_get_ulong_attr} returns the value of the number-representable attribute @var{what} of the signature @var{idx} on the user ID @var{uid_idx} in the key @var{key}. The argument @var{reserved} is reserved for later use and should be @code{NULL}. The function returns @code{0} if an attribute can't be returned as a string, @var{key} is not a valid pointer, @var{uid_idx} or @var{idx} out of range, or @var{reserved} not @code{NULL}. @end deftypefun @c node Information About Trust Items @c subsection Information About Trust Items @c cindex trust item, information about @c cindex trust item, attributes @c cindex attributes, of a trust item Trust items have attributes which can be queried using the interfaces below. The attribute identifiers are shared with those for key attributes. @xref{Information About Keys}. @deftypefun {const char *} gpgme_trust_item_get_string_attr (@w{gpgme_trust_item_t @var{item}}, @w{gpgme_attr_t @var{what}}, @w{const void *@var{reserved}}, @w{int @var{idx}}) The function @code{gpgme_trust_item_get_string_attr} returns the value of the string-representable attribute @var{what} of trust item @var{item}. The arguments @var{idx} and @var{reserved} are reserved for later use and should be @code{0} and @code{NULL} respectively. The string returned is only valid as long as the key is valid. The function returns @code{0} if an attribute can't be returned as a string, @var{key} is not a valid pointer, @var{idx} out of range, or @var{reserved} not @code{NULL}. @end deftypefun @deftypefun int gpgme_trust_item_get_int_attr (@w{gpgme_trust_item_t @var{item}}, @w{gpgme_attr_t @var{what}}, @w{const void *@var{reserved}}, @w{int @var{idx}}) The function @code{gpgme_trust_item_get_int_attr} returns the value of the number-representable attribute @var{what} of trust item @var{item}. If the attribute occurs more than once in the trust item, the index is specified by @var{idx}. However, currently no such attribute exists, so @var{idx} should be @code{0}. The argument @var{reserved} is reserved for later use and should be @code{NULL}. The function returns @code{0} if the attribute can't be returned as a number, @var{key} is not a valid pointer, @var{idx} out of range, or @var{reserved} not @code{NULL}. @end deftypefun @deftp {Data type} {enum gpgme_sig_stat_t} @tindex gpgme_sig_stat_t The @code{gpgme_sig_stat_t} type holds the result of a signature check, or the combined result of all signatures. The following results are possible: @table @code @item GPGME_SIG_STAT_NONE This status should not occur in normal operation. @item GPGME_SIG_STAT_GOOD This status indicates that the signature is valid. For the combined result this status means that all signatures are valid. @item GPGME_SIG_STAT_GOOD_EXP This status indicates that the signature is valid but expired. For the combined result this status means that all signatures are valid and expired. @item GPGME_SIG_STAT_GOOD_EXPKEY This status indicates that the signature is valid but the key used to verify the signature has expired. For the combined result this status means that all signatures are valid and all keys are expired. @item GPGME_SIG_STAT_BAD This status indicates that the signature is invalid. For the combined result this status means that all signatures are invalid. @item GPGME_SIG_STAT_NOKEY This status indicates that the signature could not be verified due to a missing key. For the combined result this status means that all signatures could not be checked due to missing keys. @item GPGME_SIG_STAT_NOSIG This status indicates that the signature data provided was not a real signature. @item GPGME_SIG_STAT_ERROR This status indicates that there was some other error which prevented the signature verification. @item GPGME_SIG_STAT_DIFF For the combined result this status means that at least two signatures have a different status. You can get each key's status with @code{gpgme_get_sig_status}. @end table @end deftp @deftypefun {const char *} gpgme_get_sig_status (@w{gpgme_ctx_t @var{ctx}}, @w{int @var{idx}}, @w{gpgme_sig_stat_t *@var{r_stat}}, @w{time_t *@var{r_created}}) The function @code{gpgme_get_sig_status} is equivalent to: @example gpgme_verify_result_t result; gpgme_signature_t sig; result = gpgme_op_verify_result (ctx); sig = result->signatures; while (sig && idx) @{ sig = sig->next; idx--; @} if (!sig || idx) return NULL; if (r_stat) @{ switch (gpg_err_code (sig->status)) @{ case GPG_ERR_NO_ERROR: *r_stat = GPGME_SIG_STAT_GOOD; break; case GPG_ERR_BAD_SIGNATURE: *r_stat = GPGME_SIG_STAT_BAD; break; case GPG_ERR_NO_PUBKEY: *r_stat = GPGME_SIG_STAT_NOKEY; break; case GPG_ERR_NO_DATA: *r_stat = GPGME_SIG_STAT_NOSIG; break; case GPG_ERR_SIG_EXPIRED: *r_stat = GPGME_SIG_STAT_GOOD_EXP; break; case GPG_ERR_KEY_EXPIRED: *r_stat = GPGME_SIG_STAT_GOOD_EXPKEY; break; default: *r_stat = GPGME_SIG_STAT_ERROR; break; @} @} if (r_created) *r_created = sig->timestamp; return sig->fpr; @end example @end deftypefun @deftypefun {const char *} gpgme_get_sig_string_attr (@w{gpgme_ctx_t @var{ctx}}, @w{int @var{idx}}, @w{gpgme_attr_t @var{what}}, @w{int @var{whatidx}}) The function @code{gpgme_get_sig_string_attr} is equivalent to: @example gpgme_verify_result_t result; gpgme_signature_t sig; result = gpgme_op_verify_result (ctx); sig = result->signatures; while (sig && idx) @{ sig = sig->next; idx--; @} if (!sig || idx) return NULL; switch (what) @{ case GPGME_ATTR_FPR: return sig->fpr; case GPGME_ATTR_ERRTOK: if (whatidx == 1) return sig->wrong_key_usage ? "Wrong_Key_Usage" : ""; else return ""; default: break; @} return NULL; @end example @end deftypefun -@deftypefun {const char *} gpgme_get_sig_ulong_attr (@w{gpgme_ctx_t @var{ctx}}, @w{int @var{idx}}, @w{gpgme_attr_t @var{waht}}, @w{int @var{whatidx}}) +@deftypefun {const char *} gpgme_get_sig_ulong_attr (@w{gpgme_ctx_t @var{ctx}}, @w{int @var{idx}}, @w{gpgme_attr_t @var{what}}, @w{int @var{whatidx}}) The function @code{gpgme_get_sig_ulong_attr} is equivalent to: @example gpgme_verify_result_t result; gpgme_signature_t sig; result = gpgme_op_verify_result (ctx); sig = result->signatures; while (sig && idx) @{ sig = sig->next; idx--; @} if (!sig || idx) return 0; switch (what) @{ case GPGME_ATTR_CREATED: return sig->timestamp; case GPGME_ATTR_EXPIRE: return sig->exp_timestamp; case GPGME_ATTR_VALIDITY: return (unsigned long) sig->validity; case GPGME_ATTR_SIG_STATUS: switch (sig->status) @{ case GPG_ERR_NO_ERROR: return GPGME_SIG_STAT_GOOD; case GPG_ERR_BAD_SIGNATURE: return GPGME_SIG_STAT_BAD; case GPG_ERR_NO_PUBKEY: return GPGME_SIG_STAT_NOKEY; case GPG_ERR_NO_DATA: return GPGME_SIG_STAT_NOSIG; case GPG_ERR_SIG_EXPIRED: return GPGME_SIG_STAT_GOOD_EXP; case GPG_ERR_KEY_EXPIRED: return GPGME_SIG_STAT_GOOD_EXPKEY; default: return GPGME_SIG_STAT_ERROR; @} case GPGME_ATTR_SIG_SUMMARY: return sig->summary; default: break; @} return 0; @end example @end deftypefun @deftypefun {const char *} gpgme_get_sig_key (@w{gpgme_ctx_t @var{ctx}}, @w{int @var{idx}}, @w{gpgme_key_t *@var{r_key}}) The function @code{gpgme_get_sig_key} is equivalent to: @example gpgme_verify_result_t result; gpgme_signature_t sig; result = gpgme_op_verify_result (ctx); sig = result->signatures; while (sig && idx) @{ sig = sig->next; idx--; @} if (!sig || idx) return gpg_error (GPG_ERR_EOF); return gpgme_get_key (ctx, sig->fpr, r_key, 0); @end example @end deftypefun @include lesser.texi @include gpl.texi @node Concept Index @unnumbered Concept Index @printindex cp @node Function and Data Index @unnumbered Function and Data Index @printindex fn @bye diff --git a/doc/uiserver.texi b/doc/uiserver.texi index 6938aeea..e001d120 100644 --- a/doc/uiserver.texi +++ b/doc/uiserver.texi @@ -1,621 +1,621 @@ @c uiserver.texi -*- mode: texinfo; coding: latin-1; -*- @c Specification of the UI server protocol. @c To be included by gpgme.texi @node UI Server Protocol @appendix The GnuPG UI Server Protocol @cindex UI server @cindex user interface server This section specifies the protocol used between clients and a User Interface Server (UI server). This protocol helps to build a system where all cryptographic operations are done by a server and the server is responsible for all dialogs. Although @acronym{GPGME} has no direct support for this protocol it is believed that servers will utilize the @acronym{GPGME} library; thus having the specification included in this manual is an appropriate choice. This protocol should be referenced as `The GnuPG UI Server Protocol'. @noindent A server needs to implement these commands:@footnote{In all examples we assume that the connection has already been established; see the Assuan manual for details.} @menu * UI Server Encrypt:: Encrypt a message. * UI Server Sign:: Sign a message. * UI Server Decrypt:: Decrypt a message. * UI Server Verify:: Verify a message. * UI Server Set Input Files:: Specifying the input files to operate on. * UI Server Sign/Encrypt Files:: Encrypting and signing files. * UI Server Verify/Decrypt Files:: Decrypting and verifying files. * UI Server Import/Export Keys:: Managing certificates. * UI Server Checksum Files:: Create and verify checksums for files. * Miscellaneous UI Server Commands:: Commands not related to a specific operation. @end menu @node UI Server Encrypt @section UI Server: Encrypt a Message Before encryption can be done the recipients must be set using the command: @deffn Command RECIPIENT @var{string} Set the recipient for the encryption. @var{string} is an RFC-2822 recipient name ("mailbox" as per section 3.4). This command may or may not check the recipient for validity right away; if it does not all recipients are expected to be checked at the time of the @code{ENCRYPT} command. All @code{RECIPIENT} commands are cumulative until a successful @code{ENCRYPT} command or until a @code{RESET} command. Linefeeds are obviously not allowed in @var{string} and should be folded into spaces (which are equivalent). @end deffn @noindent To tell the server the source and destination of the data, the next two commands are to be used: @deffn Command INPUT FD=@var{n} Set the file descriptor for the message to be encrypted to @var{n}. The message send to the server is binary encoded. GpgOL is a Windows only program, thus @var{n} is not a libc file descriptor but a regular system handle. Given that the Assuan connection works over a socket, it is not possible to use regular inheritance to make the file descriptor available to the server. Thus @code{DuplicateHandle} needs to be used to duplicate a handle to the server process. This is the reason that the server needs to implement the @code{GETINFO pid} command. Sending this command a second time replaces the file descriptor set by the last one. @c If @var{n} is not given, this commands uses the @c %last file descriptor passed to the application. @c %@xref{fun-assuan_sendfd, ,the assuan_sendfd function,assuan,the @c %Libassuan manual}, on how to do descriptor passing. @end deffn @deffn Command OUTPUT FD=@var{n} [--binary] Set the file descriptor to be used for the output (i.e. the encrypted message) to @var{n}. If the option @code{--binary} is given the output shall be in binary format; if not given, the output for OpenPGP needs to be ASCII armored and for CMS Base-64 encoded. For details on the file descriptor, see the @code{INPUT} command. @end deffn @noindent The setting of the recipients, the data source and destination may happen in any order, even intermixed. If this has been done the actual encryption operation is called using: @deffn Command ENCRYPT -@w{}-protocol=@var{name} This command reads the plaintext from the file descriptor set by the @code{INPUT} command, encrypts it and writes the ciphertext to the file descriptor set by the @code{OUTPUT} command. The server may (and should) overlap reading and writing. The recipients used for the encryption are all the recipients set so far. If any recipient is not usable the server should take appropriate measures to notify the user about the problem and may cancel the operation by returning an error code. The used file descriptors are void after this command; the recipient list is only cleared if the server returns success. @noindent Because GpgOL uses a streaming mode of operation the server is not allowed to auto select the protocol and must obey to the mandatory @var{protocol} parameter: @table @code @item OpenPGP Use the OpenPGP protocol (RFC-2440). @item CMS Use the CMS (PKCS#7) protocol (RFC-3852). @end table @end deffn To support automagically selection of the protocol depending on the selected keys, the server MAY implement the command: @deffn Command PREP_ENCRYPT [-@w{}-protocol=@var{name}] [-@w{}-expect-sign] This commands considers all recipients set so far and decides whether it is able to take input and start the actual encryption. This is kind of a dry-run @command{ENCRYPT} without requiring or using the input and output file descriptors. The server shall cache the result of any user selection to avoid asking this again when the actual @command{ENCRYPT} command is send. The @option{--protocol} option is optional; if it is not given, the server should allow the user to select the protocol to be used based on the recipients given or by any other means. If @option{--expect-sign} is given the server should expect that the message will also be signed and use this hint to present a unified recipient and signer selection dialog if possible and desired. A selected signer should then be cached for the expected SIGN command (which is expected in the same session but possible on another connection). If this command is given again before a successful @command{ENCRYPT} command, the second one takes effect. Before sending the OK response the server shall tell the client the protocol to be used (either the one given by the argument or the one selected by the user) by means of a status line: @end deffn @deffn {Status line} PROTOCOL @var{name} Advise the client to use the protocol @var{name} for the @command{ENCRYPT} command. The valid protocol names are listed under the description of the @command{ENCRYPT} command. The server shall emit exactly one PROTOCOL status line. @end deffn @noindent Here is an example of a complete encryption sequence; client lines are indicated by a @sc{c:}, server responses by @sc{c:}: @smallexample @group @clnt{RESET} @srvr{OK} @clnt{RECIPIENT foo@@example.net} @srvr{OK} @clnt{RECIPIENT bar@@example.com} @srvr{OK} @clnt{PREP_ENCRYPT} @srvr{S PROTOCOL OpenPGP} @srvr{OK} @clnt{INPUT FD=17} @srvr{OK} @clnt{OUTPUT FD=18} @srvr{OK} @clnt{ENCRYPT} @srvr{OK} @end group @end smallexample @node UI Server Sign @section UI Server: Sign a Message The server needs to implement opaque signing as well as detached signing. Due to the nature of OpenPGP messages it is always required to send the entire message to the server; sending just the hash is not possible. The following two commands are required to set the input and output file descriptors: @deffn Command INPUT FD=@var{n} Set the file descriptor for the message to be signed to @var{n}. The message send to the server is binary encoded. For details on the file descriptor, see the description of @code{INPUT} in the @code{ENCRYPT} section. @end deffn @deffn Command OUTPUT FD=@var{n} [--binary] Set the file descriptor to be used for the output. The output is either the complete signed message or in case of a detached signature just that detached signature. If the option @code{--binary} is given the output shall be in binary format; if not given, the output for OpenPGP needs to be ASCII armored and for CMS Base-64 encoded. For details on the file descriptor, see the @code{INPUT} command. @end deffn @noindent To allow the server the selection of a non-default signing key the client may optionally use the @code{SENDER} command, see @ref{command SENDER}. @noindent The signing operation is then initiated by: @deffn Command SIGN -@w{}-protocol=@var{name} [-@w{}-detached] Sign the data set with the @code{INPUT} command and write it to the sink set by OUTPUT. @var{name} is the signing protocol used for the message. For a description of the allowed protocols see the @code{ENCRYPT} command. With option @code{--detached} given, a detached signature is created; this is actually the usual way the command is used. @end deffn @noindent The client expects the server to send at least this status information before the final OK response: @deffn {Status line} MICALG @var{string} The @var{string} represents the hash algorithm used to create the signature. It is used with RFC-1847 style signature messages and defined by PGP/MIME (RFC-3156) and S/MIME (RFC-3851). The GPGME library has a supporting function @code{gpgme_hash_algo_name} to return the algorithm name as a string. This string needs to be lowercased and for OpenPGP prefixed with "@code{pgp-}". @end deffn @node UI Server Decrypt @section UI Server: Decrypt a Message Decryption may include the verification of OpenPGP messages. This is due to the often used combined signing/encryption modus of OpenPGP. The client may pass an option to the server to inhibit the signature verification. The following two commands are required to set the input and output file descriptors: @deffn Command INPUT FD=@var{n} Set the file descriptor for the message to be decrypted to @var{n}. The message send to the server is either binary encoded or --- in the case of OpenPGP --- ASCII armored. For details on the file descriptor, see the description of @code{INPUT} in the @code{ENCRYPT} section. @end deffn @deffn Command OUTPUT FD=@var{n} Set the file descriptor to be used for the output. The output is binary encoded. For details on the file descriptor, see the description of @code{INPUT} in the @code{ENCRYPT} section. @end deffn @noindent The decryption is started with the command: @deffn Command DECRYPT -@w{}-protocol=@var{name} [-@w{}-no-verify] [-@w{}-export-session-key] @var{name} is the encryption protocol used for the message. For a description of the allowed protocols see the @code{ENCRYPT} command. This argument is mandatory. If the option @option{--no-verify} is given, the server should not try to verify a signature, in case the input data is an OpenPGP combined message. If the option @option{--export-session-key} is given and the underlying engine knows how to export the session key, it will appear on a status line @end deffn @node UI Server Verify @section UI Server: Verify a Message The server needs to support the verification of opaque signatures as well as detached signatures. The kind of input sources controls what kind message is to be verified. @deffn Command MESSAGE FD=@var{n} This command is used with detached signatures to set the file descriptor for the signed data to @var{n}. The data is binary encoded (used verbatim). For details on the file descriptor, see the description of @code{INPUT} in the @code{ENCRYPT} section. @end deffn @deffn Command INPUT FD=@var{n} Set the file descriptor for the opaque message or the signature part of a detached signature to @var{n}. The message send to the server is either binary encoded or -- in the case of OpenPGP -- ASCII armored. For details on the file descriptor, see the description of @code{INPUT} in the @code{ENCRYPT} section. @end deffn @deffn Command OUTPUT FD=@var{n} Set the file descriptor to be used for the output. The output is binary encoded and only used for opaque signatures. For details on the file descriptor, see the description of @code{INPUT} in the @code{ENCRYPT} section. @end deffn @noindent The verification is then started using: @deffn Command VERIFY -@w{}-protocol=@var{name} [-@w{}-silent] @var{name} is the signing protocol used for the message. For a description of the allowed protocols see the @code{ENCRYPT} command. This argument is mandatory. Depending on the combination of @code{MESSAGE} @code{INPUT} and @code{OUTPUT} commands, the server needs to select the appropriate verification mode: @table @asis @item MESSAGE and INPUT This indicates a detached signature. Output data is not applicable. @item INPUT This indicates an opaque signature. As no output command has been given, the server is only required to check the signature. @item INPUT and OUTPUT This indicates an opaque signature. The server shall write the signed data to the file descriptor set by the output command. This data shall even be written if the signatures can't be verified. @end table @end deffn With @option{--silent} the server shall not display any dialog; this is for example used by the client to get the content of opaque signed messages. The client expects the server to send at least this status information before the final OK response: @deffn {Status line} SIGSTATUS @var{flag} @var{displaystring} Returns the status for the signature and a short string explaining the status. Valid values for @var{flag} are: @table @code @item none The message has a signature but it could not not be verified due to a missing key. @item green The signature is fully valid. @item yellow The signature is valid but additional information was shown regarding the validity of the key. @item red The signature is not valid. @end table @var{displaystring} is a percent-and-plus-encoded string with a short human readable description of the status. For example @smallexample S SIGSTATUS green Good+signature+from+Keith+Moon+ @end smallexample Note that this string needs to fit into an Assuan line and should be short enough to be displayed as short one-liner on the clients window. As usual the encoding of this string is UTF-8 and it should be send in its translated form. The server shall send one status line for every signature found on the message. @end deffn @node UI Server Set Input Files @section UI Server: Specifying the input files to operate on. All file related UI server commands operate on a number of input files or directories, specified by one or more @code{FILE} commands: @deffn Command FILE [--clear] @var{name} Add the file or directory @var{name} to the list of pathnames to be processed by the server. The parameter @var{name} must be an absolute path name (including the drive letter) and is percent espaced (in particular, the characters %, = and white space characters are always escaped). If the option @code{--clear} is given, the list of files is cleared before adding @var{name}. Historical note: The original spec did not define @code{--clear} but the keyword @code{--continued} after the file name to indicate that more files are to be expected. However, this has never been used and thus removed from the specs. @end deffn @node UI Server Sign/Encrypt Files @section UI Server: Encrypting and signing files. First, the input files need to be specified by one or more @code{FILE} commands. Afterwards, the actual operation is requested: @deffn Command ENCRYPT_FILES --nohup @deffnx Command SIGN_FILES --nohup @deffnx Command ENCRYPT_SIGN_FILES --nohup Request that the files specified by @code{FILE} are encrypted and/or signed. The command selects the default action. The UI server may allow the user to change this default afterwards interactively, and even abort the operation or complete it only on some of the selected files and directories. What it means to encrypt or sign a file or directory is specific to the preferences of the user, the functionality the UI server provides, and the selected protocol. Typically, for each input file a new file is created under the original filename plus a protocol specific extension (like @code{.gpg} or @code{.sig}), which contain the encrypted/signed file or a detached signature. For directories, the server may offer multiple options to the user (for example ignore or process recursively). The @code{ENCRYPT_SIGN_FILES} command requests a combined sign and encrypt operation. It may not be available for all protocols (for example, it is available for OpenPGP but not for CMS). The option @code{--nohup} is mandatory. It is currently unspecified what should happen if @code{--nohup} is not present. Because @code{--nohup} is present, the server always returns @code{OK} promptly, and completes the operation asynchronously. @end deffn @node UI Server Verify/Decrypt Files @section UI Server: Decrypting and verifying files. First, the input files need to be specified by one or more @code{FILE} commands. Afterwards, the actual operation is requested: @deffn Command DECRYPT_FILES --nohup @deffnx Command VERIFY_FILES --nohup @deffnx Command DECRYPT_VERIFY_FILES --nohup Request that the files specified by @code{FILE} are decrypted and/or verified. The command selects the default action. The UI server may allow the user to change this default afterwards interactively, and even abort the operation or complete it only on some of the selected files and directories. What it means to decrypt or verify a file or directory is specific to the preferences of the user, the functionality the UI server provides, and the selected protocol. Typically, for decryption, a new file is created for each input file under the original filename minus a protocol specific extension (like @code{.gpg}) which contains the original plaintext. For verification a status is displayed for each signed input file, indicating if it is signed, and if yes, if the signature is valid. For files that are signed and encrypted, the @code{VERIFY} command transiently decrypts the file to verify the enclosed signature. For directories, the server may offer multiple options to the user (for example ignore or process recursively). The option @code{--nohup} is mandatory. It is currently unspecified what should happen if @code{--nohup} is not present. Because @code{--nohup} is present, the server always returns @code{OK} promptly, and completes the operation asynchronously. @end deffn @node UI Server Import/Export Keys @section UI Server: Managing certificates. First, the input files need to be specified by one or more @code{FILE} commands. Afterwards, the actual operation is requested: @deffn Command IMPORT_FILES --nohup Request that the certificates contained in the files specified by @code{FILE} are imported into the local certificate databases. For directories, the server may offer multiple options to the user (for example ignore or process recursively). The option @code{--nohup} is mandatory. It is currently unspecified what should happen if @code{--nohup} is not present. Because @code{--nohup} is present, the server always returns @code{OK} promptly, and completes the operation asynchronously. @end deffn FIXME: It may be nice to support an @code{EXPORT} command as well, which is enabled by the context menu of the background of a directory. @node UI Server Checksum Files @section UI Server: Create and verify checksums for files. First, the input files need to be specified by one or more @code{FILE} commands. Afterwards, the actual operation is requested: @deffn Command CHECKSUM_CREATE_FILES --nohup Request that checksums are created for the files specified by @code{FILE}. The choice of checksum algorithm and the destination storage and format for the created checksums depend on the preferences of the user and the functionality provided by the UI server. For directories, the server may offer multiple options to the user (for example ignore or process recursively). The option @code{--nohup} is mandatory. It is currently unspecified what should happen if @code{--nohup} is not present. Because @code{--nohup} is present, the server always returns @code{OK} promptly, and completes the operation asynchronously. @end deffn @deffn Command CHECKSUM_VERIFY_FILES --nohup Request that checksums are created for the files specified by @code{FILE} and verified against previously created and stored checksums. The choice of checksum algorithm and the source storage and format for previously created checksums depend on the preferences of the user and the functionality provided by the UI server. For directories, the server may offer multiple options to the user (for example ignore or process recursively). If the source storage of previously created checksums is available to the user through the Windows shell, this command may also accept such checksum files as @code{FILE} arguments. In this case, the UI server should instead verify the checksum of the referenced files as if they were given as INPUT files. The option @code{--nohup} is mandatory. It is currently unspecified what should happen if @code{--nohup} is not present. Because @code{--nohup} is present, the server always returns @code{OK} promptly, and completes the operation asynchronously. @end deffn @c @c M I S C E L L A N E O U S C O M M A N D S @c @node Miscellaneous UI Server Commands @section Miscellaneous UI Server Commands The server needs to implement the following commands which are not related to a specific command: @deffn Command GETINFO @var{what} This is a multi purpose command, commonly used to return a variety of information. The required subcommands as described by the @var{what} parameter are: @table @code @item pid Return the process id of the server in decimal notation using an Assuan data line. @end table @end deffn @noindent To allow the server to pop up the windows in the correct relation to the client, the client is advised to tell the server by sending the option: @deffn {Command option} window-id @var{number} The @var{number} represents the native window ID of the clients current window. On Windows systems this is a windows handle (@code{HWND}) and on X11 systems it is the @code{X Window ID}. The number needs to be given as a hexadecimal value so that it is easier to convey pointer values (e.g. @code{HWND}). @end deffn @noindent A client may want to fire up the certificate manager of the server. To do this it uses the Assuan command: @deffn Command START_KEYMANAGER The server shall pop up the main window of the key manager (aka certificate manager). The client expects that the key manager is brought -into the foregound and that this command immediatley returns (does not +into the foregound and that this command immediately returns (does not wait until the key manager has been fully brought up). @end deffn @noindent A client may want to fire up the configuration dialog of the server. To do this it uses the Assuan command: @deffn Command START_CONFDIALOG The server shall pop up its configuration dialog. The client expects that this dialog is brought into the foregound and that this command -immediatley returns (i.e. it does not wait until the dialog has been +immediately returns (i.e. it does not wait until the dialog has been fully brought up). @end deffn @anchor{command SENDER} @noindent When doing an operation on a mail, it is useful to let the server know the address of the sender: @deffn Command SENDER [-@w{}-info] [-@w{}-protocol=@var{name}] @var{email} @var{email} is the plain ASCII encoded address ("addr-spec" as per RFC-2822) enclosed in angle brackets. The address set with this command is valid until a successful completion of the operation or until a @code{RESET} command. A second command overrides the effect of the first one; if @var{email} is not given and @option{--info} is not used, the server shall use the default signing key. If option @option{--info} is not given, the server shall also suggest a protocol to use for signing. The client may use this suggested protocol on its own discretion. The same status line as with PREP_ENCRYPT is used for this. The option @option{--protocol} may be used to give the server a hint on which signing protocol should be preferred. @end deffn @noindent To allow the UI-server to visually identify a running operation or to associate operations the server MAY support the command: @deffn Command SESSION @var{number} [@var{string}] The @var{number} is an arbitrary value, a server may use to associate simultaneous running sessions. It is a 32 bit unsigned integer with @code{0} as a special value indicating that no session association shall be done. If @var{string} is given, the server may use this as the title of a window or, in the case of an email operation, to extract the sender's address. The string may contain spaces; thus no plus-escaping is used. This command may be used at any time and overrides the effect of the last command. A @code{RESET} undoes the effect of this command. @end deffn diff --git a/lang/cl/gpgme.lisp b/lang/cl/gpgme.lisp index b1a38ca1..a0d5f3d0 100644 --- a/lang/cl/gpgme.lisp +++ b/lang/cl/gpgme.lisp @@ -1,2261 +1,2261 @@ ;;;; gpgme.lisp ;;; Copyright (C) 2006 g10 Code GmbH ;;; ;;; This file is part of GPGME-CL. ;;; ;;; GPGME-CL 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, 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. ;;; ;;; You should have received a copy of the GNU General Public License ;;; along with GPGME; if not, write to the Free Software Foundation, ;;; Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. ;;; TODO ;;; Set up the library. (in-package :gpgme) (deftype byte-array () '(simple-array (unsigned-byte 8) (*))) (deftype character-array () '(simple-array character (*))) ;;; Debugging. (defvar *debug* nil "If debugging output should be given or not.") ;;; Load the foreign library. (define-foreign-library libgpgme (:unix "libgpgme.so") (t (:default "libgpgme"))) (use-foreign-library libgpgme) ;;; System dependencies. ; Access to ERRNO. (defcfun ("strerror" c-strerror) :string (err :int)) (defun get-errno () *errno*) (defun set-errno (errno) (setf *errno* errno)) (define-condition system-error (error) ((errno :initarg :errno :reader system-error-errno)) (:report (lambda (c stream) (format stream "System error: ~A: ~A" (system-error-errno c) (c-strerror (system-error-errno c))))) (:documentation "Signalled when an errno is encountered.")) ; Needed to write passphrases. (defcfun ("write" c-write) ssize-t (fd :int) (buffer :string) ; Actually :pointer, but we only need string. (size size-t)) (defun system-write (fd buffer size) (let ((res (c-write fd buffer size))) (when (< res 0) (error 'system-error :errno (get-errno))) res)) ;;; ;;; C Interface Definitions ;;; ;;; Data Type Interface ;;; Some new data types used for easier translation. ;;; The number of include certs. Translates to NIL for default. (defctype cert-int-t (:wrapper :int :from-c translate-cert-int-t-from-foreign :to-c translate-cert-int-t-to-foreign)) ;;; A string that may be NIL to indicate a null pointer. (defctype string-or-nil-t (:wrapper :string :to-c translate-string-or-nil-t-to-foreign)) ;;; Some opaque data types used by GPGME. (defctype gpgme-ctx-t (:wrapper :pointer :to-c translate-gpgme-ctx-t-to-foreign) "The GPGME context type.") (defctype gpgme-data-t (:wrapper :pointer :to-c translate-gpgme-data-t-to-foreign) "The GPGME data object type.") ;;; Wrappers for the libgpg-error library. (defctype gpgme-error-t (:wrapper gpg-error::gpg-error-t :from-c translate-gpgme-error-t-from-foreign :to-c translate-gpgme-error-t-to-foreign) "The GPGME error type.") (defctype gpgme-error-no-signal-t (:wrapper gpg-error::gpg-error-t :from-c translate-gpgme-error-no-signal-t-from-foreign) "The GPGME error type (this version does not signal conditions in translation.") (defctype gpgme-err-code-t gpg-error::gpg-err-code-t "The GPGME error code type.") (defctype gpgme-err-source-t gpg-error::gpg-err-source-t "The GPGME error source type.") (defun gpgme-err-make (source code) "Construct an error value from an error code and source." (gpg-err-make source code)) (defun gpgme-error (code) "Construct an error value from an error code." (gpgme-err-make :gpg-err-source-gpgme code)) (defun gpgme-err-code (err) "Retrieve an error code from the error value ERR." (gpg-err-code err)) (defun gpgme-err-source (err) "Retrieve an error source from the error value ERR." (gpg-err-source err)) (defun gpgme-strerror (err) - "Return a string containig a description of the error code." + "Return a string containing a description of the error code." (gpg-strerror err)) (defun gpgme-strsource (err) - "Return a string containig a description of the error source." + "Return a string containing a description of the error source." (gpg-strsource err)) (defun gpgme-err-code-from-errno (err) "Retrieve the error code for the system error. If the system error is not mapped, :gpg-err-unknown-errno is returned." (gpg-err-code-from-errno err)) (defun gpgme-err-code-to-errno (code) "Retrieve the system error for the error code. If this is not a system error, 0 is returned." (gpg-err-code-to-errno code)) (defun gpgme-err-make-from-errno (source err) (gpg-err-make-from-errno source err)) (defun gpgme-error-from-errno (err) (gpg-error-from-errno err)) ;;; (defcenum gpgme-data-encoding-t "The possible encoding mode of gpgme-data-t objects." (:none 0) (:binary 1) (:base64 2) (:armor 3) (:url 4) (:urlesc 5) (:url0 6) (:mime 7)) ;;; (defcenum gpgme-pubkey-algo-t "Public key algorithms from libgcrypt." (:rsa 1) (:rsa-e 2) (:rsa-s 3) (:elg-e 16) (:dsa 17) (:ecc 18) (:elg 20) (:ecdsa 301) (:ecdh 302) (:eddsa 303)) (defcenum gpgme-hash-algo-t "Hash algorithms from libgcrypt." (:none 0) (:md5 1) (:sha1 2) (:rmd160 3) (:md2 5) (:tiger 6) (:haval 7) (:sha256 8) (:sha384 9) (:sha512 10) (:sha224 11) (:md4 301) (:crc32 302) (:crc32-rfc1510 303) (:crc24-rfc2440 304)) ;;; (defcenum gpgme-sig-mode-t "The available signature modes." (:none 0) (:detach 1) (:clear 2)) ;;; (defcenum gpgme-validity-t "The available validities for a trust item or key." (:unknown 0) (:undefined 1) (:never 2) (:marginal 3) (:full 4) (:ultimate 5)) ;;; (defcenum gpgme-protocol-t "The available protocols." (:openpgp 0) (:cms 1) (:gpgconf 2) (:assuan 3) (:g13 4) (:uiserver 5) (:spawn 6) (:default 254) (:unknown 255)) ;;; (defbitfield (gpgme-keylist-mode-t :unsigned-int) "The available keylist mode flags." (:local 1) (:extern 2) (:sigs 4) (:sig-notations) (:with-secret 16) (:with-tofu 32) (:ephemeral 128) (:validate 256)) ;;; (defbitfield (gpgme-sig-notation-flags-t :unsigned-int) "The available signature notation flags." (:human-readable 1) (:critical 2)) (defctype gpgme-sig-notation-t (:wrapper :pointer :from-c translate-gpgme-sig-notation-t-from-foreign) "Signature notation pointer type.") -;; FIXME: Doesn't this depend on endianess? +;; FIXME: Doesn't this depend on endianness? (defbitfield (gpgme-sig-notation-bitfield :unsigned-int) (:human-readable 1) (:critical 2)) (defcstruct gpgme-sig-notation "Signature notations." (next gpgme-sig-notation-t) (name :pointer) (value :pointer) (name-len :int) (value-len :int) (flags gpgme-sig-notation-flags-t) (bitfield gpgme-sig-notation-bitfield)) ;;; (defcenum gpgme-status-code-t "The possible status codes for the edit operation." (:eof 0) (:enter 1) (:leave 2) (:abort 3) (:goodsig 4) (:badsig 5) (:errsig 6) (:badarmor 7) (:rsa-or-idea 8) (:keyexpired 9) (:keyrevoked 10) (:trust-undefined 11) (:trust-never 12) (:trust-marginal 13) (:trust-fully 14) (:trust-ultimate 15) (:shm-info 16) (:shm-get 17) (:shm-get-bool 18) (:shm-get-hidden 19) (:need-passphrase 20) (:validsig 21) (:sig-id 22) (:enc-to 23) (:nodata 24) (:bad-passphrase 25) (:no-pubkey 26) (:no-seckey 27) (:need-passphrase-sym 28) (:decryption-failed 29) (:decryption-okay 30) (:missing-passphrase 31) (:good-passphrase 32) (:goodmdc 33) (:badmdc 34) (:errmdc 35) (:imported 36) (:import-ok 37) (:import-problem 38) (:import-res 39) (:file-start 40) (:file-done 41) (:file-error 42) (:begin-decryption 43) (:end-decryption 44) (:begin-encryption 45) (:end-encryption 46) (:delete-problem 47) (:get-bool 48) (:get-line 49) (:get-hidden 50) (:got-it 51) (:progress 52) (:sig-created 53) (:session-key 54) (:notation-name 55) (:notation-data 56) (:policy-url 57) (:begin-stream 58) (:end-stream 59) (:key-created 60) (:userid-hint 61) (:unexpected 62) (:inv-recp 63) (:no-recp 64) (:already-signed 65) (:sigexpired 66) (:expsig 67) (:expkeysig 68) (:truncated 69) (:error 70) (:newsig 71) (:revkeysig 72) (:sig-subpacket 73) (:need-passphrase-pin 74) (:sc-op-failure 75) (:sc-op-success 76) (:cardctrl 77) (:backup-key-created 78) (:pka-trust-bad 79) (:pka-trust-good 80) (:plaintext 81) (:inv-sgnr 82) (:no-sgnr 83) (:success 84) (:decryption-info 85) (:plaintext-length 86) (:mountpoint 87) (:pinentry-launched 88) (:attribute 89) (:begin-signing 90) (:key-not-created 91) (:inquire-maxlen 92) (:failure 93) (:key-considered 94) (:tofu-user 95) (:tofu-stats 96) (:tofu-stats-long 97) (:notation-flags 98) (:decryption-compliance-mode 99) (:verification-compliance-mode 100)) ;;; (defctype gpgme-engine-info-t (:wrapper :pointer :from-c translate-gpgme-engine-info-t-to-foreign) "The engine information structure pointer type.") (defcstruct gpgme-engine-info "Engine information." (next gpgme-engine-info-t) (protocol gpgme-protocol-t) (file-name :string) (version :string) (req-version :string) (home-dir :string)) ;;; (defctype gpgme-subkey-t (:wrapper :pointer :from-c translate-gpgme-subkey-t-from-foreign) "A subkey from a key.") -;; FIXME: Doesn't this depend on endianess? +;; FIXME: Doesn't this depend on endianness? (defbitfield (gpgme-subkey-bitfield :unsigned-int) "The subkey bitfield." (:revoked 1) (:expired 2) (:disabled 4) (:invalid 8) (:can-encrypt 16) (:can-sign 32) (:can-certify 64) (:secret 128) (:can-authenticate 256) (:is-qualified 512) (:is-cardkey 1024) (:is-de-vs 2048)) (defcstruct gpgme-subkey "Subkey from a key." (next gpgme-subkey-t) (bitfield gpgme-subkey-bitfield) (pubkey-algo gpgme-pubkey-algo-t) (length :unsigned-int) (keyid :string) (-keyid :char :count 17) (fpr :string) (timestamp :long) (expires :long)) (defctype gpgme-key-sig-t (:wrapper :pointer :from-c translate-gpgme-key-sig-t-from-foreign) "A signature on a user ID.") -;; FIXME: Doesn't this depend on endianess? +;; FIXME: Doesn't this depend on endianness? (defbitfield (gpgme-key-sig-bitfield :unsigned-int) "The key signature bitfield." (:revoked 1) (:expired 2) (:invalid 4) (:exportable 16)) (defcstruct gpgme-key-sig "A signature on a user ID." (next gpgme-key-sig-t) (bitfield gpgme-key-sig-bitfield) (pubkey-algo gpgme-pubkey-algo-t) (keyid :string) (-keyid :char :count 17) (timestamp :long) (expires :long) (status gpgme-error-no-signal-t) (-class :unsigned-int) (uid :string) (name :string) (email :string) (comment :string) (sig-class :unsigned-int)) (defctype gpgme-user-id-t (:wrapper :pointer :from-c translate-gpgme-user-id-t-from-foreign) "A user ID from a key.") -;; FIXME: Doesn't this depend on endianess? +;; FIXME: Doesn't this depend on endianness? (defbitfield (gpgme-user-id-bitfield :unsigned-int) "The user ID bitfield." (:revoked 1) (:invalid 2)) (defcstruct gpgme-user-id "A user ID from a key." (next gpgme-user-id-t) (bitfield gpgme-user-id-bitfield) (validity gpgme-validity-t) (uid :string) (name :string) (email :string) (comment :string) (signatures gpgme-key-sig-t) (-last-keysig gpgme-key-sig-t)) (defctype gpgme-key-t (:wrapper :pointer :from-c translate-gpgme-key-t-from-foreign :to-c translate-gpgme-key-t-to-foreign) "A key from the keyring.") -;; FIXME: Doesn't this depend on endianess? +;; FIXME: Doesn't this depend on endianness? (defbitfield (gpgme-key-bitfield :unsigned-int) "The key bitfield." (:revoked 1) (:expired 2) (:disabled 4) (:invalid 8) (:can-encrypt 16) (:can-sign 32) (:can-certify 64) (:secret 128) (:can-authenticate 256) (:is-qualified 512)) (defcstruct gpgme-key "A signature on a user ID." (-refs :unsigned-int) (bitfield gpgme-key-bitfield) (protocol gpgme-protocol-t) (issuer-serial :string) (issuer-name :string) (chain-id :string) (owner-trust gpgme-validity-t) (subkeys gpgme-subkey-t) (uids gpgme-user-id-t) (-last-subkey gpgme-subkey-t) (-last-uid gpgme-user-id-t) (keylist-mode gpgme-keylist-mode-t)) ;;; ;;; There is no support in CFFI to define callback C types and have ;;; automatic type checking with the callback definition. (defctype gpgme-passphrase-cb-t :pointer) (defctype gpgme-progress-cb-t :pointer) (defctype gpgme-edit-cb-t :pointer) ;;; ;;; Function Interface ;;; ;;; Context management functions. (defcfun ("gpgme_new" c-gpgme-new) gpgme-error-t (ctx :pointer)) (defcfun ("gpgme_release" c-gpgme-release) :void (ctx gpgme-ctx-t)) (defcfun ("gpgme_set_protocol" c-gpgme-set-protocol) gpgme-error-t (ctx gpgme-ctx-t) (proto gpgme-protocol-t)) (defcfun ("gpgme_get_protocol" c-gpgme-get-protocol) gpgme-protocol-t (ctx gpgme-ctx-t)) (defcfun ("gpgme_get_protocol_name" c-gpgme-get-protocol-name) :string (proto gpgme-protocol-t)) (defcfun ("gpgme_set_armor" c-gpgme-set-armor) :void (ctx gpgme-ctx-t) (yes :boolean)) (defcfun ("gpgme_get_armor" c-gpgme-get-armor) :boolean (ctx gpgme-ctx-t)) (defcfun ("gpgme_set_textmode" c-gpgme-set-textmode) :void (ctx gpgme-ctx-t) (yes :boolean)) (defcfun ("gpgme_get_textmode" c-gpgme-get-textmode) :boolean (ctx gpgme-ctx-t)) (defconstant +include-certs-default+ -256) (defcfun ("gpgme_set_include_certs" c-gpgme-set-include-certs) :void (ctx gpgme-ctx-t) (nr-of-certs cert-int-t)) (defcfun ("gpgme_get_include_certs" c-gpgme-get-include-certs) cert-int-t (ctx gpgme-ctx-t)) (defcfun ("gpgme_set_keylist_mode" c-gpgme-set-keylist-mode) gpgme-error-t (ctx gpgme-ctx-t) (mode gpgme-keylist-mode-t)) (defcfun ("gpgme_get_keylist_mode" c-gpgme-get-keylist-mode) gpgme-keylist-mode-t (ctx gpgme-ctx-t)) (defcfun ("gpgme_set_passphrase_cb" c-gpgme-set-passphrase-cb) :void (ctx gpgme-ctx-t) (cb gpgme-passphrase-cb-t) (hook-value :pointer)) (defcfun ("gpgme_get_passphrase_cb" c-gpgme-get-passphrase-cb) :void (ctx gpgme-ctx-t) (cb-p :pointer) (hook-value-p :pointer)) (defcfun ("gpgme_set_progress_cb" c-gpgme-set-progress-cb) :void (ctx gpgme-ctx-t) (cb gpgme-progress-cb-t) (hook-value :pointer)) (defcfun ("gpgme_get_progress_cb" c-gpgme-get-progress-cb) :void (ctx gpgme-ctx-t) (cb-p :pointer) (hook-value-p :pointer)) (defcfun ("gpgme_set_locale" c-gpgme-set-locale) gpgme-error-t (ctx gpgme-ctx-t) (category :int) (value string-or-nil-t)) (defcfun ("gpgme_ctx_get_engine_info" c-gpgme-ctx-get-engine-info) gpgme-engine-info-t (ctx gpgme-ctx-t)) (defcfun ("gpgme_ctx_set_engine_info" c-gpgme-ctx-set-engine-info) gpgme-error-t (ctx gpgme-ctx-t) (proto gpgme-protocol-t) (file-name string-or-nil-t) (home-dir string-or-nil-t)) ;;; (defcfun ("gpgme_pubkey_algo_name" c-gpgme-pubkey-algo-name) :string (algo gpgme-pubkey-algo-t)) (defcfun ("gpgme_hash_algo_name" c-gpgme-hash-algo-name) :string (algo gpgme-hash-algo-t)) ;;; (defcfun ("gpgme_signers_clear" c-gpgme-signers-clear) :void (ctx gpgme-ctx-t)) (defcfun ("gpgme_signers_add" c-gpgme-signers-add) gpgme-error-t (ctx gpgme-ctx-t) (key gpgme-key-t)) (defcfun ("gpgme_signers_enum" c-gpgme-signers-enum) gpgme-key-t (ctx gpgme-ctx-t) (seq :int)) ;;; (defcfun ("gpgme_sig_notation_clear" c-gpgme-sig-notation-clear) :void (ctx gpgme-ctx-t)) (defcfun ("gpgme_sig_notation_add" c-gpgme-sig-notation-add) gpgme-error-t (ctx gpgme-ctx-t) (name :string) (value string-or-nil-t) (flags gpgme-sig-notation-flags-t)) (defcfun ("gpgme_sig_notation_get" c-gpgme-sig-notation-get) gpgme-sig-notation-t (ctx gpgme-ctx-t)) ;;; Run Control. ;;; There is no support in CFFI to define callback C types and have ;;; automatic type checking with the callback definition. (defctype gpgme-io-cb-t :pointer) (defctype gpgme-register-io-cb-t :pointer) (defctype gpgme-remove-io-cb-t :pointer) (defcenum gpgme-event-io-t "The possible events on I/O event callbacks." (:start 0) (:done 1) (:next-key 2) (:next-trustitem 3)) (defctype gpgme-event-io-cb-t :pointer) (defcstruct gpgme-io-cbs "I/O callbacks." (add gpgme-register-io-cb-t) (add-priv :pointer) (remove gpgme-remove-io-cb-t) (event gpgme-event-io-cb-t) (event-priv :pointer)) (defctype gpgme-io-cbs-t :pointer) (defcfun ("gpgme_set_io_cbs" c-gpgme-set-io-cbs) :void (ctx gpgme-ctx-t) (io-cbs gpgme-io-cbs-t)) (defcfun ("gpgme_get_io_cbs" c-gpgme-get-io-cbs) :void (ctx gpgme-ctx-t) (io-cbs gpgme-io-cbs-t)) (defcfun ("gpgme_wait" c-gpgme-wait) gpgme-ctx-t (ctx gpgme-ctx-t) (status-p :pointer) (hang :int)) ;;; Functions to handle data objects. ;;; There is no support in CFFI to define callback C types and have ;;; automatic type checking with the callback definition. (defctype gpgme-data-read-cb-t :pointer) (defctype gpgme-data-write-cb-t :pointer) (defctype gpgme-data-seek-cb-t :pointer) (defctype gpgme-data-release-cb-t :pointer) (defcstruct gpgme-data-cbs "Data callbacks." (read gpgme-data-read-cb-t) (write gpgme-data-write-cb-t) (seek gpgme-data-seek-cb-t) (release gpgme-data-release-cb-t)) (defctype gpgme-data-cbs-t :pointer "Data callbacks pointer.") (defcfun ("gpgme_data_read" c-gpgme-data-read) ssize-t (dh gpgme-data-t) (buffer :pointer) (size size-t)) (defcfun ("gpgme_data_write" c-gpgme-data-write) ssize-t (dh gpgme-data-t) (buffer :pointer) (size size-t)) (defcfun ("gpgme_data_seek" c-gpgme-data-seek) off-t (dh gpgme-data-t) (offset off-t) (whence :int)) (defcfun ("gpgme_data_new" c-gpgme-data-new) gpgme-error-t (dh-p :pointer)) (defcfun ("gpgme_data_release" c-gpgme-data-release) :void (dh gpgme-data-t)) (defcfun ("gpgme_data_new_from_mem" c-gpgme-data-new-from-mem) gpgme-error-t (dh-p :pointer) (buffer :pointer) (size size-t) (copy :int)) (defcfun ("gpgme_data_release_and_get_mem" c-gpgme-data-release-and-get-mem) :pointer (dh gpgme-data-t) (len-p :pointer)) (defcfun ("gpgme_data_new_from_cbs" c-gpgme-data-new-from-cbs) gpgme-error-t (dh-p :pointer) (cbs gpgme-data-cbs-t) (handle :pointer)) (defcfun ("gpgme_data_new_from_fd" c-gpgme-data-new-from-fd) gpgme-error-t (dh-p :pointer) (fd :int)) (defcfun ("gpgme_data_new_from_stream" c-gpgme-data-new-from-stream) gpgme-error-t (dh-p :pointer) (stream :pointer)) (defcfun ("gpgme_data_get_encoding" c-gpgme-data-get-encoding) gpgme-data-encoding-t (dh gpgme-data-t)) (defcfun ("gpgme_data_set_encoding" c-gpgme-data-set-encoding) gpgme-error-t (dh gpgme-data-t) (enc gpgme-data-encoding-t)) (defcfun ("gpgme_data_get_file_name" c-gpgme-data-get-file-name) :string (dh gpgme-data-t)) (defcfun ("gpgme_data_set_file_name" c-gpgme-data-set-file-name) gpgme-error-t (dh gpgme-data-t) (file-name string-or-nil-t)) (defcfun ("gpgme_data_new_from_file" c-gpgme-data-new-from-file) gpgme-error-t (dh-p :pointer) (fname :string) (copy :int)) (defcfun ("gpgme_data_new_from_filepart" c-gpgme-data-new-from-filepart) gpgme-error-t (dh-p :pointer) (fname :string) (fp :pointer) (offset off-t) (length size-t)) ;;; Key and trust functions. (defcfun ("gpgme_get_key" c-gpgme-get-key) gpgme-error-t (ctx gpgme-ctx-t) (fpr :string) (key-p :pointer) (secret :boolean)) (defcfun ("gpgme_key_ref" c-gpgme-key-ref) :void (key gpgme-key-t)) (defcfun ("gpgme_key_unref" c-gpgme-key-unref) :void (key gpgme-key-t)) ;;; Crypto operations. (defcfun ("gpgme_cancel" c-gpgme-cancel) gpgme-error-t (ctx gpgme-ctx-t)) ;;; (defctype gpgme-invalid-key-t (:wrapper :pointer :from-c translate-gpgme-invalid-key-t-from-foreign) "An invalid key structure.") (defcstruct gpgme-invalid-key "An invalid key structure." (next gpgme-invalid-key-t) (fpr :string) (reason gpgme-error-no-signal-t)) ;;; Encryption. (defcstruct gpgme-op-encrypt-result "Encryption result structure." (invalid-recipients gpgme-invalid-key-t)) (defctype gpgme-op-encrypt-result-t (:wrapper :pointer :from-c translate-gpgme-op-encrypt-result-t-from-foreign) "An encryption result structure.") (defcfun ("gpgme_op_encrypt_result" c-gpgme-op-encrypt-result) gpgme-op-encrypt-result-t (ctx gpgme-ctx-t)) (defbitfield gpgme-encrypt-flags-t (:always-trust 1) (:no-encrypt-to 2) (:prepare 4) (:expect-sign 8) (:no-compress 16) (:symmetric 32) (:throw-keyids 64) (:wrap 128) (:want-address 256)) (defcfun ("gpgme_op_encrypt_start" c-gpgme-op-encrypt-start) gpgme-error-t (ctx gpgme-ctx-t) (recp :pointer) ; Key array. (flags gpgme-encrypt-flags-t) (plain gpgme-data-t) (cipher gpgme-data-t)) (defcfun ("gpgme_op_encrypt" c-gpgme-op-encrypt) gpgme-error-t (ctx gpgme-ctx-t) (recp :pointer) ; Key array. (flags gpgme-encrypt-flags-t) (plain gpgme-data-t) (cipher gpgme-data-t)) (defcfun ("gpgme_op_encrypt_sign_start" c-gpgme-op-encrypt-sign-start) gpgme-error-t (ctx gpgme-ctx-t) (recp :pointer) ; Key array. (flags gpgme-encrypt-flags-t) (plain gpgme-data-t) (cipher gpgme-data-t)) (defcfun ("gpgme_op_encrypt_sign" c-gpgme-op-encrypt-sign) gpgme-error-t (ctx gpgme-ctx-t) (recp :pointer) ; Key array. (flags gpgme-encrypt-flags-t) (plain gpgme-data-t) (cipher gpgme-data-t)) ;;; Decryption. (defctype gpgme-recipient-t (:wrapper :pointer :from-c translate-gpgme-recipient-t-from-foreign) "A recipient structure.") (defcstruct gpgme-recipient "Recipient structure." (next gpgme-recipient-t) (keyid :string) (-keyid :char :count 17) (pubkey-algo gpgme-pubkey-algo-t) (status gpgme-error-no-signal-t)) (defbitfield gpgme-op-decrypt-result-bitfield "Decryption result structure bitfield." (:wrong-key-usage 1) (:is-de-vs 2) (:is-mine 4)) (defcstruct gpgme-op-decrypt-result "Decryption result structure." (unsupported-algorithm :string) (bitfield gpgme-op-decrypt-result-bitfield) (recipients gpgme-recipient-t) (file-name :string)) (defctype gpgme-op-decrypt-result-t (:wrapper :pointer :from-c translate-gpgme-op-decrypt-result-t-from-foreign) "A decryption result structure.") (defcfun ("gpgme_op_decrypt_result" c-gpgme-op-decrypt-result) gpgme-op-decrypt-result-t (ctx gpgme-ctx-t)) (defcfun ("gpgme_op_decrypt_start" c-gpgme-op-decrypt-start) gpgme-error-t (ctx gpgme-ctx-t) (cipher gpgme-data-t) (plain gpgme-data-t)) (defcfun ("gpgme_op_decrypt" c-gpgme-op-decrypt) gpgme-error-t (ctx gpgme-ctx-t) (cipher gpgme-data-t) (plain gpgme-data-t)) (defcfun ("gpgme_op_decrypt_verify_start" c-gpgme-op-decrypt-verify-start) gpgme-error-t (ctx gpgme-ctx-t) (cipher gpgme-data-t) (plain gpgme-data-t)) (defcfun ("gpgme_op_decrypt_verify" c-gpgme-op-decrypt-verify) gpgme-error-t (ctx gpgme-ctx-t) (cipher gpgme-data-t) (plain gpgme-data-t)) ;;; Signing. (defctype gpgme-new-signature-t (:wrapper :pointer :from-c translate-gpgme-new-signature-t-from-foreign) "A new signature structure.") (defcstruct gpgme-new-signature "New signature structure." (next gpgme-new-signature-t) (type gpgme-sig-mode-t) (pubkey-algo gpgme-pubkey-algo-t) (hash-algo gpgme-hash-algo-t) (-obsolete-class :unsigned-long) (timestamp :long) (fpr :string) (-obsolete-class-2 :unsigned-int) (sig-class :unsigned-int)) (defcstruct gpgme-op-sign-result "Signing result structure." (invalid-signers gpgme-invalid-key-t) (signatures gpgme-new-signature-t)) (defctype gpgme-op-sign-result-t (:wrapper :pointer :from-c translate-gpgme-op-sign-result-t-from-foreign) "A signing result structure.") (defcfun ("gpgme_op_sign_result" c-gpgme-op-sign-result) gpgme-op-sign-result-t (ctx gpgme-ctx-t)) (defcfun ("gpgme_op_sign_start" c-gpgme-op-sign-start) gpgme-error-t (ctx gpgme-ctx-t) (plain gpgme-data-t) (sig gpgme-data-t) (mode gpgme-sig-mode-t)) (defcfun ("gpgme_op_sign" c-gpgme-op-sign) gpgme-error-t (ctx gpgme-ctx-t) (plain gpgme-data-t) (sig gpgme-data-t) (mode gpgme-sig-mode-t)) ;;; Verify. (defbitfield (gpgme-sigsum-t :unsigned-int) "Flags used for the summary field in a gpgme-signature-t." (:valid #x0001) (:green #x0002) (:red #x0004) (:key-revoked #x0010) (:key-expired #x0020) (:sig-expired #x0040) (:key-missing #x0080) (:crl-missing #x0100) (:crl-too-old #x0200) (:bad-policy #x0400) (:sys-error #x0800) (:tofu-conflict #x1000)) (defctype gpgme-signature-t (:wrapper :pointer :from-c translate-gpgme-signature-t-from-foreign) "A signature structure.") -;; FIXME: Doesn't this depend on endianess? +;; FIXME: Doesn't this depend on endianness? (defbitfield (gpgme-signature-bitfield :unsigned-int) "The signature bitfield." (:wrong-key-usage 1) (:pka-trust 2) (:chain-model 4) (:is-de-vs 8)) (defcstruct gpgme-signature "Signature structure." (next gpgme-signature-t) (summary gpgme-sigsum-t) (fpr :string) (status gpgme-error-no-signal-t) (notations gpgme-sig-notation-t) (timestamp :unsigned-long) (exp-timestamp :unsigned-long) (bitfield gpgme-signature-bitfield) (validity gpgme-validity-t) (validity-reason gpgme-error-no-signal-t) (pubkey-algo gpgme-pubkey-algo-t) (hash-algo gpgme-hash-algo-t)) (defcstruct gpgme-op-verify-result "Verify result structure." (signatures gpgme-signature-t) (file-name :string)) (defctype gpgme-op-verify-result-t (:wrapper :pointer :from-c translate-gpgme-op-verify-result-t-from-foreign) "A verify result structure.") (defcfun ("gpgme_op_verify_result" c-gpgme-op-verify-result) gpgme-op-verify-result-t (ctx gpgme-ctx-t)) (defcfun ("gpgme_op_verify_start" c-gpgme-op-verify-start) gpgme-error-t (ctx gpgme-ctx-t) (sig gpgme-data-t) (signed-text gpgme-data-t) (plaintext gpgme-data-t)) (defcfun ("gpgme_op_verify" c-gpgme-op-verify) gpgme-error-t (ctx gpgme-ctx-t) (sig gpgme-data-t) (signed-text gpgme-data-t) (plaintext gpgme-data-t)) ;;; Import. (defbitfield (gpgme-import-flags-t :unsigned-int) "Flags used for the import status field." (:new #x0001) (:uid #x0002) (:sig #x0004) (:subkey #x0008) (:secret #x0010)) (defctype gpgme-import-status-t (:wrapper :pointer :from-c translate-gpgme-import-status-t-from-foreign) "An import status structure.") (defcstruct gpgme-import-status "New import status structure." (next gpgme-import-status-t) (fpr :string) (result gpgme-error-no-signal-t) (status :unsigned-int)) (defcstruct gpgme-op-import-result "Import result structure." (considered :int) (no-user-id :int) (imported :int) (imported-rsa :int) (unchanged :int) (new-user-ids :int) (new-sub-keys :int) (new-signatures :int) (new-revocations :int) (secret-read :int) (secret-imported :int) (secret-unchanged :int) (skipped-new-keys :int) (not-imported :int) (imports gpgme-import-status-t)) (defctype gpgme-op-import-result-t (:wrapper :pointer :from-c translate-gpgme-op-import-result-t-from-foreign) "An import status result structure.") (defcfun ("gpgme_op_import_result" c-gpgme-op-import-result) gpgme-op-import-result-t (ctx gpgme-ctx-t)) (defcfun ("gpgme_op_import_start" c-gpgme-op-import-start) gpgme-error-t (ctx gpgme-ctx-t) (keydata gpgme-data-t)) (defcfun ("gpgme_op_import" c-gpgme-op-import) gpgme-error-t (ctx gpgme-ctx-t) (keydata gpgme-data-t)) ;;; Export. (defcfun ("gpgme_op_export_start" c-gpgme-op-export-start) gpgme-error-t (ctx gpgme-ctx-t) (pattern :string) (reserved :unsigned-int) (keydata gpgme-data-t)) (defcfun ("gpgme_op_export" c-gpgme-op-export) gpgme-error-t (ctx gpgme-ctx-t) (pattern :string) (reserved :unsigned-int) (keydata gpgme-data-t)) ;;; FIXME: Extended export interfaces require array handling. ;;; Key generation. (defbitfield (gpgme-genkey-flags-t :unsigned-int) "Flags used for the key generation result bitfield." (:primary #x0001) (:sub #x0002) (:uid #x0004)) (defcstruct gpgme-op-genkey-result "Key generation result structure." (bitfield gpgme-genkey-flags-t) (fpr :string)) (defctype gpgme-op-genkey-result-t :pointer "A key generation result structure.") (defcfun ("gpgme_op_genkey_result" c-gpgme-op-genkey-result) gpgme-op-genkey-result-t (ctx gpgme-ctx-t)) (defcfun ("gpgme_op_genkey_start" c-gpgme-op-genkey-start) gpgme-error-t (ctx gpgme-ctx-t) (parms :string) (pubkey gpgme-data-t) (seckey gpgme-data-t)) (defcfun ("gpgme_op_genkey" c-gpgme-op-genkey) gpgme-error-t (ctx gpgme-ctx-t) (parms :string) (pubkey gpgme-data-t) (seckey gpgme-data-t)) ;;; Key deletion. (defcfun ("gpgme_op_delete_start" c-gpgme-op-delete-start) gpgme-error-t (ctx gpgme-ctx-t) (key gpgme-key-t) (allow-secret :int)) (defcfun ("gpgme_op_delete" c-gpgme-op-delete) gpgme-error-t (ctx gpgme-ctx-t) (key gpgme-key-t) (allow-secret :int)) ;;; FIXME: Add edit interfaces. ;;; Keylist interface. (defbitfield (gpgme-keylist-flags-t :unsigned-int) "Flags used for the key listing result bitfield." (:truncated #x0001)) (defcstruct gpgme-op-keylist-result "Key listing result structure." (bitfield gpgme-keylist-flags-t)) (defctype gpgme-op-keylist-result-t :pointer "A key listing result structure.") (defcfun ("gpgme_op_keylist_result" c-gpgme-op-keylist-result) gpgme-op-keylist-result-t (ctx gpgme-ctx-t)) (defcfun ("gpgme_op_keylist_start" c-gpgme-op-keylist-start) gpgme-error-t (ctx gpgme-ctx-t) (pattern :string) (secret_only :boolean)) ;;; FIXME: Extended keylisting requires array handling. (defcfun ("gpgme_op_keylist_next" c-gpgme-op-keylist-next) gpgme-error-t (ctx gpgme-ctx-t) (r-key :pointer)) (defcfun ("gpgme_op_keylist_end" c-gpgme-op-keylist-end) gpgme-error-t (ctx gpgme-ctx-t)) ;;; Various functions. (defcfun ("gpgme_check_version" c-gpgme-check-version) :string (req-version string-or-nil-t)) (defcfun ("gpgme_get_engine_info" c-gpgme-get-engine-info) gpgme-error-t (engine-info-p :pointer)) (defcfun ("gpgme_set_engine_info" c-gpgme-set-engine-info) gpgme-error-t (proto gpgme-protocol-t) (file-name string-or-nil-t) (home-dir string-or-nil-t)) (defcfun ("gpgme_engine_check_version" c-gpgme-engine-check-verson) gpgme-error-t (proto gpgme-protocol-t)) ;;; ;;; L I S P I N T E R F A C E ;;; ;;; ;;; Lisp type translators. ;;; ;;; Both directions. ;;; cert-int-t is a helper type that takes care of representing the ;;; default number of certs as NIL. (defun translate-cert-int-t-from-foreign (value) (cond ((eql value +include-certs-default+) nil) (t value))) (defun translate-cert-int-t-to-foreign (value) (cond (value value) (t +include-certs-default+))) ;;; string-or-nil-t translates a null pointer to NIL and vice versa. ;;; Translation from foreign null pointer already works as expected. (defun translate-string-or-nil-t-to-foreign (value) (cond (value value) (t (null-pointer)))) ;;; Output only. ;;; These type translators only convert from foreign type, because we ;;; never use these types in the other direction. ;;; Convert gpgme-engine-info-t linked lists into a list of property ;;; lists. Note that this converter will automatically be invoked ;;; recursively. ;;; ;;; FIXME: Should we use a hash table (or struct, or clos) instead of ;;; property list, as recommended by the Lisp FAQ? (defun translate-gpgme-engine-info-t-from-foreign (value) (cond ((null-pointer-p value) nil) (t (with-foreign-slots ((next protocol file-name version req-version home-dir) value (:struct gpgme-engine-info)) (append (list protocol (list :file-name file-name :version version :req-version req-version :home-dir home-dir)) next))))) (defun translate-gpgme-invalid-key-t-from-foreign (value) (cond ((null-pointer-p value) nil) (t (with-foreign-slots ((next fpr reason) value (:struct gpgme-invalid-key)) (append (list (list :fpr fpr :reason reason)) next))))) (defun translate-gpgme-op-encrypt-result-t-from-foreign (value) (cond ((null-pointer-p value) nil) (t (with-foreign-slots ((invalid-recipients) value (:struct gpgme-op-encrypt-result)) (list :encrypt (list :invalid-recipients invalid-recipients)))))) (defun translate-gpgme-recipient-t-from-foreign (value) (cond ((null-pointer-p value) nil) (t (with-foreign-slots ((next keyid pubkey-algo status) value (:struct gpgme-recipient)) (append (list (list :keyid keyid :pubkey-algo pubkey-algo :status status)) next))))) (defun translate-gpgme-op-decrypt-result-t-from-foreign (value) (cond ((null-pointer-p value) nil) (t (with-foreign-slots ((unsupported-algorithm bitfield recipients file-name) value (:struct gpgme-op-decrypt-result)) (list :decrypt (list :unsupported-algorithm unsupported-algorithm :bitfield bitfield :recipients recipients :file-name file-name)))))) (defun translate-gpgme-new-signature-t-from-foreign (value) (cond ((null-pointer-p value) nil) (t (with-foreign-slots ((next type pubkey-algo hash-algo timestamp fpr sig-class) value (:struct gpgme-new-signature)) (append (list (list :type type :pubkey-algo pubkey-algo :hash-algo hash-algo :timestamp timestamp :fpr fpr :sig-class sig-class)) next))))) (defun translate-gpgme-op-sign-result-t-from-foreign (value) (cond ((null-pointer-p value) nil) (t (with-foreign-slots ((invalid-signers signatures) value (:struct gpgme-op-sign-result)) (list :sign (list :invalid-signers invalid-signers :signatures signatures)))))) (defun translate-gpgme-signature-t-from-foreign (value) (cond ((null-pointer-p value) nil) (t (with-foreign-slots ((next summary fpr status notations timestamp exp-timestamp bitfield validity validity-reason pubkey-algo hash-algo) value (:struct gpgme-signature)) (append (list (list :summary summary :fpr fpr :status status :notations notations :timestamp timestamp :exp-timestamp exp-timestamp :bitfield bitfield :validity validity :validity-reason validity-reason :pubkey-algo pubkey-algo)) next))))) (defun translate-gpgme-op-verify-result-t-from-foreign (value) (cond ((null-pointer-p value) nil) (t (with-foreign-slots ((signatures file-name) value (:struct gpgme-op-verify-result)) (list :verify (list :signatures signatures :file-name file-name)))))) (defun translate-gpgme-import-status-t-from-foreign (value) (cond ((null-pointer-p value) nil) (t (with-foreign-slots ((next fpr result status) value (:struct gpgme-import-status)) (append (list (list :fpr fpr :result result :status status)) next))))) (defun translate-gpgme-op-import-result-t-from-foreign (value) (cond ((null-pointer-p value) nil) (t (with-foreign-slots ((considered no-user-id imported imported-rsa unchanged new-user-ids new-sub-keys new-signatures new-revocations secret-read secret-imported secret-unchanged skipped-new-keys not-imported imports) value (:struct gpgme-op-import-result)) (list :verify (list :considered considered :no-user-id no-user-id :imported imported :imported-rsa imported-rsa :unchanged unchanged :new-user-ids new-user-ids :new-sub-keys new-sub-keys :new-signatures new-signatures :new-revocations new-revocations :secret-read secret-read :secret-imported secret-imported :secret-unchanged secret-unchanged :skipped-new-keys skipped-new-keys :not-imported not-imported :imports imports)))))) ;;; Error handling. ;;; Use gpgme-error-no-signal-t to suppress automatic error handling ;;; at translation time. ;;; ;;; FIXME: Part of this probably should be in gpg-error! (define-condition gpgme-error (error) ((value :initarg :gpgme-error :reader gpgme-error-value)) (:report (lambda (c stream) (format stream "GPGME returned error: ~A (~A)" (gpgme-strerror (gpgme-error-value c)) (gpgme-strsource (gpgme-error-value c))))) (:documentation "Signalled when a GPGME function returns an error.")) (defun translate-gpgme-error-t-from-foreign (value) "Raise a GPGME-ERROR if VALUE is non-zero." (when (not (eql (gpgme-err-code value) :gpg-err-no-error)) (error 'gpgme-error :gpgme-error value)) (gpg-err-canonicalize value)) (defun translate-gpgme-error-t-to-foreign (value) "Canonicalize the error value." (if (eql (gpgme-err-code value) :gpg-err-no-error) 0 (gpg-err-as-value value))) (defun translate-gpgme-error-no-signal-t-from-foreign (value) "Canonicalize the error value." (gpg-err-canonicalize value)) ;;; *INTERNAL* Lispy Function Interface that is still close to the C ;;; interface. ;;; Passphrase callback management. ;;; Maybe: Instead, use subclassing, and provide a customizable ;;; default implementation for ease-of-use. (defvar *passphrase-handles* (make-hash-table) "Hash table with GPGME context address as key and the corresponding passphrase callback object as value.") (defcallback passphrase-cb gpgme-error-t ((handle :pointer) (uid-hint :string) (passphrase-info :string) (prev-was-bad :boolean) (fd :int)) (handler-case (let* ((passphrase-cb (gethash (pointer-address handle) *passphrase-handles*)) (passphrase (cond ((functionp passphrase-cb) (concatenate 'string (funcall passphrase-cb uid-hint passphrase-info prev-was-bad) '(#\Newline))) (t (concatenate 'string passphrase-cb '(#\Newline))))) (passphrase-len (length passphrase)) ;; FIXME: Could be more robust. (res (system-write fd passphrase passphrase-len))) (cond ((< res passphrase-len) ; FIXME: Blech. A weak attempt to be robust. (gpgme-error :gpg-err-inval)) (t (gpgme-error :gpg-err-no-error)))) (gpgme-error (err) (gpgme-error-value err)) (system-error (err) (gpgme-error-from-errno (system-error-errno err))) ;; FIXME: The original error gets lost here. (condition (err) (progn (when *debug* (format t "DEBUG: passphrase-cb: Unexpressable: ~A~%" err)) (gpgme-error :gpg-err-general))))) ;;; CTX is a C-pointer to the context. (defun gpgme-set-passphrase-cb (ctx cb) "Set the passphrase callback for CTX." (let ((handle (pointer-address ctx))) (cond (cb (setf (gethash handle *passphrase-handles*) cb) (c-gpgme-set-passphrase-cb ctx (callback passphrase-cb) ctx)) (t (c-gpgme-set-passphrase-cb ctx (null-pointer) (null-pointer)) (remhash handle *passphrase-handles*))))) ;;; Progress callback management. ;;; Maybe: Instead, use subclassing, and provide a customizable ;;; default implementation for ease-of-use. (defvar *progress-handles* (make-hash-table) "Hash table with GPGME context address as key and the corresponding progress callback object as value.") (defcallback progress-cb :void ((handle :pointer) (what :string) (type :int) (current :int) (total :int)) (handler-case (let* ((progress-cb (gethash (pointer-address handle) *progress-handles*))) (funcall progress-cb what type current total)) ;; FIXME: The original error gets lost here. (condition (err) (when *debug* (format t "DEBUG: progress-cb: Unexpressable: ~A~%" err))))) ;;; CTX is a C-pointer to the context. (defun gpgme-set-progress-cb (ctx cb) "Set the progress callback for CTX." (let ((handle (pointer-address ctx))) (cond (cb (setf (gethash handle *progress-handles*) cb) (c-gpgme-set-progress-cb ctx (callback progress-cb) ctx)) (t (c-gpgme-set-progress-cb ctx (null-pointer) (null-pointer)) (remhash handle *progress-handles*))))) ;;; Context management. (defun gpgme-new (&key (protocol :openpgp) armor textmode include-certs keylist-mode passphrase progress file-name home-dir) "Allocate a new GPGME context." (with-foreign-object (ctx-p 'gpgme-ctx-t) (c-gpgme-new ctx-p) (let ((ctx (mem-ref ctx-p 'gpgme-ctx-t))) ;;; Set locale? (gpgme-set-protocol ctx protocol) (gpgme-set-armor ctx armor) (gpgme-set-textmode ctx textmode) (when include-certs (gpgme-set-include-certs ctx include-certs)) (when keylist-mode (gpgme-set-keylist-mode ctx keylist-mode)) (gpgme-set-passphrase-cb ctx passphrase) (gpgme-set-progress-cb ctx progress) (gpgme-set-engine-info ctx protocol :file-name file-name :home-dir home-dir) (when *debug* (format t "DEBUG: gpgme-new: ~A~%" ctx)) ctx))) (defun gpgme-release (ctx) "Release a GPGME context." (when *debug* (format t "DEBUG: gpgme-release: ~A~%" ctx)) (c-gpgme-release ctx)) (defun gpgme-set-protocol (ctx proto) "Set the protocol to be used by CTX to PROTO." (c-gpgme-set-protocol ctx proto)) (defun gpgme-get-protocol (ctx) "Get the protocol used with CTX." (c-gpgme-get-protocol ctx)) ;;; FIXME: How to do pretty printing? ;;; ;;; gpgme-get-protocol-name (defun gpgme-set-armor (ctx armor) "If ARMOR is true, enable armor mode in CTX, disable it otherwise." (c-gpgme-set-armor ctx armor)) (defun gpgme-armor-p (ctx) "Return true if armor mode is set for CTX." (c-gpgme-get-armor ctx)) (defun gpgme-set-textmode (ctx textmode) "If TEXTMODE is true, enable text mode mode in CTX, disable it otherwise." (c-gpgme-set-textmode ctx textmode)) (defun gpgme-textmode-p (ctx) "Return true if text mode mode is set for CTX." (c-gpgme-get-textmode ctx)) (defun gpgme-set-include-certs (ctx &optional certs) "Include up to CERTS certificates in an S/MIME message." (c-gpgme-set-include-certs ctx certs)) (defun gpgme-get-include-certs (ctx) "Return the number of certs to include in an S/MIME message, or NIL if the default is used." (c-gpgme-get-include-certs ctx)) (defun gpgme-get-keylist-mode (ctx) "Get the keylist mode in CTX." (c-gpgme-get-keylist-mode ctx)) (defun gpgme-set-keylist-mode (ctx mode) "Set the keylist mode in CTX." (c-gpgme-set-keylist-mode ctx mode)) ;;; FIXME: How to handle locale? cffi-grovel? (defun gpgme-get-engine-info (&optional ctx) "Retrieve the engine info for CTX, or the default if CTX is omitted." (cond (ctx (c-gpgme-ctx-get-engine-info ctx)) (t (with-foreign-object (info-p 'gpgme-engine-info-t) (c-gpgme-get-engine-info info-p) (mem-ref info-p 'gpgme-engine-info-t))))) (defun gpgme-set-engine-info (ctx proto &key file-name home-dir) "Set the engine info for CTX, or the default if CTX is NIL." (cond (ctx (c-gpgme-ctx-set-engine-info ctx proto file-name home-dir)) (t (c-gpgme-set-engine-info proto file-name home-dir)))) ;;; FIXME: How to do pretty printing? ;;; ;;; gpgme_pubkey_algo_name, gpgme_hash_algo_name (defun gpgme-set-signers (ctx keys) "Set the signers for the context CTX." (c-gpgme-signers-clear ctx) (dolist (key keys) (c-gpgme-signers-add ctx key))) ;;; (defun gpgme-set-sig-notation (ctx notations) "Set the sig notation for the context CTX." (c-gpgme-sig-notation-clear ctx) (dolist (notation notations) (c-gpgme-sig-notation-add ctx (first notation) (second notation) (third notation)))) (defun gpgme-get-sig-notation (ctx) "Get the signature notation data for the context CTX." (c-gpgme-sig-notation-get ctx)) ;;; FIXME: Add I/O callback interface, for integration with clg. ;;; FIXME: Add gpgme_wait? ;;; Streams ;;; ------- ;;; ;;; GPGME uses standard streams. You can define your own streams, or ;;; use the existing file or string streams. ;;; ;;; A stream-spec is either a stream, or a list with a stream as its ;;; first argument followed by keyword parameters: encoding, ;;; file-name. ;;; ;;; FIXME: Eventually, we should provide a class that can be mixed ;;; into stream classes and which provides accessors for encoding and ;;; file-names. This interface should be provided in addition to the ;;; above sleazy interface, because the sleazy interface is easier to ;;; use (less typing), and is quite sufficient in a number of cases. ;;; ;;; For best results, streams with element type (unsigned-byte 8) ;;; should be used. Character streams may work if armor mode is used. ;;; Do we need to provide access to GPGME data objects through streams ;;; as well? It seems to me that specific optimizations, like ;;; directly writing to file descriptors, is better done by extending ;;; the sleazy syntax (stream-spec) instead of customized streams. ;;; Customized streams do buffering, and this may mess up things. Mmh. (defvar *data-handles* (make-hash-table) "Hash table with GPGME data user callback handle address as key and the corresponding stream as value.") ;;; The release callback removes the stream from the *data-handles* ;;; hash and releases the CBS structure that is used as the key in -;;; that hash. It is implicitely invoked (through GPGME) by +;;; that hash. It is implicitly invoked (through GPGME) by ;;; gpgme-data-release. (defcallback data-release-cb :void ((handle :pointer)) (unwind-protect (remhash (pointer-address handle) *data-handles*) (when (not (null-pointer-p handle)) (foreign-free handle)))) (defcallback data-read-cb ssize-t ((handle :pointer) (buffer :pointer) (size size-t)) (when *debug* (format t "DEBUG: gpgme-data-read-cb: want ~A~%" size)) (let ((stream (gethash (pointer-address handle) *data-handles*))) (cond (stream (let* ((stream-type (stream-element-type stream)) (seq (make-array size :element-type stream-type)) (read (read-sequence seq stream))) (cond ((equal stream-type '(unsigned-byte 8)) (dotimes (i read) (setf (mem-aref buffer :unsigned-char i) (aref (the byte-array seq) i)))) ((eql stream-type 'character) (dotimes (i read) (setf (mem-aref buffer :unsigned-char i) (char-code (aref (the character-array seq) i))))) (t (dotimes (i read) (setf (mem-aref buffer :unsigned-char i) (coerce (aref seq i) '(unsigned-byte 8)))))) (when *debug* (format t "DEBUG: gpgme-data-read-cb: read ~A~%" read)) read)) (t (set-errno +ebadf+) -1)))) (defcallback data-write-cb ssize-t ((handle :pointer) (buffer :pointer) (size size-t)) (when *debug* (format t "DEBUG: gpgme-data-write-cb: want ~A~%" size)) (let ((stream (gethash (pointer-address handle) *data-handles*))) (cond (stream (let* ((stream-type (stream-element-type stream)) (seq (make-array size :element-type stream-type))) (cond ((equal stream-type '(unsigned-byte 8)) (dotimes (i size) (setf (aref (the byte-array seq) i) (mem-aref buffer :unsigned-char i)))) ((eql stream-type 'character) (dotimes (i size) (setf (aref (the character-array seq) i) (code-char (mem-aref buffer :unsigned-char i))))) (t (dotimes (i size) (setf (aref seq i) (coerce (mem-aref buffer :unsigned-char i) stream-type))))) (write-sequence seq stream) size)) (t (set-errno +ebadf+) -1)))) ;;; This little helper macro allows us to swallow the cbs structure by ;;; simply setting it to a null pointer, but still protect against ;;; conditions. (defmacro with-cbs-swallowed ((cbs) &body body) `(let ((,cbs (foreign-alloc '(:struct gpgme-data-cbs)))) (unwind-protect (progn ,@body) (when (not (null-pointer-p ,cbs)) (foreign-free ,cbs))))) (defun gpgme-data-new (stream &key encoding file-name) "Allocate a new GPGME data object for STREAM." (with-foreign-object (dh-p 'gpgme-data-t) ;;; We allocate one CBS structure for each stream we wrap in a ;;; data object. Although we could also share all these ;;; structures, as they contain the very same callbacks, we need a ;;; unique C pointer as handle anyway to look up the stream in the ;;; callback. This is a convenient one to use. (with-cbs-swallowed (cbs) (setf (foreign-slot-value cbs '(:struct gpgme-data-cbs) 'read) (callback data-read-cb)) (setf (foreign-slot-value cbs '(:struct gpgme-data-cbs) 'write) (callback data-write-cb)) (setf (foreign-slot-value cbs '(:struct gpgme-data-cbs) 'seek) (null-pointer)) (setf (foreign-slot-value cbs '(:struct gpgme-data-cbs) 'release) (callback data-release-cb)) (c-gpgme-data-new-from-cbs dh-p cbs cbs) (let ((dh (mem-ref dh-p 'gpgme-data-t))) (when encoding (gpgme-data-set-encoding dh encoding)) (when file-name (gpgme-data-set-file-name dh file-name)) ;;; Install the stream into the hash table and swallow the cbs ;;; structure while protecting against any errors. (unwind-protect (progn (setf (gethash (pointer-address cbs) *data-handles*) stream) (setf cbs (null-pointer))) (when (not (null-pointer-p cbs)) (c-gpgme-data-release dh))) (when *debug* (format t "DEBUG: gpgme-data-new: ~A~%" dh)) dh)))) -;;; This function releases a GPGME data object. It implicitely +;;; This function releases a GPGME data object. It implicitly ;;; invokes the data-release-cb function to clean up associated junk. (defun gpgme-data-release (dh) "Release a GPGME data object." (when *debug* (format t "DEBUG: gpgme-data-release: ~A~%" dh)) (c-gpgme-data-release dh)) (defclass data () (c-data) ; The C data object pointer (:documentation "The GPGME data type.")) (defmethod initialize-instance :after ((data data) &key streamspec &allow-other-keys) (let ((c-data (if (listp streamspec) (apply #'gpgme-data-new streamspec) (gpgme-data-new streamspec))) (cleanup t)) (unwind-protect (progn (setf (slot-value data 'c-data) c-data) (finalize data (lambda () (gpgme-data-release c-data))) (setf cleanup nil)) (if cleanup (gpgme-data-release c-data))))) (defun translate-gpgme-data-t-to-foreign (value) ;; Allow a pointer to be passed directly for the finalizer to work. (cond ((null value) (null-pointer)) ((pointerp value) value) (t (slot-value value 'c-data)))) (defmacro with-gpgme-data ((dh streamspec) &body body) `(let ((,dh (make-instance 'data :streamspec ,streamspec))) ,@body)) (defun gpgme-data-get-encoding (dh) "Get the encoding associated with the data object DH." (c-gpgme-data-get-encoding dh)) (defun gpgme-data-set-encoding (dh encoding) "Set the encoding associated with the data object DH to ENCODING." (c-gpgme-data-set-encoding dh encoding)) (defun gpgme-data-get-file-name (dh) "Get the file name associated with the data object DH." (c-gpgme-data-get-file-name dh)) (defun gpgme-data-set-file-name (dh file-name) "Set the file name associated with the data object DH to FILE-NAME." (c-gpgme-data-set-file-name dh file-name)) ;;; FIXME: Add key accessor interfaces. (defun gpgme-get-key (ctx fpr &optional secret) "Get the key with the fingerprint FPR from the context CTX." (with-foreign-object (key-p 'gpgme-key-t) (c-gpgme-get-key ctx fpr key-p secret) (mem-ref key-p 'gpgme-key-t))) (defun gpgme-key-ref (key) "Acquire an additional reference to the key KEY." (when *debug* (format t "DEBUG: gpgme-key-ref: ~A~%" key)) (c-gpgme-key-ref key)) (defun gpgme-key-unref (key) "Release a reference to the key KEY." (when *debug* (format t "DEBUG: gpgme-key-unref: ~A~%" key)) (c-gpgme-key-unref key)) ;;; FIXME: We REALLY need pretty printing for keys and all the other ;;; big structs. ;;; Various interfaces. (defun gpgme-check-version (&optional req-version) (c-gpgme-check-version req-version)) ;;; ;;; The *EXPORTED* CLOS interface. ;;; ;;; The context type. ;;; We wrap the C context pointer into a class object to be able to ;;; stick a finalizer on it. (defclass context () (c-ctx ; The C context object pointer. signers ; The list of signers. sig-notation) ; The list of signers. (:documentation "The GPGME context type.")) (defmethod initialize-instance :after ((ctx context) &rest rest &key &allow-other-keys) (let ((c-ctx (apply #'gpgme-new rest)) (cleanup t)) (unwind-protect (progn (setf (slot-value ctx 'c-ctx) c-ctx) (finalize ctx (lambda () (gpgme-release c-ctx))) (setf cleanup nil)) (if cleanup (gpgme-release c-ctx))))) (defun translate-gpgme-ctx-t-to-foreign (value) ;; Allow a pointer to be passed directly for the finalizer to work. (if (pointerp value) value (slot-value value 'c-ctx))) (defmacro context (&rest rest) "Create a new GPGME context." `(make-instance 'context ,@rest)) ;;; The context type: Accessor functions. ;;; The context type: Accessor functions: Protocol. (defgeneric protocol (ctx) (:documentation "Get the protocol of CONTEXT.")) (defmethod protocol ((ctx context)) (gpgme-get-protocol ctx)) (defgeneric (setf protocol) (protocol ctx) (:documentation "Set the protocol of CONTEXT to PROTOCOL.")) ;;; FIXME: Adjust translator to reject invalid protocols. Currently, -;;; specifing an invalid protocol throws a "NIL is not 32 signed int" +;;; specifying an invalid protocol throws a "NIL is not 32 signed int" ;;; error. This is suboptimal. (defmethod (setf protocol) (protocol (ctx context)) (gpgme-set-protocol ctx protocol)) ;;; The context type: Accessor functions: Armor. ;;; FIXME: Is it good style to make foop setf-able? Or should it be ;;; foo/foop for set/get? (defgeneric armorp (ctx) (:documentation "Get the armor flag of CONTEXT.")) (defmethod armorp ((ctx context)) (gpgme-armor-p ctx)) (defgeneric (setf armorp) (armor ctx) (:documentation "Set the armor flag of CONTEXT to ARMOR.")) (defmethod (setf armorp) (armor (ctx context)) (gpgme-set-armor ctx armor)) ;;; The context type: Accessor functions: Textmode. ;;; FIXME: Is it good style to make foop setf-able? Or should it be ;;; foo/foop for set/get? (defgeneric textmodep (ctx) (:documentation "Get the text mode flag of CONTEXT.")) (defmethod textmodep ((ctx context)) (gpgme-textmode-p ctx)) (defgeneric (setf textmodep) (textmode ctx) (:documentation "Set the text mode flag of CONTEXT to TEXTMODE.")) (defmethod (setf textmodep) (textmode (ctx context)) (gpgme-set-textmode ctx textmode)) ;;; The context type: Accessor functions: Include Certs. (defgeneric include-certs (ctx) (:documentation "Get the number of included certificates in an S/MIME message, or NIL if the default is used.")) (defmethod include-certs ((ctx context)) (gpgme-get-include-certs ctx)) (defgeneric (setf include-certs) (certs ctx) (:documentation "Return the number of certificates to include in an S/MIME message, or NIL if the default is used.")) (defmethod (setf include-certs) (certs (ctx context)) (gpgme-set-include-certs ctx certs)) ;;; The context type: Accessor functions: Engine info. (defgeneric engine-info (ctx) (:documentation "Retrieve the engine info for CTX.")) (defmethod engine-info ((ctx context)) (gpgme-get-engine-info ctx)) (defgeneric (setf engine-info) (info ctx) (:documentation "Set the engine info for CTX.")) (defmethod (setf engine-info) (info (ctx context)) (dolist (proto '(:openpgp :cms)) (let ((pinfo (getf info proto))) (when pinfo (gpgme-set-engine-info ctx proto :file-name (getf pinfo :file-name) :home-dir (getf pinfo :home-dir)))))) ;;; The context type: Accessor functions: Keylist mode. (defgeneric keylist-mode (ctx) (:documentation "Get the keylist mode of CTX.")) (defmethod keylist-mode ((ctx context)) (gpgme-get-keylist-mode ctx)) (defgeneric (setf keylist-mode) (mode ctx) (:documentation "Set the keylist mode of CTX to MODE.")) (defmethod (setf keylist-mode) (mode (ctx context)) (gpgme-set-keylist-mode ctx mode)) ;;; The context type: Accessor functions: Signers. (defgeneric signers (ctx) (:documentation "Get the signers of CTX.")) (defmethod signers ((ctx context)) (slot-value ctx 'signers)) (defgeneric (setf signers) (signers ctx) (:documentation "Set the signers of CTX to SIGNERS.")) (defmethod (setf keylist-mode) (signers (ctx context)) (gpgme-set-signers ctx signers) (setf (slot-value ctx 'signers) signers)) ;;; The context type: Accessor functions: Sig notations. (defgeneric sig-notations (ctx) (:documentation "Get the signature notations of CTX.")) (defmethod sig-notations ((ctx context)) (slot-value ctx 'signers)) (defgeneric (setf sig-notations) (notations ctx) (:documentation "Set the signatire notations of CTX to NOTATIONS.")) (defmethod (setf sig-notations) (notations (ctx context)) (gpgme-set-signers ctx notations) (setf (slot-value ctx 'notations) notations)) ;;; The context type: Support macros. (defmacro with-context ((ctx &rest rest) &body body) `(let ((,ctx (make-instance 'context ,@rest))) ,@body)) ;;; The key type. (defclass key () (c-key) ; The C key object pointer. (:documentation "The GPGME key type.")) ;;; In the initializer, we swallow the c-key argument. (defmethod initialize-instance :after ((key key) &key c-key &allow-other-keys) (setf (slot-value key 'c-key) c-key) (finalize key (lambda () (gpgme-key-unref c-key)))) (defun translate-gpgme-key-t-from-foreign (value) (when *debug* (format t "DEBUG: import key: ~A~%" value)) (make-instance 'key :c-key value)) (defun translate-gpgme-key-t-to-foreign (value) ;; Allow a pointer to be passed directly for the finalizer to work. (if (pointerp value) value (slot-value value 'c-key))) (defmethod print-object ((key key) stream) (print-unreadable-object (key stream :type t :identity t) (format stream "~s" (fpr key)))) ;;; The key type: Accessor functions. ;;; FIXME: The bitfield and flags contain redundant information at ;;; this point. FIXME: Deal nicer with zero-length name (policy url) ;;; and zero length value (omit?) and human-readable (convert to string). ;;; FIXME: Turn binary data into sequence or vector or what it should be. ;;; FIXME: Turn the whole thing into a hash? (defun translate-gpgme-sig-notation-t-from-foreign (value) (cond ((null-pointer-p value) nil) (t (with-foreign-slots ((next name value name-len value-len flags bitfield) value (:struct gpgme-sig-notation)) (append (list (list :name name :value value :name-len name-len :value-len value-len :flags flags :bitfield bitfield)) next))))) ;;; FIXME: Deal nicer with timestamps. bitfield field name? (defun translate-gpgme-subkey-t-from-foreign (value) (cond ((null-pointer-p value) nil) (t (with-foreign-slots ((next bitfield pubkey-algo length keyid fpr timestamp expires) value (:struct gpgme-subkey)) (append (list (list :bitfield bitfield :pubkey-algo pubkey-algo :length length :keyid keyid :fpr fpr :timestamp timestamp :expires expires)) next))))) (defun translate-gpgme-key-sig-t-from-foreign (value) (cond ((null-pointer-p value) nil) (t (with-foreign-slots ((next bitfield pubkey-algo keyid timestamp expires status uid name email comment sig-class) value (:struct gpgme-key-sig)) (append (list (list :bitfield bitfield :pubkey-algo pubkey-algo :keyid keyid :timestamp timestamp :expires expires :status status :uid uid :name name :email email :comment comment :sig-class sig-class)) next))))) (defun translate-gpgme-user-id-t-from-foreign (value) (cond ((null-pointer-p value) nil) (t (with-foreign-slots ((next bitfield validity uid name email comment signatures) value (:struct gpgme-user-id)) (append (list (list :bitfield bitfield :validity validity :uid uid :name name :email email :comment comment :signatures signatures)) next))))) (defun key-data (key) (with-slots (c-key) key (with-foreign-slots ((bitfield protocol issuer-serial issuer-name chain-id owner-trust subkeys uids keylist-mode) c-key (:struct gpgme-key)) (list :bitfield bitfield :protocol protocol :issuer-serial issuer-serial :issuer-name issuer-name :chain-id chain-id :owner-trust owner-trust :subkeys subkeys :uids uids :keylist-mode keylist-mode)) )) (defgeneric fpr (key) (:documentation "Get the primary fingerprint of the key.")) (defmethod fpr ((key key)) (getf (car (getf (key-data key) :subkeys)) :fpr)) ;;; The context type: Crypto-Operations. (defgeneric get-key (ctx fpr &optional secret) (:documentation "Get the (secret) key FPR from CTX.")) (defmethod get-key ((ctx context) fpr &optional secret) (gpgme-get-key ctx fpr secret)) ;;; Encrypt. (defgeneric op-encrypt (ctx recp plain cipher &key always-trust sign) (:documentation "Encrypt.")) (defmethod op-encrypt ((ctx context) recp plain cipher &key always-trust sign) (with-foreign-object (c-recp :pointer (+ 1 (length recp))) (dotimes (i (length recp)) (setf (mem-aref c-recp 'gpgme-key-t i) (elt recp i))) (setf (mem-aref c-recp :pointer (length recp)) (null-pointer)) (with-gpgme-data (in plain) (with-gpgme-data (out cipher) (let ((flags)) (if always-trust (push :always-trust flags)) (cond (sign (c-gpgme-op-encrypt-sign ctx c-recp flags in out) (append (c-gpgme-op-encrypt-result ctx) (c-gpgme-op-sign-result ctx))) (t (c-gpgme-op-encrypt ctx c-recp flags in out) (c-gpgme-op-encrypt-result ctx)))))))) ;;; Decrypt. (defgeneric op-decrypt (ctx cipher plain &key verify) (:documentation "Decrypt.")) (defmethod op-decrypt ((ctx context) cipher plain &key verify) (with-gpgme-data (in cipher) (with-gpgme-data (out plain) (cond (verify (c-gpgme-op-decrypt-verify ctx in out) (append (c-gpgme-op-decrypt-result ctx) (c-gpgme-op-verify-result ctx))) (t (c-gpgme-op-decrypt ctx in out) (c-gpgme-op-decrypt-result ctx)))))) ;;; Signing. (defgeneric op-sign (ctx plain sig &optional mode) (:documentation "Sign.")) (defmethod op-sign ((ctx context) plain sig &optional (mode :none)) (with-gpgme-data (in plain) (with-gpgme-data (out sig) (c-gpgme-op-sign ctx in out mode) (c-gpgme-op-sign-result ctx)))) ;;; Verify. (defgeneric op-verify (ctx sig text &key detached) (:documentation "Verify.")) (defmethod op-verify ((ctx context) sig text &key detached) (with-gpgme-data (in sig) (with-gpgme-data (on text) (c-gpgme-op-verify ctx in (if detached on nil) (if detached nil on)) (c-gpgme-op-verify-result ctx)))) ;;; Import. (defgeneric op-import (ctx keydata) (:documentation "Import.")) (defmethod op-import ((ctx context) keydata) (with-gpgme-data (in keydata) (c-gpgme-op-import ctx in) (c-gpgme-op-import-result ctx))) ;;; Export. (defgeneric op-export (ctx pattern keydata) (:documentation "Export public key data matching PATTERN to the stream KEYDATA.")) (defmethod op-export ((ctx context) pattern keydata) (with-gpgme-data (dh keydata) (c-gpgme-op-export ctx pattern 0 dh))) ;;; Key generation. ;;; ;;; Initialization ;;; (defun check-version (&optional req-version) "Check that the GPGME version requirement is satisfied." (gpgme-check-version req-version)) (defparameter *version* (check-version) "The version number of GPGME used.") diff --git a/lang/cpp/README b/lang/cpp/README index e142e371..16c9a4a1 100644 --- a/lang/cpp/README +++ b/lang/cpp/README @@ -1,101 +1,101 @@ GpgMEpp - C++ bindings/wrapper for GPGME ---------------------------------------- Based on KF5gpgmepp Overview -------- GpgMEpp is a C++ wrapper (or C++ bindings) for the GnuPG project's gpgme (GnuPG Made Easy) library, version 0.4.4 and later. It is fairly complete, with some minor things still missing (in particular, the key edit interface). The design principles of this library are as follows: 1. A value-based interface (most clases are implicitly shared) 2. Callbacks are replaced by C++ interfaces (classes with only abstract methods). 3. No exceptions are thrown 4. There is (as yet) no explicit support for multi-threaded use (other than what gpgme itself provides; most notably the refcounting for implicit sharing is not thread-safe) 5. To avoid binary incompatible interface changes, we make extensive use of the d-pointer pattern and avoid virtual methods; any polymorphism present is already provided by gpgme itself, anyway (see e.g. Data). A notable exception of the no-virtuals rule is the use of abstract classes to cover C-callbacks. 6. Use of STL containers for improved memory management and dealing with lists. 7. Complete abstraction of the C-API so "gpgme.h" should not be needed in your project using GpgME++. 8. Abstraction of GnuPG's edit-key interface by prepared Editinteractor classes. GpgMEpp was originally developed as part of the KDEPIM community. Usage ----- The usage pattern of GpgMEpp closely follows GPGMEs core usage pattern so the documentation for GPGME itself provides a good way to start. The context structure in GPGME is mapped to a Context object in -GpgMEpp. Additional convienience code provides Data objects and +GpgMEpp. Additional convenience code provides Data objects and a Dataprovider interface that can be used to implement GPGME's data with any subclass by implementing the right callbacks. EditInteractor subclasses provide ready to use classes for common --edit-key tasks. You can implement your own editinteractor classes by implementing the EditInteractor interface and using your subclass as an interactor in the edit function. Example to set the ownertrust of a key: /* Create an edit interactor */ EditInteractor *ei = new GpgSetOwnerTrustEditInteractor(Key::Ultimate); /* Obtain a Context */ Context *ctx = Context::createForProtocol(Protocol::OpenPGP); /* Create an in memory data object */ Data data; /* Start the edit on some key previously obtained. */ Error e = ctx->edit(key, std::unique_ptr(ei), data); /* Errors provide boolean comparison */ if (!e) ... /* Delete the context */ delete ctx; Examples / Tests ---------------- GpgMEpp is tested through the Qt API. You can refer to the tests in qt/tests for examples of usage or refer to the actual QGpgME*Job.cpp implementations which rely on GpgMEpp and should cover most use cases. Hacking ------- GpgMEpp follows KDE Coding styles. See: https://techbase.kde.org/Policies/Frameworks_Coding_Style for more info. License ------- GPGMEpp 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. GPGMEpp 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. diff --git a/lang/cpp/src/key.h b/lang/cpp/src/key.h index c4edba07..dd855aec 100644 --- a/lang/cpp/src/key.h +++ b/lang/cpp/src/key.h @@ -1,511 +1,511 @@ /* key.h - wraps a gpgme key Copyright (C) 2003, 2005 Klarälvdalens Datakonsult AB 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. */ // -*- c++ -*- #ifndef __GPGMEPP_KEY_H__ #define __GPGMEPP_KEY_H__ #include "global.h" #include "notation.h" #include "gpgmefw.h" #include #include #include #include #include namespace GpgME { class Context; class Subkey; class UserID; class TofuInfo; typedef std::shared_ptr< std::remove_pointer::type > shared_gpgme_key_t; // // class Key // class GPGMEPP_EXPORT Key { friend class ::GpgME::Context; struct Null { Null() {} }; public: Key(); /* implicit */ Key(const Null &); Key(const shared_gpgme_key_t &key); Key(gpgme_key_t key, bool acquireRef); static const Null null; const Key &operator=(Key other) { swap(other); return *this; } const Key &mergeWith(const Key &other); void swap(Key &other) { using std::swap; swap(this->key, other.key); } bool isNull() const { return !key; } UserID userID(unsigned int index) const; Subkey subkey(unsigned int index) const; unsigned int numUserIDs() const; unsigned int numSubkeys() const; std::vector userIDs() const; std::vector subkeys() const; bool isRevoked() const; bool isExpired() const; bool isDisabled() const; bool isInvalid() const; /*! Shorthand for isNull || isRevoked || isExpired || * isDisabled || isInvalid */ bool isBad() const; 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. */ bool canSign() const; bool canReallySign() const; bool canCertify() const; bool canAuthenticate() const; bool isQualified() const; bool isDeVs() const; bool hasSecret() const; GPGMEPP_DEPRECATED bool isSecret() const { return hasSecret(); } /*! @return true if this is a X.509 root certificate (currently equivalent to something like strcmp( chainID(), subkey(0).fingerprint() ) == 0 ) */ bool isRoot() const; enum OwnerTrust { Unknown = 0, Undefined = 1, Never = 2, Marginal = 3, Full = 4, Ultimate = 5 }; OwnerTrust ownerTrust() const; char ownerTrustAsString() const; Protocol protocol() const; const char *protocolAsString() const; const char *issuerSerial() const; const char *issuerName() const; const char *chainID() const; const char *keyID() const; const char *shortKeyID() const; const char *primaryFingerprint() const; unsigned int keyListMode() const; /*! Update information about this key. * Starts a keylisting for this key with validity * and tofu information gathering. Blocks for * how long the keylisting takes.*/ void update(); /** * @brief Add a user id to this key. * * Needs gnupg 2.1.13 and the key needs to be updated * afterwards to see the new uid. * - * @param uid should be fully formated and UTF-8 encoded. + * @param uid should be fully formatted and UTF-8 encoded. * * @returns a possible error. **/ Error addUid(const char *uid); /** * @brief try to locate the best pgp key for a given mailbox. * * Boils down to gpg --locate-key * This may take some time if remote sources are also * used. * * @param mbox should be a mail address does not need to be normalized. * * @returns The best key for a mailbox or a null key. */ static Key locate(const char *mbox); /* @enum Origin * @brief The Origin of the key. */ enum Origin : unsigned int { OriginUnknown = 0, OriginKS = 1, OriginDane = 3, OriginWKD = 4, OriginURL = 5, OriginFile = 6, OriginSelf = 7, OriginOther = 31, }; /*! Get the origin of the key. * * @returns the Origin. */ Origin origin() const; /*! Get the last update time. * * @returns the last update time. */ time_t lastUpdate() const; private: gpgme_key_t impl() const { return key.get(); } shared_gpgme_key_t key; }; // // class Subkey // class GPGMEPP_EXPORT Subkey { public: Subkey(); Subkey(const shared_gpgme_key_t &key, gpgme_sub_key_t subkey); Subkey(const shared_gpgme_key_t &key, unsigned int idx); const Subkey &operator=(Subkey other) { swap(other); return *this; } void swap(Subkey &other) { using std::swap; swap(this->key, other.key); swap(this->subkey, other.subkey); } bool isNull() const { return !key || !subkey; } Key parent() const; const char *keyID() const; const char *fingerprint() const; time_t creationTime() const; time_t expirationTime() const; bool neverExpires() const; bool isRevoked() const; bool isExpired() const; bool isInvalid() const; bool isDisabled() const; /*! Shorthand for isNull || isRevoked || isExpired || * isDisabled || isInvalid */ bool isBad() const; bool canEncrypt() const; bool canSign() const; bool canCertify() const; bool canAuthenticate() const; bool isQualified() const; bool isDeVs() const; bool isCardKey() const; bool isSecret() const; /** Same as gpgme_pubkey_algo_t */ enum PubkeyAlgo { AlgoUnknown = 0, AlgoRSA = 1, AlgoRSA_E = 2, AlgoRSA_S = 3, AlgoELG_E = 16, AlgoDSA = 17, AlgoECC = 18, AlgoELG = 20, AlgoECDSA = 301, AlgoECDH = 302, AlgoEDDSA = 303, AlgoMax = 1 << 31 }; PubkeyAlgo publicKeyAlgorithm() const; /** @brief Get the public key algorithm name. This only works for the pre 2.1 algorithms for ECC NULL is returned. @returns a statically allocated string with the name of the public key algorithm, or NULL if that name is not known. */ const char *publicKeyAlgorithmAsString() const; /** @brief Same as publicKeyAlgorithmAsString but static. */ static const char *publicKeyAlgorithmAsString(PubkeyAlgo algo); /** @brief Get the key algo string like GnuPG 2.1 prints it. This returns combinations of size and algorithm. Like bp512 or rsa2048. Misnamed because publicKeyAlgorithmAsString already used the older pubkey_algo_name. Actually uses gpgme_pubkey_algo_string. @returns the key algorithm as string. Empty string on error. */ std::string algoName() const; unsigned int length() const; const char *cardSerialNumber() const; const char *keyGrip() const; private: shared_gpgme_key_t key; gpgme_sub_key_t subkey; }; // // class UserID // class GPGMEPP_EXPORT UserID { public: class Signature; UserID(); UserID(const shared_gpgme_key_t &key, gpgme_user_id_t uid); UserID(const shared_gpgme_key_t &key, unsigned int idx); const UserID &operator=(UserID other) { swap(other); return *this; } void swap(UserID &other) { using std::swap; swap(this->key, other.key); swap(this->uid, other.uid); } bool isNull() const { return !key || !uid; } Key parent() const; unsigned int numSignatures() const; Signature signature(unsigned int index) const; std::vector signatures() const; const char *id() const; const char *name() const; const char *email() const; const char *comment() const; enum Validity { Unknown = 0, Undefined = 1, Never = 2, Marginal = 3, Full = 4, Ultimate = 5 }; Validity validity() const; char validityAsString() const; bool isRevoked() const; bool isInvalid() const; /*! Shorthand for isNull || isRevoked || isInvalid */ bool isBad() const; /** TOFU info for this userid. * @returns The TOFU stats or a null TofuInfo. */ GpgME::TofuInfo tofuInfo() const; /*! Wrapper around gpgme_addrspec_from_uid. * * The input string should match the format of * a user id string. * * @returns a normalized mail address if found * or an empty string. */ static std::string addrSpecFromString(const char *uid); /*! Wrapper around gpgme_addrspec_from_uid. * * @returns a normalized mail address for this userid * or an empty string. */ std::string addrSpec() const; /*! Revoke the user id. * * Key needs update afterwards. * * @returns an error on error.*/ Error revoke(); /*! Get the origin of the key. * * @returns the Origin. */ Key::Origin origin() const; /*! Get the last update time. * * @returns the last update time. */ time_t lastUpdate() const; private: shared_gpgme_key_t key; gpgme_user_id_t uid; }; // // class UserID::Signature // class GPGMEPP_EXPORT UserID::Signature { public: typedef GPGMEPP_DEPRECATED GpgME::Notation Notation; Signature(); Signature(const shared_gpgme_key_t &key, gpgme_user_id_t uid, gpgme_key_sig_t sig); Signature(const shared_gpgme_key_t &key, gpgme_user_id_t uid, unsigned int idx); const Signature &operator=(Signature other) { swap(other); return *this; } void swap(Signature &other) { using std::swap; swap(this->key, other.key); swap(this->uid, other.uid); swap(this->sig, other.sig); } bool isNull() const { return !sig || !uid || !key ; } UserID parent() const; const char *signerKeyID() const; const char *algorithmAsString() const; unsigned int algorithm() const; time_t creationTime() const; time_t expirationTime() const; bool neverExpires() const; bool isRevokation() const; bool isInvalid() const; bool isExpired() const; bool isExportable() const; /*! Shorthand for isNull || isExpired || isInvalid */ bool isBad() const; const char *signerUserID() const; const char *signerName() const; const char *signerEmail() const; const char *signerComment() const; unsigned int certClass() const; enum Status { NoError = 0, SigExpired, KeyExpired, BadSignature, NoPublicKey, GeneralError }; Status status() const; std::string statusAsString() const; const char *policyURL() const; unsigned int numNotations() const; GpgME::Notation notation(unsigned int idx) const; std::vector notations() const; private: shared_gpgme_key_t key; gpgme_user_id_t uid; gpgme_key_sig_t sig; }; GPGMEPP_EXPORT std::ostream &operator<<(std::ostream &os, const UserID &uid); GPGMEPP_EXPORT std::ostream &operator<<(std::ostream &os, const Key &key); } // namespace GpgME GPGMEPP_MAKE_STD_SWAP_SPECIALIZATION(Key) GPGMEPP_MAKE_STD_SWAP_SPECIALIZATION(Subkey) GPGMEPP_MAKE_STD_SWAP_SPECIALIZATION(UserID) GPGMEPP_MAKE_STD_SWAP_SPECIALIZATION(UserID::Signature) GPGMEPP_MAKE_STRCMP(ByFingerprint, .primaryFingerprint()); GPGMEPP_MAKE_STRCMP(ByKeyID, .keyID()); GPGMEPP_MAKE_STRCMP(ByShortKeyID, .shortKeyID()); GPGMEPP_MAKE_STRCMP(ByChainID, .chainID()); #endif // __GPGMEPP_KEY_H__ diff --git a/lang/js/DemoExtension/maindemo.js b/lang/js/DemoExtension/maindemo.js index a9fdf28c..0c64860c 100644 --- a/lang/js/DemoExtension/maindemo.js +++ b/lang/js/DemoExtension/maindemo.js @@ -1,123 +1,123 @@ /* gpgme.js - Javascript integration for gpgme * Copyright (C) 2018 Bundesamt für Sicherheit in der Informationstechnik * * This file is part of GPGME. * * GPGME is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 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 * Lesser 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 . * SPDX-License-Identifier: LGPL-2.1+ * * Author(s): * Maximilian Krambach */ /* global document, Gpgmejs */ document.addEventListener('DOMContentLoaded', function () { Gpgmejs.init().then(function (gpgmejs){ document.getElementById('buttonencrypt').addEventListener('click', function (){ let data = document.getElementById('inputtext').value; let keyId = document.getElementById('pubkey').value; gpgmejs.encrypt({ data: data, publicKeys: keyId, armor: true }) .then(function (answer){ if (answer.data){ document.getElementById( 'answer').value = answer.data; } }, function (errormsg){ alert( errormsg.message); }); }); document.getElementById('buttondecrypt').addEventListener('click', function (){ let data = document.getElementById('inputtext').value; gpgmejs.decrypt({ data: data }).then( function (answer){ if (answer.data){ document.getElementById( 'answer').value = answer.data; } }, function (errormsg){ alert(errormsg.message); }); }); document.getElementById('getdefaultkey').addEventListener('click', function (){ gpgmejs.Keyring.getDefaultKey().then(function (answer){ document.getElementById('pubkey').value = answer.fingerprint; }, function (errormsg){ alert(errormsg.message); }); }); document.getElementById('signtext').addEventListener('click', function (){ let data = document.getElementById('inputtext').value; let keyId = document.getElementById('pubkey').value; gpgmejs.sign({ data: data, keys: keyId }).then( function (answer){ if (answer.data){ document.getElementById( 'answer').value = answer.data; } }, function (errormsg){ alert( errormsg.message); }); }); document.getElementById('verifytext').addEventListener('click', function (){ let data = document.getElementById('inputtext').value; gpgmejs.verify({ data: data }).then( function (answer){ let vals = ''; if (answer.all_valid === true){ vals = 'Success! '; } else { vals = 'Failure! '; } vals = vals + (answer.count - answer.failures) + 'of ' + answer.count + ' signature(s) were successfully ' + 'verified.\n\n' + answer.data; document.getElementById('answer').value = vals; }, function (errormsg){ alert( errormsg.message); }); }); document.getElementById('searchkey').addEventListener('click', function (){ let data = document.getElementById('inputtext').value; gpgmejs.Keyring.getKeys({ pattern: data, prepare_sync: true, search: true } ).then(function (keys){ if (keys.length === 1){ document.getElementById( 'pubkey').value = keys[0].fingerprint; } else if (keys.length > 1) { - alert('The pattern was not unambigious enough for a Key. ' + alert('The pattern was not unambiguous enough for a Key. ' + keys.length + ' Keys were found'); } else { alert('No keys found'); } }, function (errormsg){ alert( errormsg.message); }); }); }); }); diff --git a/lang/js/jsdoc_index.md b/lang/js/jsdoc_index.md index b7371ad5..e5cf2873 100644 --- a/lang/js/jsdoc_index.md +++ b/lang/js/jsdoc_index.md @@ -1,50 +1,50 @@ Using gpgme.js --------------- At first, make sure that the environment you want to use gpgme.js in has access and permissions for nativeMessaging, and gpgme-json installed. For details, see the README. The library itself is started via the {@link init} method. This will test the nativeMessaging connection, and then resolve into an Object offering the top level API: * [encrypt]{@link GpgME#encrypt} * [decrypt]{@link GpgME#decrypt} * [sign]{@link GpgME#sign} * [verify]{@link GpgME#verify} * [Keyring]{@link GPGME_Keyring} ``` gpgmejs.init() .then(function(GPGME) { // using GPGME }, function(error){ // error handling; }) ``` All methods that require communication with nativeMessaging are asynchronous, using Promises. Rejections will be instances of {@link GPGME_Error}. An exaeption are Keys, which can be initialized in a 'sync' mode, allowing them to be cached and used synchronously until manually refreshed. Keyring and Keys ---------------- The gnupg keys can be accessed via the [Keyring]{@link GPGME_Keyring}. The Keyring offers the methods for accessing information on all Keys known to gnupg. **Due to security constraints, the javascript-binding currently only offers limited support for secret-Key interaction.** -The existance of secret Keys is not secret, and those secret Keys can be used +The existence of secret Keys is not secret, and those secret Keys can be used for signing, but Operations that may expose, modify or delete secret Keys are not supported. * [getKeysArmored]{@link GPGME_Keyring#getKeysArmored} * [getKeys]{@link GPGME_Keyring#getKeys} * [getDefaultKey]{@link GPGME_Keyring#getDefaultKey} * [generateKey]{@link GPGME_Keyring#generateKey} * [deleteKey]{@link GPGME_Keyring#deleteKey} diff --git a/lang/js/src/Helpers.js b/lang/js/src/Helpers.js index f472b234..0b5ab7e8 100644 --- a/lang/js/src/Helpers.js +++ b/lang/js/src/Helpers.js @@ -1,219 +1,219 @@ /* gpgme.js - Javascript integration for gpgme * Copyright (C) 2018 Bundesamt für Sicherheit in der Informationstechnik * * This file is part of GPGME. * * GPGME is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 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 * Lesser 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 . * SPDX-License-Identifier: LGPL-2.1+ * * Author(s): * Maximilian Krambach */ import { gpgme_error } from './Errors'; /** * Helper function that tries to return an array of fingerprints, either from * input fingerprints or from Key objects (openpgp Keys or GPGME_Keys are both * accepted). * * @param {Object | Object[] | String | String[] } input * @returns {String[]} Array of fingerprints, or an empty array */ export function toKeyIdArray (input){ if (!input){ return []; } if (!Array.isArray(input)){ input = [input]; } let result = []; for (let i=0; i < input.length; i++){ if (typeof (input[i]) === 'string'){ if (isFingerprint(input[i]) === true){ result.push(input[i]); } else { // MSG_NOT_A_FPR is just a console warning if warning enabled // in src/Errors.js gpgme_error('MSG_NOT_A_FPR'); } } else if (typeof (input[i]) === 'object'){ let fpr = ''; if (input[i].fingerprint !== undefined){ fpr = input[i].fingerprint; } else if (input[i].hasOwnProperty('primaryKey') && input[i].primaryKey.hasOwnProperty('getFingerprint')){ fpr = input[i].primaryKey.getFingerprint(); } if (isFingerprint(fpr) === true){ result.push(fpr); } else { gpgme_error('MSG_NOT_A_FPR'); } } else { return gpgme_error('PARAM_WRONG'); } } if (result.length === 0){ return []; } else { return result; } } /** * Check if values are valid hexadecimal values of a specified length * @param {String} key input value. * @param {int} len the expected length of the value * @returns {Boolean} true if value passes test * @private */ function hextest (key, len){ if (!key || typeof (key) !== 'string'){ return false; } if (key.length !== len){ return false; } let regexp= /^[0-9a-fA-F]*$/i; return regexp.test(key); } /** * Checks if the input is a valid Fingerprint * (Hex string with a length of 40 characters) * @param {String} value to check * @returns {Boolean} true if value passes test */ export function isFingerprint (value){ return hextest(value, 40); } /** * check if the input is a valid gnupg long ID (Hex string with a length of 16 * characters) * @param {String} value to check * @returns {Boolean} true if value passes test */ export function isLongId (value){ return hextest(value, 16); } /** * Recursively decodes input (utf8) to output (utf-16; javascript) strings. * @param {Object | Array | String} property * @private */ export function decode (property){ if (typeof property === 'string'){ try { return decodeURIComponent(escape(unescape(property))); } catch (error){ if (error instanceof URIError) { return property; } } } else if (Array.isArray(property)){ let res = []; for (let arr=0; arr < property.length; arr++){ res.push(decode(property[arr])); } return res; } else if (typeof property === 'object'){ const keys = Object.keys(property); if (keys.length){ let res = {}; for (let k=0; k < keys.length; k++ ){ res[keys[k]] = decode(property[keys[k]]); } return res; } return property; } return property; } /** * Turns a base64 encoded string into an uint8 array * adapted from https://gist.github.com/borismus/1032746 * @param {String} base64 encoded String * @returns {Uint8Array} * @private */ export function atobArray (base64) { if (typeof (base64) !== 'string'){ throw gpgme_error('DECODE_FAIL'); } const raw = window.atob(base64); const rawLength = raw.length; let array = new Uint8Array(new ArrayBuffer(rawLength)); for (let i = 0; i < rawLength; i++) { array[i] = raw.charCodeAt(i); } return array; } /** * Turns a Uint8Array into an utf8-String *
  * Taken and slightly adapted from
  *  https://www.onicos.com/staff/iz/amuse/javascript/expert/utf.txt
  * (original header:
- *   utf.js - UTF-8 <=> UTF-16 convertion
+ *   utf.js - UTF-8 <=> UTF-16 conversion
  *
  *   Copyright (C) 1999 Masanao Izumo 
  *   Version: 1.0
  *   LastModified: Dec 25 1999
  *   This library is free.  You can redistribute it and/or modify it.
  *  )
  * 
* @param {*} array Uint8Array * @returns {String} * @private */ export function Utf8ArrayToStr (array) { let out, i, len, c, char2, char3; out = ''; len = array.length; i = 0; if (array instanceof Uint8Array === false){ throw gpgme_error('DECODE_FAIL'); } while (i < len) { c = array[i++]; switch (c >> 4) { case 0: case 1: case 2: case 3: case 4: case 5: case 6: case 7: // 0xxxxxxx out += String.fromCharCode(c); break; case 12: case 13: // 110x xxxx 10xx xxxx char2 = array[i++]; out += String.fromCharCode(((c & 0x1F) << 6) | (char2 & 0x3F)); break; case 14: // 1110 xxxx 10xx xxxx 10xx xxxx char2 = array[i++]; char3 = array[i++]; out += String.fromCharCode(((c & 0x0F) << 12) | ((char2 & 0x3F) << 6) | ((char3 & 0x3F) << 0)); break; default: break; } } return out; } diff --git a/lang/js/src/Key.js b/lang/js/src/Key.js index f5ee9656..a3f52044 100644 --- a/lang/js/src/Key.js +++ b/lang/js/src/Key.js @@ -1,711 +1,711 @@ /* gpgme.js - Javascript integration for gpgme * Copyright (C) 2018 Bundesamt für Sicherheit in der Informationstechnik * * This file is part of GPGME. * * GPGME is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 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 * Lesser 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 . * SPDX-License-Identifier: LGPL-2.1+ * * Author(s): * Maximilian Krambach */ import { isFingerprint, isLongId } from './Helpers'; import { gpgme_error } from './Errors'; import { createMessage } from './Message'; /** * Validates the given fingerprint and creates a new {@link GPGME_Key} * @param {String} fingerprint * @param {Boolean} async If True, Key properties (except fingerprint) will be * queried from gnupg on each call, making the operation up-to-date, the * answers will be Promises, and the performance will likely suffer * @param {Object} data additional initial properties this Key will have. Needs * a full object as delivered by gpgme-json * @returns {Object} The verified and updated data */ export function createKey (fingerprint, async = false, data){ if (!isFingerprint(fingerprint) || typeof (async) !== 'boolean'){ throw gpgme_error('PARAM_WRONG'); } if (data !== undefined){ data = validateKeyData(fingerprint, data); } if (data instanceof Error){ throw gpgme_error('KEY_INVALID'); } else { return new GPGME_Key(fingerprint, async, data); } } /** * Represents the Keys as stored in the gnupg backend. A key is defined by a * fingerprint. * A key cannot be directly created via the new operator, please use * {@link createKey} instead. * A GPGME_Key object allows to query almost all information defined in gpgme * Keys. It offers two modes, async: true/false. In async mode, Key properties * with the exception of the fingerprint will be queried from gnupg on each * call, making the operation up-to-date, the answers will be Promises, and * the performance will likely suffer. In Sync modes, all information except * for the armored Key export will be cached and can be refreshed by * [refreshKey]{@link GPGME_Key#refreshKey}. * *
  * see also:
  *      {@link GPGME_UserId} user Id objects
  *      {@link GPGME_Subkey} subKey objects
  * 
* For other Key properteis, refer to {@link validKeyProperties}, * and to the [gpgme documentation]{@link https://www.gnupg.org/documentation/manuals/gpgme/Key-objects.html} * for meanings and further details. * * @class */ class GPGME_Key { constructor (fingerprint, async, data){ /** * @property {Boolean} _async If true, the Key was initialized without * cached data */ this._async = async; this._data = { fingerprint: fingerprint.toUpperCase() }; if (data !== undefined && data.fingerprint.toUpperCase() === this._data.fingerprint ) { this._data = data; } } /** * Query any property of the Key listed in {@link validKeyProperties} - * @param {String} property property to be retreived + * @param {String} property property to be retrieved * @returns {Boolean| String | Date | Array | Object} * @returns {Promise} (if in async * mode) *
      * Returns the value of the property requested. If the Key is set to async,
      * the value will be fetched from gnupg and resolved as a Promise. If Key
      * is not  async, the armored property is not available (it can still be
      * retrieved asynchronously by [getArmor]{@link GPGME_Key#getArmor})
      */
     get (property) {
         if (this._async === true) {
             switch (property){
             case 'armored':
                 return this.getArmor();
             case 'hasSecret':
                 return this.getGnupgSecretState();
             default:
                 return getGnupgState(this.fingerprint, property);
             }
         } else {
             if (property === 'armored') {
                 throw gpgme_error('KEY_ASYNC_ONLY');
             }
             // eslint-disable-next-line no-use-before-define
             if (!validKeyProperties.hasOwnProperty(property)){
                 throw gpgme_error('PARAM_WRONG');
             } else {
                 return (this._data[property]);
             }
         }
     }
 
     /**
      * Reloads the Key information from gnupg. This is only useful if the Key
      * use the GPGME_Keys cached. Note that this is a performance hungry
      * operation. If you desire more than a few refreshs, it may be
      * advisable to run [Keyring.getKeys]{@link Keyring#getKeys} instead.
      * @returns {Promise}
      * @async
      */
     refreshKey () {
         let me = this;
         return new Promise(function (resolve, reject) {
             if (!me._data.fingerprint){
                 reject(gpgme_error('KEY_INVALID'));
             }
             let msg = createMessage('keylist');
             msg.setParameter('sigs', true);
             msg.setParameter('keys', me._data.fingerprint);
             msg.post().then(function (result){
                 if (result.keys.length === 1){
                     const newdata = validateKeyData(
                         me._data.fingerprint, result.keys[0]);
                     if (newdata instanceof Error){
                         reject(gpgme_error('KEY_INVALID'));
                     } else {
                         me._data = newdata;
                         me.getGnupgSecretState().then(function (){
                             me.getArmor().then(function (){
                                 resolve(me);
                             }, function (error){
                                 reject(error);
                             });
                         }, function (error){
                             reject(error);
                         });
                     }
                 } else {
                     reject(gpgme_error('KEY_NOKEY'));
                 }
             }, function (error) {
                 reject(gpgme_error('GNUPG_ERROR'), error);
             });
         });
     }
 
     /**
      * Query the armored block of the Key directly from gnupg. Please note
      * that this will not get you any export of the secret/private parts of
      * a Key
      * @returns {Promise}
      * @async
      */
     getArmor () {
         const me = this;
         return new Promise(function (resolve, reject) {
             if (!me._data.fingerprint){
                 reject(gpgme_error('KEY_INVALID'));
             }
             let msg = createMessage('export');
             msg.setParameter('armor', true);
             msg.setParameter('keys', me._data.fingerprint);
             msg.post().then(function (result){
                 resolve(result.data);
             }, function (error){
                 reject(error);
             });
         });
     }
 
     /**
      * Find out if the Key is part of a Key pair including public and
      * private key(s). If you want this information about more than a few
      * Keys in synchronous mode, it may be advisable to run
      * [Keyring.getKeys]{@link Keyring#getKeys} instead, as it performs faster
      * in bulk querying.
      * @returns {Promise} True if a private Key is available in the
      * gnupg Keyring.
      * @async
      */
     getGnupgSecretState (){
         const me = this;
         return new Promise(function (resolve, reject) {
             if (!me._data.fingerprint){
                 reject(gpgme_error('KEY_INVALID'));
             } else {
                 let msg = createMessage('keylist');
                 msg.setParameter('keys', me._data.fingerprint);
                 msg.setParameter('secret', true);
                 msg.post().then(function (result){
                     me._data.hasSecret = null;
                     if (
                         result.keys &&
                         result.keys.length === 1 &&
                         result.keys[0].secret === true
                     ) {
                         me._data.hasSecret = true;
                         resolve(true);
                     } else {
                         me._data.hasSecret = false;
                         resolve(false);
                     }
                 }, function (error){
                     reject(error);
                 });
             }
         });
     }
 
     /**
      * Deletes the (public) Key from the GPG Keyring. Note that a deletion
      * of a secret key is not supported by the native backend, and gnupg will
      * refuse to delete a Key if there is still a secret/private Key present
      * to that public Key
      * @returns {Promise} Success if key was deleted.
      */
     delete (){
         const me = this;
         return new Promise(function (resolve, reject){
             if (!me._data.fingerprint){
                 reject(gpgme_error('KEY_INVALID'));
             }
             let msg = createMessage('delete');
             msg.setParameter('key', me._data.fingerprint);
             msg.post().then(function (result){
                 resolve(result.success);
             }, function (error){
                 reject(error);
             });
         });
     }
 
     /**
      * @returns {String} The fingerprint defining this Key. Convenience getter
      */
     get fingerprint (){
         return this._data.fingerprint;
     }
 }
 
 /**
  * Representing a subkey of a Key. See {@link validSubKeyProperties} for
  * possible properties.
  * @class
  * @protected
  */
 class GPGME_Subkey {
 
     /**
      * Initializes with the json data sent by gpgme-json
      * @param {Object} data
      * @private
      */
     constructor (data){
         this._data = {};
         let keys = Object.keys(data);
         const me = this;
 
         /**
          * Validates a subkey property against {@link validSubKeyProperties} and
          * sets it if validation is successful
          * @param {String} property
          * @param {*} value
          * @param private
          */
         const setProperty = function (property, value){
             // eslint-disable-next-line no-use-before-define
             if (validSubKeyProperties.hasOwnProperty(property)){
                 // eslint-disable-next-line no-use-before-define
                 if (validSubKeyProperties[property](value) === true) {
                     if (property === 'timestamp' || property === 'expires'){
                         me._data[property] = new Date(value * 1000);
                     } else {
                         me._data[property] = value;
                     }
                 }
             }
         };
         for (let i=0; i< keys.length; i++) {
             setProperty(keys[i], data[keys[i]]);
         }
     }
 
     /**
      * Fetches any information about this subkey
      * @param {String} property Information to request
      * @returns {String | Number | Date}
      */
     get (property) {
         if (this._data.hasOwnProperty(property)){
             return (this._data[property]);
         }
     }
 
 }
 
 /**
  * Representing user attributes associated with a Key or subkey. See
  * {@link validUserIdProperties} for possible properties.
  * @class
  * @protected
  */
 class GPGME_UserId {
 
     /**
      * Initializes with the json data sent by gpgme-json
      * @param {Object} data
      * @private
      */
     constructor (data){
         this._data = {};
         const me = this;
         let keys = Object.keys(data);
         const setProperty = function (property, value){
             // eslint-disable-next-line no-use-before-define
             if (validUserIdProperties.hasOwnProperty(property)){
                 // eslint-disable-next-line no-use-before-define
                 if (validUserIdProperties[property](value) === true) {
                     if (property === 'last_update'){
                         me._data[property] = new Date(value*1000);
                     } else {
                         me._data[property] = value;
                     }
                 }
             }
         };
         for (let i=0; i< keys.length; i++) {
             setProperty(keys[i], data[keys[i]]);
         }
     }
 
     /**
      * Fetches information about the user
      * @param {String} property Information to request
      * @returns {String | Number}
      */
     get (property) {
         if (this._data.hasOwnProperty(property)){
             return (this._data[property]);
         }
     }
 
 }
 
 /**
  * Validation definition for userIds. Each valid userId property is represented
  * as a key- Value pair, with their value being a validation function to check
  * against
  * @protected
  * @const
  */
 const validUserIdProperties = {
     'revoked': function (value){
         return typeof (value) === 'boolean';
     },
     'invalid':  function (value){
         return typeof (value) === 'boolean';
     },
     'uid': function (value){
         if (typeof (value) === 'string' || value === ''){
             return true;
         }
         return false;
     },
     'validity': function (value){
         if (typeof (value) === 'string'){
             return true;
         }
         return false;
     },
     'name': function (value){
         if (typeof (value) === 'string' || value === ''){
             return true;
         }
         return false;
     },
     'email': function (value){
         if (typeof (value) === 'string' || value === ''){
             return true;
         }
         return false;
     },
     'address': function (value){
         if (typeof (value) === 'string' || value === ''){
             return true;
         }
         return false;
     },
     'comment': function (value){
         if (typeof (value) === 'string' || value === ''){
             return true;
         }
         return false;
     },
     'origin':  function (value){
         return Number.isInteger(value);
     },
     'last_update':  function (value){
         return Number.isInteger(value);
     }
 };
 
 /**
  * Validation definition for subKeys. Each valid userId property is represented
  * as a key-value pair, with the value being a validation function
  * @protected
  * @const
  */
 const validSubKeyProperties = {
     'invalid': function (value){
         return typeof (value) === 'boolean';
     },
     'can_encrypt': function (value){
         return typeof (value) === 'boolean';
     },
     'can_sign': function (value){
         return typeof (value) === 'boolean';
     },
     'can_certify':  function (value){
         return typeof (value) === 'boolean';
     },
     'can_authenticate':  function (value){
         return typeof (value) === 'boolean';
     },
     'secret': function (value){
         return typeof (value) === 'boolean';
     },
     'is_qualified': function (value){
         return typeof (value) === 'boolean';
     },
     'is_cardkey':  function (value){
         return typeof (value) === 'boolean';
     },
     'is_de_vs':  function (value){
         return typeof (value) === 'boolean';
     },
     'pubkey_algo_name': function (value){
         return typeof (value) === 'string';
         // TODO: check against list of known?['']
     },
     'pubkey_algo_string': function (value){
         return typeof (value) === 'string';
         // TODO: check against list of known?['']
     },
     'keyid': function (value){
         return isLongId(value);
     },
     'pubkey_algo': function (value) {
         return (Number.isInteger(value) && value >= 0);
     },
     'length': function (value){
         return (Number.isInteger(value) && value > 0);
     },
     'timestamp': function (value){
         return (Number.isInteger(value) && value > 0);
     },
     'expires': function (value){
         return (Number.isInteger(value) && value > 0);
     }
 };
 
 /**
  * Validation definition for Keys. Each valid Key property is represented
  * as a key-value pair, with their value being a validation function. For
  * details on the meanings, please refer to the gpgme documentation
  * https://www.gnupg.org/documentation/manuals/gpgme/Key-objects.html#Key-objects
  * @param {String} fingerprint
  * @param {Boolean} revoked
  * @param {Boolean} expired
  * @param {Boolean} disabled
  * @param {Boolean} invalid
  * @param {Boolean} can_encrypt
  * @param {Boolean} can_sign
  * @param {Boolean} can_certify
  * @param {Boolean} can_authenticate
  * @param {Boolean} secret
  * @param {Boolean}is_qualified
  * @param {String} protocol
  * @param {String} issuer_serial
  * @param {String} issuer_name
  * @param {Boolean} chain_id
  * @param {String} owner_trust
  * @param {Date} last_update
  * @param {String} origin
  * @param {Array} subkeys
  * @param {Array} userids
  * @param {Array} tofu
  * @param {Boolean} hasSecret
  * @protected
  * @const
  */
 const validKeyProperties = {
     'fingerprint': function (value){
         return isFingerprint(value);
     },
     'revoked': function (value){
         return typeof (value) === 'boolean';
     },
     'expired': function (value){
         return typeof (value) === 'boolean';
     },
     'disabled': function (value){
         return typeof (value) === 'boolean';
     },
     'invalid': function (value){
         return typeof (value) === 'boolean';
     },
     'can_encrypt': function (value){
         return typeof (value) === 'boolean';
     },
     'can_sign': function (value){
         return typeof (value) === 'boolean';
     },
     'can_certify': function (value){
         return typeof (value) === 'boolean';
     },
     'can_authenticate': function (value){
         return typeof (value) === 'boolean';
     },
     'secret': function (value){
         return typeof (value) === 'boolean';
     },
     'is_qualified': function (value){
         return typeof (value) === 'boolean';
     },
     'protocol': function (value){
         return typeof (value) === 'string';
         // TODO check for implemented ones
     },
     'issuer_serial': function (value){
         return typeof (value) === 'string';
     },
     'issuer_name': function (value){
         return typeof (value) === 'string';
     },
     'chain_id': function (value){
         return typeof (value) === 'string';
     },
     'owner_trust': function (value){
         return typeof (value) === 'string';
     },
     'last_update': function (value){
         return (Number.isInteger(value));
         // TODO undefined/null possible?
     },
     'origin': function (value){
         return (Number.isInteger(value));
     },
     'subkeys': function (value){
         return (Array.isArray(value));
     },
     'userids': function (value){
         return (Array.isArray(value));
     },
     'tofu': function (value){
         return (Array.isArray(value));
     },
     'hasSecret': function (value){
         return typeof (value) === 'boolean';
     }
 
 };
 
 /**
 * sets the Key data in bulk. It can only be used from inside a Key, either
 * during construction or on a refresh callback.
 * @param {Object} key the original internal key data.
 * @param {Object} data Bulk set the data for this key, with an Object structure
 * as sent by gpgme-json.
 * @returns {Object|GPGME_Error} the changed data after values have been set,
 * an error if something went wrong.
 * @private
 */
 function validateKeyData (fingerprint, data){
     const key = {};
     if (!fingerprint || typeof (data) !== 'object' || !data.fingerprint
      || fingerprint !== data.fingerprint.toUpperCase()
     ){
         return gpgme_error('KEY_INVALID');
     }
     let props = Object.keys(data);
     for (let i=0; i< props.length; i++){
         if (!validKeyProperties.hasOwnProperty(props[i])){
             return gpgme_error('KEY_INVALID');
         }
         // running the defined validation function
         if (validKeyProperties[props[i]](data[props[i]]) !== true ){
             return gpgme_error('KEY_INVALID');
         }
         switch (props[i]){
         case 'subkeys':
             key.subkeys = [];
             for (let i=0; i< data.subkeys.length; i++) {
                 key.subkeys.push(
                     new GPGME_Subkey(data.subkeys[i]));
             }
             break;
         case 'userids':
             key.userids = [];
             for (let i=0; i< data.userids.length; i++) {
                 key.userids.push(
                     new GPGME_UserId(data.userids[i]));
             }
             break;
         case 'last_update':
             key[props[i]] = new Date( data[props[i]] * 1000 );
             break;
         default:
             key[props[i]] = data[props[i]];
         }
     }
     return key;
 }
 
 /**
  * Fetches and sets properties from gnupg
  * @param {String} fingerprint
  * @param {String} property to search for.
  * @private
  * @async
  */
 function getGnupgState (fingerprint, property){
     return new Promise(function (resolve, reject) {
         if (!isFingerprint(fingerprint)) {
             reject(gpgme_error('KEY_INVALID'));
         } else {
             let msg = createMessage('keylist');
             msg.setParameter('keys', fingerprint);
             msg.post().then(function (res){
                 if (!res.keys || res.keys.length !== 1){
                     reject(gpgme_error('KEY_INVALID'));
                 } else {
                     const key = res.keys[0];
                     let result;
                     switch (property){
                     case 'subkeys':
                         result = [];
                         if (key.subkeys.length){
                             for (let i=0; i < key.subkeys.length; i++) {
                                 result.push(
                                     new GPGME_Subkey(key.subkeys[i]));
                             }
                         }
                         resolve(result);
                         break;
                     case 'userids':
                         result = [];
                         if (key.userids.length){
                             for (let i=0; i< key.userids.length; i++) {
                                 result.push(
                                     new GPGME_UserId(key.userids[i]));
                             }
                         }
                         resolve(result);
                         break;
                     case 'last_update':
                         if (key.last_update === undefined){
                             reject(gpgme_error('CONN_UNEXPECTED_ANSWER'));
                         } else if (key.last_update !== null){
                             resolve(new Date( key.last_update * 1000));
                         } else {
                             resolve(null);
                         }
                         break;
                     default:
                         if (!validKeyProperties.hasOwnProperty(property)){
                             reject(gpgme_error('PARAM_WRONG'));
                         } else {
                             if (key.hasOwnProperty(property)){
                                 resolve(key[property]);
                             } else {
                                 reject(gpgme_error(
                                     'CONN_UNEXPECTED_ANSWER'));
                             }
                         }
                         break;
                     }
                 }
             }, function (error){
                 reject(gpgme_error(error));
             });
         }
     });
-}
\ No newline at end of file
+}
diff --git a/lang/js/src/Keyring.js b/lang/js/src/Keyring.js
index 850f9f18..9f313577 100644
--- a/lang/js/src/Keyring.js
+++ b/lang/js/src/Keyring.js
@@ -1,439 +1,439 @@
 /* gpgme.js - Javascript integration for gpgme
  * Copyright (C) 2018 Bundesamt für Sicherheit in der Informationstechnik
  *
  * This file is part of GPGME.
  *
  * GPGME is free software; you can redistribute it and/or modify it
  * under the terms of the GNU Lesser General Public License as
  * published by the Free Software Foundation; either version 2.1 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
  * Lesser 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 .
  * SPDX-License-Identifier: LGPL-2.1+
  *
  * Author(s):
  *     Maximilian Krambach 
  */
 
 
 import { createMessage } from './Message';
 import { createKey } from './Key';
 import { isFingerprint } from './Helpers';
 import { gpgme_error } from './Errors';
 
 /**
  * This class offers access to the gnupg keyring
  */
 export class GPGME_Keyring {
 
     /**
      * Queries Keys (all Keys or a subset) from gnupg.
      *
      * @param {Object} options:
      * @param {String | Array} options.pattern (optional) A pattern to
      * search for in userIds or KeyIds.
      * @param {Boolean} options.prepare_sync (optional) if set to true, most
      * data (with the exception of armored Key blocks) will be cached for the
      * Keys. This enables direct, synchronous use of these properties for
      * all keys. It does not check for changes on the backend. The cached
      * information can be updated with the {@link Key.refresh} method.
      * @param {Boolean} options.search (optional) retrieve Keys from external
      * servers with the method(s) defined in gnupg (e.g. WKD/HKP lookup)
      * @returns {Promise}
      * @static
      * @async
      */
     getKeys ({ pattern, prepare_sync = false, search = false } = {}){
         if (typeof arguments[0] !== 'object') {
             return Promise.reject(gpgme_error('PARAM_WRONG'));
         }
         if (arguments.length && typeof arguments[0] !== 'object') {
             return Promise.reject(gpgme_error('PARAM_WRONG'));
         }
         return new Promise(function (resolve, reject) {
             let msg = createMessage('keylist');
             if (pattern) {
                 msg.setParameter('keys', pattern);
             }
             msg.setParameter('sigs', true);
             if (search === true){
                 msg.setParameter('locate', true);
             }
             msg.post().then(function (result){
                 let resultset = [];
                 if (result.keys.length === 0){
                     resolve([]);
                 } else {
                     let secondrequest;
                     if (prepare_sync === true) {
                         secondrequest = function () {
                             let msg2 = createMessage('keylist');
                             if (pattern){
                                 msg2.setParameter('keys', pattern);
                             }
                             msg2.setParameter('secret', true);
                             return msg2.post();
                         };
                     } else {
                         secondrequest = function () {
                             return Promise.resolve(true);
                         };
                     }
                     secondrequest().then(function (answer) {
                         for (let i=0; i < result.keys.length; i++){
                             if (prepare_sync === true){
                                 if (answer && answer.keys) {
                                     for (let j=0;
                                         j < answer.keys.length; j++ ){
                                         const a = answer.keys[j];
                                         const b = result.keys[i];
                                         if (
                                             a.fingerprint === b.fingerprint
                                         ) {
                                             if (a.secret === true){
                                                 b.hasSecret = true;
                                             } else {
                                                 b.hasSecret = false;
                                             }
                                             break;
                                         }
                                     }
                                 }
                             }
                             let k = createKey(result.keys[i].fingerprint,
                                 !prepare_sync, result.keys[i]);
                             resultset.push(k);
                         }
                         resolve(resultset);
                     }, function (error){
                         reject(error);
                     });
                 }
             });
         });
     }
 
     /**
      * @typedef {Object} exportResult The result of a getKeysArmored
      * operation.
      * @property {String} armored The public Key(s) as armored block. Note
      * that the result is one armored block, and not a block per key.
      * @property {Array} secret_fprs (optional) list of
      * fingerprints for those Keys that also have a secret Key available in
      * gnupg. The secret key will not be exported, but the fingerprint can
      * be used in operations needing a secret key.
      */
 
     /**
      * Fetches the armored public Key blocks for all Keys matching the
      * pattern (if no pattern is given, fetches all keys known to gnupg).
      * @param {Object} options (optional)
      * @param {String|Array} options.pattern The Pattern to
      * search for
      * @param {Boolean} options.with_secret_fpr also return a list of
      * fingerprints for the keys that have a secret key available
      * @returns {Promise} Object containing the
      * armored Key(s) and additional information.
      * @static
      * @async
      */
     getKeysArmored ({ pattern, with_secret_fpr }) {
         return new Promise(function (resolve, reject) {
             let msg = createMessage('export');
             msg.setParameter('armor', true);
             if (with_secret_fpr === true) {
                 msg.setParameter('with-sec-fprs', true);
             }
             if (pattern){
                 msg.setParameter('keys', pattern);
             }
             msg.post().then(function (answer){
                 const result = { armored: answer.data };
                 if (with_secret_fpr === true){
                     if (answer.hasOwnProperty('sec-fprs')){
                         result.secret_fprs = answer['sec-fprs'];
                     } else {
                         result.secret_fprs = [];
                     }
                 }
                 resolve(result);
             }, function (error){
                 reject(error);
             });
         });
     }
 
     /**
      * Returns the Key used by default in gnupg.
      * (a.k.a. 'primary Key or 'main key').
      * It looks up the gpg configuration if set, or the first key that
      * contains a secret key.
      *
      * @returns {Promise}
      * @async
      * @static
      */
     getDefaultKey (prepare_sync = false) {
         let me = this;
         return new Promise(function (resolve, reject){
             let msg = createMessage('config_opt');
             msg.setParameter('component', 'gpg');
             msg.setParameter('option', 'default-key');
             msg.post().then(function (resp){
                 if (resp.option !== undefined
                     && resp.option.hasOwnProperty('value')
                     && resp.option.value.length === 1
                     && resp.option.value[0].hasOwnProperty('string')
                     && typeof (resp.option.value[0].string) === 'string'){
                     me.getKeys({ pattern: resp.option.value[0].string,
                         prepare_sync: true }).then(
                         function (keys){
                             if (keys.length === 1){
                                 resolve(keys[0]);
                             } else {
                                 reject(gpgme_error('KEY_NO_DEFAULT'));
                             }
                         }, function (error){
                             reject(error);
                         });
                 } else {
                     let msg = createMessage('keylist');
                     msg.setParameter('secret', true);
                     msg.post().then(function (result){
                         if (result.keys.length === 0){
                             reject(gpgme_error('KEY_NO_DEFAULT'));
                         } else {
                             for (let i=0; i< result.keys.length; i++ ) {
                                 if (
                                     result.keys[i].invalid === false &&
                                     result.keys[i].expired === false &&
                                     result.keys[i].revoked === false &&
                                     result.keys[i].can_sign === true
                                 ) {
                                     let k = createKey(
                                         result.keys[i].fingerprint,
                                         !prepare_sync,
                                         result.keys[i]);
                                     resolve(k);
                                     break;
                                 } else if (i === result.keys.length - 1){
                                     reject(gpgme_error('KEY_NO_DEFAULT'));
                                 }
                             }
                         }
                     }, function (error){
                         reject(error);
                     });
                 }
             }, function (error){
                 reject(error);
             });
         });
     }
 
     /**
      * @typedef {Object} importResult The result of a Key update
      * @property {Object} summary Numerical summary of the result. See the
      * feedbackValues variable for available Keys values and the gnupg
      * documentation.
      * https://www.gnupg.org/documentation/manuals/gpgme/Importing-Keys.html
      * for details on their meaning.
      * @property {Array} Keys Array of Object containing
      * GPGME_Keys with additional import information
      *
      */
 
     /**
      * @typedef {Object} importedKeyResult
      * @property {GPGME_Key} key The resulting key
      * @property {String} status:
      *  'nochange' if the Key was not changed,
      *  'newkey' if the Key was imported in gpg, and did not exist
      *    previously,
      *  'change' if the key existed, but details were updated. For details,
      *    Key.changes is available.
      * @property {Boolean} changes.userId Changes in userIds
      * @property {Boolean} changes.signature Changes in signatures
      * @property {Boolean} changes.subkey Changes in subkeys
      */
 
     /**
      * Import an armored Key block into gnupg. Note that this currently
      * will not succeed on private Key blocks.
      * @param {String} armored Armored Key block of the Key(s) to be
      * imported into gnupg
      * @param {Boolean} prepare_sync prepare the keys for synched use
      * (see {@link getKeys}).
      * @returns {Promise} A summary and Keys considered.
      * @async
      * @static
      */
     importKey (armored, prepare_sync) {
         let feedbackValues = ['considered', 'no_user_id', 'imported',
             'imported_rsa', 'unchanged', 'new_user_ids', 'new_sub_keys',
             'new_signatures', 'new_revocations', 'secret_read',
             'secret_imported', 'secret_unchanged', 'skipped_new_keys',
             'not_imported', 'skipped_v3_keys'];
         if (!armored || typeof (armored) !== 'string'){
             return Promise.reject(gpgme_error('PARAM_WRONG'));
         }
         let me = this;
         return new Promise(function (resolve, reject){
             let msg = createMessage('import');
             msg.setParameter('data', armored);
             msg.post().then(function (response){
                 let infos = {};
                 let fprs = [];
                 let summary = {};
                 for (let i=0; i < feedbackValues.length; i++ ){
                     summary[feedbackValues[i]] =
                         response.result[feedbackValues[i]];
                 }
                 if (!response.result.hasOwnProperty('imports') ||
                     response.result.imports.length === 0
                 ){
                     resolve({ Keys:[],summary: summary });
                     return;
                 }
                 for (let res=0; res}
      * @async
      * @static
      */
     deleteKey (fingerprint){
         if (isFingerprint(fingerprint) === true) {
             let key = createKey(fingerprint);
             return key.delete();
         } else {
             return Promise.reject(gpgme_error('KEY_INVALID'));
         }
     }
 
     /**
      * Generates a new Key pair directly in gpg, and returns a GPGME_Key
      * representing that Key. Please note that due to security concerns,
      * secret Keys can not be deleted or exported from inside gpgme.js.
      * @param {Object} options
      * @param {String} option.userId The user Id, e.g. 'Foo Bar '
      * @param {String} option.algo (optional) algorithm (and optionally key
      * size) to be used. See {@link supportedKeyAlgos} below for supported
-     * values. If ommitted, 'default' is used.
+     * values. If omitted, 'default' is used.
      * @param {Number} option.expires (optional) Expiration time in seconds
      * from now. If not set or set to 0, expiration will be 'never'
      *
      * @return {Promise}
      * @async
      */
     generateKey ({ userId, algo = 'default', expires= 0 } = {}){
         if (typeof userId !== 'string'
             // eslint-disable-next-line no-use-before-define
             || (algo && supportedKeyAlgos.indexOf(algo) < 0 )
             || (!Number.isInteger(expires) || expires < 0 )
         ){
             return Promise.reject(gpgme_error('PARAM_WRONG'));
         }
         // eslint-disable-next-line no-use-before-define
         let me = this;
         return new Promise(function (resolve, reject){
             let msg = createMessage('createkey');
             msg.setParameter('userid', userId);
             msg.setParameter('algo', algo);
             msg.setParameter('expires', expires);
             msg.post().then(function (response){
                 me.getKeys({
                     pattern: response.fingerprint,
                     prepare_sync: true
                 }).then(function (result){
                     resolve(result);
                 }, function (error){
                     reject(error);
                 });
             }, function (error) {
                 reject(error);
             });
         });
     }
 }
 
 
 /**
  * List of algorithms supported for key generation. Please refer to the gnupg
  * documentation for details
  */
 const supportedKeyAlgos = [
     'default', 'future-default',
     'rsa', 'rsa2048', 'rsa3072', 'rsa4096',
     'dsa', 'dsa2048', 'dsa3072', 'dsa4096',
     'elg', 'elg2048', 'elg3072', 'elg4096',
     'ed25519',
     'cv25519',
     'brainpoolP256r1', 'brainpoolP384r1', 'brainpoolP512r1',
     'NIST P-256', 'NIST P-384', 'NIST P-521'
 ];
diff --git a/lang/python/doc/meta/old-commits.log b/lang/python/doc/meta/old-commits.log
index 93661e35..eb870cda 100644
--- a/lang/python/doc/meta/old-commits.log
+++ b/lang/python/doc/meta/old-commits.log
@@ -1,2445 +1,2445 @@
 commit 2145348ec54c6027f2ea20f695de0277e2871405
 Merge: 348ba88 2036f1a
 Author: Ben McGinnes 
 Date:   Wed May 6 03:04:19 2015 +1000
 
     Merge pull request #4 from Hasimir/master
 
     history
 
 commit 2036f1a0a670a0561993e195c458059220b36114
 Merge: dbabf0c 348ba88
 Author: Ben McGinnes 
 Date:   Wed May 6 02:57:44 2015 +1000
 
     Merge branch 'master' of github:adversary-org/pyme3
 
 commit dbabf0cf1f2985755c2293b619011832e34faa9c
 Author: Ben McGinnes 
 Date:   Wed May 6 02:52:23 2015 +1000
 
     Added a short history
 
     * A (very) brief summary of the project's history since 2002.
     * Deals with why the commit log in the GPGME repo does not include the
       history of PyME.
     * Mentions that intact git repos will be maintained, but not where they
       are (one will be on github, another will be in a user directory on
       playfair.gnupg.org).
 
  docs/Short_History.rst | 57 ++++++++++++++++++++++++++++++++++++++++++++++++++
  1 file changed, 57 insertions(+)
 
 commit 348ba883424778c711c04ae9b66035ccdb36eb8c
 Merge: 127d0a5 7c37a27
 Author: Ben McGinnes 
 Date:   Wed May 6 02:21:34 2015 +1000
 
     Merge pull request #3 from Hasimir/master
 
     Version release preparation
 
 commit 7c37a27a6845c58222d4d947c2efbe38e955b612
 Merge: f692cff 127d0a5
 Author: Ben McGinnes 
 Date:   Wed May 6 02:17:14 2015 +1000
 
     Merge branch 'master' of github:adversary-org/pyme3
 
 commit f692cff50a89c2c61acdbd3d7dd60f5ce3cd15af
 Author: Ben McGinnes 
 Date:   Wed May 6 02:09:44 2015 +1000
 
     TODO update
 
     * Removed reference to GitHub, replaced with impending new home at gnupg.org.
 
  docs/TODO.rst | 4 ++--
  1 file changed, 2 insertions(+), 2 deletions(-)
 
 commit bd5ccf9e3bfe69fa681613757577e87b72ca08ec
 Author: Ben McGinnes 
 Date:   Wed May 6 02:00:44 2015 +1000
 
     Version bump
 
     * Bumped version number to 0.9.1 to keep it somewhat in line with the
       existing PyME project, even though there will be some divergence at
       some point (or even re-merging, depending on how many of the Python 3
       modifications can be back-ported to the Python 2 version).
     * Updated the author and copyright information to reflect the two
       current authors (Martin and I).
     * Replaced Igor's contact details with mine.
     * Replaced project home page with the GnuPG one.
 
  pyme/version.py | 16 +++++++++-------
  1 file changed, 9 insertions(+), 7 deletions(-)
 
 commit ec167512f4ca88d8f6e89e2ae831798c8283b4df
 Author: Ben McGinnes 
 Date:   Wed May 6 01:48:01 2015 +1000
 
     README preparation.
 
     * Changes in preparation for impending move of code to the GnuPG git
       server as a part of GPGME.
 
  README.rst | 14 +++++++-------
  1 file changed, 7 insertions(+), 7 deletions(-)
 
 commit 8a48515e884c36b5bdb24a13cb4d2e49f4ee6f17
 Author: Ben McGinnes 
 Date:   Wed May 6 01:43:53 2015 +1000
 
     TODO moved to docs
 
     * As it says.
 
  TODO.rst      | 25 -------------------------
  docs/TODO.rst | 25 +++++++++++++++++++++++++
  2 files changed, 25 insertions(+), 25 deletions(-)
 
 commit f968c777472f01f308f6e57eac1740bf5c76c205
 Author: Ben McGinnes 
 Date:   Sun May 3 16:52:13 2015 +1000
 
     Started another TODO file.
 
  TODO.rst | 25 +++++++++++++++++++++++++
  1 file changed, 25 insertions(+)
 
 commit 127d0a56fa9f7ad1d4fb39d0b529b890a8d67365
 Merge: db72dea 44837f6
 Author: Ben McGinnes 
 Date:   Sun May 3 14:59:44 2015 +1000
 
     Merge pull request #2 from Hasimir/master
 
     Minor editing.
 
 commit 44837f6e50fc539c86aef1f75a6a3538b02029ea
 Author: Ben McGinnes 
 Date:   Sun May 3 14:56:55 2015 +1000
 
     Minor editing.
 
     * Fixed another URL.
     * Changed Py3 version's version number to v0.9.1-beta0.
 
  README.rst | 4 ++--
  1 file changed, 2 insertions(+), 2 deletions(-)
 
 commit db72deaae19c3513391df040bcaf66a88d9213af
 Merge: db34286 48eb185
 Author: Ben McGinnes 
 Date:   Sun May 3 14:26:11 2015 +1000
 
     Merge pull request #1 from Hasimir/master
 
     Links
 
 commit 48eb1856cb0739cc9f0b9084da9d965e1fc7fddd
 Author: Ben McGinnes 
 Date:   Sun May 3 14:22:30 2015 +1000
 
     Links
 
     * Fixed URLs for authors.
     * Updated my entry to point to github location.
     ** I strongly suspect the result of this work will be concurrent
        projects, so preparing for that eventuality with this repo.
 
  README.rst | 8 ++++----
  1 file changed, 4 insertions(+), 4 deletions(-)
 
 commit db3428659783f30b9a76204403daedf9fc4cf7cf
 Author: Ben McGinnes 
 Date:   Sun May 3 11:29:00 2015 +1000
 
     Explicit over Implicit ...
 
     ... isn't just for code.
 
     * Removed the 2to3 working directory and its contents.
     * Made the README.rst file a little more clear that this branch is for
       Python 3 (set Python 3.2 as a fairly arbitrary requirement for the
       moment, but will probably raise this to 3.3).
 
  2to3/2to3-output-remaining.log |  60 ---
  2to3/2to3-output-setup.log     |  35 --
  2to3/2to3-output.log           | 950 -----------------------------------------
  README.rst                     |  10 +-
  4 files changed, 7 insertions(+), 1048 deletions(-)
 
 commit 3edf07a4ba8a86af3a33246234d6e133074862af
 Author: Ben McGinnes 
 Date:   Sun May 3 11:19:41 2015 +1000
 
     Added authors.
 
     * In alphabetical order.
     * Mine will need updating once Martin and I have decided what to do
       regarding the two main branches.
 
  README.rst | 12 ++++++++++++
  1 file changed, 12 insertions(+)
 
 commit 811eb14b53e8856312d99f46b77215f7f9bd672c
 Author: Ben McGinnes 
 Date:   Sun May 3 10:23:00 2015 +1000
 
     Docs and other things.
 
     * Now able to import pyme.core without error, indicates port process is
       successful.
     * Code is *not* compatible with the Python 2 version.
     * Will need to consider making this a parallel project with the master
       branch.
     * Got rid of the .org TODO file.
     * Changed the README to use the reST file extension since it's full of
       reST anyway.
 
  2to3/TODO.org |  5 -----
  README.rst    | 32 ++++++++++++++++++++++++++++++++
  README.txt    | 32 --------------------------------
  3 files changed, 32 insertions(+), 37 deletions(-)
 
 commit 79e784bdcce1de6f7856921b5431044c62c6f015
 Author: Ben McGinnes 
 Date:   Sun May 3 10:18:40 2015 +1000
 
     Fixed another implicit import by making it explicit.  Hopefully this is the last one.
 
  pyme/util.py | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)
 
 commit 2b52b46ccda3e7abcc50eed0745062259d698661
 Author: Ben McGinnes 
 Date:   Sun May 3 10:16:01 2015 +1000
 
     Fixed another implicit import by making it explicit.
 
  pyme/errors.py | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)
 
 commit 409c8fd565e21f23cd41daaeffc867e6d23a0863
 Author: Ben McGinnes 
 Date:   Sun May 3 10:08:22 2015 +1000
 
     Bytes vs. Unicode
 
     * Trying PyBytes instead of PyUnicode.
 
  gpgme.i   | 14 +++++++-------
  helpers.c |  8 ++++----
  2 files changed, 11 insertions(+), 11 deletions(-)
 
 commit d8164aa2ae98bf8c807c16e2d9be12c5fbea7cfd
 Author: Ben McGinnes 
 Date:   Sun May 3 09:22:58 2015 +1000
 
     String to Unicode
 
     * Replaced all instances of PyString with PyUnicode (and hoping there's
       no byte data in there).
 
  gpgme.i   | 14 +++++++-------
  helpers.c |  8 ++++----
  2 files changed, 11 insertions(+), 11 deletions(-)
 
 commit bd99b7865656e559b17c419c6b64b412a22c6c44
 Author: Ben McGinnes 
 Date:   Sun May 3 09:17:06 2015 +1000
 
     PyInt_AsLong
 
     * Replaced all instances of PyInt with PyLong, as per C API docs.
 
  gpgme.i   | 4 ++--
  helpers.c | 8 ++++----
  2 files changed, 6 insertions(+), 6 deletions(-)
 
 commit 3c91e2ccf8ca788b51e3308e292c6b64888fdb15
 Author: Ben McGinnes 
 Date:   Sun May 3 05:59:36 2015 +1000
 
     Import correction
 
     * Once pygpgme.py is generated and moved, it will be in the right
       directory for the explicit "from . import pygpgme" to be correct.
 
  pyme/core.py | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)
 
 commit 23a49e7070812ff1ce138d8d4cc46d0b80328897
 Author: Ben McGinnes 
 Date:   Sun May 3 05:38:29 2015 +1000
 
     The -py3 flag.
 
  Makefile | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)
 
 commit b1549587d6db5e33081b9c20f75d1348a1d25938
 Author: Ben McGinnes 
 Date:   Sun May 3 05:01:42 2015 +1000
 
     Fixed indentation - 4.
 
  pyme/core.py | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)
 
 commit a685142ce46761ee6f5176e90717176e38e0d24f
 Author: Ben McGinnes 
 Date:   Sun May 3 05:00:16 2015 +1000
 
     Fixed indentation - 3.
 
  pyme/core.py | 5 ++---
  1 file changed, 2 insertions(+), 3 deletions(-)
 
 commit 488a70b490cc64eb1c47d2483cb2f4079c6767f7
 Author: Ben McGinnes 
 Date:   Sun May 3 04:53:21 2015 +1000
 
     Pet Peeve
 
     def pet_peeve(self):
         peeve = print("people who don't press return after a colon!")
 
     FFS!
 
  pyme/core.py | 5 +++--
  1 file changed, 3 insertions(+), 2 deletions(-)
 
 commit a5d38eb47d64bb17bb609fe594dae2aca480bac9
 Author: Ben McGinnes 
 Date:   Sun May 3 04:47:54 2015 +1000
 
     Fixed indentation - 2.
 
  pyme/core.py | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)
 
 commit 476a207f732b8559abb1ea3c23147c0e34804730
 Author: Ben McGinnes 
 Date:   Sun May 3 04:46:01 2015 +1000
 
     Fixed indentation.
 
  pyme/core.py | 4 ++--
  1 file changed, 2 insertions(+), 2 deletions(-)
 
 commit 0572900eba9bcd9b0283c7d8e022e8972f06f9f8
 Author: Ben McGinnes 
 Date:   Sun May 3 04:43:49 2015 +1000
 
     Replaced all tabs with 4 spaces.
 
  pyme/core.py | 18 +++++++++---------
  1 file changed, 9 insertions(+), 9 deletions(-)
 
 commit 78c0b7677e94ce1e11b8cdb833a9064527187330
 Author: Ben McGinnes 
 Date:   Sun May 3 04:39:07 2015 +1000
 
     SWIG flags in the wrong place.
 
  Makefile | 4 ++--
  1 file changed, 2 insertions(+), 2 deletions(-)
 
 commit dfa7f2589963494a8f89277560d8c1116604a3c8
 Author: Ben McGinnes 
 Date:   Sun May 3 04:35:09 2015 +1000
 
     Fixed subprocess call for swig (again).
 
  setup.py | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)
 
 commit 249bfd8c714dcda53127b99b6cc8a6c7c4a99f20
 Author: Ben McGinnes 
 Date:   Sun May 3 04:32:40 2015 +1000
 
     Fixed subprocess call for swig.
 
  setup.py | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)
 
 commit 6fd7e719cf4c975f466ceb39835db7007df36fb2
 Author: Ben McGinnes 
 Date:   Sun May 3 03:51:48 2015 +1000
 
     Linking swig to py3
 
     * Changed the swig invocations to run with the -python -py3 flags explicitly.
 
  Makefile | 4 ++--
  setup.py | 2 +-
  2 files changed, 3 insertions(+), 3 deletions(-)
 
 commit 7a6b584f50ed6ddc8617a642185eea1f24ff791a
 Author: Ben McGinnes 
 Date:   Sat May 2 11:12:00 2015 +1000
 
     String fun
 
     * streamlined confdata details, including decoding strom binary to string.
 
  setup.py | 4 +---
  1 file changed, 1 insertion(+), 3 deletions(-)
 
 commit f7fd3f270592021a95a8f779bfe85ac18f4e390b
 Author: Ben McGinnes 
 Date:   Sat May 2 10:46:59 2015 +1000
 
     Open File
 
     * Removed deprecated file() and replaced with open().
 
  examples/PyGtkGpgKeys.py | 2 +-
  examples/pygpa.py        | 6 +++---
  gpgme-h-clean.py         | 2 +-
  3 files changed, 5 insertions(+), 5 deletions(-)
 
 commit 4227d486f9558015e7e548d71085e58e1b50ec08
 Author: Ben McGinnes 
 Date:   Sat May 2 10:36:15 2015 +1000
 
     print() fix
 
     * Makefile includes a python print, changed from statement to function.
 
  Makefile | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)
 
 commit 406f7f2567b701502186fe0a325dc2a3491ff7f8
 Author: Ben McGinnes 
 Date:   Sat May 2 10:28:42 2015 +1000
 
     Updated Makefile
 
     * set make to use python3 instead.
-    * This will mean a successful port may need to be maintained seperately
+    * This will mean a successful port may need to be maintained separately
       from the original python2 code instead of merged, but ought to be able
       to share most things.  So maybe merge with separated make files or a
       pre-make script to set python2 or python3 prior to building ... decide
       later, after it works.
 
  Makefile | 6 +++---
  1 file changed, 3 insertions(+), 3 deletions(-)
 
 commit 90b3efa5b193d37e08dc9b4ee766ba9ebc9412af
 Author: Ben McGinnes 
 Date:   Sat May 2 10:15:20 2015 +1000
 
     Env and a little license issue
 
     * Updated all the /usr/bin/env paths to point to python3.
     * Also fixed the hard coded /usr/bin/python paths.
     * Updated part of setup.py which gave the impression this package was
       only licensed under the GPL (it's actually licensed under the LGPL as
       well, essentially the same dual licensing as the GPGME library).
 
  examples/PyGtkGpgKeys.py   | 2 +-
  examples/delkey.py         | 2 +-
  examples/encrypt-to-all.py | 2 +-
  examples/exportimport.py   | 2 +-
  examples/genkey.py         | 2 +-
  examples/inter-edit.py     | 2 +-
  examples/pygpa.py          | 2 +-
  examples/sign.py           | 2 +-
  examples/signverify.py     | 2 +-
  examples/simple.py         | 2 +-
  examples/t-edit.py         | 2 +-
  examples/testCMSgetkey.py  | 2 +-
  examples/verifydetails.py  | 2 +-
  gpgme-h-clean.py           | 2 +-
  setup.py                   | 4 ++--
  15 files changed, 16 insertions(+), 16 deletions(-)
 
 commit 1a4b55dbccd2774344352e579130bf494bc5fa4b
 Author: Ben McGinnes 
 Date:   Sat May 2 08:50:54 2015 +1000
 
     Removed extraneous files.
 
     * The two .bak files.
 
  pyme/errors.py.bak |  46 ---------------------
  setup.py.bak       | 116 -----------------------------------------------------
  2 files changed, 162 deletions(-)
 
 commit 208879d4f2a6d0514c3f8ee2fc0da8bba42350de
 Author: Ben McGinnes 
 Date:   Sat May 2 08:19:37 2015 +1000
 
     Added TODO.org
 
     * TODO list in Emacs org-mode.
     * Will eventually be removed along with this entire directory when the
       porting process is complete.
 
  2to3/TODO.org | 5 +++++
  1 file changed, 5 insertions(+)
 
 commit 1548bf201059638675c5387c6f124d4b703363a9
 Author: Ben McGinnes 
 Date:   Sat May 2 07:58:40 2015 +1000
 
     2to3 conversion of remaining files
 
     * Ran the extended version against all the unmodified python files.
     * Only pyme/errors.py required additional work.
 
  2to3/2to3-output-remaining.log | 60 ++++++++++++++++++++++++++++++++++++++++++
  pyme/errors.py                 |  2 +-
  pyme/errors.py.bak             | 46 ++++++++++++++++++++++++++++++++
  3 files changed, 107 insertions(+), 1 deletion(-)
 
 commit 1230650bc6bbe4c14d1284f7877aa932f3e86eb4
 Author: Ben McGinnes 
 Date:   Sat May 2 07:50:39 2015 +1000
 
     2to3 conversion of setup.py
 
     * Ran extended 2to3 command to produce python 3 code for setup.py.
     * Effectively testing for what to run against the other originally
       unmodified py2 files.
 
  2to3/2to3-output-setup.log |  35 ++++++++++++++
  setup.py                   |   7 ++-
  setup.py.bak               | 116 +++++++++++++++++++++++++++++++++++++++++++++
  3 files changed, 154 insertions(+), 4 deletions(-)
 
 commit edad44955f59aa879e95a369591717fb19eec6b7
 Author: Ben McGinnes 
 Date:   Fri May 1 21:50:07 2015 +1000
 
     Removing 2to3 generated .bak files.
 
     * Not really needed with a real VCS, but couldn't hurt to have them for
       a couple of revisions.  ;)
 
  examples/PyGtkGpgKeys.py.bak           |  663 ---------------
  examples/encrypt-to-all.py.bak         |   65 --
  examples/exportimport.py.bak           |   75 --
  examples/genkey.py.bak                 |   45 -
  examples/inter-edit.py.bak             |   57 --
  examples/pygpa.py.bak                  | 1457 --------------------------------
  examples/sign.py.bak                   |   31 -
  examples/signverify.py.bak             |   78 --
  examples/simple.py.bak                 |   52 --
  examples/t-edit.py.bak                 |   59 --
  examples/testCMSgetkey.py.bak          |   45 -
  examples/verifydetails.py.bak          |  100 ---
  gpgme-h-clean.py.bak                   |   42 -
  pyme/callbacks.py.bak                  |   47 --
  pyme/constants/data/__init__.py.bak    |    4 -
  pyme/constants/keylist/__init__.py.bak |    4 -
  pyme/constants/sig/__init__.py.bak     |    4 -
  pyme/core.py.bak                       |  463 ----------
  pyme/util.py.bak                       |   72 --
  pyme/version.py.bak                    |   41 -
  20 files changed, 3404 deletions(-)
 
 commit 1cfc3c969f885ed191610bffbbd60ac23fdd349e
 Author: Ben McGinnes 
 Date:   Fri May 1 21:45:50 2015 +1000
 
     2to3 conversion log
 
     * The output of the command to convert the code from Python 2 to 3.
     * Note: this contains the list of files which were not modified and
       which will or may need to be modified.
 
  2to3/2to3-output.log | 950 +++++++++++++++++++++++++++++++++++++++++++++++++++
  1 file changed, 950 insertions(+)
 
 commit 078f6cf878aa62d12704fab424198a613a24cc8c
 Author: Ben McGinnes 
 Date:   Fri May 1 21:36:58 2015 +1000
 
     2to3 conversion of pyme master
 
     * Branch from commit 459f3eca659b4949e394c4a032d9ce2053e6c721
     * Ran this: or x in `find . | egrep .py$` ; do 2to3 -w $x; done ;
     * Multiple files not modified, will record elsewhere (see next commit).
 
  examples/PyGtkGpgKeys.py               |   10 +-
  examples/PyGtkGpgKeys.py.bak           |  663 +++++++++++++++
  examples/encrypt-to-all.py             |   12 +-
  examples/encrypt-to-all.py.bak         |   65 ++
  examples/exportimport.py               |   20 +-
  examples/exportimport.py.bak           |   75 ++
  examples/genkey.py                     |    2 +-
  examples/genkey.py.bak                 |   45 +
  examples/inter-edit.py                 |    8 +-
  examples/inter-edit.py.bak             |   57 ++
  examples/pygpa.py                      |   40 +-
  examples/pygpa.py.bak                  | 1457 ++++++++++++++++++++++++++++++++
  examples/sign.py                       |    2 +-
  examples/sign.py.bak                   |   31 +
  examples/signverify.py                 |   18 +-
  examples/signverify.py.bak             |   78 ++
  examples/simple.py                     |    8 +-
  examples/simple.py.bak                 |   52 ++
  examples/t-edit.py                     |   12 +-
  examples/t-edit.py.bak                 |   59 ++
  examples/testCMSgetkey.py              |    8 +-
  examples/testCMSgetkey.py.bak          |   45 +
  examples/verifydetails.py              |   34 +-
  examples/verifydetails.py.bak          |  100 +++
  gpgme-h-clean.py                       |    2 +-
  gpgme-h-clean.py.bak                   |   42 +
  pyme/callbacks.py                      |    6 +-
  pyme/callbacks.py.bak                  |   47 ++
  pyme/constants/data/__init__.py        |    2 +-
  pyme/constants/data/__init__.py.bak    |    4 +
  pyme/constants/keylist/__init__.py     |    2 +-
  pyme/constants/keylist/__init__.py.bak |    4 +
  pyme/constants/sig/__init__.py         |    2 +-
  pyme/constants/sig/__init__.py.bak     |    4 +
  pyme/core.py                           |   26 +-
  pyme/core.py.bak                       |  463 ++++++++++
  pyme/util.py                           |    6 +-
  pyme/util.py.bak                       |   72 ++
  pyme/version.py                        |    2 +-
  pyme/version.py.bak                    |   41 +
  40 files changed, 3515 insertions(+), 111 deletions(-)
 
 commit 459f3eca659b4949e394c4a032d9ce2053e6c721
 Merge: c5966ab dae7f14
 Author: Martin Albrecht 
 Date:   Wed Jul 9 10:48:33 2014 +0100
 
     Merged in jerrykan/pyme/fix_setup_26 (pull request #1)
 
     Provide support for using setup.py with Python v2.6
 
 commit dae7f14a54e6c2bde0ad4da7308cc7fc0d0c0469
 Author: John Kristensen 
 Date:   Wed Jul 9 15:54:39 2014 +1000
 
     Provide support for using setup.py with Python v2.6
 
     The setup.py script uses subprocess.check_output() which was introduced
     in Python v2.7. The equivalent functionality can be achieved without
     adding much extra code and provide support for Python v2.6.
 
  setup.py | 4 +++-
  1 file changed, 3 insertions(+), 1 deletion(-)
 
 commit c5966abec9d772b3922d32650da288fd50a217be
 Author: Martin Albrecht 
 Date:   Thu May 15 19:43:00 2014 +0100
 
     README.txt in ReST, including headlines
 
  README.txt | 8 ++++++--
  1 file changed, 6 insertions(+), 2 deletions(-)
 
 commit 43ee8c6f34fa9b6d3975aa6ea60b3d4a741fa721
 Author: Martin Albrecht 
 Date:   Thu May 15 19:37:15 2014 +0100
 
     README.txt in ReST
 
  README.txt | 25 +++++++++++++------------
  1 file changed, 13 insertions(+), 12 deletions(-)
 
 commit f71a369484cba8801df23ccc5842335fa496c0df
 Author: Martin Albrecht 
 Date:   Thu May 15 19:28:12 2014 +0100
 
     added MANIFEST.in and README.txt (instead of .md)
 
  MANIFEST.in |  6 ++++++
  README.md   | 27 ---------------------------
  README.txt  | 27 +++++++++++++++++++++++++++
  3 files changed, 33 insertions(+), 27 deletions(-)
 
 commit d0d6755229f920b0bed043e9c2731de2d57c096c
 Author: Martin Albrecht 
 Date:   Tue May 13 09:52:44 2014 +0100
 
     added mailing list to README
 
  README.md | 19 ++++++++++++++++---
  1 file changed, 16 insertions(+), 3 deletions(-)
 
 commit 30ca60ddf92df684de261cb24c83c68089be0adc
 Author: Martin Albrecht 
 Date:   Sun May 11 13:34:28 2014 +0100
 
     we don't need a separate out of date ChangeLog file
 
  ChangeLog | 802 --------------------------------------------------------------
  1 file changed, 802 deletions(-)
 
 commit 8263f1a6d38fdb7f5f3dd5c7e28f83caa7528a08
 Author: Martin Albrecht 
 Date:   Sun May 11 13:32:31 2014 +0100
 
     adding README.md
 
  README.md | 14 ++++++++++++++
  1 file changed, 14 insertions(+)
 
 commit 3fc71b47e9e14b0b984801c28d722723baa4b406
 Author: Martin Albrecht 
 Date:   Sat May 10 15:43:06 2014 +0100
 
     ValueError -> RuntimeError
 
  setup.py | 4 ++--
  1 file changed, 2 insertions(+), 2 deletions(-)
 
 commit eec432abea56296b9fa36aac0d10926a2335b739
 Merge: eea6537 d2738b3
 Author: Martin Albrecht 
 Date:   Sat May 10 15:41:02 2014 +0100
 
     Merge branch 'master' of bitbucket.org:malb/pyme
 
     Conflicts:
         setup.py
 
 commit eea6537921061b4dcfc54e00a99d3fa110e71433
 Author: Martin Albrecht 
 Date:   Sat May 10 15:39:51 2014 +0100
 
     check for swig
 
  setup.py | 8 ++++++++
  1 file changed, 8 insertions(+)
 
 commit 53867bf9715ee1b4ea873bf5e2fbb7d9740a2b4a
 Author: Martin Albrecht 
 Date:   Sat May 10 15:35:04 2014 +0100
 
     more friendly error message if gpgme is missing
 
  setup.py | 8 +++++++-
  1 file changed, 7 insertions(+), 1 deletion(-)
 
 commit d2738b35d63b1492d69641c5466103685f2d3a30
 Author: Martin Albrecht 
 Date:   Sat May 10 15:35:04 2014 +0100
 
     more friendly error message if gpgme is missing
 
  setup.py | 8 +++++++-
  1 file changed, 7 insertions(+), 1 deletion(-)
 
 commit c0b01240becf8ba6cf1d4c1f64b2cb4c056f5163
 Author: Martin Albrecht 
 Date:   Fri May 9 15:20:24 2014 +0100
 
     version number should have three digits
 
  pyme/version.py | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)
 
 commit 6672bb60b9bec60d38e854016c48658b57774578
 Author: Martin Albrecht 
 Date:   Wed May 7 15:11:08 2014 +0100
 
     bump version number for upcoming release
 
  pyme/version.py | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)
 
 commit 7bd6de700f33ca5d1f27bc16ebbd401f21d2e788
 Author: Martin Albrecht 
 Date:   Sat May 3 19:36:25 2014 +0100
 
     bump version number to indicate changes
 
  pyme/version.py | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)
 
 commit 4fb6bd9b3f47c1a343242ac83b326cacd12a136e
 Author: Martin Albrecht 
 Date:   Sat May 3 19:34:07 2014 +0100
 
     pyme instead of pygpgme
 
  setup.py | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)
 
 commit 9548973138d78241a45ccb82333b25f2cf36ce7d
 Author: Martin Albrecht 
 Date:   Sat May 3 19:31:10 2014 +0100
 
     dirty hack to make 'python setup.py install' work
 
  setup.py | 7 ++++---
  1 file changed, 4 insertions(+), 3 deletions(-)
 
 commit a961d7eab9db478b7e603324bc5d243bd3c84bad
 Author: Martin Albrecht 
 Date:   Sat May 3 19:05:44 2014 +0100
 
     moved everything down to the toplevel directory
 
  COPYING                                 |  340 ++
  COPYING.LESSER                          |  510 +++
  ChangeLog                               |  802 +++++
  INSTALL                                 |   15 +
  Makefile                                |  104 +
  debian/README.Debian                    |    6 +
  debian/changelog                        |   93 +
  debian/control                          |   34 +
  debian/copyright                        |   25 +
  debian/docs                             |    2 +
  debian/examples                         |    2 +
  debian/rules                            |   99 +
  examples/PyGtkGpgKeys.glade             | 1394 ++++++++
  examples/PyGtkGpgKeys.gladep            |    8 +
  examples/PyGtkGpgKeys.py                |  663 ++++
  examples/delkey.py                      |   34 +
  examples/encrypt-to-all.py              |   65 +
  examples/exportimport.py                |   75 +
  examples/genkey.py                      |   45 +
  examples/inter-edit.py                  |   57 +
  examples/pygpa.glade                    | 5546 +++++++++++++++++++++++++++++++
  examples/pygpa.py                       | 1457 ++++++++
  examples/sign.py                        |   31 +
  examples/signverify.py                  |   78 +
  examples/simple.py                      |   52 +
  examples/t-edit.py                      |   59 +
  examples/testCMSgetkey.py               |   45 +
  examples/verifydetails.py               |  100 +
  gpgme-h-clean.py                        |   42 +
  gpgme.i                                 |  267 ++
  helpers.c                               |  154 +
  helpers.h                               |   36 +
  pyme/COPYING                            |  340 --
  pyme/COPYING.LESSER                     |  510 ---
  pyme/ChangeLog                          |  802 -----
  pyme/INSTALL                            |   15 -
  pyme/Makefile                           |  104 -
  pyme/__init__.py                        |  137 +
  pyme/callbacks.py                       |   47 +
  pyme/constants/__init__.py              |    7 +
  pyme/constants/data/__init__.py         |    4 +
  pyme/constants/data/encoding.py         |   20 +
  pyme/constants/event.py                 |   20 +
  pyme/constants/import.py                |   20 +
  pyme/constants/keylist/__init__.py      |    4 +
  pyme/constants/keylist/mode.py          |   20 +
  pyme/constants/md.py                    |   20 +
  pyme/constants/pk.py                    |   20 +
  pyme/constants/protocol.py              |   20 +
  pyme/constants/sig/__init__.py          |    4 +
  pyme/constants/sig/mode.py              |   20 +
  pyme/constants/sigsum.py                |   20 +
  pyme/constants/status.py                |   20 +
  pyme/constants/validity.py              |   20 +
  pyme/core.py                            |  463 +++
  pyme/debian/README.Debian               |    6 -
  pyme/debian/changelog                   |   93 -
  pyme/debian/control                     |   34 -
  pyme/debian/copyright                   |   25 -
  pyme/debian/docs                        |    2 -
  pyme/debian/examples                    |    2 -
  pyme/debian/rules                       |   99 -
  pyme/errors.py                          |   46 +
  pyme/examples/PyGtkGpgKeys.glade        | 1394 --------
  pyme/examples/PyGtkGpgKeys.gladep       |    8 -
  pyme/examples/PyGtkGpgKeys.py           |  663 ----
  pyme/examples/delkey.py                 |   34 -
  pyme/examples/encrypt-to-all.py         |   65 -
  pyme/examples/exportimport.py           |   75 -
  pyme/examples/genkey.py                 |   45 -
  pyme/examples/inter-edit.py             |   57 -
  pyme/examples/pygpa.glade               | 5546 -------------------------------
  pyme/examples/pygpa.py                  | 1457 --------
  pyme/examples/sign.py                   |   31 -
  pyme/examples/signverify.py             |   78 -
  pyme/examples/simple.py                 |   52 -
  pyme/examples/t-edit.py                 |   59 -
  pyme/examples/testCMSgetkey.py          |   45 -
  pyme/examples/verifydetails.py          |  100 -
  pyme/gpgme-h-clean.py                   |   42 -
  pyme/gpgme.i                            |  267 --
  pyme/helpers.c                          |  154 -
  pyme/helpers.h                          |   36 -
  pyme/pyme/__init__.py                   |  137 -
  pyme/pyme/callbacks.py                  |   47 -
  pyme/pyme/constants/__init__.py         |    7 -
  pyme/pyme/constants/data/__init__.py    |    4 -
  pyme/pyme/constants/data/encoding.py    |   20 -
  pyme/pyme/constants/event.py            |   20 -
  pyme/pyme/constants/import.py           |   20 -
  pyme/pyme/constants/keylist/__init__.py |    4 -
  pyme/pyme/constants/keylist/mode.py     |   20 -
  pyme/pyme/constants/md.py               |   20 -
  pyme/pyme/constants/pk.py               |   20 -
  pyme/pyme/constants/protocol.py         |   20 -
  pyme/pyme/constants/sig/__init__.py     |    4 -
  pyme/pyme/constants/sig/mode.py         |   20 -
  pyme/pyme/constants/sigsum.py           |   20 -
  pyme/pyme/constants/status.py           |   20 -
  pyme/pyme/constants/validity.py         |   20 -
  pyme/pyme/core.py                       |  463 ---
  pyme/pyme/errors.py                     |   46 -
  pyme/pyme/util.py                       |   72 -
  pyme/pyme/version.py                    |   41 -
  pyme/setup.py                           |   99 -
  pyme/util.py                            |   72 +
  pyme/version.py                         |   41 +
  setup.py                                |   99 +
  108 files changed, 13384 insertions(+), 13384 deletions(-)
 
 commit 8148cdd424c434e833ce427612ea8c89abc6e41c
 Author: Martin Albrecht 
 Date:   Sat May 3 18:58:52 2014 +0100
 
     removing pyme-web
 
  pyme-web/Makefile                                  |  15 -
  pyme-web/default.css                               |  37 --
  pyme-web/doc/gpgme/ASCII-Armor.html                |  57 ---
  pyme-web/doc/gpgme/Advanced-Key-Editing.html       |  98 ----
  pyme-web/doc/gpgme/Algorithms.html                 |  47 --
  pyme-web/doc/gpgme/Building-the-Source.html        |  82 ----
  .../doc/gpgme/Callback-Based-Data-Buffers.html     | 148 ------
  pyme-web/doc/gpgme/Cancellation.html               |  67 ---
  pyme-web/doc/gpgme/Concept-Index.html              | 186 -------
  pyme-web/doc/gpgme/Context-Attributes.html         |  52 --
  pyme-web/doc/gpgme/Contexts.html                   |  61 ---
  pyme-web/doc/gpgme/Creating-Contexts.html          |  49 --
  pyme-web/doc/gpgme/Creating-Data-Buffers.html      |  47 --
  pyme-web/doc/gpgme/Creating-a-Signature.html       | 143 ------
  pyme-web/doc/gpgme/Crypto-Engine.html              |  79 ---
  pyme-web/doc/gpgme/Crypto-Operations.html          |  67 ---
  .../doc/gpgme/Cryptographic-Message-Syntax.html    |  42 --
  .../doc/gpgme/Data-Buffer-I_002fO-Operations.html  | 104 ----
  pyme-web/doc/gpgme/Data-Buffer-Meta_002dData.html  | 100 ----
  pyme-web/doc/gpgme/Decrypt-and-Verify.html         |  79 ---
  pyme-web/doc/gpgme/Decrypt.html                    | 123 -----
  pyme-web/doc/gpgme/Deleting-Keys.html              |  67 ---
  pyme-web/doc/gpgme/Destroying-Contexts.html        |  46 --
  pyme-web/doc/gpgme/Destroying-Data-Buffers.html    |  70 ---
  pyme-web/doc/gpgme/Encrypt.html                    |  45 --
  pyme-web/doc/gpgme/Encrypting-a-Plaintext.html     | 147 ------
  pyme-web/doc/gpgme/Engine-Configuration.html       |  65 ---
  pyme-web/doc/gpgme/Engine-Information.html         | 119 -----
  pyme-web/doc/gpgme/Engine-Version-Check.html       |  48 --
  pyme-web/doc/gpgme/Error-Codes.html                | 133 -----
  pyme-web/doc/gpgme/Error-Handling.html             |  72 ---
  pyme-web/doc/gpgme/Error-Sources.html              |  89 ----
  pyme-web/doc/gpgme/Error-Strings.html              |  80 ---
  pyme-web/doc/gpgme/Error-Values.html               | 159 ------
  pyme-web/doc/gpgme/Exchanging-Data.html            |  58 ---
  pyme-web/doc/gpgme/Exporting-Keys.html             | 101 ----
  pyme-web/doc/gpgme/Features.html                   |  59 ---
  pyme-web/doc/gpgme/File-Based-Data-Buffers.html    |  74 ---
  pyme-web/doc/gpgme/Function-and-Data-Index.html    | 229 ---------
  pyme-web/doc/gpgme/Generating-Keys.html            | 144 ------
  pyme-web/doc/gpgme/Getting-Started.html            |  55 ---
  pyme-web/doc/gpgme/Hash-Algorithms.html            |  59 ---
  pyme-web/doc/gpgme/Header.html                     |  53 --
  .../doc/gpgme/I_002fO-Callback-Example-GDK.html    |  85 ----
  .../gpgme/I_002fO-Callback-Example-GTK_002b.html   |  86 ----
  .../doc/gpgme/I_002fO-Callback-Example-Qt.html     |  99 ----
  pyme-web/doc/gpgme/I_002fO-Callback-Example.html   | 259 ----------
  pyme-web/doc/gpgme/I_002fO-Callback-Interface.html | 142 ------
  pyme-web/doc/gpgme/Importing-Keys.html             | 171 -------
  pyme-web/doc/gpgme/Included-Certificates.html      |  70 ---
  pyme-web/doc/gpgme/Information-About-Keys.html     | 207 --------
  .../doc/gpgme/Information-About-Trust-Items.html   |  75 ---
  pyme-web/doc/gpgme/Introduction.html               |  53 --
  pyme-web/doc/gpgme/Key-Listing-Mode.html           |  99 ----
  pyme-web/doc/gpgme/Key-Management.html             | 260 ----------
  pyme-web/doc/gpgme/Key-Signatures.html             | 130 -----
  .../doc/gpgme/Largefile-Support-_0028LFS_0029.html | 110 -----
  pyme-web/doc/gpgme/Library-Copying.html            | 542 ---------------------
  pyme-web/doc/gpgme/Library-Version-Check.html      |  97 ----
  pyme-web/doc/gpgme/Listing-Keys.html               | 204 --------
  pyme-web/doc/gpgme/Listing-Trust-Items.html        |  88 ----
  pyme-web/doc/gpgme/Locale.html                     |  69 ---
  pyme-web/doc/gpgme/Manipulating-Data-Buffers.html  |  45 --
  pyme-web/doc/gpgme/Manipulating-Keys.html          |  63 ---
  pyme-web/doc/gpgme/Manipulating-Trust-Items.html   |  62 ---
  pyme-web/doc/gpgme/Memory-Based-Data-Buffers.html  | 107 ----
  pyme-web/doc/gpgme/Multi-Threading.html            |  93 ----
  pyme-web/doc/gpgme/OpenPGP.html                    |  44 --
  pyme-web/doc/gpgme/Overview.html                   |  57 ---
  pyme-web/doc/gpgme/Passphrase-Callback.html        | 101 ----
  pyme-web/doc/gpgme/Preparation.html                |  54 --
  pyme-web/doc/gpgme/Progress-Meter-Callback.html    |  80 ---
  pyme-web/doc/gpgme/Protocol-Selection.html         |  60 ---
  pyme-web/doc/gpgme/Protocols-and-Engines.html      |  82 ----
  pyme-web/doc/gpgme/Public-Key-Algorithms.html      |  74 ---
  .../doc/gpgme/Registering-I_002fO-Callbacks.html   |  81 ---
  pyme-web/doc/gpgme/Run-Control.html                |  53 --
  pyme-web/doc/gpgme/Selecting-Signers.html          |  64 ---
  pyme-web/doc/gpgme/Sign.html                       |  50 --
  pyme-web/doc/gpgme/Signal-Handling.html            |  61 ---
  pyme-web/doc/gpgme/Signature-Notation-Data.html    |  85 ----
  pyme-web/doc/gpgme/Text-Mode.html                  |  63 ---
  pyme-web/doc/gpgme/Trust-Item-Management.html      |  68 ---
  pyme-web/doc/gpgme/Using-Automake.html             |  74 ---
  pyme-web/doc/gpgme/Using-External-Event-Loops.html |  74 ---
  pyme-web/doc/gpgme/Using-Libtool.html              |  44 --
  pyme-web/doc/gpgme/Verify.html                     | 492 -------------------
  pyme-web/doc/gpgme/Waiting-For-Completion.html     |  77 ---
  pyme-web/doc/gpgme/index.html                      | 169 -------
  pyme-web/doc/pyme/index.html                       | 164 -------
  pyme-web/doc/pyme/pyme.callbacks.html              |  42 --
  .../doc/pyme/pyme.constants.data.encoding.html     |  48 --
  pyme-web/doc/pyme/pyme.constants.data.html         |  29 --
  pyme-web/doc/pyme/pyme.constants.event.html        |  48 --
  pyme-web/doc/pyme/pyme.constants.html              |  39 --
  pyme-web/doc/pyme/pyme.constants.import.html       |  49 --
  pyme-web/doc/pyme/pyme.constants.keylist.html      |  29 --
  pyme-web/doc/pyme/pyme.constants.keylist.mode.html |  49 --
  pyme-web/doc/pyme/pyme.constants.md.html           |  58 ---
  pyme-web/doc/pyme/pyme.constants.pk.html           |  50 --
  pyme-web/doc/pyme/pyme.constants.protocol.html     |  48 --
  pyme-web/doc/pyme/pyme.constants.sig.html          |  29 --
  pyme-web/doc/pyme/pyme.constants.sig.mode.html     |  47 --
  pyme-web/doc/pyme/pyme.constants.sigsum.html       |  55 ---
  pyme-web/doc/pyme/pyme.constants.status.html       | 126 -----
  pyme-web/doc/pyme/pyme.constants.validity.html     |  50 --
  pyme-web/doc/pyme/pyme.core.html                   | 277 -----------
  pyme-web/doc/pyme/pyme.errors.html                 |  82 ----
  pyme-web/doc/pyme/pyme.html                        | 164 -------
  pyme-web/doc/pyme/pyme.util.html                   |  81 ---
  pyme-web/doc/pyme/pyme.version.html                |  37 --
  pyme-web/index.html                                |  72 ---
  112 files changed, 10551 deletions(-)
 
 commit 684d95feb7e10e538a56fb1b27f1456111bacb60
 Author: Martin Albrecht 
 Date:   Mon Jan 6 17:44:20 2014 +0100
 
     fixing op_export_keys()
 
     the conversion of gpgme_key_t [] was restricted to gpgme_key_t [] with the
     name recv, i.e. only the use-cases of encryption were covered.
 
     see: http://sourceforge.net/mailarchive/forum.php?forum_name=pyme-help&max_rows=25&style=nested&viewmonth=201309
 
  pyme/gpgme.i | 6 +++---
  1 file changed, 3 insertions(+), 3 deletions(-)
 
 commit 658d23b95110d21eeb50abf4e74701a667521a88
 Author: Martin Albrecht 
 Date:   Mon Jan 6 17:41:33 2014 +0100
 
     deleting CVSROOT
 
  CVSROOT/checkoutlist | 13 -------------
  CVSROOT/commitinfo   | 15 ---------------
  CVSROOT/config       | 21 ---------------------
  CVSROOT/cvswrappers  | 19 -------------------
  CVSROOT/editinfo     | 21 ---------------------
  CVSROOT/loginfo      | 26 --------------------------
  CVSROOT/modules      | 26 --------------------------
  CVSROOT/notify       | 12 ------------
  CVSROOT/rcsinfo      | 13 -------------
  CVSROOT/taginfo      | 20 --------------------
  CVSROOT/verifymsg    | 21 ---------------------
  11 files changed, 207 deletions(-)
 
 commit 576b555499c094c4786d42de9e59aa9826009b89
 Author: convert-repo 
 Date:   Mon Jan 6 15:22:44 2014 +0000
 
     update tags
 
 commit 2dcf0c5b702eb5a18c66ff1e42a72eaa7427af1d
 Author: belyi 
 Date:   Wed Nov 26 02:38:33 2008 +0000
 
     Move Windows specific fix from helpers.c to helpers.h so that it works
     for edit callback as well as for the passphrase one.
 
  pyme/helpers.c | 5 -----
  pyme/helpers.h | 5 +++++
  2 files changed, 5 insertions(+), 5 deletions(-)
 
 commit 42a035f2ef62470fea7a7f8ee33a1297fa90a603
 Author: belyi 
 Date:   Mon Nov 24 21:44:30 2008 +0000
 
     Update the way build directives are constructed on MinGW to have a bit
     more robust. Update PyMe build version to 0.8.1 in version.py
 
  pyme/pyme/version.py |  2 +-
  pyme/setup.py        | 10 ++++++++--
  2 files changed, 9 insertions(+), 3 deletions(-)
 
 commit 3aaa20fbcba17066c9ffd580f5209946022793a2
 Author: belyi 
 Date:   Mon Nov 24 06:57:11 2008 +0000
 
     Update changelog
 
  pyme/debian/changelog | 5 ++++-
  1 file changed, 4 insertions(+), 1 deletion(-)
 
 commit 689ff46b2550547e3883f809a6dc40c22c3e137e
 Author: belyi 
 Date:   Mon Nov 24 06:50:41 2008 +0000
 
     Fix hang problem on Windows when password is written to a filehandle.
     Fix the way path is constructed on MinGW platform.
 
  pyme/helpers.c | 5 +++++
  pyme/setup.py  | 4 ++--
  2 files changed, 7 insertions(+), 2 deletions(-)
 
 commit 852a60d541d66cb56f40378182b976fd87a02c46
 Author: belyi 
 Date:   Sun Nov 23 04:31:31 2008 +0000
 
     Add Bernard's example testCMSgetkey.py and his updates for
     verifydetails.py
 
  pyme/examples/testCMSgetkey.py | 45 ++++++++++++++++++++++++++++++++++++++++++
  pyme/examples/verifydetails.py | 43 +++++++++++++++++++++++++++++-----------
  2 files changed, 77 insertions(+), 11 deletions(-)
 
 commit f080527d9184f3360f0a8ef6136b9a188d8e7d2a
 Author: belyi 
 Date:   Thu May 29 18:29:37 2008 +0000
 
     Remove debian packaging for python2.3 since it is removed from both
     testing and unstable dists.
     Update docs build target to have correct PYTHONPATH set.
 
  pyme/Makefile         | 2 +-
  pyme/debian/changelog | 4 +++-
  pyme/debian/control   | 4 ++--
  pyme/debian/rules     | 2 --
  4 files changed, 6 insertions(+), 6 deletions(-)
 
 commit c25d133fcbadf3c7f6e655586b4a05d6e3cf6f0b
 Author: belyi 
 Date:   Thu Apr 3 13:37:12 2008 +0000
 
     Forgot to adjust mainText margin. Doing it now.
 
  pyme-web/default.css | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)
 
 commit 897286a54a32336d060cd03305cdecb7905f34f1
 Author: belyi 
 Date:   Thu Apr 3 13:00:11 2008 +0000
 
     Fix an error in default.css and make index.html "Standards Compliant".
 
  pyme-web/default.css | 2 +-
  pyme-web/index.html  | 7 ++++---
  2 files changed, 5 insertions(+), 4 deletions(-)
 
 commit 4e049212bd214449cc0ba1ce06e00782783f328a
 Author: belyi 
 Date:   Thu Apr 3 12:38:42 2008 +0000
 
     Adjust spacing between links.
 
  pyme-web/default.css | 9 ++++++---
  1 file changed, 6 insertions(+), 3 deletions(-)
 
 commit cb2bddfbd77483b1deb14f2eab0715a03dd33fcd
 Author: belyi 
 Date:   Wed Apr 2 22:50:21 2008 +0000
 
     Make style a big more IE friendly.
 
  pyme-web/default.css | 15 +++++++++++----
  1 file changed, 11 insertions(+), 4 deletions(-)
 
 commit ad66f0a1bb01b46baac328e9fee439b35a60c232
 Author: belyi 
 Date:   Wed Apr 2 11:58:32 2008 +0000
 
     Make GPGME documentation a bit more web friendly on the index.html page.
 
  pyme-web/doc/gpgme/Algorithms.html              |   2 +-
  pyme-web/doc/gpgme/Concept-Index.html           |   2 +-
  pyme-web/doc/gpgme/Contexts.html                |   2 +-
  pyme-web/doc/gpgme/Error-Handling.html          |   2 +-
  pyme-web/doc/gpgme/Exchanging-Data.html         |   2 +-
  pyme-web/doc/gpgme/Function-and-Data-Index.html |   2 +-
  pyme-web/doc/gpgme/Introduction.html            |   4 +-
  pyme-web/doc/gpgme/Library-Copying.html         |   2 +-
  pyme-web/doc/gpgme/Preparation.html             |   2 +-
  pyme-web/doc/gpgme/Protocols-and-Engines.html   |   2 +-
  pyme-web/doc/gpgme/index.html                   | 229 +-----------------------
  11 files changed, 12 insertions(+), 239 deletions(-)
 
 commit 4f57c0ccb049d4442e7732e2d1d05dabffd2a21d
 Author: belyi 
 Date:   Wed Apr 2 06:12:57 2008 +0000
 
     Add missing core.set_locale() to set default locale for contexts.
 
  pyme/debian/changelog | 2 +-
  pyme/pyme/core.py     | 4 ++++
  2 files changed, 5 insertions(+), 1 deletion(-)
 
 commit acf7ead3dea8590cf9fe86b67bb125837ad6ed4f
 Author: belyi 
 Date:   Wed Apr 2 05:50:24 2008 +0000
 
     Avoid leaks caused by keys.
     Add set/get methods for engine info.
 
  pyme/debian/changelog | 10 ++++++++++
  pyme/pyme/core.py     | 24 ++++++++++++++++++++++++
  2 files changed, 34 insertions(+)
 
 commit df4a2fb518adbb6420d95ce74af212c87abff7e7
 Author: belyi 
 Date:   Wed Apr 2 04:04:41 2008 +0000
 
     Update index.html to reflect new versions on the web.
 
  pyme-web/Makefile             | 3 ++-
  pyme-web/doc/gpgme/index.html | 4 +---
  pyme-web/index.html           | 4 ++--
  3 files changed, 5 insertions(+), 6 deletions(-)
 
 commit bd3ffc9bdf98d6aafde6b689c6c8215fa468612d
 Author: belyi 
 Date:   Wed Apr 2 04:01:04 2008 +0000
 
     Update PyMe documentation to match 0.8.0 version of the package.
 
  pyme-web/doc/pyme/index.html                       | 14 ++++-----
  pyme-web/doc/pyme/pyme.constants.keylist.mode.html |  1 +
  pyme-web/doc/pyme/pyme.constants.protocol.html     |  4 ++-
  pyme-web/doc/pyme/pyme.constants.status.html       |  9 ++++++
  pyme-web/doc/pyme/pyme.core.html                   | 36 ++++++++++++++++++----
  pyme-web/doc/pyme/pyme.errors.html                 |  8 ++---
  pyme-web/doc/pyme/pyme.html                        | 14 ++++-----
  pyme-web/doc/pyme/pyme.util.html                   | 17 ++++++++--
  pyme-web/doc/pyme/pyme.version.html                | 14 ++++-----
  9 files changed, 82 insertions(+), 35 deletions(-)
 
 commit 6973a69a317608a0d0661590d701f4e3f3a21b32
 Author: belyi 
 Date:   Wed Apr 2 02:35:24 2008 +0000
 
     Have a fix for Contents being put onto 'Function and Data Index' page.
 
  pyme-web/doc/gpgme/Concept-Index.html           |   2 +-
  pyme-web/doc/gpgme/Function-and-Data-Index.html | 153 +----------------------
  pyme-web/doc/gpgme/index.html                   | 154 +++++++++++++++++++++++-
  3 files changed, 155 insertions(+), 154 deletions(-)
 
 commit 086315964cbc2abad1187f306dcb9c72ac3257f3
 Author: belyi 
 Date:   Wed Apr 2 01:00:29 2008 +0000
 
     Update GPGME documentation. It's for v1.1.6 now.
 
  pyme-web/doc/gpgme/ASCII-Armor.html                |  57 ++
  pyme-web/doc/gpgme/Advanced-Key-Editing.html       |  98 +++
  pyme-web/doc/gpgme/Algorithms.html                 |  47 ++
  pyme-web/doc/gpgme/Building-the-Source.html        |  82 +++
  .../doc/gpgme/Callback-Based-Data-Buffers.html     | 148 +++++
  pyme-web/doc/gpgme/Cancellation.html               |  67 ++
  pyme-web/doc/gpgme/Concept-Index.html              | 186 ++++++
  pyme-web/doc/gpgme/Context-Attributes.html         |  52 ++
  pyme-web/doc/gpgme/Contexts.html                   |  61 ++
  pyme-web/doc/gpgme/Creating-Contexts.html          |  49 ++
  pyme-web/doc/gpgme/Creating-Data-Buffers.html      |  47 ++
  pyme-web/doc/gpgme/Creating-a-Signature.html       | 143 +++++
  pyme-web/doc/gpgme/Crypto-Engine.html              |  79 +++
  pyme-web/doc/gpgme/Crypto-Operations.html          |  67 ++
  .../doc/gpgme/Cryptographic-Message-Syntax.html    |  42 ++
  .../doc/gpgme/Data-Buffer-I_002fO-Operations.html  | 104 ++++
  pyme-web/doc/gpgme/Data-Buffer-Meta_002dData.html  | 100 +++
  pyme-web/doc/gpgme/Decrypt-and-Verify.html         |  79 +++
  pyme-web/doc/gpgme/Decrypt.html                    | 123 ++++
  pyme-web/doc/gpgme/Deleting-Keys.html              |  67 ++
  pyme-web/doc/gpgme/Destroying-Contexts.html        |  46 ++
  pyme-web/doc/gpgme/Destroying-Data-Buffers.html    |  70 +++
  pyme-web/doc/gpgme/Encrypt.html                    |  45 ++
  pyme-web/doc/gpgme/Encrypting-a-Plaintext.html     | 147 +++++
  pyme-web/doc/gpgme/Engine-Configuration.html       |  65 ++
  pyme-web/doc/gpgme/Engine-Information.html         | 119 ++++
  pyme-web/doc/gpgme/Engine-Version-Check.html       |  48 ++
  pyme-web/doc/gpgme/Error-Codes.html                | 133 ++++
  pyme-web/doc/gpgme/Error-Handling.html             |  72 +++
  pyme-web/doc/gpgme/Error-Sources.html              |  89 +++
  pyme-web/doc/gpgme/Error-Strings.html              |  80 +++
  pyme-web/doc/gpgme/Error-Values.html               | 159 +++++
  pyme-web/doc/gpgme/Exchanging-Data.html            |  58 ++
  pyme-web/doc/gpgme/Exporting-Keys.html             | 101 +++
  pyme-web/doc/gpgme/Features.html                   |  59 ++
  pyme-web/doc/gpgme/File-Based-Data-Buffers.html    |  74 +++
  pyme-web/doc/gpgme/Function-and-Data-Index.html    | 380 ++++++++++++
  pyme-web/doc/gpgme/Generating-Keys.html            | 144 +++++
  pyme-web/doc/gpgme/Getting-Started.html            |  55 ++
  pyme-web/doc/gpgme/Hash-Algorithms.html            |  59 ++
  pyme-web/doc/gpgme/Header.html                     |  53 ++
  .../doc/gpgme/I_002fO-Callback-Example-GDK.html    |  85 +++
  .../gpgme/I_002fO-Callback-Example-GTK_002b.html   |  86 +++
  .../doc/gpgme/I_002fO-Callback-Example-Qt.html     |  99 +++
  pyme-web/doc/gpgme/I_002fO-Callback-Example.html   | 259 ++++++++
  pyme-web/doc/gpgme/I_002fO-Callback-Interface.html | 142 +++++
  pyme-web/doc/gpgme/Importing-Keys.html             | 171 +++++
  pyme-web/doc/gpgme/Included-Certificates.html      |  70 +++
  pyme-web/doc/gpgme/Information-About-Keys.html     | 207 +++++++
  .../doc/gpgme/Information-About-Trust-Items.html   |  75 +++
  pyme-web/doc/gpgme/Introduction.html               |  53 ++
  pyme-web/doc/gpgme/Key-Listing-Mode.html           |  99 +++
  pyme-web/doc/gpgme/Key-Management.html             | 260 ++++++++
  pyme-web/doc/gpgme/Key-Signatures.html             | 130 ++++
  .../doc/gpgme/Largefile-Support-_0028LFS_0029.html | 110 ++++
  pyme-web/doc/gpgme/Library-Copying.html            | 542 ++++++++++++++++
  pyme-web/doc/gpgme/Library-Version-Check.html      |  97 +++
  pyme-web/doc/gpgme/Listing-Keys.html               | 204 ++++++
  pyme-web/doc/gpgme/Listing-Trust-Items.html        |  88 +++
  pyme-web/doc/gpgme/Locale.html                     |  69 +++
  pyme-web/doc/gpgme/Manipulating-Data-Buffers.html  |  45 ++
  pyme-web/doc/gpgme/Manipulating-Keys.html          |  63 ++
  pyme-web/doc/gpgme/Manipulating-Trust-Items.html   |  62 ++
  pyme-web/doc/gpgme/Memory-Based-Data-Buffers.html  | 107 ++++
  pyme-web/doc/gpgme/Multi-Threading.html            |  93 +++
  pyme-web/doc/gpgme/OpenPGP.html                    |  44 ++
  pyme-web/doc/gpgme/Overview.html                   |  57 ++
  pyme-web/doc/gpgme/Passphrase-Callback.html        | 101 +++
  pyme-web/doc/gpgme/Preparation.html                |  54 ++
  pyme-web/doc/gpgme/Progress-Meter-Callback.html    |  80 +++
  pyme-web/doc/gpgme/Protocol-Selection.html         |  60 ++
  pyme-web/doc/gpgme/Protocols-and-Engines.html      |  82 +++
  pyme-web/doc/gpgme/Public-Key-Algorithms.html      |  74 +++
  .../doc/gpgme/Registering-I_002fO-Callbacks.html   |  81 +++
  pyme-web/doc/gpgme/Run-Control.html                |  53 ++
  pyme-web/doc/gpgme/Selecting-Signers.html          |  64 ++
  pyme-web/doc/gpgme/Sign.html                       |  50 ++
  pyme-web/doc/gpgme/Signal-Handling.html            |  61 ++
  pyme-web/doc/gpgme/Signature-Notation-Data.html    |  85 +++
  pyme-web/doc/gpgme/Text-Mode.html                  |  63 ++
  pyme-web/doc/gpgme/Trust-Item-Management.html      |  68 ++
  pyme-web/doc/gpgme/Using-Automake.html             |  74 +++
  pyme-web/doc/gpgme/Using-External-Event-Loops.html |  74 +++
  pyme-web/doc/gpgme/Using-Libtool.html              |  44 ++
  pyme-web/doc/gpgme/Verify.html                     | 492 +++++++++++++++
  pyme-web/doc/gpgme/Waiting-For-Completion.html     |  77 +++
  pyme-web/doc/gpgme/gpgme.html                      | 251 --------
  pyme-web/doc/gpgme/gpgme_1.html                    |  76 ---
  pyme-web/doc/gpgme/gpgme_10.html                   |  61 --
  pyme-web/doc/gpgme/gpgme_11.html                   | 130 ----
  pyme-web/doc/gpgme/gpgme_12.html                   |  82 ---
  pyme-web/doc/gpgme/gpgme_13.html                   | 130 ----
  pyme-web/doc/gpgme/gpgme_14.html                   | 108 ----
  pyme-web/doc/gpgme/gpgme_15.html                   |  69 ---
  pyme-web/doc/gpgme/gpgme_16.html                   | 169 -----
  pyme-web/doc/gpgme/gpgme_17.html                   |  63 --
  pyme-web/doc/gpgme/gpgme_18.html                   |  63 --
  pyme-web/doc/gpgme/gpgme_19.html                   |  66 --
  pyme-web/doc/gpgme/gpgme_2.html                    |  79 ---
  pyme-web/doc/gpgme/gpgme_20.html                   | 120 ----
  pyme-web/doc/gpgme/gpgme_21.html                   | 102 ---
  pyme-web/doc/gpgme/gpgme_22.html                   | 108 ----
  pyme-web/doc/gpgme/gpgme_23.html                   | 237 -------
  pyme-web/doc/gpgme/gpgme_24.html                   | 154 -----
  pyme-web/doc/gpgme/gpgme_25.html                   | 248 --------
  pyme-web/doc/gpgme/gpgme_26.html                   | 107 ----
  pyme-web/doc/gpgme/gpgme_27.html                   |  80 ---
  pyme-web/doc/gpgme/gpgme_28.html                   |  67 --
  pyme-web/doc/gpgme/gpgme_29.html                   | 164 -----
  pyme-web/doc/gpgme/gpgme_3.html                    |  86 ---
  pyme-web/doc/gpgme/gpgme_30.html                   | 106 ----
  pyme-web/doc/gpgme/gpgme_31.html                   | 232 -------
  pyme-web/doc/gpgme/gpgme_32.html                   |  85 ---
  pyme-web/doc/gpgme/gpgme_33.html                   | 223 -------
  pyme-web/doc/gpgme/gpgme_34.html                   |  83 ---
  pyme-web/doc/gpgme/gpgme_35.html                   |  70 ---
  pyme-web/doc/gpgme/gpgme_36.html                   |  63 --
  pyme-web/doc/gpgme/gpgme_37.html                   |  66 --
  pyme-web/doc/gpgme/gpgme_38.html                   |  86 ---
  pyme-web/doc/gpgme/gpgme_39.html                   |  79 ---
  pyme-web/doc/gpgme/gpgme_4.html                    |  83 ---
  pyme-web/doc/gpgme/gpgme_40.html                   |  89 ---
  pyme-web/doc/gpgme/gpgme_41.html                   |  99 ---
  pyme-web/doc/gpgme/gpgme_42.html                   | 144 -----
  pyme-web/doc/gpgme/gpgme_43.html                   | 152 -----
  pyme-web/doc/gpgme/gpgme_44.html                   | 112 ----
  pyme-web/doc/gpgme/gpgme_45.html                   | 101 ---
  pyme-web/doc/gpgme/gpgme_46.html                   | 459 --------------
  pyme-web/doc/gpgme/gpgme_47.html                   | 292 ---------
  pyme-web/doc/gpgme/gpgme_48.html                   | 363 -----------
  pyme-web/doc/gpgme/gpgme_49.html                   | 209 -------
  pyme-web/doc/gpgme/gpgme_5.html                    |  74 ---
  pyme-web/doc/gpgme/gpgme_50.html                   |  88 ---
  pyme-web/doc/gpgme/gpgme_51.html                   | 208 -------
  pyme-web/doc/gpgme/gpgme_52.html                   | 154 -----
  pyme-web/doc/gpgme/gpgme_53.html                   | 291 ---------
  pyme-web/doc/gpgme/gpgme_54.html                   |  91 ---
  pyme-web/doc/gpgme/gpgme_55.html                   | 107 ----
  pyme-web/doc/gpgme/gpgme_56.html                   | 140 -----
  pyme-web/doc/gpgme/gpgme_57.html                   | 106 ----
  pyme-web/doc/gpgme/gpgme_58.html                   |  89 ---
  pyme-web/doc/gpgme/gpgme_59.html                   |  97 ---
  pyme-web/doc/gpgme/gpgme_6.html                    |  77 ---
  pyme-web/doc/gpgme/gpgme_60.html                   | 142 -----
  pyme-web/doc/gpgme/gpgme_61.html                   | 626 -------------------
  pyme-web/doc/gpgme/gpgme_62.html                   | 107 ----
  pyme-web/doc/gpgme/gpgme_63.html                   |  67 --
  pyme-web/doc/gpgme/gpgme_64.html                   |  95 ---
  pyme-web/doc/gpgme/gpgme_65.html                   | 233 -------
  pyme-web/doc/gpgme/gpgme_66.html                   |  65 --
  pyme-web/doc/gpgme/gpgme_67.html                   | 220 -------
  pyme-web/doc/gpgme/gpgme_68.html                   |  75 ---
  pyme-web/doc/gpgme/gpgme_69.html                   | 119 ----
  pyme-web/doc/gpgme/gpgme_7.html                    | 123 ----
  pyme-web/doc/gpgme/gpgme_70.html                   | 107 ----
  pyme-web/doc/gpgme/gpgme_71.html                   | 218 -------
  pyme-web/doc/gpgme/gpgme_72.html                   | 134 ----
  pyme-web/doc/gpgme/gpgme_73.html                   | 299 ---------
  pyme-web/doc/gpgme/gpgme_74.html                   | 103 ----
  pyme-web/doc/gpgme/gpgme_75.html                   | 104 ----
  pyme-web/doc/gpgme/gpgme_76.html                   | 118 ----
  pyme-web/doc/gpgme/gpgme_77.html                   |  95 ---
  pyme-web/doc/gpgme/gpgme_78.html                   |  71 ---
  pyme-web/doc/gpgme/gpgme_79.html                   | 686 ---------------------
  pyme-web/doc/gpgme/gpgme_8.html                    | 155 -----
  pyme-web/doc/gpgme/gpgme_80.html                   | 120 ----
  pyme-web/doc/gpgme/gpgme_81.html                   | 278 ---------
  pyme-web/doc/gpgme/gpgme_82.html                   | 272 --------
  pyme-web/doc/gpgme/gpgme_83.html                   | 180 ------
  pyme-web/doc/gpgme/gpgme_84.html                   |  99 ---
  pyme-web/doc/gpgme/gpgme_9.html                    | 104 ----
  pyme-web/doc/gpgme/gpgme_abt.html                  | 206 -------
  pyme-web/doc/gpgme/gpgme_fot.html                  |  53 --
  pyme-web/doc/gpgme/gpgme_ovr.html                  |  68 --
  pyme-web/doc/gpgme/gpgme_toc.html                  | 247 --------
  pyme-web/doc/gpgme/index.html                      | 497 ++++++++-------
  176 files changed, 9054 insertions(+), 13378 deletions(-)
 
 commit 163c1053dc761682f5a4231da163bdd0ff7162d7
 Author: belyi 
 Date:   Tue Apr 1 21:14:29 2008 +0000
 
     Update Home page to be a bit more visitor friendly.
 
  pyme-web/Makefile    |  2 +-
  pyme-web/default.css | 27 ++++++++++++++++++++
  pyme-web/index.html  | 70 +++++++++++++++++++++++++++++++++++-----------------
  3 files changed, 75 insertions(+), 24 deletions(-)
 
 commit 05db2d17d8fda0ab8c948bbdc0643dfc1466830d
 Author: belyi 
 Date:   Sun Mar 30 21:27:38 2008 +0000
 
     Add a rule to build binary distribution for Windows.
 
  pyme/Makefile | 16 ++++++++++++++--
  1 file changed, 14 insertions(+), 2 deletions(-)
 
 commit 57acb1089f5f8c24323ee62fc0a7f492a496b9c0
 Author: belyi 
 Date:   Sat Mar 29 22:50:11 2008 +0000
 
     Switch to using central location for python files (pycentral)
     Update docs rule to fix location of the python source files.
 
  pyme/Makefile             |  5 +++-
  pyme/debian/changelog     |  4 ++-
  pyme/debian/control       | 74 +++++------------------------------------------
  pyme/debian/dirs          |  2 --
  pyme/debian/docs          |  1 +
  pyme/debian/postinst.ex   | 48 ------------------------------
  pyme/debian/postrm.ex     | 38 ------------------------
  pyme/debian/preinst.ex    | 44 ----------------------------
  pyme/debian/prerm.ex      | 39 -------------------------
  pyme/debian/rules         | 50 ++++++--------------------------
  pyme/debian/setup.cfg-2.2 |  8 -----
  pyme/debian/setup.cfg-2.3 |  8 -----
  pyme/debian/setup.cfg-2.4 |  8 -----
  pyme/gpgme-h-clean.py     |  2 +-
  pyme/pyme/core.py         |  2 +-
  pyme/pyme/util.py         |  2 +-
  16 files changed, 28 insertions(+), 307 deletions(-)
 
 commit 2b56fd10517cfbcffaa4ba98d8ea42f40f0d38a9
 Author: belyi 
 Date:   Sun Mar 23 02:01:12 2008 +0000
 
     Turn SWIG's autodoc feature on. Ignore 'next' in the types which are lists now.
     Use new style for class declarations. Specify None as a default value for
     core.check_version() method. Update version.py for 0.8.0 version.
 
  pyme/examples/pygpa.py | 2 +-
  pyme/gpgme.i           | 5 +++++
  pyme/pyme/core.py      | 2 +-
  pyme/pyme/util.py      | 5 +++--
  pyme/pyme/version.py   | 6 +++---
  5 files changed, 13 insertions(+), 7 deletions(-)
 
 commit df5e25d7ee4dc0aa0d429f9d009322dd8ac33bb8
 Author: belyi 
 Date:   Thu Mar 20 19:07:00 2008 +0000
 
     Improve matching for DEPRECATED typedefs
 
  pyme/gpgme-h-clean.py | 4 ++--
  1 file changed, 2 insertions(+), 2 deletions(-)
 
 commit 78d8fc732848ac267ec65e9069265cd500587cdf
 Author: belyi 
 Date:   Wed Mar 19 19:28:40 2008 +0000
 
     Update API to use list when types containing 'next' field are return.
     Update examples accordingly
     Add verifydetails.py example
     Start adding bullets for 0.8.0 version.
 
  pyme/Makefile                   |  2 +-
  pyme/debian/changelog           | 14 +++++++-
  pyme/examples/PyGtkGpgKeys.py   | 53 +++++++++++++--------------
  pyme/examples/delkey.py         |  7 ++--
  pyme/examples/encrypt-to-all.py |  7 ++--
  pyme/examples/exportimport.py   |  7 ++--
  pyme/examples/pygpa.py          | 70 ++++++++++++++++--------------------
  pyme/examples/signverify.py     | 11 +++---
  pyme/examples/verifydetails.py  | 79 +++++++++++++++++++++++++++++++++++++++++
  pyme/gpgme.i                    | 19 +++++++++-
  10 files changed, 180 insertions(+), 89 deletions(-)
 
 commit 342d85b07475e7360bcd62804bf5facda039494f
 Author: belyi 
 Date:   Mon Mar 10 01:14:16 2008 +0000
 
     Change references to source files so that they point to the WebCVS browse
     location.
 
  pyme-web/doc/pyme/index.html                        | 2 +-
  pyme-web/doc/pyme/pyme.callbacks.html               | 2 +-
  pyme-web/doc/pyme/pyme.constants.data.encoding.html | 2 +-
  pyme-web/doc/pyme/pyme.constants.data.html          | 2 +-
  pyme-web/doc/pyme/pyme.constants.event.html         | 2 +-
  pyme-web/doc/pyme/pyme.constants.html               | 2 +-
  pyme-web/doc/pyme/pyme.constants.import.html        | 2 +-
  pyme-web/doc/pyme/pyme.constants.keylist.html       | 2 +-
  pyme-web/doc/pyme/pyme.constants.keylist.mode.html  | 2 +-
  pyme-web/doc/pyme/pyme.constants.md.html            | 2 +-
  pyme-web/doc/pyme/pyme.constants.pk.html            | 2 +-
  pyme-web/doc/pyme/pyme.constants.protocol.html      | 2 +-
  pyme-web/doc/pyme/pyme.constants.sig.html           | 2 +-
  pyme-web/doc/pyme/pyme.constants.sig.mode.html      | 2 +-
  pyme-web/doc/pyme/pyme.constants.sigsum.html        | 2 +-
  pyme-web/doc/pyme/pyme.constants.status.html        | 2 +-
  pyme-web/doc/pyme/pyme.constants.validity.html      | 2 +-
  pyme-web/doc/pyme/pyme.core.html                    | 2 +-
  pyme-web/doc/pyme/pyme.errors.html                  | 2 +-
  pyme-web/doc/pyme/pyme.html                         | 2 +-
  pyme-web/doc/pyme/pyme.util.html                    | 2 +-
  pyme-web/doc/pyme/pyme.version.html                 | 2 +-
  22 files changed, 22 insertions(+), 22 deletions(-)
 
 commit 4139dd1d066c1a6c892d84fe45dc3e6c4aa1b803
 Author: belyi 
 Date:   Sat Mar 8 18:21:08 2008 +0000
 
     Add core.check_version(None) to all examples since this function is used by
     Gpgme to do internal initialization. Update debian/rules to use dh_pysupport
     instead of deprecated dh_python.
 
  pyme/debian/rules               | 8 +++-----
  pyme/examples/PyGtkGpgKeys.py   | 7 ++++++-
  pyme/examples/delkey.py         | 2 ++
  pyme/examples/encrypt-to-all.py | 3 +++
  pyme/examples/exportimport.py   | 2 ++
  pyme/examples/genkey.py         | 1 +
  pyme/examples/inter-edit.py     | 3 +++
  pyme/examples/pygpa.py          | 5 +++++
  pyme/examples/sign.py           | 2 ++
  pyme/examples/signverify.py     | 2 ++
  pyme/examples/simple.py         | 2 ++
  pyme/examples/t-edit.py         | 3 +++
  12 files changed, 34 insertions(+), 6 deletions(-)
 
 commit ae76c6176457dd38e0634cbc17d794294a3a81d2
 Author: belyi 
 Date:   Wed Apr 12 22:20:38 2006 +0000
 
     Change name of internal package name from 'gpgme' to 'pygpgme' to avoid
     conflict with gpgme.dll on Windows.
     Fix build with SWIG 1.3.28.
     Change version to 0.7.1 in a preparation for new release.
 
  pyme/Makefile          |   3 +-
  pyme/debian/changelog  |  12 ++++
  pyme/gpgme.i           |  19 +++---
  pyme/pyme/callbacks.py |   1 -
  pyme/pyme/core.py      | 153 +++++++++++++++++++++++++------------------------
  pyme/pyme/errors.py    |  12 ++--
  pyme/pyme/util.py      |  10 ++--
  pyme/pyme/version.py   |   2 +-
  pyme/setup.py          |   4 +-
  9 files changed, 116 insertions(+), 100 deletions(-)
 
 commit d644383a76e9f83bc2d426628319e3c4a989dc2d
 Author: belyi 
 Date:   Sat Dec 17 01:34:53 2005 +0000
 
     Put all constants into pyme.constants package to avoid stepping on python
     reserved words.
     Add build rules for Mingw32 and Cygwin on Windows. Rules for Mingw under
     Debian are still to come.
     Fixed a small bug in pygpa.py example.
 
  pyme/Makefile                   | 11 ++++++++---
  pyme/examples/pygpa.py          |  3 ++-
  pyme/pyme/__init__.py           |  2 +-
  pyme/pyme/constants/__init__.py |  3 +++
  pyme/setup.py                   | 42 ++++++++++++++++++++++++++++++++++++-----
  5 files changed, 51 insertions(+), 10 deletions(-)
 
 commit 89eb370fcaa8adc9d219eadbaa579dde7bf06329
 Author: belyi 
 Date:   Mon Aug 1 03:08:32 2005 +0000
 
     Imported changes provided by Joost van Baal:
     Use dh_python in debian/rules and change the Section pyme belongs to from
     'libs' to 'python'.
 
  pyme/debian/control | 6 +++---
  pyme/debian/rules   | 2 ++
  2 files changed, 5 insertions(+), 3 deletions(-)
 
 commit ad76d10c2a77b45b7459c62131279e946b860891
 Author: belyi 
 Date:   Fri Jun 10 03:01:22 2005 +0000
 
     Update 'docs' rule in Makefile to build packages first to ensure that
     documentation is build for the current version of pyme and not for the
     installed one.
 
     Added 'callbacks' into the list of visible pyme modules (__all__ var.)
 
     Slightly updated INSTALL file.
 
  pyme/INSTALL          | 11 ++++++++---
  pyme/Makefile         |  4 ++--
  pyme/pyme/__init__.py |  2 +-
  3 files changed, 11 insertions(+), 6 deletions(-)
 
 commit 2fe1a81e00721698bfa6850b3db2eb85e43d1724
 Author: belyi 
 Date:   Wed Jun 8 16:16:18 2005 +0000
 
     Update pyme documentation to remove dead links to pyme.gpgme.html and
     pyme._gpgme.html
     Added reference to the installed GPGME and PyMe documentation to the head
     web page.
     Updated Makefile to install all *.html files and to clean *~ files in all
     subdirectories
 
  pyme-web/Makefile                     | 10 ++++++----
  pyme-web/doc/pyme/index.html          |  8 +++-----
  pyme-web/doc/pyme/pyme.callbacks.html |  8 --------
  pyme-web/doc/pyme/pyme.core.html      |  1 -
  pyme-web/doc/pyme/pyme.errors.html    |  8 --------
  pyme-web/doc/pyme/pyme.html           |  8 +++-----
  pyme-web/doc/pyme/pyme.util.html      |  8 --------
  pyme-web/index.html                   |  9 +++++++--
  8 files changed, 19 insertions(+), 41 deletions(-)
 
 commit 6aa34cce4ea0099e50b4936dfee59778157b8ca8
 Author: belyi 
 Date:   Wed Jun 8 15:18:20 2005 +0000
 
     Added pyme and gpgme documentation.
 
  pyme-web/doc/gpgme/gpgme.html                      | 251 ++++++++
  pyme-web/doc/gpgme/gpgme_1.html                    |  76 +++
  pyme-web/doc/gpgme/gpgme_10.html                   |  61 ++
  pyme-web/doc/gpgme/gpgme_11.html                   | 130 ++++
  pyme-web/doc/gpgme/gpgme_12.html                   |  82 +++
  pyme-web/doc/gpgme/gpgme_13.html                   | 130 ++++
  pyme-web/doc/gpgme/gpgme_14.html                   | 108 ++++
  pyme-web/doc/gpgme/gpgme_15.html                   |  69 +++
  pyme-web/doc/gpgme/gpgme_16.html                   | 169 +++++
  pyme-web/doc/gpgme/gpgme_17.html                   |  63 ++
  pyme-web/doc/gpgme/gpgme_18.html                   |  63 ++
  pyme-web/doc/gpgme/gpgme_19.html                   |  66 ++
  pyme-web/doc/gpgme/gpgme_2.html                    |  79 +++
  pyme-web/doc/gpgme/gpgme_20.html                   | 120 ++++
  pyme-web/doc/gpgme/gpgme_21.html                   | 102 +++
  pyme-web/doc/gpgme/gpgme_22.html                   | 108 ++++
  pyme-web/doc/gpgme/gpgme_23.html                   | 237 +++++++
  pyme-web/doc/gpgme/gpgme_24.html                   | 154 +++++
  pyme-web/doc/gpgme/gpgme_25.html                   | 248 ++++++++
  pyme-web/doc/gpgme/gpgme_26.html                   | 107 ++++
  pyme-web/doc/gpgme/gpgme_27.html                   |  80 +++
  pyme-web/doc/gpgme/gpgme_28.html                   |  67 ++
  pyme-web/doc/gpgme/gpgme_29.html                   | 164 +++++
  pyme-web/doc/gpgme/gpgme_3.html                    |  86 +++
  pyme-web/doc/gpgme/gpgme_30.html                   | 106 ++++
  pyme-web/doc/gpgme/gpgme_31.html                   | 232 +++++++
  pyme-web/doc/gpgme/gpgme_32.html                   |  85 +++
  pyme-web/doc/gpgme/gpgme_33.html                   | 223 +++++++
  pyme-web/doc/gpgme/gpgme_34.html                   |  83 +++
  pyme-web/doc/gpgme/gpgme_35.html                   |  70 +++
  pyme-web/doc/gpgme/gpgme_36.html                   |  63 ++
  pyme-web/doc/gpgme/gpgme_37.html                   |  66 ++
  pyme-web/doc/gpgme/gpgme_38.html                   |  86 +++
  pyme-web/doc/gpgme/gpgme_39.html                   |  79 +++
  pyme-web/doc/gpgme/gpgme_4.html                    |  83 +++
  pyme-web/doc/gpgme/gpgme_40.html                   |  89 +++
  pyme-web/doc/gpgme/gpgme_41.html                   |  99 +++
  pyme-web/doc/gpgme/gpgme_42.html                   | 144 +++++
  pyme-web/doc/gpgme/gpgme_43.html                   | 152 +++++
  pyme-web/doc/gpgme/gpgme_44.html                   | 112 ++++
  pyme-web/doc/gpgme/gpgme_45.html                   | 101 +++
  pyme-web/doc/gpgme/gpgme_46.html                   | 459 ++++++++++++++
  pyme-web/doc/gpgme/gpgme_47.html                   | 292 +++++++++
  pyme-web/doc/gpgme/gpgme_48.html                   | 363 +++++++++++
  pyme-web/doc/gpgme/gpgme_49.html                   | 209 +++++++
  pyme-web/doc/gpgme/gpgme_5.html                    |  74 +++
  pyme-web/doc/gpgme/gpgme_50.html                   |  88 +++
  pyme-web/doc/gpgme/gpgme_51.html                   | 208 +++++++
  pyme-web/doc/gpgme/gpgme_52.html                   | 154 +++++
  pyme-web/doc/gpgme/gpgme_53.html                   | 291 +++++++++
  pyme-web/doc/gpgme/gpgme_54.html                   |  91 +++
  pyme-web/doc/gpgme/gpgme_55.html                   | 107 ++++
  pyme-web/doc/gpgme/gpgme_56.html                   | 140 +++++
  pyme-web/doc/gpgme/gpgme_57.html                   | 106 ++++
  pyme-web/doc/gpgme/gpgme_58.html                   |  89 +++
  pyme-web/doc/gpgme/gpgme_59.html                   |  97 +++
  pyme-web/doc/gpgme/gpgme_6.html                    |  77 +++
  pyme-web/doc/gpgme/gpgme_60.html                   | 142 +++++
  pyme-web/doc/gpgme/gpgme_61.html                   | 626 +++++++++++++++++++
  pyme-web/doc/gpgme/gpgme_62.html                   | 107 ++++
  pyme-web/doc/gpgme/gpgme_63.html                   |  67 ++
  pyme-web/doc/gpgme/gpgme_64.html                   |  95 +++
  pyme-web/doc/gpgme/gpgme_65.html                   | 233 +++++++
  pyme-web/doc/gpgme/gpgme_66.html                   |  65 ++
  pyme-web/doc/gpgme/gpgme_67.html                   | 220 +++++++
  pyme-web/doc/gpgme/gpgme_68.html                   |  75 +++
  pyme-web/doc/gpgme/gpgme_69.html                   | 119 ++++
  pyme-web/doc/gpgme/gpgme_7.html                    | 123 ++++
  pyme-web/doc/gpgme/gpgme_70.html                   | 107 ++++
  pyme-web/doc/gpgme/gpgme_71.html                   | 218 +++++++
  pyme-web/doc/gpgme/gpgme_72.html                   | 134 ++++
  pyme-web/doc/gpgme/gpgme_73.html                   | 299 +++++++++
  pyme-web/doc/gpgme/gpgme_74.html                   | 103 ++++
  pyme-web/doc/gpgme/gpgme_75.html                   | 104 ++++
  pyme-web/doc/gpgme/gpgme_76.html                   | 118 ++++
  pyme-web/doc/gpgme/gpgme_77.html                   |  95 +++
  pyme-web/doc/gpgme/gpgme_78.html                   |  71 +++
  pyme-web/doc/gpgme/gpgme_79.html                   | 686 +++++++++++++++++++++
  pyme-web/doc/gpgme/gpgme_8.html                    | 155 +++++
  pyme-web/doc/gpgme/gpgme_80.html                   | 120 ++++
  pyme-web/doc/gpgme/gpgme_81.html                   | 278 +++++++++
  pyme-web/doc/gpgme/gpgme_82.html                   | 272 ++++++++
  pyme-web/doc/gpgme/gpgme_83.html                   | 180 ++++++
  pyme-web/doc/gpgme/gpgme_84.html                   |  99 +++
  pyme-web/doc/gpgme/gpgme_9.html                    | 104 ++++
  pyme-web/doc/gpgme/gpgme_abt.html                  | 206 +++++++
  pyme-web/doc/gpgme/gpgme_fot.html                  |  53 ++
  pyme-web/doc/gpgme/gpgme_ovr.html                  |  68 ++
  pyme-web/doc/gpgme/gpgme_toc.html                  | 247 ++++++++
  pyme-web/doc/gpgme/index.html                      | 251 ++++++++
  pyme-web/doc/pyme/index.html                       | 166 +++++
  pyme-web/doc/pyme/pyme.callbacks.html              |  50 ++
  .../doc/pyme/pyme.constants.data.encoding.html     |  48 ++
  pyme-web/doc/pyme/pyme.constants.data.html         |  29 +
  pyme-web/doc/pyme/pyme.constants.event.html        |  48 ++
  pyme-web/doc/pyme/pyme.constants.html              |  39 ++
  pyme-web/doc/pyme/pyme.constants.import.html       |  49 ++
  pyme-web/doc/pyme/pyme.constants.keylist.html      |  29 +
  pyme-web/doc/pyme/pyme.constants.keylist.mode.html |  48 ++
  pyme-web/doc/pyme/pyme.constants.md.html           |  58 ++
  pyme-web/doc/pyme/pyme.constants.pk.html           |  50 ++
  pyme-web/doc/pyme/pyme.constants.protocol.html     |  46 ++
  pyme-web/doc/pyme/pyme.constants.sig.html          |  29 +
  pyme-web/doc/pyme/pyme.constants.sig.mode.html     |  47 ++
  pyme-web/doc/pyme/pyme.constants.sigsum.html       |  55 ++
  pyme-web/doc/pyme/pyme.constants.status.html       | 117 ++++
  pyme-web/doc/pyme/pyme.constants.validity.html     |  50 ++
  pyme-web/doc/pyme/pyme.core.html                   | 254 ++++++++
  pyme-web/doc/pyme/pyme.errors.html                 |  90 +++
  pyme-web/doc/pyme/pyme.html                        | 166 +++++
  pyme-web/doc/pyme/pyme.util.html                   |  78 +++
  pyme-web/doc/pyme/pyme.version.html                |  37 ++
  pyme-web/index.html                                |   6 +-
  113 files changed, 14966 insertions(+), 1 deletion(-)
 
 commit 2d6fe54479f042644f7b0f3d2fe35877d2056144
 Author: belyi 
 Date:   Thu May 19 02:06:09 2005 +0000
 
     Added INSTALL file.
 
  pyme/INSTALL | 10 ++++++++++
  1 file changed, 10 insertions(+)
 
 commit d6892fff0c3cedf41dba4c25ab8608e7f2bc039c
 Author: belyi 
 Date:   Tue May 17 16:49:28 2005 +0000
 
     Update copyright note on simple.py
 
  pyme/examples/simple.py | 4 ++--
  1 file changed, 2 insertions(+), 2 deletions(-)
 
 commit c2cd9cdf5995843aad7b200b929db2969effc9d2
 Author: belyi 
 Date:   Tue May 17 15:03:58 2005 +0000
 
     Update simple.py to catch errors.
 
  pyme/examples/simple.py | 17 +++++++++++------
  1 file changed, 11 insertions(+), 6 deletions(-)
 
 commit eaedae7c6a0ea993caab067efe781a59b6769c44
 Author: belyi 
 Date:   Tue May 17 01:18:23 2005 +0000
 
     Added 'PYTHON = python' into Makefile for bug #1199122
 
  pyme/Makefile               | 1 +
  pyme/examples/signverify.py | 1 +
  2 files changed, 2 insertions(+)
 
 commit 56fd244bb2636a4d58629899ea3cde1d96428198
 Author: belyi 
 Date:   Wed Apr 27 21:37:06 2005 +0000
 
     Added pygpa example.
 
  pyme/debian/changelog     |    3 +-
  pyme/examples/pygpa.glade | 5546 +++++++++++++++++++++++++++++++++++++++++++++
  pyme/examples/pygpa.py    | 1459 ++++++++++++
  3 files changed, 7007 insertions(+), 1 deletion(-)
 
 commit 2d9a2a91a59ac3fee5410c953b7e0859e9e7cd35
 Author: belyi 
 Date:   Thu Apr 21 15:17:51 2005 +0000
 
     Change version to 0.7.0 due to the change in license.
 
  pyme/debian/changelog | 2 +-
  pyme/pyme/version.py  | 2 +-
  2 files changed, 2 insertions(+), 2 deletions(-)
 
 commit 94e34e38d742f145385bd235825b6ba1e30d8339
 Author: belyi 
 Date:   Thu Apr 21 03:53:12 2005 +0000
 
     Changed license on PyMe from GPL to LGPL.
     PyMe examples keep GPL license.
 
  pyme/COPYING.LESSER                  | 510 +++++++++++++++++++++++++++++++++++
  pyme/Makefile                        |  20 +-
  pyme/debian/changelog                |   4 +-
  pyme/debian/copyright                |  22 +-
  pyme/gpgme-h-clean.py                |  16 ++
  pyme/gpgme.i                         |  20 +-
  pyme/helpers.c                       |  20 +-
  pyme/helpers.h                       |  20 +-
  pyme/pyme/__init__.py                |  20 +-
  pyme/pyme/callbacks.py               |  20 +-
  pyme/pyme/constants/data/encoding.py |  20 +-
  pyme/pyme/constants/event.py         |  20 +-
  pyme/pyme/constants/import.py        |  20 +-
  pyme/pyme/constants/keylist/mode.py  |  20 +-
  pyme/pyme/constants/md.py            |  20 +-
  pyme/pyme/constants/pk.py            |  20 +-
  pyme/pyme/constants/protocol.py      |  20 +-
  pyme/pyme/constants/sig/mode.py      |  20 +-
  pyme/pyme/constants/sigsum.py        |  20 +-
  pyme/pyme/constants/status.py        |  20 +-
  pyme/pyme/constants/validity.py      |  20 +-
  pyme/pyme/core.py                    |  20 +-
  pyme/pyme/errors.py                  |  20 +-
  pyme/pyme/util.py                    |  20 +-
  pyme/pyme/version.py                 |  22 +-
  pyme/setup.py                        |  20 +-
  26 files changed, 761 insertions(+), 233 deletions(-)
 
 commit 0d8aa0f6335cb1506a37085095ed45173b099a02
 Author: belyi 
 Date:   Tue Apr 19 01:46:06 2005 +0000
 
     Added __hash__ and __eq__ methods to GpgmeWrapper to allow both Context()
     and Data() to be used as a dictionary key.
     Changed core.wait() function to always return a tuple. On timeout now it
     returns (0, None) instead of just None. Plus, return context is now a
     Context() object instead of a wrapper return by underlying gpgme.
 
  pyme/helpers.c    |  1 -
  pyme/pyme/core.py | 25 +++++++++++++++----------
  pyme/pyme/util.py |  9 +++++++++
  3 files changed, 24 insertions(+), 11 deletions(-)
 
 commit 63ff6d10637be1dcbcd78c939ac1ef1ac30b1024
 Author: belyi 
 Date:   Wed Apr 6 04:58:40 2005 +0000
 
     Made hook parameter optional in passphrase_cb and progress_cb.
     Allowed None for callbacks to unset ones set previously.
     Removed cleanup of exception in callbacks - now just retrieve the error code.
     Added prev_bad parameter in passphrase_cb since it can be used in
     change password protocols.
     Updated examples to follow new sets of arguments in callbacks
     Updated op_edit to check if passed key is None (otherwise gpgme dumps core)
     God rid of annoying warning "function declaration isn't a prototype" in
     helpers.c and helpers.h by changing from () to (void) list of arguments.
 
  pyme/debian/changelog       | 10 +++++---
  pyme/examples/signverify.py |  2 +-
  pyme/examples/t-edit.py     |  2 +-
  pyme/gpgme.i                | 18 +++++++++-----
  pyme/helpers.c              | 60 ++++++++++++++++++++++++++++++---------------
  pyme/helpers.h              |  4 +--
  pyme/pyme/callbacks.py      |  6 +++--
  pyme/pyme/core.py           | 47 +++++++++++++++++++++--------------
  pyme/pyme/errors.py         |  2 +-
  9 files changed, 96 insertions(+), 55 deletions(-)
 
 commit 8f0ab8138c7aa190936376ccbbf33bb09c64d6f1
 Author: belyi 
 Date:   Thu Mar 31 23:50:59 2005 +0000
 
     Added exception handling in passphrase_cb and edit_cb. If GPGMEError
     exception is thrown in those callbacks it will be converted into its
     core representation and return as an error code to the caller.
     On all other exceptions error code will be GPG_ERR_GENERAL.
 
  pyme/Makefile         |  1 +
  pyme/debian/changelog |  8 ++++++++
  pyme/gpgme.i          | 20 ++++++++++++++------
  pyme/helpers.c        | 51 +++++++++++++++++++++++++++++++++++++++++++++------
  pyme/helpers.h        |  3 +++
  5 files changed, 71 insertions(+), 12 deletions(-)
 
 commit 9903d1fb11231e7e3d920e58d1ecb674c5988b07
 Author: belyi 
 Date:   Thu Mar 31 05:12:15 2005 +0000
 
     Remove workaround from Context.wait() method since the bug report and
     patch fixing gpgme_wait's behavior is sent to GPMGE developers already.
     Added errorcheck into op_edit() so that it can report an error.
 
  pyme/pyme/core.py | 10 +++++-----
  1 file changed, 5 insertions(+), 5 deletions(-)
 
 commit 45e8a5f4e13d3ca797ec3b0037242874a6be5562
 Author: belyi 
 Date:   Sat Mar 26 19:44:18 2005 +0000
 
-    Updated verion number to 0.6.2 in version.py
+    Updated version number to 0.6.2 in version.py
     Added examples/*.glade files into documentation package.
 
  pyme/debian/examples | 1 +
  pyme/pyme/version.py | 2 +-
  2 files changed, 2 insertions(+), 1 deletion(-)
 
 commit 270b87bb40e180cb6e8f1de9a0e8161525ffa4ab
 Author: belyi 
 Date:   Sat Mar 26 19:31:14 2005 +0000
 
     Updated debian/changelog regarding PyGtkGpgKeys example and a fix in errors.
 
  pyme/debian/changelog | 5 ++++-
  1 file changed, 4 insertions(+), 1 deletion(-)
 
 commit ea4682009a506db91e5174ffd038fe7e4406b591
 Author: belyi 
 Date:   Sat Mar 26 19:25:36 2005 +0000
 
     Added handling of right mouse button click.
     Changed reporting a string instead of a number on key generation failure.
 
  pyme/examples/PyGtkGpgKeys.glade |  2 ++
  pyme/examples/PyGtkGpgKeys.py    | 30 +++++++++++++++++++++++++++---
  2 files changed, 29 insertions(+), 3 deletions(-)
 
 commit f65ad1a703d0098a3204fb8527a54d253e5847e7
 Author: belyi 
 Date:   Sat Mar 26 18:11:11 2005 +0000
 
     Added another column indicating if a key has a secret part.
     Automated generation of the View menu from the view field of the KeyColumn
     class.
 
  pyme/examples/PyGtkGpgKeys.glade | 93 ++--------------------------------------
  pyme/examples/PyGtkGpgKeys.py    | 74 +++++++++++++++++---------------
  2 files changed, 44 insertions(+), 123 deletions(-)
 
 commit b54e83a7a7a5785502f3c7e8b95f15e23b40e65a
 Author: belyi 
 Date:   Sat Mar 26 16:45:13 2005 +0000
 
     Small change to the way gtk.TreeModel object is used.
 
  pyme/examples/PyGtkGpgKeys.py | 21 ++++++++++-----------
  1 file changed, 10 insertions(+), 11 deletions(-)
 
 commit 7078db75cef4c1fd70cf03e37172bdb4f933fd1b
 Author: belyi 
 Date:   Fri Mar 25 23:33:06 2005 +0000
 
     Use more comprehansible error reporting since gpgme_strerror_r returns None
     all the time.
 
  pyme/pyme/errors.py | 6 +++---
  1 file changed, 3 insertions(+), 3 deletions(-)
 
 commit 151213f4344d9984975721440af07de09e3df61c
 Author: belyi 
 Date:   Fri Mar 25 04:30:17 2005 +0000
 
     Improved PyGtkGpgKeys example to manage owner_trust on keys.
-    Added another example inter-edit.py which is just a hepler to write
+    Added another example inter-edit.py which is just a helper to write
     scripts for Context.op_edit() command.
 
  pyme/examples/PyGtkGpgKeys.glade | 78 ++++++++++++++++++++++++++++++++++++++++
  pyme/examples/PyGtkGpgKeys.py    | 68 +++++++++++++++++++++++++++++++----
  pyme/examples/inter-edit.py      | 54 ++++++++++++++++++++++++++++
  pyme/examples/t-edit.py          | 18 ++++++++++
  4 files changed, 212 insertions(+), 6 deletions(-)
 
 commit fc7235af217bcee5231ce7fbd7f234712d5ad3b0
 Author: belyi 
 Date:   Fri Mar 25 00:30:39 2005 +0000
 
     Updated PyGtkGpgKeys example to include import, export and reload
-    functionality. Also added ability to remove number of keys simultanously.
+    functionality. Also added ability to remove number of keys simultaneously.
     Rearanged how KeyColumn is used to avoid unnecessary sorts and duplication
     of information in different parts of the code.
 
  pyme/examples/PyGtkGpgKeys.glade |  86 +++++++++-
  pyme/examples/PyGtkGpgKeys.py    | 332 ++++++++++++++++++++++++++++-----------
  2 files changed, 325 insertions(+), 93 deletions(-)
 
 commit 9f65749ccb1b7cab562e19c03f4371d5f7d94912
 Author: belyi 
 Date:   Thu Mar 24 05:51:03 2005 +0000
 
     Added example of PyGTK+ and PyMe integration.
     For now it does only simple things - listing, deleting, and generating keys.
 
  pyme/examples/PyGtkGpgKeys.glade  | 1321 +++++++++++++++++++++++++++++++++++++
  pyme/examples/PyGtkGpgKeys.gladep |    8 +
  pyme/examples/PyGtkGpgKeys.py     |  424 ++++++++++++
  3 files changed, 1753 insertions(+)
 
 commit 59e23f32c3b46413c9ec09e23e1a385a110fb103
 Author: belyi 
 Date:   Thu Mar 24 05:44:58 2005 +0000
 
-    Added wait method Context class which handles asynchornous calls a little
+    Added wait method Context class which handles asynchronous calls a little
     bit better than the one generated by SWIG.
 
  pyme/debian/changelog |  7 +++++++
  pyme/gpgme.i          |  1 +
  pyme/pyme/core.py     | 40 ++++++++++++++++++++++++++++++++++++++++
  3 files changed, 48 insertions(+)
 
 commit 4c1b5259e4985df2cba0ae4fc09f12cd94603a75
 Author: belyi 
 Date:   Tue Mar 22 18:29:31 2005 +0000
 
     Added correct handling of Context.op_edit() method.
     Added example/t-edit.py showing usage for this method.
     Output of this example should match output of the  tests/gpg/t-edit
     from the GPGME test suite.
     Remove unused static function from helpers.c
 
  pyme/examples/t-edit.py | 38 ++++++++++++++++++++++++++++++++++++++
  pyme/gpgme.i            | 36 ++++++++++++++++++++++++++++++++++++
  pyme/helpers.c          | 36 ------------------------------------
  pyme/pyme/core.py       |  5 ++++-
  4 files changed, 78 insertions(+), 37 deletions(-)
 
 commit dc587e215283bfef2dd594f86a7b2945f74f5155
 Author: belyi 
 Date:   Sat Mar 19 01:43:59 2005 +0000
 
     Update changelog to include note about deprecated function in 0.6.1 release
 
  pyme/debian/changelog           | 3 ++-
  pyme/examples/encrypt-to-all.py | 3 +--
  2 files changed, 3 insertions(+), 3 deletions(-)
 
 commit 86de4b3ad777f980ccf7ba3462c85bbe1787d1fd
 Author: belyi 
 Date:   Sat Mar 19 01:40:07 2005 +0000
 
     Remove deprecated functions from helpers.[ch]
     Use gpgme-h-clean.py to remove deprecated functions and typedefs from
     the GPGME header file. This will reduce the number of unused methods.
 
  pyme/Makefile         |  4 ++--
  pyme/gpgme-h-clean.py | 26 ++++++++++++++++++++++++++
  pyme/helpers.c        |  8 --------
  pyme/helpers.h        |  2 --
  4 files changed, 28 insertions(+), 12 deletions(-)
 
 commit 2483efcbd0d73c628c4d7717928a766c3b58f0aa
 Author: belyi 
 Date:   Fri Mar 18 22:15:52 2005 +0000
 
     Update copyright and author values in pyme/version.py
     Create rules to build distribution files - one full and one without
     debian bits.
 
  pyme/Makefile        | 28 ++++++++++++++++++++++------
  pyme/pyme/version.py | 12 ++++++------
  2 files changed, 28 insertions(+), 12 deletions(-)
 
 commit 168593285380f5a7805f3dd08657d429a72d3621
 Author: belyi 
 Date:   Fri Mar 18 19:09:33 2005 +0000
 
     Added package building for python2.4
 
-    Updated copyright notes to include myslef and avoid confusion who's the
+    Updated copyright notes to include myself and avoid confusion who's the
     maintainer. In John's own words: "I'd prefer to just step out of the picture".
     Jonh's copyright notice left intact.
 
  pyme/Makefile                        |  6 +++---
  pyme/debian/changelog                |  7 +++++++
  pyme/debian/control                  | 30 +++++++++++++++++++++++++++---
  pyme/debian/copyright                | 10 ++++------
  pyme/debian/rules                    |  4 ++++
  pyme/debian/setup.cfg-2.4            |  8 ++++++++
  pyme/examples/genkey.py              |  4 ++--
  pyme/gpgme.i                         |  4 ++--
  pyme/helpers.c                       |  4 ++--
  pyme/helpers.h                       |  4 ++--
  pyme/pyme/__init__.py                |  4 ++--
  pyme/pyme/callbacks.py               |  4 ++--
  pyme/pyme/constants/data/encoding.py |  4 ++--
  pyme/pyme/constants/event.py         |  4 ++--
  pyme/pyme/constants/import.py        |  4 ++--
  pyme/pyme/constants/keylist/mode.py  |  4 ++--
  pyme/pyme/constants/md.py            |  4 ++--
  pyme/pyme/constants/pk.py            |  4 ++--
  pyme/pyme/constants/protocol.py      |  4 ++--
  pyme/pyme/constants/sig/mode.py      |  4 ++--
  pyme/pyme/constants/sigsum.py        |  4 ++--
  pyme/pyme/constants/status.py        |  4 ++--
  pyme/pyme/constants/validity.py      |  4 ++--
  pyme/pyme/core.py                    |  4 ++--
  pyme/pyme/errors.py                  |  4 ++--
  pyme/pyme/util.py                    |  4 ++--
  pyme/pyme/version.py                 |  2 +-
  pyme/setup.py                        |  3 ++-
  28 files changed, 96 insertions(+), 54 deletions(-)
 
 commit 6dbbb252771133724b2879ed6d767cd708196dae
 Author: belyi 
 Date:   Fri Mar 18 18:04:35 2005 +0000
 
     Remove the note about gpgme.i to be generated - it's been the primary source
     for some time.
 
  pyme/gpgme.i | 6 ------
  1 file changed, 6 deletions(-)
 
 commit 9d449fa4889c6bda6d14583c0625b8d5c4ffe759
 Author: belyi 
 Date:   Fri May 7 18:31:22 2004 +0000
 
     Added my copyright in genkey.py since there's enough changes made.
     Updated signverify to use only keys generated by genkey.py, to check
       that keys added to singers are able to sign and to check that the
       list of signers is not empty. The last check is necessary to prevent
       signing with the key of the user running signverify.py script.
     Added delkey.py script to delete keys generated by genkey.py
     Added exportimport.py example for key export/import.
 
  pyme/examples/delkey.py       | 29 +++++++++++++++++
  pyme/examples/exportimport.py | 76 +++++++++++++++++++++++++++++++++++++++++++
  pyme/examples/genkey.py       |  6 ++--
  pyme/examples/signverify.py   | 18 ++++++----
  4 files changed, 119 insertions(+), 10 deletions(-)
 
 commit df98c8d28245ad2c14b0ab50fc8f8932853bec8b
 Author: belyi 
 Date:   Tue May 4 17:34:15 2004 +0000
 
     Added examples/signverify.py for unattended sing/verify.
     Updated examples/genkey.py to work correctly.
     Updated gpgme.i to allow None as a value for gpgme_data_t
 
  pyme/examples/genkey.py     | 14 ++-------
  pyme/examples/signverify.py | 72 +++++++++++++++++++++++++++++++++++++++++++++
  pyme/gpgme.i                | 21 ++++++++-----
  3 files changed, 87 insertions(+), 20 deletions(-)
 
 commit ba45931abf530ab89ead46d7233ff1b62b629a18
 Author: belyi 
 Date:   Thu Apr 8 16:15:09 2004 +0000
 
     Ensure that we support only python2.2 and up. :-)
     Use generators in core.Context class which makes pyme.aux obsolete
-    Remove importing future nested_scopes since they are standart starting
+    Remove importing future nested_scopes since they are standard starting
     with python2.2
 
  pyme/pyme/__init__.py |  5 ++---
  pyme/pyme/aux.py      | 56 ---------------------------------------------------
  pyme/pyme/core.py     | 15 +++++++++++---
  pyme/pyme/errors.py   |  1 -
  pyme/pyme/util.py     |  2 +-
  5 files changed, 15 insertions(+), 64 deletions(-)
 
 commit 4e9be5a55ecffa4da7ad5c192cc892eddaaa9586
 Author: belyi 
 Date:   Sun Mar 21 03:53:30 2004 +0000
 
     Small change to index.html
     Added clean: rule to the Makefile
 
  pyme-web/Makefile   | 3 +++
  pyme-web/index.html | 6 +++---
  2 files changed, 6 insertions(+), 3 deletions(-)
 
 commit 2efb95176f4edf56ed61c9ac0c3aa09c56534df0
 Author: belyi 
 Date:   Sun Mar 21 03:00:32 2004 +0000
 
     Added Makefile rules for pyme module installation.
 
  pyme/Makefile | 5 ++++-
  1 file changed, 4 insertions(+), 1 deletion(-)
 
 commit 2b83d5d8b513029cc3e54f2fa502ccc85618104b
 Author: belyi 
 Date:   Sun Mar 21 02:29:54 2004 +0000
 
     Decorative change.
 
  pyme/pyme/aux.py | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)
 
 commit e3478015d763a036c1d806ae01433fce59712204
 Author: belyi 
 Date:   Sun Mar 21 02:25:55 2004 +0000
 
     Added RCS Id: tags
 
  pyme/Makefile                           | 1 +
  pyme/examples/encrypt-to-all.py         | 3 ++-
  pyme/examples/genkey.py                 | 3 ++-
  pyme/examples/sign.py                   | 3 ++-
  pyme/examples/simple.py                 | 3 ++-
  pyme/gpgme.i                            | 1 +
  pyme/helpers.c                          | 1 +
  pyme/helpers.h                          | 1 +
  pyme/pyme/__init__.py                   | 1 +
  pyme/pyme/aux.py                        | 1 +
  pyme/pyme/callbacks.py                  | 1 +
  pyme/pyme/constants/__init__.py         | 2 ++
  pyme/pyme/constants/data/__init__.py    | 2 ++
  pyme/pyme/constants/data/encoding.py    | 1 +
  pyme/pyme/constants/event.py            | 1 +
  pyme/pyme/constants/import.py           | 1 +
  pyme/pyme/constants/keylist/__init__.py | 2 ++
  pyme/pyme/constants/keylist/mode.py     | 1 +
  pyme/pyme/constants/md.py               | 1 +
  pyme/pyme/constants/pk.py               | 1 +
  pyme/pyme/constants/protocol.py         | 1 +
  pyme/pyme/constants/sig/__init__.py     | 2 ++
  pyme/pyme/constants/sig/mode.py         | 1 +
  pyme/pyme/constants/sigsum.py           | 1 +
  pyme/pyme/constants/status.py           | 1 +
  pyme/pyme/constants/validity.py         | 1 +
  pyme/pyme/core.py                       | 1 +
  pyme/pyme/errors.py                     | 1 +
  pyme/pyme/util.py                       | 1 +
  pyme/pyme/version.py                    | 2 ++
  30 files changed, 39 insertions(+), 4 deletions(-)
 
 commit b3b3712645332c5bc3e8d9d557aab21d48ff0f86
 Author: belyi 
 Date:   Sun Mar 21 02:07:36 2004 +0000
 
     Added Id: RCS tags to all files.
 
  pyme-web/Makefile   | 2 ++
  pyme-web/index.html | 3 ++-
  2 files changed, 4 insertions(+), 1 deletion(-)
 
 commit 6aea2426beaaa8c43e6f2310a37a2737c0c3a1b5
 Author: belyi 
 Date:   Sun Mar 21 01:50:55 2004 +0000
 
     Update example on the init pyme.html page to match simple.py example.
     Fix core.py to use getcode() instead of getvalue() method of the exception.
 
  pyme/pyme/__init__.py | 22 ++++++++++++++--------
  pyme/pyme/core.py     |  4 ++--
  2 files changed, 16 insertions(+), 10 deletions(-)
 
 commit dee337455ffd624d3f83e1c159c4bb2cefc692c9
 Author: belyi 
 Date:   Sat Mar 20 20:32:29 2004 +0000
 
     Added Makefile to simplify publishing web files.
 
  pyme-web/Makefile | 7 +++++++
  1 file changed, 7 insertions(+)
 
 commit af7129baa8260697d85c2ddb434562e8a80b62d8
 Author: belyi 
 Date:   Sat Mar 20 20:15:53 2004 +0000
 
-    Added minimum of formating and SF icon.
+    Added minimum of formatting and SF icon.
 
  pyme-web/index.html | 18 +++++++++++-------
  1 file changed, 11 insertions(+), 7 deletions(-)
 
 commit 2e64dcbf99cee796b51667b04d8961e390edde87
 Author: belyi 
 Date:   Sat Mar 20 18:30:09 2004 +0000
 
     Initial revision
 
  pyme-web/index.html | 33 +++++++++++++++++++++++++++++++++
  1 file changed, 33 insertions(+)
 
 commit 1c51644b3d0b6611422d971758e35f303d2ad5df
 Author: belyi 
 Date:   Sat Mar 20 05:10:46 2004 +0000
 
     Update examples and package information on the initial pyme doc page.
 
  pyme/pyme/__init__.py | 27 ++++++++++++---------------
  1 file changed, 12 insertions(+), 15 deletions(-)
 
 commit b2d31b0bfbffdff5247d6db4e3c95140cc1b1f19
 Author: belyi 
 Date:   Sat Mar 20 04:47:42 2004 +0000
 
     Deleted unnecessary files.
     Updated debian/control to remove dependency on python-xml package since there's
     none now.
     Move example files from 'doc' into separate control file.
     Update debian/rules to build documentation from *.py files and to exclude
     CVS directories from the installation.
 
  pyme/Makefile                   |  26 ++-----
  pyme/debian/control             |   8 +--
  pyme/debian/docs                |   1 -
  pyme/debian/ex.package.doc-base |  22 ------
  pyme/debian/examples            |   1 +
  pyme/debian/manpage.1.ex        |  60 ----------------
  pyme/debian/manpage.sgml.ex     | 152 ----------------------------------------
  pyme/debian/rules               |  12 ++--
  8 files changed, 15 insertions(+), 267 deletions(-)
 
 commit 1b517dd9b82a433499b4696b06d94d756cd36e53
 Author: belyi 
 Date:   Sat Mar 20 02:59:15 2004 +0000
 
     Remove doc/gpgme directory containing GPGME documentation since this belongs
     to a different project. Need to add reference in our documentation.
 
  pyme/doc/gpgme/fdl.texi     |  402 ------
  pyme/doc/gpgme/gpgme.texi   | 3372 -------------------------------------------
  pyme/doc/gpgme/gpl.texi     |  397 -----
  pyme/doc/gpgme/version.texi |    4 -
  4 files changed, 4175 deletions(-)
 
 commit 95d7d171da115a0fedfe2a4a7e5acc8aa408f673
 Author: belyi 
 Date:   Sat Mar 20 02:45:03 2004 +0000
 
     Change debian/rules to generate files by swig during build and to cleanup
     those files on 'clean' rule.
     Plus, leave generated gpgme_wrap.c in the root directory instead of moving
     it into subdirectory 'generated'.
 
  pyme/Makefile     | 8 +++-----
  pyme/debian/rules | 3 ++-
  pyme/setup.py     | 2 +-
  3 files changed, 6 insertions(+), 7 deletions(-)
 
 commit 545b3d90d445c5c78e8d72b2c1780863e02c789a
 Author: belyi 
 Date:   Sat Mar 20 02:18:01 2004 +0000
 
     Initial revision
 
  pyme/COPYING                            |  340 ++++
  pyme/ChangeLog                          |  802 ++++++++
  pyme/Makefile                           |   79 +
  pyme/debian/README.Debian               |    6 +
  pyme/debian/changelog                   |   19 +
  pyme/debian/control                     |   68 +
  pyme/debian/copyright                   |   27 +
  pyme/debian/dirs                        |    2 +
  pyme/debian/docs                        |    2 +
  pyme/debian/ex.package.doc-base         |   22 +
  pyme/debian/manpage.1.ex                |   60 +
  pyme/debian/manpage.sgml.ex             |  152 ++
  pyme/debian/postinst.ex                 |   48 +
  pyme/debian/postrm.ex                   |   38 +
  pyme/debian/preinst.ex                  |   44 +
  pyme/debian/prerm.ex                    |   39 +
  pyme/debian/rules                       |  130 ++
  pyme/debian/setup.cfg-2.2               |    8 +
  pyme/debian/setup.cfg-2.3               |    8 +
  pyme/doc/gpgme/fdl.texi                 |  402 ++++
  pyme/doc/gpgme/gpgme.texi               | 3372 +++++++++++++++++++++++++++++++
  pyme/doc/gpgme/gpl.texi                 |  397 ++++
  pyme/doc/gpgme/version.texi             |    4 +
  pyme/examples/encrypt-to-all.py         |   63 +
  pyme/examples/genkey.py                 |   55 +
  pyme/examples/sign.py                   |   28 +
  pyme/examples/simple.py                 |   44 +
  pyme/gpgme.i                            |  191 ++
  pyme/helpers.c                          |  139 ++
  pyme/helpers.h                          |   29 +
  pyme/pyme/__init__.py                   |  134 ++
  pyme/pyme/aux.py                        |   55 +
  pyme/pyme/callbacks.py                  |   45 +
  pyme/pyme/constants/__init__.py         |    2 +
  pyme/pyme/constants/data/__init__.py    |    2 +
  pyme/pyme/constants/data/encoding.py    |   19 +
  pyme/pyme/constants/event.py            |   19 +
  pyme/pyme/constants/import.py           |   19 +
  pyme/pyme/constants/keylist/__init__.py |    2 +
  pyme/pyme/constants/keylist/mode.py     |   19 +
  pyme/pyme/constants/md.py               |   19 +
  pyme/pyme/constants/pk.py               |   19 +
  pyme/pyme/constants/protocol.py         |   19 +
  pyme/pyme/constants/sig/__init__.py     |    2 +
  pyme/pyme/constants/sig/mode.py         |   19 +
  pyme/pyme/constants/sigsum.py           |   19 +
  pyme/pyme/constants/status.py           |   19 +
  pyme/pyme/constants/validity.py         |   19 +
  pyme/pyme/core.py                       |  367 ++++
  pyme/pyme/errors.py                     |   46 +
  pyme/pyme/util.py                       |   61 +
  pyme/pyme/version.py                    |   39 +
  pyme/setup.py                           |   60 +
  53 files changed, 7642 insertions(+)
 
 commit a3d5a442dc713b6c4d6fc4134db5b47e379dc41d
 Author: root 
 Date:   Fri Mar 19 14:12:30 2004 +0000
 
     initial checkin
 
  CVSROOT/checkoutlist | 13 +++++++++++++
  CVSROOT/commitinfo   | 15 +++++++++++++++
  CVSROOT/config       | 21 +++++++++++++++++++++
  CVSROOT/cvswrappers  | 19 +++++++++++++++++++
  CVSROOT/editinfo     | 21 +++++++++++++++++++++
  CVSROOT/loginfo      | 26 ++++++++++++++++++++++++++
  CVSROOT/modules      | 26 ++++++++++++++++++++++++++
  CVSROOT/notify       | 12 ++++++++++++
  CVSROOT/rcsinfo      | 13 +++++++++++++
  CVSROOT/taginfo      | 20 ++++++++++++++++++++
  CVSROOT/verifymsg    | 21 +++++++++++++++++++++
  11 files changed, 207 insertions(+)
diff --git a/lang/python/doc/rst/gpgme-python-howto.rst b/lang/python/doc/rst/gpgme-python-howto.rst
index 3fd8a4d0..4cbb929a 100644
--- a/lang/python/doc/rst/gpgme-python-howto.rst
+++ b/lang/python/doc/rst/gpgme-python-howto.rst
@@ -1,2947 +1,2947 @@
 .. _intro:
 
 Introduction
 ============
 
 +-----------------------------------+-----------------------------------+
 | Version:                          | 0.1.4                             |
 +-----------------------------------+-----------------------------------+
 | GPGME Version:                    | 1.12.0                            |
 +-----------------------------------+-----------------------------------+
 | Author:                           | `Ben                              |
 |                                   | McGinnes `__          |
 |                                   |                    |
 +-----------------------------------+-----------------------------------+
 | Author GPG Key:                   | DB4724E6FA4286C92B4E55C4321E4E237 |
 |                                   | 3590E5D                           |
 +-----------------------------------+-----------------------------------+
 | Language:                         | Australian English, British       |
 |                                   | English                           |
 +-----------------------------------+-----------------------------------+
 | xml:lang:                         | en-AU, en-GB, en                  |
 +-----------------------------------+-----------------------------------+
 
 This document provides basic instruction in how to use the GPGME Python
 bindings to programmatically leverage the GPGME library.
 
 .. _py2-vs-py3:
 
 Python 2 versus Python 3
 ------------------------
 
 Though the GPGME Python bindings themselves provide support for both
 Python 2 and 3, the focus is unequivocally on Python 3 and specifically
 from Python 3.4 and above. As a consequence all the examples and
 instructions in this guide use Python 3 code.
 
 Much of it will work with Python 2, but much of it also deals with
 Python 3 byte literals, particularly when reading and writing data.
 Developers concentrating on Python 2.7, and possibly even 2.6, will need
 to make the appropriate modifications to support the older string and
 unicode types as opposed to bytes.
 
 There are multiple reasons for concentrating on Python 3; some of which
 relate to the immediate integration of these bindings, some of which
 relate to longer term plans for both GPGME and the python bindings and
 some of which relate to the impending EOL period for Python 2.7.
 Essentially, though, there is little value in tying the bindings to a
 version of the language which is a dead end and the advantages offered
 by Python 3 over Python 2 make handling the data types with which GPGME
 deals considerably easier.
 
 .. _howto-python3-examples:
 
 Examples
 --------
 
 All of the examples found in this document can be found as Python 3
 scripts in the ``lang/python/examples/howto`` directory.
 
 Unofficial Drafts
 -----------------
 
 In addition to shipping with each release of GPGME, there is a section
 on locations to read or download `draft editions <#draft-editions>`__ of
 this document from at the end of it. These are unofficial versions
 produced in between major releases.
 
 .. _new-stuff:
 
 What\'s New
 -----------
 
 Full details of what is new are now available in the `What\'s
 New `__ file and archives of the preceding *What\'s
 New* sections are available in the `What Was New `__ file.
 
 .. _new-stuff-1-13-0:
 
 New in GPGME 1·13·0
 ~~~~~~~~~~~~~~~~~~~
 
 See the `What\'s New `__ document for what
 is new in version 1.13.0.
 
 .. _new-stuff-1-12-0:
 
 New in GPGME 1·12·0
 ~~~~~~~~~~~~~~~~~~~
 
 See the `What Was New `__ document for
 what was new in version 1.12.0.
 
 GPGME Concepts
 ==============
 
 .. _gpgme-c-api:
 
 A C API
 -------
 
 Unlike many modern APIs with which programmers will be more familiar
 with these days, the GPGME API is a C API. The API is intended for use
 by C coders who would be able to access its features by including the
 ``gpgme.h`` header file with their own C source code and then access its
 functions just as they would any other C headers.
 
 This is a very effective method of gaining complete access to the API
 and in the most efficient manner possible. It does, however, have the
 drawback that it cannot be directly used by other languages without some
 means of providing an interface to those languages. This is where the
 need for bindings in various languages stems.
 
 .. _gpgme-python-bindings:
 
 Python bindings
 ---------------
 
 The Python bindings for GPGME provide a higher level means of accessing
 the complete feature set of GPGME itself. It also provides a more
 pythonic means of calling these API functions.
 
 The bindings are generated dynamically with SWIG and the copy of
 ``gpgme.h`` generated when GPGME is compiled.
 
 This means that a version of the Python bindings is fundamentally tied
 to the exact same version of GPGME used to generate that copy of
 ``gpgme.h``.
 
 .. _gpgme-python-bindings-diffs:
 
 Difference between the Python bindings and other GnuPG Python packages
 ----------------------------------------------------------------------
 
 There have been numerous attempts to add GnuPG support to Python over
 the years. Some of the most well known are listed here, along with what
 differentiates them.
 
 .. _diffs-python-gnupg:
 
 The python-gnupg package maintained by Vinay Sajip
 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 
 This is arguably the most popular means of integrating GPG with Python.
 The package utilises the ``subprocess`` module to implement wrappers for
 the ``gpg`` and ``gpg2`` executables normally invoked on the command
 line (``gpg.exe`` and ``gpg2.exe`` on Windows).
 
 The popularity of this package stemmed from its ease of use and
 capability in providing the most commonly required features.
 
 Unfortunately it has been beset by a number of security issues in the
 past; most of which stemmed from using unsafe methods of accessing the
 command line via the ``subprocess`` calls. While some effort has been
 made over the last two to three years (as of 2018) to mitigate this,
 particularly by no longer providing shell access through those
 subprocess calls, the wrapper is still somewhat limited in the scope of
 its GnuPG features coverage.
 
 The python-gnupg package is available under the MIT license.
 
 .. _diffs-isis-gnupg:
 
 The gnupg package created and maintained by Isis Lovecruft
 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 
 In 2015 Isis Lovecruft from the Tor Project forked and then
 re-implemented the python-gnupg package as just gnupg. This new package
 also relied on subprocess to call the ``gpg`` or ``gpg2`` binaries, but
 did so somewhat more securely.
 
 The naming and version numbering selected for this package, however,
 resulted in conflicts with the original python-gnupg and since its
 functions were called in a different manner to python-gnupg, the release
 of this package also resulted in a great deal of consternation when
 people installed what they thought was an upgrade that subsequently
 broke the code relying on it.
 
 The gnupg package is available under the GNU General Public License
 version 3.0 (or any later version).
 
 .. _diffs-pyme:
 
 The PyME package maintained by Martin Albrecht
 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 
 This package is the origin of these bindings, though they are somewhat
 different now. For details of when and how the PyME package was folded
 back into GPGME itself see the `Short History `__
 document. [1]_
 
 The PyME package was first released in 2002 and was also the first
 attempt to implement a low level binding to GPGME. In doing so it
 provided access to considerably more functionality than either the
 ``python-gnupg`` or ``gnupg`` packages.
 
 The PyME package is only available for Python 2.6 and 2.7.
 
 Porting the PyME package to Python 3.4 in 2015 is what resulted in it
 being folded into the GPGME project and the current bindings are the end
 result of that effort.
 
 The PyME package is available under the same dual licensing as GPGME
 itself: the GNU General Public License version 2.0 (or any later
 version) and the GNU Lesser General Public License version 2.1 (or any
 later version).
 
 .. _gpgme-python-install:
 
 GPGME Python bindings installation
 ==================================
 
 .. _do-not-use-pypi:
 
 No PyPI
 -------
 
 Most third-party Python packages and modules are available and
 distributed through the Python Package Installer, known as PyPI.
 
 Due to the nature of what these bindings are and how they work, it is
 infeasible to install the GPGME Python bindings in the same way.
 
 This is because the bindings use SWIG to dynamically generate C bindings
 against ``gpgme.h`` and ``gpgme.h`` is generated from ``gpgme.h.in`` at
 compile time when GPGME is built from source. Thus to include a package
 in PyPI which actually built correctly would require either statically
 built libraries for every architecture bundled with it or a full
 implementation of C for each architecture.
 
 See the additional notes regarding `CFFI and SWIG <#snafu-cffi>`__ at
 the end of this section for further details.
 
 .. _gpgme-python-requirements:
 
 Requirements
 ------------
 
 The GPGME Python bindings only have three requirements:
 
 #. A suitable version of Python 2 or Python 3. With Python 2 that means
    CPython 2.7 and with Python 3 that means CPython 3.4 or higher.
 #. `SWIG `__.
 #. GPGME itself. Which also means that all of GPGME\'s dependencies must
    be installed too.
 
 .. _gpgme-python-recommendations:
 
 Recommended Additions
 ~~~~~~~~~~~~~~~~~~~~~
 
 Though none of the following are absolute requirements, they are all
 recommended for use with the Python bindings. In some cases these
 recommendations refer to which version(s) of CPython to use the bindings
 with, while others refer to third party modules which provide a
 significant advantage in some way.
 
 #. If possible, use Python 3 instead of 2.
 #. Favour a more recent version of Python since even 3.4 is due to reach
    EOL soon. In production systems and services, Python 3.6 should be
    robust enough to be relied on.
 #. If possible add the following Python modules which are not part of
    the standard library:
    `Requests `__,
    `Cython `__ and
    `hkp4py `__. Chances are quite
    high that at least the first one and maybe two of those will already
    be installed.
 
 Note that, as with Cython, some of the planned additions to the
 `Advanced <#advanced-use>`__ section, will bring with them additional
 requirements. Most of these will be fairly well known and commonly
 installed ones, however, which are in many cases likely to have already
 been installed on many systems or be familiar to Python programmers.
 
 Installation
 ------------
 
 Installing the Python bindings is effectively achieved by compiling and
 installing GPGME itself.
 
 Once SWIG is installed with Python and all the dependencies for GPGME
 are installed you only need to confirm that the version(s) of Python you
 want the bindings installed for are in your ``$PATH``.
 
 By default GPGME will attempt to install the bindings for the most
 recent or highest version number of Python 2 and Python 3 it detects in
 ``$PATH``. It specifically checks for the ``python`` and ``python3``
 executables first and then checks for specific version numbers.
 
 For Python 2 it checks for these executables in this order: ``python``,
 ``python2`` and ``python2.7``.
 
 For Python 3 it checks for these executables in this order: ``python3``,
 ``python3.7``, ``python3.6``, ``python3.5`` and ``python3.4``. [2]_
 
 On systems where ``python`` is actually ``python3`` and not ``python2``
 it may be possible that ``python2`` may be overlooked, but there have
 been no reports of that actually occurring as yet.
 
 In the three months or so since the release of Python 3.7.0 there has
 been extensive testing and work with these bindings with no issues
 specifically relating to the new version of Python or any of the new
 features of either the language or the bindings. This has also been the
 case with Python 3.7.1rc1. With that in mind and given the release of
 Python 3.7.1 is scheduled for around the same time as GPGME 1.12.0, the
 order of preferred Python versions has been changed to move Python 3.7
 ahead of Python 3.6.
 
 .. _install-gpgme:
 
 Installing GPGME
 ~~~~~~~~~~~~~~~~
 
 See the GPGME ``README`` file for details of how to install GPGME from
 source.
 
 .. _snafu:
 
 Known Issues
 ------------
 
 There are a few known issues with the current build process and the
 Python bindings. For the most part these are easily addressed should
 they be encountered.
 
 .. _snafu-a-swig-of-this-builds-character:
 
 Breaking Builds
 ~~~~~~~~~~~~~~~
 
 Occasionally when installing GPGME with the Python bindings included it
 may be observed that the ``make`` portion of that process induces a
 large very number of warnings and, eventually errors which end that part
 of the build process. Yet following that with ``make check`` and
 ``make install`` appears to work seamlessly.
 
 The cause of this is related to the way SWIG needs to be called to
 dynamically generate the C bindings for GPGME in the first place. So the
 entire process will always produce ``lang/python/python2-gpg/`` and
 ``lang/python/python3-gpg/`` directories. These should contain the build
 output generated during compilation, including the complete bindings and
 module installed into ``site-packages``.
 
 Occasionally the errors in the early part or some other conflict (e.g.
 not installing as **root** or **su**) may result in nothing being
 installed to the relevant ``site-packages`` directory and the build
 directory missing a lot of expected files. Even when this occurs, the
 solution is actually quite simple and will always work.
 
 That solution is simply to run the following commands as either the
 **root** user or prepended with ``sudo -H``\  [3]_ in the
 ``lang/python/`` directory:
 
 .. code:: shell
 
    /path/to/pythonX.Y setup.py build
    /path/to/pythonX.Y setup.py build
    /path/to/pythonX.Y setup.py install
 
 Yes, the build command does need to be run twice. Yes, you still need to
 run the potentially failing or incomplete steps during the
 ``configure``, ``make`` and ``make install`` steps with installing
 GPGME. This is because those steps generate a lot of essential files
 needed, both by and in order to create, the bindings (including both the
 ``setup.py`` and ``gpgme.h`` files).
 
 #. IMPORTANT Note
 
    If specifying a selected number of languages to create bindings for,
    try to leave Python last. Currently the majority of the other
    language bindings are also preceding Python of either version when
    listed alphabetically and so that just happens by default currently.
 
    If Python is set to precede one of the other languages then it is
    possible that the errors described here may interrupt the build
    process before generating bindings for those other languages. In
    these cases it may be preferable to configure all preferred language
    bindings separately with alternative ``configure`` steps for GPGME
    using the ``--enable-languages=$LANGUAGE`` option.
 
 .. _snafu-lessons-for-the-lazy:
 
 Reinstalling Responsibly
 ~~~~~~~~~~~~~~~~~~~~~~~~
 
 Regardless of whether you\'re installing for one version of Python or
 several, there will come a point where reinstallation is required. With
 most Python module installations, the installed files go into the
 relevant site-packages directory and are then forgotten about. Then the
 module is upgraded, the new files are copied over the old and that\'s
 the end of the matter.
 
 While the same is true of these bindings, there have been intermittent
 issues observed on some platforms which have benefited significantly
 from removing all the previous installations of the bindings before
 installing the updated versions.
 
 Removing the previous version(s) is simply a matter of changing to the
 relevant ``site-packages`` directory for the version of Python in
 question and removing the ``gpg/`` directory and any accompanying
 egg-info files for that module.
 
 In most cases this will require root or administration privileges on the
 system, but the same is true of installing the module in the first
 place.
 
 .. _snafu-the-full-monty:
 
 Multiple installations
 ~~~~~~~~~~~~~~~~~~~~~~
 
 For a variety of reasons it may be either necessary or just preferable
 to install the bindings to alternative installed Python versions which
 meet the requirements of these bindings.
 
 On POSIX systems this will generally be most simply achieved by running
 the manual installation commands (build, build, install) as described in
 the previous section for each Python installation the bindings need to
 be installed to.
 
 As per the SWIG documentation: the compilers, libraries and runtime used
 to build GPGME and the Python Bindings **must** match those used to
 compile Python itself, including the version number(s) (at least going
 by major version numbers and probably minor numbers too).
 
 On most POSIX systems, including OS X, this will very likely be the case
 in most, if not all, cases.
 
 Note that from GPGME
 `1.12.1 `__
 the default installation installs to each version of Python it can find
 first. That is that it will currently install for the first copies of
 Python versions 2.7, 3.4, 3.5, 3.6, 3.7 and 3.8 (dev branch) that it
 finds. Usually this will be in the same prefix as GPGME itself, but is
 dictated by the ``$PATH`` when the installation is performed. The above
 instructions can still be performed on other python installations which
 the installer does not find, including alternative prefixes.
 
 .. _snafu-runtime-not-funtime:
 
 Won\'t Work With Windows
 ~~~~~~~~~~~~~~~~~~~~~~~~
 
 There are semi-regular reports of Windows users having considerable
 difficulty in installing and using the Python bindings at all. Very
 often, possibly even always, these reports come from Cygwin users and/or
 MinGW users and/or Msys2 users. Though not all of them have been
 confirmed, it appears that these reports have also come from people who
 installed Python using the Windows installer files from the `Python
 website `__ (i.e. mostly MSI installers, sometimes
 self-extracting ``.exe`` files).
 
 The Windows versions of Python are not built using Cygwin, MinGW or
 Msys2; they\'re built using Microsoft Visual Studio. Furthermore the
 version used is *considerably* more advanced than the version which
 MinGW obtained a small number of files from many years ago in order to
 be able to compile anything at all. Not only that, but there are changes
 to the version of Visual Studio between some micro releases, though that
 is is particularly the case with Python 2.7, since it has been kept
 around far longer than it should have been.
 
 There are two theoretical solutions to this issue:
 
 #. Compile and install the GnuPG stack, including GPGME and the Python
    bibdings using the same version of Microsoft Visual Studio used by
    the Python Foundation to compile the version of Python installed.
 
    If there are multiple versions of Python then this will need to be
    done with each different version of Visual Studio used.
 
 #. Compile and install Python using the same tools used by choice, such
    as MinGW or Msys2.
 
 Do **not** use the official Windows installer for Python unless
 following the first method.
 
 In this type of situation it may even be for the best to accept that
 there are less limitations on permissive software than free software and
 simply opt to use a recent version of the Community Edition of Microsoft
 Visual Studio to compile and build all of it, no matter what.
 
 Investigations into the extent or the limitations of this issue are
 ongoing.
 
 .. _snafu-cffi:
 
 CFFI is the Best™ and GPGME should use it instead of SWIG
 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 
 There are many reasons for favouring
 `CFFI `__ and
 proponents of it are quite happy to repeat these things as if all it
 would take to switch from SWIG to CFFI is repeating that list as if it
 were a new concept.
 
 The fact is that there are things which Python\'s CFFI implementation
 cannot handle in the GPGME C code. Beyond that there are features of
 SWIG which are simply not available with CFFI at all. SWIG generates the
 bindings to Python using the ``gpgme.h`` file, but that file is not a
 single version shipped with each release, it too is generated when GPGME
 is compiled.
 
 CFFI is currently unable to adapt to such a potentially mutable
 codebase. If there were some means of applying SWIG\'s dynamic code
 generation to produce the Python/CFFI API modes of accessing the GPGME
 libraries (or the source source code directly), but such a thing does
 not exist yet either and it currently appears that work is needed in at
 least one of CFFI\'s dependencies before any of this can be addressed.
 
 So if you\'re a massive fan of CFFI; that\'s great, but if you want this
 project to switch to CFFI then rather than just insisting that it
 should, I\'d suggest you volunteer to bring CFFI up to the level this
 project needs.
 
 If you\'re actually seriously considering doing so, then I\'d suggest
 taking the ``gpgme-tool.c`` file in the GPGME ``src/`` directory and
 getting that to work with any of the CFFI API methods (not the ABI
 methods, they\'ll work with pretty much anything). When you start
 running into trouble with \"ifdefs\" then you\'ll know what sort of
 things are lacking. That doesn\'t even take into account the amount of
 work saved via SWIG\'s code generation techniques either.
 
 .. _snafu-venv:
 
 Virtualised Environments
 ~~~~~~~~~~~~~~~~~~~~~~~~
 
 It is fairly common practice amongst Python developers to, as much as
 possible, use packages like virtualenv to keep various things that are
 to be installed from interfering with each other. Given how much of the
 GPGME bindings is often at odds with the usual pythonic way of doing
 things, it stands to reason that this would be called into question too.
 
 As it happens the answer as to whether or not the bindings can be used
 with virtualenv, the answer is both yes and no.
 
 In general we recommend installing to the relevant path and matching
 prefix of GPGME itself. Which means that when GPGME, and ideally the
 rest of the GnuPG stack, is installed to a prefix like ``/usr/local`` or
 ``/opt/local`` then the bindings would need to be installed to the main
 Python installation and not a virtualised abstraction. Attempts to
 separate the two in the past have been known to cause weird and
 intermittent errors ranging from minor annoyances to complete failures
 in the build process.
 
 As a consequence we only recommend building with and installing to the
 main Python installations within the same prefix as GPGME is installed
 to or which are found by GPGME\'s configuration stage immediately prior
 to running the make commands. Which is exactly what the compiling and
 installing process of GPGME does by default.
 
 Once that is done, however, it appears that a copy of the compiled
 module may be installed into a virtualenv of the same major and minor
 version matching the build. Alternatively it is possible to utilise a
 ``sites.pth`` file in the ``site-packages/`` directory of a virtualenv
 installation, which links back to the system installations corresponding
 directory in order to import anything installed system wide. This may or
 may not be appropriate on a case by case basis.
 
 Though extensive testing of either of these options is not yet complete,
 preliminary testing of them indicates that both are viable as long as
 the main installation is complete. Which means that certain other
 options normally restricted to virtual environments are also available,
 including integration with pythonic test suites (e.g.
 `pytest `__) and other
 large projects.
 
 That said, it is worth reiterating the warning regarding non-standard
 installations. If one were to attempt to install the bindings only to a
 virtual environment without somehow also including the full GnuPG stack
 (or enough of it as to include GPGME) then it is highly likely that
 errors would be encountered at some point and more than a little likely
 that the build process itself would break.
 
 If a degree of separation from the main operating system is still
 required in spite of these warnings, then consider other forms of
 virtualisation. Either a virtual machine (e.g.
 `VirtualBox `__), a hardware emulation
 layer (e.g. `QEMU `__) or an application
 container (e.g. `Docker `__).
 
 Finally it should be noted that the limited tests conducted thus far
 have been using the ``virtualenv`` command in a new directory to create
 the virtual python environment. As opposed to the standard ``python3
 -m venv`` and it is possible that this will make a difference depending
 on the system and version of Python in use. Another option is to run the
 command ``python3 -m virtualenv /path/to/install/virtual/thingy``
 instead.
 
 .. _howto-fund-a-mental:
 
 Fundamentals
 ============
 
 Before we can get to the fun stuff, there are a few matters regarding
 GPGME\'s design which hold true whether you\'re dealing with the C code
 directly or these Python bindings.
 
 .. _no-rest-for-the-wicked:
 
 No REST
 -------
 
 The first part of which is or will be fairly blatantly obvious upon
 viewing the first example, but it\'s worth reiterating anyway. That
 being that this API is **not** a REST API. Nor indeed could it ever be
 one.
 
 Most, if not all, Python programmers (and not just Python programmers)
 know how easy it is to work with a RESTful API. In fact they\'ve become
 so popular that many other APIs attempt to emulate REST-like behaviour
 as much as they are able. Right down to the use of JSON formatted output
 to facilitate the use of their API without having to retrain developers.
 
 This API does not do that. It would not be able to do that and also
 provide access to the entire C API on which it\'s built. It does,
 however, provide a very pythonic interface on top of the direct bindings
 and it\'s this pythonic layer that this HOWTO deals with.
 
 .. _howto-get-context:
 
 Context
 -------
 
 One of the reasons which prevents this API from being RESTful is that
 most operations require more than one instruction to the API to perform
 the task. Sure, there are certain functions which can be performed
 simultaneously, particularly if the result known or strongly anticipated
 (e.g. selecting and encrypting to a key known to be in the public
 keybox).
 
 There are many more, however, which cannot be manipulated so readily:
 they must be performed in a specific sequence and the result of one
 operation has a direct bearing on the outcome of subsequent operations.
 Not merely by generating an error either.
 
 When dealing with this type of persistent state on the web, full of both
 the RESTful and REST-like, it\'s most commonly referred to as a session.
 In GPGME, however, it is called a context and every operation type has
 one.
 
 .. _howto-keys:
 
 Working with keys
 =================
 
 .. _howto-keys-selection:
 
 Key selection
 -------------
 
 Selecting keys to encrypt to or to sign with will be a common occurrence
 when working with GPGMe and the means available for doing so are quite
 simple.
 
 They do depend on utilising a Context; however once the data is recorded
 in another variable, that Context does not need to be the same one which
 subsequent operations are performed.
 
 The easiest way to select a specific key is by searching for that key\'s
 key ID or fingerprint, preferably the full fingerprint without any
 spaces in it. A long key ID will probably be okay, but is not advised
 and short key IDs are already a problem with some being generated to
 match specific patterns. It does not matter whether the pattern is upper
 or lower case.
 
 So this is the best method:
 
 .. code:: python
 
    import gpg
 
    k = gpg.Context().keylist(pattern="258E88DCBD3CD44D8E7AB43F6ECB6AF0DEADBEEF")
    keys = list(k)
 
 This is passable and very likely to be common:
 
 .. code:: python
 
    import gpg
 
    k = gpg.Context().keylist(pattern="0x6ECB6AF0DEADBEEF")
    keys = list(k)
 
 And this is a really bad idea:
 
 .. code:: python
 
    import gpg
 
    k = gpg.Context().keylist(pattern="0xDEADBEEF")
    keys = list(k)
 
 Alternatively it may be that the intention is to create a list of keys
 which all match a particular search string. For instance all the
 addresses at a particular domain, like this:
 
 .. code:: python
 
    import gpg
 
    ncsc = gpg.Context().keylist(pattern="ncsc.mil")
    nsa = list(ncsc)
 
 .. _howto-keys-counting:
 
 Counting keys
 ~~~~~~~~~~~~~
 
 Counting the number of keys in your public keybox (``pubring.kbx``), the
 format which has superseded the old keyring format (``pubring.gpg`` and
 ``secring.gpg``), or the number of secret keys is a very simple task.
 
 .. code:: python
 
    import gpg
 
    c = gpg.Context()
    seckeys = c.keylist(pattern=None, secret=True)
    pubkeys = c.keylist(pattern=None, secret=False)
 
    seclist = list(seckeys)
    secnum = len(seclist)
 
    publist = list(pubkeys)
    pubnum = len(publist)
 
    print("""
      Number of secret keys:  {0}
      Number of public keys:  {1}
    """.format(secnum, pubnum))
 
 NOTE: The `Cython <#cython>`__ introduction in the `Advanced and
 Experimental <#advanced-use>`__ section uses this same key counting code
 with Cython to demonstrate some areas where Cython can improve
 performance even with the bindings. Users with large public keyrings or
 keyboxes, for instance, should consider these options if they are
 comfortable with using Cython.
 
 .. _howto-get-key:
 
 Get key
 -------
 
 An alternative method of getting a single key via its fingerprint is
 available directly within a Context with ``Context().get_key``. This is
 the preferred method of selecting a key in order to modify it, sign or
 certify it and for obtaining relevant data about a single key as a part
 of other functions; when verifying a signature made by that key, for
 instance.
 
 By default this method will select public keys, but it can select secret
 keys as well.
 
 This first example demonstrates selecting the current key of Werner
 Koch, which is due to expire at the end of 2018:
 
 .. code:: python
 
    import gpg
 
    fingerprint = "80615870F5BAD690333686D0F2AD85AC1E42B367"
    key = gpg.Context().get_key(fingerprint)
 
 Whereas this example demonstrates selecting the author\'s current key
 with the ``secret`` key word argument set to ``True``:
 
 .. code:: python
 
    import gpg
 
    fingerprint = "DB4724E6FA4286C92B4E55C4321E4E2373590E5D"
    key = gpg.Context().get_key(fingerprint, secret=True)
 
 It is, of course, quite possible to select expired, disabled and revoked
 keys with this function, but only to effectively display information
 about those keys.
 
 It is also possible to use both unicode or string literals and byte
 literals with the fingerprint when getting a key in this way.
 
 .. _howto-import-key:
 
 Importing keys
 --------------
 
 Importing keys is possible with the ``key_import()`` method and takes
 one argument which is a bytes literal object containing either the
 binary or ASCII armoured key data for one or more keys.
 
 The following example retrieves one or more keys from the SKS keyservers
 via the web using the requests module. Since requests returns the
 content as a bytes literal object, we can then use that directly to
 import the resulting data into our keybox.
 
 .. code:: python
 
    import gpg
    import os.path
    import requests
 
    c = gpg.Context()
    url = "https://sks-keyservers.net/pks/lookup"
    pattern = input("Enter the pattern to search for key or user IDs: ")
    payload = {"op": "get", "search": pattern}
 
    r = requests.get(url, verify=True, params=payload)
    result = c.key_import(r.content)
 
    if result is not None and hasattr(result, "considered") is False:
        print(result)
    elif result is not None and hasattr(result, "considered") is True:
        num_keys = len(result.imports)
        new_revs = result.new_revocations
        new_sigs = result.new_signatures
        new_subs = result.new_sub_keys
        new_uids = result.new_user_ids
        new_scrt = result.secret_imported
        nochange = result.unchanged
        print("""
      The total number of keys considered for import was:  {0}
 
         Number of keys revoked:  {1}
       Number of new signatures:  {2}
          Number of new subkeys:  {3}
         Number of new user IDs:  {4}
      Number of new secret keys:  {5}
       Number of unchanged keys:  {6}
 
      The key IDs for all considered keys were:
    """.format(num_keys, new_revs, new_sigs, new_subs, new_uids, new_scrt,
               nochange))
        for i in range(num_keys):
            print("{0}\n".format(result.imports[i].fpr))
    else:
        pass
 
 NOTE: When searching for a key ID of any length or a fingerprint
 (without spaces), the SKS servers require the the leading ``0x``
 indicative of hexadecimal be included. Also note that the old short key
 IDs (e.g. ``0xDEADBEEF``) should no longer be used due to the relative
 ease by which such key IDs can be reproduced, as demonstrated by the
 Evil32 Project in 2014 (which was subsequently exploited in 2016).
 
 .. _import-protonmail:
 
 Working with ProtonMail
 ~~~~~~~~~~~~~~~~~~~~~~~
 
 Here is a variation on the example above which checks the constrained
 ProtonMail keyserver for ProtonMail public keys.
 
 .. code:: python
 
    import gpg
    import requests
    import sys
 
    print("""
    This script searches the ProtonMail key server for the specified key and
    imports it.
    """)
 
    c = gpg.Context(armor=True)
    url = "https://api.protonmail.ch/pks/lookup"
    ksearch = []
 
    if len(sys.argv) >= 2:
        keyterm = sys.argv[1]
    else:
        keyterm = input("Enter the key ID, UID or search string: ")
 
    if keyterm.count("@") == 2 and keyterm.startswith("@") is True:
        ksearch.append(keyterm[1:])
        ksearch.append(keyterm[1:])
        ksearch.append(keyterm[1:])
    elif keyterm.count("@") == 1 and keyterm.startswith("@") is True:
        ksearch.append("{0}@protonmail.com".format(keyterm[1:]))
        ksearch.append("{0}@protonmail.ch".format(keyterm[1:]))
        ksearch.append("{0}@pm.me".format(keyterm[1:]))
    elif keyterm.count("@") == 0:
        ksearch.append("{0}@protonmail.com".format(keyterm))
        ksearch.append("{0}@protonmail.ch".format(keyterm))
        ksearch.append("{0}@pm.me".format(keyterm))
    elif keyterm.count("@") == 2 and keyterm.startswith("@") is False:
        uidlist = keyterm.split("@")
        for uid in uidlist:
            ksearch.append("{0}@protonmail.com".format(uid))
            ksearch.append("{0}@protonmail.ch".format(uid))
            ksearch.append("{0}@pm.me".format(uid))
    elif keyterm.count("@") > 2:
        uidlist = keyterm.split("@")
        for uid in uidlist:
            ksearch.append("{0}@protonmail.com".format(uid))
            ksearch.append("{0}@protonmail.ch".format(uid))
            ksearch.append("{0}@pm.me".format(uid))
    else:
        ksearch.append(keyterm)
 
    for k in ksearch:
        payload = {"op": "get", "search": k}
        try:
            r = requests.get(url, verify=True, params=payload)
            if r.ok is True:
                result = c.key_import(r.content)
            elif r.ok is False:
                result = r.content
        except Exception as e:
            result = None
 
        if result is not None and hasattr(result, "considered") is False:
            print("{0} for {1}".format(result.decode(), k))
        elif result is not None and hasattr(result, "considered") is True:
            num_keys = len(result.imports)
            new_revs = result.new_revocations
            new_sigs = result.new_signatures
            new_subs = result.new_sub_keys
            new_uids = result.new_user_ids
            new_scrt = result.secret_imported
            nochange = result.unchanged
            print("""
    The total number of keys considered for import was:  {0}
 
    With UIDs wholely or partially matching the following string:
 
            {1}
 
       Number of keys revoked:  {2}
     Number of new signatures:  {3}
        Number of new subkeys:  {4}
       Number of new user IDs:  {5}
    Number of new secret keys:  {6}
     Number of unchanged keys:  {7}
 
    The key IDs for all considered keys were:
    """.format(num_keys, k, new_revs, new_sigs, new_subs, new_uids, new_scrt,
               nochange))
            for i in range(num_keys):
                print(result.imports[i].fpr)
            print("")
        elif result is None:
            print(e)
 
 Both the above example,
 `pmkey-import.py <../examples/howto/pmkey-import.py>`__, and a version
 which prompts for an alternative GnuPG home directory,
 `pmkey-import-alt.py <../examples/howto/pmkey-import-alt.py>`__, are
 available with the other examples and are executable scripts.
 
 Note that while the ProtonMail servers are based on the SKS servers,
 their server is related more to their API and is not feature complete by
 comparison to the servers in the SKS pool. One notable difference being
 that the ProtonMail server does not permit non ProtonMail users to
 update their own keys, which could be a vector for attacking ProtonMail
 users who may not receive a key\'s revocation if it had been
 compromised.
 
 .. _import-hkp4py:
 
 Importing with HKP for Python
 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 
 Performing the same tasks with the `hkp4py
 module `__ (available via PyPI) is
 not too much different, but does provide a number of options of benefit
 to end users. Not least of which being the ability to perform some
 checks on a key before importing it or not. For instance it may be the
 policy of a site or project to only import keys which have not been
 revoked. The hkp4py module permits such checks prior to the importing of
 the keys found.
 
 .. code:: python
 
    import gpg
    import hkp4py
    import sys
 
    c = gpg.Context()
    server = hkp4py.KeyServer("hkps://hkps.pool.sks-keyservers.net")
    results = []
 
    if len(sys.argv) > 2:
        pattern = " ".join(sys.argv[1:])
    elif len(sys.argv) == 2:
        pattern = sys.argv[1]
    else:
        pattern = input("Enter the pattern to search for keys or user IDs: ")
 
    try:
        keys = server.search(pattern)
        print("Found {0} key(s).".format(len(keys)))
    except Exception as e:
        keys = []
        for logrus in pattern.split():
            if logrus.startswith("0x") is True:
                key = server.search(logrus)
            else:
                key = server.search("0x{0}".format(logrus))
            keys.append(key[0])
        print("Found {0} key(s).".format(len(keys)))
 
    for key in keys:
        import_result = c.key_import(key.key_blob)
        results.append(import_result)
 
    for result in results:
        if result is not None and hasattr(result, "considered") is False:
            print(result)
        elif result is not None and hasattr(result, "considered") is True:
            num_keys = len(result.imports)
            new_revs = result.new_revocations
            new_sigs = result.new_signatures
            new_subs = result.new_sub_keys
            new_uids = result.new_user_ids
            new_scrt = result.secret_imported
            nochange = result.unchanged
            print("""
    The total number of keys considered for import was:  {0}
 
       Number of keys revoked:  {1}
     Number of new signatures:  {2}
        Number of new subkeys:  {3}
       Number of new user IDs:  {4}
    Number of new secret keys:  {5}
     Number of unchanged keys:  {6}
 
    The key IDs for all considered keys were:
    """.format(num_keys, new_revs, new_sigs, new_subs, new_uids, new_scrt,
               nochange))
            for i in range(num_keys):
                print(result.imports[i].fpr)
            print("")
        else:
            pass
 
 Since the hkp4py module handles multiple keys just as effectively as one
 (``keys`` is a list of responses per matching key), the example above is
 able to do a little bit more with the returned data before anything is
 actually imported.
 
 .. _import-protonmail-hkp4py:
 
 Importing from ProtonMail with HKP for Python
 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 
 Though this can provide certain benefits even when working with
 ProtonMail, the scope is somewhat constrained there due to the
 limitations of the ProtonMail keyserver.
 
 For instance, searching the SKS keyserver pool for the term \"gnupg\"
 produces hundreds of results from any time the word appears in any part
 of a user ID. Performing the same search on the ProtonMail keyserver
 returns zero results, even though there are at least two test accounts
 which include it as part of the username.
 
 The cause of this discrepancy is the deliberate configuration of that
 server by ProtonMail to require an exact match of the full email address
 of the ProtonMail user whose key is being requested. Presumably this is
 intended to reduce breaches of privacy of their users as an email
 address must already be known before a key for that address can be
 obtained.
 
 #. Import from ProtonMail via HKP for Python Example no. 1
 
-   The following script is avalable with the rest of the examples under
+   The following script is available with the rest of the examples under
    the somewhat less than original name, ``pmkey-import-hkp.py``.
 
    .. code:: python
 
       import gpg
       import hkp4py
       import os.path
       import sys
 
       print("""
       This script searches the ProtonMail key server for the specified key and
       imports it.
 
       Usage:  pmkey-import-hkp.py [search strings]
       """)
 
       c = gpg.Context(armor=True)
       server = hkp4py.KeyServer("hkps://api.protonmail.ch")
       keyterms = []
       ksearch = []
       allkeys = []
       results = []
       paradox = []
       homeless = None
 
       if len(sys.argv) > 2:
           keyterms = sys.argv[1:]
       elif len(sys.argv) == 2:
           keyterm = sys.argv[1]
           keyterms.append(keyterm)
       else:
           key_term = input("Enter the key ID, UID or search string: ")
           keyterms = key_term.split()
 
       for keyterm in keyterms:
           if keyterm.count("@") == 2 and keyterm.startswith("@") is True:
               ksearch.append(keyterm[1:])
               ksearch.append(keyterm[1:])
               ksearch.append(keyterm[1:])
           elif keyterm.count("@") == 1 and keyterm.startswith("@") is True:
               ksearch.append("{0}@protonmail.com".format(keyterm[1:]))
               ksearch.append("{0}@protonmail.ch".format(keyterm[1:]))
               ksearch.append("{0}@pm.me".format(keyterm[1:]))
           elif keyterm.count("@") == 0:
               ksearch.append("{0}@protonmail.com".format(keyterm))
               ksearch.append("{0}@protonmail.ch".format(keyterm))
               ksearch.append("{0}@pm.me".format(keyterm))
           elif keyterm.count("@") == 2 and keyterm.startswith("@") is False:
               uidlist = keyterm.split("@")
               for uid in uidlist:
                   ksearch.append("{0}@protonmail.com".format(uid))
                   ksearch.append("{0}@protonmail.ch".format(uid))
                   ksearch.append("{0}@pm.me".format(uid))
           elif keyterm.count("@") > 2:
               uidlist = keyterm.split("@")
               for uid in uidlist:
                   ksearch.append("{0}@protonmail.com".format(uid))
                   ksearch.append("{0}@protonmail.ch".format(uid))
                   ksearch.append("{0}@pm.me".format(uid))
           else:
               ksearch.append(keyterm)
 
       for k in ksearch:
           print("Checking for key for: {0}".format(k))
           try:
               keys = server.search(k)
               if isinstance(keys, list) is True:
                   for key in keys:
                       allkeys.append(key)
                       try:
                           import_result = c.key_import(key.key_blob)
                       except Exception as e:
                           import_result = c.key_import(key.key)
               else:
                   paradox.append(keys)
                   import_result = None
           except Exception as e:
               import_result = None
           results.append(import_result)
 
       for result in results:
           if result is not None and hasattr(result, "considered") is False:
               print("{0} for {1}".format(result.decode(), k))
           elif result is not None and hasattr(result, "considered") is True:
               num_keys = len(result.imports)
               new_revs = result.new_revocations
               new_sigs = result.new_signatures
               new_subs = result.new_sub_keys
               new_uids = result.new_user_ids
               new_scrt = result.secret_imported
               nochange = result.unchanged
               print("""
       The total number of keys considered for import was:  {0}
 
       With UIDs wholely or partially matching the following string:
 
               {1}
 
          Number of keys revoked:  {2}
        Number of new signatures:  {3}
           Number of new subkeys:  {4}
          Number of new user IDs:  {5}
       Number of new secret keys:  {6}
        Number of unchanged keys:  {7}
 
       The key IDs for all considered keys were:
       """.format(num_keys, k, new_revs, new_sigs, new_subs, new_uids, new_scrt,
                  nochange))
               for i in range(num_keys):
                   print(result.imports[i].fpr)
               print("")
           elif result is None:
               pass
 
 #. Import from ProtonMail via HKP for Python Example no. 2
 
    Like its counterpart above, this script can also be found with the
    rest of the examples, by the name pmkey-import-hkp-alt.py.
 
    With this script a modicum of effort has been made to treat anything
    passed as a ``homedir`` which either does not exist or which is not a
    directory, as also being a pssible user ID to check for. It\'s not
    guaranteed to pick up on all such cases, but it should cover most of
    them.
 
    .. code:: python
 
       import gpg
       import hkp4py
       import os.path
       import sys
 
       print("""
       This script searches the ProtonMail key server for the specified key and
       imports it.  Optionally enables specifying a different GnuPG home directory.
 
       Usage:  pmkey-import-hkp.py [homedir] [search string]
          or:  pmkey-import-hkp.py [search string]
       """)
 
       c = gpg.Context(armor=True)
       server = hkp4py.KeyServer("hkps://api.protonmail.ch")
       keyterms = []
       ksearch = []
       allkeys = []
       results = []
       paradox = []
       homeless = None
 
       if len(sys.argv) > 3:
           homedir = sys.argv[1]
           keyterms = sys.argv[2:]
       elif len(sys.argv) == 3:
           homedir = sys.argv[1]
           keyterm = sys.argv[2]
           keyterms.append(keyterm)
       elif len(sys.argv) == 2:
           homedir = ""
           keyterm = sys.argv[1]
           keyterms.append(keyterm)
       else:
           keyterm = input("Enter the key ID, UID or search string: ")
           homedir = input("Enter the GPG configuration directory path (optional): ")
           keyterms.append(keyterm)
 
       if len(homedir) == 0:
           homedir = None
           homeless = False
 
       if homedir is not None:
           if homedir.startswith("~"):
               if os.path.exists(os.path.expanduser(homedir)) is True:
                   if os.path.isdir(os.path.expanduser(homedir)) is True:
                       c.home_dir = os.path.realpath(os.path.expanduser(homedir))
                   else:
                       homeless = True
               else:
                   homeless = True
           elif os.path.exists(os.path.realpath(homedir)) is True:
               if os.path.isdir(os.path.realpath(homedir)) is True:
                   c.home_dir = os.path.realpath(homedir)
               else:
                   homeless = True
           else:
               homeless = True
 
       # First check to see if the homedir really is a homedir and if not, treat it as
       # a search string.
       if homeless is True:
           keyterms.append(homedir)
           c.home_dir = None
       else:
           pass
 
       for keyterm in keyterms:
           if keyterm.count("@") == 2 and keyterm.startswith("@") is True:
               ksearch.append(keyterm[1:])
               ksearch.append(keyterm[1:])
               ksearch.append(keyterm[1:])
           elif keyterm.count("@") == 1 and keyterm.startswith("@") is True:
               ksearch.append("{0}@protonmail.com".format(keyterm[1:]))
               ksearch.append("{0}@protonmail.ch".format(keyterm[1:]))
               ksearch.append("{0}@pm.me".format(keyterm[1:]))
           elif keyterm.count("@") == 0:
               ksearch.append("{0}@protonmail.com".format(keyterm))
               ksearch.append("{0}@protonmail.ch".format(keyterm))
               ksearch.append("{0}@pm.me".format(keyterm))
           elif keyterm.count("@") == 2 and keyterm.startswith("@") is False:
               uidlist = keyterm.split("@")
               for uid in uidlist:
                   ksearch.append("{0}@protonmail.com".format(uid))
                   ksearch.append("{0}@protonmail.ch".format(uid))
                   ksearch.append("{0}@pm.me".format(uid))
           elif keyterm.count("@") > 2:
               uidlist = keyterm.split("@")
               for uid in uidlist:
                   ksearch.append("{0}@protonmail.com".format(uid))
                   ksearch.append("{0}@protonmail.ch".format(uid))
                   ksearch.append("{0}@pm.me".format(uid))
           else:
               ksearch.append(keyterm)
 
       for k in ksearch:
           print("Checking for key for: {0}".format(k))
           try:
               keys = server.search(k)
               if isinstance(keys, list) is True:
                   for key in keys:
                       allkeys.append(key)
                       try:
                           import_result = c.key_import(key.key_blob)
                       except Exception as e:
                           import_result = c.key_import(key.key)
               else:
                   paradox.append(keys)
                   import_result = None
           except Exception as e:
               import_result = None
           results.append(import_result)
 
       for result in results:
           if result is not None and hasattr(result, "considered") is False:
               print("{0} for {1}".format(result.decode(), k))
           elif result is not None and hasattr(result, "considered") is True:
               num_keys = len(result.imports)
               new_revs = result.new_revocations
               new_sigs = result.new_signatures
               new_subs = result.new_sub_keys
               new_uids = result.new_user_ids
               new_scrt = result.secret_imported
               nochange = result.unchanged
               print("""
       The total number of keys considered for import was:  {0}
 
       With UIDs wholely or partially matching the following string:
 
               {1}
 
          Number of keys revoked:  {2}
        Number of new signatures:  {3}
           Number of new subkeys:  {4}
          Number of new user IDs:  {5}
       Number of new secret keys:  {6}
        Number of unchanged keys:  {7}
 
       The key IDs for all considered keys were:
       """.format(num_keys, k, new_revs, new_sigs, new_subs, new_uids, new_scrt,
                  nochange))
               for i in range(num_keys):
                   print(result.imports[i].fpr)
               print("")
           elif result is None:
               pass
 
 .. _howto-export-key:
 
 Exporting keys
 --------------
 
 Exporting keys remains a reasonably simple task, but has been separated
 into three different functions for the OpenPGP cryptographic engine. Two
 of those functions are for exporting public keys and the third is for
 exporting secret keys.
 
 .. _howto-export-public-key:
 
 Exporting public keys
 ~~~~~~~~~~~~~~~~~~~~~
 
 There are two methods of exporting public keys, both of which are very
 similar to the other. The default method, ``key_export()``, will export
 a public key or keys matching a specified pattern as normal. The
 alternative, the ``key_export_minimal()`` method, will do the same thing
 except producing a minimised output with extra signatures and third
 party signatures or certifications removed.
 
 .. code:: python
 
    import gpg
    import os.path
    import sys
 
    print("""
    This script exports one or more public keys.
    """)
 
    c = gpg.Context(armor=True)
 
    if len(sys.argv) >= 4:
        keyfile = sys.argv[1]
        logrus = sys.argv[2]
        homedir = sys.argv[3]
    elif len(sys.argv) == 3:
        keyfile = sys.argv[1]
        logrus = sys.argv[2]
        homedir = input("Enter the GPG configuration directory path (optional): ")
    elif len(sys.argv) == 2:
        keyfile = sys.argv[1]
        logrus = input("Enter the UID matching the key(s) to export: ")
        homedir = input("Enter the GPG configuration directory path (optional): ")
    else:
        keyfile = input("Enter the path and filename to save the secret key to: ")
        logrus = input("Enter the UID matching the key(s) to export: ")
        homedir = input("Enter the GPG configuration directory path (optional): ")
 
    if homedir.startswith("~"):
        if os.path.exists(os.path.expanduser(homedir)) is True:
            c.home_dir = os.path.expanduser(homedir)
        else:
            pass
    elif os.path.exists(homedir) is True:
        c.home_dir = homedir
    else:
        pass
 
    try:
        result = c.key_export(pattern=logrus)
    except:
        result = c.key_export(pattern=None)
 
    if result is not None:
        with open(keyfile, "wb") as f:
            f.write(result)
    else:
        pass
 
 It should be noted that the result will only return ``None`` when a
 search pattern has been entered, but has not matched any keys. When the
 search pattern itself is set to ``None`` this triggers the exporting of
 the entire public keybox.
 
 .. code:: python
 
    import gpg
    import os.path
    import sys
 
    print("""
    This script exports one or more public keys in minimised form.
    """)
 
    c = gpg.Context(armor=True)
 
    if len(sys.argv) >= 4:
        keyfile = sys.argv[1]
        logrus = sys.argv[2]
        homedir = sys.argv[3]
    elif len(sys.argv) == 3:
        keyfile = sys.argv[1]
        logrus = sys.argv[2]
        homedir = input("Enter the GPG configuration directory path (optional): ")
    elif len(sys.argv) == 2:
        keyfile = sys.argv[1]
        logrus = input("Enter the UID matching the key(s) to export: ")
        homedir = input("Enter the GPG configuration directory path (optional): ")
    else:
        keyfile = input("Enter the path and filename to save the secret key to: ")
        logrus = input("Enter the UID matching the key(s) to export: ")
        homedir = input("Enter the GPG configuration directory path (optional): ")
 
    if homedir.startswith("~"):
        if os.path.exists(os.path.expanduser(homedir)) is True:
            c.home_dir = os.path.expanduser(homedir)
        else:
            pass
    elif os.path.exists(homedir) is True:
        c.home_dir = homedir
    else:
        pass
 
    try:
        result = c.key_export_minimal(pattern=logrus)
    except:
        result = c.key_export_minimal(pattern=None)
 
    if result is not None:
        with open(keyfile, "wb") as f:
            f.write(result)
    else:
        pass
 
 .. _howto-export-secret-key:
 
 Exporting secret keys
 ~~~~~~~~~~~~~~~~~~~~~
 
 Exporting secret keys is, functionally, very similar to exporting public
 keys; save for the invocation of ``pinentry`` via ``gpg-agent`` in order
 to securely enter the key\'s passphrase and authorise the export.
 
 The following example exports the secret key to a file which is then set
 with the same permissions as the output files created by the command
 line secret key export options.
 
 .. code:: python
 
    import gpg
    import os
    import os.path
    import sys
 
    print("""
    This script exports one or more secret keys.
 
    The gpg-agent and pinentry are invoked to authorise the export.
    """)
 
    c = gpg.Context(armor=True)
 
    if len(sys.argv) >= 4:
        keyfile = sys.argv[1]
        logrus = sys.argv[2]
        homedir = sys.argv[3]
    elif len(sys.argv) == 3:
        keyfile = sys.argv[1]
        logrus = sys.argv[2]
        homedir = input("Enter the GPG configuration directory path (optional): ")
    elif len(sys.argv) == 2:
        keyfile = sys.argv[1]
        logrus = input("Enter the UID matching the secret key(s) to export: ")
        homedir = input("Enter the GPG configuration directory path (optional): ")
    else:
        keyfile = input("Enter the path and filename to save the secret key to: ")
        logrus = input("Enter the UID matching the secret key(s) to export: ")
        homedir = input("Enter the GPG configuration directory path (optional): ")
 
    if len(homedir) == 0:
        homedir = None
    elif homedir.startswith("~"):
        userdir = os.path.expanduser(homedir)
        if os.path.exists(userdir) is True:
            homedir = os.path.realpath(userdir)
        else:
            homedir = None
    else:
        homedir = os.path.realpath(homedir)
 
    if os.path.exists(homedir) is False:
        homedir = None
    else:
        if os.path.isdir(homedir) is False:
            homedir = None
        else:
            pass
 
    if homedir is not None:
        c.home_dir = homedir
    else:
        pass
 
    try:
        result = c.key_export_secret(pattern=logrus)
    except:
        result = c.key_export_secret(pattern=None)
 
    if result is not None:
        with open(keyfile, "wb") as f:
            f.write(result)
        os.chmod(keyfile, 0o600)
    else:
        pass
 
 Alternatively the approach of the following script can be used. This
 longer example saves the exported secret key(s) in files in the GnuPG
 home directory, in addition to setting the file permissions as only
 readable and writable by the user. It also exports the secret key(s)
 twice in order to output both GPG binary (``.gpg``) and ASCII armoured
 (``.asc``) files.
 
 .. code:: python
 
    import gpg
    import os
    import os.path
    import subprocess
    import sys
 
    print("""
    This script exports one or more secret keys as both ASCII armored and binary
    file formats, saved in files within the user's GPG home directory.
 
    The gpg-agent and pinentry are invoked to authorise the export.
    """)
 
    if sys.platform == "win32":
        gpgconfcmd = "gpgconf.exe --list-dirs homedir"
    else:
        gpgconfcmd = "gpgconf --list-dirs homedir"
 
    a = gpg.Context(armor=True)
    b = gpg.Context()
    c = gpg.Context()
 
    if len(sys.argv) >= 4:
        keyfile = sys.argv[1]
        logrus = sys.argv[2]
        homedir = sys.argv[3]
    elif len(sys.argv) == 3:
        keyfile = sys.argv[1]
        logrus = sys.argv[2]
        homedir = input("Enter the GPG configuration directory path (optional): ")
    elif len(sys.argv) == 2:
        keyfile = sys.argv[1]
        logrus = input("Enter the UID matching the secret key(s) to export: ")
        homedir = input("Enter the GPG configuration directory path (optional): ")
    else:
        keyfile = input("Enter the filename to save the secret key to: ")
        logrus = input("Enter the UID matching the secret key(s) to export: ")
        homedir = input("Enter the GPG configuration directory path (optional): ")
 
    if len(homedir) == 0:
        homedir = None
    elif homedir.startswith("~"):
        userdir = os.path.expanduser(homedir)
        if os.path.exists(userdir) is True:
            homedir = os.path.realpath(userdir)
        else:
            homedir = None
    else:
        homedir = os.path.realpath(homedir)
 
    if os.path.exists(homedir) is False:
        homedir = None
    else:
        if os.path.isdir(homedir) is False:
            homedir = None
        else:
            pass
 
    if homedir is not None:
        c.home_dir = homedir
    else:
        pass
 
    if c.home_dir is not None:
        if c.home_dir.endswith("/"):
            gpgfile = "{0}{1}.gpg".format(c.home_dir, keyfile)
            ascfile = "{0}{1}.asc".format(c.home_dir, keyfile)
        else:
            gpgfile = "{0}/{1}.gpg".format(c.home_dir, keyfile)
            ascfile = "{0}/{1}.asc".format(c.home_dir, keyfile)
    else:
        if os.path.exists(os.environ["GNUPGHOME"]) is True:
            hd = os.environ["GNUPGHOME"]
        else:
            try:
                hd = subprocess.getoutput(gpgconfcmd)
            except:
                process = subprocess.Popen(gpgconfcmd.split(),
                                           stdout=subprocess.PIPE)
                procom = process.communicate()
                if sys.version_info[0] == 2:
                    hd = procom[0].strip()
                else:
                    hd = procom[0].decode().strip()
        gpgfile = "{0}/{1}.gpg".format(hd, keyfile)
        ascfile = "{0}/{1}.asc".format(hd, keyfile)
 
    try:
        a_result = a.key_export_secret(pattern=logrus)
        b_result = b.key_export_secret(pattern=logrus)
    except:
        a_result = a.key_export_secret(pattern=None)
        b_result = b.key_export_secret(pattern=None)
 
    if a_result is not None:
        with open(ascfile, "wb") as f:
            f.write(a_result)
        os.chmod(ascfile, 0o600)
    else:
        pass
 
    if b_result is not None:
        with open(gpgfile, "wb") as f:
            f.write(b_result)
        os.chmod(gpgfile, 0o600)
    else:
        pass
 
 .. _howto-send-public-key:
 
 Sending public keys to the SKS Keyservers
 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 
 As with the previous section on importing keys, the ``hkp4py`` module
 adds another option with exporting keys in order to send them to the
 public keyservers.
 
 The following example demonstrates how this may be done.
 
 .. code:: python
 
    import gpg
    import hkp4py
    import os.path
    import sys
 
    print("""
    This script sends one or more public keys to the SKS keyservers and is
    essentially a slight variation on the export-key.py script.
    """)
 
    c = gpg.Context(armor=True)
    server = hkp4py.KeyServer("hkps://hkps.pool.sks-keyservers.net")
 
    if len(sys.argv) > 2:
        logrus = " ".join(sys.argv[1:])
    elif len(sys.argv) == 2:
        logrus = sys.argv[1]
    else:
        logrus = input("Enter the UID matching the key(s) to send: ")
 
    if len(logrus) > 0:
        try:
            export_result = c.key_export(pattern=logrus)
        except Exception as e:
            print(e)
            export_result = None
    else:
        export_result = c.key_export(pattern=None)
 
    if export_result is not None:
        try:
            try:
                send_result = server.add(export_result)
            except:
                send_result = server.add(export_result.decode())
            if send_result is not None:
                print(send_result)
            else:
                pass
        except Exception as e:
            print(e)
    else:
        pass
 
 An expanded version of this script with additional functions for
 specifying an alternative homedir location is in the examples directory
 as ``send-key-to-keyserver.py``.
 
 The ``hkp4py`` module appears to handle both string and byte literal
 text data equally well, but the GPGME bindings deal primarily with byte
 literal data only and so this script sends in that format first, then
 tries the string literal form.
 
 .. _howto-the-basics:
 
 Basic Functions
 ===============
 
 The most frequently called features of any cryptographic library will be
 the most fundamental tasks for encryption software. In this section we
 will look at how to programmatically encrypt data, decrypt it, sign it
 and verify signatures.
 
 .. _howto-basic-encryption:
 
 Encryption
 ----------
 
 Encrypting is very straight forward. In the first example below the
 message, ``text``, is encrypted to a single recipient\'s key. In the
 second example the message will be encrypted to multiple recipients.
 
 .. _howto-basic-encryption-single:
 
 Encrypting to one key
 ~~~~~~~~~~~~~~~~~~~~~
 
 Once the the Context is set the main issues with encrypting data is
 essentially reduced to key selection and the keyword arguments specified
 in the ``gpg.Context().encrypt()`` method.
 
 Those keyword arguments are: ``recipients``, a list of keys encrypted to
 (covered in greater detail in the following section); ``sign``, whether
 or not to sign the plaintext data, see subsequent sections on signing
 and verifying signatures below (defaults to ``True``); ``sink``, to
 write results or partial results to a secure sink instead of returning
 it (defaults to ``None``); ``passphrase``, only used when utilising
 symmetric encryption (defaults to ``None``); ``always_trust``, used to
 override the trust model settings for recipient keys (defaults to
 ``False``); ``add_encrypt_to``, utilises any preconfigured
 ``encrypt-to`` or ``default-key`` settings in the user\'s ``gpg.conf``
 file (defaults to ``False``); ``prepare``, prepare for encryption
 (defaults to ``False``); ``expect_sign``, prepare for signing (defaults
 to ``False``); ``compress``, compresses the plaintext prior to
 encryption (defaults to ``True``).
 
 .. code:: python
 
    import gpg
 
    a_key = "0x12345678DEADBEEF"
    text = b"""Some text to test with.
 
    Since the text in this case must be bytes, it is most likely that
    the input form will be a separate file which is opened with "rb"
    as this is the simplest method of obtaining the correct data format.
    """
 
    c = gpg.Context(armor=True)
    rkey = list(c.keylist(pattern=a_key, secret=False))
    ciphertext, result, sign_result = c.encrypt(text, recipients=rkey, sign=False)
 
    with open("secret_plans.txt.asc", "wb") as afile:
        afile.write(ciphertext)
 
 Though this is even more likely to be used like this; with the plaintext
 input read from a file, the recipient keys used for encryption
 regardless of key trust status and the encrypted output also encrypted
 to any preconfigured keys set in the ``gpg.conf`` file:
 
 .. code:: python
 
    import gpg
 
    a_key = "0x12345678DEADBEEF"
 
    with open("secret_plans.txt", "rb") as afile:
        text = afile.read()
 
    c = gpg.Context(armor=True)
    rkey = list(c.keylist(pattern=a_key, secret=False))
    ciphertext, result, sign_result = c.encrypt(text, recipients=rkey, sign=True,
                                                always_trust=True,
                                                add_encrypt_to=True)
 
    with open("secret_plans.txt.asc", "wb") as afile:
        afile.write(ciphertext)
 
-If the ``recipients`` paramater is empty then the plaintext is encrypted
+If the ``recipients`` parameter is empty then the plaintext is encrypted
 symmetrically. If no ``passphrase`` is supplied as a parameter or via a
 callback registered with the ``Context()`` then an out-of-band prompt
 for the passphrase via pinentry will be invoked.
 
 .. _howto-basic-encryption-multiple:
 
 Encrypting to multiple keys
 ~~~~~~~~~~~~~~~~~~~~~~~~~~~
 
 Encrypting to multiple keys essentially just expands upon the key
 selection process and the recipients from the previous examples.
 
 The following example encrypts a message (``text``) to everyone with an
 email address on the ``gnupg.org`` domain, [4]_ but does *not* encrypt
 to a default key or other key which is configured to normally encrypt
 to.
 
 .. code:: python
 
    import gpg
 
    text = b"""Oh look, another test message.
 
    The same rules apply as with the previous example and more likely
    than not, the message will actually be drawn from reading the
    contents of a file or, maybe, from entering data at an input()
    prompt.
 
    Since the text in this case must be bytes, it is most likely that
    the input form will be a separate file which is opened with "rb"
    as this is the simplest method of obtaining the correct data
    format.
    """
 
    c = gpg.Context(armor=True)
    rpattern = list(c.keylist(pattern="@gnupg.org", secret=False))
    logrus = []
 
    for i in range(len(rpattern)):
        if rpattern[i].can_encrypt == 1:
            logrus.append(rpattern[i])
 
    ciphertext, result, sign_result = c.encrypt(text, recipients=logrus,
                                                sign=False, always_trust=True)
 
    with open("secret_plans.txt.asc", "wb") as afile:
        afile.write(ciphertext)
 
 All it would take to change the above example to sign the message and
 also encrypt the message to any configured default keys would be to
 change the ``c.encrypt`` line to this:
 
 .. code:: python
 
    ciphertext, result, sign_result = c.encrypt(text, recipients=logrus,
                                                always_trust=True,
                                                add_encrypt_to=True)
 
 The only keyword arguments requiring modification are those for which
 the default values are changing. The default value of ``sign`` is
 ``True``, the default of ``always_trust`` is ``False``, the default of
 ``add_encrypt_to`` is ``False``.
 
 If ``always_trust`` is not set to ``True`` and any of the recipient keys
 are not trusted (e.g. not signed or locally signed) then the encryption
 will raise an error. It is possible to mitigate this somewhat with
 something more like this:
 
 .. code:: python
 
    import gpg
 
    with open("secret_plans.txt.asc", "rb") as afile:
        text = afile.read()
 
    c = gpg.Context(armor=True)
    rpattern = list(c.keylist(pattern="@gnupg.org", secret=False))
    logrus = []
 
    for i in range(len(rpattern)):
        if rpattern[i].can_encrypt == 1:
            logrus.append(rpattern[i])
 
        try:
            ciphertext, result, sign_result = c.encrypt(text, recipients=logrus,
                                                        add_encrypt_to=True)
        except gpg.errors.InvalidRecipients as e:
            for i in range(len(e.recipients)):
                for n in range(len(logrus)):
                    if logrus[n].fpr == e.recipients[i].fpr:
                        logrus.remove(logrus[n])
                    else:
                        pass
            try:
                ciphertext, result, sign_result = c.encrypt(text,
                                                            recipients=logrus,
                                                            add_encrypt_to=True)
                with open("secret_plans.txt.asc", "wb") as afile:
                    afile.write(ciphertext)
            except:
                pass
 
 This will attempt to encrypt to all the keys searched for, then remove
 invalid recipients if it fails and try again.
 
 .. _howto-basic-decryption:
 
 Decryption
 ----------
 
 Decrypting something encrypted to a key in one\'s secret keyring is
 fairly straight forward.
 
 In this example code, however, preconfiguring either ``gpg.Context()``
 or ``gpg.core.Context()`` as ``c`` is unnecessary because there is no
 need to modify the Context prior to conducting the decryption and since
 the Context is only used once, setting it to ``c`` simply adds lines for
 no gain.
 
 .. code:: python
 
    import gpg
 
    ciphertext = input("Enter path and filename of encrypted file: ")
    newfile = input("Enter path and filename of file to save decrypted data to: ")
 
    with open(ciphertext, "rb") as cfile:
        try:
            plaintext, result, verify_result = gpg.Context().decrypt(cfile)
        except gpg.errors.GPGMEError as e:
            plaintext = None
            print(e)
 
    if plaintext is not None:
        with open(newfile, "wb") as nfile:
            nfile.write(plaintext)
        else:
            pass
 
 The data available in ``plaintext`` in this example is the decrypted
 content as a byte object, the recipient key IDs and algorithms in
 ``result`` and the results of verifying any signatures of the data in
 ``verify_result``.
 
 .. _howto-basic-signing:
 
 Signing text and files
 ----------------------
 
 The following sections demonstrate how to specify keys to sign with.
 
 .. _howto-basic-signing-signers:
 
 Signing key selection
 ~~~~~~~~~~~~~~~~~~~~~
 
 By default GPGME and the Python bindings will use the default key
 configured for the user invoking the GPGME API. If there is no default
 key specified and there is more than one secret key available it may be
 necessary to specify the key or keys with which to sign messages and
 files.
 
 .. code:: python
 
    import gpg
 
    logrus = input("Enter the email address or string to match signing keys to: ")
    hancock = gpg.Context().keylist(pattern=logrus, secret=True)
    sig_src = list(hancock)
 
 The signing examples in the following sections include the explicitly
 designated ``signers`` parameter in two of the five examples; once where
 the resulting signature would be ASCII armoured and once where it would
 not be armoured.
 
 While it would be possible to enter a key ID or fingerprint here to
 match a specific key, it is not possible to enter two fingerprints and
 match two keys since the patten expects a string, bytes or None and not
 a list. A string with two fingerprints won\'t match any single key.
 
 .. _howto-basic-signing-normal:
 
 Normal or default signing messages or files
 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 
 The normal or default signing process is essentially the same as is most
 often invoked when also encrypting a message or file. So when the
 encryption component is not utilised, the result is to produce an
 encoded and signed output which may or may not be ASCII armoured and
 which may or may not also be compressed.
 
 By default compression will be used unless GnuPG detects that the
 plaintext is already compressed. ASCII armouring will be determined
 according to the value of ``gpg.Context().armor``.
 
 The compression algorithm is selected in much the same way as the
 symmetric encryption algorithm or the hash digest algorithm is when
 multiple keys are involved; from the preferences saved into the key
 itself or by comparison with the preferences with all other keys
 involved.
 
 .. code:: python
 
    import gpg
 
    text0 = """Declaration of ... something.
 
    """
    text = text0.encode()
 
    c = gpg.Context(armor=True, signers=sig_src)
    signed_data, result = c.sign(text, mode=gpg.constants.sig.mode.NORMAL)
 
    with open("/path/to/statement.txt.asc", "w") as afile:
        afile.write(signed_data.decode())
 
 Though everything in this example is accurate, it is more likely that
 reading the input data from another file and writing the result to a new
 file will be performed more like the way it is done in the next example.
 Even if the output format is ASCII armoured.
 
 .. code:: python
 
    import gpg
 
    with open("/path/to/statement.txt", "rb") as tfile:
        text = tfile.read()
 
    c = gpg.Context()
    signed_data, result = c.sign(text, mode=gpg.constants.sig.mode.NORMAL)
 
    with open("/path/to/statement.txt.sig", "wb") as afile:
        afile.write(signed_data)
 
 .. _howto-basic-signing-detached:
 
 Detached signing messages and files
 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 
 Detached signatures will often be needed in programmatic uses of GPGME,
 either for signing files (e.g. tarballs of code releases) or as a
 component of message signing (e.g. PGP/MIME encoded email).
 
 .. code:: python
 
    import gpg
 
    text0 = """Declaration of ... something.
 
    """
    text = text0.encode()
 
    c = gpg.Context(armor=True)
    signed_data, result = c.sign(text, mode=gpg.constants.sig.mode.DETACH)
 
    with open("/path/to/statement.txt.asc", "w") as afile:
        afile.write(signed_data.decode())
 
 As with normal signatures, detached signatures are best handled as byte
 literals, even when the output is ASCII armoured.
 
 .. code:: python
 
    import gpg
 
    with open("/path/to/statement.txt", "rb") as tfile:
        text = tfile.read()
 
    c = gpg.Context(signers=sig_src)
    signed_data, result = c.sign(text, mode=gpg.constants.sig.mode.DETACH)
 
    with open("/path/to/statement.txt.sig", "wb") as afile:
        afile.write(signed_data)
 
 .. _howto-basic-signing-clear:
 
 Clearsigning messages or text
 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 
 Though PGP/in-line messages are no longer encouraged in favour of
 PGP/MIME, there is still sometimes value in utilising in-line
 signatures. This is where clear-signed messages or text is of value.
 
 .. code:: python
 
    import gpg
 
    text0 = """Declaration of ... something.
 
    """
    text = text0.encode()
 
    c = gpg.Context()
    signed_data, result = c.sign(text, mode=gpg.constants.sig.mode.CLEAR)
 
    with open("/path/to/statement.txt.asc", "w") as afile:
        afile.write(signed_data.decode())
 
 In spite of the appearance of a clear-signed message, the data handled
 by GPGME in signing it must still be byte literals.
 
 .. code:: python
 
    import gpg
 
    with open("/path/to/statement.txt", "rb") as tfile:
        text = tfile.read()
 
    c = gpg.Context()
    signed_data, result = c.sign(text, mode=gpg.constants.sig.mode.CLEAR)
 
    with open("/path/to/statement.txt.asc", "wb") as afile:
        afile.write(signed_data)
 
 .. _howto-basic-verification:
 
 Signature verification
 ----------------------
 
 Essentially there are two principal methods of verification of a
 signature. The first of these is for use with the normal or default
 signing method and for clear-signed messages. The second is for use with
 files and data with detached signatures.
 
 The following example is intended for use with the default signing
 method where the file was not ASCII armoured:
 
 .. code:: python
 
    import gpg
    import time
 
    filename = "statement.txt"
    gpg_file = "statement.txt.gpg"
 
    c = gpg.Context()
 
    try:
        data, result = c.verify(open(gpg_file))
        verified = True
    except gpg.errors.BadSignatures as e:
        verified = False
        print(e)
 
    if verified is True:
        for i in range(len(result.signatures)):
            sign = result.signatures[i]
            print("""Good signature from:
    {0}
    with key {1}
    made at {2}
    """.format(c.get_key(sign.fpr).uids[0].uid, sign.fpr,
               time.ctime(sign.timestamp)))
    else:
        pass
 
 Whereas this next example, which is almost identical would work with
 normal ASCII armoured files and with clear-signed files:
 
 .. code:: python
 
    import gpg
    import time
 
    filename = "statement.txt"
    asc_file = "statement.txt.asc"
 
    c = gpg.Context()
 
    try:
        data, result = c.verify(open(asc_file))
        verified = True
    except gpg.errors.BadSignatures as e:
        verified = False
        print(e)
 
    if verified is True:
        for i in range(len(result.signatures)):
            sign = result.signatures[i]
            print("""Good signature from:
    {0}
    with key {1}
    made at {2}
    """.format(c.get_key(sign.fpr).uids[0].uid, sign.fpr,
               time.ctime(sign.timestamp)))
    else:
        pass
 
 In both of the previous examples it is also possible to compare the
 original data that was signed against the signed data in ``data`` to see
 if it matches with something like this:
 
 .. code:: python
 
    with open(filename, "rb") as afile:
        text = afile.read()
 
    if text == data:
        print("Good signature.")
    else:
        pass
 
 The following two examples, however, deal with detached signatures. With
 his method of verification the data that was signed does not get
 returned since it is already being explicitly referenced in the first
 argument of ``c.verify``. So ``data`` is ``None`` and only the
 information in ``result`` is available.
 
 .. code:: python
 
    import gpg
    import time
 
    filename = "statement.txt"
    sig_file = "statement.txt.sig"
 
    c = gpg.Context()
 
    try:
        data, result = c.verify(open(filename), open(sig_file))
        verified = True
    except gpg.errors.BadSignatures as e:
        verified = False
        print(e)
 
    if verified is True:
        for i in range(len(result.signatures)):
            sign = result.signatures[i]
            print("""Good signature from:
    {0}
    with key {1}
    made at {2}
    """.format(c.get_key(sign.fpr).uids[0].uid, sign.fpr,
               time.ctime(sign.timestamp)))
    else:
        pass
 
 .. code:: python
 
    import gpg
    import time
 
    filename = "statement.txt"
    asc_file = "statement.txt.asc"
 
    c = gpg.Context()
 
    try:
        data, result = c.verify(open(filename), open(asc_file))
        verified = True
    except gpg.errors.BadSignatures as e:
        verified = False
        print(e)
 
    if verified is True:
        for i in range(len(result.signatures)):
            sign = result.signatures[i]
            print("""Good signature from:
    {0}
    with key {1}
    made at {2}
    """.format(c.get_key(sign.fpr).uids[0].uid, sign.fpr,
               time.ctime(sign.timestamp)))
    else:
        pass
 
 .. _key-generation:
 
 Creating keys and subkeys
 =========================
 
 The one thing, aside from GnuPG itself, that GPGME depends on, of
 course, is the keys themselves. So it is necessary to be able to
 generate them and modify them by adding subkeys, revoking or disabling
 them, sometimes deleting them and doing the same for user IDs.
 
 In the following examples a key will be created for the world\'s
 greatest secret agent, Danger Mouse. Since Danger Mouse is a secret
 agent he needs to be able to protect information to ``SECRET`` level
 clearance, so his keys will be 3072-bit keys.
 
 The pre-configured ``gpg.conf`` file which sets cipher, digest and other
 preferences contains the following configuration parameters:
 
 .. code:: conf
 
    expert
    allow-freeform-uid
    allow-secret-key-import
    trust-model tofu+pgp
    tofu-default-policy unknown
    enable-large-rsa
    enable-dsa2
    cert-digest-algo SHA512
    default-preference-list TWOFISH CAMELLIA256 AES256 CAMELLIA192 AES192 CAMELLIA128 AES BLOWFISH IDEA CAST5 3DES SHA512 SHA384 SHA256 SHA224 RIPEMD160 SHA1 ZLIB BZIP2 ZIP Uncompressed
    personal-cipher-preferences TWOFISH CAMELLIA256 AES256 CAMELLIA192 AES192 CAMELLIA128 AES BLOWFISH IDEA CAST5 3DES
    personal-digest-preferences SHA512 SHA384 SHA256 SHA224 RIPEMD160 SHA1
    personal-compress-preferences ZLIB BZIP2 ZIP Uncompressed
 
 .. _keygen-primary:
 
 Primary key
 -----------
 
 Generating a primary key uses the ``create_key`` method in a Context. It
 contains multiple arguments and keyword arguments, including:
 ``userid``, ``algorithm``, ``expires_in``, ``expires``, ``sign``,
 ``encrypt``, ``certify``, ``authenticate``, ``passphrase`` and
 ``force``. The defaults for all of those except ``userid``,
 ``algorithm``, ``expires_in``, ``expires`` and ``passphrase`` is
 ``False``. The defaults for ``algorithm`` and ``passphrase`` is
 ``None``. The default for ``expires_in`` is ``0``. The default for
 ``expires`` is ``True``. There is no default for ``userid``.
 
 If ``passphrase`` is left as ``None`` then the key will not be generated
 with a passphrase, if ``passphrase`` is set to a string then that will
 be the passphrase and if ``passphrase`` is set to ``True`` then
 gpg-agent will launch pinentry to prompt for a passphrase. For the sake
 of convenience, these examples will keep ``passphrase`` set to ``None``.
 
 .. code:: python
 
    import gpg
 
    c = gpg.Context()
 
    c.home_dir = "~/.gnupg-dm"
    userid = "Danger Mouse "
 
    dmkey = c.create_key(userid, algorithm="rsa3072", expires_in=31536000,
                         sign=True, certify=True)
 
 One thing to note here is the use of setting the ``c.home_dir``
 parameter. This enables generating the key or keys in a different
 location. In this case to keep the new key data created for this example
 in a separate location rather than adding it to existing and active key
 store data. As with the default directory, ``~/.gnupg``, any temporary
 or separate directory needs the permissions set to only permit access by
 the directory owner. On posix systems this means setting the directory
 permissions to 700.
 
 The ``temp-homedir-config.py`` script in the HOWTO examples directory
 will create an alternative homedir with these configuration options
 already set and the correct directory and file permissions.
 
 The successful generation of the key can be confirmed via the returned
 ``GenkeyResult`` object, which includes the following data:
 
 .. code:: python
 
    print("""
     Fingerprint:  {0}
     Primary Key:  {1}
      Public Key:  {2}
      Secret Key:  {3}
     Sub Key:  {4}
    User IDs:  {5}
    """.format(dmkey.fpr, dmkey.primary, dmkey.pubkey, dmkey.seckey, dmkey.sub,
               dmkey.uid))
 
 Alternatively the information can be confirmed using the command line
 program:
 
 .. code:: shell
 
    bash-4.4$ gpg --homedir ~/.gnupg-dm -K
    ~/.gnupg-dm/pubring.kbx
    ----------------------
    sec   rsa3072 2018-03-15 [SC] [expires: 2019-03-15]
      177B7C25DB99745EE2EE13ED026D2F19E99E63AA
    uid           [ultimate] Danger Mouse 
 
    bash-4.4$
 
 As with generating keys manually, to preconfigure expanded preferences
 for the cipher, digest and compression algorithms, the ``gpg.conf`` file
 must contain those details in the home directory in which the new key is
 being generated. I used a cut down version of my own ``gpg.conf`` file
 in order to be able to generate this:
 
 .. code:: shell
 
    bash-4.4$ gpg --homedir ~/.gnupg-dm --edit-key 177B7C25DB99745EE2EE13ED026D2F19E99E63AA showpref quit
    Secret key is available.
 
    sec  rsa3072/026D2F19E99E63AA
         created: 2018-03-15  expires: 2019-03-15  usage: SC
         trust: ultimate      validity: ultimate
    [ultimate] (1). Danger Mouse 
 
    [ultimate] (1). Danger Mouse 
         Cipher: TWOFISH, CAMELLIA256, AES256, CAMELLIA192, AES192, CAMELLIA128, AES, BLOWFISH, IDEA, CAST5, 3DES
         Digest: SHA512, SHA384, SHA256, SHA224, RIPEMD160, SHA1
         Compression: ZLIB, BZIP2, ZIP, Uncompressed
         Features: MDC, Keyserver no-modify
 
    bash-4.4$
 
 .. _keygen-subkeys:
 
 Subkeys
 -------
 
 Adding subkeys to a primary key is fairly similar to creating the
 primary key with the ``create_subkey`` method. Most of the arguments are
 the same, but not quite all. Instead of the ``userid`` argument there is
 now a ``key`` argument for selecting which primary key to add the subkey
 to.
 
 In the following example an encryption subkey will be added to the
 primary key. Since Danger Mouse is a security conscious secret agent,
 this subkey will only be valid for about six months, half the length of
 the primary key.
 
 .. code:: python
 
    import gpg
 
    c = gpg.Context()
    c.home_dir = "~/.gnupg-dm"
 
    key = c.get_key(dmkey.fpr, secret=True)
    dmsub = c.create_subkey(key, algorithm="rsa3072", expires_in=15768000,
                            encrypt=True)
 
 As with the primary key, the results here can be checked with:
 
 .. code:: python
 
    print("""
     Fingerprint:  {0}
     Primary Key:  {1}
      Public Key:  {2}
      Secret Key:  {3}
     Sub Key:  {4}
    User IDs:  {5}
    """.format(dmsub.fpr, dmsub.primary, dmsub.pubkey, dmsub.seckey, dmsub.sub,
               dmsub.uid))
 
 As well as on the command line with:
 
 .. code:: shell
 
    bash-4.4$ gpg --homedir ~/.gnupg-dm -K
    ~/.gnupg-dm/pubring.kbx
    ----------------------
    sec   rsa3072 2018-03-15 [SC] [expires: 2019-03-15]
      177B7C25DB99745EE2EE13ED026D2F19E99E63AA
    uid           [ultimate] Danger Mouse 
    ssb   rsa3072 2018-03-15 [E] [expires: 2018-09-13]
 
    bash-4.4$
 
 .. _keygen-uids:
 
 User IDs
 --------
 
 .. _keygen-uids-add:
 
 Adding User IDs
 ~~~~~~~~~~~~~~~
 
 By comparison to creating primary keys and subkeys, adding a new user ID
 to an existing key is much simpler. The method used to do this is
 ``key_add_uid`` and the only arguments it takes are for the ``key`` and
 the new ``uid``.
 
 .. code:: python
 
    import gpg
 
    c = gpg.Context()
    c.home_dir = "~/.gnupg-dm"
 
    dmfpr = "177B7C25DB99745EE2EE13ED026D2F19E99E63AA"
    key = c.get_key(dmfpr, secret=True)
    uid = "Danger Mouse "
 
    c.key_add_uid(key, uid)
 
 Unsurprisingly the result of this is:
 
 .. code:: shell
 
    bash-4.4$ gpg --homedir ~/.gnupg-dm -K
    ~/.gnupg-dm/pubring.kbx
    ----------------------
    sec   rsa3072 2018-03-15 [SC] [expires: 2019-03-15]
      177B7C25DB99745EE2EE13ED026D2F19E99E63AA
    uid           [ultimate] Danger Mouse 
    uid           [ultimate] Danger Mouse 
    ssb   rsa3072 2018-03-15 [E] [expires: 2018-09-13]
 
    bash-4.4$
 
 .. _keygen-uids-revoke:
 
 Revoking User IDs
 ~~~~~~~~~~~~~~~~~
 
 Revoking a user ID is a fairly similar process, except that it uses the
 ``key_revoke_uid`` method.
 
 .. code:: python
 
    import gpg
 
    c = gpg.Context()
    c.home_dir = "~/.gnupg-dm"
 
    dmfpr = "177B7C25DB99745EE2EE13ED026D2F19E99E63AA"
    key = c.get_key(dmfpr, secret=True)
    uid = "Danger Mouse "
 
    c.key_revoke_uid(key, uid)
 
 .. _key-sign:
 
 Key certification
 -----------------
 
 Since key certification is more frequently referred to as key signing,
 the method used to perform this function is ``key_sign``.
 
 The ``key_sign`` method takes four arguments: ``key``, ``uids``,
 ``expires_in`` and ``local``. The default value of ``uids`` is ``None``
 and which results in all user IDs being selected. The default value of
 both ``expires_in`` and ``local`` is ``False``; which results in the
 signature never expiring and being able to be exported.
 
 The ``key`` is the key being signed rather than the key doing the
 signing. To change the key doing the signing refer to the signing key
 selection above for signing messages and files.
 
 If the ``uids`` value is not ``None`` then it must either be a string to
 match a single user ID or a list of strings to match multiple user IDs.
 In this case the matching of those strings must be precise and it is
 case sensitive.
 
 To sign Danger Mouse\'s key for just the initial user ID with a
 signature which will last a little over a month, do this:
 
 .. code:: python
 
    import gpg
 
    c = gpg.Context()
    uid = "Danger Mouse "
 
    dmfpr = "177B7C25DB99745EE2EE13ED026D2F19E99E63AA"
    key = c.get_key(dmfpr, secret=True)
    c.key_sign(key, uids=uid, expires_in=2764800)
 
 .. _advanced-use:
 
 Advanced or Experimental Use Cases
 ==================================
 
 .. _cython:
 
 C plus Python plus SWIG plus Cython
 -----------------------------------
 
 In spite of the apparent incongruence of using Python bindings to a C
 interface only to generate more C from the Python; it is in fact quite
 possible to use the GPGME bindings with
 `Cython `__. Though in many
 cases the benefits may not be obvious since the most computationally
 intensive work never leaves the level of the C code with which GPGME
 itself is interacting with.
 
 Nevertheless, there are some situations where the benefits are
 demonstrable. One of the better and easier examples being the one of the
 early examples in this HOWTO, the `key
 counting <#howto-keys-counting>`__ code. Running that example as an
 executable Python script, ``keycount.py`` (available in the
-``examples/howto/`` directory), will take a noticable amount of time to
+``examples/howto/`` directory), will take a noticeable amount of time to
 run on most systems where the public keybox or keyring contains a few
 thousand public keys.
 
 Earlier in the evening, prior to starting this section, I ran that
 script on my laptop; as I tend to do periodically and timed it using
 ``time`` utility, with the following results:
 
 .. code:: shell
 
    bash-4.4$ time keycount.py
 
    Number of secret keys:  23
    Number of public keys:  12112
 
 
    real  11m52.945s
    user  0m0.913s
    sys   0m0.752s
 
    bash-4.4$
 
 Sometime after that I imported another key and followed it with a little
 test of Cython. This test was kept fairly basic, essentially lifting the
 material from the `Cython Basic
 Tutorial `__
 to demonstrate compiling Python code to C. The first step was to take
 the example key counting code quoted previously, essentially from the
 importing of the ``gpg`` module to the end of the script:
 
 .. code:: python
 
    import gpg
 
    c = gpg.Context()
    seckeys = c.keylist(pattern=None, secret=True)
    pubkeys = c.keylist(pattern=None, secret=False)
 
    seclist = list(seckeys)
    secnum = len(seclist)
 
    publist = list(pubkeys)
    pubnum = len(publist)
 
    print("""
        Number of secret keys:  {0}
        Number of public keys:  {1}
 
    """.format(secnum, pubnum))
 
 Save that into a file called ``keycount.pyx`` and then create a
 ``setup.py`` file which contains this:
 
 .. code:: python
 
    from distutils.core import setup
    from Cython.Build import cythonize
 
    setup(
        ext_modules = cythonize("keycount.pyx")
    )
 
 Compile it:
 
 .. code:: shell
 
    bash-4.4$ python setup.py build_ext --inplace
    bash-4.4$
 
 Then run it in a similar manner to ``keycount.py``:
 
 .. code:: shell
 
    bash-4.4$ time python3.7 -c "import keycount"
 
    Number of secret keys:  23
    Number of public keys:  12113
 
 
    real  6m47.905s
    user  0m0.785s
    sys   0m0.331s
 
    bash-4.4$
 
 Cython turned ``keycount.pyx`` into an 81KB ``keycount.o`` file in the
 ``build/`` directory, a 24KB ``keycount.cpython-37m-darwin.so`` file to
 be imported into Python 3.7 and a 113KB ``keycount.c`` generated C
 source code file of nearly three thousand lines. Quite a bit bigger than
 the 314 bytes of the ``keycount.pyx`` file or the full 1,452 bytes of
 the full executable ``keycount.py`` example script.
 
 On the other hand it ran in nearly half the time; taking 6 minutes and
 47.905 seconds to run. As opposed to the 11 minutes and 52.945 seconds
 which the CPython script alone took.
 
 The ``keycount.pyx`` and ``setup.py`` files used to generate this
 example have been added to the ``examples/howto/advanced/cython/``
 directory The example versions include some additional options to
 annotate the existing code and to detect Cython\'s use. The latter comes
 from the `Magic
 Attributes `__
 section of the Cython documentation.
 
 .. _cheats-and-hacks:
 
 Miscellaneous extras and work-arounds
 =====================================
 
 Most of the things in the following sections are here simply because
 there was no better place to put them, even though some are only
 peripherally related to the GPGME Python bindings. Some are also
 workarounds for functions not integrated with GPGME as yet. This is
 especially true of the first of these, dealing with `group
 lines <#group-lines>`__.
 
 Group lines
 -----------
 
 There is not yet an easy way to access groups configured in the gpg.conf
 file from within GPGME. As a consequence these central groupings of keys
 cannot be shared amongst multiple programs, such as MUAs readily.
 
 The following code, however, provides a work-around for obtaining this
 information in Python.
 
 .. code:: python
 
    import subprocess
    import sys
 
    if sys.platform == "win32":
        gpgconfcmd = "gpgconf.exe --list-options gpg"
    else:
        gpgconfcmd = "gpgconf --list-options gpg"
 
    try:
        lines = subprocess.getoutput(gpgconfcmd).splitlines()
    except:
        process = subprocess.Popen(gpgconfcmd.split(), stdout=subprocess.PIPE)
        procom = process.communicate()
        if sys.version_info[0] == 2:
            lines = procom[0].splitlines()
        else:
            lines = procom[0].decode().splitlines()
 
    for i in range(len(lines)):
        if lines[i].startswith("group") is True:
            line = lines[i]
        else:
            pass
 
    groups = line.split(":")[-1].replace('"', '').split(',')
 
    group_lines = []
    group_lists = []
 
    for i in range(len(groups)):
        group_lines.append(groups[i].split("="))
        group_lists.append(groups[i].split("="))
 
    for i in range(len(group_lists)):
        group_lists[i][1] = group_lists[i][1].split()
 
 The result of that code is that ``group_lines`` is a list of lists where
 ``group_lines[i][0]`` is the name of the group and ``group_lines[i][1]``
 is the key IDs of the group as a string.
 
 The ``group_lists`` result is very similar in that it is a list of
 lists. The first part, ``group_lists[i][0]`` matches
 ``group_lines[i][0]`` as the name of the group, but
 ``group_lists[i][1]`` is the key IDs of the group as a list.
 
 A demonstration of using the ``groups.py`` module is also available in
 the form of the executable ``mutt-groups.py`` script. This second script
 reads all the group entries in a user\'s ``gpg.conf`` file and converts
 them into crypt-hooks suitable for use with the Mutt and Neomutt mail
 clients.
 
 .. _hkp4py:
 
 Keyserver access for Python
 ---------------------------
 
 The `hkp4py `__ module by Marcel Fest
 was originally a port of the old
 `python-hkp `__ module from
 Python 2 to Python 3 and updated to use the
 `requests `__
 module instead. It has since been modified to provide support for Python
 2.7 as well and is available via PyPI.
 
 Since it rewrites the ``hkp`` protocol prefix as ``http`` and ``hkps``
 as ``https``, the module is able to be used even with servers which do
 not support the full scope of keyserver functions. [5]_ It also works
 quite readily when incorporated into a `Cython <#cython>`__ generated
 and compiled version of any code.
 
 .. _hkp4py-strings:
 
 Key import format
 ~~~~~~~~~~~~~~~~~
 
 The hkp4py module returns key data via requests as string literals
 (``r.text``) instead of byte literals (``r.content``). This means that
 the retrurned key data must be encoded to UTF-8 when importing that key
 material using a ``gpg.Context().key_import()`` method.
 
 For this reason an alternative method has been added to the ``search``
 function of ``hkp4py.KeyServer()`` which returns the key in the correct
 format as expected by ``key_import``. When importing using this module,
 it is now possible to import with this:
 
 .. code:: python
 
    for key in keys:
        if key.revoked is False:
            gpg.Context().key_import(key.key_blob)
        else:
            pass
 
 Without that recent addition it would have been necessary to encode the
 contents of each ``hkp4py.KeyServer().search()[i].key`` in
 ``hkp4py.KeyServer().search()`` before trying to import it.
 
 An example of this is included in the `Importing
 Keys <#howto-import-key>`__ section of this HOWTO and the corresponding
 executable version of that example is available in the
 ``lang/python/examples/howto`` directory as normal; the executable
 version is the ``import-keys-hkp.py`` file.
 
 .. _copyright-and-license:
 
 Copyright and Licensing
 =======================
 
 Copyright
 ---------
 
 Copyright © The GnuPG Project, 2018.
 
 Copyright (C) The GnuPG Project, 2018.
 
 .. _draft-editions:
 
 Draft Editions of this HOWTO
 ----------------------------
 
 Draft editions of this HOWTO may be periodically available directly from
 the author at any of the following URLs:
 
 -  `GPGME Python Bindings HOWTO draft (XHTML AWS S3
    SSL) `__
 -  `GPGME Python Bindings HOWTO draft (XHTML AWS S3 no
    SSL) `__
 -  `GPGME Python Bindings HOWTO draft (Texinfo file AWS S3
    SSL) `__
 -  `GPGME Python Bindings HOWTO draft (Texinfo file AWS S3 no
    SSL) `__
 -  `GPGME Python Bindings HOWTO draft (Info file AWS S3
    SSL) `__
 -  `GPGME Python Bindings HOWTO draft (Info file AWS S3 no
    SSL) `__
 -  `GPGME Python Bindings HOWTO draft (reST file AWS S3
    SSL) `__
 -  `GPGME Python Bindings HOWTO draft (reST file AWS S3 no
    SSL) `__
 -  `GPGME Python Bindings HOWTO draft (Docbook 4.2 AWS S3
    SSL) `__
 -  `GPGME Python Bindings HOWTO draft (Docbook 4.2 AWS S3 no
    SSL) `__
 
 All of these draft versions except for one have been generated from this
 document via Emacs `Org mode `__ and `GNU
 Texinfo `__. Though it is likely
 that the specific
 `file `__
 `version `__
 used will be on the same server with the generated output formats.
 
 The one exception is the reStructuredText version, which was converted
 using the latest version of Pandoc from the Org mode source file using
 either of the following two commands:
 
 .. code:: shell
 
    pandoc -f org -t rst -o gpgme-python-howto.rst gpgme-python-howto.org
    pandoc -f org -t rst -o gpgme-python-howto.rst gpgme-python-howto
 
 In addition to these there is a significantly less frequently updated
 version as a HTML `WebHelp
 site `__
 (AWS S3 SSL); generated from DITA XML source files, which can be found
 in `an alternative
 branch `__
 of the GPGME git repository.
 
 These draft editions are not official documents and the version of
 documentation in the master branch or which ships with released versions
 is the only official documentation. Nevertheless, these draft editions
 may occasionally be of use by providing more accessible web versions
 which are updated between releases. They are provided on the
 understanding that they may contain errors or may contain content
 subject to change prior to an official release.
 
 .. _license:
 
 License GPL compatible
 ----------------------
 
 This file is free software; as a special exception the author gives
 unlimited permission to copy and/or distribute it, with or without
 modifications, as long as this notice is preserved.
 
 This file is distributed in the hope that it will be useful, but WITHOUT
 ANY WARRANTY, to the extent permitted by law; without even the implied
 warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
 
 Footnotes
 =========
 
 .. [1]
    ``short-history`` and/or ``short-history.html``.
 
 .. [2]
    With no issues reported specific to Python 3.7, the release of Python
    3.7.1 at around the same time as GPGME 1.12.0 and the testing with
    Python 3.7.1rc1, there is no reason to delay moving 3.7 ahead of 3.6
    now. Production environments with more conservative requirements will
    always enforce their own policies anyway and installation to each
    supported minor release is quite possible too.
 
 .. [3]
    Yes, even if you use virtualenv with everything you do in Python. If
    you want to install this module as just your user account then you
    will need to manually configure, compile and install the *entire*
    GnuPG stack as that user as well. This includes libraries which are
    not often installed that way. It can be done and there are
    circumstances under which it is worthwhile, but generally only on
    POSIX systems which utilise single user mode (some even require it).
 
 .. [4]
    You probably don\'t really want to do this. Searching the keyservers
    for \"gnupg.org\" produces over 400 results, the majority of which
    aren\'t actually at the gnupg.org domain, but just included a comment
    regarding the project in their key somewhere.
 
 .. [5]
    Such as with ProtonMail servers. This also means that restricted
    servers which only advertise either HTTP or HTTPS end points and not
    HKP or HKPS end points must still be identified as as HKP or HKPS
    within the Python Code. The ``hkp4py`` module will rewrite these
    appropriately when the connection is made to the server.
diff --git a/lang/python/doc/src/gpgme-python-howto b/lang/python/doc/src/gpgme-python-howto
index 4ad5bc41..e12dc364 100644
--- a/lang/python/doc/src/gpgme-python-howto
+++ b/lang/python/doc/src/gpgme-python-howto
@@ -1,3002 +1,3002 @@
 # -*- mode: org -*-
 #+TITLE: GNU Privacy Guard (GnuPG) Made Easy Python Bindings HOWTO (English)
 #+AUTHOR: Ben McGinnes
 #+LATEX_COMPILER: xelatex
 #+LATEX_CLASS: article
 #+LATEX_CLASS_OPTIONS: [12pt]
 #+LATEX_HEADER: \usepackage{xltxtra}
 #+LATEX_HEADER: \usepackage[margin=1in]{geometry}
 #+LATEX_HEADER: \setmainfont[Ligatures={Common}]{Times New Roman}
 #+LATEX_HEADER: \author{Ben McGinnes }
 
 
 * Introduction
   :PROPERTIES:
   :CUSTOM_ID: intro
   :END:
 
 | Version:        | 0.1.4                                    |
 | GPGME Version:  | 1.12.0                                   |
 | Author:         | [[https://gnupg.org/people/index.html#sec-1-5][Ben McGinnes]]              |
 | Author GPG Key: | DB4724E6FA4286C92B4E55C4321E4E2373590E5D |
 | Language:       | Australian English, British English      |
 | xml:lang:       | en-AU, en-GB, en                         |
 
 This document provides basic instruction in how to use the GPGME
 Python bindings to programmatically leverage the GPGME library.
 
 
 ** Python 2 versus Python 3
    :PROPERTIES:
    :CUSTOM_ID: py2-vs-py3
    :END:
 
 Though the GPGME Python bindings themselves provide support for both
 Python 2 and 3, the focus is unequivocally on Python 3 and
 specifically from Python 3.4 and above.  As a consequence all the
 examples and instructions in this guide use Python 3 code.
 
 Much of it will work with Python 2, but much of it also deals with
 Python 3 byte literals, particularly when reading and writing data.
 Developers concentrating on Python 2.7, and possibly even 2.6, will
 need to make the appropriate modifications to support the older string
 and unicode types as opposed to bytes.
 
 There are multiple reasons for concentrating on Python 3; some of
 which relate to the immediate integration of these bindings, some of
 which relate to longer term plans for both GPGME and the python
 bindings and some of which relate to the impending EOL period for
 Python 2.7.  Essentially, though, there is little value in tying the
 bindings to a version of the language which is a dead end and the
 advantages offered by Python 3 over Python 2 make handling the data
 types with which GPGME deals considerably easier.
 
 
 ** Examples
    :PROPERTIES:
    :CUSTOM_ID: howto-python3-examples
    :END:
 
 All of the examples found in this document can be found as Python 3
 scripts in the =lang/python/examples/howto= directory.
 
 
 ** Unofficial Drafts
    :PROPERTIES:
    :CUSTOM_ID: unofficial-drafts
    :END:
 
 In addition to shipping with each release of GPGME, there is a section
 on locations to read or download [[#draft-editions][draft editions]] of this document from
 at the end of it.  These are unofficial versions produced in between
 major releases.
 
 
 ** What's New
    :PROPERTIES:
    :CUSTOM_ID: new-stuff
    :END:
 
 Full details of what is new are now available in the [[file:what-is-new.org][What's New]] file
 and archives of the preceding /What's New/ sections are available in
 the [[file:what-was-new][What Was New]] file.
 
 
 *** New in GPGME 1·13·0
     :PROPERTIES:
     :CUSTOM_ID: new-stuff-1-13-0
     :END:
 
 See the [[file:what-is-new#new-stuff-1-13-0][What's New]] document for what is new in version 1.13.0.
 
 
 *** New in GPGME 1·12·0
     :PROPERTIES:
     :CUSTOM_ID: new-stuff-1-12-0
     :END:
 
 See the [[file:what-was-new#new-stuff-1-12-0][What Was New]] document for what was new in version 1.12.0.
 
 
 * GPGME Concepts
   :PROPERTIES:
   :CUSTOM_ID: gpgme-concepts
   :END:
 
 
 ** A C API
    :PROPERTIES:
    :CUSTOM_ID: gpgme-c-api
    :END:
 
 Unlike many modern APIs with which programmers will be more familiar
 with these days, the GPGME API is a C API.  The API is intended for
 use by C coders who would be able to access its features by including
 the =gpgme.h= header file with their own C source code and then access
 its functions just as they would any other C headers.
 
 This is a very effective method of gaining complete access to the API
 and in the most efficient manner possible.  It does, however, have the
 drawback that it cannot be directly used by other languages without
 some means of providing an interface to those languages.  This is
 where the need for bindings in various languages stems.
 
 
 ** Python bindings
    :PROPERTIES:
    :CUSTOM_ID: gpgme-python-bindings
    :END:
 
 The Python bindings for GPGME provide a higher level means of
 accessing the complete feature set of GPGME itself.  It also provides
 a more pythonic means of calling these API functions.
 
 The bindings are generated dynamically with SWIG and the copy of
 =gpgme.h= generated when GPGME is compiled.
 
 This means that a version of the Python bindings is fundamentally tied
 to the exact same version of GPGME used to generate that copy of
 =gpgme.h=.
 
 
 ** Difference between the Python bindings and other GnuPG Python packages
    :PROPERTIES:
    :CUSTOM_ID: gpgme-python-bindings-diffs
    :END:
 
 There have been numerous attempts to add GnuPG support to Python over
 the years.  Some of the most well known are listed here, along with
 what differentiates them.
 
 
 *** The python-gnupg package maintained by Vinay Sajip
     :PROPERTIES:
     :CUSTOM_ID: diffs-python-gnupg
     :END:
 
 This is arguably the most popular means of integrating GPG with
 Python.  The package utilises the =subprocess= module to implement
 wrappers for the =gpg= and =gpg2= executables normally invoked on the
 command line (=gpg.exe= and =gpg2.exe= on Windows).
 
 The popularity of this package stemmed from its ease of use and
 capability in providing the most commonly required features.
 
 Unfortunately it has been beset by a number of security issues in the
 past; most of which stemmed from using unsafe methods of accessing the
 command line via the =subprocess= calls.  While some effort has been
 made over the last two to three years (as of 2018) to mitigate this,
 particularly by no longer providing shell access through those
 subprocess calls, the wrapper is still somewhat limited in the scope
 of its GnuPG features coverage.
 
 The python-gnupg package is available under the MIT license.
 
 
 *** The gnupg package created and maintained by Isis Lovecruft
     :PROPERTIES:
     :CUSTOM_ID: diffs-isis-gnupg
     :END:
 
 In 2015 Isis Lovecruft from the Tor Project forked and then
 re-implemented the python-gnupg package as just gnupg.  This new
 package also relied on subprocess to call the =gpg= or =gpg2=
 binaries, but did so somewhat more securely.
 
 The naming and version numbering selected for this package, however,
 resulted in conflicts with the original python-gnupg and since its
 functions were called in a different manner to python-gnupg, the
 release of this package also resulted in a great deal of consternation
 when people installed what they thought was an upgrade that
 subsequently broke the code relying on it.
 
 The gnupg package is available under the GNU General Public License
 version 3.0 (or any later version).
 
 
 *** The PyME package maintained by Martin Albrecht
     :PROPERTIES:
     :CUSTOM_ID: diffs-pyme
     :END:
 
 This package is the origin of these bindings, though they are somewhat
 different now.  For details of when and how the PyME package was
 folded back into GPGME itself see the [[file:short-history.org][Short History]] document.[fn:1]
 
 The PyME package was first released in 2002 and was also the first
 attempt to implement a low level binding to GPGME.  In doing so it
 provided access to considerably more functionality than either the
 =python-gnupg= or =gnupg= packages.
 
 The PyME package is only available for Python 2.6 and 2.7.
 
 Porting the PyME package to Python 3.4 in 2015 is what resulted in it
 being folded into the GPGME project and the current bindings are the
 end result of that effort.
 
 The PyME package is available under the same dual licensing as GPGME
 itself: the GNU General Public License version 2.0 (or any later
 version) and the GNU Lesser General Public License version 2.1 (or any
 later version).
 
 
 * GPGME Python bindings installation
   :PROPERTIES:
   :CUSTOM_ID: gpgme-python-install
   :END:
 
 
 ** No PyPI
    :PROPERTIES:
    :CUSTOM_ID: do-not-use-pypi
    :END:
 
 Most third-party Python packages and modules are available and
 distributed through the Python Package Installer, known as PyPI.
 
 Due to the nature of what these bindings are and how they work, it is
 infeasible to install the GPGME Python bindings in the same way.
 
 This is because the bindings use SWIG to dynamically generate C
 bindings against =gpgme.h= and =gpgme.h= is generated from
 =gpgme.h.in= at compile time when GPGME is built from source.  Thus to
 include a package in PyPI which actually built correctly would require
 either statically built libraries for every architecture bundled with
 it or a full implementation of C for each architecture.
 
 See the additional notes regarding [[#snafu-cffi][CFFI and SWIG]] at the end of this
 section for further details.
 
 
 ** Requirements
    :PROPERTIES:
    :CUSTOM_ID: gpgme-python-requirements
    :END:
 
 The GPGME Python bindings only have three requirements:
 
 1. A suitable version of Python 2 or Python 3.  With Python 2 that
    means CPython 2.7 and with Python 3 that means CPython 3.4 or
    higher.
 2. [[https://www.swig.org][SWIG]].
 3. GPGME itself.  Which also means that all of GPGME's dependencies
    must be installed too.
 
 
 *** Recommended Additions
    :PROPERTIES:
    :CUSTOM_ID: gpgme-python-recommendations
    :END:
 
 Though none of the following are absolute requirements, they are all
 recommended for use with the Python bindings.  In some cases these
 recommendations refer to which version(s) of CPython to use the
 bindings with, while others refer to third party modules which provide
 a significant advantage in some way.
 
 1. If possible, use Python 3 instead of 2.
 2. Favour a more recent version of Python since even 3.4 is due to
    reach EOL soon.  In production systems and services, Python 3.6
    should be robust enough to be relied on.
 3. If possible add the following Python modules which are not part of
    the standard library: [[http://docs.python-requests.org/en/latest/index.html][Requests]], [[https://cython.org/][Cython]] and [[https://github.com/Selfnet/hkp4py][hkp4py]].  Chances are
    quite high that at least the first one and maybe two of those will
    already be installed.
 
 Note that, as with Cython, some of the planned additions to the
 [[#advanced-use][Advanced]] section, will bring with them additional requirements.  Most
 of these will be fairly well known and commonly installed ones,
 however, which are in many cases likely to have already been installed
 on many systems or be familiar to Python programmers.
 
 
 ** Installation
    :PROPERTIES:
    :CUSTOM_ID: installation
    :END:
 
 Installing the Python bindings is effectively achieved by compiling
 and installing GPGME itself.
 
 Once SWIG is installed with Python and all the dependencies for GPGME
 are installed you only need to confirm that the version(s) of Python
 you want the bindings installed for are in your =$PATH=.
 
 By default GPGME will attempt to install the bindings for the most
 recent or highest version number of Python 2 and Python 3 it detects
 in =$PATH=.  It specifically checks for the =python= and =python3=
 executables first and then checks for specific version numbers.
 
 For Python 2 it checks for these executables in this order: =python=,
 =python2= and =python2.7=.
 
 For Python 3 it checks for these executables in this order: =python3=,
  =python3.7=, =python3.6=, =python3.5= and =python3.4=.[fn:2]
 
 On systems where =python= is actually =python3= and not =python2= it
 may be possible that =python2= may be overlooked, but there have been
 no reports of that actually occurring as yet.
 
 In the three months or so since the release of Python 3.7.0 there has
 been extensive testing and work with these bindings with no issues
 specifically relating to the new version of Python or any of the new
 features of either the language or the bindings.  This has also been
 the case with Python 3.7.1rc1.  With that in mind and given the
 release of Python 3.7.1 is scheduled for around the same time as GPGME
 1.12.0, the order of preferred Python versions has been changed to
 move Python 3.7 ahead of Python 3.6.
 
 
 *** Installing GPGME
     :PROPERTIES:
     :CUSTOM_ID: install-gpgme
     :END:
 
 See the GPGME =README= file for details of how to install GPGME from
 source.
 
 
 ** Known Issues
    :PROPERTIES:
    :CUSTOM_ID: snafu
    :END:
 
 There are a few known issues with the current build process and the
 Python bindings.  For the most part these are easily addressed should
 they be encountered.
 
 
 *** Breaking Builds
     :PROPERTIES:
     :CUSTOM_ID: snafu-a-swig-of-this-builds-character
     :END:
 
 Occasionally when installing GPGME with the Python bindings included
 it may be observed that the =make= portion of that process induces a
 large very number of warnings and, eventually errors which end that
 part of the build process.  Yet following that with =make check= and
 =make install= appears to work seamlessly.
 
 The cause of this is related to the way SWIG needs to be called to
 dynamically generate the C bindings for GPGME in the first place.  So
 the entire process will always produce =lang/python/python2-gpg/= and
 =lang/python/python3-gpg/= directories.  These should contain the
 build output generated during compilation, including the complete
 bindings and module installed into =site-packages=.
 
 Occasionally the errors in the early part or some other conflict
 (e.g. not installing as */root/* or */su/*) may result in nothing
 being installed to the relevant =site-packages= directory and the
 build directory missing a lot of expected files.  Even when this
 occurs, the solution is actually quite simple and will always work.
 
 That solution is simply to run the following commands as either the
 *root* user or prepended with =sudo -H=[fn:3] in the =lang/python/=
 directory:
 
 #+BEGIN_SRC shell
   /path/to/pythonX.Y setup.py build
   /path/to/pythonX.Y setup.py build
   /path/to/pythonX.Y setup.py install
 #+END_SRC
 
 Yes, the build command does need to be run twice.  Yes, you still need
 to run the potentially failing or incomplete steps during the
 =configure=, =make= and =make install= steps with installing GPGME.
 This is because those steps generate a lot of essential files needed,
 both by and in order to create, the bindings (including both the
 =setup.py= and =gpgme.h= files).
 
 
 **** IMPORTANT Note
      :PROPERTIES:
      :CUSTOM_ID: snafu-swig-build-note
      :END:
 
 If specifying a selected number of languages to create bindings for,
 try to leave Python last.  Currently the majority of the other
 language bindings are also preceding Python of either version when
 listed alphabetically and so that just happens by default currently.
 
 If Python is set to precede one of the other languages then it is
 possible that the errors described here may interrupt the build
 process before generating bindings for those other languages.  In
 these cases it may be preferable to configure all preferred language
 bindings separately with alternative =configure= steps for GPGME using
 the =--enable-languages=$LANGUAGE= option.
 
 
 *** Reinstalling Responsibly
     :PROPERTIES:
     :CUSTOM_ID: snafu-lessons-for-the-lazy
     :END:
 
 Regardless of whether you're installing for one version of Python or
 several, there will come a point where reinstallation is required.
 With most Python module installations, the installed files go into the
 relevant site-packages directory and are then forgotten about.  Then
 the module is upgraded, the new files are copied over the old and
 that's the end of the matter.
 
 While the same is true of these bindings, there have been intermittent
 issues observed on some platforms which have benefited significantly
 from removing all the previous installations of the bindings before
 installing the updated versions.
 
 Removing the previous version(s) is simply a matter of changing to the
 relevant =site-packages= directory for the version of Python in
 question and removing the =gpg/= directory and any accompanying
 egg-info files for that module.
 
 In most cases this will require root or administration privileges on
 the system, but the same is true of installing the module in the first
 place.
 
 
 *** Multiple installations
     :PROPERTIES:
     :CUSTOM_ID: snafu-the-full-monty
     :END:
 
 For a variety of reasons it may be either necessary or just preferable
 to install the bindings to alternative installed Python versions which
 meet the requirements of these bindings.
 
 On POSIX systems this will generally be most simply achieved by
 running the manual installation commands (build, build, install) as
 described in the previous section for each Python installation the
 bindings need to be installed to.
 
 As per the SWIG documentation: the compilers, libraries and runtime
 used to build GPGME and the Python Bindings *must* match those used to
 compile Python itself, including the version number(s) (at least going
 by major version numbers and probably minor numbers too).
 
 On most POSIX systems, including OS X, this will very likely be the
 case in most, if not all, cases.
 
 Note that from GPGME [[https://dev.gnupg.org/rMff6ff616aea6f59b7f2ce1176492850ecdf3851e][1.12.1]] the default installation installs to each
 version of Python it can find first.  That is that it will currently
 install for the first copies of Python versions 2.7, 3.4, 3.5, 3.6,
 3.7 and 3.8 (dev branch) that it finds.  Usually this will be in the
 same prefix as GPGME itself, but is dictated by the =$PATH= when the
 installation is performed.  The above instructions can still be
 performed on other python installations which the installer does not
 find, including alternative prefixes.
 
 
 
 *** Won't Work With Windows
     :PROPERTIES:
     :CUSTOM_ID: snafu-runtime-not-funtime
     :END:
 
 There are semi-regular reports of Windows users having considerable
 difficulty in installing and using the Python bindings at all.  Very
 often, possibly even always, these reports come from Cygwin users
 and/or MinGW users and/or Msys2 users.  Though not all of them have
 been confirmed, it appears that these reports have also come from
 people who installed Python using the Windows installer files from the
 [[https://python.org][Python website]] (i.e. mostly MSI installers, sometimes self-extracting
 =.exe= files).
 
 The Windows versions of Python are not built using Cygwin, MinGW or
 Msys2; they're built using Microsoft Visual Studio.  Furthermore the
 version used is /considerably/ more advanced than the version which
 MinGW obtained a small number of files from many years ago in order to
 be able to compile anything at all.  Not only that, but there are
 changes to the version of Visual Studio between some micro releases,
 though that is is particularly the case with Python 2.7, since it has
 been kept around far longer than it should have been.
 
 There are two theoretical solutions to this issue:
 
  1. Compile and install the GnuPG stack, including GPGME and the
     Python bibdings using the same version of Microsoft Visual Studio
     used by the Python Foundation to compile the version of Python
     installed.
 
     If there are multiple versions of Python then this will need to be
     done with each different version of Visual Studio used.
 
  2. Compile and install Python using the same tools used by choice,
     such as MinGW or Msys2.
 
 Do *not* use the official Windows installer for Python unless
 following the first method.
 
 In this type of situation it may even be for the best to accept that
 there are less limitations on permissive software than free software
 and simply opt to use a recent version of the Community Edition of
 Microsoft Visual Studio to compile and build all of it, no matter
 what.
 
 Investigations into the extent or the limitations of this issue are
 ongoing.
 
 
 *** CFFI is the Best™ and GPGME should use it instead of SWIG
     :PROPERTIES:
     :CUSTOM_ID: snafu-cffi
     :END:
 
 There are many reasons for favouring [[https://cffi.readthedocs.io/en/latest/overview.html][CFFI]] and proponents of it are
 quite happy to repeat these things as if all it would take to switch
 from SWIG to CFFI is repeating that list as if it were a new concept.
 
 The fact is that there are things which Python's CFFI implementation
 cannot handle in the GPGME C code.  Beyond that there are features of
 SWIG which are simply not available with CFFI at all.  SWIG generates
 the bindings to Python using the =gpgme.h= file, but that file is not
 a single version shipped with each release, it too is generated when
 GPGME is compiled.
 
 CFFI is currently unable to adapt to such a potentially mutable
 codebase.  If there were some means of applying SWIG's dynamic code
 generation to produce the Python/CFFI API modes of accessing the GPGME
 libraries (or the source source code directly), but such a thing does
 not exist yet either and it currently appears that work is needed in
 at least one of CFFI's dependencies before any of this can be
 addressed.
 
 So if you're a massive fan of CFFI; that's great, but if you want this
 project to switch to CFFI then rather than just insisting that it
 should, I'd suggest you volunteer to bring CFFI up to the level this
 project needs.
 
 If you're actually seriously considering doing so, then I'd suggest
 taking the =gpgme-tool.c= file in the GPGME =src/= directory and
 getting that to work with any of the CFFI API methods (not the ABI
 methods, they'll work with pretty much anything).  When you start
 running into trouble with "ifdefs" then you'll know what sort of
 things are lacking.  That doesn't even take into account the amount of
 work saved via SWIG's code generation techniques either.
 
 
 *** Virtualised Environments
     :PROPERTIES:
     :CUSTOM_ID: snafu-venv
     :END:
 
 It is fairly common practice amongst Python developers to, as much as
 possible, use packages like virtualenv to keep various things that are
 to be installed from interfering with each other.  Given how much of
 the GPGME bindings is often at odds with the usual pythonic way of
 doing things, it stands to reason that this would be called into
 question too.
 
 As it happens the answer as to whether or not the bindings can be used
 with virtualenv, the answer is both yes and no.
 
 In general we recommend installing to the relevant path and matching
 prefix of GPGME itself.  Which means that when GPGME, and ideally the
 rest of the GnuPG stack, is installed to a prefix like =/usr/local= or
 =/opt/local= then the bindings would need to be installed to the main
 Python installation and not a virtualised abstraction.  Attempts to
 separate the two in the past have been known to cause weird and
 intermittent errors ranging from minor annoyances to complete failures
 in the build process.
 
 As a consequence we only recommend building with and installing to the
 main Python installations within the same prefix as GPGME is installed
 to or which are found by GPGME's configuration stage immediately prior
 to running the make commands.  Which is exactly what the compiling and
 installing process of GPGME does by default.
 
 Once that is done, however, it appears that a copy of the compiled
 module may be installed into a virtualenv of the same major and minor
 version matching the build.  Alternatively it is possible to utilise a
 =sites.pth= file in the =site-packages/= directory of a virtualenv
 installation, which links back to the system installations
 corresponding directory in order to import anything installed system
 wide.  This may or may not be appropriate on a case by case basis.
 
 Though extensive testing of either of these options is not yet
 complete, preliminary testing of them indicates that both are viable
 as long as the main installation is complete.  Which means that
 certain other options normally restricted to virtual environments are
 also available, including integration with pythonic test suites
 (e.g. [[https://docs.pytest.org/en/latest/index.html][pytest]]) and other large projects.
 
 That said, it is worth reiterating the warning regarding non-standard
 installations.  If one were to attempt to install the bindings only to
 a virtual environment without somehow also including the full GnuPG
 stack (or enough of it as to include GPGME) then it is highly likely
 that errors would be encountered at some point and more than a little
 likely that the build process itself would break.
 
 If a degree of separation from the main operating system is still
 required in spite of these warnings, then consider other forms of
 virtualisation.  Either a virtual machine (e.g. [[https://www.virtualbox.org/][VirtualBox]]), a
 hardware emulation layer (e.g. [[https://www.qemu.org/][QEMU]]) or an application container
 (e.g. [[https://www.docker.com/why-docker][Docker]]).
 
 Finally it should be noted that the limited tests conducted thus far
 have been using the =virtualenv= command in a new directory to create
 the virtual python environment.  As opposed to the standard =python3
 -m venv= and it is possible that this will make a difference depending
 on the system and version of Python in use.  Another option is to run
 the command =python3 -m virtualenv /path/to/install/virtual/thingy=
 instead.
 
 
 * Fundamentals
   :PROPERTIES:
   :CUSTOM_ID: howto-fund-a-mental
   :END:
 
 Before we can get to the fun stuff, there are a few matters regarding
 GPGME's design which hold true whether you're dealing with the C code
 directly or these Python bindings.
 
 
 ** No REST
    :PROPERTIES:
    :CUSTOM_ID: no-rest-for-the-wicked
    :END:
 
 The first part of which is or will be fairly blatantly obvious upon
 viewing the first example, but it's worth reiterating anyway.  That
 being that this API is /*not*/ a REST API.  Nor indeed could it ever
 be one.
 
 Most, if not all, Python programmers (and not just Python programmers)
 know how easy it is to work with a RESTful API.  In fact they've
 become so popular that many other APIs attempt to emulate REST-like
 behaviour as much as they are able.  Right down to the use of JSON
 formatted output to facilitate the use of their API without having to
 retrain developers.
 
 This API does not do that.  It would not be able to do that and also
 provide access to the entire C API on which it's built.  It does,
 however, provide a very pythonic interface on top of the direct
 bindings and it's this pythonic layer that this HOWTO deals with.
 
 
 ** Context
    :PROPERTIES:
    :CUSTOM_ID: howto-get-context
    :END:
 
 One of the reasons which prevents this API from being RESTful is that
 most operations require more than one instruction to the API to
 perform the task.  Sure, there are certain functions which can be
 performed simultaneously, particularly if the result known or strongly
 anticipated (e.g. selecting and encrypting to a key known to be in the
 public keybox).
 
 There are many more, however, which cannot be manipulated so readily:
 they must be performed in a specific sequence and the result of one
 operation has a direct bearing on the outcome of subsequent
 operations.  Not merely by generating an error either.
 
 When dealing with this type of persistent state on the web, full of
 both the RESTful and REST-like, it's most commonly referred to as a
 session.  In GPGME, however, it is called a context and every
 operation type has one.
 
 
 * Working with keys
   :PROPERTIES:
   :CUSTOM_ID: howto-keys
   :END:
 
 
 ** Key selection
    :PROPERTIES:
    :CUSTOM_ID: howto-keys-selection
    :END:
 
 Selecting keys to encrypt to or to sign with will be a common
 occurrence when working with GPGMe and the means available for doing
 so are quite simple.
 
 They do depend on utilising a Context; however once the data is
 recorded in another variable, that Context does not need to be the
 same one which subsequent operations are performed.
 
 The easiest way to select a specific key is by searching for that
 key's key ID or fingerprint, preferably the full fingerprint without
 any spaces in it.  A long key ID will probably be okay, but is not
 advised and short key IDs are already a problem with some being
 generated to match specific patterns.  It does not matter whether the
 pattern is upper or lower case.
 
 So this is the best method:
 
 #+BEGIN_SRC python -i
 import gpg
 
 k = gpg.Context().keylist(pattern="258E88DCBD3CD44D8E7AB43F6ECB6AF0DEADBEEF")
 keys = list(k)
 #+END_SRC
 
 This is passable and very likely to be common:
 
 #+BEGIN_SRC python -i
 import gpg
 
 k = gpg.Context().keylist(pattern="0x6ECB6AF0DEADBEEF")
 keys = list(k)
 #+END_SRC
 
 And this is a really bad idea:
 
 #+BEGIN_SRC python -i
 import gpg
 
 k = gpg.Context().keylist(pattern="0xDEADBEEF")
 keys = list(k)
 #+END_SRC
 
 Alternatively it may be that the intention is to create a list of keys
 which all match a particular search string.  For instance all the
 addresses at a particular domain, like this:
 
 #+BEGIN_SRC python -i
 import gpg
 
 ncsc = gpg.Context().keylist(pattern="ncsc.mil")
 nsa = list(ncsc)
 #+END_SRC
 
 
 *** Counting keys
     :PROPERTIES:
     :CUSTOM_ID: howto-keys-counting
     :END:
 
 Counting the number of keys in your public keybox (=pubring.kbx=), the
 format which has superseded the old keyring format (=pubring.gpg= and
 =secring.gpg=), or the number of secret keys is a very simple task.
 
 #+BEGIN_SRC python -i
 import gpg
 
 c = gpg.Context()
 seckeys = c.keylist(pattern=None, secret=True)
 pubkeys = c.keylist(pattern=None, secret=False)
 
 seclist = list(seckeys)
 secnum = len(seclist)
 
 publist = list(pubkeys)
 pubnum = len(publist)
 
 print("""
   Number of secret keys:  {0}
   Number of public keys:  {1}
 """.format(secnum, pubnum))
 #+END_SRC
 
 NOTE: The [[#cython][Cython]] introduction in the [[#advanced-use][Advanced and Experimental]]
 section uses this same key counting code with Cython to demonstrate
 some areas where Cython can improve performance even with the
 bindings.  Users with large public keyrings or keyboxes, for instance,
 should consider these options if they are comfortable with using
 Cython.
 
 
 ** Get key
    :PROPERTIES:
    :CUSTOM_ID: howto-get-key
    :END:
 
 An alternative method of getting a single key via its fingerprint is
 available directly within a Context with =Context().get_key=.  This is
 the preferred method of selecting a key in order to modify it, sign or
 certify it and for obtaining relevant data about a single key as a
 part of other functions; when verifying a signature made by that key,
 for instance.
 
 By default this method will select public keys, but it can select
 secret keys as well.
 
 This first example demonstrates selecting the current key of Werner
 Koch, which is due to expire at the end of 2018:
 
 #+BEGIN_SRC python -i
 import gpg
 
 fingerprint = "80615870F5BAD690333686D0F2AD85AC1E42B367"
 key = gpg.Context().get_key(fingerprint)
 #+END_SRC
 
 Whereas this example demonstrates selecting the author's current key
 with the =secret= key word argument set to =True=:
 
 #+BEGIN_SRC python -i
 import gpg
 
 fingerprint = "DB4724E6FA4286C92B4E55C4321E4E2373590E5D"
 key = gpg.Context().get_key(fingerprint, secret=True)
 #+END_SRC
 
 It is, of course, quite possible to select expired, disabled and
 revoked keys with this function, but only to effectively display
 information about those keys.
 
 It is also possible to use both unicode or string literals and byte
 literals with the fingerprint when getting a key in this way.
 
 
 ** Importing keys
    :PROPERTIES:
    :CUSTOM_ID: howto-import-key
    :END:
 
 Importing keys is possible with the =key_import()= method and takes
 one argument which is a bytes literal object containing either the
 binary or ASCII armoured key data for one or more keys.
 
 The following example retrieves one or more keys from the SKS
 keyservers via the web using the requests module.  Since requests
 returns the content as a bytes literal object, we can then use that
 directly to import the resulting data into our keybox.
 
 #+BEGIN_SRC python -i
 import gpg
 import os.path
 import requests
 
 c = gpg.Context()
 url = "https://sks-keyservers.net/pks/lookup"
 pattern = input("Enter the pattern to search for key or user IDs: ")
 payload = {"op": "get", "search": pattern}
 
 r = requests.get(url, verify=True, params=payload)
 result = c.key_import(r.content)
 
 if result is not None and hasattr(result, "considered") is False:
     print(result)
 elif result is not None and hasattr(result, "considered") is True:
     num_keys = len(result.imports)
     new_revs = result.new_revocations
     new_sigs = result.new_signatures
     new_subs = result.new_sub_keys
     new_uids = result.new_user_ids
     new_scrt = result.secret_imported
     nochange = result.unchanged
     print("""
   The total number of keys considered for import was:  {0}
 
      Number of keys revoked:  {1}
    Number of new signatures:  {2}
       Number of new subkeys:  {3}
      Number of new user IDs:  {4}
   Number of new secret keys:  {5}
    Number of unchanged keys:  {6}
 
   The key IDs for all considered keys were:
 """.format(num_keys, new_revs, new_sigs, new_subs, new_uids, new_scrt,
            nochange))
     for i in range(num_keys):
         print("{0}\n".format(result.imports[i].fpr))
 else:
     pass
 #+END_SRC
 
 NOTE: When searching for a key ID of any length or a fingerprint
 (without spaces), the SKS servers require the the leading =0x=
 indicative of hexadecimal be included.  Also note that the old short
 key IDs (e.g. =0xDEADBEEF=) should no longer be used due to the
 relative ease by which such key IDs can be reproduced, as demonstrated
 by the Evil32 Project in 2014 (which was subsequently exploited in
 2016).
 
 
 *** Working with ProtonMail
     :PROPERTIES:
     :CUSTOM_ID: import-protonmail
     :END:
 
 Here is a variation on the example above which checks the constrained
 ProtonMail keyserver for ProtonMail public keys.
 
 #+BEGIN_SRC python -i
 import gpg
 import requests
 import sys
 
 print("""
 This script searches the ProtonMail key server for the specified key and
 imports it.
 """)
 
 c = gpg.Context(armor=True)
 url = "https://api.protonmail.ch/pks/lookup"
 ksearch = []
 
 if len(sys.argv) >= 2:
     keyterm = sys.argv[1]
 else:
     keyterm = input("Enter the key ID, UID or search string: ")
 
 if keyterm.count("@") == 2 and keyterm.startswith("@") is True:
     ksearch.append(keyterm[1:])
     ksearch.append(keyterm[1:])
     ksearch.append(keyterm[1:])
 elif keyterm.count("@") == 1 and keyterm.startswith("@") is True:
     ksearch.append("{0}@protonmail.com".format(keyterm[1:]))
     ksearch.append("{0}@protonmail.ch".format(keyterm[1:]))
     ksearch.append("{0}@pm.me".format(keyterm[1:]))
 elif keyterm.count("@") == 0:
     ksearch.append("{0}@protonmail.com".format(keyterm))
     ksearch.append("{0}@protonmail.ch".format(keyterm))
     ksearch.append("{0}@pm.me".format(keyterm))
 elif keyterm.count("@") == 2 and keyterm.startswith("@") is False:
     uidlist = keyterm.split("@")
     for uid in uidlist:
         ksearch.append("{0}@protonmail.com".format(uid))
         ksearch.append("{0}@protonmail.ch".format(uid))
         ksearch.append("{0}@pm.me".format(uid))
 elif keyterm.count("@") > 2:
     uidlist = keyterm.split("@")
     for uid in uidlist:
         ksearch.append("{0}@protonmail.com".format(uid))
         ksearch.append("{0}@protonmail.ch".format(uid))
         ksearch.append("{0}@pm.me".format(uid))
 else:
     ksearch.append(keyterm)
 
 for k in ksearch:
     payload = {"op": "get", "search": k}
     try:
         r = requests.get(url, verify=True, params=payload)
         if r.ok is True:
             result = c.key_import(r.content)
         elif r.ok is False:
             result = r.content
     except Exception as e:
         result = None
 
     if result is not None and hasattr(result, "considered") is False:
         print("{0} for {1}".format(result.decode(), k))
     elif result is not None and hasattr(result, "considered") is True:
         num_keys = len(result.imports)
         new_revs = result.new_revocations
         new_sigs = result.new_signatures
         new_subs = result.new_sub_keys
         new_uids = result.new_user_ids
         new_scrt = result.secret_imported
         nochange = result.unchanged
         print("""
 The total number of keys considered for import was:  {0}
 
 With UIDs wholely or partially matching the following string:
 
         {1}
 
    Number of keys revoked:  {2}
  Number of new signatures:  {3}
     Number of new subkeys:  {4}
    Number of new user IDs:  {5}
 Number of new secret keys:  {6}
  Number of unchanged keys:  {7}
 
 The key IDs for all considered keys were:
 """.format(num_keys, k, new_revs, new_sigs, new_subs, new_uids, new_scrt,
            nochange))
         for i in range(num_keys):
             print(result.imports[i].fpr)
         print("")
     elif result is None:
         print(e)
 #+END_SRC
 
 Both the above example, [[../examples/howto/pmkey-import.py][pmkey-import.py]], and a version which prompts
 for an alternative GnuPG home directory, [[../examples/howto/pmkey-import-alt.py][pmkey-import-alt.py]], are
 available with the other examples and are executable scripts.
 
 Note that while the ProtonMail servers are based on the SKS servers,
 their server is related more to their API and is not feature complete
 by comparison to the servers in the SKS pool.  One notable difference
 being that the ProtonMail server does not permit non ProtonMail users
 to update their own keys, which could be a vector for attacking
 ProtonMail users who may not receive a key's revocation if it had been
 compromised.
 
 
 *** Importing with HKP for Python
     :PROPERTIES:
     :CUSTOM_ID: import-hkp4py
     :END:
 
 Performing the same tasks with the [[https://github.com/Selfnet/hkp4py][hkp4py module]] (available via PyPI)
 is not too much different, but does provide a number of options of
 benefit to end users.  Not least of which being the ability to perform
 some checks on a key before importing it or not.  For instance it may
 be the policy of a site or project to only import keys which have not
 been revoked.  The hkp4py module permits such checks prior to the
 importing of the keys found.
 
 #+BEGIN_SRC python -i
 import gpg
 import hkp4py
 import sys
 
 c = gpg.Context()
 server = hkp4py.KeyServer("hkps://hkps.pool.sks-keyservers.net")
 results = []
 
 if len(sys.argv) > 2:
     pattern = " ".join(sys.argv[1:])
 elif len(sys.argv) == 2:
     pattern = sys.argv[1]
 else:
     pattern = input("Enter the pattern to search for keys or user IDs: ")
 
 try:
     keys = server.search(pattern)
     print("Found {0} key(s).".format(len(keys)))
 except Exception as e:
     keys = []
     for logrus in pattern.split():
         if logrus.startswith("0x") is True:
             key = server.search(logrus)
         else:
             key = server.search("0x{0}".format(logrus))
         keys.append(key[0])
     print("Found {0} key(s).".format(len(keys)))
 
 for key in keys:
     import_result = c.key_import(key.key_blob)
     results.append(import_result)
 
 for result in results:
     if result is not None and hasattr(result, "considered") is False:
         print(result)
     elif result is not None and hasattr(result, "considered") is True:
         num_keys = len(result.imports)
         new_revs = result.new_revocations
         new_sigs = result.new_signatures
         new_subs = result.new_sub_keys
         new_uids = result.new_user_ids
         new_scrt = result.secret_imported
         nochange = result.unchanged
         print("""
 The total number of keys considered for import was:  {0}
 
    Number of keys revoked:  {1}
  Number of new signatures:  {2}
     Number of new subkeys:  {3}
    Number of new user IDs:  {4}
 Number of new secret keys:  {5}
  Number of unchanged keys:  {6}
 
 The key IDs for all considered keys were:
 """.format(num_keys, new_revs, new_sigs, new_subs, new_uids, new_scrt,
            nochange))
         for i in range(num_keys):
             print(result.imports[i].fpr)
         print("")
     else:
         pass
 #+END_SRC
 
 Since the hkp4py module handles multiple keys just as effectively as
 one (=keys= is a list of responses per matching key), the example
 above is able to do a little bit more with the returned data before
 anything is actually imported.
 
 
 *** Importing from ProtonMail with HKP for Python
     :PROPERTIES:
     :CUSTOM_ID: import-protonmail-hkp4py
     :END:
 
 Though this can provide certain benefits even when working with
 ProtonMail, the scope is somewhat constrained there due to the
 limitations of the ProtonMail keyserver.
 
 For instance, searching the SKS keyserver pool for the term "gnupg"
 produces hundreds of results from any time the word appears in any
 part of a user ID.  Performing the same search on the ProtonMail
 keyserver returns zero results, even though there are at least two
 test accounts which include it as part of the username.
 
 The cause of this discrepancy is the deliberate configuration of that
 server by ProtonMail to require an exact match of the full email
 address of the ProtonMail user whose key is being requested.
 Presumably this is intended to reduce breaches of privacy of their
 users as an email address must already be known before a key for that
 address can be obtained.
 
 
 **** Import from ProtonMail via HKP for Python Example no. 1
      :PROPERTIES:
      :CUSTOM_ID: import-hkp4py-pm1
      :END:
 
-The following script is avalable with the rest of the examples under
+The following script is available with the rest of the examples under
 the somewhat less than original name, =pmkey-import-hkp.py=.
 
 #+BEGIN_SRC python -i
 import gpg
 import hkp4py
 import os.path
 import sys
 
 print("""
 This script searches the ProtonMail key server for the specified key and
 imports it.
 
 Usage:  pmkey-import-hkp.py [search strings]
 """)
 
 c = gpg.Context(armor=True)
 server = hkp4py.KeyServer("hkps://api.protonmail.ch")
 keyterms = []
 ksearch = []
 allkeys = []
 results = []
 paradox = []
 homeless = None
 
 if len(sys.argv) > 2:
     keyterms = sys.argv[1:]
 elif len(sys.argv) == 2:
     keyterm = sys.argv[1]
     keyterms.append(keyterm)
 else:
     key_term = input("Enter the key ID, UID or search string: ")
     keyterms = key_term.split()
 
 for keyterm in keyterms:
     if keyterm.count("@") == 2 and keyterm.startswith("@") is True:
         ksearch.append(keyterm[1:])
         ksearch.append(keyterm[1:])
         ksearch.append(keyterm[1:])
     elif keyterm.count("@") == 1 and keyterm.startswith("@") is True:
         ksearch.append("{0}@protonmail.com".format(keyterm[1:]))
         ksearch.append("{0}@protonmail.ch".format(keyterm[1:]))
         ksearch.append("{0}@pm.me".format(keyterm[1:]))
     elif keyterm.count("@") == 0:
         ksearch.append("{0}@protonmail.com".format(keyterm))
         ksearch.append("{0}@protonmail.ch".format(keyterm))
         ksearch.append("{0}@pm.me".format(keyterm))
     elif keyterm.count("@") == 2 and keyterm.startswith("@") is False:
         uidlist = keyterm.split("@")
         for uid in uidlist:
             ksearch.append("{0}@protonmail.com".format(uid))
             ksearch.append("{0}@protonmail.ch".format(uid))
             ksearch.append("{0}@pm.me".format(uid))
     elif keyterm.count("@") > 2:
         uidlist = keyterm.split("@")
         for uid in uidlist:
             ksearch.append("{0}@protonmail.com".format(uid))
             ksearch.append("{0}@protonmail.ch".format(uid))
             ksearch.append("{0}@pm.me".format(uid))
     else:
         ksearch.append(keyterm)
 
 for k in ksearch:
     print("Checking for key for: {0}".format(k))
     try:
         keys = server.search(k)
         if isinstance(keys, list) is True:
             for key in keys:
                 allkeys.append(key)
                 try:
                     import_result = c.key_import(key.key_blob)
                 except Exception as e:
                     import_result = c.key_import(key.key)
         else:
             paradox.append(keys)
             import_result = None
     except Exception as e:
         import_result = None
     results.append(import_result)
 
 for result in results:
     if result is not None and hasattr(result, "considered") is False:
         print("{0} for {1}".format(result.decode(), k))
     elif result is not None and hasattr(result, "considered") is True:
         num_keys = len(result.imports)
         new_revs = result.new_revocations
         new_sigs = result.new_signatures
         new_subs = result.new_sub_keys
         new_uids = result.new_user_ids
         new_scrt = result.secret_imported
         nochange = result.unchanged
         print("""
 The total number of keys considered for import was:  {0}
 
 With UIDs wholely or partially matching the following string:
 
         {1}
 
    Number of keys revoked:  {2}
  Number of new signatures:  {3}
     Number of new subkeys:  {4}
    Number of new user IDs:  {5}
 Number of new secret keys:  {6}
  Number of unchanged keys:  {7}
 
 The key IDs for all considered keys were:
 """.format(num_keys, k, new_revs, new_sigs, new_subs, new_uids, new_scrt,
            nochange))
         for i in range(num_keys):
             print(result.imports[i].fpr)
         print("")
     elif result is None:
         pass
 #+END_SRC
 
 
 **** Import from ProtonMail via HKP for Python Example no. 2
      :PROPERTIES:
      :CUSTOM_ID: import-hkp4py-pm2
      :END:
 
 Like its counterpart above, this script can also be found with the
 rest of the examples, by the name pmkey-import-hkp-alt.py.
 
 With this script a modicum of effort has been made to treat anything
 passed as a =homedir= which either does not exist or which is not a
 directory, as also being a pssible user ID to check for.  It's not
 guaranteed to pick up on all such cases, but it should cover most of
 them.
 
 #+BEGIN_SRC python -i
 import gpg
 import hkp4py
 import os.path
 import sys
 
 print("""
 This script searches the ProtonMail key server for the specified key and
 imports it.  Optionally enables specifying a different GnuPG home directory.
 
 Usage:  pmkey-import-hkp.py [homedir] [search string]
    or:  pmkey-import-hkp.py [search string]
 """)
 
 c = gpg.Context(armor=True)
 server = hkp4py.KeyServer("hkps://api.protonmail.ch")
 keyterms = []
 ksearch = []
 allkeys = []
 results = []
 paradox = []
 homeless = None
 
 if len(sys.argv) > 3:
     homedir = sys.argv[1]
     keyterms = sys.argv[2:]
 elif len(sys.argv) == 3:
     homedir = sys.argv[1]
     keyterm = sys.argv[2]
     keyterms.append(keyterm)
 elif len(sys.argv) == 2:
     homedir = ""
     keyterm = sys.argv[1]
     keyterms.append(keyterm)
 else:
     keyterm = input("Enter the key ID, UID or search string: ")
     homedir = input("Enter the GPG configuration directory path (optional): ")
     keyterms.append(keyterm)
 
 if len(homedir) == 0:
     homedir = None
     homeless = False
 
 if homedir is not None:
     if homedir.startswith("~"):
         if os.path.exists(os.path.expanduser(homedir)) is True:
             if os.path.isdir(os.path.expanduser(homedir)) is True:
                 c.home_dir = os.path.realpath(os.path.expanduser(homedir))
             else:
                 homeless = True
         else:
             homeless = True
     elif os.path.exists(os.path.realpath(homedir)) is True:
         if os.path.isdir(os.path.realpath(homedir)) is True:
             c.home_dir = os.path.realpath(homedir)
         else:
             homeless = True
     else:
         homeless = True
 
 # First check to see if the homedir really is a homedir and if not, treat it as
 # a search string.
 if homeless is True:
     keyterms.append(homedir)
     c.home_dir = None
 else:
     pass
 
 for keyterm in keyterms:
     if keyterm.count("@") == 2 and keyterm.startswith("@") is True:
         ksearch.append(keyterm[1:])
         ksearch.append(keyterm[1:])
         ksearch.append(keyterm[1:])
     elif keyterm.count("@") == 1 and keyterm.startswith("@") is True:
         ksearch.append("{0}@protonmail.com".format(keyterm[1:]))
         ksearch.append("{0}@protonmail.ch".format(keyterm[1:]))
         ksearch.append("{0}@pm.me".format(keyterm[1:]))
     elif keyterm.count("@") == 0:
         ksearch.append("{0}@protonmail.com".format(keyterm))
         ksearch.append("{0}@protonmail.ch".format(keyterm))
         ksearch.append("{0}@pm.me".format(keyterm))
     elif keyterm.count("@") == 2 and keyterm.startswith("@") is False:
         uidlist = keyterm.split("@")
         for uid in uidlist:
             ksearch.append("{0}@protonmail.com".format(uid))
             ksearch.append("{0}@protonmail.ch".format(uid))
             ksearch.append("{0}@pm.me".format(uid))
     elif keyterm.count("@") > 2:
         uidlist = keyterm.split("@")
         for uid in uidlist:
             ksearch.append("{0}@protonmail.com".format(uid))
             ksearch.append("{0}@protonmail.ch".format(uid))
             ksearch.append("{0}@pm.me".format(uid))
     else:
         ksearch.append(keyterm)
 
 for k in ksearch:
     print("Checking for key for: {0}".format(k))
     try:
         keys = server.search(k)
         if isinstance(keys, list) is True:
             for key in keys:
                 allkeys.append(key)
                 try:
                     import_result = c.key_import(key.key_blob)
                 except Exception as e:
                     import_result = c.key_import(key.key)
         else:
             paradox.append(keys)
             import_result = None
     except Exception as e:
         import_result = None
     results.append(import_result)
 
 for result in results:
     if result is not None and hasattr(result, "considered") is False:
         print("{0} for {1}".format(result.decode(), k))
     elif result is not None and hasattr(result, "considered") is True:
         num_keys = len(result.imports)
         new_revs = result.new_revocations
         new_sigs = result.new_signatures
         new_subs = result.new_sub_keys
         new_uids = result.new_user_ids
         new_scrt = result.secret_imported
         nochange = result.unchanged
         print("""
 The total number of keys considered for import was:  {0}
 
 With UIDs wholely or partially matching the following string:
 
         {1}
 
    Number of keys revoked:  {2}
  Number of new signatures:  {3}
     Number of new subkeys:  {4}
    Number of new user IDs:  {5}
 Number of new secret keys:  {6}
  Number of unchanged keys:  {7}
 
 The key IDs for all considered keys were:
 """.format(num_keys, k, new_revs, new_sigs, new_subs, new_uids, new_scrt,
            nochange))
         for i in range(num_keys):
             print(result.imports[i].fpr)
         print("")
     elif result is None:
         pass
 #+END_SRC
 
 
 ** Exporting keys
    :PROPERTIES:
    :CUSTOM_ID: howto-export-key
    :END:
 
 Exporting keys remains a reasonably simple task, but has been
 separated into three different functions for the OpenPGP cryptographic
 engine.  Two of those functions are for exporting public keys and the
 third is for exporting secret keys.
 
 
 *** Exporting public keys
     :PROPERTIES:
     :CUSTOM_ID: howto-export-public-key
     :END:
 
 There are two methods of exporting public keys, both of which are very
 similar to the other.  The default method, =key_export()=, will export
 a public key or keys matching a specified pattern as normal.  The
 alternative, the =key_export_minimal()= method, will do the same thing
 except producing a minimised output with extra signatures and third
 party signatures or certifications removed.
 
 #+BEGIN_SRC python -i
 import gpg
 import os.path
 import sys
 
 print("""
 This script exports one or more public keys.
 """)
 
 c = gpg.Context(armor=True)
 
 if len(sys.argv) >= 4:
     keyfile = sys.argv[1]
     logrus = sys.argv[2]
     homedir = sys.argv[3]
 elif len(sys.argv) == 3:
     keyfile = sys.argv[1]
     logrus = sys.argv[2]
     homedir = input("Enter the GPG configuration directory path (optional): ")
 elif len(sys.argv) == 2:
     keyfile = sys.argv[1]
     logrus = input("Enter the UID matching the key(s) to export: ")
     homedir = input("Enter the GPG configuration directory path (optional): ")
 else:
     keyfile = input("Enter the path and filename to save the secret key to: ")
     logrus = input("Enter the UID matching the key(s) to export: ")
     homedir = input("Enter the GPG configuration directory path (optional): ")
 
 if homedir.startswith("~"):
     if os.path.exists(os.path.expanduser(homedir)) is True:
         c.home_dir = os.path.expanduser(homedir)
     else:
         pass
 elif os.path.exists(homedir) is True:
     c.home_dir = homedir
 else:
     pass
 
 try:
     result = c.key_export(pattern=logrus)
 except:
     result = c.key_export(pattern=None)
 
 if result is not None:
     with open(keyfile, "wb") as f:
         f.write(result)
 else:
     pass
 #+END_SRC
 
 It should be noted that the result will only return =None= when a
 search pattern has been entered, but has not matched any keys.  When
 the search pattern itself is set to =None= this triggers the exporting
 of the entire public keybox.
 
 #+BEGIN_SRC python -i
 import gpg
 import os.path
 import sys
 
 print("""
 This script exports one or more public keys in minimised form.
 """)
 
 c = gpg.Context(armor=True)
 
 if len(sys.argv) >= 4:
     keyfile = sys.argv[1]
     logrus = sys.argv[2]
     homedir = sys.argv[3]
 elif len(sys.argv) == 3:
     keyfile = sys.argv[1]
     logrus = sys.argv[2]
     homedir = input("Enter the GPG configuration directory path (optional): ")
 elif len(sys.argv) == 2:
     keyfile = sys.argv[1]
     logrus = input("Enter the UID matching the key(s) to export: ")
     homedir = input("Enter the GPG configuration directory path (optional): ")
 else:
     keyfile = input("Enter the path and filename to save the secret key to: ")
     logrus = input("Enter the UID matching the key(s) to export: ")
     homedir = input("Enter the GPG configuration directory path (optional): ")
 
 if homedir.startswith("~"):
     if os.path.exists(os.path.expanduser(homedir)) is True:
         c.home_dir = os.path.expanduser(homedir)
     else:
         pass
 elif os.path.exists(homedir) is True:
     c.home_dir = homedir
 else:
     pass
 
 try:
     result = c.key_export_minimal(pattern=logrus)
 except:
     result = c.key_export_minimal(pattern=None)
 
 if result is not None:
     with open(keyfile, "wb") as f:
         f.write(result)
 else:
     pass
 #+END_SRC
 
 
 *** Exporting secret keys
     :PROPERTIES:
     :CUSTOM_ID: howto-export-secret-key
     :END:
 
 Exporting secret keys is, functionally, very similar to exporting
 public keys; save for the invocation of =pinentry= via =gpg-agent= in
 order to securely enter the key's passphrase and authorise the export.
 
 The following example exports the secret key to a file which is then
 set with the same permissions as the output files created by the
 command line secret key export options.
 
 #+BEGIN_SRC python -i
 import gpg
 import os
 import os.path
 import sys
 
 print("""
 This script exports one or more secret keys.
 
 The gpg-agent and pinentry are invoked to authorise the export.
 """)
 
 c = gpg.Context(armor=True)
 
 if len(sys.argv) >= 4:
     keyfile = sys.argv[1]
     logrus = sys.argv[2]
     homedir = sys.argv[3]
 elif len(sys.argv) == 3:
     keyfile = sys.argv[1]
     logrus = sys.argv[2]
     homedir = input("Enter the GPG configuration directory path (optional): ")
 elif len(sys.argv) == 2:
     keyfile = sys.argv[1]
     logrus = input("Enter the UID matching the secret key(s) to export: ")
     homedir = input("Enter the GPG configuration directory path (optional): ")
 else:
     keyfile = input("Enter the path and filename to save the secret key to: ")
     logrus = input("Enter the UID matching the secret key(s) to export: ")
     homedir = input("Enter the GPG configuration directory path (optional): ")
 
 if len(homedir) == 0:
     homedir = None
 elif homedir.startswith("~"):
     userdir = os.path.expanduser(homedir)
     if os.path.exists(userdir) is True:
         homedir = os.path.realpath(userdir)
     else:
         homedir = None
 else:
     homedir = os.path.realpath(homedir)
 
 if os.path.exists(homedir) is False:
     homedir = None
 else:
     if os.path.isdir(homedir) is False:
         homedir = None
     else:
         pass
 
 if homedir is not None:
     c.home_dir = homedir
 else:
     pass
 
 try:
     result = c.key_export_secret(pattern=logrus)
 except:
     result = c.key_export_secret(pattern=None)
 
 if result is not None:
     with open(keyfile, "wb") as f:
         f.write(result)
     os.chmod(keyfile, 0o600)
 else:
     pass
 #+END_SRC
 
 Alternatively the approach of the following script can be used.  This
 longer example saves the exported secret key(s) in files in the GnuPG
 home directory, in addition to setting the file permissions as only
 readable and writable by the user.  It also exports the secret key(s)
 twice in order to output both GPG binary (=.gpg=) and ASCII armoured
 (=.asc=) files.
 
 #+BEGIN_SRC python -i
 import gpg
 import os
 import os.path
 import subprocess
 import sys
 
 print("""
 This script exports one or more secret keys as both ASCII armored and binary
 file formats, saved in files within the user's GPG home directory.
 
 The gpg-agent and pinentry are invoked to authorise the export.
 """)
 
 if sys.platform == "win32":
     gpgconfcmd = "gpgconf.exe --list-dirs homedir"
 else:
     gpgconfcmd = "gpgconf --list-dirs homedir"
 
 a = gpg.Context(armor=True)
 b = gpg.Context()
 c = gpg.Context()
 
 if len(sys.argv) >= 4:
     keyfile = sys.argv[1]
     logrus = sys.argv[2]
     homedir = sys.argv[3]
 elif len(sys.argv) == 3:
     keyfile = sys.argv[1]
     logrus = sys.argv[2]
     homedir = input("Enter the GPG configuration directory path (optional): ")
 elif len(sys.argv) == 2:
     keyfile = sys.argv[1]
     logrus = input("Enter the UID matching the secret key(s) to export: ")
     homedir = input("Enter the GPG configuration directory path (optional): ")
 else:
     keyfile = input("Enter the filename to save the secret key to: ")
     logrus = input("Enter the UID matching the secret key(s) to export: ")
     homedir = input("Enter the GPG configuration directory path (optional): ")
 
 if len(homedir) == 0:
     homedir = None
 elif homedir.startswith("~"):
     userdir = os.path.expanduser(homedir)
     if os.path.exists(userdir) is True:
         homedir = os.path.realpath(userdir)
     else:
         homedir = None
 else:
     homedir = os.path.realpath(homedir)
 
 if os.path.exists(homedir) is False:
     homedir = None
 else:
     if os.path.isdir(homedir) is False:
         homedir = None
     else:
         pass
 
 if homedir is not None:
     c.home_dir = homedir
 else:
     pass
 
 if c.home_dir is not None:
     if c.home_dir.endswith("/"):
         gpgfile = "{0}{1}.gpg".format(c.home_dir, keyfile)
         ascfile = "{0}{1}.asc".format(c.home_dir, keyfile)
     else:
         gpgfile = "{0}/{1}.gpg".format(c.home_dir, keyfile)
         ascfile = "{0}/{1}.asc".format(c.home_dir, keyfile)
 else:
     if os.path.exists(os.environ["GNUPGHOME"]) is True:
         hd = os.environ["GNUPGHOME"]
     else:
         try:
             hd = subprocess.getoutput(gpgconfcmd)
         except:
             process = subprocess.Popen(gpgconfcmd.split(),
                                        stdout=subprocess.PIPE)
             procom = process.communicate()
             if sys.version_info[0] == 2:
                 hd = procom[0].strip()
             else:
                 hd = procom[0].decode().strip()
     gpgfile = "{0}/{1}.gpg".format(hd, keyfile)
     ascfile = "{0}/{1}.asc".format(hd, keyfile)
 
 try:
     a_result = a.key_export_secret(pattern=logrus)
     b_result = b.key_export_secret(pattern=logrus)
 except:
     a_result = a.key_export_secret(pattern=None)
     b_result = b.key_export_secret(pattern=None)
 
 if a_result is not None:
     with open(ascfile, "wb") as f:
         f.write(a_result)
     os.chmod(ascfile, 0o600)
 else:
     pass
 
 if b_result is not None:
     with open(gpgfile, "wb") as f:
         f.write(b_result)
     os.chmod(gpgfile, 0o600)
 else:
     pass
 #+END_SRC
 
 
 *** Sending public keys to the SKS Keyservers
     :PROPERTIES:
     :CUSTOM_ID: howto-send-public-key
     :END:
 
 As with the previous section on importing keys, the =hkp4py= module
 adds another option with exporting keys in order to send them to the
 public keyservers.
 
 The following example demonstrates how this may be done.
 
 #+BEGIN_SRC python -i
 import gpg
 import hkp4py
 import os.path
 import sys
 
 print("""
 This script sends one or more public keys to the SKS keyservers and is
 essentially a slight variation on the export-key.py script.
 """)
 
 c = gpg.Context(armor=True)
 server = hkp4py.KeyServer("hkps://hkps.pool.sks-keyservers.net")
 
 if len(sys.argv) > 2:
     logrus = " ".join(sys.argv[1:])
 elif len(sys.argv) == 2:
     logrus = sys.argv[1]
 else:
     logrus = input("Enter the UID matching the key(s) to send: ")
 
 if len(logrus) > 0:
     try:
         export_result = c.key_export(pattern=logrus)
     except Exception as e:
         print(e)
         export_result = None
 else:
     export_result = c.key_export(pattern=None)
 
 if export_result is not None:
     try:
         try:
             send_result = server.add(export_result)
         except:
             send_result = server.add(export_result.decode())
         if send_result is not None:
             print(send_result)
         else:
             pass
     except Exception as e:
         print(e)
 else:
     pass
 #+END_SRC
 
 An expanded version of this script with additional functions for
 specifying an alternative homedir location is in the examples
 directory as =send-key-to-keyserver.py=.
 
 The =hkp4py= module appears to handle both string and byte literal text
 data equally well, but the GPGME bindings deal primarily with byte
 literal data only and so this script sends in that format first, then
 tries the string literal form.
 
 
 * Basic Functions
   :PROPERTIES:
   :CUSTOM_ID: howto-the-basics
   :END:
 
 The most frequently called features of any cryptographic library will
 be the most fundamental tasks for encryption software.  In this
 section we will look at how to programmatically encrypt data, decrypt
 it, sign it and verify signatures.
 
 
 ** Encryption
    :PROPERTIES:
    :CUSTOM_ID: howto-basic-encryption
    :END:
 
 Encrypting is very straight forward.  In the first example below the
 message, =text=, is encrypted to a single recipient's key.  In the
 second example the message will be encrypted to multiple recipients.
 
 
 *** Encrypting to one key
     :PROPERTIES:
     :CUSTOM_ID: howto-basic-encryption-single
     :END:
 
 Once the the Context is set the main issues with encrypting data is
 essentially reduced to key selection and the keyword arguments
 specified in the =gpg.Context().encrypt()= method.
 
 Those keyword arguments are: =recipients=, a list of keys encrypted to
 (covered in greater detail in the following section); =sign=, whether
 or not to sign the plaintext data, see subsequent sections on signing
 and verifying signatures below (defaults to =True=); =sink=, to write
 results or partial results to a secure sink instead of returning it
 (defaults to =None=); =passphrase=, only used when utilising symmetric
 encryption (defaults to =None=); =always_trust=, used to override the
 trust model settings for recipient keys (defaults to =False=);
 =add_encrypt_to=, utilises any preconfigured =encrypt-to= or
 =default-key= settings in the user's =gpg.conf= file (defaults to
 =False=); =prepare=, prepare for encryption (defaults to =False=);
 =expect_sign=, prepare for signing (defaults to =False=); =compress=,
 compresses the plaintext prior to encryption (defaults to =True=).
 
 #+BEGIN_SRC python -i
 import gpg
 
 a_key = "0x12345678DEADBEEF"
 text = b"""Some text to test with.
 
 Since the text in this case must be bytes, it is most likely that
 the input form will be a separate file which is opened with "rb"
 as this is the simplest method of obtaining the correct data format.
 """
 
 c = gpg.Context(armor=True)
 rkey = list(c.keylist(pattern=a_key, secret=False))
 ciphertext, result, sign_result = c.encrypt(text, recipients=rkey, sign=False)
 
 with open("secret_plans.txt.asc", "wb") as afile:
     afile.write(ciphertext)
 #+END_SRC
 
 Though this is even more likely to be used like this; with the
 plaintext input read from a file, the recipient keys used for
 encryption regardless of key trust status and the encrypted output
 also encrypted to any preconfigured keys set in the =gpg.conf= file:
 
 #+BEGIN_SRC python -i
 import gpg
 
 a_key = "0x12345678DEADBEEF"
 
 with open("secret_plans.txt", "rb") as afile:
     text = afile.read()
 
 c = gpg.Context(armor=True)
 rkey = list(c.keylist(pattern=a_key, secret=False))
 ciphertext, result, sign_result = c.encrypt(text, recipients=rkey, sign=True,
                                             always_trust=True,
                                             add_encrypt_to=True)
 
 with open("secret_plans.txt.asc", "wb") as afile:
     afile.write(ciphertext)
 #+END_SRC
 
-If the =recipients= paramater is empty then the plaintext is encrypted
+If the =recipients= parameter is empty then the plaintext is encrypted
 symmetrically.  If no =passphrase= is supplied as a parameter or via a
 callback registered with the =Context()= then an out-of-band prompt
 for the passphrase via pinentry will be invoked.
 
 
 *** Encrypting to multiple keys
     :PROPERTIES:
     :CUSTOM_ID: howto-basic-encryption-multiple
     :END:
 
 Encrypting to multiple keys essentially just expands upon the key
 selection process and the recipients from the previous examples.
 
 The following example encrypts a message (=text=) to everyone with an
 email address on the =gnupg.org= domain,[fn:4] but does /not/ encrypt
 to a default key or other key which is configured to normally encrypt
 to.
 
 #+BEGIN_SRC python -i
 import gpg
 
 text = b"""Oh look, another test message.
 
 The same rules apply as with the previous example and more likely
 than not, the message will actually be drawn from reading the
 contents of a file or, maybe, from entering data at an input()
 prompt.
 
 Since the text in this case must be bytes, it is most likely that
 the input form will be a separate file which is opened with "rb"
 as this is the simplest method of obtaining the correct data
 format.
 """
 
 c = gpg.Context(armor=True)
 rpattern = list(c.keylist(pattern="@gnupg.org", secret=False))
 logrus = []
 
 for i in range(len(rpattern)):
     if rpattern[i].can_encrypt == 1:
         logrus.append(rpattern[i])
 
 ciphertext, result, sign_result = c.encrypt(text, recipients=logrus,
                                             sign=False, always_trust=True)
 
 with open("secret_plans.txt.asc", "wb") as afile:
     afile.write(ciphertext)
 #+END_SRC
 
 All it would take to change the above example to sign the message
 and also encrypt the message to any configured default keys would
 be to change the =c.encrypt= line to this:
 
 #+BEGIN_SRC python -i
 ciphertext, result, sign_result = c.encrypt(text, recipients=logrus,
                                             always_trust=True,
                                             add_encrypt_to=True)
 #+END_SRC
 
 The only keyword arguments requiring modification are those for which
 the default values are changing.  The default value of =sign= is
 =True=, the default of =always_trust= is =False=, the default of
 =add_encrypt_to= is =False=.
 
 If =always_trust= is not set to =True= and any of the recipient keys
 are not trusted (e.g. not signed or locally signed) then the
 encryption will raise an error.  It is possible to mitigate this
 somewhat with something more like this:
 
 #+BEGIN_SRC python -i
 import gpg
 
 with open("secret_plans.txt.asc", "rb") as afile:
     text = afile.read()
 
 c = gpg.Context(armor=True)
 rpattern = list(c.keylist(pattern="@gnupg.org", secret=False))
 logrus = []
 
 for i in range(len(rpattern)):
     if rpattern[i].can_encrypt == 1:
         logrus.append(rpattern[i])
 
     try:
         ciphertext, result, sign_result = c.encrypt(text, recipients=logrus,
                                                     add_encrypt_to=True)
     except gpg.errors.InvalidRecipients as e:
         for i in range(len(e.recipients)):
             for n in range(len(logrus)):
                 if logrus[n].fpr == e.recipients[i].fpr:
                     logrus.remove(logrus[n])
                 else:
                     pass
         try:
             ciphertext, result, sign_result = c.encrypt(text,
                                                         recipients=logrus,
                                                         add_encrypt_to=True)
             with open("secret_plans.txt.asc", "wb") as afile:
                 afile.write(ciphertext)
         except:
             pass
 #+END_SRC
 
 This will attempt to encrypt to all the keys searched for, then remove
 invalid recipients if it fails and try again.
 
 
 ** Decryption
    :PROPERTIES:
    :CUSTOM_ID: howto-basic-decryption
    :END:
 
 Decrypting something encrypted to a key in one's secret keyring is
 fairly straight forward.
 
 In this example code, however, preconfiguring either =gpg.Context()=
 or =gpg.core.Context()= as =c= is unnecessary because there is no need
 to modify the Context prior to conducting the decryption and since the
 Context is only used once, setting it to =c= simply adds lines for no
 gain.
 
 #+BEGIN_SRC python -i
 import gpg
 
 ciphertext = input("Enter path and filename of encrypted file: ")
 newfile = input("Enter path and filename of file to save decrypted data to: ")
 
 with open(ciphertext, "rb") as cfile:
     try:
         plaintext, result, verify_result = gpg.Context().decrypt(cfile)
     except gpg.errors.GPGMEError as e:
         plaintext = None
         print(e)
 
 if plaintext is not None:
     with open(newfile, "wb") as nfile:
 	    nfile.write(plaintext)
     else:
         pass
 #+END_SRC
 
 The data available in =plaintext= in this example is the decrypted
 content as a byte object, the recipient key IDs and algorithms in
 =result= and the results of verifying any signatures of the data in
 =verify_result=.
 
 
 ** Signing text and files
    :PROPERTIES:
    :CUSTOM_ID: howto-basic-signing
    :END:
 
 The following sections demonstrate how to specify keys to sign with.
 
 
 *** Signing key selection
     :PROPERTIES:
     :CUSTOM_ID: howto-basic-signing-signers
     :END:
 
 By default GPGME and the Python bindings will use the default key
 configured for the user invoking the GPGME API.  If there is no
 default key specified and there is more than one secret key available
 it may be necessary to specify the key or keys with which to sign
 messages and files.
 
 #+BEGIN_SRC python -i
 import gpg
 
 logrus = input("Enter the email address or string to match signing keys to: ")
 hancock = gpg.Context().keylist(pattern=logrus, secret=True)
 sig_src = list(hancock)
 #+END_SRC
 
 The signing examples in the following sections include the explicitly
 designated =signers= parameter in two of the five examples; once where
 the resulting signature would be ASCII armoured and once where it
 would not be armoured.
 
 While it would be possible to enter a key ID or fingerprint here to
 match a specific key, it is not possible to enter two fingerprints and
 match two keys since the patten expects a string, bytes or None and
 not a list.  A string with two fingerprints won't match any single
 key.
 
 
 *** Normal or default signing messages or files
     :PROPERTIES:
     :CUSTOM_ID: howto-basic-signing-normal
     :END:
 
 The normal or default signing process is essentially the same as is
 most often invoked when also encrypting a message or file.  So when
 the encryption component is not utilised, the result is to produce an
 encoded and signed output which may or may not be ASCII armoured and
 which may or may not also be compressed.
 
 By default compression will be used unless GnuPG detects that the
 plaintext is already compressed.  ASCII armouring will be determined
 according to the value of =gpg.Context().armor=.
 
 The compression algorithm is selected in much the same way as the
 symmetric encryption algorithm or the hash digest algorithm is when
 multiple keys are involved; from the preferences saved into the key
 itself or by comparison with the preferences with all other keys
 involved.
 
 #+BEGIN_SRC python -i
 import gpg
 
 text0 = """Declaration of ... something.
 
 """
 text = text0.encode()
 
 c = gpg.Context(armor=True, signers=sig_src)
 signed_data, result = c.sign(text, mode=gpg.constants.sig.mode.NORMAL)
 
 with open("/path/to/statement.txt.asc", "w") as afile:
     afile.write(signed_data.decode())
 #+END_SRC
 
 Though everything in this example is accurate, it is more likely that
 reading the input data from another file and writing the result to a
 new file will be performed more like the way it is done in the next
 example.  Even if the output format is ASCII armoured.
 
 #+BEGIN_SRC python -i
 import gpg
 
 with open("/path/to/statement.txt", "rb") as tfile:
     text = tfile.read()
 
 c = gpg.Context()
 signed_data, result = c.sign(text, mode=gpg.constants.sig.mode.NORMAL)
 
 with open("/path/to/statement.txt.sig", "wb") as afile:
     afile.write(signed_data)
 #+END_SRC
 
 
 *** Detached signing messages and files
     :PROPERTIES:
     :CUSTOM_ID: howto-basic-signing-detached
     :END:
 
 Detached signatures will often be needed in programmatic uses of
 GPGME, either for signing files (e.g. tarballs of code releases) or as
 a component of message signing (e.g. PGP/MIME encoded email).
 
 #+BEGIN_SRC python -i
 import gpg
 
 text0 = """Declaration of ... something.
 
 """
 text = text0.encode()
 
 c = gpg.Context(armor=True)
 signed_data, result = c.sign(text, mode=gpg.constants.sig.mode.DETACH)
 
 with open("/path/to/statement.txt.asc", "w") as afile:
     afile.write(signed_data.decode())
 #+END_SRC
 
 As with normal signatures, detached signatures are best handled as
 byte literals, even when the output is ASCII armoured.
 
 #+BEGIN_SRC python -i
 import gpg
 
 with open("/path/to/statement.txt", "rb") as tfile:
     text = tfile.read()
 
 c = gpg.Context(signers=sig_src)
 signed_data, result = c.sign(text, mode=gpg.constants.sig.mode.DETACH)
 
 with open("/path/to/statement.txt.sig", "wb") as afile:
     afile.write(signed_data)
 #+END_SRC
 
 
 *** Clearsigning messages or text
     :PROPERTIES:
     :CUSTOM_ID: howto-basic-signing-clear
     :END:
 
 Though PGP/in-line messages are no longer encouraged in favour of
 PGP/MIME, there is still sometimes value in utilising in-line
 signatures.  This is where clear-signed messages or text is of value.
 
 #+BEGIN_SRC python -i
 import gpg
 
 text0 = """Declaration of ... something.
 
 """
 text = text0.encode()
 
 c = gpg.Context()
 signed_data, result = c.sign(text, mode=gpg.constants.sig.mode.CLEAR)
 
 with open("/path/to/statement.txt.asc", "w") as afile:
     afile.write(signed_data.decode())
 #+END_SRC
 
 In spite of the appearance of a clear-signed message, the data handled
 by GPGME in signing it must still be byte literals.
 
 #+BEGIN_SRC python -i
 import gpg
 
 with open("/path/to/statement.txt", "rb") as tfile:
     text = tfile.read()
 
 c = gpg.Context()
 signed_data, result = c.sign(text, mode=gpg.constants.sig.mode.CLEAR)
 
 with open("/path/to/statement.txt.asc", "wb") as afile:
     afile.write(signed_data)
 #+END_SRC
 
 
 ** Signature verification
    :PROPERTIES:
    :CUSTOM_ID: howto-basic-verification
    :END:
 
 Essentially there are two principal methods of verification of a
 signature.  The first of these is for use with the normal or default
 signing method and for clear-signed messages.  The second is for use
 with files and data with detached signatures.
 
 The following example is intended for use with the default signing
 method where the file was not ASCII armoured:
 
 #+BEGIN_SRC python -i
 import gpg
 import time
 
 filename = "statement.txt"
 gpg_file = "statement.txt.gpg"
 
 c = gpg.Context()
 
 try:
     data, result = c.verify(open(gpg_file))
     verified = True
 except gpg.errors.BadSignatures as e:
     verified = False
     print(e)
 
 if verified is True:
     for i in range(len(result.signatures)):
         sign = result.signatures[i]
         print("""Good signature from:
 {0}
 with key {1}
 made at {2}
 """.format(c.get_key(sign.fpr).uids[0].uid, sign.fpr,
            time.ctime(sign.timestamp)))
 else:
     pass
 #+END_SRC
 
 Whereas this next example, which is almost identical would work with
 normal ASCII armoured files and with clear-signed files:
 
 #+BEGIN_SRC python -i
 import gpg
 import time
 
 filename = "statement.txt"
 asc_file = "statement.txt.asc"
 
 c = gpg.Context()
 
 try:
     data, result = c.verify(open(asc_file))
     verified = True
 except gpg.errors.BadSignatures as e:
     verified = False
     print(e)
 
 if verified is True:
     for i in range(len(result.signatures)):
         sign = result.signatures[i]
         print("""Good signature from:
 {0}
 with key {1}
 made at {2}
 """.format(c.get_key(sign.fpr).uids[0].uid, sign.fpr,
            time.ctime(sign.timestamp)))
 else:
     pass
 #+END_SRC
 
 In both of the previous examples it is also possible to compare the
 original data that was signed against the signed data in =data= to see
 if it matches with something like this:
 
 #+BEGIN_SRC python -i
 with open(filename, "rb") as afile:
     text = afile.read()
 
 if text == data:
     print("Good signature.")
 else:
     pass
 #+END_SRC
 
 The following two examples, however, deal with detached signatures.
 With his method of verification the data that was signed does not get
 returned since it is already being explicitly referenced in the first
 argument of =c.verify=.  So =data= is =None= and only the information
 in =result= is available.
 
 #+BEGIN_SRC python -i
 import gpg
 import time
 
 filename = "statement.txt"
 sig_file = "statement.txt.sig"
 
 c = gpg.Context()
 
 try:
     data, result = c.verify(open(filename), open(sig_file))
     verified = True
 except gpg.errors.BadSignatures as e:
     verified = False
     print(e)
 
 if verified is True:
     for i in range(len(result.signatures)):
         sign = result.signatures[i]
         print("""Good signature from:
 {0}
 with key {1}
 made at {2}
 """.format(c.get_key(sign.fpr).uids[0].uid, sign.fpr,
            time.ctime(sign.timestamp)))
 else:
     pass
 #+END_SRC
 
 #+BEGIN_SRC python -i
 import gpg
 import time
 
 filename = "statement.txt"
 asc_file = "statement.txt.asc"
 
 c = gpg.Context()
 
 try:
     data, result = c.verify(open(filename), open(asc_file))
     verified = True
 except gpg.errors.BadSignatures as e:
     verified = False
     print(e)
 
 if verified is True:
     for i in range(len(result.signatures)):
         sign = result.signatures[i]
         print("""Good signature from:
 {0}
 with key {1}
 made at {2}
 """.format(c.get_key(sign.fpr).uids[0].uid, sign.fpr,
            time.ctime(sign.timestamp)))
 else:
     pass
 #+END_SRC
 
 
 * Creating keys and subkeys
   :PROPERTIES:
   :CUSTOM_ID: key-generation
   :END:
 
 The one thing, aside from GnuPG itself, that GPGME depends on, of
 course, is the keys themselves.  So it is necessary to be able to
 generate them and modify them by adding subkeys, revoking or disabling
 them, sometimes deleting them and doing the same for user IDs.
 
 In the following examples a key will be created for the world's
 greatest secret agent, Danger Mouse.  Since Danger Mouse is a secret
 agent he needs to be able to protect information to =SECRET= level
 clearance, so his keys will be 3072-bit keys.
 
 The pre-configured =gpg.conf= file which sets cipher, digest and other
 preferences contains the following configuration parameters:
 
 #+BEGIN_SRC conf
   expert
   allow-freeform-uid
   allow-secret-key-import
   trust-model tofu+pgp
   tofu-default-policy unknown
   enable-large-rsa
   enable-dsa2
   cert-digest-algo SHA512
   default-preference-list TWOFISH CAMELLIA256 AES256 CAMELLIA192 AES192 CAMELLIA128 AES BLOWFISH IDEA CAST5 3DES SHA512 SHA384 SHA256 SHA224 RIPEMD160 SHA1 ZLIB BZIP2 ZIP Uncompressed
   personal-cipher-preferences TWOFISH CAMELLIA256 AES256 CAMELLIA192 AES192 CAMELLIA128 AES BLOWFISH IDEA CAST5 3DES
   personal-digest-preferences SHA512 SHA384 SHA256 SHA224 RIPEMD160 SHA1
   personal-compress-preferences ZLIB BZIP2 ZIP Uncompressed
 #+END_SRC
 
 
 ** Primary key
    :PROPERTIES:
    :CUSTOM_ID: keygen-primary
    :END:
 
 Generating a primary key uses the =create_key= method in a Context.
 It contains multiple arguments and keyword arguments, including:
 =userid=, =algorithm=, =expires_in=, =expires=, =sign=, =encrypt=,
 =certify=, =authenticate=, =passphrase= and =force=.  The defaults for
 all of those except =userid=, =algorithm=, =expires_in=, =expires= and
 =passphrase= is =False=.  The defaults for =algorithm= and
 =passphrase= is =None=.  The default for =expires_in= is =0=.  The
 default for =expires= is =True=.  There is no default for =userid=.
 
 If =passphrase= is left as =None= then the key will not be generated
 with a passphrase, if =passphrase= is set to a string then that will
 be the passphrase and if =passphrase= is set to =True= then gpg-agent
 will launch pinentry to prompt for a passphrase.  For the sake of
 convenience, these examples will keep =passphrase= set to =None=.
 
 #+BEGIN_SRC python -i
 import gpg
 
 c = gpg.Context()
 
 c.home_dir = "~/.gnupg-dm"
 userid = "Danger Mouse "
 
 dmkey = c.create_key(userid, algorithm="rsa3072", expires_in=31536000,
                      sign=True, certify=True)
 #+END_SRC
 
 One thing to note here is the use of setting the =c.home_dir=
 parameter.  This enables generating the key or keys in a different
 location.  In this case to keep the new key data created for this
 example in a separate location rather than adding it to existing and
 active key store data.  As with the default directory, =~/.gnupg=, any
 temporary or separate directory needs the permissions set to only
 permit access by the directory owner.  On posix systems this means
 setting the directory permissions to 700.
 
 The =temp-homedir-config.py= script in the HOWTO examples directory
 will create an alternative homedir with these configuration options
 already set and the correct directory and file permissions.
 
 The successful generation of the key can be confirmed via the returned
 =GenkeyResult= object, which includes the following data:
 
 #+BEGIN_SRC python -i
 print("""
  Fingerprint:  {0}
  Primary Key:  {1}
   Public Key:  {2}
   Secret Key:  {3}
  Sub Key:  {4}
 User IDs:  {5}
 """.format(dmkey.fpr, dmkey.primary, dmkey.pubkey, dmkey.seckey, dmkey.sub,
            dmkey.uid))
 #+END_SRC
 
 Alternatively the information can be confirmed using the command line
 program:
 
 #+BEGIN_SRC shell
   bash-4.4$ gpg --homedir ~/.gnupg-dm -K
   ~/.gnupg-dm/pubring.kbx
   ----------------------
   sec   rsa3072 2018-03-15 [SC] [expires: 2019-03-15]
 	177B7C25DB99745EE2EE13ED026D2F19E99E63AA
   uid           [ultimate] Danger Mouse 
 
   bash-4.4$
 #+END_SRC
 
 As with generating keys manually, to preconfigure expanded preferences
 for the cipher, digest and compression algorithms, the =gpg.conf= file
 must contain those details in the home directory in which the new key
 is being generated.  I used a cut down version of my own =gpg.conf=
 file in order to be able to generate this:
 
 #+BEGIN_SRC shell
   bash-4.4$ gpg --homedir ~/.gnupg-dm --edit-key 177B7C25DB99745EE2EE13ED026D2F19E99E63AA showpref quit
   Secret key is available.
 
   sec  rsa3072/026D2F19E99E63AA
        created: 2018-03-15  expires: 2019-03-15  usage: SC
        trust: ultimate      validity: ultimate
   [ultimate] (1). Danger Mouse 
 
   [ultimate] (1). Danger Mouse 
        Cipher: TWOFISH, CAMELLIA256, AES256, CAMELLIA192, AES192, CAMELLIA128, AES, BLOWFISH, IDEA, CAST5, 3DES
        Digest: SHA512, SHA384, SHA256, SHA224, RIPEMD160, SHA1
        Compression: ZLIB, BZIP2, ZIP, Uncompressed
        Features: MDC, Keyserver no-modify
 
   bash-4.4$
 #+END_SRC
 
 
 ** Subkeys
    :PROPERTIES:
    :CUSTOM_ID: keygen-subkeys
    :END:
 
 Adding subkeys to a primary key is fairly similar to creating the
 primary key with the =create_subkey= method.  Most of the arguments
 are the same, but not quite all.  Instead of the =userid= argument
 there is now a =key= argument for selecting which primary key to add
 the subkey to.
 
 In the following example an encryption subkey will be added to the
 primary key.  Since Danger Mouse is a security conscious secret agent,
 this subkey will only be valid for about six months, half the length
 of the primary key.
 
 #+BEGIN_SRC python -i
 import gpg
 
 c = gpg.Context()
 c.home_dir = "~/.gnupg-dm"
 
 key = c.get_key(dmkey.fpr, secret=True)
 dmsub = c.create_subkey(key, algorithm="rsa3072", expires_in=15768000,
                         encrypt=True)
 #+END_SRC
 
 As with the primary key, the results here can be checked with:
 
 #+BEGIN_SRC python -i
 print("""
  Fingerprint:  {0}
  Primary Key:  {1}
   Public Key:  {2}
   Secret Key:  {3}
  Sub Key:  {4}
 User IDs:  {5}
 """.format(dmsub.fpr, dmsub.primary, dmsub.pubkey, dmsub.seckey, dmsub.sub,
            dmsub.uid))
 #+END_SRC
 
 As well as on the command line with:
 
 #+BEGIN_SRC shell
   bash-4.4$ gpg --homedir ~/.gnupg-dm -K
   ~/.gnupg-dm/pubring.kbx
   ----------------------
   sec   rsa3072 2018-03-15 [SC] [expires: 2019-03-15]
 	177B7C25DB99745EE2EE13ED026D2F19E99E63AA
   uid           [ultimate] Danger Mouse 
   ssb   rsa3072 2018-03-15 [E] [expires: 2018-09-13]
 
   bash-4.4$
 #+END_SRC
 
 
 ** User IDs
    :PROPERTIES:
    :CUSTOM_ID: keygen-uids
    :END:
 
 
 *** Adding User IDs
     :PROPERTIES:
     :CUSTOM_ID: keygen-uids-add
     :END:
 
 By comparison to creating primary keys and subkeys, adding a new user
 ID to an existing key is much simpler.  The method used to do this is
 =key_add_uid= and the only arguments it takes are for the =key= and
 the new =uid=.
 
 #+BEGIN_SRC python -i
 import gpg
 
 c = gpg.Context()
 c.home_dir = "~/.gnupg-dm"
 
 dmfpr = "177B7C25DB99745EE2EE13ED026D2F19E99E63AA"
 key = c.get_key(dmfpr, secret=True)
 uid = "Danger Mouse "
 
 c.key_add_uid(key, uid)
 #+END_SRC
 
 Unsurprisingly the result of this is:
 
 #+BEGIN_SRC shell
   bash-4.4$ gpg --homedir ~/.gnupg-dm -K
   ~/.gnupg-dm/pubring.kbx
   ----------------------
   sec   rsa3072 2018-03-15 [SC] [expires: 2019-03-15]
 	177B7C25DB99745EE2EE13ED026D2F19E99E63AA
   uid           [ultimate] Danger Mouse 
   uid           [ultimate] Danger Mouse 
   ssb   rsa3072 2018-03-15 [E] [expires: 2018-09-13]
 
   bash-4.4$
 #+END_SRC
 
 
 *** Revoking User IDs
     :PROPERTIES:
     :CUSTOM_ID: keygen-uids-revoke
     :END:
 
 Revoking a user ID is a fairly similar process, except that it uses
 the =key_revoke_uid= method.
 
 #+BEGIN_SRC python -i
 import gpg
 
 c = gpg.Context()
 c.home_dir = "~/.gnupg-dm"
 
 dmfpr = "177B7C25DB99745EE2EE13ED026D2F19E99E63AA"
 key = c.get_key(dmfpr, secret=True)
 uid = "Danger Mouse "
 
 c.key_revoke_uid(key, uid)
 #+END_SRC
 
 
 ** Key certification
    :PROPERTIES:
    :CUSTOM_ID: key-sign
    :END:
 
 Since key certification is more frequently referred to as key signing,
 the method used to perform this function is =key_sign=.
 
 The =key_sign= method takes four arguments: =key=, =uids=,
 =expires_in= and =local=.  The default value of =uids= is =None= and
 which results in all user IDs being selected.  The default value of
 both =expires_in= and =local= is =False=; which results in the
 signature never expiring and being able to be exported.
 
 The =key= is the key being signed rather than the key doing the
 signing.  To change the key doing the signing refer to the signing key
 selection above for signing messages and files.
 
 If the =uids= value is not =None= then it must either be a string to
 match a single user ID or a list of strings to match multiple user
 IDs.  In this case the matching of those strings must be precise and
 it is case sensitive.
 
 To sign Danger Mouse's key for just the initial user ID with a
 signature which will last a little over a month, do this:
 
 #+BEGIN_SRC python -i
 import gpg
 
 c = gpg.Context()
 uid = "Danger Mouse "
 
 dmfpr = "177B7C25DB99745EE2EE13ED026D2F19E99E63AA"
 key = c.get_key(dmfpr, secret=True)
 c.key_sign(key, uids=uid, expires_in=2764800)
 #+END_SRC
 
 
 * Advanced or Experimental Use Cases
   :PROPERTIES:
   :CUSTOM_ID: advanced-use
   :END:
 
 
 ** C plus Python plus SWIG plus Cython
    :PROPERTIES:
    :CUSTOM_ID: cython
    :END:
 
 In spite of the apparent incongruence of using Python bindings to a C
 interface only to generate more C from the Python; it is in fact quite
 possible to use the GPGME bindings with [[http://docs.cython.org/en/latest/index.html][Cython]].  Though in many cases
 the benefits may not be obvious since the most computationally
 intensive work never leaves the level of the C code with which GPGME
 itself is interacting with.
 
 Nevertheless, there are some situations where the benefits are
 demonstrable.  One of the better and easier examples being the one of
 the early examples in this HOWTO, the [[#howto-keys-counting][key counting]] code.  Running that
 example as an executable Python script, =keycount.py= (available in
-the =examples/howto/= directory), will take a noticable amount of time
+the =examples/howto/= directory), will take a noticeable amount of time
 to run on most systems where the public keybox or keyring contains a
 few thousand public keys.
 
 Earlier in the evening, prior to starting this section, I ran that
 script on my laptop; as I tend to do periodically and timed it using
 =time= utility, with the following results:
 
 #+BEGIN_SRC shell
   bash-4.4$ time keycount.py
 
   Number of secret keys:  23
   Number of public keys:  12112
 
 
   real	11m52.945s
   user	0m0.913s
   sys	0m0.752s
 
   bash-4.4$
 #+END_SRC
 
 Sometime after that I imported another key and followed it with a
 little test of Cython.  This test was kept fairly basic, essentially
 lifting the material from the [[http://docs.cython.org/en/latest/src/tutorial/cython_tutorial.html][Cython Basic Tutorial]] to demonstrate
 compiling Python code to C.  The first step was to take the example
 key counting code quoted previously, essentially from the importing of
 the =gpg= module to the end of the script:
 
 #+BEGIN_SRC python -i
 import gpg
 
 c = gpg.Context()
 seckeys = c.keylist(pattern=None, secret=True)
 pubkeys = c.keylist(pattern=None, secret=False)
 
 seclist = list(seckeys)
 secnum = len(seclist)
 
 publist = list(pubkeys)
 pubnum = len(publist)
 
 print("""
     Number of secret keys:  {0}
     Number of public keys:  {1}
 
 """.format(secnum, pubnum))
 #+END_SRC
 
 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 Cython.Build import cythonize
 
 setup(
     ext_modules = cythonize("keycount.pyx")
 )
 #+END_SRC
 
 Compile it:
 
 #+BEGIN_SRC shell
   bash-4.4$ python setup.py build_ext --inplace
   bash-4.4$
 #+END_SRC
 
 Then run it in a similar manner to =keycount.py=:
 
 #+BEGIN_SRC shell
   bash-4.4$ time python3.7 -c "import keycount"
 
   Number of secret keys:  23
   Number of public keys:  12113
 
 
   real	6m47.905s
   user	0m0.785s
   sys	0m0.331s
 
   bash-4.4$
 #+END_SRC
 
 Cython turned =keycount.pyx= into an 81KB =keycount.o= file in the
 =build/= directory, a 24KB =keycount.cpython-37m-darwin.so= file to be
 imported into Python 3.7 and a 113KB =keycount.c= generated C source
 code file of nearly three thousand lines.  Quite a bit bigger than the
 314 bytes of the =keycount.pyx= file or the full 1,452 bytes of the
 full executable =keycount.py= example script.
 
 On the other hand it ran in nearly half the time; taking 6 minutes and
 47.905 seconds to run.  As opposed to the 11 minutes and 52.945 seconds
 which the CPython script alone took.
 
 The =keycount.pyx= and =setup.py= files used to generate this example
 have been added to the =examples/howto/advanced/cython/= directory
 The example versions include some additional options to annotate the
 existing code and to detect Cython's use.  The latter comes from the
 [[http://docs.cython.org/en/latest/src/tutorial/pure.html#magic-attributes-within-the-pxd][Magic Attributes]] section of the Cython documentation.
 
 
 * Miscellaneous extras and work-arounds
   :PROPERTIES:
   :CUSTOM_ID: cheats-and-hacks
   :END:
 
 Most of the things in the following sections are here simply because
 there was no better place to put them, even though some are only
 peripherally related to the GPGME Python bindings.  Some are also
 workarounds for functions not integrated with GPGME as yet.  This is
 especially true of the first of these, dealing with [[#group-lines][group lines]].
 
 
 ** Group lines
    :PROPERTIES:
    :CUSTOM_ID: group-lines
    :END:
 
 There is not yet an easy way to access groups configured in the
 gpg.conf file from within GPGME.  As a consequence these central
 groupings of keys cannot be shared amongst multiple programs, such as
 MUAs readily.
 
 The following code, however, provides a work-around for obtaining this
 information in Python.
 
 #+BEGIN_SRC python -i
 import subprocess
 import sys
 
 if sys.platform == "win32":
     gpgconfcmd = "gpgconf.exe --list-options gpg"
 else:
     gpgconfcmd = "gpgconf --list-options gpg"
 
 try:
     lines = subprocess.getoutput(gpgconfcmd).splitlines()
 except:
     process = subprocess.Popen(gpgconfcmd.split(), stdout=subprocess.PIPE)
     procom = process.communicate()
     if sys.version_info[0] == 2:
         lines = procom[0].splitlines()
     else:
         lines = procom[0].decode().splitlines()
 
 for i in range(len(lines)):
     if lines[i].startswith("group") is True:
         line = lines[i]
     else:
         pass
 
 groups = line.split(":")[-1].replace('"', '').split(',')
 
 group_lines = []
 group_lists = []
 
 for i in range(len(groups)):
     group_lines.append(groups[i].split("="))
     group_lists.append(groups[i].split("="))
 
 for i in range(len(group_lists)):
     group_lists[i][1] = group_lists[i][1].split()
 #+END_SRC
 
 The result of that code is that =group_lines= is a list of lists where
 =group_lines[i][0]= is the name of the group and =group_lines[i][1]=
 is the key IDs of the group as a string.
 
 The =group_lists= result is very similar in that it is a list of
 lists.  The first part, =group_lists[i][0]= matches
 =group_lines[i][0]= as the name of the group, but =group_lists[i][1]=
 is the key IDs of the group as a list.
 
 A demonstration of using the =groups.py= module is also available in
 the form of the executable =mutt-groups.py= script.  This second
 script reads all the group entries in a user's =gpg.conf= file and
 converts them into crypt-hooks suitable for use with the Mutt and
 Neomutt mail clients.
 
 
 ** Keyserver access for Python
    :PROPERTIES:
    :CUSTOM_ID: hkp4py
    :END:
 
 The [[https://github.com/Selfnet/hkp4py][hkp4py]] module by Marcel Fest was originally a port of the old
 [[https://github.com/dgladkov/python-hkp][python-hkp]] module from Python 2 to Python 3 and updated to use the
 [[http://docs.python-requests.org/en/latest/index.html][requests]] module instead.  It has since been modified to provide
 support for Python 2.7 as well and is available via PyPI.
 
 Since it rewrites the =hkp= protocol prefix as =http= and =hkps= as
 =https=, the module is able to be used even with servers which do not
 support the full scope of keyserver functions.[fn:5]  It also works quite
 readily when incorporated into a [[#cython][Cython]] generated and compiled version
 of any code.
 
 
 *** Key import format
     :PROPERTIES:
     :CUSTOM_ID: hkp4py-strings
     :END:
 
 The hkp4py module returns key data via requests as string literals
 (=r.text=) instead of byte literals (=r.content=).  This means that
 the retrurned key data must be encoded to UTF-8 when importing that
 key material using a =gpg.Context().key_import()= method.
 
 For this reason an alternative method has been added to the =search=
 function of =hkp4py.KeyServer()= which returns the key in the correct
 format as expected by =key_import=.  When importing using this module,
 it is now possible to import with this:
 
 #+BEGIN_SRC python -i
 for key in keys:
     if key.revoked is False:
         gpg.Context().key_import(key.key_blob)
     else:
         pass
 #+END_SRC
 
 Without that recent addition it would have been necessary to encode
 the contents of each =hkp4py.KeyServer().search()[i].key= in
 =hkp4py.KeyServer().search()= before trying to import it.
 
 An example of this is included in the [[#howto-import-key][Importing Keys]] section of this
 HOWTO and the corresponding executable version of that example is
 available in the =lang/python/examples/howto= directory as normal; the
 executable version is the =import-keys-hkp.py= file.
 
 
 * Copyright and Licensing
   :PROPERTIES:
   :CUSTOM_ID: copyright-and-license
   :END:
 
 
 ** Copyright
    :PROPERTIES:
    :CUSTOM_ID: copyright
    :END:
 
 Copyright © The GnuPG Project, 2018.
 
 Copyright (C) The GnuPG Project, 2018.
 
 
 ** Draft Editions of this HOWTO
    :PROPERTIES:
    :CUSTOM_ID: draft-editions
    :END:
 
 Draft editions of this HOWTO may be periodically available directly
 from the author at any of the following URLs:
 
 - [[https://files.au.adversary.org/crypto/gpgme-python-howto.html][GPGME Python Bindings HOWTO draft (XHTML AWS S3 SSL)]]
 - [[http://files.au.adversary.org/crypto/gpgme-python-howto.html][GPGME Python Bindings HOWTO draft (XHTML AWS S3 no SSL)]]
 - [[https://files.au.adversary.org/crypto/gpgme-python-howto.texi][GPGME Python Bindings HOWTO draft (Texinfo file AWS S3 SSL)]]
 - [[http://files.au.adversary.org/crypto/gpgme-python-howto.texi][GPGME Python Bindings HOWTO draft (Texinfo file AWS S3 no SSL)]]
 - [[https://files.au.adversary.org/crypto/gpgme-python-howto.info][GPGME Python Bindings HOWTO draft (Info file AWS S3 SSL)]]
 - [[http://files.au.adversary.org/crypto/gpgme-python-howto.info][GPGME Python Bindings HOWTO draft (Info file AWS S3 no SSL)]]
 - [[https://files.au.adversary.org/crypto/gpgme-python-howto.rst][GPGME Python Bindings HOWTO draft (reST file AWS S3 SSL)]]
 - [[http://files.au.adversary.org/crypto/gpgme-python-howto.rst][GPGME Python Bindings HOWTO draft (reST file AWS S3 no SSL)]]
 - [[https://files.au.adversary.org/crypto/gpgme-python-howto.xml][GPGME Python Bindings HOWTO draft (Docbook 4.2 AWS S3 SSL)]]
 - [[http://files.au.adversary.org/crypto/gpgme-python-howto.xml][GPGME Python Bindings HOWTO draft (Docbook 4.2 AWS S3 no SSL)]]
 
 All of these draft versions except for one have been generated from
 this document via Emacs [[https://orgmode.org/][Org mode]] and [[https://www.gnu.org/software/texinfo/][GNU Texinfo]].  Though it is likely
 that the specific [[https://files.au.adversary.org/crypto/gpgme-python-howto][file]] [[http://files.au.adversary.org/crypto/gpgme-python-howto.org][version]] used will be on the same server with
 the generated output formats.
 
 The one exception is the reStructuredText version, which was converted
 using the latest version of Pandoc from the Org mode source file using
 either of the following two commands:
 
 #+BEGIN_SRC shell
   pandoc -f org -t rst -o gpgme-python-howto.rst gpgme-python-howto.org
   pandoc -f org -t rst -o gpgme-python-howto.rst gpgme-python-howto
 #+END_SRC
 
 In addition to these there is a significantly less frequently updated
 version as a HTML [[https://files.au.adversary.org/crypto/gpgme-python-howto/webhelp/index.html][WebHelp site]] (AWS S3 SSL); generated from DITA XML
 source files, which can be found in [[https://dev.gnupg.org/source/gpgme/browse/ben%252Fhowto-dita/][an alternative branch]] of the GPGME
 git repository.
 
 These draft editions are not official documents and the version of
 documentation in the master branch or which ships with released
 versions is the only official documentation.  Nevertheless, these
 draft editions may occasionally be of use by providing more accessible
 web versions which are updated between releases.  They are provided on
 the understanding that they may contain errors or may contain content
 subject to change prior to an official release.
 
 
 ** License GPL compatible
    :PROPERTIES:
    :CUSTOM_ID: license
    :END:
 
 This file is free software; as a special exception the author gives
 unlimited permission to copy and/or distribute it, with or without
 modifications, as long as this notice is preserved.
 
 This file is distributed in the hope that it will be useful, but
 WITHOUT ANY WARRANTY, to the extent permitted by law; without even the
 implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
 PURPOSE.
 
 
 * Footnotes
 
 [fn:1] =short-history= and/or =short-history.html=.
 
 [fn:2] With no issues reported specific to Python 3.7, the release of
 Python 3.7.1 at around the same time as GPGME 1.12.0 and the testing
 with Python 3.7.1rc1, there is no reason to delay moving 3.7 ahead of
 3.6 now.  Production environments with more conservative requirements
 will always enforce their own policies anyway and installation to each
 supported minor release is quite possible too.
 
 [fn:3] Yes, even if you use virtualenv with everything you do in
 Python.  If you want to install this module as just your user account
 then you will need to manually configure, compile and install the
 /entire/ GnuPG stack as that user as well.  This includes libraries
 which are not often installed that way.  It can be done and there are
 circumstances under which it is worthwhile, but generally only on
 POSIX systems which utilise single user mode (some even require it).
 
 [fn:4] You probably don't really want to do this.  Searching the
 keyservers for "gnupg.org" produces over 400 results, the majority of
 which aren't actually at the gnupg.org domain, but just included a
 comment regarding the project in their key somewhere.
 
 [fn:5] Such as with ProtonMail servers.  This also means that
 restricted servers which only advertise either HTTP or HTTPS end
 points and not HKP or HKPS end points must still be identified as as
 HKP or HKPS within the Python Code.  The =hkp4py= module will rewrite
 these appropriately when the connection is made to the server.
diff --git a/lang/python/doc/texinfo/gpgme-python-howto.texi b/lang/python/doc/texinfo/gpgme-python-howto.texi
index d776f58d..4f10bc5b 100644
--- a/lang/python/doc/texinfo/gpgme-python-howto.texi
+++ b/lang/python/doc/texinfo/gpgme-python-howto.texi
@@ -1,3092 +1,3092 @@
 \input texinfo    @c -*- texinfo -*-
 @c %**start of header
 @setfilename gpgme-python-howto.info
 @settitle GNU Privacy Guard (GnuPG) Made Easy Python Bindings HOWTO (English)
 @documentencoding UTF-8
 @documentlanguage en
 @c %**end of header
 
 @finalout
 @titlepage
 @title GNU Privacy Guard (GnuPG) Made Easy Python Bindings HOWTO (English)
 @author Ben McGinnes
 @end titlepage
 
 @contents
 
 @ifnottex
 @node Top
 @top GNU Privacy Guard (GnuPG) Made Easy Python Bindings HOWTO (English)
 @end ifnottex
 
 @menu
 * Introduction::
 * GPGME Concepts::
 * GPGME Python bindings installation::
 * Fundamentals::
 * Working with keys::
 * Basic Functions::
 * Creating keys and subkeys::
 * Advanced or Experimental Use Cases::
 * Miscellaneous extras and work-arounds::
 * Copyright and Licensing::
 
 @detailmenu
 --- The Detailed Node Listing ---
 
 Introduction
 
 * Python 2 versus Python 3::
 * Examples::
 * Unofficial Drafts::
 * What's New::
 
 What's New
 
 * New in GPGME 1·13·0::
 * New in GPGME 1·12·0::
 
 GPGME Concepts
 
 * A C API::
 * Python bindings::
 * Difference between the Python bindings and other GnuPG Python packages::
 
 Difference between the Python bindings and other GnuPG Python packages
 
 * The python-gnupg package maintained by Vinay Sajip::
 * The gnupg package created and maintained by Isis Lovecruft::
 * The PyME package maintained by Martin Albrecht::
 
 GPGME Python bindings installation
 
 * No PyPI::
 * Requirements::
 * Installation::
 * Known Issues::
 
 Requirements
 
 * Recommended Additions::
 
 Installation
 
 * Installing GPGME::
 
 Known Issues
 
 * Breaking Builds::
 * Reinstalling Responsibly::
 * Multiple installations::
 * Won't Work With Windows::
 * CFFI is the Best™ and GPGME should use it instead of SWIG::
 * Virtualised Environments::
 
 Fundamentals
 
 * No REST::
 * Context::
 
 Working with keys
 
 * Key selection::
 * Get key::
 * Importing keys::
 * Exporting keys::
 
 Key selection
 
 * Counting keys::
 
 Importing keys
 
 * Working with ProtonMail::
 * Importing with HKP for Python::
 * Importing from ProtonMail with HKP for Python::
 
 Exporting keys
 
 * Exporting public keys::
 * Exporting secret keys::
 * Sending public keys to the SKS Keyservers::
 
 Basic Functions
 
 * Encryption::
 * Decryption::
 * Signing text and files::
 * Signature verification::
 
 Encryption
 
 * Encrypting to one key::
 * Encrypting to multiple keys::
 
 Signing text and files
 
 * Signing key selection::
 * Normal or default signing messages or files::
 * Detached signing messages and files::
 * Clearsigning messages or text::
 
 Creating keys and subkeys
 
 * Primary key::
 * Subkeys::
 * User IDs::
 * Key certification::
 
 User IDs
 
 * Adding User IDs::
 * Revoking User IDs::
 
 Advanced or Experimental Use Cases
 
 * C plus Python plus SWIG plus Cython::
 
 Miscellaneous extras and work-arounds
 
 * Group lines::
 * Keyserver access for Python::
 
 Keyserver access for Python
 
 * Key import format::
 
 Copyright and Licensing
 
 * Copyright::
 * Draft Editions of this HOWTO::
 * License GPL compatible::
 
 @end detailmenu
 @end menu
 
 @node Introduction
 @chapter Introduction
 
 @multitable {aaaaaaaaaaaaaaa} {aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa}
 @item Version:
 @tab 0.1.4
 @item GPGME Version:
 @tab 1.12.0
 @item Author:
 @tab @uref{https://gnupg.org/people/index.html#sec-1-5, Ben McGinnes} 
 @item Author GPG Key:
 @tab DB4724E6FA4286C92B4E55C4321E4E2373590E5D
 @item Language:
 @tab Australian English, British English
 @item xml:lang:
 @tab en-AU, en-GB, en
 @end multitable
 
 This document provides basic instruction in how to use the GPGME
 Python bindings to programmatically leverage the GPGME library.
 
 @menu
 * Python 2 versus Python 3::
 * Examples::
 * Unofficial Drafts::
 * What's New::
 @end menu
 
 @node Python 2 versus Python 3
 @section Python 2 versus Python 3
 
 Though the GPGME Python bindings themselves provide support for both
 Python 2 and 3, the focus is unequivocally on Python 3 and
 specifically from Python 3.4 and above.  As a consequence all the
 examples and instructions in this guide use Python 3 code.
 
 Much of it will work with Python 2, but much of it also deals with
 Python 3 byte literals, particularly when reading and writing data.
 Developers concentrating on Python 2.7, and possibly even 2.6, will
 need to make the appropriate modifications to support the older string
 and unicode types as opposed to bytes.
 
 There are multiple reasons for concentrating on Python 3; some of
 which relate to the immediate integration of these bindings, some of
 which relate to longer term plans for both GPGME and the python
 bindings and some of which relate to the impending EOL period for
 Python 2.7.  Essentially, though, there is little value in tying the
 bindings to a version of the language which is a dead end and the
 advantages offered by Python 3 over Python 2 make handling the data
 types with which GPGME deals considerably easier.
 
 @node Examples
 @section Examples
 
 All of the examples found in this document can be found as Python 3
 scripts in the @samp{lang/python/examples/howto} directory.
 
 @node Unofficial Drafts
 @section Unofficial Drafts
 
 In addition to shipping with each release of GPGME, there is a section
 on locations to read or download @ref{Draft Editions of this HOWTO, , draft editions} of this document from
 at the end of it.  These are unofficial versions produced in between
 major releases.
 
 @node What's New
 @section What's New
 
 Full details of what is new are now available in the @uref{what-is-new.org, What's New} file
 and archives of the preceding @emph{What's New} sections are available in
 the @uref{what-was-new, What Was New} file.
 
 @menu
 * New in GPGME 1·13·0::
 * New in GPGME 1·12·0::
 @end menu
 
 @node New in GPGME 1·13·0
 @subsection New in GPGME 1·13·0
 
 See the @uref{what-is-new#new-stuff-1-13-0, What's New} document for what is new in version 1.13.0.
 
 @node New in GPGME 1·12·0
 @subsection New in GPGME 1·12·0
 
 See the @uref{what-was-new#new-stuff-1-12-0, What Was New} document for what was new in version 1.12.0.
 
 @node GPGME Concepts
 @chapter GPGME Concepts
 
 @menu
 * A C API::
 * Python bindings::
 * Difference between the Python bindings and other GnuPG Python packages::
 @end menu
 
 @node A C API
 @section A C API
 
 Unlike many modern APIs with which programmers will be more familiar
 with these days, the GPGME API is a C API.  The API is intended for
 use by C coders who would be able to access its features by including
 the @samp{gpgme.h} header file with their own C source code and then access
 its functions just as they would any other C headers.
 
 This is a very effective method of gaining complete access to the API
 and in the most efficient manner possible.  It does, however, have the
 drawback that it cannot be directly used by other languages without
 some means of providing an interface to those languages.  This is
 where the need for bindings in various languages stems.
 
 @node Python bindings
 @section Python bindings
 
 The Python bindings for GPGME provide a higher level means of
 accessing the complete feature set of GPGME itself.  It also provides
 a more pythonic means of calling these API functions.
 
 The bindings are generated dynamically with SWIG and the copy of
 @samp{gpgme.h} generated when GPGME is compiled.
 
 This means that a version of the Python bindings is fundamentally tied
 to the exact same version of GPGME used to generate that copy of
 @samp{gpgme.h}.
 
 @node Difference between the Python bindings and other GnuPG Python packages
 @section Difference between the Python bindings and other GnuPG Python packages
 
 There have been numerous attempts to add GnuPG support to Python over
 the years.  Some of the most well known are listed here, along with
 what differentiates them.
 
 @menu
 * The python-gnupg package maintained by Vinay Sajip::
 * The gnupg package created and maintained by Isis Lovecruft::
 * The PyME package maintained by Martin Albrecht::
 @end menu
 
 @node The python-gnupg package maintained by Vinay Sajip
 @subsection The python-gnupg package maintained by Vinay Sajip
 
 This is arguably the most popular means of integrating GPG with
 Python.  The package utilises the @samp{subprocess} module to implement
 wrappers for the @samp{gpg} and @samp{gpg2} executables normally invoked on the
 command line (@samp{gpg.exe} and @samp{gpg2.exe} on Windows).
 
 The popularity of this package stemmed from its ease of use and
 capability in providing the most commonly required features.
 
 Unfortunately it has been beset by a number of security issues in the
 past; most of which stemmed from using unsafe methods of accessing the
 command line via the @samp{subprocess} calls.  While some effort has been
 made over the last two to three years (as of 2018) to mitigate this,
 particularly by no longer providing shell access through those
 subprocess calls, the wrapper is still somewhat limited in the scope
 of its GnuPG features coverage.
 
 The python-gnupg package is available under the MIT license.
 
 @node The gnupg package created and maintained by Isis Lovecruft
 @subsection The gnupg package created and maintained by Isis Lovecruft
 
 In 2015 Isis Lovecruft from the Tor Project forked and then
 re-implemented the python-gnupg package as just gnupg.  This new
 package also relied on subprocess to call the @samp{gpg} or @samp{gpg2}
 binaries, but did so somewhat more securely.
 
 The naming and version numbering selected for this package, however,
 resulted in conflicts with the original python-gnupg and since its
 functions were called in a different manner to python-gnupg, the
 release of this package also resulted in a great deal of consternation
 when people installed what they thought was an upgrade that
 subsequently broke the code relying on it.
 
 The gnupg package is available under the GNU General Public License
 version 3.0 (or any later version).
 
 @node The PyME package maintained by Martin Albrecht
 @subsection The PyME package maintained by Martin Albrecht
 
 This package is the origin of these bindings, though they are somewhat
 different now.  For details of when and how the PyME package was
 folded back into GPGME itself see the @uref{short-history.org, Short History} document.@footnote{@samp{short-history} and/or @samp{short-history.html}.}
 
 The PyME package was first released in 2002 and was also the first
 attempt to implement a low level binding to GPGME.  In doing so it
 provided access to considerably more functionality than either the
 @samp{python-gnupg} or @samp{gnupg} packages.
 
 The PyME package is only available for Python 2.6 and 2.7.
 
 Porting the PyME package to Python 3.4 in 2015 is what resulted in it
 being folded into the GPGME project and the current bindings are the
 end result of that effort.
 
 The PyME package is available under the same dual licensing as GPGME
 itself: the GNU General Public License version 2.0 (or any later
 version) and the GNU Lesser General Public License version 2.1 (or any
 later version).
 
 @node GPGME Python bindings installation
 @chapter GPGME Python bindings installation
 
 @menu
 * No PyPI::
 * Requirements::
 * Installation::
 * Known Issues::
 @end menu
 
 @node No PyPI
 @section No PyPI
 
 Most third-party Python packages and modules are available and
 distributed through the Python Package Installer, known as PyPI.
 
 Due to the nature of what these bindings are and how they work, it is
 infeasible to install the GPGME Python bindings in the same way.
 
 This is because the bindings use SWIG to dynamically generate C
 bindings against @samp{gpgme.h} and @samp{gpgme.h} is generated from
 @samp{gpgme.h.in} at compile time when GPGME is built from source.  Thus to
 include a package in PyPI which actually built correctly would require
 either statically built libraries for every architecture bundled with
 it or a full implementation of C for each architecture.
 
 See the additional notes regarding @ref{CFFI is the Best™ and GPGME should use it instead of SWIG, , CFFI and SWIG} at the end of this
 section for further details.
 
 @node Requirements
 @section Requirements
 
 The GPGME Python bindings only have three requirements:
 
 @enumerate
 @item
 A suitable version of Python 2 or Python 3.  With Python 2 that
 means CPython 2.7 and with Python 3 that means CPython 3.4 or
 higher.
 @item
 @uref{https://www.swig.org, SWIG}.
 @item
 GPGME itself.  Which also means that all of GPGME's dependencies
 must be installed too.
 @end enumerate
 
 @menu
 * Recommended Additions::
 @end menu
 
 @node Recommended Additions
 @subsection Recommended Additions
 
 Though none of the following are absolute requirements, they are all
 recommended for use with the Python bindings.  In some cases these
 recommendations refer to which version(s) of CPython to use the
 bindings with, while others refer to third party modules which provide
 a significant advantage in some way.
 
 @enumerate
 @item
 If possible, use Python 3 instead of 2.
 @item
 Favour a more recent version of Python since even 3.4 is due to
 reach EOL soon.  In production systems and services, Python 3.6
 should be robust enough to be relied on.
 @item
 If possible add the following Python modules which are not part of
 the standard library: @uref{http://docs.python-requests.org/en/latest/index.html, Requests}, @uref{https://cython.org/, Cython} and @uref{https://github.com/Selfnet/hkp4py, hkp4py}.  Chances are
 quite high that at least the first one and maybe two of those will
 already be installed.
 @end enumerate
 
 Note that, as with Cython, some of the planned additions to the
 @ref{Advanced or Experimental Use Cases, , Advanced} section, will bring with them additional requirements.  Most
 of these will be fairly well known and commonly installed ones,
 however, which are in many cases likely to have already been installed
 on many systems or be familiar to Python programmers.
 
 @node Installation
 @section Installation
 
 Installing the Python bindings is effectively achieved by compiling
 and installing GPGME itself.
 
 Once SWIG is installed with Python and all the dependencies for GPGME
 are installed you only need to confirm that the version(s) of Python
 you want the bindings installed for are in your @samp{$PATH}.
 
 By default GPGME will attempt to install the bindings for the most
 recent or highest version number of Python 2 and Python 3 it detects
 in @samp{$PATH}.  It specifically checks for the @samp{python} and @samp{python3}
 executables first and then checks for specific version numbers.
 
 For Python 2 it checks for these executables in this order: @samp{python},
 @samp{python2} and @samp{python2.7}.
 
 For Python 3 it checks for these executables in this order: @samp{python3},
  @samp{python3.7}, @samp{python3.6}, @samp{python3.5} and @samp{python3.4}.@footnote{With no issues reported specific to Python 3.7, the release of
 Python 3.7.1 at around the same time as GPGME 1.12.0 and the testing
 with Python 3.7.1rc1, there is no reason to delay moving 3.7 ahead of
 3.6 now.  Production environments with more conservative requirements
 will always enforce their own policies anyway and installation to each
 supported minor release is quite possible too.}
 
 On systems where @samp{python} is actually @samp{python3} and not @samp{python2} it
 may be possible that @samp{python2} may be overlooked, but there have been
 no reports of that actually occurring as yet.
 
 In the three months or so since the release of Python 3.7.0 there has
 been extensive testing and work with these bindings with no issues
 specifically relating to the new version of Python or any of the new
 features of either the language or the bindings.  This has also been
 the case with Python 3.7.1rc1.  With that in mind and given the
 release of Python 3.7.1 is scheduled for around the same time as GPGME
 1.12.0, the order of preferred Python versions has been changed to
 move Python 3.7 ahead of Python 3.6.
 
 @menu
 * Installing GPGME::
 @end menu
 
 @node Installing GPGME
 @subsection Installing GPGME
 
 See the GPGME @samp{README} file for details of how to install GPGME from
 source.
 
 @node Known Issues
 @section Known Issues
 
 There are a few known issues with the current build process and the
 Python bindings.  For the most part these are easily addressed should
 they be encountered.
 
 @menu
 * Breaking Builds::
 * Reinstalling Responsibly::
 * Multiple installations::
 * Won't Work With Windows::
 * CFFI is the Best™ and GPGME should use it instead of SWIG::
 * Virtualised Environments::
 @end menu
 
 @node Breaking Builds
 @subsection Breaking Builds
 
 Occasionally when installing GPGME with the Python bindings included
 it may be observed that the @samp{make} portion of that process induces a
 large very number of warnings and, eventually errors which end that
 part of the build process.  Yet following that with @samp{make check} and
 @samp{make install} appears to work seamlessly.
 
 The cause of this is related to the way SWIG needs to be called to
 dynamically generate the C bindings for GPGME in the first place.  So
 the entire process will always produce @samp{lang/python/python2-gpg/} and
 @samp{lang/python/python3-gpg/} directories.  These should contain the
 build output generated during compilation, including the complete
 bindings and module installed into @samp{site-packages}.
 
 Occasionally the errors in the early part or some other conflict
 (e.g. not installing as @strong{@emph{root}} or @strong{@emph{su}}) may result in nothing
 being installed to the relevant @samp{site-packages} directory and the
 build directory missing a lot of expected files.  Even when this
 occurs, the solution is actually quite simple and will always work.
 
 That solution is simply to run the following commands as either the
 @strong{root} user or prepended with @samp{sudo -H}@footnote{Yes, even if you use virtualenv with everything you do in
 Python.  If you want to install this module as just your user account
 then you will need to manually configure, compile and install the
 @emph{entire} GnuPG stack as that user as well.  This includes libraries
 which are not often installed that way.  It can be done and there are
 circumstances under which it is worthwhile, but generally only on
 POSIX systems which utilise single user mode (some even require it).} in the @samp{lang/python/}
 directory:
 
 @example
 /path/to/pythonX.Y setup.py build
 /path/to/pythonX.Y setup.py build
 /path/to/pythonX.Y setup.py install
 @end example
 
 Yes, the build command does need to be run twice.  Yes, you still need
 to run the potentially failing or incomplete steps during the
 @samp{configure}, @samp{make} and @samp{make install} steps with installing GPGME.
 This is because those steps generate a lot of essential files needed,
 both by and in order to create, the bindings (including both the
 @samp{setup.py} and @samp{gpgme.h} files).
 
 @enumerate
 @item
 IMPORTANT Note
 
 
 If specifying a selected number of languages to create bindings for,
 try to leave Python last.  Currently the majority of the other
 language bindings are also preceding Python of either version when
 listed alphabetically and so that just happens by default currently.
 
 If Python is set to precede one of the other languages then it is
 possible that the errors described here may interrupt the build
 process before generating bindings for those other languages.  In
 these cases it may be preferable to configure all preferred language
 bindings separately with alternative @samp{configure} steps for GPGME using
 the @samp{--enable-languages=$LANGUAGE} option.
 @end enumerate
 
 @node Reinstalling Responsibly
 @subsection Reinstalling Responsibly
 
 Regardless of whether you're installing for one version of Python or
 several, there will come a point where reinstallation is required.
 With most Python module installations, the installed files go into the
 relevant site-packages directory and are then forgotten about.  Then
 the module is upgraded, the new files are copied over the old and
 that's the end of the matter.
 
 While the same is true of these bindings, there have been intermittent
 issues observed on some platforms which have benefited significantly
 from removing all the previous installations of the bindings before
 installing the updated versions.
 
 Removing the previous version(s) is simply a matter of changing to the
 relevant @samp{site-packages} directory for the version of Python in
 question and removing the @samp{gpg/} directory and any accompanying
 egg-info files for that module.
 
 In most cases this will require root or administration privileges on
 the system, but the same is true of installing the module in the first
 place.
 
 @node Multiple installations
 @subsection Multiple installations
 
 For a variety of reasons it may be either necessary or just preferable
 to install the bindings to alternative installed Python versions which
 meet the requirements of these bindings.
 
 On POSIX systems this will generally be most simply achieved by
 running the manual installation commands (build, build, install) as
 described in the previous section for each Python installation the
 bindings need to be installed to.
 
 As per the SWIG documentation: the compilers, libraries and runtime
 used to build GPGME and the Python Bindings @strong{must} match those used to
 compile Python itself, including the version number(s) (at least going
 by major version numbers and probably minor numbers too).
 
 On most POSIX systems, including OS X, this will very likely be the
 case in most, if not all, cases.
 
 Note that from GPGME @uref{https://dev.gnupg.org/rMff6ff616aea6f59b7f2ce1176492850ecdf3851e, 1.12.1} the default installation installs to each
 version of Python it can find first.  That is that it will currently
 install for the first copies of Python versions 2.7, 3.4, 3.5, 3.6,
 3.7 and 3.8 (dev branch) that it finds.  Usually this will be in the
 same prefix as GPGME itself, but is dictated by the @samp{$PATH} when the
 installation is performed.  The above instructions can still be
 performed on other python installations which the installer does not
 find, including alternative prefixes.
 
 @node Won't Work With Windows
 @subsection Won't Work With Windows
 
 There are semi-regular reports of Windows users having considerable
 difficulty in installing and using the Python bindings at all.  Very
 often, possibly even always, these reports come from Cygwin users
 and/or MinGW users and/or Msys2 users.  Though not all of them have
 been confirmed, it appears that these reports have also come from
 people who installed Python using the Windows installer files from the
 @uref{https://python.org, Python website} (i.e. mostly MSI installers, sometimes self-extracting
 @samp{.exe} files).
 
 The Windows versions of Python are not built using Cygwin, MinGW or
 Msys2; they're built using Microsoft Visual Studio.  Furthermore the
 version used is @emph{considerably} more advanced than the version which
 MinGW obtained a small number of files from many years ago in order to
 be able to compile anything at all.  Not only that, but there are
 changes to the version of Visual Studio between some micro releases,
 though that is is particularly the case with Python 2.7, since it has
 been kept around far longer than it should have been.
 
 There are two theoretical solutions to this issue:
 
 @enumerate
 @item
 Compile and install the GnuPG stack, including GPGME and the
 Python bibdings using the same version of Microsoft Visual Studio
 used by the Python Foundation to compile the version of Python
 installed.
 
 If there are multiple versions of Python then this will need to be
 done with each different version of Visual Studio used.
 
 @item
 Compile and install Python using the same tools used by choice,
 such as MinGW or Msys2.
 @end enumerate
 
 Do @strong{not} use the official Windows installer for Python unless
 following the first method.
 
 In this type of situation it may even be for the best to accept that
 there are less limitations on permissive software than free software
 and simply opt to use a recent version of the Community Edition of
 Microsoft Visual Studio to compile and build all of it, no matter
 what.
 
 Investigations into the extent or the limitations of this issue are
 ongoing.
 
 @node CFFI is the Best™ and GPGME should use it instead of SWIG
 @subsection CFFI is the Best™ and GPGME should use it instead of SWIG
 
 There are many reasons for favouring @uref{https://cffi.readthedocs.io/en/latest/overview.html, CFFI} and proponents of it are
 quite happy to repeat these things as if all it would take to switch
 from SWIG to CFFI is repeating that list as if it were a new concept.
 
 The fact is that there are things which Python's CFFI implementation
 cannot handle in the GPGME C code.  Beyond that there are features of
 SWIG which are simply not available with CFFI at all.  SWIG generates
 the bindings to Python using the @samp{gpgme.h} file, but that file is not
 a single version shipped with each release, it too is generated when
 GPGME is compiled.
 
 CFFI is currently unable to adapt to such a potentially mutable
 codebase.  If there were some means of applying SWIG's dynamic code
 generation to produce the Python/CFFI API modes of accessing the GPGME
 libraries (or the source source code directly), but such a thing does
 not exist yet either and it currently appears that work is needed in
 at least one of CFFI's dependencies before any of this can be
 addressed.
 
 So if you're a massive fan of CFFI; that's great, but if you want this
 project to switch to CFFI then rather than just insisting that it
 should, I'd suggest you volunteer to bring CFFI up to the level this
 project needs.
 
 If you're actually seriously considering doing so, then I'd suggest
 taking the @samp{gpgme-tool.c} file in the GPGME @samp{src/} directory and
 getting that to work with any of the CFFI API methods (not the ABI
 methods, they'll work with pretty much anything).  When you start
 running into trouble with "ifdefs" then you'll know what sort of
 things are lacking.  That doesn't even take into account the amount of
 work saved via SWIG's code generation techniques either.
 
 @node Virtualised Environments
 @subsection Virtualised Environments
 
 It is fairly common practice amongst Python developers to, as much as
 possible, use packages like virtualenv to keep various things that are
 to be installed from interfering with each other.  Given how much of
 the GPGME bindings is often at odds with the usual pythonic way of
 doing things, it stands to reason that this would be called into
 question too.
 
 As it happens the answer as to whether or not the bindings can be used
 with virtualenv, the answer is both yes and no.
 
 In general we recommend installing to the relevant path and matching
 prefix of GPGME itself.  Which means that when GPGME, and ideally the
 rest of the GnuPG stack, is installed to a prefix like @samp{/usr/local} or
 @samp{/opt/local} then the bindings would need to be installed to the main
 Python installation and not a virtualised abstraction.  Attempts to
 separate the two in the past have been known to cause weird and
 intermittent errors ranging from minor annoyances to complete failures
 in the build process.
 
 As a consequence we only recommend building with and installing to the
 main Python installations within the same prefix as GPGME is installed
 to or which are found by GPGME's configuration stage immediately prior
 to running the make commands.  Which is exactly what the compiling and
 installing process of GPGME does by default.
 
 Once that is done, however, it appears that a copy of the compiled
 module may be installed into a virtualenv of the same major and minor
 version matching the build.  Alternatively it is possible to utilise a
 @samp{sites.pth} file in the @samp{site-packages/} directory of a virtualenv
 installation, which links back to the system installations
 corresponding directory in order to import anything installed system
 wide.  This may or may not be appropriate on a case by case basis.
 
 Though extensive testing of either of these options is not yet
 complete, preliminary testing of them indicates that both are viable
 as long as the main installation is complete.  Which means that
 certain other options normally restricted to virtual environments are
 also available, including integration with pythonic test suites
 (e.g. @uref{https://docs.pytest.org/en/latest/index.html, pytest}) and other large projects.
 
 That said, it is worth reiterating the warning regarding non-standard
 installations.  If one were to attempt to install the bindings only to
 a virtual environment without somehow also including the full GnuPG
 stack (or enough of it as to include GPGME) then it is highly likely
 that errors would be encountered at some point and more than a little
 likely that the build process itself would break.
 
 If a degree of separation from the main operating system is still
 required in spite of these warnings, then consider other forms of
 virtualisation.  Either a virtual machine (e.g. @uref{https://www.virtualbox.org/, VirtualBox}), a
 hardware emulation layer (e.g. @uref{https://www.qemu.org/, QEMU}) or an application container
 (e.g. @uref{https://www.docker.com/why-docker, Docker}).
 
 Finally it should be noted that the limited tests conducted thus far
 have been using the @samp{virtualenv} command in a new directory to create
 the virtual python environment.  As opposed to the standard @samp{python3
 -m venv} and it is possible that this will make a difference depending
 on the system and version of Python in use.  Another option is to run
 the command @samp{python3 -m virtualenv /path/to/install/virtual/thingy}
 instead.
 
 @node Fundamentals
 @chapter Fundamentals
 
 Before we can get to the fun stuff, there are a few matters regarding
 GPGME's design which hold true whether you're dealing with the C code
 directly or these Python bindings.
 
 @menu
 * No REST::
 * Context::
 @end menu
 
 @node No REST
 @section No REST
 
 The first part of which is or will be fairly blatantly obvious upon
 viewing the first example, but it's worth reiterating anyway.  That
 being that this API is @emph{@strong{not}} a REST API.  Nor indeed could it ever
 be one.
 
 Most, if not all, Python programmers (and not just Python programmers)
 know how easy it is to work with a RESTful API.  In fact they've
 become so popular that many other APIs attempt to emulate REST-like
 behaviour as much as they are able.  Right down to the use of JSON
 formatted output to facilitate the use of their API without having to
 retrain developers.
 
 This API does not do that.  It would not be able to do that and also
 provide access to the entire C API on which it's built.  It does,
 however, provide a very pythonic interface on top of the direct
 bindings and it's this pythonic layer that this HOWTO deals with.
 
 @node Context
 @section Context
 
 One of the reasons which prevents this API from being RESTful is that
 most operations require more than one instruction to the API to
 perform the task.  Sure, there are certain functions which can be
 performed simultaneously, particularly if the result known or strongly
 anticipated (e.g. selecting and encrypting to a key known to be in the
 public keybox).
 
 There are many more, however, which cannot be manipulated so readily:
 they must be performed in a specific sequence and the result of one
 operation has a direct bearing on the outcome of subsequent
 operations.  Not merely by generating an error either.
 
 When dealing with this type of persistent state on the web, full of
 both the RESTful and REST-like, it's most commonly referred to as a
 session.  In GPGME, however, it is called a context and every
 operation type has one.
 
 @node Working with keys
 @chapter Working with keys
 
 @menu
 * Key selection::
 * Get key::
 * Importing keys::
 * Exporting keys::
 @end menu
 
 @node Key selection
 @section Key selection
 
 Selecting keys to encrypt to or to sign with will be a common
 occurrence when working with GPGMe and the means available for doing
 so are quite simple.
 
 They do depend on utilising a Context; however once the data is
 recorded in another variable, that Context does not need to be the
 same one which subsequent operations are performed.
 
 The easiest way to select a specific key is by searching for that
 key's key ID or fingerprint, preferably the full fingerprint without
 any spaces in it.  A long key ID will probably be okay, but is not
 advised and short key IDs are already a problem with some being
 generated to match specific patterns.  It does not matter whether the
 pattern is upper or lower case.
 
 So this is the best method:
 
 @example
 import gpg
 
 k = gpg.Context().keylist(pattern="258E88DCBD3CD44D8E7AB43F6ECB6AF0DEADBEEF")
 keys = list(k)
 @end example
 
 This is passable and very likely to be common:
 
 @example
 import gpg
 
 k = gpg.Context().keylist(pattern="0x6ECB6AF0DEADBEEF")
 keys = list(k)
 @end example
 
 And this is a really bad idea:
 
 @example
 import gpg
 
 k = gpg.Context().keylist(pattern="0xDEADBEEF")
 keys = list(k)
 @end example
 
 Alternatively it may be that the intention is to create a list of keys
 which all match a particular search string.  For instance all the
 addresses at a particular domain, like this:
 
 @example
 import gpg
 
 ncsc = gpg.Context().keylist(pattern="ncsc.mil")
 nsa = list(ncsc)
 @end example
 
 @menu
 * Counting keys::
 @end menu
 
 @node Counting keys
 @subsection Counting keys
 
 Counting the number of keys in your public keybox (@samp{pubring.kbx}), the
 format which has superseded the old keyring format (@samp{pubring.gpg} and
 @samp{secring.gpg}), or the number of secret keys is a very simple task.
 
 @example
 import gpg
 
 c = gpg.Context()
 seckeys = c.keylist(pattern=None, secret=True)
 pubkeys = c.keylist(pattern=None, secret=False)
 
 seclist = list(seckeys)
 secnum = len(seclist)
 
 publist = list(pubkeys)
 pubnum = len(publist)
 
 print("""
   Number of secret keys:  @{0@}
   Number of public keys:  @{1@}
 """.format(secnum, pubnum))
 @end example
 
 NOTE: The @ref{C plus Python plus SWIG plus Cython, , Cython} introduction in the @ref{Advanced or Experimental Use Cases, , Advanced and Experimental}
 section uses this same key counting code with Cython to demonstrate
 some areas where Cython can improve performance even with the
 bindings.  Users with large public keyrings or keyboxes, for instance,
 should consider these options if they are comfortable with using
 Cython.
 
 @node Get key
 @section Get key
 
 An alternative method of getting a single key via its fingerprint is
 available directly within a Context with @samp{Context().get_key}.  This is
 the preferred method of selecting a key in order to modify it, sign or
 certify it and for obtaining relevant data about a single key as a
 part of other functions; when verifying a signature made by that key,
 for instance.
 
 By default this method will select public keys, but it can select
 secret keys as well.
 
 This first example demonstrates selecting the current key of Werner
 Koch, which is due to expire at the end of 2018:
 
 @example
 import gpg
 
 fingerprint = "80615870F5BAD690333686D0F2AD85AC1E42B367"
 key = gpg.Context().get_key(fingerprint)
 @end example
 
 Whereas this example demonstrates selecting the author's current key
 with the @samp{secret} key word argument set to @samp{True}:
 
 @example
 import gpg
 
 fingerprint = "DB4724E6FA4286C92B4E55C4321E4E2373590E5D"
 key = gpg.Context().get_key(fingerprint, secret=True)
 @end example
 
 It is, of course, quite possible to select expired, disabled and
 revoked keys with this function, but only to effectively display
 information about those keys.
 
 It is also possible to use both unicode or string literals and byte
 literals with the fingerprint when getting a key in this way.
 
 @node Importing keys
 @section Importing keys
 
 Importing keys is possible with the @samp{key_import()} method and takes
 one argument which is a bytes literal object containing either the
 binary or ASCII armoured key data for one or more keys.
 
 The following example retrieves one or more keys from the SKS
 keyservers via the web using the requests module.  Since requests
 returns the content as a bytes literal object, we can then use that
 directly to import the resulting data into our keybox.
 
 @example
 import gpg
 import os.path
 import requests
 
 c = gpg.Context()
 url = "https://sks-keyservers.net/pks/lookup"
 pattern = input("Enter the pattern to search for key or user IDs: ")
 payload = @{"op": "get", "search": pattern@}
 
 r = requests.get(url, verify=True, params=payload)
 result = c.key_import(r.content)
 
 if result is not None and hasattr(result, "considered") is False:
     print(result)
 elif result is not None and hasattr(result, "considered") is True:
     num_keys = len(result.imports)
     new_revs = result.new_revocations
     new_sigs = result.new_signatures
     new_subs = result.new_sub_keys
     new_uids = result.new_user_ids
     new_scrt = result.secret_imported
     nochange = result.unchanged
     print("""
   The total number of keys considered for import was:  @{0@}
 
      Number of keys revoked:  @{1@}
    Number of new signatures:  @{2@}
       Number of new subkeys:  @{3@}
      Number of new user IDs:  @{4@}
   Number of new secret keys:  @{5@}
    Number of unchanged keys:  @{6@}
 
   The key IDs for all considered keys were:
 """.format(num_keys, new_revs, new_sigs, new_subs, new_uids, new_scrt,
            nochange))
     for i in range(num_keys):
         print("@{0@}\n".format(result.imports[i].fpr))
 else:
     pass
 @end example
 
 NOTE: When searching for a key ID of any length or a fingerprint
 (without spaces), the SKS servers require the the leading @samp{0x}
 indicative of hexadecimal be included.  Also note that the old short
 key IDs (e.g. @samp{0xDEADBEEF}) should no longer be used due to the
 relative ease by which such key IDs can be reproduced, as demonstrated
 by the Evil32 Project in 2014 (which was subsequently exploited in
 2016).
 
 @menu
 * Working with ProtonMail::
 * Importing with HKP for Python::
 * Importing from ProtonMail with HKP for Python::
 @end menu
 
 @node Working with ProtonMail
 @subsection Working with ProtonMail
 
 Here is a variation on the example above which checks the constrained
 ProtonMail keyserver for ProtonMail public keys.
 
 @example
 import gpg
 import requests
 import sys
 
 print("""
 This script searches the ProtonMail key server for the specified key and
 imports it.
 """)
 
 c = gpg.Context(armor=True)
 url = "https://api.protonmail.ch/pks/lookup"
 ksearch = []
 
 if len(sys.argv) >= 2:
     keyterm = sys.argv[1]
 else:
     keyterm = input("Enter the key ID, UID or search string: ")
 
 if keyterm.count("@@") == 2 and keyterm.startswith("@@") is True:
     ksearch.append(keyterm[1:])
     ksearch.append(keyterm[1:])
     ksearch.append(keyterm[1:])
 elif keyterm.count("@@") == 1 and keyterm.startswith("@@") is True:
     ksearch.append("@{0@}@@protonmail.com".format(keyterm[1:]))
     ksearch.append("@{0@}@@protonmail.ch".format(keyterm[1:]))
     ksearch.append("@{0@}@@pm.me".format(keyterm[1:]))
 elif keyterm.count("@@") == 0:
     ksearch.append("@{0@}@@protonmail.com".format(keyterm))
     ksearch.append("@{0@}@@protonmail.ch".format(keyterm))
     ksearch.append("@{0@}@@pm.me".format(keyterm))
 elif keyterm.count("@@") == 2 and keyterm.startswith("@@") is False:
     uidlist = keyterm.split("@@")
     for uid in uidlist:
         ksearch.append("@{0@}@@protonmail.com".format(uid))
         ksearch.append("@{0@}@@protonmail.ch".format(uid))
         ksearch.append("@{0@}@@pm.me".format(uid))
 elif keyterm.count("@@") > 2:
     uidlist = keyterm.split("@@")
     for uid in uidlist:
         ksearch.append("@{0@}@@protonmail.com".format(uid))
         ksearch.append("@{0@}@@protonmail.ch".format(uid))
         ksearch.append("@{0@}@@pm.me".format(uid))
 else:
     ksearch.append(keyterm)
 
 for k in ksearch:
     payload = @{"op": "get", "search": k@}
     try:
         r = requests.get(url, verify=True, params=payload)
         if r.ok is True:
             result = c.key_import(r.content)
         elif r.ok is False:
             result = r.content
     except Exception as e:
         result = None
 
     if result is not None and hasattr(result, "considered") is False:
         print("@{0@} for @{1@}".format(result.decode(), k))
     elif result is not None and hasattr(result, "considered") is True:
         num_keys = len(result.imports)
         new_revs = result.new_revocations
         new_sigs = result.new_signatures
         new_subs = result.new_sub_keys
         new_uids = result.new_user_ids
         new_scrt = result.secret_imported
         nochange = result.unchanged
         print("""
 The total number of keys considered for import was:  @{0@}
 
 With UIDs wholely or partially matching the following string:
 
         @{1@}
 
    Number of keys revoked:  @{2@}
  Number of new signatures:  @{3@}
     Number of new subkeys:  @{4@}
    Number of new user IDs:  @{5@}
 Number of new secret keys:  @{6@}
  Number of unchanged keys:  @{7@}
 
 The key IDs for all considered keys were:
 """.format(num_keys, k, new_revs, new_sigs, new_subs, new_uids, new_scrt,
            nochange))
         for i in range(num_keys):
             print(result.imports[i].fpr)
         print("")
     elif result is None:
         print(e)
 @end example
 
 Both the above example, @uref{../examples/howto/pmkey-import.py, pmkey-import.py}, and a version which prompts
 for an alternative GnuPG home directory, @uref{../examples/howto/pmkey-import-alt.py, pmkey-import-alt.py}, are
 available with the other examples and are executable scripts.
 
 Note that while the ProtonMail servers are based on the SKS servers,
 their server is related more to their API and is not feature complete
 by comparison to the servers in the SKS pool.  One notable difference
 being that the ProtonMail server does not permit non ProtonMail users
 to update their own keys, which could be a vector for attacking
 ProtonMail users who may not receive a key's revocation if it had been
 compromised.
 
 @node Importing with HKP for Python
 @subsection Importing with HKP for Python
 
 Performing the same tasks with the @uref{https://github.com/Selfnet/hkp4py, hkp4py module} (available via PyPI)
 is not too much different, but does provide a number of options of
 benefit to end users.  Not least of which being the ability to perform
 some checks on a key before importing it or not.  For instance it may
 be the policy of a site or project to only import keys which have not
 been revoked.  The hkp4py module permits such checks prior to the
 importing of the keys found.
 
 @example
 import gpg
 import hkp4py
 import sys
 
 c = gpg.Context()
 server = hkp4py.KeyServer("hkps://hkps.pool.sks-keyservers.net")
 results = []
 
 if len(sys.argv) > 2:
     pattern = " ".join(sys.argv[1:])
 elif len(sys.argv) == 2:
     pattern = sys.argv[1]
 else:
     pattern = input("Enter the pattern to search for keys or user IDs: ")
 
 try:
     keys = server.search(pattern)
     print("Found @{0@} key(s).".format(len(keys)))
 except Exception as e:
     keys = []
     for logrus in pattern.split():
         if logrus.startswith("0x") is True:
             key = server.search(logrus)
         else:
             key = server.search("0x@{0@}".format(logrus))
         keys.append(key[0])
     print("Found @{0@} key(s).".format(len(keys)))
 
 for key in keys:
     import_result = c.key_import(key.key_blob)
     results.append(import_result)
 
 for result in results:
     if result is not None and hasattr(result, "considered") is False:
         print(result)
     elif result is not None and hasattr(result, "considered") is True:
         num_keys = len(result.imports)
         new_revs = result.new_revocations
         new_sigs = result.new_signatures
         new_subs = result.new_sub_keys
         new_uids = result.new_user_ids
         new_scrt = result.secret_imported
         nochange = result.unchanged
         print("""
 The total number of keys considered for import was:  @{0@}
 
    Number of keys revoked:  @{1@}
  Number of new signatures:  @{2@}
     Number of new subkeys:  @{3@}
    Number of new user IDs:  @{4@}
 Number of new secret keys:  @{5@}
  Number of unchanged keys:  @{6@}
 
 The key IDs for all considered keys were:
 """.format(num_keys, new_revs, new_sigs, new_subs, new_uids, new_scrt,
            nochange))
         for i in range(num_keys):
             print(result.imports[i].fpr)
         print("")
     else:
         pass
 @end example
 
 Since the hkp4py module handles multiple keys just as effectively as
 one (@samp{keys} is a list of responses per matching key), the example
 above is able to do a little bit more with the returned data before
 anything is actually imported.
 
 @node Importing from ProtonMail with HKP for Python
 @subsection Importing from ProtonMail with HKP for Python
 
 Though this can provide certain benefits even when working with
 ProtonMail, the scope is somewhat constrained there due to the
 limitations of the ProtonMail keyserver.
 
 For instance, searching the SKS keyserver pool for the term "gnupg"
 produces hundreds of results from any time the word appears in any
 part of a user ID.  Performing the same search on the ProtonMail
 keyserver returns zero results, even though there are at least two
 test accounts which include it as part of the username.
 
 The cause of this discrepancy is the deliberate configuration of that
 server by ProtonMail to require an exact match of the full email
 address of the ProtonMail user whose key is being requested.
 Presumably this is intended to reduce breaches of privacy of their
 users as an email address must already be known before a key for that
 address can be obtained.
 
 @enumerate
 @item
 Import from ProtonMail via HKP for Python Example no. 1
 
 
-The following script is avalable with the rest of the examples under
+The following script is available with the rest of the examples under
 the somewhat less than original name, @samp{pmkey-import-hkp.py}.
 
 @example
 import gpg
 import hkp4py
 import os.path
 import sys
 
 print("""
 This script searches the ProtonMail key server for the specified key and
 imports it.
 
 Usage:  pmkey-import-hkp.py [search strings]
 """)
 
 c = gpg.Context(armor=True)
 server = hkp4py.KeyServer("hkps://api.protonmail.ch")
 keyterms = []
 ksearch = []
 allkeys = []
 results = []
 paradox = []
 homeless = None
 
 if len(sys.argv) > 2:
     keyterms = sys.argv[1:]
 elif len(sys.argv) == 2:
     keyterm = sys.argv[1]
     keyterms.append(keyterm)
 else:
     key_term = input("Enter the key ID, UID or search string: ")
     keyterms = key_term.split()
 
 for keyterm in keyterms:
     if keyterm.count("@@") == 2 and keyterm.startswith("@@") is True:
         ksearch.append(keyterm[1:])
         ksearch.append(keyterm[1:])
         ksearch.append(keyterm[1:])
     elif keyterm.count("@@") == 1 and keyterm.startswith("@@") is True:
         ksearch.append("@{0@}@@protonmail.com".format(keyterm[1:]))
         ksearch.append("@{0@}@@protonmail.ch".format(keyterm[1:]))
         ksearch.append("@{0@}@@pm.me".format(keyterm[1:]))
     elif keyterm.count("@@") == 0:
         ksearch.append("@{0@}@@protonmail.com".format(keyterm))
         ksearch.append("@{0@}@@protonmail.ch".format(keyterm))
         ksearch.append("@{0@}@@pm.me".format(keyterm))
     elif keyterm.count("@@") == 2 and keyterm.startswith("@@") is False:
         uidlist = keyterm.split("@@")
         for uid in uidlist:
             ksearch.append("@{0@}@@protonmail.com".format(uid))
             ksearch.append("@{0@}@@protonmail.ch".format(uid))
             ksearch.append("@{0@}@@pm.me".format(uid))
     elif keyterm.count("@@") > 2:
         uidlist = keyterm.split("@@")
         for uid in uidlist:
             ksearch.append("@{0@}@@protonmail.com".format(uid))
             ksearch.append("@{0@}@@protonmail.ch".format(uid))
             ksearch.append("@{0@}@@pm.me".format(uid))
     else:
         ksearch.append(keyterm)
 
 for k in ksearch:
     print("Checking for key for: @{0@}".format(k))
     try:
         keys = server.search(k)
         if isinstance(keys, list) is True:
             for key in keys:
                 allkeys.append(key)
                 try:
                     import_result = c.key_import(key.key_blob)
                 except Exception as e:
                     import_result = c.key_import(key.key)
         else:
             paradox.append(keys)
             import_result = None
     except Exception as e:
         import_result = None
     results.append(import_result)
 
 for result in results:
     if result is not None and hasattr(result, "considered") is False:
         print("@{0@} for @{1@}".format(result.decode(), k))
     elif result is not None and hasattr(result, "considered") is True:
         num_keys = len(result.imports)
         new_revs = result.new_revocations
         new_sigs = result.new_signatures
         new_subs = result.new_sub_keys
         new_uids = result.new_user_ids
         new_scrt = result.secret_imported
         nochange = result.unchanged
         print("""
 The total number of keys considered for import was:  @{0@}
 
 With UIDs wholely or partially matching the following string:
 
         @{1@}
 
    Number of keys revoked:  @{2@}
  Number of new signatures:  @{3@}
     Number of new subkeys:  @{4@}
    Number of new user IDs:  @{5@}
 Number of new secret keys:  @{6@}
  Number of unchanged keys:  @{7@}
 
 The key IDs for all considered keys were:
 """.format(num_keys, k, new_revs, new_sigs, new_subs, new_uids, new_scrt,
            nochange))
         for i in range(num_keys):
             print(result.imports[i].fpr)
         print("")
     elif result is None:
         pass
 @end example
 
 @item
 Import from ProtonMail via HKP for Python Example no. 2
 
 
 Like its counterpart above, this script can also be found with the
 rest of the examples, by the name pmkey-import-hkp-alt.py.
 
 With this script a modicum of effort has been made to treat anything
 passed as a @samp{homedir} which either does not exist or which is not a
 directory, as also being a pssible user ID to check for.  It's not
 guaranteed to pick up on all such cases, but it should cover most of
 them.
 
 @example
 import gpg
 import hkp4py
 import os.path
 import sys
 
 print("""
 This script searches the ProtonMail key server for the specified key and
 imports it.  Optionally enables specifying a different GnuPG home directory.
 
 Usage:  pmkey-import-hkp.py [homedir] [search string]
    or:  pmkey-import-hkp.py [search string]
 """)
 
 c = gpg.Context(armor=True)
 server = hkp4py.KeyServer("hkps://api.protonmail.ch")
 keyterms = []
 ksearch = []
 allkeys = []
 results = []
 paradox = []
 homeless = None
 
 if len(sys.argv) > 3:
     homedir = sys.argv[1]
     keyterms = sys.argv[2:]
 elif len(sys.argv) == 3:
     homedir = sys.argv[1]
     keyterm = sys.argv[2]
     keyterms.append(keyterm)
 elif len(sys.argv) == 2:
     homedir = ""
     keyterm = sys.argv[1]
     keyterms.append(keyterm)
 else:
     keyterm = input("Enter the key ID, UID or search string: ")
     homedir = input("Enter the GPG configuration directory path (optional): ")
     keyterms.append(keyterm)
 
 if len(homedir) == 0:
     homedir = None
     homeless = False
 
 if homedir is not None:
     if homedir.startswith("~"):
         if os.path.exists(os.path.expanduser(homedir)) is True:
             if os.path.isdir(os.path.expanduser(homedir)) is True:
                 c.home_dir = os.path.realpath(os.path.expanduser(homedir))
             else:
                 homeless = True
         else:
             homeless = True
     elif os.path.exists(os.path.realpath(homedir)) is True:
         if os.path.isdir(os.path.realpath(homedir)) is True:
             c.home_dir = os.path.realpath(homedir)
         else:
             homeless = True
     else:
         homeless = True
 
 # First check to see if the homedir really is a homedir and if not, treat it as
 # a search string.
 if homeless is True:
     keyterms.append(homedir)
     c.home_dir = None
 else:
     pass
 
 for keyterm in keyterms:
     if keyterm.count("@@") == 2 and keyterm.startswith("@@") is True:
         ksearch.append(keyterm[1:])
         ksearch.append(keyterm[1:])
         ksearch.append(keyterm[1:])
     elif keyterm.count("@@") == 1 and keyterm.startswith("@@") is True:
         ksearch.append("@{0@}@@protonmail.com".format(keyterm[1:]))
         ksearch.append("@{0@}@@protonmail.ch".format(keyterm[1:]))
         ksearch.append("@{0@}@@pm.me".format(keyterm[1:]))
     elif keyterm.count("@@") == 0:
         ksearch.append("@{0@}@@protonmail.com".format(keyterm))
         ksearch.append("@{0@}@@protonmail.ch".format(keyterm))
         ksearch.append("@{0@}@@pm.me".format(keyterm))
     elif keyterm.count("@@") == 2 and keyterm.startswith("@@") is False:
         uidlist = keyterm.split("@@")
         for uid in uidlist:
             ksearch.append("@{0@}@@protonmail.com".format(uid))
             ksearch.append("@{0@}@@protonmail.ch".format(uid))
             ksearch.append("@{0@}@@pm.me".format(uid))
     elif keyterm.count("@@") > 2:
         uidlist = keyterm.split("@@")
         for uid in uidlist:
             ksearch.append("@{0@}@@protonmail.com".format(uid))
             ksearch.append("@{0@}@@protonmail.ch".format(uid))
             ksearch.append("@{0@}@@pm.me".format(uid))
     else:
         ksearch.append(keyterm)
 
 for k in ksearch:
     print("Checking for key for: @{0@}".format(k))
     try:
         keys = server.search(k)
         if isinstance(keys, list) is True:
             for key in keys:
                 allkeys.append(key)
                 try:
                     import_result = c.key_import(key.key_blob)
                 except Exception as e:
                     import_result = c.key_import(key.key)
         else:
             paradox.append(keys)
             import_result = None
     except Exception as e:
         import_result = None
     results.append(import_result)
 
 for result in results:
     if result is not None and hasattr(result, "considered") is False:
         print("@{0@} for @{1@}".format(result.decode(), k))
     elif result is not None and hasattr(result, "considered") is True:
         num_keys = len(result.imports)
         new_revs = result.new_revocations
         new_sigs = result.new_signatures
         new_subs = result.new_sub_keys
         new_uids = result.new_user_ids
         new_scrt = result.secret_imported
         nochange = result.unchanged
         print("""
 The total number of keys considered for import was:  @{0@}
 
 With UIDs wholely or partially matching the following string:
 
         @{1@}
 
    Number of keys revoked:  @{2@}
  Number of new signatures:  @{3@}
     Number of new subkeys:  @{4@}
    Number of new user IDs:  @{5@}
 Number of new secret keys:  @{6@}
  Number of unchanged keys:  @{7@}
 
 The key IDs for all considered keys were:
 """.format(num_keys, k, new_revs, new_sigs, new_subs, new_uids, new_scrt,
            nochange))
         for i in range(num_keys):
             print(result.imports[i].fpr)
         print("")
     elif result is None:
         pass
 @end example
 @end enumerate
 
 @node Exporting keys
 @section Exporting keys
 
 Exporting keys remains a reasonably simple task, but has been
 separated into three different functions for the OpenPGP cryptographic
 engine.  Two of those functions are for exporting public keys and the
 third is for exporting secret keys.
 
 @menu
 * Exporting public keys::
 * Exporting secret keys::
 * Sending public keys to the SKS Keyservers::
 @end menu
 
 @node Exporting public keys
 @subsection Exporting public keys
 
 There are two methods of exporting public keys, both of which are very
 similar to the other.  The default method, @samp{key_export()}, will export
 a public key or keys matching a specified pattern as normal.  The
 alternative, the @samp{key_export_minimal()} method, will do the same thing
 except producing a minimised output with extra signatures and third
 party signatures or certifications removed.
 
 @example
 import gpg
 import os.path
 import sys
 
 print("""
 This script exports one or more public keys.
 """)
 
 c = gpg.Context(armor=True)
 
 if len(sys.argv) >= 4:
     keyfile = sys.argv[1]
     logrus = sys.argv[2]
     homedir = sys.argv[3]
 elif len(sys.argv) == 3:
     keyfile = sys.argv[1]
     logrus = sys.argv[2]
     homedir = input("Enter the GPG configuration directory path (optional): ")
 elif len(sys.argv) == 2:
     keyfile = sys.argv[1]
     logrus = input("Enter the UID matching the key(s) to export: ")
     homedir = input("Enter the GPG configuration directory path (optional): ")
 else:
     keyfile = input("Enter the path and filename to save the secret key to: ")
     logrus = input("Enter the UID matching the key(s) to export: ")
     homedir = input("Enter the GPG configuration directory path (optional): ")
 
 if homedir.startswith("~"):
     if os.path.exists(os.path.expanduser(homedir)) is True:
         c.home_dir = os.path.expanduser(homedir)
     else:
         pass
 elif os.path.exists(homedir) is True:
     c.home_dir = homedir
 else:
     pass
 
 try:
     result = c.key_export(pattern=logrus)
 except:
     result = c.key_export(pattern=None)
 
 if result is not None:
     with open(keyfile, "wb") as f:
         f.write(result)
 else:
     pass
 @end example
 
 It should be noted that the result will only return @samp{None} when a
 search pattern has been entered, but has not matched any keys.  When
 the search pattern itself is set to @samp{None} this triggers the exporting
 of the entire public keybox.
 
 @example
 import gpg
 import os.path
 import sys
 
 print("""
 This script exports one or more public keys in minimised form.
 """)
 
 c = gpg.Context(armor=True)
 
 if len(sys.argv) >= 4:
     keyfile = sys.argv[1]
     logrus = sys.argv[2]
     homedir = sys.argv[3]
 elif len(sys.argv) == 3:
     keyfile = sys.argv[1]
     logrus = sys.argv[2]
     homedir = input("Enter the GPG configuration directory path (optional): ")
 elif len(sys.argv) == 2:
     keyfile = sys.argv[1]
     logrus = input("Enter the UID matching the key(s) to export: ")
     homedir = input("Enter the GPG configuration directory path (optional): ")
 else:
     keyfile = input("Enter the path and filename to save the secret key to: ")
     logrus = input("Enter the UID matching the key(s) to export: ")
     homedir = input("Enter the GPG configuration directory path (optional): ")
 
 if homedir.startswith("~"):
     if os.path.exists(os.path.expanduser(homedir)) is True:
         c.home_dir = os.path.expanduser(homedir)
     else:
         pass
 elif os.path.exists(homedir) is True:
     c.home_dir = homedir
 else:
     pass
 
 try:
     result = c.key_export_minimal(pattern=logrus)
 except:
     result = c.key_export_minimal(pattern=None)
 
 if result is not None:
     with open(keyfile, "wb") as f:
         f.write(result)
 else:
     pass
 @end example
 
 @node Exporting secret keys
 @subsection Exporting secret keys
 
 Exporting secret keys is, functionally, very similar to exporting
 public keys; save for the invocation of @samp{pinentry} via @samp{gpg-agent} in
 order to securely enter the key's passphrase and authorise the export.
 
 The following example exports the secret key to a file which is then
 set with the same permissions as the output files created by the
 command line secret key export options.
 
 @example
 import gpg
 import os
 import os.path
 import sys
 
 print("""
 This script exports one or more secret keys.
 
 The gpg-agent and pinentry are invoked to authorise the export.
 """)
 
 c = gpg.Context(armor=True)
 
 if len(sys.argv) >= 4:
     keyfile = sys.argv[1]
     logrus = sys.argv[2]
     homedir = sys.argv[3]
 elif len(sys.argv) == 3:
     keyfile = sys.argv[1]
     logrus = sys.argv[2]
     homedir = input("Enter the GPG configuration directory path (optional): ")
 elif len(sys.argv) == 2:
     keyfile = sys.argv[1]
     logrus = input("Enter the UID matching the secret key(s) to export: ")
     homedir = input("Enter the GPG configuration directory path (optional): ")
 else:
     keyfile = input("Enter the path and filename to save the secret key to: ")
     logrus = input("Enter the UID matching the secret key(s) to export: ")
     homedir = input("Enter the GPG configuration directory path (optional): ")
 
 if len(homedir) == 0:
     homedir = None
 elif homedir.startswith("~"):
     userdir = os.path.expanduser(homedir)
     if os.path.exists(userdir) is True:
         homedir = os.path.realpath(userdir)
     else:
         homedir = None
 else:
     homedir = os.path.realpath(homedir)
 
 if os.path.exists(homedir) is False:
     homedir = None
 else:
     if os.path.isdir(homedir) is False:
         homedir = None
     else:
         pass
 
 if homedir is not None:
     c.home_dir = homedir
 else:
     pass
 
 try:
     result = c.key_export_secret(pattern=logrus)
 except:
     result = c.key_export_secret(pattern=None)
 
 if result is not None:
     with open(keyfile, "wb") as f:
         f.write(result)
     os.chmod(keyfile, 0o600)
 else:
     pass
 @end example
 
 Alternatively the approach of the following script can be used.  This
 longer example saves the exported secret key(s) in files in the GnuPG
 home directory, in addition to setting the file permissions as only
 readable and writable by the user.  It also exports the secret key(s)
 twice in order to output both GPG binary (@samp{.gpg}) and ASCII armoured
 (@samp{.asc}) files.
 
 @example
 import gpg
 import os
 import os.path
 import subprocess
 import sys
 
 print("""
 This script exports one or more secret keys as both ASCII armored and binary
 file formats, saved in files within the user's GPG home directory.
 
 The gpg-agent and pinentry are invoked to authorise the export.
 """)
 
 if sys.platform == "win32":
     gpgconfcmd = "gpgconf.exe --list-dirs homedir"
 else:
     gpgconfcmd = "gpgconf --list-dirs homedir"
 
 a = gpg.Context(armor=True)
 b = gpg.Context()
 c = gpg.Context()
 
 if len(sys.argv) >= 4:
     keyfile = sys.argv[1]
     logrus = sys.argv[2]
     homedir = sys.argv[3]
 elif len(sys.argv) == 3:
     keyfile = sys.argv[1]
     logrus = sys.argv[2]
     homedir = input("Enter the GPG configuration directory path (optional): ")
 elif len(sys.argv) == 2:
     keyfile = sys.argv[1]
     logrus = input("Enter the UID matching the secret key(s) to export: ")
     homedir = input("Enter the GPG configuration directory path (optional): ")
 else:
     keyfile = input("Enter the filename to save the secret key to: ")
     logrus = input("Enter the UID matching the secret key(s) to export: ")
     homedir = input("Enter the GPG configuration directory path (optional): ")
 
 if len(homedir) == 0:
     homedir = None
 elif homedir.startswith("~"):
     userdir = os.path.expanduser(homedir)
     if os.path.exists(userdir) is True:
         homedir = os.path.realpath(userdir)
     else:
         homedir = None
 else:
     homedir = os.path.realpath(homedir)
 
 if os.path.exists(homedir) is False:
     homedir = None
 else:
     if os.path.isdir(homedir) is False:
         homedir = None
     else:
         pass
 
 if homedir is not None:
     c.home_dir = homedir
 else:
     pass
 
 if c.home_dir is not None:
     if c.home_dir.endswith("/"):
         gpgfile = "@{0@}@{1@}.gpg".format(c.home_dir, keyfile)
         ascfile = "@{0@}@{1@}.asc".format(c.home_dir, keyfile)
     else:
         gpgfile = "@{0@}/@{1@}.gpg".format(c.home_dir, keyfile)
         ascfile = "@{0@}/@{1@}.asc".format(c.home_dir, keyfile)
 else:
     if os.path.exists(os.environ["GNUPGHOME"]) is True:
         hd = os.environ["GNUPGHOME"]
     else:
         try:
             hd = subprocess.getoutput(gpgconfcmd)
         except:
             process = subprocess.Popen(gpgconfcmd.split(),
                                        stdout=subprocess.PIPE)
             procom = process.communicate()
             if sys.version_info[0] == 2:
                 hd = procom[0].strip()
             else:
                 hd = procom[0].decode().strip()
     gpgfile = "@{0@}/@{1@}.gpg".format(hd, keyfile)
     ascfile = "@{0@}/@{1@}.asc".format(hd, keyfile)
 
 try:
     a_result = a.key_export_secret(pattern=logrus)
     b_result = b.key_export_secret(pattern=logrus)
 except:
     a_result = a.key_export_secret(pattern=None)
     b_result = b.key_export_secret(pattern=None)
 
 if a_result is not None:
     with open(ascfile, "wb") as f:
         f.write(a_result)
     os.chmod(ascfile, 0o600)
 else:
     pass
 
 if b_result is not None:
     with open(gpgfile, "wb") as f:
         f.write(b_result)
     os.chmod(gpgfile, 0o600)
 else:
     pass
 @end example
 
 @node Sending public keys to the SKS Keyservers
 @subsection Sending public keys to the SKS Keyservers
 
 As with the previous section on importing keys, the @samp{hkp4py} module
 adds another option with exporting keys in order to send them to the
 public keyservers.
 
 The following example demonstrates how this may be done.
 
 @example
 import gpg
 import hkp4py
 import os.path
 import sys
 
 print("""
 This script sends one or more public keys to the SKS keyservers and is
 essentially a slight variation on the export-key.py script.
 """)
 
 c = gpg.Context(armor=True)
 server = hkp4py.KeyServer("hkps://hkps.pool.sks-keyservers.net")
 
 if len(sys.argv) > 2:
     logrus = " ".join(sys.argv[1:])
 elif len(sys.argv) == 2:
     logrus = sys.argv[1]
 else:
     logrus = input("Enter the UID matching the key(s) to send: ")
 
 if len(logrus) > 0:
     try:
         export_result = c.key_export(pattern=logrus)
     except Exception as e:
         print(e)
         export_result = None
 else:
     export_result = c.key_export(pattern=None)
 
 if export_result is not None:
     try:
         try:
             send_result = server.add(export_result)
         except:
             send_result = server.add(export_result.decode())
         if send_result is not None:
             print(send_result)
         else:
             pass
     except Exception as e:
         print(e)
 else:
     pass
 @end example
 
 An expanded version of this script with additional functions for
 specifying an alternative homedir location is in the examples
 directory as @samp{send-key-to-keyserver.py}.
 
 The @samp{hkp4py} module appears to handle both string and byte literal text
 data equally well, but the GPGME bindings deal primarily with byte
 literal data only and so this script sends in that format first, then
 tries the string literal form.
 
 @node Basic Functions
 @chapter Basic Functions
 
 The most frequently called features of any cryptographic library will
 be the most fundamental tasks for encryption software.  In this
 section we will look at how to programmatically encrypt data, decrypt
 it, sign it and verify signatures.
 
 @menu
 * Encryption::
 * Decryption::
 * Signing text and files::
 * Signature verification::
 @end menu
 
 @node Encryption
 @section Encryption
 
 Encrypting is very straight forward.  In the first example below the
 message, @samp{text}, is encrypted to a single recipient's key.  In the
 second example the message will be encrypted to multiple recipients.
 
 @menu
 * Encrypting to one key::
 * Encrypting to multiple keys::
 @end menu
 
 @node Encrypting to one key
 @subsection Encrypting to one key
 
 Once the the Context is set the main issues with encrypting data is
 essentially reduced to key selection and the keyword arguments
 specified in the @samp{gpg.Context().encrypt()} method.
 
 Those keyword arguments are: @samp{recipients}, a list of keys encrypted to
 (covered in greater detail in the following section); @samp{sign}, whether
 or not to sign the plaintext data, see subsequent sections on signing
 and verifying signatures below (defaults to @samp{True}); @samp{sink}, to write
 results or partial results to a secure sink instead of returning it
 (defaults to @samp{None}); @samp{passphrase}, only used when utilising symmetric
 encryption (defaults to @samp{None}); @samp{always_trust}, used to override the
 trust model settings for recipient keys (defaults to @samp{False});
 @samp{add_encrypt_to}, utilises any preconfigured @samp{encrypt-to} or
 @samp{default-key} settings in the user's @samp{gpg.conf} file (defaults to
 @samp{False}); @samp{prepare}, prepare for encryption (defaults to @samp{False});
 @samp{expect_sign}, prepare for signing (defaults to @samp{False}); @samp{compress},
 compresses the plaintext prior to encryption (defaults to @samp{True}).
 
 @example
 import gpg
 
 a_key = "0x12345678DEADBEEF"
 text = b"""Some text to test with.
 
 Since the text in this case must be bytes, it is most likely that
 the input form will be a separate file which is opened with "rb"
 as this is the simplest method of obtaining the correct data format.
 """
 
 c = gpg.Context(armor=True)
 rkey = list(c.keylist(pattern=a_key, secret=False))
 ciphertext, result, sign_result = c.encrypt(text, recipients=rkey, sign=False)
 
 with open("secret_plans.txt.asc", "wb") as afile:
     afile.write(ciphertext)
 @end example
 
 Though this is even more likely to be used like this; with the
 plaintext input read from a file, the recipient keys used for
 encryption regardless of key trust status and the encrypted output
 also encrypted to any preconfigured keys set in the @samp{gpg.conf} file:
 
 @example
 import gpg
 
 a_key = "0x12345678DEADBEEF"
 
 with open("secret_plans.txt", "rb") as afile:
     text = afile.read()
 
 c = gpg.Context(armor=True)
 rkey = list(c.keylist(pattern=a_key, secret=False))
 ciphertext, result, sign_result = c.encrypt(text, recipients=rkey, sign=True,
                                             always_trust=True,
                                             add_encrypt_to=True)
 
 with open("secret_plans.txt.asc", "wb") as afile:
     afile.write(ciphertext)
 @end example
 
-If the @samp{recipients} paramater is empty then the plaintext is encrypted
+If the @samp{recipients} parameter is empty then the plaintext is encrypted
 symmetrically.  If no @samp{passphrase} is supplied as a parameter or via a
 callback registered with the @samp{Context()} then an out-of-band prompt
 for the passphrase via pinentry will be invoked.
 
 @node Encrypting to multiple keys
 @subsection Encrypting to multiple keys
 
 Encrypting to multiple keys essentially just expands upon the key
 selection process and the recipients from the previous examples.
 
 The following example encrypts a message (@samp{text}) to everyone with an
 email address on the @samp{gnupg.org} domain,@footnote{You probably don't really want to do this.  Searching the
 keyservers for "gnupg.org" produces over 400 results, the majority of
 which aren't actually at the gnupg.org domain, but just included a
 comment regarding the project in their key somewhere.} but does @emph{not} encrypt
 to a default key or other key which is configured to normally encrypt
 to.
 
 @example
 import gpg
 
 text = b"""Oh look, another test message.
 
 The same rules apply as with the previous example and more likely
 than not, the message will actually be drawn from reading the
 contents of a file or, maybe, from entering data at an input()
 prompt.
 
 Since the text in this case must be bytes, it is most likely that
 the input form will be a separate file which is opened with "rb"
 as this is the simplest method of obtaining the correct data
 format.
 """
 
 c = gpg.Context(armor=True)
 rpattern = list(c.keylist(pattern="@@gnupg.org", secret=False))
 logrus = []
 
 for i in range(len(rpattern)):
     if rpattern[i].can_encrypt == 1:
         logrus.append(rpattern[i])
 
 ciphertext, result, sign_result = c.encrypt(text, recipients=logrus,
                                             sign=False, always_trust=True)
 
 with open("secret_plans.txt.asc", "wb") as afile:
     afile.write(ciphertext)
 @end example
 
 All it would take to change the above example to sign the message
 and also encrypt the message to any configured default keys would
 be to change the @samp{c.encrypt} line to this:
 
 @example
 ciphertext, result, sign_result = c.encrypt(text, recipients=logrus,
                                             always_trust=True,
                                             add_encrypt_to=True)
 @end example
 
 The only keyword arguments requiring modification are those for which
 the default values are changing.  The default value of @samp{sign} is
 @samp{True}, the default of @samp{always_trust} is @samp{False}, the default of
 @samp{add_encrypt_to} is @samp{False}.
 
 If @samp{always_trust} is not set to @samp{True} and any of the recipient keys
 are not trusted (e.g. not signed or locally signed) then the
 encryption will raise an error.  It is possible to mitigate this
 somewhat with something more like this:
 
 @example
 import gpg
 
 with open("secret_plans.txt.asc", "rb") as afile:
     text = afile.read()
 
 c = gpg.Context(armor=True)
 rpattern = list(c.keylist(pattern="@@gnupg.org", secret=False))
 logrus = []
 
 for i in range(len(rpattern)):
     if rpattern[i].can_encrypt == 1:
         logrus.append(rpattern[i])
 
     try:
         ciphertext, result, sign_result = c.encrypt(text, recipients=logrus,
                                                     add_encrypt_to=True)
     except gpg.errors.InvalidRecipients as e:
         for i in range(len(e.recipients)):
             for n in range(len(logrus)):
                 if logrus[n].fpr == e.recipients[i].fpr:
                     logrus.remove(logrus[n])
                 else:
                     pass
         try:
             ciphertext, result, sign_result = c.encrypt(text,
                                                         recipients=logrus,
                                                         add_encrypt_to=True)
             with open("secret_plans.txt.asc", "wb") as afile:
                 afile.write(ciphertext)
         except:
             pass
 @end example
 
 This will attempt to encrypt to all the keys searched for, then remove
 invalid recipients if it fails and try again.
 
 @node Decryption
 @section Decryption
 
 Decrypting something encrypted to a key in one's secret keyring is
 fairly straight forward.
 
 In this example code, however, preconfiguring either @samp{gpg.Context()}
 or @samp{gpg.core.Context()} as @samp{c} is unnecessary because there is no need
 to modify the Context prior to conducting the decryption and since the
 Context is only used once, setting it to @samp{c} simply adds lines for no
 gain.
 
 @example
 import gpg
 
 ciphertext = input("Enter path and filename of encrypted file: ")
 newfile = input("Enter path and filename of file to save decrypted data to: ")
 
 with open(ciphertext, "rb") as cfile:
     try:
         plaintext, result, verify_result = gpg.Context().decrypt(cfile)
     except gpg.errors.GPGMEError as e:
         plaintext = None
         print(e)
 
 if plaintext is not None:
     with open(newfile, "wb") as nfile:
             nfile.write(plaintext)
     else:
         pass
 @end example
 
 The data available in @samp{plaintext} in this example is the decrypted
 content as a byte object, the recipient key IDs and algorithms in
 @samp{result} and the results of verifying any signatures of the data in
 @samp{verify_result}.
 
 @node Signing text and files
 @section Signing text and files
 
 The following sections demonstrate how to specify keys to sign with.
 
 @menu
 * Signing key selection::
 * Normal or default signing messages or files::
 * Detached signing messages and files::
 * Clearsigning messages or text::
 @end menu
 
 @node Signing key selection
 @subsection Signing key selection
 
 By default GPGME and the Python bindings will use the default key
 configured for the user invoking the GPGME API.  If there is no
 default key specified and there is more than one secret key available
 it may be necessary to specify the key or keys with which to sign
 messages and files.
 
 @example
 import gpg
 
 logrus = input("Enter the email address or string to match signing keys to: ")
 hancock = gpg.Context().keylist(pattern=logrus, secret=True)
 sig_src = list(hancock)
 @end example
 
 The signing examples in the following sections include the explicitly
 designated @samp{signers} parameter in two of the five examples; once where
 the resulting signature would be ASCII armoured and once where it
 would not be armoured.
 
 While it would be possible to enter a key ID or fingerprint here to
 match a specific key, it is not possible to enter two fingerprints and
 match two keys since the patten expects a string, bytes or None and
 not a list.  A string with two fingerprints won't match any single
 key.
 
 @node Normal or default signing messages or files
 @subsection Normal or default signing messages or files
 
 The normal or default signing process is essentially the same as is
 most often invoked when also encrypting a message or file.  So when
 the encryption component is not utilised, the result is to produce an
 encoded and signed output which may or may not be ASCII armoured and
 which may or may not also be compressed.
 
 By default compression will be used unless GnuPG detects that the
 plaintext is already compressed.  ASCII armouring will be determined
 according to the value of @samp{gpg.Context().armor}.
 
 The compression algorithm is selected in much the same way as the
 symmetric encryption algorithm or the hash digest algorithm is when
 multiple keys are involved; from the preferences saved into the key
 itself or by comparison with the preferences with all other keys
 involved.
 
 @example
 import gpg
 
 text0 = """Declaration of ... something.
 
 """
 text = text0.encode()
 
 c = gpg.Context(armor=True, signers=sig_src)
 signed_data, result = c.sign(text, mode=gpg.constants.sig.mode.NORMAL)
 
 with open("/path/to/statement.txt.asc", "w") as afile:
     afile.write(signed_data.decode())
 @end example
 
 Though everything in this example is accurate, it is more likely that
 reading the input data from another file and writing the result to a
 new file will be performed more like the way it is done in the next
 example.  Even if the output format is ASCII armoured.
 
 @example
 import gpg
 
 with open("/path/to/statement.txt", "rb") as tfile:
     text = tfile.read()
 
 c = gpg.Context()
 signed_data, result = c.sign(text, mode=gpg.constants.sig.mode.NORMAL)
 
 with open("/path/to/statement.txt.sig", "wb") as afile:
     afile.write(signed_data)
 @end example
 
 @node Detached signing messages and files
 @subsection Detached signing messages and files
 
 Detached signatures will often be needed in programmatic uses of
 GPGME, either for signing files (e.g. tarballs of code releases) or as
 a component of message signing (e.g. PGP/MIME encoded email).
 
 @example
 import gpg
 
 text0 = """Declaration of ... something.
 
 """
 text = text0.encode()
 
 c = gpg.Context(armor=True)
 signed_data, result = c.sign(text, mode=gpg.constants.sig.mode.DETACH)
 
 with open("/path/to/statement.txt.asc", "w") as afile:
     afile.write(signed_data.decode())
 @end example
 
 As with normal signatures, detached signatures are best handled as
 byte literals, even when the output is ASCII armoured.
 
 @example
 import gpg
 
 with open("/path/to/statement.txt", "rb") as tfile:
     text = tfile.read()
 
 c = gpg.Context(signers=sig_src)
 signed_data, result = c.sign(text, mode=gpg.constants.sig.mode.DETACH)
 
 with open("/path/to/statement.txt.sig", "wb") as afile:
     afile.write(signed_data)
 @end example
 
 @node Clearsigning messages or text
 @subsection Clearsigning messages or text
 
 Though PGP/in-line messages are no longer encouraged in favour of
 PGP/MIME, there is still sometimes value in utilising in-line
 signatures.  This is where clear-signed messages or text is of value.
 
 @example
 import gpg
 
 text0 = """Declaration of ... something.
 
 """
 text = text0.encode()
 
 c = gpg.Context()
 signed_data, result = c.sign(text, mode=gpg.constants.sig.mode.CLEAR)
 
 with open("/path/to/statement.txt.asc", "w") as afile:
     afile.write(signed_data.decode())
 @end example
 
 In spite of the appearance of a clear-signed message, the data handled
 by GPGME in signing it must still be byte literals.
 
 @example
 import gpg
 
 with open("/path/to/statement.txt", "rb") as tfile:
     text = tfile.read()
 
 c = gpg.Context()
 signed_data, result = c.sign(text, mode=gpg.constants.sig.mode.CLEAR)
 
 with open("/path/to/statement.txt.asc", "wb") as afile:
     afile.write(signed_data)
 @end example
 
 @node Signature verification
 @section Signature verification
 
 Essentially there are two principal methods of verification of a
 signature.  The first of these is for use with the normal or default
 signing method and for clear-signed messages.  The second is for use
 with files and data with detached signatures.
 
 The following example is intended for use with the default signing
 method where the file was not ASCII armoured:
 
 @example
 import gpg
 import time
 
 filename = "statement.txt"
 gpg_file = "statement.txt.gpg"
 
 c = gpg.Context()
 
 try:
     data, result = c.verify(open(gpg_file))
     verified = True
 except gpg.errors.BadSignatures as e:
     verified = False
     print(e)
 
 if verified is True:
     for i in range(len(result.signatures)):
         sign = result.signatures[i]
         print("""Good signature from:
 @{0@}
 with key @{1@}
 made at @{2@}
 """.format(c.get_key(sign.fpr).uids[0].uid, sign.fpr,
            time.ctime(sign.timestamp)))
 else:
     pass
 @end example
 
 Whereas this next example, which is almost identical would work with
 normal ASCII armoured files and with clear-signed files:
 
 @example
 import gpg
 import time
 
 filename = "statement.txt"
 asc_file = "statement.txt.asc"
 
 c = gpg.Context()
 
 try:
     data, result = c.verify(open(asc_file))
     verified = True
 except gpg.errors.BadSignatures as e:
     verified = False
     print(e)
 
 if verified is True:
     for i in range(len(result.signatures)):
         sign = result.signatures[i]
         print("""Good signature from:
 @{0@}
 with key @{1@}
 made at @{2@}
 """.format(c.get_key(sign.fpr).uids[0].uid, sign.fpr,
            time.ctime(sign.timestamp)))
 else:
     pass
 @end example
 
 In both of the previous examples it is also possible to compare the
 original data that was signed against the signed data in @samp{data} to see
 if it matches with something like this:
 
 @example
 with open(filename, "rb") as afile:
     text = afile.read()
 
 if text == data:
     print("Good signature.")
 else:
     pass
 @end example
 
 The following two examples, however, deal with detached signatures.
 With his method of verification the data that was signed does not get
 returned since it is already being explicitly referenced in the first
 argument of @samp{c.verify}.  So @samp{data} is @samp{None} and only the information
 in @samp{result} is available.
 
 @example
 import gpg
 import time
 
 filename = "statement.txt"
 sig_file = "statement.txt.sig"
 
 c = gpg.Context()
 
 try:
     data, result = c.verify(open(filename), open(sig_file))
     verified = True
 except gpg.errors.BadSignatures as e:
     verified = False
     print(e)
 
 if verified is True:
     for i in range(len(result.signatures)):
         sign = result.signatures[i]
         print("""Good signature from:
 @{0@}
 with key @{1@}
 made at @{2@}
 """.format(c.get_key(sign.fpr).uids[0].uid, sign.fpr,
            time.ctime(sign.timestamp)))
 else:
     pass
 @end example
 
 @example
 import gpg
 import time
 
 filename = "statement.txt"
 asc_file = "statement.txt.asc"
 
 c = gpg.Context()
 
 try:
     data, result = c.verify(open(filename), open(asc_file))
     verified = True
 except gpg.errors.BadSignatures as e:
     verified = False
     print(e)
 
 if verified is True:
     for i in range(len(result.signatures)):
         sign = result.signatures[i]
         print("""Good signature from:
 @{0@}
 with key @{1@}
 made at @{2@}
 """.format(c.get_key(sign.fpr).uids[0].uid, sign.fpr,
            time.ctime(sign.timestamp)))
 else:
     pass
 @end example
 
 @node Creating keys and subkeys
 @chapter Creating keys and subkeys
 
 The one thing, aside from GnuPG itself, that GPGME depends on, of
 course, is the keys themselves.  So it is necessary to be able to
 generate them and modify them by adding subkeys, revoking or disabling
 them, sometimes deleting them and doing the same for user IDs.
 
 In the following examples a key will be created for the world's
 greatest secret agent, Danger Mouse.  Since Danger Mouse is a secret
 agent he needs to be able to protect information to @samp{SECRET} level
 clearance, so his keys will be 3072-bit keys.
 
 The pre-configured @samp{gpg.conf} file which sets cipher, digest and other
 preferences contains the following configuration parameters:
 
 @example
 expert
 allow-freeform-uid
 allow-secret-key-import
 trust-model tofu+pgp
 tofu-default-policy unknown
 enable-large-rsa
 enable-dsa2
 cert-digest-algo SHA512
 default-preference-list TWOFISH CAMELLIA256 AES256 CAMELLIA192 AES192 CAMELLIA128 AES BLOWFISH IDEA CAST5 3DES SHA512 SHA384 SHA256 SHA224 RIPEMD160 SHA1 ZLIB BZIP2 ZIP Uncompressed
 personal-cipher-preferences TWOFISH CAMELLIA256 AES256 CAMELLIA192 AES192 CAMELLIA128 AES BLOWFISH IDEA CAST5 3DES
 personal-digest-preferences SHA512 SHA384 SHA256 SHA224 RIPEMD160 SHA1
 personal-compress-preferences ZLIB BZIP2 ZIP Uncompressed
 @end example
 
 @menu
 * Primary key::
 * Subkeys::
 * User IDs::
 * Key certification::
 @end menu
 
 @node Primary key
 @section Primary key
 
 Generating a primary key uses the @samp{create_key} method in a Context.
 It contains multiple arguments and keyword arguments, including:
 @samp{userid}, @samp{algorithm}, @samp{expires_in}, @samp{expires}, @samp{sign}, @samp{encrypt},
 @samp{certify}, @samp{authenticate}, @samp{passphrase} and @samp{force}.  The defaults for
 all of those except @samp{userid}, @samp{algorithm}, @samp{expires_in}, @samp{expires} and
 @samp{passphrase} is @samp{False}.  The defaults for @samp{algorithm} and
 @samp{passphrase} is @samp{None}.  The default for @samp{expires_in} is @samp{0}.  The
 default for @samp{expires} is @samp{True}.  There is no default for @samp{userid}.
 
 If @samp{passphrase} is left as @samp{None} then the key will not be generated
 with a passphrase, if @samp{passphrase} is set to a string then that will
 be the passphrase and if @samp{passphrase} is set to @samp{True} then gpg-agent
 will launch pinentry to prompt for a passphrase.  For the sake of
 convenience, these examples will keep @samp{passphrase} set to @samp{None}.
 
 @example
 import gpg
 
 c = gpg.Context()
 
 c.home_dir = "~/.gnupg-dm"
 userid = "Danger Mouse "
 
 dmkey = c.create_key(userid, algorithm="rsa3072", expires_in=31536000,
                      sign=True, certify=True)
 @end example
 
 One thing to note here is the use of setting the @samp{c.home_dir}
 parameter.  This enables generating the key or keys in a different
 location.  In this case to keep the new key data created for this
 example in a separate location rather than adding it to existing and
 active key store data.  As with the default directory, @samp{~/.gnupg}, any
 temporary or separate directory needs the permissions set to only
 permit access by the directory owner.  On posix systems this means
 setting the directory permissions to 700.
 
 The @samp{temp-homedir-config.py} script in the HOWTO examples directory
 will create an alternative homedir with these configuration options
 already set and the correct directory and file permissions.
 
 The successful generation of the key can be confirmed via the returned
 @samp{GenkeyResult} object, which includes the following data:
 
 @example
 print("""
  Fingerprint:  @{0@}
  Primary Key:  @{1@}
   Public Key:  @{2@}
   Secret Key:  @{3@}
  Sub Key:  @{4@}
 User IDs:  @{5@}
 """.format(dmkey.fpr, dmkey.primary, dmkey.pubkey, dmkey.seckey, dmkey.sub,
            dmkey.uid))
 @end example
 
 Alternatively the information can be confirmed using the command line
 program:
 
 @example
 bash-4.4$ gpg --homedir ~/.gnupg-dm -K
 ~/.gnupg-dm/pubring.kbx
 ----------------------
 sec   rsa3072 2018-03-15 [SC] [expires: 2019-03-15]
       177B7C25DB99745EE2EE13ED026D2F19E99E63AA
 uid           [ultimate] Danger Mouse 
 
 bash-4.4$
 @end example
 
 As with generating keys manually, to preconfigure expanded preferences
 for the cipher, digest and compression algorithms, the @samp{gpg.conf} file
 must contain those details in the home directory in which the new key
 is being generated.  I used a cut down version of my own @samp{gpg.conf}
 file in order to be able to generate this:
 
 @example
 bash-4.4$ gpg --homedir ~/.gnupg-dm --edit-key 177B7C25DB99745EE2EE13ED026D2F19E99E63AA showpref quit
 Secret key is available.
 
 sec  rsa3072/026D2F19E99E63AA
      created: 2018-03-15  expires: 2019-03-15  usage: SC
      trust: ultimate      validity: ultimate
 [ultimate] (1). Danger Mouse 
 
 [ultimate] (1). Danger Mouse 
      Cipher: TWOFISH, CAMELLIA256, AES256, CAMELLIA192, AES192, CAMELLIA128, AES, BLOWFISH, IDEA, CAST5, 3DES
      Digest: SHA512, SHA384, SHA256, SHA224, RIPEMD160, SHA1
      Compression: ZLIB, BZIP2, ZIP, Uncompressed
      Features: MDC, Keyserver no-modify
 
 bash-4.4$
 @end example
 
 @node Subkeys
 @section Subkeys
 
 Adding subkeys to a primary key is fairly similar to creating the
 primary key with the @samp{create_subkey} method.  Most of the arguments
 are the same, but not quite all.  Instead of the @samp{userid} argument
 there is now a @samp{key} argument for selecting which primary key to add
 the subkey to.
 
 In the following example an encryption subkey will be added to the
 primary key.  Since Danger Mouse is a security conscious secret agent,
 this subkey will only be valid for about six months, half the length
 of the primary key.
 
 @example
 import gpg
 
 c = gpg.Context()
 c.home_dir = "~/.gnupg-dm"
 
 key = c.get_key(dmkey.fpr, secret=True)
 dmsub = c.create_subkey(key, algorithm="rsa3072", expires_in=15768000,
                         encrypt=True)
 @end example
 
 As with the primary key, the results here can be checked with:
 
 @example
 print("""
  Fingerprint:  @{0@}
  Primary Key:  @{1@}
   Public Key:  @{2@}
   Secret Key:  @{3@}
  Sub Key:  @{4@}
 User IDs:  @{5@}
 """.format(dmsub.fpr, dmsub.primary, dmsub.pubkey, dmsub.seckey, dmsub.sub,
            dmsub.uid))
 @end example
 
 As well as on the command line with:
 
 @example
 bash-4.4$ gpg --homedir ~/.gnupg-dm -K
 ~/.gnupg-dm/pubring.kbx
 ----------------------
 sec   rsa3072 2018-03-15 [SC] [expires: 2019-03-15]
       177B7C25DB99745EE2EE13ED026D2F19E99E63AA
 uid           [ultimate] Danger Mouse 
 ssb   rsa3072 2018-03-15 [E] [expires: 2018-09-13]
 
 bash-4.4$
 @end example
 
 @node User IDs
 @section User IDs
 
 @menu
 * Adding User IDs::
 * Revoking User IDs::
 @end menu
 
 @node Adding User IDs
 @subsection Adding User IDs
 
 By comparison to creating primary keys and subkeys, adding a new user
 ID to an existing key is much simpler.  The method used to do this is
 @samp{key_add_uid} and the only arguments it takes are for the @samp{key} and
 the new @samp{uid}.
 
 @example
 import gpg
 
 c = gpg.Context()
 c.home_dir = "~/.gnupg-dm"
 
 dmfpr = "177B7C25DB99745EE2EE13ED026D2F19E99E63AA"
 key = c.get_key(dmfpr, secret=True)
 uid = "Danger Mouse "
 
 c.key_add_uid(key, uid)
 @end example
 
 Unsurprisingly the result of this is:
 
 @example
 bash-4.4$ gpg --homedir ~/.gnupg-dm -K
 ~/.gnupg-dm/pubring.kbx
 ----------------------
 sec   rsa3072 2018-03-15 [SC] [expires: 2019-03-15]
       177B7C25DB99745EE2EE13ED026D2F19E99E63AA
 uid           [ultimate] Danger Mouse 
 uid           [ultimate] Danger Mouse 
 ssb   rsa3072 2018-03-15 [E] [expires: 2018-09-13]
 
 bash-4.4$
 @end example
 
 @node Revoking User IDs
 @subsection Revoking User IDs
 
 Revoking a user ID is a fairly similar process, except that it uses
 the @samp{key_revoke_uid} method.
 
 @example
 import gpg
 
 c = gpg.Context()
 c.home_dir = "~/.gnupg-dm"
 
 dmfpr = "177B7C25DB99745EE2EE13ED026D2F19E99E63AA"
 key = c.get_key(dmfpr, secret=True)
 uid = "Danger Mouse "
 
 c.key_revoke_uid(key, uid)
 @end example
 
 @node Key certification
 @section Key certification
 
 Since key certification is more frequently referred to as key signing,
 the method used to perform this function is @samp{key_sign}.
 
 The @samp{key_sign} method takes four arguments: @samp{key}, @samp{uids},
 @samp{expires_in} and @samp{local}.  The default value of @samp{uids} is @samp{None} and
 which results in all user IDs being selected.  The default value of
 both @samp{expires_in} and @samp{local} is @samp{False}; which results in the
 signature never expiring and being able to be exported.
 
 The @samp{key} is the key being signed rather than the key doing the
 signing.  To change the key doing the signing refer to the signing key
 selection above for signing messages and files.
 
 If the @samp{uids} value is not @samp{None} then it must either be a string to
 match a single user ID or a list of strings to match multiple user
 IDs.  In this case the matching of those strings must be precise and
 it is case sensitive.
 
 To sign Danger Mouse's key for just the initial user ID with a
 signature which will last a little over a month, do this:
 
 @example
 import gpg
 
 c = gpg.Context()
 uid = "Danger Mouse "
 
 dmfpr = "177B7C25DB99745EE2EE13ED026D2F19E99E63AA"
 key = c.get_key(dmfpr, secret=True)
 c.key_sign(key, uids=uid, expires_in=2764800)
 @end example
 
 @node Advanced or Experimental Use Cases
 @chapter Advanced or Experimental Use Cases
 
 @menu
 * C plus Python plus SWIG plus Cython::
 @end menu
 
 @node C plus Python plus SWIG plus Cython
 @section C plus Python plus SWIG plus Cython
 
 In spite of the apparent incongruence of using Python bindings to a C
 interface only to generate more C from the Python; it is in fact quite
 possible to use the GPGME bindings with @uref{http://docs.cython.org/en/latest/index.html, Cython}.  Though in many cases
 the benefits may not be obvious since the most computationally
 intensive work never leaves the level of the C code with which GPGME
 itself is interacting with.
 
 Nevertheless, there are some situations where the benefits are
 demonstrable.  One of the better and easier examples being the one of
 the early examples in this HOWTO, the @ref{Counting keys, , key counting} code.  Running that
 example as an executable Python script, @samp{keycount.py} (available in
-the @samp{examples/howto/} directory), will take a noticable amount of time
+the @samp{examples/howto/} directory), will take a noticeable amount of time
 to run on most systems where the public keybox or keyring contains a
 few thousand public keys.
 
 Earlier in the evening, prior to starting this section, I ran that
 script on my laptop; as I tend to do periodically and timed it using
 @samp{time} utility, with the following results:
 
 @example
 bash-4.4$ time keycount.py
 
 Number of secret keys:  23
 Number of public keys:  12112
 
 
 real        11m52.945s
 user        0m0.913s
 sys        0m0.752s
 
 bash-4.4$
 @end example
 
 Sometime after that I imported another key and followed it with a
 little test of Cython.  This test was kept fairly basic, essentially
 lifting the material from the @uref{http://docs.cython.org/en/latest/src/tutorial/cython_tutorial.html, Cython Basic Tutorial} to demonstrate
 compiling Python code to C.  The first step was to take the example
 key counting code quoted previously, essentially from the importing of
 the @samp{gpg} module to the end of the script:
 
 @example
 import gpg
 
 c = gpg.Context()
 seckeys = c.keylist(pattern=None, secret=True)
 pubkeys = c.keylist(pattern=None, secret=False)
 
 seclist = list(seckeys)
 secnum = len(seclist)
 
 publist = list(pubkeys)
 pubnum = len(publist)
 
 print("""
     Number of secret keys:  @{0@}
     Number of public keys:  @{1@}
 
 """.format(secnum, pubnum))
 @end example
 
 Save that into a file called @samp{keycount.pyx} and then create a
 @samp{setup.py} file which contains this:
 
 @example
 from distutils.core import setup
 from Cython.Build import cythonize
 
 setup(
     ext_modules = cythonize("keycount.pyx")
 )
 @end example
 
 Compile it:
 
 @example
 bash-4.4$ python setup.py build_ext --inplace
 bash-4.4$
 @end example
 
 Then run it in a similar manner to @samp{keycount.py}:
 
 @example
 bash-4.4$ time python3.7 -c "import keycount"
 
 Number of secret keys:  23
 Number of public keys:  12113
 
 
 real        6m47.905s
 user        0m0.785s
 sys        0m0.331s
 
 bash-4.4$
 @end example
 
 Cython turned @samp{keycount.pyx} into an 81KB @samp{keycount.o} file in the
 @samp{build/} directory, a 24KB @samp{keycount.cpython-37m-darwin.so} file to be
 imported into Python 3.7 and a 113KB @samp{keycount.c} generated C source
 code file of nearly three thousand lines.  Quite a bit bigger than the
 314 bytes of the @samp{keycount.pyx} file or the full 1,452 bytes of the
 full executable @samp{keycount.py} example script.
 
 On the other hand it ran in nearly half the time; taking 6 minutes and
 47.905 seconds to run.  As opposed to the 11 minutes and 52.945 seconds
 which the CPython script alone took.
 
 The @samp{keycount.pyx} and @samp{setup.py} files used to generate this example
 have been added to the @samp{examples/howto/advanced/cython/} directory
 The example versions include some additional options to annotate the
 existing code and to detect Cython's use.  The latter comes from the
 @uref{http://docs.cython.org/en/latest/src/tutorial/pure.html#magic-attributes-within-the-pxd, Magic Attributes} section of the Cython documentation.
 
 @node Miscellaneous extras and work-arounds
 @chapter Miscellaneous extras and work-arounds
 
 Most of the things in the following sections are here simply because
 there was no better place to put them, even though some are only
 peripherally related to the GPGME Python bindings.  Some are also
 workarounds for functions not integrated with GPGME as yet.  This is
 especially true of the first of these, dealing with @ref{Group lines, , group lines}.
 
 @menu
 * Group lines::
 * Keyserver access for Python::
 @end menu
 
 @node Group lines
 @section Group lines
 
 There is not yet an easy way to access groups configured in the
 gpg.conf file from within GPGME.  As a consequence these central
 groupings of keys cannot be shared amongst multiple programs, such as
 MUAs readily.
 
 The following code, however, provides a work-around for obtaining this
 information in Python.
 
 @example
 import subprocess
 import sys
 
 if sys.platform == "win32":
     gpgconfcmd = "gpgconf.exe --list-options gpg"
 else:
     gpgconfcmd = "gpgconf --list-options gpg"
 
 try:
     lines = subprocess.getoutput(gpgconfcmd).splitlines()
 except:
     process = subprocess.Popen(gpgconfcmd.split(), stdout=subprocess.PIPE)
     procom = process.communicate()
     if sys.version_info[0] == 2:
         lines = procom[0].splitlines()
     else:
         lines = procom[0].decode().splitlines()
 
 for i in range(len(lines)):
     if lines[i].startswith("group") is True:
         line = lines[i]
     else:
         pass
 
 groups = line.split(":")[-1].replace('"', '').split(',')
 
 group_lines = []
 group_lists = []
 
 for i in range(len(groups)):
     group_lines.append(groups[i].split("="))
     group_lists.append(groups[i].split("="))
 
 for i in range(len(group_lists)):
     group_lists[i][1] = group_lists[i][1].split()
 @end example
 
 The result of that code is that @samp{group_lines} is a list of lists where
 @samp{group_lines[i][0]} is the name of the group and @samp{group_lines[i][1]}
 is the key IDs of the group as a string.
 
 The @samp{group_lists} result is very similar in that it is a list of
 lists.  The first part, @samp{group_lists[i][0]} matches
 @samp{group_lines[i][0]} as the name of the group, but @samp{group_lists[i][1]}
 is the key IDs of the group as a list.
 
 A demonstration of using the @samp{groups.py} module is also available in
 the form of the executable @samp{mutt-groups.py} script.  This second
 script reads all the group entries in a user's @samp{gpg.conf} file and
 converts them into crypt-hooks suitable for use with the Mutt and
 Neomutt mail clients.
 
 @node Keyserver access for Python
 @section Keyserver access for Python
 
 The @uref{https://github.com/Selfnet/hkp4py, hkp4py} module by Marcel Fest was originally a port of the old
 @uref{https://github.com/dgladkov/python-hkp, python-hkp} module from Python 2 to Python 3 and updated to use the
 @uref{http://docs.python-requests.org/en/latest/index.html, requests} module instead.  It has since been modified to provide
 support for Python 2.7 as well and is available via PyPI.
 
 Since it rewrites the @samp{hkp} protocol prefix as @samp{http} and @samp{hkps} as
 @samp{https}, the module is able to be used even with servers which do not
 support the full scope of keyserver functions.@footnote{Such as with ProtonMail servers.  This also means that
 restricted servers which only advertise either HTTP or HTTPS end
 points and not HKP or HKPS end points must still be identified as as
 HKP or HKPS within the Python Code.  The @samp{hkp4py} module will rewrite
 these appropriately when the connection is made to the server.}  It also works quite
 readily when incorporated into a @ref{C plus Python plus SWIG plus Cython, , Cython} generated and compiled version
 of any code.
 
 @menu
 * Key import format::
 @end menu
 
 @node Key import format
 @subsection Key import format
 
 The hkp4py module returns key data via requests as string literals
 (@samp{r.text}) instead of byte literals (@samp{r.content}).  This means that
 the retrurned key data must be encoded to UTF-8 when importing that
 key material using a @samp{gpg.Context().key_import()} method.
 
 For this reason an alternative method has been added to the @samp{search}
 function of @samp{hkp4py.KeyServer()} which returns the key in the correct
 format as expected by @samp{key_import}.  When importing using this module,
 it is now possible to import with this:
 
 @example
 for key in keys:
     if key.revoked is False:
         gpg.Context().key_import(key.key_blob)
     else:
         pass
 @end example
 
 Without that recent addition it would have been necessary to encode
 the contents of each @samp{hkp4py.KeyServer().search()[i].key} in
 @samp{hkp4py.KeyServer().search()} before trying to import it.
 
 An example of this is included in the @ref{Importing keys, , Importing Keys} section of this
 HOWTO and the corresponding executable version of that example is
 available in the @samp{lang/python/examples/howto} directory as normal; the
 executable version is the @samp{import-keys-hkp.py} file.
 
 @node Copyright and Licensing
 @chapter Copyright and Licensing
 
 @menu
 * Copyright::
 * Draft Editions of this HOWTO::
 * License GPL compatible::
 @end menu
 
 @node Copyright
 @section Copyright
 
 Copyright © The GnuPG Project, 2018.
 
 Copyright (C) The GnuPG Project, 2018.
 
 @node Draft Editions of this HOWTO
 @section Draft Editions of this HOWTO
 
 Draft editions of this HOWTO may be periodically available directly
 from the author at any of the following URLs:
 
 @itemize
 @item
 @uref{https://files.au.adversary.org/crypto/gpgme-python-howto.html, GPGME Python Bindings HOWTO draft (XHTML AWS S3 SSL)}
 @item
 @uref{http://files.au.adversary.org/crypto/gpgme-python-howto.html, GPGME Python Bindings HOWTO draft (XHTML AWS S3 no SSL)}
 @item
 @uref{https://files.au.adversary.org/crypto/gpgme-python-howto.texi, GPGME Python Bindings HOWTO draft (Texinfo file AWS S3 SSL)}
 @item
 @uref{http://files.au.adversary.org/crypto/gpgme-python-howto.texi, GPGME Python Bindings HOWTO draft (Texinfo file AWS S3 no SSL)}
 @item
 @uref{https://files.au.adversary.org/crypto/gpgme-python-howto.info, GPGME Python Bindings HOWTO draft (Info file AWS S3 SSL)}
 @item
 @uref{http://files.au.adversary.org/crypto/gpgme-python-howto.info, GPGME Python Bindings HOWTO draft (Info file AWS S3 no SSL)}
 @item
 @uref{https://files.au.adversary.org/crypto/gpgme-python-howto.rst, GPGME Python Bindings HOWTO draft (reST file AWS S3 SSL)}
 @item
 @uref{http://files.au.adversary.org/crypto/gpgme-python-howto.rst, GPGME Python Bindings HOWTO draft (reST file AWS S3 no SSL)}
 @item
 @uref{https://files.au.adversary.org/crypto/gpgme-python-howto.xml, GPGME Python Bindings HOWTO draft (Docbook 4.2 AWS S3 SSL)}
 @item
 @uref{http://files.au.adversary.org/crypto/gpgme-python-howto.xml, GPGME Python Bindings HOWTO draft (Docbook 4.2 AWS S3 no SSL)}
 @end itemize
 
 All of these draft versions except for one have been generated from
 this document via Emacs @uref{https://orgmode.org/, Org mode} and @uref{https://www.gnu.org/software/texinfo/, GNU Texinfo}.  Though it is likely
 that the specific @uref{https://files.au.adversary.org/crypto/gpgme-python-howto, file} @uref{http://files.au.adversary.org/crypto/gpgme-python-howto.org, version} used will be on the same server with
 the generated output formats.
 
 The one exception is the reStructuredText version, which was converted
 using the latest version of Pandoc from the Org mode source file using
 either of the following two commands:
 
 @example
 pandoc -f org -t rst -o gpgme-python-howto.rst gpgme-python-howto.org
 pandoc -f org -t rst -o gpgme-python-howto.rst gpgme-python-howto
 @end example
 
 In addition to these there is a significantly less frequently updated
 version as a HTML @uref{https://files.au.adversary.org/crypto/gpgme-python-howto/webhelp/index.html, WebHelp site} (AWS S3 SSL); generated from DITA XML
 source files, which can be found in @uref{https://dev.gnupg.org/source/gpgme/browse/ben%252Fhowto-dita/, an alternative branch} of the GPGME
 git repository.
 
 These draft editions are not official documents and the version of
 documentation in the master branch or which ships with released
 versions is the only official documentation.  Nevertheless, these
 draft editions may occasionally be of use by providing more accessible
 web versions which are updated between releases.  They are provided on
 the understanding that they may contain errors or may contain content
 subject to change prior to an official release.
 
 @node License GPL compatible
 @section License GPL compatible
 
 This file is free software; as a special exception the author gives
 unlimited permission to copy and/or distribute it, with or without
 modifications, as long as this notice is preserved.
 
 This file is distributed in the hope that it will be useful, but
 WITHOUT ANY WARRANTY, to the extent permitted by law; without even the
 implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
 PURPOSE.
 
-@bye
\ No newline at end of file
+@bye
diff --git a/lang/python/helpers.c b/lang/python/helpers.c
index 947819d2..d5d1fc99 100644
--- a/lang/python/helpers.c
+++ b/lang/python/helpers.c
@@ -1,1189 +1,1189 @@
 /*
 # Copyright (C) 2016 g10 Code GmbH
 # Copyright (C) 2004 Igor Belyi 
 # Copyright (C) 2002 John Goerzen 
 #
 #    This library is free software; you can redistribute it and/or
 #    modify it under the terms of the GNU Lesser General Public
 #    License as published by the Free Software Foundation; either
 #    version 2.1 of the License, or (at your option) any later version.
 #
 #    This library 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.
 #
 #    You should have received a copy of the GNU Lesser General Public
 #    License along with this library; if not, write to the Free Software
 #    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307  USA
 */
 
 #ifdef HAVE_CONFIG_H
 #include "config.h"
 #endif
 
 #include 
 #include 
 #include 
 #include 
 #include 
 #include "Python.h"
 
 #include "helpers.h"
 #include "private.h"
 
 /* Flag specifying whether this is an in-tree build.  */
 int gpg_in_tree_build =
 #if IN_TREE_BUILD
   1
 #else
   0
 #endif
   ;
 
 static PyObject *GPGMEError = NULL;
 
 void _gpg_exception_init(void) {
   if (GPGMEError == NULL) {
     PyObject *errors;
     PyObject *from_list = PyList_New(0);
     errors = PyImport_ImportModuleLevel("errors", PyEval_GetGlobals(),
                                         PyEval_GetLocals(), from_list, 1);
     Py_XDECREF(from_list);
     if (errors) {
       GPGMEError=PyDict_GetItemString(PyModule_GetDict(errors), "GPGMEError");
       Py_XINCREF(GPGMEError);
     }
   }
 }
 
 static PyObject *
 _gpg_raise_exception(gpgme_error_t err)
 {
   PyObject *e;
 
   _gpg_exception_init();
   if (GPGMEError == NULL)
     return PyErr_Format(PyExc_RuntimeError, "Got gpgme_error_t %d", err);
 
   e = PyObject_CallFunction(GPGMEError, "l", (long) err);
   if (e == NULL)
     return NULL;
 
   PyErr_SetObject(GPGMEError, e);
   Py_DECREF(e);
 
   return NULL;	/* raise */
 }
 
 gpgme_error_t _gpg_exception2code(void) {
   gpgme_error_t err_status = gpg_error(GPG_ERR_GENERAL);
   if (GPGMEError && PyErr_ExceptionMatches(GPGMEError)) {
     PyObject *type = 0, *value = 0, *traceback = 0;
     PyObject *error = 0;
     PyErr_Fetch(&type, &value, &traceback);
     PyErr_NormalizeException(&type, &value, &traceback);
     error = PyObject_GetAttrString(value, "error");
     err_status = PyLong_AsLong(error);
     Py_DECREF(error);
     PyErr_Restore(type, value, traceback);
   }
   return err_status;
 }
 
 /* Exception support for callbacks.  */
 #define EXCINFO	"_callback_excinfo"
 
 static void _gpg_stash_callback_exception(PyObject *weak_self)
 {
   PyObject *self, *ptype, *pvalue, *ptraceback, *excinfo;
 
   PyErr_Fetch(&ptype, &pvalue, &ptraceback);
   excinfo = PyTuple_New(3);
   PyTuple_SetItem(excinfo, 0, ptype);
 
   if (pvalue)
     PyTuple_SetItem(excinfo, 1, pvalue);
   else {
     Py_INCREF(Py_None);
     PyTuple_SetItem(excinfo, 1, Py_None);
   }
 
   if (ptraceback)
     PyTuple_SetItem(excinfo, 2, ptraceback);
   else {
     Py_INCREF(Py_None);
     PyTuple_SetItem(excinfo, 2, Py_None);
   }
 
   self = PyWeakref_GetObject(weak_self);
   /* self only has a borrowed reference.  */
   if (self == Py_None) {
     /* This should not happen, as even if we're called from the data
        release callback triggered from the wrappers destructor, the
        object is still alive and hence the weak reference still refers
        to the object.  However, in case this ever changes, not seeing
        any exceptions is worse than having a little extra code, so
        here we go.  */
       fprintf(stderr,
               "Error occurred in callback, but the wrapper object "
               "has been deallocated.\n");
       PyErr_Restore(ptype, pvalue, ptraceback);
       PyErr_Print();
     }
   else
     PyObject_SetAttrString(self, EXCINFO, excinfo);
   Py_DECREF(excinfo);
 }
 
 PyObject *gpg_raise_callback_exception(PyObject *self)
 {
   PyGILState_STATE state = PyGILState_Ensure();
   PyObject *ptype, *pvalue, *ptraceback, *excinfo;
 
   if (! PyObject_HasAttrString(self, EXCINFO))
     goto leave;
 
   excinfo = PyObject_GetAttrString(self, EXCINFO);
   if (! PyTuple_Check(excinfo))
     {
       Py_DECREF(excinfo);
       goto leave;
     }
 
   ptype = PyTuple_GetItem(excinfo, 0);
   Py_INCREF(excinfo);
 
   pvalue = PyTuple_GetItem(excinfo, 1);
   if (pvalue == Py_None)
     pvalue = NULL;
   else
     Py_INCREF(pvalue);
 
   ptraceback = PyTuple_GetItem(excinfo, 2);
   if (ptraceback == Py_None)
     ptraceback = NULL;
   else
     Py_INCREF(ptraceback);
 
   /* We now have references for the extracted items.  */
   Py_DECREF(excinfo);
 
   /* Clear the exception information.  It is important to do this
      before setting the error, because setting the attribute may
      execute python code, and the runtime system raises a SystemError
      if an exception is set but values are returned.  */
   Py_INCREF(Py_None);
   PyObject_SetAttrString(self, EXCINFO, Py_None);
 
   /* Restore exception.  */
   PyErr_Restore(ptype, pvalue, ptraceback);
   PyGILState_Release(state);
   return NULL; /* Raise exception.  */
 
  leave:
   Py_INCREF(Py_None);
   PyGILState_Release(state);
   return Py_None;
 }
 #undef EXCINFO
 
 /* Argument conversion.  */
 
 /* Convert object to a pointer to gpgme type, generic version.  */
 PyObject *
 _gpg_obj2gpgme_t(PyObject *input, const char *objtype, int argnum)
 {
   PyObject *pyname = NULL, *pypointer = NULL;
   pyname = PyObject_GetAttrString(input, "_ctype");
   if (pyname && PyUnicode_Check(pyname))
     {
       PyObject *encoded = PyUnicode_AsUTF8String(pyname);
       if (strcmp(PyBytes_AsString(encoded), objtype) != 0)
         {
           PyErr_Format(PyExc_TypeError,
                        "arg %d: Expected value of type %s, but got %s",
                        argnum, objtype, PyBytes_AsString(encoded));
           Py_DECREF(encoded);
           Py_DECREF(pyname);
           return NULL;
         }
       Py_DECREF(encoded);
     }
   else
     return NULL;
 
   Py_DECREF(pyname);
   pypointer = PyObject_GetAttrString(input, "wrapped");
   if (pypointer == NULL) {
     PyErr_Format(PyExc_TypeError,
 		 "arg %d: Use of uninitialized Python object %s",
 		 argnum, objtype);
     return NULL;
   }
   return pypointer;
 }
 
 /* Convert object to a pointer to gpgme type, version for data
    objects.  Constructs a wrapper Python on the fly e.g. for file-like
    objects with a fileno method, returning it in WRAPPER.  This object
    must be de-referenced when no longer needed.  */
 PyObject *
 _gpg_obj2gpgme_data_t(PyObject *input, int argnum, gpgme_data_t *wrapper,
                        PyObject **bytesio, Py_buffer *view)
 {
   gpgme_error_t err;
   PyObject *data;
   PyObject *fd;
 
   /* See if it is a file-like object with file number.  */
   fd = PyObject_CallMethod(input, "fileno", NULL);
   if (fd) {
     err = gpgme_data_new_from_fd(wrapper, (int) PyLong_AsLong(fd));
     Py_DECREF(fd);
     if (err)
       return _gpg_raise_exception (err);
 
     return _gpg_wrap_gpgme_data_t(*wrapper);
   }
   else
     PyErr_Clear();
 
   /* No?  Maybe it implements the buffer protocol.  */
   data = PyObject_CallMethod(input, "getbuffer", NULL);
   if (data)
     {
       /* Save a reference to input, which seems to be a BytesIO
          object.  */
       Py_INCREF(input);
       *bytesio = input;
     }
   else
     {
       PyErr_Clear();
 
       /* No, but maybe the user supplied a buffer object?  */
       data = input;
     }
 
   /* Do we have a buffer object?  */
   if (PyObject_CheckBuffer(data))
     {
       if (PyObject_GetBuffer(data, view, PyBUF_SIMPLE) < 0)
         return NULL;
 
       if (data != input)
         Py_DECREF(data);
 
       assert (view->obj);
       assert (view->ndim == 1);
       assert (view->shape == NULL);
       assert (view->strides == NULL);
       assert (view->suboffsets == NULL);
 
       err = gpgme_data_new_from_mem(wrapper, view->buf, (size_t) view->len, 0);
       if (err)
         return _gpg_raise_exception (err);
 
       return _gpg_wrap_gpgme_data_t(*wrapper);
     }
 
   /* As last resort we assume it is a wrapped data object.  */
   if (PyObject_HasAttrString(data, "_ctype"))
     return _gpg_obj2gpgme_t(data, "gpgme_data_t", argnum);
 
   return PyErr_Format(PyExc_TypeError,
                       "arg %d: expected gpg.Data, file, "
                       "bytes (not string!), or an object "
                       "implementing the buffer protocol. Got: %s. "
                       "If you provided a string, try to encode() it.",
                       argnum, data->ob_type->tp_name);
 }
 
 
 
 PyObject *
 _gpg_wrap_result(PyObject *fragile, const char *classname)
 {
   static PyObject *results;
   PyObject *class;
   PyObject *replacement;
 
   if (results == NULL)
     {
       PyObject *from_list = PyList_New(0);
       if (from_list == NULL)
         return NULL;
 
       results = PyImport_ImportModuleLevel("results", PyEval_GetGlobals(),
                                            PyEval_GetLocals(), from_list, 1);
       Py_DECREF(from_list);
 
       if (results == NULL)
         return NULL;
     }
 
   class = PyMapping_GetItemString(PyModule_GetDict(results), classname);
   if (class == NULL)
     return NULL;
 
   replacement = PyObject_CallFunctionObjArgs(class, fragile, NULL);
   Py_DECREF(class);
   return replacement;
 }
 
 
 
 /* Callback support.  */
 static gpgme_error_t pyPassphraseCb(void *hook,
 				    const char *uid_hint,
 				    const char *passphrase_info,
 				    int prev_was_bad,
 				    int fd) {
   PyGILState_STATE state = PyGILState_Ensure();
   PyObject *pyhook = (PyObject *) hook;
   PyObject *self = NULL;
   PyObject *func = NULL;
   PyObject *args = NULL;
   PyObject *retval = NULL;
   PyObject *dataarg = NULL;
   PyObject *encoded = NULL;
   gpgme_error_t err_status = 0;
 
   _gpg_exception_init();
 
   assert (PyTuple_Check(pyhook));
   assert (PyTuple_Size(pyhook) == 2 || PyTuple_Size(pyhook) == 3);
   self = PyTuple_GetItem(pyhook, 0);
   func = PyTuple_GetItem(pyhook, 1);
   if (PyTuple_Size(pyhook) == 3) {
     dataarg = PyTuple_GetItem(pyhook, 2);
     args = PyTuple_New(4);
   } else {
     args = PyTuple_New(3);
   }
 
   if (uid_hint == NULL)
     {
       Py_INCREF(Py_None);
       PyTuple_SetItem(args, 0, Py_None);
     }
   else
     PyTuple_SetItem(args, 0, PyUnicode_DecodeUTF8(uid_hint, strlen (uid_hint),
                                                   "strict"));
   if (PyErr_Occurred()) {
     Py_DECREF(args);
     err_status = gpg_error(GPG_ERR_GENERAL);
     goto leave;
   }
 
   if (passphrase_info == NULL)
     {
       Py_INCREF(Py_None);
       PyTuple_SetItem(args, 1, Py_None);
     }
   else
     PyTuple_SetItem(args, 1, PyUnicode_DecodeUTF8(passphrase_info,
                                                   strlen (passphrase_info),
                                                   "strict"));
   if (PyErr_Occurred()) {
     Py_DECREF(args);
     err_status = gpg_error(GPG_ERR_GENERAL);
     goto leave;
   }
 
   PyTuple_SetItem(args, 2, PyBool_FromLong((long)prev_was_bad));
   if (dataarg) {
     Py_INCREF(dataarg);		/* Because GetItem doesn't give a ref but SetItem taketh away */
     PyTuple_SetItem(args, 3, dataarg);
   }
 
   retval = PyObject_CallObject(func, args);
   Py_DECREF(args);
   if (PyErr_Occurred()) {
     err_status = _gpg_exception2code();
   } else {
     if (!retval) {
       if (write(fd, "\n", 1) < 0) {
         err_status = gpgme_error_from_syserror ();
         _gpg_raise_exception (err_status);
       }
     } else {
       char *buf;
       size_t len;
       if (PyBytes_Check(retval))
         buf = PyBytes_AsString(retval), len = PyBytes_Size(retval);
       else if (PyUnicode_Check(retval))
         {
           Py_ssize_t ssize;
           encoded = PyUnicode_AsUTF8String(retval);
           if (encoded == NULL)
             {
               err_status = gpg_error(GPG_ERR_GENERAL);
               goto leave;
             }
           if (PyBytes_AsStringAndSize(encoded, &buf, &ssize) == -1)
             {
               err_status = gpg_error(GPG_ERR_GENERAL);
               goto leave;
             }
           assert (! buf || ssize >= 0);
           len = (size_t) ssize;
         }
       else
         {
           PyErr_Format(PyExc_TypeError,
                        "expected str or bytes from passphrase callback, got %s",
                        retval->ob_type->tp_name);
           err_status = gpg_error(GPG_ERR_GENERAL);
           goto leave;
         }
 
       if (write(fd, buf, len) < 0) {
         err_status = gpgme_error_from_syserror ();
         _gpg_raise_exception (err_status);
       }
       if (! err_status && write(fd, "\n", 1) < 0) {
         err_status = gpgme_error_from_syserror ();
         _gpg_raise_exception (err_status);
       }
 
       Py_DECREF(retval);
     }
   }
 
  leave:
   if (err_status)
     _gpg_stash_callback_exception(self);
 
   Py_XDECREF(encoded);
   PyGILState_Release(state);
   return err_status;
 }
 
 PyObject *
 gpg_set_passphrase_cb(PyObject *self, PyObject *cb) {
   PyGILState_STATE state = PyGILState_Ensure();
   PyObject *wrapped;
   gpgme_ctx_t ctx;
 
   wrapped = PyObject_GetAttrString(self, "wrapped");
   if (wrapped == NULL)
     {
       assert (PyErr_Occurred ());
       PyGILState_Release(state);
       return NULL;
     }
 
   ctx = _gpg_unwrap_gpgme_ctx_t(wrapped);
   Py_DECREF(wrapped);
   if (ctx == NULL)
     {
       if (cb == Py_None)
         goto out;
       else
         return PyErr_Format(PyExc_RuntimeError, "wrapped is NULL");
     }
 
   if (cb == Py_None) {
     gpgme_set_passphrase_cb(ctx, NULL, NULL);
     PyObject_SetAttrString(self, "_passphrase_cb", Py_None);
     goto out;
   }
 
   if (! PyTuple_Check(cb))
     return PyErr_Format(PyExc_TypeError, "cb must be a tuple");
   if (PyTuple_Size(cb) != 2 && PyTuple_Size(cb) != 3)
     return PyErr_Format(PyExc_TypeError,
                         "cb must be a tuple of size 2 or 3");
 
   gpgme_set_passphrase_cb(ctx, (gpgme_passphrase_cb_t) pyPassphraseCb,
                           (void *) cb);
   PyObject_SetAttrString(self, "_passphrase_cb", cb);
 
  out:
   Py_INCREF(Py_None);
   PyGILState_Release(state);
   return Py_None;
 }
 
 static void pyProgressCb(void *hook, const char *what, int type, int current,
 			 int total) {
   PyGILState_STATE state = PyGILState_Ensure();
   PyObject *func = NULL, *dataarg = NULL, *args = NULL, *retval = NULL;
   PyObject *pyhook = (PyObject *) hook;
   PyObject *self = NULL;
 
   assert (PyTuple_Check(pyhook));
   assert (PyTuple_Size(pyhook) == 2 || PyTuple_Size(pyhook) == 3);
   self = PyTuple_GetItem(pyhook, 0);
   func = PyTuple_GetItem(pyhook, 1);
   if (PyTuple_Size(pyhook) == 3) {
     dataarg = PyTuple_GetItem(pyhook, 2);
     args = PyTuple_New(5);
   } else {
     args = PyTuple_New(4);
   }
 
   PyTuple_SetItem(args, 0, PyUnicode_DecodeUTF8(what, strlen (what),
                                                 "strict"));
   if (PyErr_Occurred()) {
     _gpg_stash_callback_exception(self);
     Py_DECREF(args);
     PyGILState_Release(state);
     return;
   }
   PyTuple_SetItem(args, 1, PyLong_FromLong((long) type));
   PyTuple_SetItem(args, 2, PyLong_FromLong((long) current));
   PyTuple_SetItem(args, 3, PyLong_FromLong((long) total));
   if (dataarg) {
     Py_INCREF(dataarg);		/* Because GetItem doesn't give a ref but SetItem taketh away */
     PyTuple_SetItem(args, 4, dataarg);
   }
 
   retval = PyObject_CallObject(func, args);
   if (PyErr_Occurred())
     _gpg_stash_callback_exception(self);
   Py_DECREF(args);
   Py_XDECREF(retval);
   PyGILState_Release(state);
 }
 
 PyObject *
 gpg_set_progress_cb(PyObject *self, PyObject *cb) {
   PyGILState_STATE state = PyGILState_Ensure();
   PyObject *wrapped;
   gpgme_ctx_t ctx;
 
   wrapped = PyObject_GetAttrString(self, "wrapped");
   if (wrapped == NULL)
     {
       assert (PyErr_Occurred ());
       PyGILState_Release(state);
       return NULL;
     }
 
   ctx = _gpg_unwrap_gpgme_ctx_t(wrapped);
   Py_DECREF(wrapped);
   if (ctx == NULL)
     {
       if (cb == Py_None)
         goto out;
       else
         return PyErr_Format(PyExc_RuntimeError, "wrapped is NULL");
     }
 
   if (cb == Py_None) {
     gpgme_set_progress_cb(ctx, NULL, NULL);
     PyObject_SetAttrString(self, "_progress_cb", Py_None);
     goto out;
   }
 
   if (! PyTuple_Check(cb))
     return PyErr_Format(PyExc_TypeError, "cb must be a tuple");
   if (PyTuple_Size(cb) != 2 && PyTuple_Size(cb) != 3)
     return PyErr_Format(PyExc_TypeError,
                         "cb must be a tuple of size 2 or 3");
 
   gpgme_set_progress_cb(ctx, (gpgme_progress_cb_t) pyProgressCb, (void *) cb);
   PyObject_SetAttrString(self, "_progress_cb", cb);
 
  out:
   Py_INCREF(Py_None);
   PyGILState_Release(state);
   return Py_None;
 }
 
 /* Status callbacks.  */
 static gpgme_error_t pyStatusCb(void *hook, const char *keyword,
                                 const char *args) {
   PyGILState_STATE state = PyGILState_Ensure();
   gpgme_error_t err = 0;
   PyObject *pyhook = (PyObject *) hook;
   PyObject *self = NULL;
   PyObject *func = NULL;
   PyObject *dataarg = NULL;
   PyObject *pyargs = NULL;
   PyObject *retval = NULL;
 
   assert (PyTuple_Check(pyhook));
   assert (PyTuple_Size(pyhook) == 2 || PyTuple_Size(pyhook) == 3);
   self = PyTuple_GetItem(pyhook, 0);
   func = PyTuple_GetItem(pyhook, 1);
   if (PyTuple_Size(pyhook) == 3) {
     dataarg = PyTuple_GetItem(pyhook, 2);
     pyargs = PyTuple_New(3);
   } else {
     pyargs = PyTuple_New(2);
   }
 
   if (keyword)
     PyTuple_SetItem(pyargs, 0, PyUnicode_DecodeUTF8(keyword, strlen (keyword),
                                                     "strict"));
   else
     {
       Py_INCREF(Py_None);
       PyTuple_SetItem(pyargs, 0, Py_None);
     }
   PyTuple_SetItem(pyargs, 1, PyUnicode_DecodeUTF8(args, strlen (args),
                                                 "strict"));
   if (PyErr_Occurred()) {
     err = gpg_error(GPG_ERR_GENERAL);
     Py_DECREF(pyargs);
     goto leave;
   }
 
   if (dataarg) {
     Py_INCREF(dataarg);
     PyTuple_SetItem(pyargs, 2, dataarg);
   }
 
   retval = PyObject_CallObject(func, pyargs);
   if (PyErr_Occurred())
     err = _gpg_exception2code();
   Py_DECREF(pyargs);
   Py_XDECREF(retval);
 
  leave:
   if (err)
     _gpg_stash_callback_exception(self);
   PyGILState_Release(state);
   return err;
 }
 
 PyObject *
 gpg_set_status_cb(PyObject *self, PyObject *cb) {
   PyGILState_STATE state = PyGILState_Ensure();
   PyObject *wrapped;
   gpgme_ctx_t ctx;
 
   wrapped = PyObject_GetAttrString(self, "wrapped");
   if (wrapped == NULL)
     {
       assert (PyErr_Occurred ());
       PyGILState_Release(state);
       return NULL;
     }
 
   ctx = _gpg_unwrap_gpgme_ctx_t(wrapped);
   Py_DECREF(wrapped);
   if (ctx == NULL)
     {
       if (cb == Py_None)
         goto out;
       else
         return PyErr_Format(PyExc_RuntimeError, "wrapped is NULL");
     }
 
   if (cb == Py_None) {
     gpgme_set_status_cb(ctx, NULL, NULL);
     PyObject_SetAttrString(self, "_status_cb", Py_None);
     goto out;
   }
 
   if (! PyTuple_Check(cb))
     return PyErr_Format(PyExc_TypeError, "cb must be a tuple");
   if (PyTuple_Size(cb) != 2 && PyTuple_Size(cb) != 3)
     return PyErr_Format(PyExc_TypeError,
                         "cb must be a tuple of size 2 or 3");
 
   gpgme_set_status_cb(ctx, (gpgme_status_cb_t) pyStatusCb, (void *) cb);
   PyObject_SetAttrString(self, "_status_cb", cb);
 
  out:
   Py_INCREF(Py_None);
   PyGILState_Release(state);
   return Py_None;
 }
 
 
 
 /* Interact callbacks.  */
 gpgme_error_t
 _gpg_interact_cb(void *opaque, const char *keyword,
                   const char *args, int fd)
 {
   PyGILState_STATE state = PyGILState_Ensure();
   PyObject *func = NULL, *dataarg = NULL, *pyargs = NULL, *retval = NULL;
   PyObject *py_keyword;
   PyObject *pyopaque = (PyObject *) opaque;
   gpgme_error_t err_status = 0;
   PyObject *self = NULL;
 
   _gpg_exception_init();
 
   assert (PyTuple_Check(pyopaque));
   assert (PyTuple_Size(pyopaque) == 2 || PyTuple_Size(pyopaque) == 3);
   self = PyTuple_GetItem(pyopaque, 0);
   func = PyTuple_GetItem(pyopaque, 1);
   if (PyTuple_Size(pyopaque) == 3) {
     dataarg = PyTuple_GetItem(pyopaque, 2);
     pyargs = PyTuple_New(3);
   } else {
     pyargs = PyTuple_New(2);
   }
 
   if (keyword)
     py_keyword = PyUnicode_FromString(keyword);
   else
     {
       Py_INCREF(Py_None);
       py_keyword = Py_None;
     }
 
   PyTuple_SetItem(pyargs, 0, py_keyword);
   PyTuple_SetItem(pyargs, 1, PyUnicode_FromString(args));
   if (dataarg) {
     Py_INCREF(dataarg);		/* Because GetItem doesn't give a ref but SetItem taketh away */
     PyTuple_SetItem(pyargs, 2, dataarg);
   }
 
   retval = PyObject_CallObject(func, pyargs);
   Py_DECREF(pyargs);
   if (PyErr_Occurred()) {
     err_status = _gpg_exception2code();
   } else {
     if (fd>=0 && retval && PyUnicode_Check(retval)) {
       PyObject *encoded = NULL;
       char *buffer;
       Py_ssize_t size;
 
       encoded = PyUnicode_AsUTF8String(retval);
       if (encoded == NULL)
         {
           err_status = gpg_error(GPG_ERR_GENERAL);
           goto leave;
         }
       if (PyBytes_AsStringAndSize(encoded, &buffer, &size) == -1)
         {
           Py_DECREF(encoded);
           err_status = gpg_error(GPG_ERR_GENERAL);
           goto leave;
         }
 
       if (write(fd, buffer, size) < 0) {
         err_status = gpgme_error_from_syserror ();
         _gpg_raise_exception (err_status);
       }
       if (! err_status && write(fd, "\n", 1) < 0) {
         err_status = gpgme_error_from_syserror ();
         _gpg_raise_exception (err_status);
       }
       Py_DECREF(encoded);
     }
   }
  leave:
   if (err_status)
     _gpg_stash_callback_exception(self);
 
   Py_XDECREF(retval);
   PyGILState_Release(state);
   return err_status;
 }
 
 
 
 /* Data callbacks.  */
 
 /* Read up to SIZE bytes into buffer BUFFER from the data object with
    the handle HOOK.  Return the number of characters read, 0 on EOF
    and -1 on error.  If an error occurs, errno is set.  */
 static ssize_t pyDataReadCb(void *hook, void *buffer, size_t size)
 {
   PyGILState_STATE state = PyGILState_Ensure();
   ssize_t result;
   PyObject *pyhook = (PyObject *) hook;
   PyObject *self = NULL;
   PyObject *func = NULL;
   PyObject *dataarg = NULL;
   PyObject *pyargs = NULL;
   PyObject *retval = NULL;
 
   assert (PyTuple_Check(pyhook));
   assert (PyTuple_Size(pyhook) == 5 || PyTuple_Size(pyhook) == 6);
 
   self = PyTuple_GetItem(pyhook, 0);
   func = PyTuple_GetItem(pyhook, 1);
   if (PyTuple_Size(pyhook) == 6) {
     dataarg = PyTuple_GetItem(pyhook, 5);
     pyargs = PyTuple_New(2);
   } else {
     pyargs = PyTuple_New(1);
   }
 
   PyTuple_SetItem(pyargs, 0, PyLong_FromSize_t(size));
   if (dataarg) {
     Py_INCREF(dataarg);
     PyTuple_SetItem(pyargs, 1, dataarg);
   }
 
   retval = PyObject_CallObject(func, pyargs);
   Py_DECREF(pyargs);
   if (PyErr_Occurred()) {
     _gpg_stash_callback_exception(self);
     result = -1;
     goto leave;
   }
 
   if (! PyBytes_Check(retval)) {
     PyErr_Format(PyExc_TypeError,
                  "expected bytes from read callback, got %s",
                  retval->ob_type->tp_name);
     _gpg_stash_callback_exception(self);
     result = -1;
     goto leave;
   }
 
   if (PyBytes_Size(retval) > size) {
     PyErr_Format(PyExc_TypeError,
                  "expected %zu bytes from read callback, got %zu",
                  size, PyBytes_Size(retval));
     _gpg_stash_callback_exception(self);
     result = -1;
     goto leave;
   }
 
   memcpy(buffer, PyBytes_AsString(retval), PyBytes_Size(retval));
   result = PyBytes_Size(retval);
 
  leave:
   Py_XDECREF(retval);
   PyGILState_Release(state);
   return result;
 }
 
 /* Write up to SIZE bytes from buffer BUFFER to the data object with
    the handle HOOK.  Return the number of characters written, or -1
    on error.  If an error occurs, errno is set.  */
 static ssize_t pyDataWriteCb(void *hook, const void *buffer, size_t size)
 {
   PyGILState_STATE state = PyGILState_Ensure();
   ssize_t result;
   PyObject *pyhook = (PyObject *) hook;
   PyObject *self = NULL;
   PyObject *func = NULL;
   PyObject *dataarg = NULL;
   PyObject *pyargs = NULL;
   PyObject *retval = NULL;
 
   assert (PyTuple_Check(pyhook));
   assert (PyTuple_Size(pyhook) == 5 || PyTuple_Size(pyhook) == 6);
 
   self = PyTuple_GetItem(pyhook, 0);
   func = PyTuple_GetItem(pyhook, 2);
   if (PyTuple_Size(pyhook) == 6) {
     dataarg = PyTuple_GetItem(pyhook, 5);
     pyargs = PyTuple_New(2);
   } else {
     pyargs = PyTuple_New(1);
   }
 
   PyTuple_SetItem(pyargs, 0, PyBytes_FromStringAndSize(buffer, size));
   if (dataarg) {
     Py_INCREF(dataarg);
     PyTuple_SetItem(pyargs, 1, dataarg);
   }
 
   retval = PyObject_CallObject(func, pyargs);
   Py_DECREF(pyargs);
   if (PyErr_Occurred()) {
     _gpg_stash_callback_exception(self);
     result = -1;
     goto leave;
   }
 
 #if PY_MAJOR_VERSION < 3
   if (PyInt_Check(retval))
     result = PyInt_AsSsize_t(retval);
   else
 #endif
   if (PyLong_Check(retval))
     result = PyLong_AsSsize_t(retval);
   else {
     PyErr_Format(PyExc_TypeError,
                  "expected int from write callback, got %s",
                  retval->ob_type->tp_name);
     _gpg_stash_callback_exception(self);
     result = -1;
   }
 
  leave:
   Py_XDECREF(retval);
   PyGILState_Release(state);
   return result;
 }
 
 /* Set the current position from where the next read or write starts
-   in the data object with the handle HOOK to OFFSET, relativ to
+   in the data object with the handle HOOK to OFFSET, relative to
    WHENCE.  Returns the new offset in bytes from the beginning of the
    data object.  */
 static off_t pyDataSeekCb(void *hook, off_t offset, int whence)
 {
   PyGILState_STATE state = PyGILState_Ensure();
   off_t result;
   PyObject *pyhook = (PyObject *) hook;
   PyObject *self = NULL;
   PyObject *func = NULL;
   PyObject *dataarg = NULL;
   PyObject *pyargs = NULL;
   PyObject *retval = NULL;
 
   assert (PyTuple_Check(pyhook));
   assert (PyTuple_Size(pyhook) == 5 || PyTuple_Size(pyhook) == 6);
 
   self = PyTuple_GetItem(pyhook, 0);
   func = PyTuple_GetItem(pyhook, 3);
   if (PyTuple_Size(pyhook) == 6) {
     dataarg = PyTuple_GetItem(pyhook, 5);
     pyargs = PyTuple_New(3);
   } else {
     pyargs = PyTuple_New(2);
   }
 
 #if defined(_FILE_OFFSET_BITS) && _FILE_OFFSET_BITS == 64
   PyTuple_SetItem(pyargs, 0, PyLong_FromLongLong((long long) offset));
 #else
   PyTuple_SetItem(pyargs, 0, PyLong_FromLong((long) offset));
 #endif
   PyTuple_SetItem(pyargs, 1, PyLong_FromLong((long) whence));
   if (dataarg) {
     Py_INCREF(dataarg);
     PyTuple_SetItem(pyargs, 2, dataarg);
   }
 
   retval = PyObject_CallObject(func, pyargs);
   Py_DECREF(pyargs);
   if (PyErr_Occurred()) {
     _gpg_stash_callback_exception(self);
     result = -1;
     goto leave;
   }
 
 #if PY_MAJOR_VERSION < 3
   if (PyInt_Check(retval))
     result = PyInt_AsLong(retval);
   else
 #endif
   if (PyLong_Check(retval))
 #if defined(_FILE_OFFSET_BITS) && _FILE_OFFSET_BITS == 64
     result = PyLong_AsLongLong(retval);
 #else
     result = PyLong_AsLong(retval);
 #endif
   else {
     PyErr_Format(PyExc_TypeError,
                  "expected int from seek callback, got %s",
                  retval->ob_type->tp_name);
     _gpg_stash_callback_exception(self);
     result = -1;
   }
 
  leave:
   Py_XDECREF(retval);
   PyGILState_Release(state);
   return result;
 }
 
 /* Close the data object with the handle HOOK.  */
 static void pyDataReleaseCb(void *hook)
 {
   PyGILState_STATE state = PyGILState_Ensure();
   PyObject *pyhook = (PyObject *) hook;
   PyObject *self = NULL;
   PyObject *func = NULL;
   PyObject *dataarg = NULL;
   PyObject *pyargs = NULL;
   PyObject *retval = NULL;
 
   assert (PyTuple_Check(pyhook));
   assert (PyTuple_Size(pyhook) == 5 || PyTuple_Size(pyhook) == 6);
 
   self = PyTuple_GetItem(pyhook, 0);
   func = PyTuple_GetItem(pyhook, 4);
   if (PyTuple_Size(pyhook) == 6) {
     dataarg = PyTuple_GetItem(pyhook, 5);
     pyargs = PyTuple_New(1);
   } else {
     pyargs = PyTuple_New(0);
   }
 
   if (dataarg) {
     Py_INCREF(dataarg);
     PyTuple_SetItem(pyargs, 0, dataarg);
   }
 
   retval = PyObject_CallObject(func, pyargs);
   Py_XDECREF(retval);
   Py_DECREF(pyargs);
   if (PyErr_Occurred())
     _gpg_stash_callback_exception(self);
   PyGILState_Release(state);
 }
 
 PyObject *
 gpg_data_new_from_cbs(PyObject *self,
                        PyObject *pycbs,
                        gpgme_data_t *r_data)
 {
   PyGILState_STATE state = PyGILState_Ensure();
   static struct gpgme_data_cbs cbs = {
     pyDataReadCb,
     pyDataWriteCb,
     pyDataSeekCb,
     pyDataReleaseCb,
   };
   gpgme_error_t err;
 
   if (! PyTuple_Check(pycbs))
     return PyErr_Format(PyExc_TypeError, "pycbs must be a tuple");
   if (PyTuple_Size(pycbs) != 5 && PyTuple_Size(pycbs) != 6)
     return PyErr_Format(PyExc_TypeError,
                         "pycbs must be a tuple of size 5 or 6");
 
   err = gpgme_data_new_from_cbs(r_data, &cbs, (void *) pycbs);
   if (err)
     return _gpg_raise_exception(err);
 
   PyObject_SetAttrString(self, "_data_cbs", pycbs);
 
   Py_INCREF(Py_None);
   PyGILState_Release(state);
   return Py_None;
 }
 
 
 
 /* The assuan callbacks.  */
 
 gpgme_error_t
 _gpg_assuan_data_cb (void *hook, const void *data, size_t datalen)
 {
   PyGILState_STATE state = PyGILState_Ensure();
   gpgme_error_t err = 0;
   PyObject *pyhook = (PyObject *) hook;
   PyObject *self = NULL;
   PyObject *func = NULL;
   PyObject *py_data = NULL;
   PyObject *retval = NULL;
 
   assert (PyTuple_Check(pyhook));
   assert (PyTuple_Size(pyhook) == 2);
   self = PyTuple_GetItem(pyhook, 0);
   func = PyTuple_GetItem(pyhook, 1);
   assert (PyCallable_Check(func));
 
   py_data = PyBytes_FromStringAndSize(data, datalen);
   if (py_data == NULL)
     {
       err = _gpg_exception2code();
       goto leave;
     }
 
   retval = PyObject_CallFunctionObjArgs(func, py_data, NULL);
   if (PyErr_Occurred())
     err = _gpg_exception2code();
   Py_DECREF(py_data);
   Py_XDECREF(retval);
 
  leave:
   if (err)
     _gpg_stash_callback_exception(self);
   PyGILState_Release(state);
   return err;
 }
 
 gpgme_error_t
 _gpg_assuan_inquire_cb (void *hook, const char *name, const char *args,
                          gpgme_data_t *r_data)
 {
   PyGILState_STATE state = PyGILState_Ensure();
   gpgme_error_t err = 0;
   PyObject *pyhook = (PyObject *) hook;
   PyObject *self = NULL;
   PyObject *func = NULL;
   PyObject *py_name = NULL;
   PyObject *py_args = NULL;
   PyObject *retval = NULL;
 
   assert (PyTuple_Check(pyhook));
   assert (PyTuple_Size(pyhook) == 2);
   self = PyTuple_GetItem(pyhook, 0);
   func = PyTuple_GetItem(pyhook, 1);
   assert (PyCallable_Check(func));
 
   py_name = PyUnicode_FromString(name);
   if (py_name == NULL)
     {
       err = _gpg_exception2code();
       goto leave;
     }
 
   py_args = PyUnicode_FromString(args);
   if (py_args == NULL)
     {
       err = _gpg_exception2code();
       goto leave;
     }
 
   retval = PyObject_CallFunctionObjArgs(func, py_name, py_args, NULL);
   if (PyErr_Occurred())
     err = _gpg_exception2code();
   Py_XDECREF(retval);
 
   /* FIXME: Returning data is not yet implemented.  */
   *r_data = NULL;
 
  leave:
   Py_XDECREF(py_name);
   Py_XDECREF(py_args);
   if (err)
     _gpg_stash_callback_exception(self);
   PyGILState_Release(state);
   return err;
 }
 
 gpgme_error_t
 _gpg_assuan_status_cb (void *hook, const char *status, const char *args)
 {
   PyGILState_STATE state = PyGILState_Ensure();
   gpgme_error_t err = 0;
   PyObject *pyhook = (PyObject *) hook;
   PyObject *self = NULL;
   PyObject *func = NULL;
   PyObject *py_status = NULL;
   PyObject *py_args = NULL;
   PyObject *retval = NULL;
 
   assert (PyTuple_Check(pyhook));
   assert (PyTuple_Size(pyhook) == 2);
   self = PyTuple_GetItem(pyhook, 0);
   func = PyTuple_GetItem(pyhook, 1);
   assert (PyCallable_Check(func));
 
   py_status = PyUnicode_FromString(status);
   if (py_status == NULL)
     {
       err = _gpg_exception2code();
       goto leave;
     }
 
   py_args = PyUnicode_FromString(args);
   if (py_args == NULL)
     {
       err = _gpg_exception2code();
       goto leave;
     }
 
   retval = PyObject_CallFunctionObjArgs(func, py_status, py_args, NULL);
   if (PyErr_Occurred())
     err = _gpg_exception2code();
   Py_XDECREF(retval);
 
  leave:
   Py_XDECREF(py_status);
   Py_XDECREF(py_args);
   if (err)
     _gpg_stash_callback_exception(self);
   PyGILState_Release(state);
   return err;
 }
diff --git a/lang/python/tests/t-quick-key-manipulation.py b/lang/python/tests/t-quick-key-manipulation.py
index 0cfaa9d1..73dce16d 100755
--- a/lang/python/tests/t-quick-key-manipulation.py
+++ b/lang/python/tests/t-quick-key-manipulation.py
@@ -1,133 +1,133 @@
 #!/usr/bin/env python
 
 # Copyright (C) 2017 g10 Code 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 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 Lesser 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 .
 
 from __future__ import absolute_import, print_function, unicode_literals
 
 import os
 import gpg
 import sys
 
 import support
 support.assert_gpg_version((2, 1, 14))
 
 del absolute_import, print_function, unicode_literals
 
 alpha = "Alpha "
 bravo = "Bravo "
 
 with support.EphemeralContext() as ctx:
     res = ctx.create_key(alpha, certify=True)
     key = ctx.get_key(res.fpr)
     assert len(key.subkeys) == 1, "Expected one primary key and no subkeys"
     assert len(key.uids) == 1, "Expected exactly one UID"
 
     def get_uid(uid):
         key = ctx.get_key(res.fpr)
         for u in key.uids:
             if u.uid == uid:
                 return u
         return None
 
     # sanity check
     uid = get_uid(alpha)
     assert uid, "UID alpha not found"
     assert uid.revoked == 0
 
     # add bravo
     ctx.key_add_uid(key, bravo)
     uid = get_uid(bravo)
     assert uid, "UID bravo not found"
     assert uid.revoked == 0
 
     # revoke alpha
     ctx.key_revoke_uid(key, alpha)
     uid = get_uid(alpha)
     assert uid, "UID alpha not found"
     assert uid.revoked == 1
     uid = get_uid(bravo)
     assert uid, "UID bravo not found"
     assert uid.revoked == 0
 
     # try to revoke the last UID
     try:
         ctx.key_revoke_uid(key, alpha)
         # IMHO this should fail.  issue2961.
         # assert False, "Expected an error but got none"
     except gpg.errors.GpgError:
         pass
 
     # Everything should be the same
     uid = get_uid(alpha)
     assert uid, "UID alpha not found"
     assert uid.revoked == 1
     uid = get_uid(bravo)
     assert uid, "UID bravo not found"
     assert uid.revoked == 0
 
     # try to revoke a non-existent UID
     try:
-        ctx.key_revoke_uid(key, "i dont exist")
+        ctx.key_revoke_uid(key, "i don't exist")
         # IMHO this should fail.  issue2963.
         # assert False, "Expected an error but got none"
     except gpg.errors.GpgError:
         pass
 
     # try to add an pre-existent UID
     try:
         ctx.key_add_uid(key, bravo)
         assert False, "Expected an error but got none"
     except gpg.errors.GpgError:
         pass
 
     # Check setting the TOFU policy.
     with open(os.path.join(ctx.home_dir, "gpg.conf"), "a") as handle:
         handle.write("trust-model tofu+pgp\n")
 
     if not support.have_tofu_support(ctx, bravo):
         print("GnuPG does not support TOFU, skipping TOFU tests.")
         sys.exit()
 
     for name, policy in [(name, getattr(gpg.constants.tofu.policy, name))
                          for name in filter(lambda x: not x.startswith('__'),
                                             dir(gpg.constants.tofu.policy))]:
         if policy == gpg.constants.tofu.policy.NONE:
             # We must not set the policy to NONE.
             continue
 
         ctx.key_tofu_policy(key, policy)
 
         keys = list(
             ctx.keylist(
                 key.uids[0].uid,
                 mode=(gpg.constants.keylist.mode.LOCAL |
                       gpg.constants.keylist.mode.WITH_TOFU)))
         assert len(keys) == 1
 
         if policy == gpg.constants.tofu.policy.AUTO:
             # We cannot check that it is set to AUTO.
             continue
 
         for uid in keys[0].uids:
             if uid.uid == alpha:
                 # TOFU information of revoked UIDs is not updated.
                 # XXX: Is that expected?
                 continue
             assert uid.tofu[0].policy == policy, \
                 "Expected policy {0} ({1}), got {2}".format(policy, name,
                                                             uid.tofu[0].policy)
diff --git a/lang/qt/README b/lang/qt/README
index 4621d28c..450fb032 100644
--- a/lang/qt/README
+++ b/lang/qt/README
@@ -1,130 +1,130 @@
 Qt API bindings/wrapper for GPGME
 ---------------------------------
 Based on KF5gpgmepp QGpgME and libkleo/backends/qgpgme
 
 Please note that QGpgME has a different license (GPL only)
-then GPGME itself. See the License secion in this
+then GPGME itself. See the License section in this
 document for more information.
 
 Overview
 --------
 QGpgme provides a very high level Qt API around GpgMEpp.
 As such it depends on GpgMEpp additionally to GpgME.
 
 There are two general concepts in QGpgME. Data abstraction
 through GpgMEpp's Dataprovider interface and the Job pattern.
 
 Data can be provided with QByteArrayDataProvider or
 QIODeviceDataProvider which can be constructed from their
 respective types. This means you can pass a QFile, QProcess,
 QString, etc.. directly to GPGME.
 
 To provide a stable API / ABI and because of historic reasons
 in libkleo (Where QGpgME was originally developed as an abstract
 crypto backend) QGpgME only provides abstract interfaces as
 public API while the actual implementation happens in the
 private QGpgME prefixed classes.
 
 Usage
 -----
 
 To use QGpgME first you need to obtain a Protocol class
 either for CMS (S/MIME) or OpenPGP. This Protocol class
 can then be used to create a Job.
 
 Each Job can be started asynchronusly and emits a result
 signal when done. The jobs are deleted automatically
 with QObject::deleteLater so they can be started without
 result handlers.
 
 The result signal provides a tuple of objects with the
 appropriate result information for this job. For historic
 reasons each result signal also includes an AuditLog
 and an AuditLog Error. These are only useful for
 S/MIME signature validation but are part of other jobs
 for API stability reasons.
 
 Some jobs like the verification or decryption jobs have
 dedicated result classes. Each result class at least
 has the member function error() that can be used
-to check if a job failed. Additionally errors are emited
+to check if a job failed. Additionally errors are emitted
 in the result signal.
 
 Jobs also provide progress signal whenever GnuPG emits
 a progress status line.
 
 Most jobs also provide a way synchronusly execute them.
-Please not that synchronus use does not cause the autodeletion
+Please not that synchronous use does not cause the autodeletion
 to take place so you have to manually delete them.
 
 Async usage:
 
     /* Create a job */
     EncryptJob *job = openpgp()->encryptJob(/*ASCII Armor */false, /* Textmode */ false);
     /* Connect something to the result signal */
     connect(job, &EncryptJob::result, this, [] (const GpgME::EncryptionResult &result,
                                                 const QByteArray &cipherText,
                                                 const QString,
                                                 const GpgME::Error) {
         /* Handle the result / do something with the ciphertext */
      });
     /* Start the job */
     job->start(keys, inptr, outptr, Context::AlwaysTrust);
     /* Do not delete the job as it is autodeleted. */
 
 Synchronous usage:
 
     /* Create a job */
     KeyListJob *listjob = openpgp()->keyListJob(false, false, false);
     /* Prepare result vector */
     std::vector keys;
     /* Execute it synchronusly */
     KeyListResult result = listjob->exec(QStringList() << QStringLiteral("alfa@example.net"),
                                          false, keys);
     /* Delete the job */
     delete listjob;
     /* Work with the result */
 
 See the generated documentation for more info on the classes
 in QGpgME. (Subdir doc)
 
 Examples / Tests
 ----------------
 
 The tests in the tests subdir can be used to get a better
 idea of QGpgME's usage. They also serve to test the C++
 API. Kleopatra and KMails Messagelib also make extensive
 use of QGpgME and can be used as further examples.
 
 Hacking
 -------
 QGpgME comes from a KDE background. As such it does not use
 GNU Coding styles but KDE Coding styles. See:
 https://techbase.kde.org/Policies/Frameworks_Coding_Style
 
 License
 -------
 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.
 
 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
 General Public License for more details.
 
 You should have received a copy of the GNU General Public License
 along with this program; if not, write to the Free Software
 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
 
 In addition, as a special exception, the copyright holders give
 permission to link the code of this program with any edition of
 the Qt library by Trolltech AS, Norway (or with modified versions
 of Qt that use the same license as Qt), and distribute linked
 combinations including the two.  You must obey the GNU General
 Public License in all respects for all of the code used other than
 Qt.  If you modify this file, you may extend this exception to
 your version of the file, but you are not obligated to do so.  If
 you do not wish to do so, delete this exception statement from
 your version.
diff --git a/lang/qt/doc/Doxyfile.in b/lang/qt/doc/Doxyfile.in
index c672c4c5..8ccd11c4 100644
--- a/lang/qt/doc/Doxyfile.in
+++ b/lang/qt/doc/Doxyfile.in
@@ -1,2352 +1,2352 @@
 # Doxyfile 1.8.8
 
 # This file describes the settings to be used by the documentation system
 # doxygen (www.doxygen.org) for a project.
 #
 # All text after a double hash (##) is considered a comment and is placed in
 # front of the TAG it is preceding.
 #
 # All text after a single hash (#) is considered a comment and will be ignored.
 # The format is:
 # TAG = value [value, ...]
 # For lists, items can also be appended using:
 # TAG += value [value, ...]
 # Values that contain spaces should be placed between quotes (\" \").
 
 #---------------------------------------------------------------------------
 # Project related configuration options
 #---------------------------------------------------------------------------
 
 # This tag specifies the encoding used for all characters in the config file
 # that follow. The default is UTF-8 which is also the encoding used for all text
 # before the first occurrence of this tag. Doxygen uses libiconv (or the iconv
 # built into libc) for the transcoding. See https://www.gnu.org/software/libiconv
 # for the list of possible encodings.
 # The default value is: UTF-8.
 
 DOXYFILE_ENCODING      = UTF-8
 
 # The PROJECT_NAME tag is a single word (or a sequence of words surrounded by
 # double-quotes, unless you are using Doxywizard) that should identify the
 # project for which the documentation is generated. This name is used in the
 # title of most generated pages and in a few other places.
 # The default value is: My Project.
 
 PROJECT_NAME           = "QGpgME"
 
 # The PROJECT_NUMBER tag can be used to enter a project or revision number. This
 # could be handy for archiving the generated documentation or if some version
 # control system is used.
 
 PROJECT_NUMBER         = "@LIBQGPGME_LT_CURRENT@.@LIBQGPGME_LT_AGE@.@LIBQGPGME_LT_REVISION@.@BUILD_REVISION@"
 
 # Using the PROJECT_BRIEF tag one can provide an optional one line description
 # for a project that appears at the top of each page and should give viewer a
 # quick idea about the purpose of the project. Keep the description short.
 
 PROJECT_BRIEF          = "Qt API for GpgME"
 
 # With the PROJECT_LOGO tag one can specify an logo or icon that is included in
 # the documentation. The maximum height of the logo should not exceed 55 pixels
 # and the maximum width should not exceed 200 pixels. Doxygen will copy the logo
 # to the output directory.
 
 PROJECT_LOGO           =
 
 # The OUTPUT_DIRECTORY tag is used to specify the (relative or absolute) path
 # into which the generated documentation will be written. If a relative path is
 # entered, it will be relative to the location where doxygen was started. If
 # left blank the current directory will be used.
 
 OUTPUT_DIRECTORY       = "@abs_builddir@/generated"
 
 # If the CREATE_SUBDIRS tag is set to YES, then doxygen will create 4096 sub-
 # directories (in 2 levels) under the output directory of each output format and
 # will distribute the generated files over these directories. Enabling this
 # option can be useful when feeding doxygen a huge amount of source files, where
 # putting all generated files in the same directory would otherwise causes
 # performance problems for the file system.
 # The default value is: NO.
 
 CREATE_SUBDIRS         = NO
 
 # If the ALLOW_UNICODE_NAMES tag is set to YES, doxygen will allow non-ASCII
 # characters to appear in the names of generated files. If set to NO, non-ASCII
 # characters will be escaped, for example _xE3_x81_x84 will be used for Unicode
 # U+3044.
 # The default value is: NO.
 
 ALLOW_UNICODE_NAMES    = NO
 
 # The OUTPUT_LANGUAGE tag is used to specify the language in which all
 # documentation generated by doxygen is written. Doxygen will use this
 # information to generate all constant output in the proper language.
 # Possible values are: Afrikaans, Arabic, Armenian, Brazilian, Catalan, Chinese,
 # Chinese-Traditional, Croatian, Czech, Danish, Dutch, English (United States),
 # Esperanto, Farsi (Persian), Finnish, French, German, Greek, Hungarian,
 # Indonesian, Italian, Japanese, Japanese-en (Japanese with English messages),
 # Korean, Korean-en (Korean with English messages), Latvian, Lithuanian,
 # Macedonian, Norwegian, Persian (Farsi), Polish, Portuguese, Romanian, Russian,
 # Serbian, Serbian-Cyrillic, Slovak, Slovene, Spanish, Swedish, Turkish,
 # Ukrainian and Vietnamese.
 # The default value is: English.
 
 OUTPUT_LANGUAGE        = English
 
 # If the BRIEF_MEMBER_DESC tag is set to YES doxygen will include brief member
 # descriptions after the members that are listed in the file and class
 # documentation (similar to Javadoc). Set to NO to disable this.
 # The default value is: YES.
 
 BRIEF_MEMBER_DESC      = YES
 
 # If the REPEAT_BRIEF tag is set to YES doxygen will prepend the brief
 # description of a member or function before the detailed description
 #
 # Note: If both HIDE_UNDOC_MEMBERS and BRIEF_MEMBER_DESC are set to NO, the
 # brief descriptions will be completely suppressed.
 # The default value is: YES.
 
 REPEAT_BRIEF           = YES
 
 # This tag implements a quasi-intelligent brief description abbreviator that is
 # used to form the text in various listings. Each string in this list, if found
 # as the leading text of the brief description, will be stripped from the text
 # and the result, after processing the whole list, is used as the annotated
 # text. Otherwise, the brief description is used as-is. If left blank, the
 # following values are used ($name is automatically replaced with the name of
 # the entity):The $name class, The $name widget, The $name file, is, provides,
 # specifies, contains, represents, a, an and the.
 
 ABBREVIATE_BRIEF       =
 
 # If the ALWAYS_DETAILED_SEC and REPEAT_BRIEF tags are both set to YES then
 # doxygen will generate a detailed section even if there is only a brief
 # description.
 # The default value is: NO.
 
 ALWAYS_DETAILED_SEC    = NO
 
 # If the INLINE_INHERITED_MEMB tag is set to YES, doxygen will show all
 # inherited members of a class in the documentation of that class as if those
 # members were ordinary class members. Constructors, destructors and assignment
 # operators of the base classes will not be shown.
 # The default value is: NO.
 
 INLINE_INHERITED_MEMB  = NO
 
 # If the FULL_PATH_NAMES tag is set to YES doxygen will prepend the full path
 # before files name in the file list and in the header files. If set to NO the
 # shortest path that makes the file name unique will be used
 # The default value is: YES.
 
 FULL_PATH_NAMES        = YES
 
 # The STRIP_FROM_PATH tag can be used to strip a user-defined part of the path.
 # Stripping is only done if one of the specified strings matches the left-hand
 # part of the path. The tag can be used to show relative paths in the file list.
 # If left blank the directory from which doxygen is run is used as the path to
 # strip.
 #
 # Note that you can specify absolute paths here, but also relative paths, which
 # will be relative from the directory where doxygen is started.
 # This tag requires that the tag FULL_PATH_NAMES is set to YES.
 
 STRIP_FROM_PATH        =
 
 # The STRIP_FROM_INC_PATH tag can be used to strip a user-defined part of the
 # path mentioned in the documentation of a class, which tells the reader which
 # header file to include in order to use a class. If left blank only the name of
 # the header file containing the class definition is used. Otherwise one should
 # specify the list of include paths that are normally passed to the compiler
 # using the -I flag.
 
 STRIP_FROM_INC_PATH    =
 
 # If the SHORT_NAMES tag is set to YES, doxygen will generate much shorter (but
 # less readable) file names. This can be useful is your file systems doesn't
 # support long names like on DOS, Mac, or CD-ROM.
 # The default value is: NO.
 
 SHORT_NAMES            = NO
 
 # If the JAVADOC_AUTOBRIEF tag is set to YES then doxygen will interpret the
 # first line (until the first dot) of a Javadoc-style comment as the brief
 # description. If set to NO, the Javadoc-style will behave just like regular Qt-
 # style comments (thus requiring an explicit @brief command for a brief
 # description.)
 # The default value is: NO.
 
 JAVADOC_AUTOBRIEF      = NO
 
 # If the QT_AUTOBRIEF tag is set to YES then doxygen will interpret the first
 # line (until the first dot) of a Qt-style comment as the brief description. If
 # set to NO, the Qt-style will behave just like regular Qt-style comments (thus
 # requiring an explicit \brief command for a brief description.)
 # The default value is: NO.
 
 QT_AUTOBRIEF           = NO
 
 # The MULTILINE_CPP_IS_BRIEF tag can be set to YES to make doxygen treat a
 # multi-line C++ special comment block (i.e. a block of //! or /// comments) as
 # a brief description. This used to be the default behavior. The new default is
 # to treat a multi-line C++ comment block as a detailed description. Set this
 # tag to YES if you prefer the old behavior instead.
 #
 # Note that setting this tag to YES also means that rational rose comments are
 # not recognized any more.
 # The default value is: NO.
 
 MULTILINE_CPP_IS_BRIEF = NO
 
 # If the INHERIT_DOCS tag is set to YES then an undocumented member inherits the
 # documentation from any documented member that it re-implements.
 # The default value is: YES.
 
 INHERIT_DOCS           = YES
 
 # If the SEPARATE_MEMBER_PAGES tag is set to YES, then doxygen will produce a
 # new page for each member. If set to NO, the documentation of a member will be
 # part of the file/class/namespace that contains it.
 # The default value is: NO.
 
 SEPARATE_MEMBER_PAGES  = NO
 
 # The TAB_SIZE tag can be used to set the number of spaces in a tab. Doxygen
 # uses this value to replace tabs by spaces in code fragments.
 # Minimum value: 1, maximum value: 16, default value: 4.
 
 TAB_SIZE               = 4
 
 # This tag can be used to specify a number of aliases that act as commands in
 # the documentation. An alias has the form:
 # name=value
 # For example adding
 # "sideeffect=@par Side Effects:\n"
 # will allow you to put the command \sideeffect (or @sideeffect) in the
 # documentation, which will result in a user-defined paragraph with heading
 # "Side Effects:". You can put \n's in the value part of an alias to insert
 # newlines.
 
 ALIASES                =
 
 # This tag can be used to specify a number of word-keyword mappings (TCL only).
 # A mapping has the form "name=value". For example adding "class=itcl::class"
 # will allow you to use the command class in the itcl::class meaning.
 
 TCL_SUBST              =
 
 # Set the OPTIMIZE_OUTPUT_FOR_C tag to YES if your project consists of C sources
 # only. Doxygen will then generate output that is more tailored for C. For
 # instance, some of the names that are used will be different. The list of all
 # members will be omitted, etc.
 # The default value is: NO.
 
 OPTIMIZE_OUTPUT_FOR_C  = NO
 
 # Set the OPTIMIZE_OUTPUT_JAVA tag to YES if your project consists of Java or
 # Python sources only. Doxygen will then generate output that is more tailored
 # for that language. For instance, namespaces will be presented as packages,
 # qualified scopes will look different, etc.
 # The default value is: NO.
 
 OPTIMIZE_OUTPUT_JAVA   = NO
 
 # Set the OPTIMIZE_FOR_FORTRAN tag to YES if your project consists of Fortran
 # sources. Doxygen will then generate output that is tailored for Fortran.
 # The default value is: NO.
 
 OPTIMIZE_FOR_FORTRAN   = NO
 
 # Set the OPTIMIZE_OUTPUT_VHDL tag to YES if your project consists of VHDL
 # sources. Doxygen will then generate output that is tailored for VHDL.
 # The default value is: NO.
 
 OPTIMIZE_OUTPUT_VHDL   = NO
 
 # Doxygen selects the parser to use depending on the extension of the files it
 # parses. With this tag you can assign which parser to use for a given
 # extension. Doxygen has a built-in mapping, but you can override or extend it
 # using this tag. The format is ext=language, where ext is a file extension, and
 # language is one of the parsers supported by doxygen: IDL, Java, Javascript,
 # C#, C, C++, D, PHP, Objective-C, Python, Fortran (fixed format Fortran:
 # FortranFixed, free formatted Fortran: FortranFree, unknown formatted Fortran:
 # Fortran. In the later case the parser tries to guess whether the code is fixed
 # or free formatted code, this is the default for Fortran type files), VHDL. For
 # instance to make doxygen treat .inc files as Fortran files (default is PHP),
 # and .f files as C (default is Fortran), use: inc=Fortran f=C.
 #
 # Note For files without extension you can use no_extension as a placeholder.
 #
 # Note that for custom extensions you also need to set FILE_PATTERNS otherwise
 # the files are not read by doxygen.
 
 EXTENSION_MAPPING      =
 
 # If the MARKDOWN_SUPPORT tag is enabled then doxygen pre-processes all comments
 # according to the Markdown format, which allows for more readable
 # documentation. See http://daringfireball.net/projects/markdown/ for details.
 # The output of markdown processing is further processed by doxygen, so you can
 # mix doxygen, HTML, and XML commands with Markdown formatting. Disable only in
 # case of backward compatibilities issues.
 # The default value is: YES.
 
 MARKDOWN_SUPPORT       = YES
 
 # When enabled doxygen tries to link words that correspond to documented
 # classes, or namespaces to their corresponding documentation. Such a link can
 # be prevented in individual cases by by putting a % sign in front of the word
 # or globally by setting AUTOLINK_SUPPORT to NO.
 # The default value is: YES.
 
 AUTOLINK_SUPPORT       = YES
 
 # If you use STL classes (i.e. std::string, std::vector, etc.) but do not want
 # to include (a tag file for) the STL sources as input, then you should set this
 # tag to YES in order to let doxygen match functions declarations and
 # definitions whose arguments contain STL classes (e.g. func(std::string);
 # versus func(std::string) {}). This also make the inheritance and collaboration
 # diagrams that involve STL classes more complete and accurate.
 # The default value is: NO.
 
 BUILTIN_STL_SUPPORT    = NO
 
 # If you use Microsoft's C++/CLI language, you should set this option to YES to
 # enable parsing support.
 # The default value is: NO.
 
 CPP_CLI_SUPPORT        = NO
 
 # Set the SIP_SUPPORT tag to YES if your project consists of sip (see:
 # http://www.riverbankcomputing.co.uk/software/sip/intro) sources only. Doxygen
 # will parse them like normal C++ but will assume all classes use public instead
 # of private inheritance when no explicit protection keyword is present.
 # The default value is: NO.
 
 SIP_SUPPORT            = NO
 
 # For Microsoft's IDL there are propget and propput attributes to indicate
 # getter and setter methods for a property. Setting this option to YES will make
 # doxygen to replace the get and set methods by a property in the documentation.
 # This will only work if the methods are indeed getting or setting a simple
 # type. If this is not the case, or you want to show the methods anyway, you
 # should set this option to NO.
 # The default value is: YES.
 
 IDL_PROPERTY_SUPPORT   = YES
 
 # If member grouping is used in the documentation and the DISTRIBUTE_GROUP_DOC
 # tag is set to YES, then doxygen will reuse the documentation of the first
 # member in the group (if any) for the other members of the group. By default
 # all members of a group must be documented explicitly.
 # The default value is: NO.
 
 DISTRIBUTE_GROUP_DOC   = NO
 
 # Set the SUBGROUPING tag to YES to allow class member groups of the same type
 # (for instance a group of public functions) to be put as a subgroup of that
 # type (e.g. under the Public Functions section). Set it to NO to prevent
 # subgrouping. Alternatively, this can be done per class using the
 # \nosubgrouping command.
 # The default value is: YES.
 
 SUBGROUPING            = YES
 
 # When the INLINE_GROUPED_CLASSES tag is set to YES, classes, structs and unions
 # are shown inside the group in which they are included (e.g. using \ingroup)
 # instead of on a separate page (for HTML and Man pages) or section (for LaTeX
 # and RTF).
 #
 # Note that this feature does not work in combination with
 # SEPARATE_MEMBER_PAGES.
 # The default value is: NO.
 
 INLINE_GROUPED_CLASSES = NO
 
 # When the INLINE_SIMPLE_STRUCTS tag is set to YES, structs, classes, and unions
 # with only public data fields or simple typedef fields will be shown inline in
 # the documentation of the scope in which they are defined (i.e. file,
 # namespace, or group documentation), provided this scope is documented. If set
 # to NO, structs, classes, and unions are shown on a separate page (for HTML and
 # Man pages) or section (for LaTeX and RTF).
 # The default value is: NO.
 
 INLINE_SIMPLE_STRUCTS  = NO
 
 # When TYPEDEF_HIDES_STRUCT tag is enabled, a typedef of a struct, union, or
 # enum is documented as struct, union, or enum with the name of the typedef. So
 # typedef struct TypeS {} TypeT, will appear in the documentation as a struct
 # with name TypeT. When disabled the typedef will appear as a member of a file,
 # namespace, or class. And the struct will be named TypeS. This can typically be
 # useful for C code in case the coding convention dictates that all compound
 # types are typedef'ed and only the typedef is referenced, never the tag name.
 # The default value is: NO.
 
 TYPEDEF_HIDES_STRUCT   = NO
 
 # The size of the symbol lookup cache can be set using LOOKUP_CACHE_SIZE. This
 # cache is used to resolve symbols given their name and scope. Since this can be
 # an expensive process and often the same symbol appears multiple times in the
 # code, doxygen keeps a cache of pre-resolved symbols. If the cache is too small
 # doxygen will become slower. If the cache is too large, memory is wasted. The
 # cache size is given by this formula: 2^(16+LOOKUP_CACHE_SIZE). The valid range
 # is 0..9, the default is 0, corresponding to a cache size of 2^16=65536
 # symbols. At the end of a run doxygen will report the cache usage and suggest
 # the optimal cache size from a speed point of view.
 # Minimum value: 0, maximum value: 9, default value: 0.
 
 LOOKUP_CACHE_SIZE      = 0
 
 #---------------------------------------------------------------------------
 # Build related configuration options
 #---------------------------------------------------------------------------
 
 # If the EXTRACT_ALL tag is set to YES doxygen will assume all entities in
 # documentation are documented, even if no documentation was available. Private
 # class members and static file members will be hidden unless the
 # EXTRACT_PRIVATE respectively EXTRACT_STATIC tags are set to YES.
 # Note: This will also disable the warnings about undocumented members that are
 # normally produced when WARNINGS is set to YES.
 # The default value is: NO.
 
 EXTRACT_ALL            = NO
 
 # If the EXTRACT_PRIVATE tag is set to YES all private members of a class will
 # be included in the documentation.
 # The default value is: NO.
 
 EXTRACT_PRIVATE        = NO
 
 # If the EXTRACT_PACKAGE tag is set to YES all members with package or internal
 # scope will be included in the documentation.
 # The default value is: NO.
 
 EXTRACT_PACKAGE        = NO
 
 # If the EXTRACT_STATIC tag is set to YES all static members of a file will be
 # included in the documentation.
 # The default value is: NO.
 
 EXTRACT_STATIC         = NO
 
 # If the EXTRACT_LOCAL_CLASSES tag is set to YES classes (and structs) defined
 # locally in source files will be included in the documentation. If set to NO
 # only classes defined in header files are included. Does not have any effect
 # for Java sources.
 # The default value is: YES.
 
 EXTRACT_LOCAL_CLASSES  = YES
 
 # This flag is only useful for Objective-C code. When set to YES local methods,
 # which are defined in the implementation section but not in the interface are
 # included in the documentation. If set to NO only methods in the interface are
 # included.
 # The default value is: NO.
 
 EXTRACT_LOCAL_METHODS  = NO
 
 # If this flag is set to YES, the members of anonymous namespaces will be
 # extracted and appear in the documentation as a namespace called
 # 'anonymous_namespace{file}', where file will be replaced with the base name of
 # the file that contains the anonymous namespace. By default anonymous namespace
 # are hidden.
 # The default value is: NO.
 
 EXTRACT_ANON_NSPACES   = NO
 
 # If the HIDE_UNDOC_MEMBERS tag is set to YES, doxygen will hide all
 # undocumented members inside documented classes or files. If set to NO these
 # members will be included in the various overviews, but no documentation
 # section is generated. This option has no effect if EXTRACT_ALL is enabled.
 # The default value is: NO.
 
 HIDE_UNDOC_MEMBERS     = NO
 
 # If the HIDE_UNDOC_CLASSES tag is set to YES, doxygen will hide all
 # undocumented classes that are normally visible in the class hierarchy. If set
 # to NO these classes will be included in the various overviews. This option has
 # no effect if EXTRACT_ALL is enabled.
 # The default value is: NO.
 
 HIDE_UNDOC_CLASSES     = NO
 
 # If the HIDE_FRIEND_COMPOUNDS tag is set to YES, doxygen will hide all friend
 # (class|struct|union) declarations. If set to NO these declarations will be
 # included in the documentation.
 # The default value is: NO.
 
 HIDE_FRIEND_COMPOUNDS  = NO
 
 # If the HIDE_IN_BODY_DOCS tag is set to YES, doxygen will hide any
 # documentation blocks found inside the body of a function. If set to NO these
 # blocks will be appended to the function's detailed documentation block.
 # The default value is: NO.
 
 HIDE_IN_BODY_DOCS      = NO
 
 # The INTERNAL_DOCS tag determines if documentation that is typed after a
 # \internal command is included. If the tag is set to NO then the documentation
 # will be excluded. Set it to YES to include the internal documentation.
 # The default value is: NO.
 
 INTERNAL_DOCS          = NO
 
 # If the CASE_SENSE_NAMES tag is set to NO then doxygen will only generate file
 # names in lower-case letters. If set to YES upper-case letters are also
 # allowed. This is useful if you have classes or files whose names only differ
 # in case and if your file system supports case sensitive file names. Windows
 # and Mac users are advised to set this option to NO.
 # The default value is: system dependent.
 
 CASE_SENSE_NAMES       = YES
 
 # If the HIDE_SCOPE_NAMES tag is set to NO then doxygen will show members with
 # their full class and namespace scopes in the documentation. If set to YES the
 # scope will be hidden.
 # The default value is: NO.
 
 HIDE_SCOPE_NAMES       = NO
 
 # If the SHOW_INCLUDE_FILES tag is set to YES then doxygen will put a list of
 # the files that are included by a file in the documentation of that file.
 # The default value is: YES.
 
 SHOW_INCLUDE_FILES     = YES
 
 # If the SHOW_GROUPED_MEMB_INC tag is set to YES then Doxygen will add for each
 # grouped member an include statement to the documentation, telling the reader
 # which file to include in order to use the member.
 # The default value is: NO.
 
 SHOW_GROUPED_MEMB_INC  = NO
 
 # If the FORCE_LOCAL_INCLUDES tag is set to YES then doxygen will list include
 # files with double quotes in the documentation rather than with sharp brackets.
 # The default value is: NO.
 
 FORCE_LOCAL_INCLUDES   = NO
 
 # If the INLINE_INFO tag is set to YES then a tag [inline] is inserted in the
 # documentation for inline members.
 # The default value is: YES.
 
 INLINE_INFO            = YES
 
 # If the SORT_MEMBER_DOCS tag is set to YES then doxygen will sort the
 # (detailed) documentation of file and class members alphabetically by member
 # name. If set to NO the members will appear in declaration order.
 # The default value is: YES.
 
 SORT_MEMBER_DOCS       = YES
 
 # If the SORT_BRIEF_DOCS tag is set to YES then doxygen will sort the brief
 # descriptions of file, namespace and class members alphabetically by member
 # name. If set to NO the members will appear in declaration order. Note that
 # this will also influence the order of the classes in the class list.
 # The default value is: NO.
 
 SORT_BRIEF_DOCS        = NO
 
 # If the SORT_MEMBERS_CTORS_1ST tag is set to YES then doxygen will sort the
 # (brief and detailed) documentation of class members so that constructors and
 # destructors are listed first. If set to NO the constructors will appear in the
 # respective orders defined by SORT_BRIEF_DOCS and SORT_MEMBER_DOCS.
 # Note: If SORT_BRIEF_DOCS is set to NO this option is ignored for sorting brief
 # member documentation.
 # Note: If SORT_MEMBER_DOCS is set to NO this option is ignored for sorting
 # detailed member documentation.
 # The default value is: NO.
 
 SORT_MEMBERS_CTORS_1ST = NO
 
 # If the SORT_GROUP_NAMES tag is set to YES then doxygen will sort the hierarchy
 # of group names into alphabetical order. If set to NO the group names will
 # appear in their defined order.
 # The default value is: NO.
 
 SORT_GROUP_NAMES       = NO
 
 # If the SORT_BY_SCOPE_NAME tag is set to YES, the class list will be sorted by
 # fully-qualified names, including namespaces. If set to NO, the class list will
 # be sorted only by class name, not including the namespace part.
 # Note: This option is not very useful if HIDE_SCOPE_NAMES is set to YES.
 # Note: This option applies only to the class list, not to the alphabetical
 # list.
 # The default value is: NO.
 
 SORT_BY_SCOPE_NAME     = NO
 
 # If the STRICT_PROTO_MATCHING option is enabled and doxygen fails to do proper
 # type resolution of all parameters of a function it will reject a match between
 # the prototype and the implementation of a member function even if there is
 # only one candidate or it is obvious which candidate to choose by doing a
 # simple string match. By disabling STRICT_PROTO_MATCHING doxygen will still
 # accept a match between prototype and implementation in such cases.
 # The default value is: NO.
 
 STRICT_PROTO_MATCHING  = NO
 
 # The GENERATE_TODOLIST tag can be used to enable ( YES) or disable ( NO) the
 # todo list. This list is created by putting \todo commands in the
 # documentation.
 # The default value is: YES.
 
 GENERATE_TODOLIST      = YES
 
 # The GENERATE_TESTLIST tag can be used to enable ( YES) or disable ( NO) the
 # test list. This list is created by putting \test commands in the
 # documentation.
 # The default value is: YES.
 
 GENERATE_TESTLIST      = YES
 
 # The GENERATE_BUGLIST tag can be used to enable ( YES) or disable ( NO) the bug
 # list. This list is created by putting \bug commands in the documentation.
 # The default value is: YES.
 
 GENERATE_BUGLIST       = YES
 
 # The GENERATE_DEPRECATEDLIST tag can be used to enable ( YES) or disable ( NO)
 # the deprecated list. This list is created by putting \deprecated commands in
 # the documentation.
 # The default value is: YES.
 
 GENERATE_DEPRECATEDLIST= YES
 
 # The ENABLED_SECTIONS tag can be used to enable conditional documentation
 # sections, marked by \if  ... \endif and \cond 
 # ... \endcond blocks.
 
 ENABLED_SECTIONS       =
 
 # The MAX_INITIALIZER_LINES tag determines the maximum number of lines that the
 # initial value of a variable or macro / define can have for it to appear in the
 # documentation. If the initializer consists of more lines than specified here
 # it will be hidden. Use a value of 0 to hide initializers completely. The
 # appearance of the value of individual variables and macros / defines can be
 # controlled using \showinitializer or \hideinitializer command in the
 # documentation regardless of this setting.
 # Minimum value: 0, maximum value: 10000, default value: 30.
 
 MAX_INITIALIZER_LINES  = 30
 
 # Set the SHOW_USED_FILES tag to NO to disable the list of files generated at
 # the bottom of the documentation of classes and structs. If set to YES the list
 # will mention the files that were used to generate the documentation.
 # The default value is: YES.
 
 SHOW_USED_FILES        = YES
 
 # Set the SHOW_FILES tag to NO to disable the generation of the Files page. This
 # will remove the Files entry from the Quick Index and from the Folder Tree View
 # (if specified).
 # The default value is: YES.
 
 SHOW_FILES             = YES
 
 # Set the SHOW_NAMESPACES tag to NO to disable the generation of the Namespaces
 # page. This will remove the Namespaces entry from the Quick Index and from the
 # Folder Tree View (if specified).
 # The default value is: YES.
 
 SHOW_NAMESPACES        = YES
 
 # The FILE_VERSION_FILTER tag can be used to specify a program or script that
 # doxygen should invoke to get the current version for each file (typically from
 # the version control system). Doxygen will invoke the program by executing (via
 # popen()) the command command input-file, where command is the value of the
 # FILE_VERSION_FILTER tag, and input-file is the name of an input file provided
 # by doxygen. Whatever the program writes to standard output is used as the file
 # version. For an example see the documentation.
 
 FILE_VERSION_FILTER    =
 
 # The LAYOUT_FILE tag can be used to specify a layout file which will be parsed
 # by doxygen. The layout file controls the global structure of the generated
 # output files in an output format independent way. To create the layout file
 # that represents doxygen's defaults, run doxygen with the -l option. You can
 # optionally specify a file name after the option, if omitted DoxygenLayout.xml
 # will be used as the name of the layout file.
 #
 # Note that if you run doxygen from a directory containing a file called
 # DoxygenLayout.xml, doxygen will parse it automatically even if the LAYOUT_FILE
 # tag is left empty.
 
 LAYOUT_FILE            =
 
 # The CITE_BIB_FILES tag can be used to specify one or more bib files containing
 # the reference definitions. This must be a list of .bib files. The .bib
 # extension is automatically appended if omitted. This requires the bibtex tool
 # to be installed. See also http://en.wikipedia.org/wiki/BibTeX for more info.
 # For LaTeX the style of the bibliography can be controlled using
 # LATEX_BIB_STYLE. To use this feature you need bibtex and perl available in the
 # search path. See also \cite for info how to create references.
 
 CITE_BIB_FILES         =
 
 #---------------------------------------------------------------------------
 # Configuration options related to warning and progress messages
 #---------------------------------------------------------------------------
 
 # The QUIET tag can be used to turn on/off the messages that are generated to
 # standard output by doxygen. If QUIET is set to YES this implies that the
 # messages are off.
 # The default value is: NO.
 
 QUIET                  = YES
 
 # The WARNINGS tag can be used to turn on/off the warning messages that are
 # generated to standard error ( stderr) by doxygen. If WARNINGS is set to YES
 # this implies that the warnings are on.
 #
 # Tip: Turn warnings on while writing the documentation.
 # The default value is: YES.
 
 WARNINGS               = YES
 
 # If the WARN_IF_UNDOCUMENTED tag is set to YES, then doxygen will generate
 # warnings for undocumented members. If EXTRACT_ALL is set to YES then this flag
 # will automatically be disabled.
 # The default value is: YES.
 
 WARN_IF_UNDOCUMENTED   = NO
 
 # If the WARN_IF_DOC_ERROR tag is set to YES, doxygen will generate warnings for
 # potential errors in the documentation, such as not documenting some parameters
 # in a documented function, or documenting parameters that don't exist or using
 # markup commands wrongly.
 # The default value is: YES.
 
 WARN_IF_DOC_ERROR      = YES
 
 # This WARN_NO_PARAMDOC option can be enabled to get warnings for functions that
 # are documented, but have no documentation for their parameters or return
 # value. If set to NO doxygen will only warn about wrong or incomplete parameter
 # documentation, but not about the absence of documentation.
 # The default value is: NO.
 
 WARN_NO_PARAMDOC       = NO
 
 # The WARN_FORMAT tag determines the format of the warning messages that doxygen
 # can produce. The string should contain the $file, $line, and $text tags, which
 # will be replaced by the file and line number from which the warning originated
 # and the warning text. Optionally the format may contain $version, which will
 # be replaced by the version of the file (if it could be obtained via
 # FILE_VERSION_FILTER)
 # The default value is: $file:$line: $text.
 
 WARN_FORMAT            = "$file:$line: $text"
 
 # The WARN_LOGFILE tag can be used to specify a file to which warning and error
 # messages should be written. If left blank the output is written to standard
 # error (stderr).
 
 WARN_LOGFILE           =
 
 #---------------------------------------------------------------------------
 # Configuration options related to the input files
 #---------------------------------------------------------------------------
 
 # The INPUT tag is used to specify the files and/or directories that contain
 # documented source files. You may enter file names like myfile.cpp or
 # directories like /usr/src/myproject. Separate the files or directories with
 # spaces.
 # Note: If this tag is empty the current directory is searched.
 
 INPUT                  = "@top_srcdir@/lang/qt/src"
 
 # This tag can be used to specify the character encoding of the source files
 # that doxygen parses. Internally doxygen uses the UTF-8 encoding. Doxygen uses
 # libiconv (or the iconv built into libc) for the transcoding. See the libiconv
 # documentation (see: https://www.gnu.org/software/libiconv) for the list of
 # possible encodings.
 # The default value is: UTF-8.
 
 INPUT_ENCODING         = UTF-8
 
 # If the value of the INPUT tag contains directories, you can use the
 # FILE_PATTERNS tag to specify one or more wildcard patterns (like *.cpp and
 # *.h) to filter out the source-files in the directories. If left blank the
 # following patterns are tested:*.c, *.cc, *.cxx, *.cpp, *.c++, *.java, *.ii,
 # *.ixx, *.ipp, *.i++, *.inl, *.idl, *.ddl, *.odl, *.h, *.hh, *.hxx, *.hpp,
 # *.h++, *.cs, *.d, *.php, *.php4, *.php5, *.phtml, *.inc, *.m, *.markdown,
 # *.md, *.mm, *.dox, *.py, *.f90, *.f, *.for, *.tcl, *.vhd, *.vhdl, *.ucf,
 # *.qsf, *.as and *.js.
 
 FILE_PATTERNS          =
 
 # The RECURSIVE tag can be used to specify whether or not subdirectories should
 # be searched for input files as well.
 # The default value is: NO.
 
 RECURSIVE              = NO
 
 # The EXCLUDE tag can be used to specify files and/or directories that should be
 # excluded from the INPUT source files. This way you can easily exclude a
 # subdirectory from a directory tree whose root is specified with the INPUT tag.
 #
 # Note that relative paths are relative to the directory from which doxygen is
 # run.
 
 EXCLUDE                =
 
 # The EXCLUDE_SYMLINKS tag can be used to select whether or not files or
 # directories that are symbolic links (a Unix file system feature) are excluded
 # from the input.
 # The default value is: NO.
 
 EXCLUDE_SYMLINKS       = NO
 
 # If the value of the INPUT tag contains directories, you can use the
 # EXCLUDE_PATTERNS tag to specify one or more wildcard patterns to exclude
 # certain files from those directories.
 #
 # Note that the wildcards are matched against the file with absolute path, so to
 # exclude all test directories for example use the pattern */test/*
 
 EXCLUDE_PATTERNS       =
 
 # The EXCLUDE_SYMBOLS tag can be used to specify one or more symbol names
 # (namespaces, classes, functions, etc.) that should be excluded from the
 # output. The symbol name can be a fully qualified name, a word, or if the
 # wildcard * is used, a substring. Examples: ANamespace, AClass,
 # AClass::ANamespace, ANamespace::*Test
 #
 # Note that the wildcards are matched against the file with absolute path, so to
 # exclude all test directories use the pattern */test/*
 
 EXCLUDE_SYMBOLS        =
 
 # The EXAMPLE_PATH tag can be used to specify one or more files or directories
 # that contain example code fragments that are included (see the \include
 # command).
 
 EXAMPLE_PATH           =
 
 # If the value of the EXAMPLE_PATH tag contains directories, you can use the
 # EXAMPLE_PATTERNS tag to specify one or more wildcard pattern (like *.cpp and
 # *.h) to filter out the source-files in the directories. If left blank all
 # files are included.
 
 EXAMPLE_PATTERNS       =
 
 # If the EXAMPLE_RECURSIVE tag is set to YES then subdirectories will be
 # searched for input files to be used with the \include or \dontinclude commands
 # irrespective of the value of the RECURSIVE tag.
 # The default value is: NO.
 
 EXAMPLE_RECURSIVE      = NO
 
 # The IMAGE_PATH tag can be used to specify one or more files or directories
 # that contain images that are to be included in the documentation (see the
 # \image command).
 
 IMAGE_PATH             =
 
 # The INPUT_FILTER tag can be used to specify a program that doxygen should
 # invoke to filter for each input file. Doxygen will invoke the filter program
 # by executing (via popen()) the command:
 #
 #  
 #
 # where  is the value of the INPUT_FILTER tag, and  is the
 # name of an input file. Doxygen will then use the output that the filter
 # program writes to standard output. If FILTER_PATTERNS is specified, this tag
 # will be ignored.
 #
 # Note that the filter must not add or remove lines; it is applied before the
 # code is scanned, but not when the output code is generated. If lines are added
 # or removed, the anchors will not be placed correctly.
 
 INPUT_FILTER           =
 
 # The FILTER_PATTERNS tag can be used to specify filters on a per file pattern
 # basis. Doxygen will compare the file name with each pattern and apply the
 # filter if there is a match. The filters are a list of the form: pattern=filter
 # (like *.cpp=my_cpp_filter). See INPUT_FILTER for further information on how
 # filters are used. If the FILTER_PATTERNS tag is empty or if none of the
 # patterns match the file name, INPUT_FILTER is applied.
 
 FILTER_PATTERNS        =
 
 # If the FILTER_SOURCE_FILES tag is set to YES, the input filter (if set using
 # INPUT_FILTER ) will also be used to filter the input files that are used for
 # producing the source files to browse (i.e. when SOURCE_BROWSER is set to YES).
 # The default value is: NO.
 
 FILTER_SOURCE_FILES    = NO
 
 # The FILTER_SOURCE_PATTERNS tag can be used to specify source filters per file
 # pattern. A pattern will override the setting for FILTER_PATTERN (if any) and
 # it is also possible to disable source filtering for a specific pattern using
 # *.ext= (so without naming a filter).
 # This tag requires that the tag FILTER_SOURCE_FILES is set to YES.
 
 FILTER_SOURCE_PATTERNS =
 
 # If the USE_MDFILE_AS_MAINPAGE tag refers to the name of a markdown file that
 # is part of the input, its contents will be placed on the main page
 # (index.html). This can be useful if you have a project on for instance GitHub
 # and want to reuse the introduction page also for the doxygen output.
 
 USE_MDFILE_AS_MAINPAGE =
 
 #---------------------------------------------------------------------------
 # Configuration options related to source browsing
 #---------------------------------------------------------------------------
 
 # If the SOURCE_BROWSER tag is set to YES then a list of source files will be
 # generated. Documented entities will be cross-referenced with these sources.
 #
 # Note: To get rid of all source code in the generated output, make sure that
 # also VERBATIM_HEADERS is set to NO.
 # The default value is: NO.
 
 SOURCE_BROWSER         = NO
 
 # Setting the INLINE_SOURCES tag to YES will include the body of functions,
 # classes and enums directly into the documentation.
 # The default value is: NO.
 
 INLINE_SOURCES         = NO
 
 # Setting the STRIP_CODE_COMMENTS tag to YES will instruct doxygen to hide any
 # special comment blocks from generated source code fragments. Normal C, C++ and
 # Fortran comments will always remain visible.
 # The default value is: YES.
 
 STRIP_CODE_COMMENTS    = YES
 
 # If the REFERENCED_BY_RELATION tag is set to YES then for each documented
 # function all documented functions referencing it will be listed.
 # The default value is: NO.
 
 REFERENCED_BY_RELATION = NO
 
 # If the REFERENCES_RELATION tag is set to YES then for each documented function
 # all documented entities called/used by that function will be listed.
 # The default value is: NO.
 
 REFERENCES_RELATION    = NO
 
 # If the REFERENCES_LINK_SOURCE tag is set to YES and SOURCE_BROWSER tag is set
 # to YES, then the hyperlinks from functions in REFERENCES_RELATION and
 # REFERENCED_BY_RELATION lists will link to the source code. Otherwise they will
 # link to the documentation.
 # The default value is: YES.
 
 REFERENCES_LINK_SOURCE = YES
 
 # If SOURCE_TOOLTIPS is enabled (the default) then hovering a hyperlink in the
 # source code will show a tooltip with additional information such as prototype,
 # brief description and links to the definition and documentation. Since this
 # will make the HTML file larger and loading of large files a bit slower, you
 # can opt to disable this feature.
 # The default value is: YES.
 # This tag requires that the tag SOURCE_BROWSER is set to YES.
 
 SOURCE_TOOLTIPS        = YES
 
 # If the USE_HTAGS tag is set to YES then the references to source code will
 # point to the HTML generated by the htags(1) tool instead of doxygen built-in
 # source browser. The htags tool is part of GNU's global source tagging system
 # (see https://www.gnu.org/software/global/global.html). You will need version
 # 4.8.6 or higher.
 #
 # To use it do the following:
 # - Install the latest version of global
 # - Enable SOURCE_BROWSER and USE_HTAGS in the config file
 # - Make sure the INPUT points to the root of the source tree
 # - Run doxygen as normal
 #
 # Doxygen will invoke htags (and that will in turn invoke gtags), so these
 # tools must be available from the command line (i.e. in the search path).
 #
 # The result: instead of the source browser generated by doxygen, the links to
 # source code will now point to the output of htags.
 # The default value is: NO.
 # This tag requires that the tag SOURCE_BROWSER is set to YES.
 
 USE_HTAGS              = NO
 
 # If the VERBATIM_HEADERS tag is set the YES then doxygen will generate a
 # verbatim copy of the header file for each class for which an include is
 # specified. Set to NO to disable this.
 # See also: Section \class.
 # The default value is: YES.
 
 VERBATIM_HEADERS       = YES
 
 # If the CLANG_ASSISTED_PARSING tag is set to YES, then doxygen will use the
 # clang parser (see: http://clang.llvm.org/) for more accurate parsing at the
 # cost of reduced performance. This can be particularly helpful with template
 # rich C++ code for which doxygen's built-in parser lacks the necessary type
 # information.
 # Note: The availability of this option depends on whether or not doxygen was
 # compiled with the --with-libclang option.
 # The default value is: NO.
 
 CLANG_ASSISTED_PARSING = NO
 
 # If clang assisted parsing is enabled you can provide the compiler with command
 # line options that you would normally use when invoking the compiler. Note that
 # the include paths will already be set by doxygen for the files and directories
 # specified with INPUT and INCLUDE_PATH.
 # This tag requires that the tag CLANG_ASSISTED_PARSING is set to YES.
 
 CLANG_OPTIONS          =
 
 #---------------------------------------------------------------------------
 # Configuration options related to the alphabetical class index
 #---------------------------------------------------------------------------
 
 # If the ALPHABETICAL_INDEX tag is set to YES, an alphabetical index of all
 # compounds will be generated. Enable this if the project contains a lot of
 # classes, structs, unions or interfaces.
 # The default value is: YES.
 
 ALPHABETICAL_INDEX     = YES
 
 # The COLS_IN_ALPHA_INDEX tag can be used to specify the number of columns in
 # which the alphabetical index list will be split.
 # Minimum value: 1, maximum value: 20, default value: 5.
 # This tag requires that the tag ALPHABETICAL_INDEX is set to YES.
 
 COLS_IN_ALPHA_INDEX    = 5
 
 # In case all classes in a project start with a common prefix, all classes will
 # be put under the same header in the alphabetical index. The IGNORE_PREFIX tag
 # can be used to specify a prefix (or a list of prefixes) that should be ignored
 # while generating the index headers.
 # This tag requires that the tag ALPHABETICAL_INDEX is set to YES.
 
 IGNORE_PREFIX          =
 
 #---------------------------------------------------------------------------
 # Configuration options related to the HTML output
 #---------------------------------------------------------------------------
 
 # If the GENERATE_HTML tag is set to YES doxygen will generate HTML output
 # The default value is: YES.
 
 GENERATE_HTML          = YES
 
 # The HTML_OUTPUT tag is used to specify where the HTML docs will be put. If a
 # relative path is entered the value of OUTPUT_DIRECTORY will be put in front of
 # it.
 # The default directory is: html.
 # This tag requires that the tag GENERATE_HTML is set to YES.
 
 HTML_OUTPUT            = html
 
 # The HTML_FILE_EXTENSION tag can be used to specify the file extension for each
 # generated HTML page (for example: .htm, .php, .asp).
 # The default value is: .html.
 # This tag requires that the tag GENERATE_HTML is set to YES.
 
 HTML_FILE_EXTENSION    = .html
 
 # The HTML_HEADER tag can be used to specify a user-defined HTML header file for
 # each generated HTML page. If the tag is left blank doxygen will generate a
 # standard header.
 #
 # To get valid HTML the header file that includes any scripts and style sheets
 # that doxygen needs, which is dependent on the configuration options used (e.g.
 # the setting GENERATE_TREEVIEW). It is highly recommended to start with a
 # default header using
 # doxygen -w html new_header.html new_footer.html new_stylesheet.css
 # YourConfigFile
 # and then modify the file new_header.html. See also section "Doxygen usage"
 # for information on how to generate the default header that doxygen normally
 # uses.
 # Note: The header is subject to change so you typically have to regenerate the
 # default header when upgrading to a newer version of doxygen. For a description
 # of the possible markers and block names see the documentation.
 # This tag requires that the tag GENERATE_HTML is set to YES.
 
 HTML_HEADER            =
 
 # The HTML_FOOTER tag can be used to specify a user-defined HTML footer for each
 # generated HTML page. If the tag is left blank doxygen will generate a standard
 # footer. See HTML_HEADER for more information on how to generate a default
 # footer and what special commands can be used inside the footer. See also
 # section "Doxygen usage" for information on how to generate the default footer
 # that doxygen normally uses.
 # This tag requires that the tag GENERATE_HTML is set to YES.
 
 HTML_FOOTER            =
 
 # The HTML_STYLESHEET tag can be used to specify a user-defined cascading style
 # sheet that is used by each HTML page. It can be used to fine-tune the look of
 # the HTML output. If left blank doxygen will generate a default style sheet.
 # See also section "Doxygen usage" for information on how to generate the style
 # sheet that doxygen normally uses.
 # Note: It is recommended to use HTML_EXTRA_STYLESHEET instead of this tag, as
 # it is more robust and this tag (HTML_STYLESHEET) will in the future become
 # obsolete.
 # This tag requires that the tag GENERATE_HTML is set to YES.
 
 HTML_STYLESHEET        =
 
 # The HTML_EXTRA_STYLESHEET tag can be used to specify additional user-defined
 # cascading style sheets that are included after the standard style sheets
 # created by doxygen. Using this option one can overrule certain style aspects.
 # This is preferred over using HTML_STYLESHEET since it does not replace the
-# standard style sheet and is therefor more robust against future updates.
+# standard style sheet and is therefore more robust against future updates.
 # Doxygen will copy the style sheet files to the output directory.
 # Note: The order of the extra stylesheet files is of importance (e.g. the last
 # stylesheet in the list overrules the setting of the previous ones in the
 # list). For an example see the documentation.
 # This tag requires that the tag GENERATE_HTML is set to YES.
 
 HTML_EXTRA_STYLESHEET  =
 
 # The HTML_EXTRA_FILES tag can be used to specify one or more extra images or
 # other source files which should be copied to the HTML output directory. Note
 # that these files will be copied to the base HTML output directory. Use the
 # $relpath^ marker in the HTML_HEADER and/or HTML_FOOTER files to load these
 # files. In the HTML_STYLESHEET file, use the file name only. Also note that the
 # files will be copied as-is; there are no commands or markers available.
 # This tag requires that the tag GENERATE_HTML is set to YES.
 
 HTML_EXTRA_FILES       =
 
 # The HTML_COLORSTYLE_HUE tag controls the color of the HTML output. Doxygen
 # will adjust the colors in the stylesheet and background images according to
 # this color. Hue is specified as an angle on a colorwheel, see
 # http://en.wikipedia.org/wiki/Hue for more information. For instance the value
 # 0 represents red, 60 is yellow, 120 is green, 180 is cyan, 240 is blue, 300
 # purple, and 360 is red again.
 # Minimum value: 0, maximum value: 359, default value: 220.
 # This tag requires that the tag GENERATE_HTML is set to YES.
 
 HTML_COLORSTYLE_HUE    = 220
 
 # The HTML_COLORSTYLE_SAT tag controls the purity (or saturation) of the colors
 # in the HTML output. For a value of 0 the output will use grayscales only. A
 # value of 255 will produce the most vivid colors.
 # Minimum value: 0, maximum value: 255, default value: 100.
 # This tag requires that the tag GENERATE_HTML is set to YES.
 
 HTML_COLORSTYLE_SAT    = 100
 
 # The HTML_COLORSTYLE_GAMMA tag controls the gamma correction applied to the
 # luminance component of the colors in the HTML output. Values below 100
 # gradually make the output lighter, whereas values above 100 make the output
 # darker. The value divided by 100 is the actual gamma applied, so 80 represents
 # a gamma of 0.8, The value 220 represents a gamma of 2.2, and 100 does not
 # change the gamma.
 # Minimum value: 40, maximum value: 240, default value: 80.
 # This tag requires that the tag GENERATE_HTML is set to YES.
 
 HTML_COLORSTYLE_GAMMA  = 80
 
 # If the HTML_TIMESTAMP tag is set to YES then the footer of each generated HTML
 # page will contain the date and time when the page was generated. Setting this
 # to NO can help when comparing the output of multiple runs.
 # The default value is: YES.
 # This tag requires that the tag GENERATE_HTML is set to YES.
 
 HTML_TIMESTAMP         = YES
 
 # If the HTML_DYNAMIC_SECTIONS tag is set to YES then the generated HTML
 # documentation will contain sections that can be hidden and shown after the
 # page has loaded.
 # The default value is: NO.
 # This tag requires that the tag GENERATE_HTML is set to YES.
 
 HTML_DYNAMIC_SECTIONS  = NO
 
 # With HTML_INDEX_NUM_ENTRIES one can control the preferred number of entries
 # shown in the various tree structured indices initially; the user can expand
 # and collapse entries dynamically later on. Doxygen will expand the tree to
 # such a level that at most the specified number of entries are visible (unless
 # a fully collapsed tree already exceeds this amount). So setting the number of
 # entries 1 will produce a full collapsed tree by default. 0 is a special value
 # representing an infinite number of entries and will result in a full expanded
 # tree by default.
 # Minimum value: 0, maximum value: 9999, default value: 100.
 # This tag requires that the tag GENERATE_HTML is set to YES.
 
 HTML_INDEX_NUM_ENTRIES = 100
 
 # If the GENERATE_DOCSET tag is set to YES, additional index files will be
 # generated that can be used as input for Apple's Xcode 3 integrated development
 # environment (see: http://developer.apple.com/tools/xcode/), introduced with
 # OSX 10.5 (Leopard). To create a documentation set, doxygen will generate a
 # Makefile in the HTML output directory. Running make will produce the docset in
 # that directory and running make install will install the docset in
 # ~/Library/Developer/Shared/Documentation/DocSets so that Xcode will find it at
 # startup. See http://developer.apple.com/tools/creatingdocsetswithdoxygen.html
 # for more information.
 # The default value is: NO.
 # This tag requires that the tag GENERATE_HTML is set to YES.
 
 GENERATE_DOCSET        = NO
 
 # This tag determines the name of the docset feed. A documentation feed provides
 # an umbrella under which multiple documentation sets from a single provider
 # (such as a company or product suite) can be grouped.
 # The default value is: Doxygen generated docs.
 # This tag requires that the tag GENERATE_DOCSET is set to YES.
 
 DOCSET_FEEDNAME        = "Doxygen generated docs"
 
 # This tag specifies a string that should uniquely identify the documentation
 # set bundle. This should be a reverse domain-name style string, e.g.
 # com.mycompany.MyDocSet. Doxygen will append .docset to the name.
 # The default value is: org.doxygen.Project.
 # This tag requires that the tag GENERATE_DOCSET is set to YES.
 
 DOCSET_BUNDLE_ID       = org.doxygen.Project
 
 # The DOCSET_PUBLISHER_ID tag specifies a string that should uniquely identify
 # the documentation publisher. This should be a reverse domain-name style
 # string, e.g. com.mycompany.MyDocSet.documentation.
 # The default value is: org.doxygen.Publisher.
 # This tag requires that the tag GENERATE_DOCSET is set to YES.
 
 DOCSET_PUBLISHER_ID    = org.doxygen.Publisher
 
 # The DOCSET_PUBLISHER_NAME tag identifies the documentation publisher.
 # The default value is: Publisher.
 # This tag requires that the tag GENERATE_DOCSET is set to YES.
 
 DOCSET_PUBLISHER_NAME  = Publisher
 
 # If the GENERATE_HTMLHELP tag is set to YES then doxygen generates three
 # additional HTML index files: index.hhp, index.hhc, and index.hhk. The
 # index.hhp is a project file that can be read by Microsoft's HTML Help Workshop
 # (see: http://www.microsoft.com/en-us/download/details.aspx?id=21138) on
 # Windows.
 #
 # The HTML Help Workshop contains a compiler that can convert all HTML output
 # generated by doxygen into a single compiled HTML file (.chm). Compiled HTML
 # files are now used as the Windows 98 help format, and will replace the old
 # Windows help format (.hlp) on all Windows platforms in the future. Compressed
 # HTML files also contain an index, a table of contents, and you can search for
 # words in the documentation. The HTML workshop also contains a viewer for
 # compressed HTML files.
 # The default value is: NO.
 # This tag requires that the tag GENERATE_HTML is set to YES.
 
 GENERATE_HTMLHELP      = NO
 
 # The CHM_FILE tag can be used to specify the file name of the resulting .chm
 # file. You can add a path in front of the file if the result should not be
 # written to the html output directory.
 # This tag requires that the tag GENERATE_HTMLHELP is set to YES.
 
 CHM_FILE               =
 
 # The HHC_LOCATION tag can be used to specify the location (absolute path
 # including file name) of the HTML help compiler ( hhc.exe). If non-empty
 # doxygen will try to run the HTML help compiler on the generated index.hhp.
 # The file has to be specified with full path.
 # This tag requires that the tag GENERATE_HTMLHELP is set to YES.
 
 HHC_LOCATION           =
 
 # The GENERATE_CHI flag controls if a separate .chi index file is generated (
 # YES) or that it should be included in the master .chm file ( NO).
 # The default value is: NO.
 # This tag requires that the tag GENERATE_HTMLHELP is set to YES.
 
 GENERATE_CHI           = NO
 
 # The CHM_INDEX_ENCODING is used to encode HtmlHelp index ( hhk), content ( hhc)
 # and project file content.
 # This tag requires that the tag GENERATE_HTMLHELP is set to YES.
 
 CHM_INDEX_ENCODING     =
 
 # The BINARY_TOC flag controls whether a binary table of contents is generated (
 # YES) or a normal table of contents ( NO) in the .chm file. Furthermore it
 # enables the Previous and Next buttons.
 # The default value is: NO.
 # This tag requires that the tag GENERATE_HTMLHELP is set to YES.
 
 BINARY_TOC             = NO
 
 # The TOC_EXPAND flag can be set to YES to add extra items for group members to
 # the table of contents of the HTML help documentation and to the tree view.
 # The default value is: NO.
 # This tag requires that the tag GENERATE_HTMLHELP is set to YES.
 
 TOC_EXPAND             = NO
 
 # If the GENERATE_QHP tag is set to YES and both QHP_NAMESPACE and
 # QHP_VIRTUAL_FOLDER are set, an additional index file will be generated that
 # can be used as input for Qt's qhelpgenerator to generate a Qt Compressed Help
 # (.qch) of the generated HTML documentation.
 # The default value is: NO.
 # This tag requires that the tag GENERATE_HTML is set to YES.
 
 GENERATE_QHP           = NO
 
 # If the QHG_LOCATION tag is specified, the QCH_FILE tag can be used to specify
 # the file name of the resulting .qch file. The path specified is relative to
 # the HTML output folder.
 # This tag requires that the tag GENERATE_QHP is set to YES.
 
 QCH_FILE               =
 
 # The QHP_NAMESPACE tag specifies the namespace to use when generating Qt Help
 # Project output. For more information please see Qt Help Project / Namespace
 # (see: http://qt-project.org/doc/qt-4.8/qthelpproject.html#namespace).
 # The default value is: org.doxygen.Project.
 # This tag requires that the tag GENERATE_QHP is set to YES.
 
 QHP_NAMESPACE          = org.doxygen.Project
 
 # The QHP_VIRTUAL_FOLDER tag specifies the namespace to use when generating Qt
 # Help Project output. For more information please see Qt Help Project / Virtual
 # Folders (see: http://qt-project.org/doc/qt-4.8/qthelpproject.html#virtual-
 # folders).
 # The default value is: doc.
 # This tag requires that the tag GENERATE_QHP is set to YES.
 
 QHP_VIRTUAL_FOLDER     = doc
 
 # If the QHP_CUST_FILTER_NAME tag is set, it specifies the name of a custom
 # filter to add. For more information please see Qt Help Project / Custom
 # Filters (see: http://qt-project.org/doc/qt-4.8/qthelpproject.html#custom-
 # filters).
 # This tag requires that the tag GENERATE_QHP is set to YES.
 
 QHP_CUST_FILTER_NAME   =
 
 # The QHP_CUST_FILTER_ATTRS tag specifies the list of the attributes of the
 # custom filter to add. For more information please see Qt Help Project / Custom
 # Filters (see: http://qt-project.org/doc/qt-4.8/qthelpproject.html#custom-
 # filters).
 # This tag requires that the tag GENERATE_QHP is set to YES.
 
 QHP_CUST_FILTER_ATTRS  =
 
 # The QHP_SECT_FILTER_ATTRS tag specifies the list of the attributes this
 # project's filter section matches. Qt Help Project / Filter Attributes (see:
 # http://qt-project.org/doc/qt-4.8/qthelpproject.html#filter-attributes).
 # This tag requires that the tag GENERATE_QHP is set to YES.
 
 QHP_SECT_FILTER_ATTRS  =
 
 # The QHG_LOCATION tag can be used to specify the location of Qt's
 # qhelpgenerator. If non-empty doxygen will try to run qhelpgenerator on the
 # generated .qhp file.
 # This tag requires that the tag GENERATE_QHP is set to YES.
 
 QHG_LOCATION           =
 
 # If the GENERATE_ECLIPSEHELP tag is set to YES, additional index files will be
 # generated, together with the HTML files, they form an Eclipse help plugin. To
 # install this plugin and make it available under the help contents menu in
 # Eclipse, the contents of the directory containing the HTML and XML files needs
 # to be copied into the plugins directory of eclipse. The name of the directory
 # within the plugins directory should be the same as the ECLIPSE_DOC_ID value.
 # After copying Eclipse needs to be restarted before the help appears.
 # The default value is: NO.
 # This tag requires that the tag GENERATE_HTML is set to YES.
 
 GENERATE_ECLIPSEHELP   = NO
 
 # A unique identifier for the Eclipse help plugin. When installing the plugin
 # the directory name containing the HTML and XML files should also have this
 # name. Each documentation set should have its own identifier.
 # The default value is: org.doxygen.Project.
 # This tag requires that the tag GENERATE_ECLIPSEHELP is set to YES.
 
 ECLIPSE_DOC_ID         = org.doxygen.Project
 
 # If you want full control over the layout of the generated HTML pages it might
 # be necessary to disable the index and replace it with your own. The
 # DISABLE_INDEX tag can be used to turn on/off the condensed index (tabs) at top
 # of each HTML page. A value of NO enables the index and the value YES disables
 # it. Since the tabs in the index contain the same information as the navigation
 # tree, you can set this option to YES if you also set GENERATE_TREEVIEW to YES.
 # The default value is: NO.
 # This tag requires that the tag GENERATE_HTML is set to YES.
 
 DISABLE_INDEX          = NO
 
 # The GENERATE_TREEVIEW tag is used to specify whether a tree-like index
 # structure should be generated to display hierarchical information. If the tag
 # value is set to YES, a side panel will be generated containing a tree-like
 # index structure (just like the one that is generated for HTML Help). For this
 # to work a browser that supports JavaScript, DHTML, CSS and frames is required
 # (i.e. any modern browser). Windows users are probably better off using the
 # HTML help feature. Via custom stylesheets (see HTML_EXTRA_STYLESHEET) one can
 # further fine-tune the look of the index. As an example, the default style
 # sheet generated by doxygen has an example that shows how to put an image at
 # the root of the tree instead of the PROJECT_NAME. Since the tree basically has
 # the same information as the tab index, you could consider setting
 # DISABLE_INDEX to YES when enabling this option.
 # The default value is: NO.
 # This tag requires that the tag GENERATE_HTML is set to YES.
 
 GENERATE_TREEVIEW      = NO
 
 # The ENUM_VALUES_PER_LINE tag can be used to set the number of enum values that
 # doxygen will group on one line in the generated HTML documentation.
 #
 # Note that a value of 0 will completely suppress the enum values from appearing
 # in the overview section.
 # Minimum value: 0, maximum value: 20, default value: 4.
 # This tag requires that the tag GENERATE_HTML is set to YES.
 
 ENUM_VALUES_PER_LINE   = 4
 
 # If the treeview is enabled (see GENERATE_TREEVIEW) then this tag can be used
 # to set the initial width (in pixels) of the frame in which the tree is shown.
 # Minimum value: 0, maximum value: 1500, default value: 250.
 # This tag requires that the tag GENERATE_HTML is set to YES.
 
 TREEVIEW_WIDTH         = 250
 
 # When the EXT_LINKS_IN_WINDOW option is set to YES doxygen will open links to
 # external symbols imported via tag files in a separate window.
 # The default value is: NO.
 # This tag requires that the tag GENERATE_HTML is set to YES.
 
 EXT_LINKS_IN_WINDOW    = NO
 
 # Use this tag to change the font size of LaTeX formulas included as images in
 # the HTML documentation. When you change the font size after a successful
 # doxygen run you need to manually remove any form_*.png images from the HTML
 # output directory to force them to be regenerated.
 # Minimum value: 8, maximum value: 50, default value: 10.
 # This tag requires that the tag GENERATE_HTML is set to YES.
 
 FORMULA_FONTSIZE       = 10
 
 # Use the FORMULA_TRANPARENT tag to determine whether or not the images
 # generated for formulas are transparent PNGs. Transparent PNGs are not
 # supported properly for IE 6.0, but are supported on all modern browsers.
 #
 # Note that when changing this option you need to delete any form_*.png files in
 # the HTML output directory before the changes have effect.
 # The default value is: YES.
 # This tag requires that the tag GENERATE_HTML is set to YES.
 
 FORMULA_TRANSPARENT    = YES
 
 # Enable the USE_MATHJAX option to render LaTeX formulas using MathJax (see
 # http://www.mathjax.org) which uses client side Javascript for the rendering
 # instead of using prerendered bitmaps. Use this if you do not have LaTeX
 # installed or if you want to formulas look prettier in the HTML output. When
 # enabled you may also need to install MathJax separately and configure the path
 # to it using the MATHJAX_RELPATH option.
 # The default value is: NO.
 # This tag requires that the tag GENERATE_HTML is set to YES.
 
 USE_MATHJAX            = NO
 
 # When MathJax is enabled you can set the default output format to be used for
 # the MathJax output. See the MathJax site (see:
 # http://docs.mathjax.org/en/latest/output.html) for more details.
 # Possible values are: HTML-CSS (which is slower, but has the best
 # compatibility), NativeMML (i.e. MathML) and SVG.
 # The default value is: HTML-CSS.
 # This tag requires that the tag USE_MATHJAX is set to YES.
 
 MATHJAX_FORMAT         = HTML-CSS
 
 # When MathJax is enabled you need to specify the location relative to the HTML
 # output directory using the MATHJAX_RELPATH option. The destination directory
 # should contain the MathJax.js script. For instance, if the mathjax directory
 # is located at the same level as the HTML output directory, then
 # MATHJAX_RELPATH should be ../mathjax. The default value points to the MathJax
 # Content Delivery Network so you can quickly see the result without installing
 # MathJax. However, it is strongly recommended to install a local copy of
 # MathJax from http://www.mathjax.org before deployment.
 # The default value is: http://cdn.mathjax.org/mathjax/latest.
 # This tag requires that the tag USE_MATHJAX is set to YES.
 
 MATHJAX_RELPATH        = http://cdn.mathjax.org/mathjax/latest
 
 # The MATHJAX_EXTENSIONS tag can be used to specify one or more MathJax
 # extension names that should be enabled during MathJax rendering. For example
 # MATHJAX_EXTENSIONS = TeX/AMSmath TeX/AMSsymbols
 # This tag requires that the tag USE_MATHJAX is set to YES.
 
 MATHJAX_EXTENSIONS     =
 
 # The MATHJAX_CODEFILE tag can be used to specify a file with javascript pieces
 # of code that will be used on startup of the MathJax code. See the MathJax site
 # (see: http://docs.mathjax.org/en/latest/output.html) for more details. For an
 # example see the documentation.
 # This tag requires that the tag USE_MATHJAX is set to YES.
 
 MATHJAX_CODEFILE       =
 
 # When the SEARCHENGINE tag is enabled doxygen will generate a search box for
 # the HTML output. The underlying search engine uses javascript and DHTML and
 # should work on any modern browser. Note that when using HTML help
 # (GENERATE_HTMLHELP), Qt help (GENERATE_QHP), or docsets (GENERATE_DOCSET)
 # there is already a search function so this one should typically be disabled.
 # For large projects the javascript based search engine can be slow, then
 # enabling SERVER_BASED_SEARCH may provide a better solution. It is possible to
 # search using the keyboard; to jump to the search box use  + S
 # (what the  is depends on the OS and browser, but it is typically
 # , /