From: Repo Admin Date: Mon, 6 Oct 2003 19:48:46 +0000 (+0000) Subject: This commit was manufactured by cvs2svn to create tag 'gpgme-0-4-3'. X-Git-Tag: gpgme-1.2.0@1385~516 X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=af50a9db4357ee1a1f26f5712b5d432ab495ed98;p=gpgme.git This commit was manufactured by cvs2svn to create tag 'gpgme-0-4-3'. --- diff --git a/tags/gpgme-0-4-3/AUTHORS b/tags/gpgme-0-4-3/AUTHORS new file mode 100644 index 0000000..f948079 --- /dev/null +++ b/tags/gpgme-0-4-3/AUTHORS @@ -0,0 +1,28 @@ +Package: gpgme +Maintainer: Marcus Brinkmann +Bug reports: bug-gpgme@gnupg.org +Security related bug reports: security@gnupg.org + + +FSF + - Code taken from GnuPG 1.0: gpgme/w32-util.c, GnuPG 1.1: jnlib/. + +g10 Code GmbH + - All stuff since mid march 2001. + +Werner Koch + - Design and most stuff. + +Wojciech Polak + - gpgme.spec + + + Copyright 2001, 2002 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/tags/gpgme-0-4-3/ChangeLog b/tags/gpgme-0-4-3/ChangeLog new file mode 100644 index 0000000..d88dc48 --- /dev/null +++ b/tags/gpgme-0-4-3/ChangeLog @@ -0,0 +1,429 @@ +2003-10-06 Marcus Brinkmann + + Released 0.4.3. + + * configure.ac (LIBGPGME_LT_CURRENT, LIBGPGME_LT_AGE): Bump up by 1. + (LIBGPGME_LT_REVISION): Set to 0. + +2003-09-13 Marcus Brinkmann + + * configure.ac: Require libgpg-error 0.5. + + * acinclude.m4: Remove libtool cruft, add jm_GLIBC21. + * configure.ac: Add check for getenv_r, and call jm_GLIBC21. + Define HAVE_THREAD_SAFE_GETENV if appropriate. + +2003-09-03 Marcus Brinkmann + + * configure.ac: Remove GPGME_CONFIG_LIBS and GPGME_CONFIG_CFLAGS. + +2003-09-02 Marcus Brinkmann + + * configure.ac: Move invocation of AC_CANONICAL_HOST up to + suppress warning by autoconf. + +2003-08-30 Robert Schiele + + * gpgme.spec.in: %{_infodir}/dir is not packaged, + remove to prevent checking failure. + +2003-08-18 Marcus Brinkmann + + * configure.ac: If building Assuan, check for funopen and + fopencookie, and make isascii, putc_unlocked and memrchr + replacement functions. + (AM_PATH_GPG_ERROR): Require 0.3. + +2003-07-31 Marcus Brinkmann + + * configure.ac (AC_INIT): Bump version to 0.4.3. + +2003-07-30 Marcus Brinkmann + + * configure.ac (LIBGPGME_LT_REVISION): Bump up to 1. + + Released 0.4.2. + +2003-07-08 Marcus Brinkmann + + * configure.ac: Complain if libgpg-error is not found. + +2003-06-22 Marcus Brinkmann + + * configure.ac (AC_INIT): Bump version to 0.4.2. + +2003-06-06 Marcus Brinkmann + + * configure.ac (LIBGPGME_LT_CURRENT): Bump up to 11. + + * configure.ac: Use AM_PATH_GPG_ERROR. + + * configure.ac: Check for libgpg-error. Define + GPG_ERR_SOURCE_DEFAULT. + +2003-05-26 Marcus Brinkmann + + * configure.ac (NEED_GPG_VERSION): Bump up to 1.2.2. + +2003-05-18 Marcus Brinkmann + + In all files, replace the Gpgme* type names with the new gpgme_* + type names. + +2003-02-01 Marcus Brinkmann + + * assuan/: Update files to 2002-11-10 version of assuan. + +2003-01-29 Marcus Brinkmann + + * bonobo/gpgme.c, bonobo/main.c, bonobo/main.h, bonobo/Makefile, + bonobo/Makefile.am, bonobo/Makefile.in: Dead files removed. + * configure.ac: Remove automake conditional BUILD_BONOBO + (AC_CONFIG_FILES): Remove bonobo/Makefile. + * Makefile.am (bonobo): Remove variable. + (SUBDIRS): Remove ${bonobo}. + + * configure.ac: Remove all uses of GNUPG_CHECK_TYPEDEF, for byte, + ushort, ulong, u16 and u32. + * acinclude.m4 (GNUPG_CHECK_TYPEDEF): Remove macro. + +2002-12-24 Marcus Brinkmann + + * configure.ac: New conditional HAVE_LD_VERSION_SCRIPT. + Call AC_CANONICAL_HOST, use host instead target. + +2002-12-23 Marcus Brinkmann + + * configure.ac: Bump up to 0.4.1. + + Released 0.4.0. + +2002-12-23 Marcus Brinkmann + + * autogen.sh (automake_vers): Require 1.7 (really 1.7.1) for the + conditional source distribution bug fix. + +2002-12-08 Marcus Brinkmann + + * configure.ac (LIBGPGME_LT_CURRENT): Increase by one. + (LIBGPGME_LT_AGE, LIBGPGME_LT_REVISION): Set to 0. + +2002-11-28 Marcus Brinkmann + + * NEWS: Add note about moving "gpgmeplug" to the "cryptplug" + package. + * README: Remove instructions related to "gpgmeplug". + * configure.ac: Remove enable option "gpgmeplug" and automake + conditional BUILD_GPGMEPLUG, as well as the status info about it. + (GPGMEPLUG): Remove variable. + * Makefile.am (gpgmeplug): Remove variable. + (SUBDIRS): Remove ${gpgmeplug}. + * cryptplug.h, gpgme-openpgp.c, gpgmeplug.dox, gpgme-smime.c, + Makefile.am, gpgmeplug.c, ChangeLog: Files removed. + +2002-11-22 Marcus Brinkmann + + * configure.ac: Disable GPGSM for all dosish systems. + +2002-10-12 Marcus Brinkmann + + * configure.ac: Add automake conditional HAVE_GPGSM. + +2002-10-08 Marcus Brinkmann + + * configure.ac (AC_INIT): Bump version up to 0.4.0. + (NEED_GPG_VERSION): Bump up to 1.2.0. + (NEED_GPGSM_VERSION): Bump up to 0.9.0. + * README: Update version numbers. + * NEWS: Start entry for 0.4.0. + +2002-09-20 Werner Koch + + Released 0.3.11. + + * configure.ac: Bump up LIBGPGME_LT_REVISION. + + * configure.ac (AC_CHECK_HEADERS): Check for sys/select.h. + +2002-09-04 Marcus Brinkmann + + * autogen.sh (autoconf_vers): Bump up to 2.53 to get the @&t@ + quadrigraph. Always cutting the edge! + +2002-09-02 Marcus Brinkmann + + * configure.ac: Create and substitute LTLIBOBJS. + +2002-09-02 Marcus Brinkmann + + Released 0.3.10. + + * NEWS: Update for 0.3.9 release. + * configure.ac: Bump up LIBGPGME_LT_REVISION. + +2002-08-29 Marcus Brinkmann + + * gpgme.spec.in: Changed user name in Wojciech Polak's email + address from ghostface to polak per request by himself. + +2002-08-28 Werner Koch + + * acinclude.m4 (GNUPG_CHECK_VA_COPY): New. + * configure.ac: Use it. + +2002-08-23 Werner Koch + + * configure.ac (GPGME_CONFIG_CFLAGS): Renamed from GPGME_CFLAGS + and removed the libpath because it is set by the config script. + +2002-08-21 Marcus Brinkmann + + * configure.ac: Bump version number to 0.3.10. + + * NEWS: Add template for development version. + +2002-08-21 Marcus Brinkmann + + Released 0.3.9. + + * NEWS: Update for 0.3.9 release. + * Makefile.am (EXTRA_DIST): Add gpgme.spec.in. + +2002-08-21 Marcus Brinkmann + + * jnlib/argparse.c, jnlib/argparse.h, jnlib/ChangeLog, + jnlib/dotlock.c, jnlib/dotlock.h, jnlib/libjnlib-config.h, + jnlib/logging.c, jnlib/logging.h,jnlib/Makefile.am, + jnlib/mischelp.h, jnlib/README, jnlib/stringhelp.c, + jnlib/stringhelp.h, jnlib/strlist.c, jnlib/strlist.h, + jnlib/types.h, jnlib/xmalloc.c, jnlib/xmalloc.h: Remove files. + +2002-08-21 Marcus Brinkmann + + * Makefile.am (SUBDIRS): Remove jnlib. + * configure.ac: Don't check for unsigned short or unsigned long. + Don't check for memicmp, strlwr, strtoul, memmove, stricmp. + Make stpcpy a replaced function. + Don't define HAVE_JNLIB_LOGGING. + Don't generate jnlib/Makefile. + +2002-07-02 Werner Koch + + * configure.ac: Bumbed version number to 0.3.9; add a comment on + when to change it. + + * gpgme.spec.in: New. Contributed by Wojciech Polak. + * Makefile.am (dist-hook): New. + + * AUTHORS: Added Wojciech and bug reporting addresses. + +2002-06-25 Werner Koch + + Released 0.3.8. + + * configure.ac: Bumbed LT version to 9/3/0. + (NEED_GPGSM_VERSION): Need 0.3.8 due to fixed export command. + +2002-06-04 Marcus Brinkmann + + Released 0.3.7. + + * configure.ac (AC_INIT): Set version to 0.3.7. + (LIBGPGME_LT_REVISION): Add one. + + * README: Document version requirement correctly. + +2002-06-02 Marcus Brinkmann + + * acinclude.m4: Fix Pth check so that it doesn't error out if pth + is not found. + +2002-06-02 Marcus Brinkmann + + * configure.ac: Add checks for Pth and pthreads. + * acinclude.m4: Add slightly hacked check for pth (seems to be an + autoconf version problem). + +2002-05-21 Werner Koch + + * configure.ac (NEED_GPGSM_VERSION): We need gpgsm 0.3.7. + +2002-05-03 Werner Koch + + Released 0.3.6. + +2002-04-05 Marcus Brinkmann + + * acconfig.h: File removed. + * configure.ac (NEED_GPG_VERSION): Add description. + (NEED_GPGSM_VERSION): Likewise. + (HAVE_DOSISH_SYSTEM): Likewise. + (HAVE_DRIVE_LETTERS): Likewise. + (GPG_PATH): Likewise. + (GPGSM_PATH): Likewise. + * acinclude.m4 (GNUPG_CHECK_TYPEDEF): Likewise. + +2002-04-01 Werner Koch + + Released 0.3.5. + +2002-03-17 Marcus Brinkmann + + * configure.ac: Add automake conditional HAVE_DOSISH_SYSTEM. + +2002-03-04 Werner Koch + + * configure.ac: Bumbed version to 0.3.4-cvs to continue development. + + Released 0.3.4. + + * configure.ac: Bumbed LT version numbers to (7,1,0), requires + gpgsm 0.3.1. + +2002-03-03 Marcus Brinkmann + + * configure.ac (AC_INIT): Change version number to snapshot CVS + version. + +2002-02-13 Werner Koch + + * configure.ac (vasprintf,fopencookie): Add checks. + +2002-02-12 Marcus Brinkmann + + * configure.ac (AC_INIT): Bump version to 0.3.3. + * jnlib/Makefile.am: Rever to older version that includes xmalloc + but not dotlock and some other files. Reported by Stéphane + Corthésy. + +2002-02-10 Marcus Brinkmann + + * Released 0.3.2. + + * configure.ac (AC_INIT): Bump version to 0.3.2. + * jnlib/libjnlibconfig.h: Revert to older version that doesn't + expect libgcrypt. Reported by Jose Carlos Garcia Sogo + . + +2002-02-09 Marcus Brinkmann + + * Released 0.3.1. + + * configure.ac (LIBGPGME_LT_CURRENT): Bump it up to 6! + (NEED_GPGSM_VERSION): Bump it up to 0.3.0! + (AC_INIT): Bump version to 0.3.1 + +2002-01-22 Marcus Brinkmann + + * configure.ac (HAVE_JNLIB_LOGGING): Define always for assuan. + +2001-12-19 Werner Koch + + * configure.ac (VERSION,PACKAGE): Defined and subst. Used for + AM_INIT_AUTOMAKE and moved all version number more to the top. + +2001-12-18 Marcus Brinkmann + + * autogen.sh (libtool_vers): Bump to 1.4. + + * configure.ac (LIBGPGME_LT_CURRENT): Increment. + (LIBGPGME_LT_AGE): Reset. + Improve comment. + Fix wrong comment character. + +2001-12-18 Werner Koch + + * acinclude.m4 (GNUPG_FIX_HDR_VERSION): Fixed for new automake. + +2001-12-14 Marcus Brinkmann + + * configure.ac (GPG): Substitute this variable. + (GPGSM): Likewise. + +2001-11-22 Marcus Brinkmann + + * configure.ac (AC_CONFIG_FILES): Add tests/gpg/Makefile and + tests/gpgsm/Makefile. + +2001-11-21 Marcus Brinkmann + + * Makefile.am (gpgmeplug): New variable, set to gpgmeplug if + [BUILD_GPGMEPLUG]. + * configure.ac (AC_CONFIG_FILES): Add gpgmeplug/Makefile. + Support --enable-gpgmeplug. + +2001-11-21 Marcus Brinkmann + + * autogen.sh: Tighten version dependencies. + +2001-11-20 Marcus Brinkmann + + * Makefile.am (SUBDIRS): Support building the assuan library + (currently if GPGSM_PATH is set).. + * configure.ac: Support building the assuan library. + * assuan: New directory, populated with the Assuan library + (copied from the newpg repository). + +2001-11-20 Marcus Brinkmann + + * configure.ac (NEED_GPGSM_VERSION): New variable. Treat it + similarly to NEED_GPG_VERSION. + * acconfig.h: Likewise. + +2001-11-18 Marcus Brinkmann + + * configure.in: Renamed to ... + * configure.ac: ... this. Update to autoconf 2.52. Lots of small + changes in the transition. Support --with-gpg=PATH and + --with-gpgsm=PATH options. Check if test suites can be run. + * acconfig.h: Add GPGSM_PATH. + * Makefile.am: New variable `tests', set to `tests' if + RUN_GPG_TESTS. + (SUBDIRS): Replace string `tests' with variable `tests'. + +2001-10-22 Marcus Brinkmann + + * autogen.sh: Invoke automake with `-a' (add missing files). + Do not invoke configure. + +2001-09-17 Werner Koch + + Released 0.2.3. + + * configure.in (NEED_GPG_VERSION): Set to 1.0.6. Incremented LT + current and age. + + * Makefile.am (SUBDIRS): Add doc + +2001-06-12 Werner Koch + + Released 0.2.2. + +2001-04-05 Werner Koch + + * configure.in (NEED_GPG_VERSION): Set to 1.0.4g + +2001-04-02 Werner Koch + + Released 0.2.1. + + Changed the copyright notices all over the place. + +2001-02-28 Werner Koch + + Released 0.2.0. + +2001-01-18 Werner Koch + + * autogen.sh: Added option --build-w32. + + + Copyright 2001, 2002 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/tags/gpgme-0-4-3/Makefile.am b/tags/gpgme-0-4-3/Makefile.am new file mode 100644 index 0000000..f1f2be7 --- /dev/null +++ b/tags/gpgme-0-4-3/Makefile.am @@ -0,0 +1,50 @@ +# Copyright (C) 2000 Werner Koch (dd9jn) +# Copyright (C) 2001, 2002 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 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA + +## Process this file with automake to produce Makefile.in + +EXTRA_DIST = README-alpha autogen.sh gpgme.spec.in + +if BUILD_ASSUAN +assuan = assuan +else +assuan = +endif + +if BUILD_COMPLUS +complus = complus +else +complus = +endif + +if RUN_GPG_TESTS +tests = tests +else +tests = +endif + +SUBDIRS = ${assuan} gpgme ${tests} doc ${complus} + +# Fix the version of the spec file and create a file named VERSION +# to be used for patch's Prereq: feature. +dist-hook: + @set -e; \ + sed -e 's/@pkg_version@/$(VERSION)/g' \ + $(top_srcdir)/gpgme.spec.in > $(distdir)/gpgme.spec + echo "$(VERSION)" > $(distdir)/VERSION diff --git a/tags/gpgme-0-4-3/NEWS b/tags/gpgme-0-4-3/NEWS new file mode 100644 index 0000000..c112485 --- /dev/null +++ b/tags/gpgme-0-4-3/NEWS @@ -0,0 +1,865 @@ +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 + 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_sub_key_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.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 + 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 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/tags/gpgme-0-4-3/README b/tags/gpgme-0-4-3/README new file mode 100644 index 0000000..02739c3 --- /dev/null +++ b/tags/gpgme-0-4-3/README @@ -0,0 +1,39 @@ + GPGME - GnuPG Made Easy + --------------------------- + + !!!! THIS IS WORK IN PROGRESS !!! + +If you want to hack on it, start with one of the `tests/gpg/t-foo' +programs. + +To build GPGME, you need to install libgpg-error. You need at least +libgpg-error 0.5. + +For support of the OpenPGP protocol (default), you need the latest CVS +version of GnuPG 1.2, see `http://www.gnupg.org/cvs-access.html'. + +You need at least GnuPG 1.2.2. + +If configure can't find the `gpg' binary in your path, you can specify +the location with the --with-gpg=/path/to/gpg argument to configure. + +For support of the CMS (Cryptographic Message Syntax) protocol, you +need the latest CVS version of GpgSM, module name `newpg', at +`:pserver:anoncvs@cvs.gnupg.org:/cvs/aegypten'. + +You need at least GpgSM 0.9.0. + +If configure can't find the `gpgsm' binary in your path, you can +specify the location with the --with-gpgsm=/path/to/gpgsm argument to +configure. + +Before building the CVS version following the generic install +instructions in `INSTALL', you need to set up the build scripts with +`./autogen.sh'. To build the W32 version, use `./autogen.sh +--build-w32'. You also need to enable maintainer mode at configure +time with `--enable-maintainer-mode', or the documentation will not +built (because the version.texi won't be generated unless maintainer +mode is enabled). + +Please subscribe to the gnupg-devel@gnupg.org mailing list if you want +to do serious work. diff --git a/tags/gpgme-0-4-3/README-alpha b/tags/gpgme-0-4-3/README-alpha new file mode 100644 index 0000000..0f748e3 --- /dev/null +++ b/tags/gpgme-0-4-3/README-alpha @@ -0,0 +1 @@ + THIS IS WORK IN PROGRESS !!!! \ No newline at end of file diff --git a/tags/gpgme-0-4-3/THANKS b/tags/gpgme-0-4-3/THANKS new file mode 100644 index 0000000..414927b --- /dev/null +++ b/tags/gpgme-0-4-3/THANKS @@ -0,0 +1,23 @@ + +Alfons Hoogervorst alfons@proteus.demon.nl +Enno Cramer uebergeek@web.de +Frank Heckenbach frank@g-n-u.de +Jan-Oliver Wagner jan@intevation.de +Johannes Poehlmann jhp@caldera.de +Jose C. García Sogo jose@jaimedelamo.eu.org +Mark Mutz mutz@kde.org +Miguel Coca mcoca@gnu.org +Stéphane Corthésy stephane@sente.ch +Timo Schulz twoaday@freakmail.de +Tommy Reynolds reynolds@redhat.com + + + Copyright 2001, 2002 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/tags/gpgme-0-4-3/TODO b/tags/gpgme-0-4-3/TODO new file mode 100644 index 0000000..80f4b85 --- /dev/null +++ b/tags/gpgme-0-4-3/TODO @@ -0,0 +1,139 @@ +Hey Emacs, this is -*- outline -*- mode! + +* Before release: +** currently nothing + +* ABI's to break: +** I/O and User Data could be made extensible. But this can be done + without breaking the ABI hopefully. +** Compatibility interfaces that can be removed in future versions: +*** ath compatibility modules. +*** gpgme_data_new_from_filepart +*** gpgme_data_new_from_file +*** gpgme_data_new_with_read_cb +*** gpgme_data_rewind +*** gpgme_op_import_ext +*** gpgme_get_sig_key +*** gpgme_get_sig_ulong_attr +*** gpgme_get_sig_string_attr +*** GPGME_SIG_STAT_* +*** gpgme_get_sig_status +*** gpgme_trust_item_release +*** gpgme_trust_item_get_string_attr +*** gpgme_trust_item_get_ulong_attr +*** gpgme_attr_t +*** All Gpgme* typedefs. + +* Thread support: +** When GNU Pth supports sendmsg/recvmsg, wrap them properly. + +* New features: +** notification system + 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 + contextes of course. +** --learn-code support + 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. +** How to terminate a pending operation? Something like gpgme_op_reset, + but where are you allowed to call it (think callback handlers). + Then gpgme_op_*list_end can go. Update: The only place where this + can go is returning errors from callback handlers, and a function + to be called for example from the user event loop code. The user + must observe the threading rules! A blocking thread can not be + cancelled. +** Might need a stat() for data objects and use it for length param to gpg. +** Allow to export secret keys. +** Implement support for photo ids. +** New features requested by our dear users, but rejected or left for + later consideration: +*** Selecting the key ring, setting the version or comment in output. + 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. +*** Exchanging keys with key servers. + +* Documentation +** Document validity and trust issues. + +* Engines +** Do not create/destroy engines, but create engine and then reset it. + 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?) +** Optimize the case where a data object has an underlying fd we can pass + 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. +** engine operations can return General Error on unknown protocol + (it's an internal error, as select_protocol checks already). +** When server mode is implemented properly, more care has to be taken to + release all resources on error (for example to free assuan_cmd). + +* Operations +** If an operation failed, make sure that the result functions don't return + corrupt partial information. !!! + NOTE: The EOF status handler is not called in this case !!! +** If no passphrase cb is installed, status handler is not run even if + password is required by crypto engine. !! +** Verify must not fail on NODATA premature if auto-key-retrieval failed. + It should not fail silently if it knows there is an error. !!! +** All operations: Better error reporting. !! +** Export status handler need much more work. !!! +** Import should return a useful error when one happened. +*** Import does not take notice of NODATA status report. +*** When GPGSM does issue IMPORT_OK status reports, make sure to check for + them in tests/gpgs m/t-import.c. +** Verify can include info about version/algo/class, but currently + this is only available for gpg, not gpgsm. +** Return ENC_TO output in verify result. Again, this is not available + for gpgsm. +** Genkey should return something more useful than General_Error. +** Decrypt: + On Fri, Jun 27, 2003 at 06:28:23PM +0200, Heiko Abraham wrote: + > I have a cipher text and I use 'gpgme_op_decrypt_verify(..)' + > for decrypt and get the plaintext. But also I wish a list + > of all reciepient, that can also decrypt this file. + > + > If I store the file and check it with 'gpg --list-packets ${filename}' + > then I will become also a recipient-list. + > It this also possible with gpgme? + + Currently not, but it is easy to add this to GPGME 0.4.1. At least the key + ID and a user ID hint is available from gpg (of course key IDs are not + necessarily unique!). I will put it on the TODO list. +** If possible, use --file-setsize to set the file size for proper progress + callback handling. Write data interface for file size. +** Optimize the file descriptor list, so the number of open fds is + always known easily. +** Encryption: It should be verified that the behaviour for partially untrusted + recipients is correct. +** When GPG issues INV_something for invalid signers, catch them. + +* Error Values +** Map ASSUAN/GpgSM ERR error values in a better way than is done now. !! +** Some error values should identify the source more correctly (mostly error + values derived from status messages). + +* Tests +** Write a fake gpg-agent so that we can supply known passphrases to + 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 +*** Test gpgme_data_release_and_get_mem. +*** Test gpgme_data_seek for invalid types. + +* Debug +** Handle malloc and vasprintf errors. But decide first if they should be + ignored (and logged with 255?!), or really be assertions. ! + +* Build suite +** Make sure everything is cleaned correctly (esp. test area). +** Cofnigure test for gpg and gpgsm version (as a warning). diff --git a/tags/gpgme-0-4-3/acinclude.m4 b/tags/gpgme-0-4-3/acinclude.m4 new file mode 100644 index 0000000..30ee8ca --- /dev/null +++ b/tags/gpgme-0-4-3/acinclude.m4 @@ -0,0 +1,501 @@ +dnl Macros to configure gpgme + +dnl GNUPG_FIX_HDR_VERSION(FILE, NAME) +dnl Make the version number in gcrypt/gcrypt.h the same as the one here. +dnl (this is easier than to have a .in file just for one substitution) +dnl We must use a temp file in the current directory because make distcheck +dnl install all sourcefiles RO. +dnl (wk 2001-12-18) +AC_DEFUN(GNUPG_FIX_HDR_VERSION, + [ sed "s/^#define $2 \".*/#define $2 \"$VERSION\"/" $srcdir/$1 > fixhdr.tmp + if cmp -s $srcdir/$1 fixhdr.tmp 2>/dev/null; then + rm -f fixhdr.tmp + else + rm -f $srcdir/$1 + if mv fixhdr.tmp $srcdir/$1 ; then + : + else + AC_MSG_ERROR([[ +*** +*** Failed to fix the version string macro $2 in $1. +*** The old file has been saved as fixhdr.tmp +***]]) + fi + AC_MSG_WARN([fixed the $2 macro in $1]) + fi + ]) + + +dnl ## +dnl ## GNU Pth - The GNU Portable Threads +dnl ## Copyright (c) 1999-2002 Ralf S. Engelschall +dnl ## +dnl ## This file is part of GNU Pth, a non-preemptive thread scheduling +dnl ## library which can be found at http://www.gnu.org/software/pth/. +dnl ## +dnl ## This library is free software; you can redistribute it and/or +dnl ## modify it under the terms of the GNU Lesser General Public +dnl ## License as published by the Free Software Foundation; either +dnl ## version 2.1 of the License, or (at your option) any later version. +dnl ## +dnl ## This library is distributed in the hope that it will be useful, +dnl ## but WITHOUT ANY WARRANTY; without even the implied warranty of +dnl ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +dnl ## Lesser General Public License for more details. +dnl ## +dnl ## You should have received a copy of the GNU Lesser General Public +dnl ## License along with this library; if not, write to the Free Software +dnl ## Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 +dnl ## USA, or contact Ralf S. Engelschall . +dnl ## +dnl ## pth.m4: Autoconf macro for locating GNU Pth from within +dnl ## configure.in of third-party software packages +dnl ## + +dnl ## +dnl ## Synopsis: +dnl ## AC_CHECK_PTH([MIN-VERSION [, # minimum Pth version, e.g. 1.2.0 +dnl ## DEFAULT-WITH-PTH [, # default value for --with-pth option +dnl ## DEFAULT-WITH-PTH-TEST [,# default value for --with-pth-test option +dnl ## EXTEND-VARS [, # whether CFLAGS/LDFLAGS/etc are extended +dnl ## ACTION-IF-FOUND [, # action to perform if Pth was found +dnl ## ACTION-IF-NOT-FOUND # action to perform if Pth was not found +dnl ## ]]]]]]) +dnl ## Examples: +dnl ## AC_CHECK_PTH(1.2.0) +dnl ## AC_CHECK_PTH(1.2.0,,,no,CFLAGS="$CFLAGS -DHAVE_PTH $PTH_CFLAGS") +dnl ## AC_CHECK_PTH(1.2.0,yes,yes,yes,CFLAGS="$CFLAGS -DHAVE_PTH") +dnl ## +dnl +dnl # auxilliary macros +AC_DEFUN(_AC_PTH_ERROR, [dnl +AC_MSG_RESULT([*FAILED*]) +dnl define(_ac_pth_line,dnl +dnl "+------------------------------------------------------------------------+") +dnl echo " _ac_pth_line" 1>&2 +cat <>/ /' 1>&2 +$1 +EOT +dnl echo " _ac_pth_line" 1>&2 +dnl undefine(_ac_pth_line) +exit 1 +]) +AC_DEFUN(_AC_PTH_VERBOSE, [dnl +if test ".$verbose" = .yes; then + AC_MSG_RESULT([ $1]) +fi +]) +dnl # the user macro +AC_DEFUN(AC_CHECK_PTH, [dnl +dnl +dnl # prerequisites +AC_REQUIRE([AC_PROG_CC])dnl +AC_REQUIRE([AC_PROG_CPP])dnl +dnl +PTH_CPPFLAGS='' +PTH_CFLAGS='' +PTH_LDFLAGS='' +PTH_LIBS='' +AC_SUBST(PTH_CPPFLAGS) +AC_SUBST(PTH_CFLAGS) +AC_SUBST(PTH_LDFLAGS) +AC_SUBST(PTH_LIBS) +dnl # command line options +AC_MSG_CHECKING(for GNU Pth) +_AC_PTH_VERBOSE([]) +AC_ARG_WITH(pth,dnl +[ --with-pth[=ARG] Build with GNU Pth Library (default=]ifelse([$2],,yes,$2)[)],dnl +,dnl +with_pth="ifelse([$2],,yes,$2)" +)dnl +AC_ARG_WITH(pth-test,dnl +[ --with-pth-test Perform GNU Pth Sanity Test (default=]ifelse([$3],,yes,$3)[)],dnl +,dnl +with_pth_test="ifelse([$3],,yes,$3)" +)dnl +_AC_PTH_VERBOSE([+ Command Line Options:]) +_AC_PTH_VERBOSE([ o --with-pth=$with_pth]) +_AC_PTH_VERBOSE([ o --with-pth-test=$with_pth_test]) +dnl +dnl # configuration +if test ".$with_pth" != .no; then + _pth_subdir=no + _pth_subdir_opts='' + case "$with_pth" in + subdir:* ) + _pth_subdir=yes + changequote(, )dnl + _pth_subdir_opts=`echo $with_pth | sed -e 's/^subdir:[^ ]*[ ]*//'` + with_pth=`echo $with_pth | sed -e 's/^subdir:\([^ ]*\).*$/\1/'` + changequote([, ])dnl + ;; + esac + _pth_version="" + _pth_location="" + _pth_type="" + _pth_cppflags="" + _pth_cflags="" + _pth_ldflags="" + _pth_libs="" + if test ".$with_pth" = .yes; then + # via config script in $PATH + changequote(, )dnl + _pth_version=`(pth-config --version) 2>/dev/null |\ + sed -e 's/^.*\([0-9]\.[0-9]*[ab.][0-9]*\).*$/\1/'` + changequote([, ])dnl + if test ".$_pth_version" != .; then + _pth_location=`pth-config --prefix` + _pth_type='installed' + _pth_cppflags=`pth-config --cflags` + _pth_cflags=`pth-config --cflags` + _pth_ldflags=`pth-config --ldflags` + _pth_libs=`pth-config --libs` + fi + elif test -d "$with_pth"; then + with_pth=`echo $with_pth | sed -e 's;/*$;;'` + _pth_found=no + # via locally included source tree + if test ".$_pth_subdir" = .yes; then + _pth_location="$with_pth" + _pth_type='local' + _pth_cppflags="-I$with_pth" + _pth_cflags="-I$with_pth" + if test -f "$with_pth/ltconfig"; then + _pth_ldflags="-L$with_pth/.libs" + else + _pth_ldflags="-L$with_pth" + fi + _pth_libs="-lpth" + changequote(, )dnl + _pth_version=`grep '^const char PTH_Hello' $with_pth/pth_vers.c |\ + sed -e 's;^.*Version[ ]*\([0-9]*\.[0-9]*[.ab][0-9]*\)[ ].*$;\1;'` + changequote([, ])dnl + _pth_found=yes + ac_configure_args="$ac_configure_args --enable-subdir $_pth_subdir_opts" + with_pth_test=no + fi + # via config script under a specified directory + # (a standard installation, but not a source tree) + if test ".$_pth_found" = .no; then + for _dir in $with_pth/bin $with_pth; do + if test -f "$_dir/pth-config"; then + test -f "$_dir/pth-config.in" && continue # pth-config in source tree! + changequote(, )dnl + _pth_version=`($_dir/pth-config --version) 2>/dev/null |\ + sed -e 's/^.*\([0-9]\.[0-9]*[ab.][0-9]*\).*$/\1/'` + changequote([, ])dnl + if test ".$_pth_version" != .; then + _pth_location=`$_dir/pth-config --prefix` + _pth_type="installed" + _pth_cppflags=`$_dir/pth-config --cflags` + _pth_cflags=`$_dir/pth-config --cflags` + _pth_ldflags=`$_dir/pth-config --ldflags` + _pth_libs=`$_dir/pth-config --libs` + _pth_found=yes + break + fi + fi + done + fi + # in any subarea under a specified directory + # (either a special installation or a Pth source tree) + if test ".$_pth_found" = .no; then + changequote(, )dnl + _pth_found=0 + for _file in x `find $with_pth -name "pth.h" -type f -print`; do + test .$_file = .x && continue + _dir=`echo $_file | sed -e 's;[^/]*$;;' -e 's;\(.\)/$;\1;'` + _pth_version=`($_dir/pth-config --version) 2>/dev/null |\ + sed -e 's/^.*\([0-9]\.[0-9]*[ab.][0-9]*\).*$/\1/'` + if test ".$_pth_version" = .; then + _pth_version=`grep '^#define PTH_VERSION_STR' $_file |\ + sed -e 's;^#define[ ]*PTH_VERSION_STR[ ]*"\([0-9]*\.[0-9]*[.ab][0-9]*\)[ ].*$;\1;'` + fi + _pth_cppflags="-I$_dir" + _pth_cflags="-I$_dir" + _pth_found=`expr $_pth_found + 1` + done + for _file in x `find $with_pth -name "libpth.[aso]" -type f -print`; do + test .$_file = .x && continue + _dir=`echo $_file | sed -e 's;[^/]*$;;' -e 's;\(.\)/$;\1;'` + _pth_ldflags="-L$_dir" + _pth_libs="-lpth" + _pth_found=`expr $_pth_found + 1` + done + changequote([, ])dnl + if test ".$_pth_found" = .2; then + _pth_location="$with_pth" + _pth_type="uninstalled" + else + _pth_version='' + fi + fi + fi + _AC_PTH_VERBOSE([+ Determined Location:]) + _AC_PTH_VERBOSE([ o path: $_pth_location]) + _AC_PTH_VERBOSE([ o type: $_pth_type]) + if test ".$_pth_version" = .; then + with_pth=no + else +dnl if test ".$with_pth" != .yes; then +dnl _AC_PTH_ERROR([dnl +dnl Unable to locate GNU Pth under $with_pth. +dnl Please specify the correct path to either a GNU Pth installation tree +dnl (use --with-pth=DIR if you used --prefix=DIR for installing GNU Pth in +dnl the past) or to a GNU Pth source tree (use --with-pth=DIR if DIR is a +dnl path to a pth-X.Y.Z/ directory; but make sure the package is already +dnl built, i.e., the "configure; make" step was already performed there).]) +dnl else +dnl _AC_PTH_ERROR([dnl +dnl Unable to locate GNU Pth in any system-wide location (see \$PATH). +dnl Please specify the correct path to either a GNU Pth installation tree +dnl (use --with-pth=DIR if you used --prefix=DIR for installing GNU Pth in +dnl the past) or to a GNU Pth source tree (use --with-pth=DIR if DIR is a +dnl path to a pth-X.Y.Z/ directory; but make sure the package is already +dnl built, i.e., the "configure; make" step was already performed there).]) +dnl fi +dnl fi + dnl # + dnl # Check whether the found version is sufficiently new + dnl # + _req_version="ifelse([$1],,1.0.0,$1)" + for _var in _pth_version _req_version; do + eval "_val=\"\$${_var}\"" + _major=`echo $_val | sed 's/\([[0-9]]*\)\.\([[0-9]]*\)\([[ab.]]\)\([[0-9]]*\)/\1/'` + _minor=`echo $_val | sed 's/\([[0-9]]*\)\.\([[0-9]]*\)\([[ab.]]\)\([[0-9]]*\)/\2/'` + _rtype=`echo $_val | sed 's/\([[0-9]]*\)\.\([[0-9]]*\)\([[ab.]]\)\([[0-9]]*\)/\3/'` + _micro=`echo $_val | sed 's/\([[0-9]]*\)\.\([[0-9]]*\)\([[ab.]]\)\([[0-9]]*\)/\4/'` + case $_rtype in + "a" ) _rtype=0 ;; + "b" ) _rtype=1 ;; + "." ) _rtype=2 ;; + esac + _hex=`echo dummy | awk '{ printf("%d%02d%1d%02d", major, minor, rtype, micro); }' \ + "major=$_major" "minor=$_minor" "rtype=$_rtype" "micro=$_micro"` + eval "${_var}_hex=\"\$_hex\"" + done + _AC_PTH_VERBOSE([+ Determined Versions:]) + _AC_PTH_VERBOSE([ o existing: $_pth_version -> 0x$_pth_version_hex]) + _AC_PTH_VERBOSE([ o required: $_req_version -> 0x$_req_version_hex]) + _ok=0 + if test ".$_pth_version_hex" != .; then + if test ".$_req_version_hex" != .; then + if test $_pth_version_hex -ge $_req_version_hex; then + _ok=1 + fi + fi + fi + if test ".$_ok" = .0; then + _AC_PTH_ERROR([dnl + Found Pth version $_pth_version, but required at least version $_req_version. + Upgrade Pth under $_pth_location to $_req_version or higher first, please.]) + fi + dnl # + dnl # Perform Pth Sanity Compile Check + dnl # + if test ".$with_pth_test" = .yes; then + _ac_save_CPPFLAGS="$CPPFLAGS" + _ac_save_CFLAGS="$CFLAGS" + _ac_save_LDFLAGS="$LDFLAGS" + _ac_save_LIBS="$LIBS" + CPPFLAGS="$CPPFLAGS $_pth_cppflags" + CFLAGS="$CFLAGS $_pth_cflags" + LDFLAGS="$LDFLAGS $_pth_ldflags" + LIBS="$LIBS $_pth_libs" + _AC_PTH_VERBOSE([+ Test Build Environment:]) + _AC_PTH_VERBOSE([ o CPPFLAGS=\"$CPPFLAGS\"]) + _AC_PTH_VERBOSE([ o CFLAGS=\"$CFLAGS\"]) + _AC_PTH_VERBOSE([ o LDFLAGS=\"$LDFLAGS\"]) + _AC_PTH_VERBOSE([ o LIBS=\"$LIBS\"]) + cross_compile=no + define(_code1, [dnl + #include + #include + ]) + define(_code2, [dnl + int main(int argc, char *argv[]) + { + FILE *fp; + if (!(fp = fopen("conftestval", "w"))) + exit(1); + fprintf(fp, "hmm"); + fclose(fp); + pth_init(); + pth_kill(); + if (!(fp = fopen("conftestval", "w"))) + exit(1); + fprintf(fp, "yes"); + fclose(fp); + exit(0); + } + ]) + _AC_PTH_VERBOSE([+ Performing Sanity Checks:]) + _AC_PTH_VERBOSE([ o pre-processor test]) + AC_TRY_CPP(_code1, _ok=yes, _ok=no) + if test ".$_ok" != .yes; then + _AC_PTH_ERROR([dnl + Found GNU Pth $_pth_version under $_pth_location, but + was unable to perform a sanity pre-processor check. This means + the GNU Pth header pth.h was not found. + We used the following build environment: + >> CPP="$CPP" + >> CPPFLAGS="$CPPFLAGS" + See config.log for possibly more details.]) + fi + _AC_PTH_VERBOSE([ o link check]) + AC_TRY_LINK(_code1, _code2, _ok=yes, _ok=no) + if test ".$_ok" != .yes; then + _AC_PTH_ERROR([dnl + Found GNU Pth $_pth_version under $_pth_location, but + was unable to perform a sanity linker check. This means + the GNU Pth library libpth.a was not found. + We used the following build environment: + >> CC="$CC" + >> CFLAGS="$CFLAGS" + >> LDFLAGS="$LDFLAGS" + >> LIBS="$LIBS" + See config.log for possibly more details.]) + fi + _AC_PTH_VERBOSE([ o run-time check]) + AC_TRY_RUN(_code1 _code2, _ok=`cat conftestval`, _ok=no, _ok=no) + if test ".$_ok" != .yes; then + if test ".$_ok" = .no; then + _AC_PTH_ERROR([dnl + Found GNU Pth $_pth_version under $_pth_location, but + was unable to perform a sanity execution check. This usually + means that the GNU Pth shared library libpth.so is present + but \$LD_LIBRARY_PATH is incomplete to execute a Pth test. + In this case either disable this test via --without-pth-test, + or extend \$LD_LIBRARY_PATH, or build GNU Pth as a static + library only via its --disable-shared Autoconf option. + We used the following build environment: + >> CC="$CC" + >> CFLAGS="$CFLAGS" + >> LDFLAGS="$LDFLAGS" + >> LIBS="$LIBS" + See config.log for possibly more details.]) + else + _AC_PTH_ERROR([dnl + Found GNU Pth $_pth_version under $_pth_location, but + was unable to perform a sanity run-time check. This usually + means that the GNU Pth library failed to work and possibly + caused a core dump in the test program. In this case it + is strongly recommended that you re-install GNU Pth and this + time make sure that it really passes its "make test" procedure. + We used the following build environment: + >> CC="$CC" + >> CFLAGS="$CFLAGS" + >> LDFLAGS="$LDFLAGS" + >> LIBS="$LIBS" + See config.log for possibly more details.]) + fi + fi + _extendvars="ifelse([$4],,yes,$4)" + if test ".$_extendvars" != .yes; then + CPPFLAGS="$_ac_save_CPPFLAGS" + CFLAGS="$_ac_save_CFLAGS" + LDFLAGS="$_ac_save_LDFLAGS" + LIBS="$_ac_save_LIBS" + fi + else + _extendvars="ifelse([$4],,yes,$4)" + if test ".$_extendvars" = .yes; then + if test ".$_pth_subdir" = .yes; then + CPPFLAGS="$CPPFLAGS $_pth_cppflags" + CFLAGS="$CFLAGS $_pth_cflags" + LDFLAGS="$LDFLAGS $_pth_ldflags" + LIBS="$LIBS $_pth_libs" + fi + fi + fi + PTH_CPPFLAGS="$_pth_cppflags" + PTH_CFLAGS="$_pth_cflags" + PTH_LDFLAGS="$_pth_ldflags" + PTH_LIBS="$_pth_libs" + AC_SUBST(PTH_CPPFLAGS) + AC_SUBST(PTH_CFLAGS) + AC_SUBST(PTH_LDFLAGS) + AC_SUBST(PTH_LIBS) + _AC_PTH_VERBOSE([+ Final Results:]) + _AC_PTH_VERBOSE([ o PTH_CPPFLAGS=\"$PTH_CPPFLAGS\"]) + _AC_PTH_VERBOSE([ o PTH_CFLAGS=\"$PTH_CFLAGS\"]) + _AC_PTH_VERBOSE([ o PTH_LDFLAGS=\"$PTH_LDFLAGS\"]) + _AC_PTH_VERBOSE([ o PTH_LIBS=\"$PTH_LIBS\"]) +fi +fi +if test ".$with_pth" != .no; then + AC_MSG_RESULT([version $_pth_version, $_pth_type under $_pth_location]) + ifelse([$5], , :, [$5]) +else + AC_MSG_RESULT([no]) + ifelse([$6], , :, [$6]) +fi +]) + +dnl GNUPG_CHECK_VA_COPY() +dnl Do some check on how to implement va_copy. +dnl May define MUST_COPY_VA_BY_VAL. +dnl Actual test code taken from glib-1.1. +AC_DEFUN(GNUPG_CHECK_VA_COPY, +[ AC_MSG_CHECKING(whether va_lists must be copied by value) + AC_CACHE_VAL(gnupg_cv_must_copy_va_byval,[ + gnupg_cv_must_copy_va_byval=no + AC_TRY_RUN([ + #include + void f (int i, ...) + { + va_list args1, args2; + va_start (args1, i); + args2 = args1; + if (va_arg (args2, int) != 42 || va_arg (args1, int) != 42) + exit (1); + va_end (args1); + va_end (args2); + } + + int main() + { + f (0, 42); + return 0; + } + ],gnupg_cv_must_copy_va_byval=yes) + ]) + if test "$gnupg_cv_must_copy_va_byval" = yes; then + AC_DEFINE(MUST_COPY_VA_BYVAL,1,[used to implement the va_copy macro]) + fi + AC_MSG_RESULT($gnupg_cv_must_copy_va_byval) +]) + + +# glibc21.m4 serial 2 (fileutils-4.1.3, gettext-0.10.40) +dnl Copyright (C) 2000-2002 Free Software Foundation, Inc. +dnl This file is free software, distributed under the terms of the GNU +dnl General Public License. As a special exception to the GNU General +dnl Public License, this file may be distributed as part of a program +dnl that contains a configuration script generated by Autoconf, under +dnl the same distribution terms as the rest of that program. + +# Test for the GNU C Library, version 2.1 or newer. +# From Bruno Haible. + +AC_DEFUN([jm_GLIBC21], + [ + AC_CACHE_CHECK(whether we are using the GNU C Library 2.1 or newer, + ac_cv_gnu_library_2_1, + [AC_EGREP_CPP([Lucky GNU user], + [ +#include +#ifdef __GNU_LIBRARY__ + #if (__GLIBC__ == 2 && __GLIBC_MINOR__ >= 1) || (__GLIBC__ > 2) + Lucky GNU user + #endif +#endif + ], + ac_cv_gnu_library_2_1=yes, + ac_cv_gnu_library_2_1=no) + ] + ) + AC_SUBST(GLIBC21) + GLIBC21="$ac_cv_gnu_library_2_1" + ] +) diff --git a/tags/gpgme-0-4-3/assuan/ChangeLog b/tags/gpgme-0-4-3/assuan/ChangeLog new file mode 100644 index 0000000..3d2faf9 --- /dev/null +++ b/tags/gpgme-0-4-3/assuan/ChangeLog @@ -0,0 +1,484 @@ +2003-08-13 Werner Koch + + * assuan-inquire.c (assuan_inquire): Increase length of cmdbuf to + the Assuan limit. + +2003-06-24 Werner Koch + + * mkerrors: Kludge to print libgpg-error values in an easier + readable way. + +2003-04-29 Werner Koch + + * libassuan.m4: New. Based on libgrypt.m4. + * Makefile.am (m4data_DATA): New. + + * assuan.h (AssuanCommand): Removed. + + * assuan-handler.c: Remove the cmd_id element, + (assuan_register_command): Likewise. Note that semantics changed. + (_assuan_register_std_commands): Adjusted. + +2003-02-22 Neal H. Walfield + + * Makefile.am (bin_SCRIPTS): Renamed from bin_PROGRAMS. + +2003-02-18 Neal H. Walfield + + * Makefile.am (libassuan_a_LIBADD): New variable. + * funopen.c: Move from ../common. + * isascii.c: Likewise. + * memrchr.c: Likewise. + * putc_unlocked.c: Likewise. + +2003-02-18 Neal H. Walfield + + * assuan-handler.c (_IO_cookie_io_functions_t): Remove. + (cookie_io_functions_t): Remove. + (fopencookie): Remove prototype. + (assuan_get_data_fp): Use funopen, not fopencookie. + +2003-02-18 Neal H. Walfield + + * libassuan-config.in: New file. + * Makefile.am (bin_PROGRAMS): New variable. + +2003-02-17 Neal H. Walfield + + * .cvsignore: New file. + +2003-02-17 Neal H. Walfield + + * Makefile.am (lib_LIBRARIES): Use this instead of . . . + (noinst_LIBRARIES): . . . this. + (include_HEADERS): New variable. + (libassuan_a_SOURCES): Remove assuan.h, add assuan-logging.c. + + * assuan.h (assuan_set_assuan_log_stream): New prototype. + (assuan_get_assuan_log_stream): Likewise. + (assuan_get_assuan_log_prefix): Likewise. + * assuan-logging.c: New file. + + * assuan-buffer.c [HAVE_JNLIB_LOGGIN]: Do not include + "../jnlib/logging.h". + (my_log_prefix): Remove function. + (_assuan_read_line): Use assuan_get_assuan_log_prefix in lieu of + my_log_prefix. + (assuan_write_line): Likewise. + (_assuan_cookie_write_data): Likewise. + (_assuan_cookie_write_flush): Likewise. + * assuan-domain-connect.c (LOGERROR, LOGERROR1, LOGERROR2, + LOGERRORX): Remove. + (LOG): New macro. + (domain_reader): Use it. + (domain_writer): Likewise. + (domain_sendfd): Likewise. + (domain_receivefd): Likewise. + (_assuan_domain_init): Likewise. + (assuan_domain_connect): Likewise. + * assuan-pipe-connect.c [HAVE_JNLIB_LOGGIN]: Do not include + "../jnlib/logging.h". + (LOGERROR, LOGERROR1, LOGERROR2, LOGERRORX): Remove. + (LOG): New macro. + (assuan_pipe_connect): Use it. + * assuan-socket-connect.c [HAVE_JNLIB_LOGGIN]: Do not include + "../jnlib/logging.h". + (LOGERROR, LOGERROR1, LOGERROR2, LOGERRORX): Remove. + (LOG): New macro. + (assuan_socket_connect): Use it. + (socket_reader): Remove dead code. + (socket_writer): Likewise. + * assuan-util.c [HAVE_JNLIB_LOGGIN]: Do not include + "../jnlib/logging.h". + (_assuan_log_sanitized_string): Use assuan_get_assuan_log_stream, + not jnlib. + +2002-11-24 Neal H. Walfield + + * assuan.h (assuan_command_parse_fd): New prototype. + * assuan-handler.c (assuan_command_parse_fd): Rename from + parse_cmd_input_output. Export. + (std_handler_input): Update to use assuan_command_parse_fd. + (std_handler_output): Likewise. + +2002-11-24 Neal H. Walfield + + * assuan.h (assuan_sendfd): New prototype. + (assuan_receivefd): New prototype. + * assuan-buffer.c (assuan_sendfd): New function. + (assuan_receivefd): New function. + * assuan-handler.c (parse_cmd_input_output): Recognize incoming + file descriptors and act appropriately. + * assuan-defs.h (struct assuan_io): Add fields sendfd and + receivefd. + (struct assuan_context_s): Add fields pendingfds and + pendingfdscount. + * assuan-pipe-server.c (_assuan_new_context): Update IO to reflect + new features. + * assuan-domain-connect.c (do_deinit): Cleanup any unreceived file + descriptors. + (domain_reader): Receive file descriptors. + (domain_sendfd): New function. + (domain_receivefd): New function. + (_assuan_domain_init): Update initialization code to reflect new + features. + +2002-11-24 Neal H. Walfield + + * assuan-domain-connect.c (do_finish): Remove. + (_assuan_domain_init): Use default handlers where possible. + Add an assert and update comments. + * assuan-domain-server.c (accept_connection): Remove. + (assuan_init_domain_server): Use default handlers where possible. + Put the server in pipe mode: it can only be used by a single + client. + +2002-11-24 Neal H. Walfield + + * assuan.h: Add prototype for assuan_domain_connect and + assuan_init_domain_server. + * assuan-defs.h: Include . + Add prototype for _assuan_domain_init. + * assuan-domain-connect.c: New file. + * assuan-domain-server.c: New file. + * Makefile.am (libassuan_a_SOURCES): Add assuan-domain-connect.c + and assuan-domain-server.c + +2002-11-23 Neal H. Walfield + + * Makefile.am (libassuan_a_SOURCES): Add assuan-io.c. + * assuan-io.c: Restore. + (_assuan_simple_read): Rename from _assuan_read. + (_assuan_simple_write): Rename from _assuan_write. + * assuan-defs.h (_assuan_simple_read): New prototype. + (_assuan_simple_write): Likewise. + * assuan-pipe-server.c (pipe_reader): Remove. + (pipe_writer): Remove. + (_assuan_new_context): Initialize IO is with _assuan_simple_read + and _assuan_simple_write. + * assuan-socket-connect.c (socket_reader): Remove. + (socket_writer): Remove. + (assuan_socket_connect): Initialize IO is with _assuan_simple_read + and _assuan_simple_write. + * assuan-socket-server.c (io): New local variable. + (assuan_init_socket_server): Initialize CTX->io. + (assuan_init_connected_socket_server): Likewise. + +2002-11-23 Neal H. Walfield + + * assuan-buffer.c (readline): Use memrchr. + (_assuan_read_line): Rewritten to use the string functions. + +2002-11-20 Neal H. Walfield + + * assuan-socket-connect.c (assuan_socket_connect): Pass PF_LOCAL + to socket(), not AF_UNIX: it expects a PF_* macro and the former + is more portable. + (assuan_socket_connect): Use AF_LOCAL, not AF_UNIX which is more + POSIXy. + +2002-11-20 Neal H. Walfield + + * assuan-defs.h (struct assuan_io): New structure. + (struct assuan_context_s): New field, io. + (_assuan_read): Depreciated. + (_assuan_write): Likewise. + * assuan-pipe-server.c: Include . + (pipe_reader): New function. + (pipe_writer): Likewise. + (_assuan_new_context.IO): New local static. Set to pipe_reader + and pipe_writer. Use it to initialize new context. + * assuan-socket-connect.c (socket_reader): New function. + (socket_writer): New function. + (assuan_socket_connect.IO): New local static. Set to socket_reader + and socket_writer. Use it to initialize new context. + * assuan-buffer.c (writen): Take an ASSUAN_CONTEXT rather than a + file descriptor. Do not use _assuan_write but the write method + in the supplied context. + (readline): Likewise for _assuan_read. + (assuan_write_line): When calling writen, pass CTX; not the file + descriptor directly. + (_assuan_cookie_write_data): Likewise. + (_assuan_cookie_write_flush): Likewise. + (_assuan_read_line): Likewise for readline. + * Makefile.am (libassuan_a_SOURCES): Remove assuan-io.c. + * assuan-io.c: Removed. + +2002-11-10 Werner Koch + + * assuan-pipe-connect.c (assuan_pipe_connect): Changed the order + of the dups to handle cases where we have already used fd 2 for + other things. + +2002-10-31 Neal H. Walfield + + * assuan-util.c: Include . + (_assuan_log_print_buffer): Elide the magic numbers preferring the + standard isfoo functions. Use putc_unlocked where possible. + (_assuan_log_sanitized_string): Rewrite to use putc_unlocked and + the isfoo functions. + +2002-09-05 Neal H. Walfield + + * assuan-defs.h (_assuan_read_wrapper): Depreciated. + * assuan-util.c (_assuan_read_wrapper): Removed. + * assuan-defs.h (_assuan_write_wrapper): Depreciated. + * assuan-util.c (_assuan_write_wrapper): Removed. + * assuan.h (assuan_set_io_fun): Depreciated. + * assuan-util.c (assuan_set_io_fun): Removed. + + * assuan-defs.h (_assuan_read): New function. + (_assuan_write): Likewise. + * assuan-io.c: New file. + + * assuan-buffer.c (writen): Use _assuan_write rather than doing + the work here. + (readline): Likewise for _assuan_read. + + * Makefile.am (libassuan_a_SOURCES): Add assuan-io.c. + +2002-08-16 Werner Koch + + * assuan.h: Renamed Bad_Certificate_Path to Bad_Certificate_Chain. + +2002-07-30 Werner Koch + + Changed the license from GPL to LGPL. + +2002-07-23 Werner Koch + + * assuan-handler.c (_IO_cookie_io_functions_t): Define it here if + it does not exists. + +2002-06-27 Werner Koch + + * assuan-pipe-connect.c (assuan_pipe_connect): No special handling + for the log_fd and stderr. Connect stderr to /dev/null if it + should not be retained. + +2002-06-26 Werner Koch + + * assuan-buffer.c (assuan_write_line): Make sure we never + accidently print an extra LF. + +2002-05-23 Werner Koch + + * assuan-util.c (assuan_set_io_func): New. + * assuan-buffer.c (writen, readline): Use the new functions + instead of pth. + * assuan-socket-server.c (accept_connection): Don't use the + pth_accept - using the assuan included accept code would be a bad + idea within Pth so we don't need a replacement function. + +2002-05-22 Werner Koch + + * assuan-socket-server.c (assuan_init_connected_socket_server): New. + (accept_connection): Factored most code out to.. + (accept_connection_bottom): .. new function. + +2002-04-04 Werner Koch + + * assuan-buffer.c (my_log_prefix): New. Use it for all i/o debug + output. + +2002-03-06 Werner Koch + + * assuan-client.c (_assuan_read_from_server): Detect END. + (assuan_transact): Pass it to the data callback. + +2002-02-27 Werner Koch + + * assuan-client.c (assuan_transact): Add 2 more arguments to + support status lines. Passing NULL yields the old behaviour. + + * assuan-handler.c (process_request): Flush data lines send + without using the data fp. + +2002-02-14 Werner Koch + + * assuan-inquire.c (assuan_inquire): Check for a cancel command + and return ASSUAN_Canceled. Allow for non-data inquiry. + + * assuan.h: Add a few token specific error codes. + +2002-02-13 Werner Koch + + * assuan-defs.h (assuan_context_s): New var CLIENT_PID. + * assuan-pipe-server.c (_assuan_new_context): set default value. + * assuan-socket-server.c (accept_connection): get the actual pid. + +2002-02-12 Werner Koch + + * assuan-buffer.c (writen,readline) [USE_GNU_PT]: Use pth_read/write. + * assuan-socket-server.c (accept_connection) [USE_GNU_PTH]: Ditto. + +2002-02-01 Marcus Brinkmann + + * Makefile.am (MOSTLYCLEANFILES): New variable. + +2002-01-23 Werner Koch + + * assuan-socket-connect.c (LOGERRORX): and removed typo. + +2002-01-22 Marcus Brinkmann + + * assuan-socket-connect.c (LOGERRORX): Reverse arguments to fputs. + +2002-01-21 Werner Koch + + * assuan-connect.c: Move all except assuan_get_pid to... + * assuan-pipe-connect.c: this. + (assuan_pipe_disconnect): Removed. + (do_finish, do_deinit): New + (assuan_pipe_connect): and set them into the context. + * assuan-socket-connect.c: New. + + * assuan-util.c (_assuan_log_sanitized_string): New. + + * assuan-pipe-server.c (assuan_init_pipe_server): Factored most + code out to ... + (_assuan_new_context): new func. + (_assuan_release_context): New + * assuan-connect.c (assuan_pipe_connect): Use the new functions. + +2002-01-20 Werner Koch + + * assuan.h: Added Invalid Option error code. + + * assuan-handler.c (std_handler_option): New. + (std_cmd_tbl): Add OPTION as standard command. + (assuan_register_option_handler): New. + (dispatch_command): Use case insensitive matching as a fallback. + (my_strcasecmp): New. + +2002-01-19 Werner Koch + + * assuan-buffer.c (_assuan_read_line): Add output logging. + (assuan_write_line): Ditto. + (_assuan_cookie_write_data): Ditto. + (_assuan_cookie_write_flush): Ditto. + * assuan-util.c (_assuan_log_print_buffer): New. + (assuan_set_log_stream): New. + (assuan_begin_confidential): New. + (assuan_end_confidential): New. + + * assuan-defs.h: Add a few handler variables. + * assuan-pipe-server.c (assuan_deinit_pipe_server): Removed. + (deinit_pipe_server): New. + (assuan_deinit_server): New. Changed all callers to use this. + * assuan-listen.c (assuan_accept): Use the accept handler. + * assuan-handler.c (process_request): Use the close Handler. + * assuan-socket-server.c: New. + +2002-01-14 Werner Koch + + * assuan-client.c (_assuan_read_from_server): Skip spaces after + the keyword. + +2002-01-03 Werner Koch + + * assuan-handler.c (assuan_set_okay_line): New. + (process_request): And use it here. + +2002-01-02 Werner Koch + + * assuan-inquire.c (init_membuf,put_membuf,get_membuf): Apply a + hidden 0 behind the buffer so that the buffer can be used as a + string in certain contexts. + +2001-12-14 Marcus Brinkmann + + * assuan-connect.c (assuan_pipe_connect): New argument + FD_CHILD_LIST. Don't close those fds. + * assuan.h: Likewise for prototype. + +2001-12-14 Werner Koch + + * assuan-listen.c (assuan_close_input_fd): New. + (assuan_close_output_fd): New. + * assuan-handler.c (std_handler_reset): Always close them after a + reset command. + (std_handler_bye): Likewise. + +2001-12-14 Marcus Brinkmann + + * assuan-buffer.c (_assuan_read_line): New variable ATTICLEN, use + it to save the length of the attic line. + Rediddle the code a bit to make it more clear what happens. + +2001-12-14 Marcus Brinkmann + + * assuan-defs.h (LINELENGTH): Define as ASSUAN_LINELENGTH. + assuan.h: Define ASSUAN_LINELENGTH. + +2001-12-13 Marcus Brinkmann + + * assuan-buffer.c (assuan_read_line): Fix order of execution to + get correct return values. + +2001-12-13 Werner Koch + + * assuan-handler.c (assuan_get_active_fds): Fixed silly bug, + pretty obvious that nobody ever tested this function. + +2001-12-12 Werner Koch + + * assuan-connect.c (assuan_pipe_connect): Implemented the inital + handshake. + * assuan-client.c (read_from_server): Renamed to + (_assuan_read_from_server): this and made external. + + * assuan-listen.c (assuan_set_hello_line): New. + (assuan_accept): Use a custom hello line is available. + + * assuan-buffer.c (assuan_read_line): New. + (assuan_pending_line): New. + (_assuan_write_line): Renamed to .. + (assuan_write_line): this, made public and changed all callers. + +2001-12-04 Werner Koch + + * assuan-connect.c (assuan_pipe_connect): Add more error reporting. + * assuan-client.c: New. + + * assuan-inquire.c: New. + * assuan-handler.c (process_request): Check for nested invocations. + +2001-11-27 Werner Koch + + * assuan-handler.c (assuan_register_input_notify): New. + (assuan_register_output_notify): New. + +2001-11-26 Werner Koch + + * assuan.h: Added more status codes. + +2001-11-25 Werner Koch + + * assuan-handler.c (assuan_register_bye_notify) + (assuan_register_reset_notify) + (assuan_register_cancel_notify): New and call them from the + standard handlers. + (assuan_process): Moved bulk of function to .. + (process_request): .. new. + (assuan_process_next): One shot version of above. + (assuan_get_active_fds): New. + +2001-11-24 Werner Koch + + * assuan-connect.c (assuan_get_pid): New. + + * assuan-buffer.c (_assuan_read_line): Deal with reads of more + than a line. + * assuan-defs.h: Add space in the context for this. + + + Copyright 2001, 2002 Free Software Foundation, Inc. + + 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/tags/gpgme-0-4-3/assuan/Makefile.am b/tags/gpgme-0-4-3/assuan/Makefile.am new file mode 100644 index 0000000..8c4d88c --- /dev/null +++ b/tags/gpgme-0-4-3/assuan/Makefile.am @@ -0,0 +1,53 @@ +# Assuan Makefile +# Copyright (C) 2001, 2002, 2003 Free Software Foundation, Inc. +# +# This file is part of Assuan. +# +# Assuan 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. +# +# Assuan 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, write to the Free Software +# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA + +## Process this file with automake to produce Makefile.in + +EXTRA_DIST = mkerrors +INCLUDES = -I.. -I$(top_srcdir)/include +BUILT_SOURCES = assuan-errors.c +MOSTLYCLEANFILES = assuan-errors.c + +noinst_LTLIBRARIES = libassuan.la + +AM_CPPFLAGS = -D_ASSUAN_IN_GPGME_BUILD_ASSUAN + +#libassuan_la_LDFLAGS = +libassuan_la_SOURCES = \ + assuan.h \ + assuan-defs.h \ + assuan-util.c \ + assuan-errors.c \ + assuan-buffer.c \ + assuan-handler.c \ + assuan-inquire.c \ + assuan-listen.c \ + assuan-connect.c \ + assuan-client.c \ + assuan-pipe-server.c \ + assuan-socket-server.c \ + assuan-pipe-connect.c \ + assuan-socket-connect.c \ + assuan-io.c \ + assuan-domain-connect.c \ + assuan-domain-server.c \ + assuan-logging.c + +assuan-errors.c : assuan.h + $(srcdir)/mkerrors < $(srcdir)/assuan.h > assuan-errors.c diff --git a/tags/gpgme-0-4-3/assuan/README.1st b/tags/gpgme-0-4-3/assuan/README.1st new file mode 100644 index 0000000..6e8d4ec --- /dev/null +++ b/tags/gpgme-0-4-3/assuan/README.1st @@ -0,0 +1,25 @@ +This is a modified copy of the libassuan library. Don't modify it, +but instead modify the original Assuan library and merge the changes +back into this copy. + +The changes to the original libassuan, that have to preserved when +updating this directory, are: + +* Makefile.am +** Build the library with libtool as a convenience library, which can + be linked into the shared library GPGME. +** Do not install the library or the header file. +** Define -D_ASSUAN_IN_GPGME_BUILD_ASSUAN to wrap some POSIX functions + with ATH replacements. + +* assuan.h +** Define _ASSUAN_IN_GPGME to enable GPGME specific code. +** Put all exported Assuan functions in the _gpgme namespace. +** Also wrap all system functions that are wrapped by GNU Pth to + _gpgme wrappers. + +* assuan-io.c +** Don't try to support GNU Pth here. + +* assuan-pipe-connect.c +** Do not install SIGPIPE signal handler here. diff --git a/tags/gpgme-0-4-3/assuan/assuan-buffer.c b/tags/gpgme-0-4-3/assuan/assuan-buffer.c new file mode 100644 index 0000000..59518f2 --- /dev/null +++ b/tags/gpgme-0-4-3/assuan/assuan-buffer.c @@ -0,0 +1,448 @@ +/* assuan-buffer.c - read and send data + * Copyright (C) 2001, 2002, 2003 Free Software Foundation, Inc. + * + * This file is part of Assuan. + * + * Assuan 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. + * + * Assuan 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, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA + */ + +#include +#include +#include +#include +#include +#include +#include +#include "assuan-defs.h" + +static int +writen (ASSUAN_CONTEXT ctx, const char *buffer, size_t length) +{ + while (length) + { + ssize_t nwritten = ctx->io->write (ctx, buffer, length); + + if (nwritten < 0) + { + if (errno == EINTR) + continue; + return -1; /* write error */ + } + length -= nwritten; + buffer += nwritten; + } + return 0; /* okay */ +} + +/* Read an entire line. */ +static int +readline (ASSUAN_CONTEXT ctx, char *buf, size_t buflen, + int *r_nread, int *eof) +{ + size_t nleft = buflen; + char *p; + + *eof = 0; + *r_nread = 0; + while (nleft > 0) + { + ssize_t n = ctx->io->read (ctx, buf, nleft); + + if (n < 0) + { + if (errno == EINTR) + continue; + return -1; /* read error */ + } + else if (!n) + { + *eof = 1; + break; /* allow incomplete lines */ + } + p = buf; + nleft -= n; + buf += n; + *r_nread += n; + + p = memrchr (p, '\n', n); + if (p) + break; /* at least one full line available - that's enough for now */ + } + + return 0; +} + + +int +_assuan_read_line (ASSUAN_CONTEXT ctx) +{ + char *line = ctx->inbound.line; + int nread, atticlen; + int rc; + char *endp = 0; + + if (ctx->inbound.eof) + return -1; + + atticlen = ctx->inbound.attic.linelen; + if (atticlen) + { + memcpy (line, ctx->inbound.attic.line, atticlen); + ctx->inbound.attic.linelen = 0; + + endp = memchr (line, '\n', atticlen); + if (endp) + /* Found another line in the attic. */ + { + rc = 0; + nread = atticlen; + atticlen = 0; + } + else + /* There is pending data but not a full line. */ + { + assert (atticlen < LINELENGTH); + rc = readline (ctx, line + atticlen, + LINELENGTH - atticlen, &nread, &ctx->inbound.eof); + } + } + else + /* No pending data. */ + rc = readline (ctx, line, LINELENGTH, + &nread, &ctx->inbound.eof); + if (rc) + { + if (ctx->log_fp) + fprintf (ctx->log_fp, "%s[%p] <- [Error: %s]\n", + assuan_get_assuan_log_prefix (), ctx, strerror (errno)); + return ASSUAN_Read_Error; + } + if (!nread) + { + assert (ctx->inbound.eof); + if (ctx->log_fp) + fprintf (ctx->log_fp, "%s[%p] <- [EOF]\n", + assuan_get_assuan_log_prefix (), ctx); + return -1; + } + + ctx->inbound.attic.pending = 0; + nread += atticlen; + + if (! endp) + endp = memchr (line, '\n', nread); + + if (endp) + { + int n = endp - line + 1; + if (n < nread) + /* LINE contains more than one line. We copy it to the attic + now as handlers are allowed to modify the passed + buffer. */ + { + int len = nread - n; + memcpy (ctx->inbound.attic.line, endp + 1, len); + ctx->inbound.attic.pending = memrchr (endp + 1, '\n', len) ? 1 : 0; + ctx->inbound.attic.linelen = len; + } + + if (endp != line && endp[-1] == '\r') + endp --; + *endp = 0; + + ctx->inbound.linelen = endp - line; + if (ctx->log_fp) + { + fprintf (ctx->log_fp, "%s[%p] <- ", + assuan_get_assuan_log_prefix (), ctx); + if (ctx->confidential) + fputs ("[Confidential data not shown]", ctx->log_fp); + else + _assuan_log_print_buffer (ctx->log_fp, + ctx->inbound.line, + ctx->inbound.linelen); + putc ('\n', ctx->log_fp); + } + return 0; + } + else + { + if (ctx->log_fp) + fprintf (ctx->log_fp, "%s[%p] <- [Invalid line]\n", + assuan_get_assuan_log_prefix (), ctx); + *line = 0; + ctx->inbound.linelen = 0; + return ctx->inbound.eof ? ASSUAN_Line_Not_Terminated + : ASSUAN_Line_Too_Long; + } +} + + +/* Read the next line from the client or server and return a pointer + in *LINE to a buffer holding the line. LINELEN is the length of + *LINE. The buffer is valid until the next read operation on it. + The caller may modify the buffer. The buffer is invalid (i.e. must + not be used) if an error is returned. + + Returns 0 on success or an assuan error code. + See also: assuan_pending_line(). +*/ +AssuanError +assuan_read_line (ASSUAN_CONTEXT ctx, char **line, size_t *linelen) +{ + AssuanError err; + + if (!ctx) + return ASSUAN_Invalid_Value; + + err = _assuan_read_line (ctx); + *line = ctx->inbound.line; + *linelen = ctx->inbound.linelen; + return err; +} + + +/* Return true if a full line is buffered (i.e. an entire line may be + read without any I/O). */ +int +assuan_pending_line (ASSUAN_CONTEXT ctx) +{ + return ctx && ctx->inbound.attic.pending; +} + + +AssuanError +assuan_write_line (ASSUAN_CONTEXT ctx, const char *line) +{ + int rc; + size_t len; + const char *s; + + if (!ctx) + return ASSUAN_Invalid_Value; + + /* Make sure that we never take a LF from the user - this might + violate the protocol. */ + s = strchr (line, '\n'); + len = s? (s-line) : strlen (line); + + /* fixme: we should do some kind of line buffering. */ + if (ctx->log_fp) + { + fprintf (ctx->log_fp, "%s[%p] -> ", + assuan_get_assuan_log_prefix (), ctx); + if (s) + fputs ("[supplied line contained a LF]", ctx->log_fp); + if (ctx->confidential) + fputs ("[Confidential data not shown]", ctx->log_fp); + else + _assuan_log_print_buffer (ctx->log_fp, line, len); + putc ('\n', ctx->log_fp); + } + + rc = writen (ctx, line, len); + if (rc) + rc = ASSUAN_Write_Error; + if (!rc) + { + rc = writen (ctx, "\n", 1); + if (rc) + rc = ASSUAN_Write_Error; + } + + return rc; +} + + + +/* Write out the data in buffer as datalines with line wrapping and + percent escaping. This fucntion is used for GNU's custom streams */ +int +_assuan_cookie_write_data (void *cookie, const char *buffer, size_t size) +{ + ASSUAN_CONTEXT ctx = cookie; + char *line; + size_t linelen; + + if (ctx->outbound.data.error) + return 0; + + line = ctx->outbound.data.line; + linelen = ctx->outbound.data.linelen; + line += linelen; + while (size) + { + /* insert data line header */ + if (!linelen) + { + *line++ = 'D'; + *line++ = ' '; + linelen += 2; + } + + /* copy data, keep some space for the CRLF and to escape one character */ + while (size && linelen < LINELENGTH-2-2) + { + if (*buffer == '%' || *buffer == '\r' || *buffer == '\n') + { + sprintf (line, "%%%02X", *(unsigned char*)buffer); + line += 3; + linelen += 3; + buffer++; + } + else + { + *line++ = *buffer++; + linelen++; + } + size--; + } + + if (linelen >= LINELENGTH-2-2) + { + if (ctx->log_fp) + { + fprintf (ctx->log_fp, "%s[%p] -> ", + assuan_get_assuan_log_prefix (), ctx); + + if (ctx->confidential) + fputs ("[Confidential data not shown]", ctx->log_fp); + else + _assuan_log_print_buffer (ctx->log_fp, + ctx->outbound.data.line, + linelen); + putc ('\n', ctx->log_fp); + } + *line++ = '\n'; + linelen++; + if (writen (ctx, ctx->outbound.data.line, linelen)) + { + ctx->outbound.data.error = ASSUAN_Write_Error; + return 0; + } + line = ctx->outbound.data.line; + linelen = 0; + } + } + + ctx->outbound.data.linelen = linelen; + return 0; +} + + +/* Write out any buffered data + This fucntion is used for GNU's custom streams */ +int +_assuan_cookie_write_flush (void *cookie) +{ + ASSUAN_CONTEXT ctx = cookie; + char *line; + size_t linelen; + + if (ctx->outbound.data.error) + return 0; + + line = ctx->outbound.data.line; + linelen = ctx->outbound.data.linelen; + line += linelen; + if (linelen) + { + if (ctx->log_fp) + { + fprintf (ctx->log_fp, "%s[%p] -> ", + assuan_get_assuan_log_prefix (), ctx); + if (ctx->confidential) + fputs ("[Confidential data not shown]", ctx->log_fp); + else + _assuan_log_print_buffer (ctx->log_fp, + ctx->outbound.data.line, linelen); + putc ('\n', ctx->log_fp); + } + *line++ = '\n'; + linelen++; + if (writen (ctx, ctx->outbound.data.line, linelen)) + { + ctx->outbound.data.error = ASSUAN_Write_Error; + return 0; + } + ctx->outbound.data.linelen = 0; + } + return 0; +} + + +/** + * assuan_send_data: + * @ctx: An assuan context + * @buffer: Data to send or NULL to flush + * @length: length of the data to send/ + * + * This function may be used by the server or the client to send data + * lines. The data will be escaped as required by the Assuan protocol + * and may get buffered until a line is full. To force sending the + * data out @buffer may be passed as NULL (in which case @length must + * also be 0); however when used by a client this flush operation does + * also send the terminating "END" command to terminate the reponse on + * a INQUIRE response. However, when assuan_transact() is used, this + * function takes care of sending END itself. + * + * Return value: 0 on success or an error code + **/ + +AssuanError +assuan_send_data (ASSUAN_CONTEXT ctx, const void *buffer, size_t length) +{ + if (!ctx) + return ASSUAN_Invalid_Value; + if (!buffer && length) + return ASSUAN_Invalid_Value; + + if (!buffer) + { /* flush what we have */ + _assuan_cookie_write_flush (ctx); + if (ctx->outbound.data.error) + return ctx->outbound.data.error; + if (!ctx->is_server) + return assuan_write_line (ctx, "END"); + } + else + { + _assuan_cookie_write_data (ctx, buffer, length); + if (ctx->outbound.data.error) + return ctx->outbound.data.error; + } + + return 0; +} + +AssuanError +assuan_sendfd (ASSUAN_CONTEXT ctx, int fd) +{ + if (! ctx->io->sendfd) + return set_error (ctx, Not_Implemented, + "server does not support sending and receiving " + "of file descriptors"); + return ctx->io->sendfd (ctx, fd); +} + +AssuanError +assuan_receivefd (ASSUAN_CONTEXT ctx, int *fd) +{ + if (! ctx->io->receivefd) + return set_error (ctx, Not_Implemented, + "server does not support sending and receiving " + "of file descriptors"); + return ctx->io->receivefd (ctx, fd); +} diff --git a/tags/gpgme-0-4-3/assuan/assuan-client.c b/tags/gpgme-0-4-3/assuan/assuan-client.c new file mode 100644 index 0000000..d5c0ec8 --- /dev/null +++ b/tags/gpgme-0-4-3/assuan/assuan-client.c @@ -0,0 +1,225 @@ +/* assuan-client.c - client functions + * Copyright (C) 2001, 2002 Free Software Foundation, Inc. + * + * This file is part of Assuan. + * + * Assuan 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. + * + * Assuan 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, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA + */ + +#include +#include +#include +#include +#include +#include + +#include "assuan-defs.h" + +#define xtoi_1(p) (*(p) <= '9'? (*(p)- '0'): \ + *(p) <= 'F'? (*(p)-'A'+10):(*(p)-'a'+10)) +#define xtoi_2(p) ((xtoi_1(p) * 16) + xtoi_1((p)+1)) + + +AssuanError +_assuan_read_from_server (ASSUAN_CONTEXT ctx, int *okay, int *off) +{ + char *line; + int linelen; + AssuanError rc; + + *okay = 0; + *off = 0; + do + { + rc = _assuan_read_line (ctx); + if (rc) + return rc; + line = ctx->inbound.line; + linelen = ctx->inbound.linelen; + } + while (*line == '#' || !linelen); + + if (linelen >= 1 + && line[0] == 'D' && line[1] == ' ') + { + *okay = 2; /* data line */ + *off = 2; + } + else if (linelen >= 1 + && line[0] == 'S' + && (line[1] == '\0' || line[1] == ' ')) + { + *okay = 4; + *off = 1; + while (line[*off] == ' ') + ++*off; + } + else if (linelen >= 2 + && line[0] == 'O' && line[1] == 'K' + && (line[2] == '\0' || line[2] == ' ')) + { + *okay = 1; + *off = 2; + while (line[*off] == ' ') + ++*off; + } + else if (linelen >= 3 + && line[0] == 'E' && line[1] == 'R' && line[2] == 'R' + && (line[3] == '\0' || line[3] == ' ')) + { + *okay = 0; + *off = 3; + while (line[*off] == ' ') + ++*off; + } + else if (linelen >= 7 + && line[0] == 'I' && line[1] == 'N' && line[2] == 'Q' + && line[3] == 'U' && line[4] == 'I' && line[5] == 'R' + && line[6] == 'E' + && (line[7] == '\0' || line[7] == ' ')) + { + *okay = 3; + *off = 7; + while (line[*off] == ' ') + ++*off; + } + else if (linelen >= 3 + && line[0] == 'E' && line[1] == 'N' && line[2] == 'D' + && (line[3] == '\0' || line[3] == ' ')) + { + *okay = 5; /* end line */ + *off = 3; + } + else + rc = ASSUAN_Invalid_Response; + return rc; +} + + + +/** + * assuan_transact: + * @ctx: The Assuan context + * @command: Coimmand line to be send to server + * @data_cb: Callback function for data lines + * @data_cb_arg: first argument passed to @data_cb + * @inquire_cb: Callback function for a inquire response + * @inquire_cb_arg: first argument passed to @inquire_cb + * @status_cb: Callback function for a status response + * @status_cb_arg: first argument passed to @status_cb + * + * FIXME: Write documentation + * + * Return value: 0 on success or error code. The error code may be + * the one one returned by the server in error lines or from the + * callback functions. + **/ +AssuanError +assuan_transact (ASSUAN_CONTEXT ctx, + const char *command, + AssuanError (*data_cb)(void *, const void *, size_t), + void *data_cb_arg, + AssuanError (*inquire_cb)(void*, const char *), + void *inquire_cb_arg, + AssuanError (*status_cb)(void*, const char *), + void *status_cb_arg) +{ + int rc, okay, off; + unsigned char *line; + int linelen; + + rc = assuan_write_line (ctx, command); + if (rc) + return rc; + + again: + rc = _assuan_read_from_server (ctx, &okay, &off); + if (rc) + return rc; /* error reading from server */ + + line = ctx->inbound.line + off; + linelen = ctx->inbound.linelen - off; + + if (!okay) + { + rc = atoi (line); + if (rc < 100) + rc = ASSUAN_Server_Fault; + } + else if (okay == 2) + { + if (!data_cb) + rc = ASSUAN_No_Data_Callback; + else + { + unsigned char *s, *d; + + for (s=d=line; linelen; linelen--) + { + if (*s == '%' && linelen > 2) + { /* handle escaping */ + s++; + *d++ = xtoi_2 (s); + s += 2; + linelen -= 2; + } + else + *d++ = *s++; + } + *d = 0; /* add a hidden string terminator */ + rc = data_cb (data_cb_arg, line, d - line); + if (!rc) + goto again; + } + } + else if (okay == 3) + { + if (!inquire_cb) + { + assuan_write_line (ctx, "END"); /* get out of inquire mode */ + _assuan_read_from_server (ctx, &okay, &off); /* dummy read */ + rc = ASSUAN_No_Inquire_Callback; + } + else + { + rc = inquire_cb (inquire_cb_arg, line); + if (!rc) + rc = assuan_send_data (ctx, NULL, 0); /* flush and send END */ + if (!rc) + goto again; + } + } + else if (okay == 4) + { + if (status_cb) + rc = status_cb (status_cb_arg, line); + if (!rc) + goto again; + } + else if (okay == 5) + { + if (!data_cb) + rc = ASSUAN_No_Data_Callback; + else + { + rc = data_cb (data_cb_arg, NULL, 0); + if (!rc) + goto again; + } + } + + return rc; +} + diff --git a/tags/gpgme-0-4-3/assuan/assuan-connect.c b/tags/gpgme-0-4-3/assuan/assuan-connect.c new file mode 100644 index 0000000..009aaab --- /dev/null +++ b/tags/gpgme-0-4-3/assuan/assuan-connect.c @@ -0,0 +1,54 @@ +/* assuan-connect.c - Establish a connection (client) + * Copyright (C) 2001, 2002 Free Software Foundation, Inc. + * + * This file is part of Assuan. + * + * Assuan 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. + * + * Assuan 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, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA + */ + +#ifdef HAVE_CONFIG_H +#include +#endif + +#include +#include +#include +#include +#include +#include +#include +#include + +#include "assuan-defs.h" + +/* Disconnect and release the context CTX. */ +void +assuan_disconnect (ASSUAN_CONTEXT ctx) +{ + if (ctx) + { + assuan_write_line (ctx, "BYE"); + ctx->finish_handler (ctx); + ctx->deinit_handler (ctx); + ctx->deinit_handler = NULL; + _assuan_release_context (ctx); + } +} + +pid_t +assuan_get_pid (ASSUAN_CONTEXT ctx) +{ + return ctx ? ctx->pid : -1; +} diff --git a/tags/gpgme-0-4-3/assuan/assuan-defs.h b/tags/gpgme-0-4-3/assuan/assuan-defs.h new file mode 100644 index 0000000..1f7f1f0 --- /dev/null +++ b/tags/gpgme-0-4-3/assuan/assuan-defs.h @@ -0,0 +1,194 @@ +/* assuan-defs.c - Internal definitions to Assuan + * Copyright (C) 2001, 2002 Free Software Foundation, Inc. + * + * This file is part of Assuan. + * + * Assuan 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. + * + * Assuan 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, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA + */ + +#ifndef ASSUAN_DEFS_H +#define ASSUAN_DEFS_H + +#include +#include +#include +#include + +#include "assuan.h" + +#define LINELENGTH ASSUAN_LINELENGTH + +struct cmdtbl_s +{ + const char *name; + int (*handler)(ASSUAN_CONTEXT, char *line); +}; + +struct assuan_io +{ + /* Routine to read from input_fd. */ + ssize_t (*read) (ASSUAN_CONTEXT, void *, size_t); + /* Routine to write to output_fd. */ + ssize_t (*write) (ASSUAN_CONTEXT, const void *, size_t); + /* Send a file descriptor. */ + AssuanError (*sendfd) (ASSUAN_CONTEXT, int); + /* Receive a file descriptor. */ + AssuanError (*receivefd) (ASSUAN_CONTEXT, int *); +}; + +struct assuan_context_s +{ + AssuanError err_no; + const char *err_str; + int os_errno; /* last system error number used with certain error codes*/ + + int confidential; + int is_server; /* set if this is context belongs to a server */ + int in_inquire; + char *hello_line; + char *okay_line; /* see assan_set_okay_line() */ + + void *user_pointer; /* for assuan_[gs]et_pointer () */ + + FILE *log_fp; + + struct { + int fd; + int eof; + char line[LINELENGTH]; + int linelen; /* w/o CR, LF - might not be the same as + strlen(line) due to embedded nuls. However a nul + is always written at this pos */ + struct { + char line[LINELENGTH]; + int linelen ; + int pending; /* i.e. at least one line is available in the attic */ + } attic; + } inbound; + + struct { + int fd; + struct { + FILE *fp; + char line[LINELENGTH]; + int linelen; + int error; + } data; + } outbound; + + int pipe_mode; /* We are in pipe mode, i.e. we can handle just one + connection and must terminate then */ + pid_t pid; /* In pipe mode, the pid of the child server process. + In socket mode, the pid of the server */ + int listen_fd; /* The fd we are listening on (used by socket servers) */ + int connected_fd; /* helper */ + + pid_t client_pid; /* for a socket server the PID of the client or -1 + if not available */ + + /* Used for Unix domain sockets. */ + struct sockaddr_un myaddr; + struct sockaddr_un serveraddr; + /* When reading from datagram sockets, we must read an entire + message at a time. This means that we have to do our own + buffering to be able to get the semantics of read. */ + void *domainbuffer; + /* Offset of start of buffer. */ + int domainbufferoffset; + /* Bytes buffered. */ + int domainbuffersize; + /* Memory allocated. */ + int domainbufferallocated; + + int *pendingfds; + int pendingfdscount; + + void (*deinit_handler)(ASSUAN_CONTEXT); + int (*accept_handler)(ASSUAN_CONTEXT); + int (*finish_handler)(ASSUAN_CONTEXT); + + struct cmdtbl_s *cmdtbl; + size_t cmdtbl_used; /* used entries */ + size_t cmdtbl_size; /* allocated size of table */ + + void (*bye_notify_fnc)(ASSUAN_CONTEXT); + void (*reset_notify_fnc)(ASSUAN_CONTEXT); + void (*cancel_notify_fnc)(ASSUAN_CONTEXT); + int (*option_handler_fnc)(ASSUAN_CONTEXT,const char*, const char*); + void (*input_notify_fnc)(ASSUAN_CONTEXT, const char *); + void (*output_notify_fnc)(ASSUAN_CONTEXT, const char *); + + int input_fd; /* set by INPUT command */ + int output_fd; /* set by OUTPUT command */ + + /* io routines. */ + struct assuan_io *io; +}; + +/*-- assuan-pipe-server.c --*/ +int _assuan_new_context (ASSUAN_CONTEXT *r_ctx); +void _assuan_release_context (ASSUAN_CONTEXT ctx); + +/*-- assuan-domain-connect.c --*/ +/* Make a connection to the Unix domain socket NAME and return a new + Assuan context in CTX. SERVER_PID is currently not used but may + become handy in the future. */ +AssuanError _assuan_domain_init (ASSUAN_CONTEXT *r_ctx, + int rendezvousfd, + pid_t peer); + +/*-- assuan-handler.c --*/ +int _assuan_register_std_commands (ASSUAN_CONTEXT ctx); + +/*-- assuan-buffer.c --*/ +int _assuan_read_line (ASSUAN_CONTEXT ctx); +int _assuan_cookie_write_data (void *cookie, const char *buffer, size_t size); +int _assuan_cookie_write_flush (void *cookie); + +/*-- assuan-client.c --*/ +AssuanError _assuan_read_from_server (ASSUAN_CONTEXT ctx, int *okay, int *off); + + +/*-- assuan-util.c --*/ +void *_assuan_malloc (size_t n); +void *_assuan_calloc (size_t n, size_t m); +void *_assuan_realloc (void *p, size_t n); +void _assuan_free (void *p); + +#define xtrymalloc(a) _assuan_malloc ((a)) +#define xtrycalloc(a,b) _assuan_calloc ((a),(b)) +#define xtryrealloc(a,b) _assuan_realloc((a),(b)) +#define xfree(a) _assuan_free ((a)) + +#define set_error(c,e,t) assuan_set_error ((c), ASSUAN_ ## e, (t)) + +void _assuan_log_print_buffer (FILE *fp, const void *buffer, size_t length); +void _assuan_log_sanitized_string (const char *string); + +/*-- assuan-io.c --*/ +ssize_t _assuan_simple_read (ASSUAN_CONTEXT ctx, void *buffer, size_t size); +ssize_t _assuan_simple_write (ASSUAN_CONTEXT ctx, const void *buffer, + size_t size); + +#ifdef HAVE_FOPENCOOKIE +/* We have to implement funopen in terms of glibc's fopencookie. */ +FILE *funopen(const void *cookie, cookie_read_function_t *readfn, + cookie_write_function_t *writefn, + cookie_seek_function_t *seekfn, + cookie_close_function_t *closefn); +#endif /*HAVE_FOPENCOOKIE*/ + +#endif /*ASSUAN_DEFS_H*/ + diff --git a/tags/gpgme-0-4-3/assuan/assuan-domain-connect.c b/tags/gpgme-0-4-3/assuan/assuan-domain-connect.c new file mode 100644 index 0000000..49dcb55 --- /dev/null +++ b/tags/gpgme-0-4-3/assuan/assuan-domain-connect.c @@ -0,0 +1,473 @@ +/* assuan-domain-connect.c - Assuan unix domain socket based client + * Copyright (C) 2002, 2003 Free Software Foundation, Inc. + * + * This file is part of Assuan. + * + * Assuan 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. + * + * Assuan 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, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA + */ + +#ifdef HAVE_CONFIG_H +#include +#endif + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include "assuan-defs.h" + +#define LOG(format, args...) \ + fprintf (assuan_get_assuan_log_stream (), \ + assuan_get_assuan_log_prefix (), \ + "%s" format , ## args) + + +static void +do_deinit (ASSUAN_CONTEXT ctx) +{ + if (ctx->inbound.fd != -1) + close (ctx->inbound.fd); + ctx->inbound.fd = -1; + ctx->outbound.fd = -1; + + if (ctx->domainbuffer) + { + assert (ctx->domainbufferallocated); + free (ctx->domainbuffer); + } + + if (ctx->pendingfds) + { + int i; + + assert (ctx->pendingfdscount > 0); + for (i = 0; i < ctx->pendingfdscount; i ++) + close (ctx->pendingfds[i]); + + free (ctx->pendingfds); + } + + unlink (ctx->myaddr.sun_path); +} + + +/* Read from the socket server. */ +static ssize_t +domain_reader (ASSUAN_CONTEXT ctx, void *buf, size_t buflen) +{ + int len = ctx->domainbuffersize; + + start: + if (len == 0) + /* No data is buffered. */ + { + struct msghdr msg; + struct iovec iovec; + struct sockaddr_un sender; + struct + { + struct cmsghdr hdr; + int fd; + } + cmsg; + + memset (&msg, 0, sizeof (msg)); + + for (;;) + { + msg.msg_name = &sender; + msg.msg_namelen = sizeof (struct sockaddr_un); + msg.msg_iov = &iovec; + msg.msg_iovlen = 1; + iovec.iov_base = ctx->domainbuffer; + iovec.iov_len = ctx->domainbufferallocated; + msg.msg_control = &cmsg; + msg.msg_controllen = sizeof cmsg; + + /* Peek first: if the buffer we have is too small then it + will be truncated. */ + len = recvmsg (ctx->inbound.fd, &msg, MSG_PEEK); + if (len < 0) + { + printf ("domain_reader: %m\n"); + return -1; + } + + if (strcmp (ctx->serveraddr.sun_path, + ((struct sockaddr_un *) msg.msg_name)->sun_path) != 0) + { + /* XXX: Arg. Not from whom we expected! What do we + want to do? Should we just ignore it? Either way, + we still need to consume the message. */ + break; + } + + if (msg.msg_flags & MSG_TRUNC) + /* Enlarge the buffer and try again. */ + { + int size = ctx->domainbufferallocated; + void *tmp; + + if (size == 0) + size = 4 * 1024; + else + size *= 2; + + tmp = malloc (size); + if (! tmp) + return -1; + + free (ctx->domainbuffer); + ctx->domainbuffer = tmp; + ctx->domainbufferallocated = size; + } + else + /* We have enough space! */ + break; + } + + /* Now we have to actually consume it (remember, we only + peeked). */ + msg.msg_name = &sender; + msg.msg_namelen = sizeof (struct sockaddr_un); + msg.msg_iov = &iovec; + msg.msg_iovlen = 1; + iovec.iov_base = ctx->domainbuffer; + iovec.iov_len = ctx->domainbufferallocated; + msg.msg_control = &cmsg; + msg.msg_controllen = sizeof cmsg; + + if (strcmp (ctx->serveraddr.sun_path, + ((struct sockaddr_un *) msg.msg_name)->sun_path) != 0) + { + /* XXX: Arg. Not from whom we expected! What do we want to + do? Should we just ignore it? We shall do the latter + for the moment. */ + LOG ("Not setup to receive messages from: `%s'.", + ((struct sockaddr_un *) msg.msg_name)->sun_path); + goto start; + } + + len = recvmsg (ctx->inbound.fd, &msg, 0); + if (len < 0) + { + LOG ("domain_reader: %s\n", strerror (errno)); + return -1; + } + + ctx->domainbuffersize = len; + ctx->domainbufferoffset = 0; + + if (sizeof (cmsg) == msg.msg_controllen) + /* We received a file descriptor. */ + { + void *tmp; + + tmp = realloc (ctx->pendingfds, + sizeof (int) * (ctx->pendingfdscount + 1)); + if (! tmp) + { + LOG ("domain_reader: %s\n", strerror (errno)); + return -1; + } + + ctx->pendingfds = tmp; + ctx->pendingfds[ctx->pendingfdscount++] + = *(int *) CMSG_DATA (&cmsg.hdr); + + LOG ("Received file descriptor %d from peer.\n", + ctx->pendingfds[ctx->pendingfdscount - 1]); + } + + if (len == 0) + goto start; + } + + /* Return some data to the user. */ + + if (len > buflen) + /* We have more than the user requested. */ + len = buflen; + + memcpy (buf, ctx->domainbuffer + ctx->domainbufferoffset, len); + ctx->domainbuffersize -= len; + assert (ctx->domainbuffersize >= 0); + ctx->domainbufferoffset += len; + assert (ctx->domainbufferoffset <= ctx->domainbufferallocated); + + return len; +} + +/* Write to the domain server. */ +static ssize_t +domain_writer (ASSUAN_CONTEXT ctx, const void *buf, size_t buflen) +{ + struct msghdr msg; + struct iovec iovec; + ssize_t len; + + memset (&msg, 0, sizeof (msg)); + + msg.msg_name = &ctx->serveraddr; + msg.msg_namelen = offsetof (struct sockaddr_un, sun_path) + + strlen (ctx->serveraddr.sun_path) + 1; + + msg.msg_iovlen = 1; + msg.msg_iov = &iovec; + iovec.iov_base = (void *) buf; + iovec.iov_len = buflen; + msg.msg_control = 0; + msg.msg_controllen = 0; + + len = sendmsg (ctx->outbound.fd, &msg, 0); + if (len < 0) + LOG ("domain_writer: %s\n", strerror (errno)); + + return len; +} + +static AssuanError +domain_sendfd (ASSUAN_CONTEXT ctx, int fd) +{ + struct msghdr msg; + struct + { + struct cmsghdr hdr; + int fd; + } + cmsg; + int len; + + memset (&msg, 0, sizeof (msg)); + + msg.msg_name = &ctx->serveraddr; + msg.msg_namelen = offsetof (struct sockaddr_un, sun_path) + + strlen (ctx->serveraddr.sun_path) + 1; + + msg.msg_iovlen = 0; + msg.msg_iov = 0; + + cmsg.hdr.cmsg_level = SOL_SOCKET; + cmsg.hdr.cmsg_type = SCM_RIGHTS; + cmsg.hdr.cmsg_len = sizeof (cmsg); + + msg.msg_control = &cmsg; + msg.msg_controllen = sizeof (cmsg); + + *(int *) CMSG_DATA (&cmsg.hdr) = fd; + + len = sendmsg (ctx->outbound.fd, &msg, 0); + if (len < 0) + { + LOG ("domain_sendfd: %s\n", strerror (errno)); + return ASSUAN_General_Error; + } + else + return 0; +} + +static AssuanError +domain_receivefd (ASSUAN_CONTEXT ctx, int *fd) +{ + if (ctx->pendingfds == 0) + { + LOG ("No pending file descriptors!\n"); + return ASSUAN_General_Error; + } + + *fd = ctx->pendingfds[0]; + if (-- ctx->pendingfdscount == 0) + { + free (ctx->pendingfds); + ctx->pendingfds = 0; + } + else + /* Fix the array. */ + { + memmove (ctx->pendingfds, ctx->pendingfds + 1, + ctx->pendingfdscount * sizeof (int)); + ctx->pendingfds = realloc (ctx->pendingfds, + ctx->pendingfdscount * sizeof (int)); + } + + return 0; +} + + + +/* Make a connection to the Unix domain socket NAME and return a new + Assuan context in CTX. SERVER_PID is currently not used but may + become handy in the future. */ +AssuanError +_assuan_domain_init (ASSUAN_CONTEXT *r_ctx, int rendezvousfd, pid_t peer) +{ + static struct assuan_io io = { domain_reader, domain_writer, + domain_sendfd, domain_receivefd }; + + AssuanError err; + ASSUAN_CONTEXT ctx; + int fd; + size_t len; + int tries; + + if (!r_ctx) + return ASSUAN_Invalid_Value; + *r_ctx = NULL; + + err = _assuan_new_context (&ctx); + if (err) + return err; + + /* Save it in case we need it later. */ + ctx->pid = peer; + + /* Override the default (NOP) handlers. */ + ctx->deinit_handler = do_deinit; + + /* Setup the socket. */ + + fd = socket (PF_LOCAL, SOCK_DGRAM, 0); + if (fd == -1) + { + LOG ("can't create socket: %s\n", strerror (errno)); + _assuan_release_context (ctx); + return ASSUAN_General_Error; + } + + ctx->inbound.fd = fd; + ctx->outbound.fd = fd; + + /* And the io buffers. */ + + ctx->io = &io; + ctx->domainbuffer = 0; + ctx->domainbufferoffset = 0; + ctx->domainbuffersize = 0; + ctx->domainbufferallocated = 0; + ctx->pendingfds = 0; + ctx->pendingfdscount = 0; + + /* Get usable name and bind to it. */ + + for (tries = 0; tries < TMP_MAX; tries ++) + { + char *p; + char buf[L_tmpnam]; + + /* XXX: L_tmpnam must be shorter than sizeof (sun_path)! */ + assert (L_tmpnam < sizeof (ctx->myaddr.sun_path)); + + p = tmpnam (buf); + if (! p) + { + LOG ("cannot determine an appropriate temporary file " + "name. DOS in progress?\n"); + _assuan_release_context (ctx); + close (fd); + return ASSUAN_General_Error; + } + + memset (&ctx->myaddr, 0, sizeof ctx->myaddr); + ctx->myaddr.sun_family = AF_LOCAL; + len = strlen (buf) + 1; + memcpy (ctx->myaddr.sun_path, buf, len); + len += offsetof (struct sockaddr_un, sun_path); + + err = bind (fd, (struct sockaddr *) &ctx->myaddr, len); + if (! err) + break; + } + + if (err) + { + LOG ("can't bind to `%s': %s\n", ctx->myaddr.sun_path, + strerror (errno)); + _assuan_release_context (ctx); + close (fd); + return ASSUAN_Connect_Failed; + } + + /* Rendezvous with our peer. */ + { + FILE *fp; + char *p; + + fp = fdopen (rendezvousfd, "w+"); + if (! fp) + { + LOG ("can't open rendezvous port: %s\n", strerror (errno)); + return ASSUAN_Connect_Failed; + } + + /* Send our address. */ + fprintf (fp, "%s\n", ctx->myaddr.sun_path); + fflush (fp); + + /* And receive our peer's. */ + memset (&ctx->serveraddr, 0, sizeof ctx->serveraddr); + for (p = ctx->serveraddr.sun_path; + p < (ctx->serveraddr.sun_path + + sizeof ctx->serveraddr.sun_path - 1); + p ++) + { + *p = fgetc (fp); + if (*p == '\n') + break; + } + *p = '\0'; + fclose (fp); + + ctx->serveraddr.sun_family = AF_LOCAL; + } + + *r_ctx = ctx; + return 0; +} + +AssuanError +assuan_domain_connect (ASSUAN_CONTEXT * r_ctx, int rendezvousfd, pid_t peer) +{ + AssuanError aerr; + int okay, off; + + aerr = _assuan_domain_init (r_ctx, rendezvousfd, peer); + if (aerr) + return aerr; + + /* Initial handshake. */ + aerr = _assuan_read_from_server (*r_ctx, &okay, &off); + if (aerr) + LOG ("can't connect to server: %s\n", assuan_strerror (aerr)); + else if (okay != 1) + { + LOG ("can't connect to server: `"); + _assuan_log_sanitized_string ((*r_ctx)->inbound.line); + fprintf (assuan_get_assuan_log_stream (), "'\n"); + aerr = ASSUAN_Connect_Failed; + } + + if (aerr) + assuan_disconnect (*r_ctx); + + return aerr; +} diff --git a/tags/gpgme-0-4-3/assuan/assuan-domain-server.c b/tags/gpgme-0-4-3/assuan/assuan-domain-server.c new file mode 100644 index 0000000..b62b140 --- /dev/null +++ b/tags/gpgme-0-4-3/assuan/assuan-domain-server.c @@ -0,0 +1,46 @@ +/* assuan-socket-server.c - Assuan socket based server + * Copyright (C) 2002 Free Software Foundation, Inc. + * + * This file is part of Assuan. + * + * Assuan 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. + * + * Assuan 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, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA + */ + +#ifdef HAVE_CONFIG_H +#include +#endif + +#include + +#include "assuan-defs.h" + +/* Initialize a server. */ +AssuanError +assuan_init_domain_server (ASSUAN_CONTEXT *r_ctx, + int rendezvousfd, + pid_t peer) +{ + AssuanError err; + + err = _assuan_domain_init (r_ctx, rendezvousfd, peer); + if (err) + return err; + + (*r_ctx)->is_server = 1; + /* A domain server can only be used once. */ + (*r_ctx)->pipe_mode = 1; + + return 0; +} diff --git a/tags/gpgme-0-4-3/assuan/assuan-handler.c b/tags/gpgme-0-4-3/assuan/assuan-handler.c new file mode 100644 index 0000000..f8b85db --- /dev/null +++ b/tags/gpgme-0-4-3/assuan/assuan-handler.c @@ -0,0 +1,685 @@ +/* assuan-handler.c - dispatch commands + * Copyright (C) 2001, 2002, 2003 Free Software Foundation, Inc. + * + * This file is part of Assuan. + * + * Assuan 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. + * + * Assuan 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, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA + */ + +#include +#include +#include +#include + +#include "assuan-defs.h" + + + +#define spacep(p) (*(p) == ' ' || *(p) == '\t') +#define digitp(a) ((a) >= '0' && (a) <= '9') + +static int my_strcasecmp (const char *a, const char *b); + + + +static int +dummy_handler (ASSUAN_CONTEXT ctx, char *line) +{ + return set_error (ctx, Server_Fault, "no handler registered"); +} + + +static int +std_handler_nop (ASSUAN_CONTEXT ctx, char *line) +{ + return 0; /* okay */ +} + +static int +std_handler_cancel (ASSUAN_CONTEXT ctx, char *line) +{ + if (ctx->cancel_notify_fnc) + ctx->cancel_notify_fnc (ctx); + return set_error (ctx, Not_Implemented, NULL); +} + +static int +std_handler_option (ASSUAN_CONTEXT ctx, char *line) +{ + char *key, *value, *p; + + for (key=line; spacep (key); key++) + ; + if (!*key) + return set_error (ctx, Syntax_Error, "argument required"); + if (*key == '=') + return set_error (ctx, Syntax_Error, "no option name given"); + for (value=key; *value && !spacep (value) && *value != '='; value++) + ; + if (*value) + { + if (spacep (value)) + *value++ = 0; /* terminate key */ + for (; spacep (value); value++) + ; + if (*value == '=') + { + *value++ = 0; /* terminate key */ + for (; spacep (value); value++) + ; + if (!*value) + return set_error (ctx, Syntax_Error, "option argument expected"); + } + if (*value) + { + for (p = value + strlen(value) - 1; p > value && spacep (p); p--) + ; + if (p > value) + *++p = 0; /* strip trailing spaces */ + } + } + + if (*key == '-' && key[1] == '-' && key[2]) + key += 2; /* the double dashes are optional */ + if (*key == '-') + return set_error (ctx, Syntax_Error, + "option should not begin with one dash"); + + if (ctx->option_handler_fnc) + return ctx->option_handler_fnc (ctx, key, value); + return 0; +} + +static int +std_handler_bye (ASSUAN_CONTEXT ctx, char *line) +{ + if (ctx->bye_notify_fnc) + ctx->bye_notify_fnc (ctx); + assuan_close_input_fd (ctx); + assuan_close_output_fd (ctx); + return -1; /* pretty simple :-) */ +} + +static int +std_handler_auth (ASSUAN_CONTEXT ctx, char *line) +{ + return set_error (ctx, Not_Implemented, NULL); +} + +static int +std_handler_reset (ASSUAN_CONTEXT ctx, char *line) +{ + if (ctx->reset_notify_fnc) + ctx->reset_notify_fnc (ctx); + assuan_close_input_fd (ctx); + assuan_close_output_fd (ctx); + return 0; +} + +static int +std_handler_end (ASSUAN_CONTEXT ctx, char *line) +{ + return set_error (ctx, Not_Implemented, NULL); +} + +AssuanError +assuan_command_parse_fd (ASSUAN_CONTEXT ctx, char *line, int *rfd) +{ + char *endp; + + if (strncmp (line, "FD", 2) != 0 || (line[2] != '=' && line[2] != '\0')) + return set_error (ctx, Syntax_Error, "FD[=] expected"); + line += 2; + if (*line == '=') + { + line ++; + if (!digitp (*line)) + return set_error (ctx, Syntax_Error, "number required"); + *rfd = strtoul (line, &endp, 10); + /* remove that argument so that a notify handler won't see it */ + memset (line, ' ', endp? (endp-line):strlen(line)); + + if (*rfd == ctx->inbound.fd) + return set_error (ctx, Parameter_Conflict, "fd same as inbound fd"); + if (*rfd == ctx->outbound.fd) + return set_error (ctx, Parameter_Conflict, "fd same as outbound fd"); + return 0; + } + else + /* Our peer has sent the file descriptor. */ + return assuan_receivefd (ctx, rfd); +} + +/* Format is INPUT FD= */ +static int +std_handler_input (ASSUAN_CONTEXT ctx, char *line) +{ + int rc, fd; + + rc = assuan_command_parse_fd (ctx, line, &fd); + if (rc) + return rc; + ctx->input_fd = fd; + if (ctx->input_notify_fnc) + ctx->input_notify_fnc (ctx, line); + return 0; +} + +/* Format is OUTPUT FD= */ +static int +std_handler_output (ASSUAN_CONTEXT ctx, char *line) +{ + int rc, fd; + + rc = assuan_command_parse_fd (ctx, line, &fd); + if (rc) + return rc; + ctx->output_fd = fd; + if (ctx->output_notify_fnc) + ctx->output_notify_fnc (ctx, line); + return 0; +} + + + + + +/* This is a table with the standard commands and handler for them. + The table is used to initialize a new context and associate strings + with default handlers */ +static struct { + const char *name; + int (*handler)(ASSUAN_CONTEXT, char *line); + int always; /* always initialize this command */ +} std_cmd_table[] = { + { "NOP", std_handler_nop, 1 }, + { "CANCEL", std_handler_cancel, 1 }, + { "OPTION", std_handler_option, 1 }, + { "BYE", std_handler_bye, 1 }, + { "AUTH", std_handler_auth, 1 }, + { "RESET", std_handler_reset, 1 }, + { "END", std_handler_end, 1 }, + + { "INPUT", std_handler_input }, + { "OUTPUT", std_handler_output }, + { "OPTION", std_handler_option, 1 }, + { NULL } +}; + + +/** + * assuan_register_command: + * @ctx: the server context + * @cmd_name: A string with the command name + * @handler: The handler function to be called or NULL to use a default + * handler. + * + * Register a handler to be used for a given command. Note that + * several default handlers are already regsitered with a new context. + * This function however allows to override them. + * + * Return value: 0 on success or an error code + **/ +int +assuan_register_command (ASSUAN_CONTEXT ctx, + const char *cmd_name, + int (*handler)(ASSUAN_CONTEXT, char *)) +{ + int i; + const char *s; + + if (cmd_name && !*cmd_name) + cmd_name = NULL; + + if (!cmd_name) + return ASSUAN_Invalid_Value; + + if (!handler) + { /* find a default handler. */ + for (i=0; (s=std_cmd_table[i].name) && strcmp (cmd_name, s); i++) + ; + if (!s) + { /* Try again but case insensitive. */ + for (i=0; (s=std_cmd_table[i].name) + && my_strcasecmp (cmd_name, s); i++) + ; + } + if (s) + handler = std_cmd_table[i].handler; + if (!handler) + handler = dummy_handler; /* Last resort is the dummy handler. */ + } + + if (!ctx->cmdtbl) + { + ctx->cmdtbl_size = 50; + ctx->cmdtbl = xtrycalloc ( ctx->cmdtbl_size, sizeof *ctx->cmdtbl); + if (!ctx->cmdtbl) + return ASSUAN_Out_Of_Core; + ctx->cmdtbl_used = 0; + } + else if (ctx->cmdtbl_used >= ctx->cmdtbl_size) + { + struct cmdtbl_s *x; + + x = xtryrealloc ( ctx->cmdtbl, (ctx->cmdtbl_size+10) * sizeof *x); + if (!x) + return ASSUAN_Out_Of_Core; + ctx->cmdtbl = x; + ctx->cmdtbl_size += 50; + } + + ctx->cmdtbl[ctx->cmdtbl_used].name = cmd_name; + ctx->cmdtbl[ctx->cmdtbl_used].handler = handler; + ctx->cmdtbl_used++; + return 0; +} + +int +assuan_register_bye_notify (ASSUAN_CONTEXT ctx, void (*fnc)(ASSUAN_CONTEXT)) +{ + if (!ctx) + return ASSUAN_Invalid_Value; + ctx->bye_notify_fnc = fnc; + return 0; +} + +int +assuan_register_reset_notify (ASSUAN_CONTEXT ctx, void (*fnc)(ASSUAN_CONTEXT)) +{ + if (!ctx) + return ASSUAN_Invalid_Value; + ctx->reset_notify_fnc = fnc; + return 0; +} + +int +assuan_register_cancel_notify (ASSUAN_CONTEXT ctx, void (*fnc)(ASSUAN_CONTEXT)) +{ + if (!ctx) + return ASSUAN_Invalid_Value; + ctx->cancel_notify_fnc = fnc; + return 0; +} + +int +assuan_register_option_handler (ASSUAN_CONTEXT ctx, + int (*fnc)(ASSUAN_CONTEXT, + const char*, const char*)) +{ + if (!ctx) + return ASSUAN_Invalid_Value; + ctx->option_handler_fnc = fnc; + return 0; +} + +int +assuan_register_input_notify (ASSUAN_CONTEXT ctx, + void (*fnc)(ASSUAN_CONTEXT, const char *)) +{ + if (!ctx) + return ASSUAN_Invalid_Value; + ctx->input_notify_fnc = fnc; + return 0; +} + +int +assuan_register_output_notify (ASSUAN_CONTEXT ctx, + void (*fnc)(ASSUAN_CONTEXT, const char *)) +{ + if (!ctx) + return ASSUAN_Invalid_Value; + ctx->output_notify_fnc = fnc; + return 0; +} + + +/* Helper to register the standards commands */ +int +_assuan_register_std_commands (ASSUAN_CONTEXT ctx) +{ + int i, rc; + + for (i=0; std_cmd_table[i].name; i++) + { + if (std_cmd_table[i].always) + { + rc = assuan_register_command (ctx, std_cmd_table[i].name, NULL); + if (rc) + return rc; + } + } + return 0; +} + + + +/* Process the special data lines. The "D " has already been removed + from the line. As all handlers this function may modify the line. */ +static int +handle_data_line (ASSUAN_CONTEXT ctx, char *line, int linelen) +{ + return set_error (ctx, Not_Implemented, NULL); +} + +/* like ascii_strcasecmp but assume that B is already uppercase */ +static int +my_strcasecmp (const char *a, const char *b) +{ + if (a == b) + return 0; + + for (; *a && *b; a++, b++) + { + if (((*a >= 'a' && *a <= 'z')? (*a&~0x20):*a) != *b) + break; + } + return *a == *b? 0 : (((*a >= 'a' && *a <= 'z')? (*a&~0x20):*a) - *b); +} + +/* Parse the line, break out the command, find it in the command + table, remove leading and white spaces from the arguments, all the + handler with the argument line and return the error */ +static int +dispatch_command (ASSUAN_CONTEXT ctx, char *line, int linelen) +{ + char *p; + const char *s; + int shift, i; + + if (*line == 'D' && line[1] == ' ') /* divert to special handler */ + return handle_data_line (ctx, line+2, linelen-2); + + for (p=line; *p && *p != ' ' && *p != '\t'; p++) + ; + if (p==line) + return set_error (ctx, Invalid_Command, "leading white-space"); + if (*p) + { /* Skip over leading WS after the keyword */ + *p++ = 0; + while ( *p == ' ' || *p == '\t') + p++; + } + shift = p - line; + + for (i=0; (s=ctx->cmdtbl[i].name); i++) + { + if (!strcmp (line, s)) + break; + } + if (!s) + { /* and try case insensitive */ + for (i=0; (s=ctx->cmdtbl[i].name); i++) + { + if (!my_strcasecmp (line, s)) + break; + } + } + if (!s) + return set_error (ctx, Unknown_Command, NULL); + line += shift; + linelen -= shift; + +/* fprintf (stderr, "DBG-assuan: processing %s `%s'\n", s, line); */ + return ctx->cmdtbl[i].handler (ctx, line); +} + + + + +static int +process_request (ASSUAN_CONTEXT ctx) +{ + int rc; + + if (ctx->in_inquire) + return ASSUAN_Nested_Commands; + + rc = _assuan_read_line (ctx); + if (rc) + return rc; + if (*ctx->inbound.line == '#' || !ctx->inbound.linelen) + return 0; /* comment line - ignore */ + + ctx->outbound.data.error = 0; + ctx->outbound.data.linelen = 0; + /* dispatch command and return reply */ + rc = dispatch_command (ctx, ctx->inbound.line, ctx->inbound.linelen); + /* check from data write errors */ + if (ctx->outbound.data.fp) + { /* Flush the data lines */ + fclose (ctx->outbound.data.fp); + ctx->outbound.data.fp = NULL; + if (!rc && ctx->outbound.data.error) + rc = ctx->outbound.data.error; + } + else /* flush any data send w/o using the data fp */ + { + assuan_send_data (ctx, NULL, 0); + if (!rc && ctx->outbound.data.error) + rc = ctx->outbound.data.error; + } + /* Error handling */ + if (!rc) + { + rc = assuan_write_line (ctx, ctx->okay_line? ctx->okay_line : "OK"); + } + else if (rc == -1) + { /* No error checking because the peer may have already disconnect */ + assuan_write_line (ctx, "OK closing connection"); + ctx->finish_handler (ctx); + } + else + { + char errline[256]; + + if (rc < 100) + sprintf (errline, "ERR %d server fault (%.50s)", + ASSUAN_Server_Fault, assuan_strerror (rc)); + else + { + const char *text = ctx->err_no == rc? ctx->err_str:NULL; + + sprintf (errline, "ERR %d %.50s%s%.100s", + rc, assuan_strerror (rc), text? " - ":"", text?text:""); + } + rc = assuan_write_line (ctx, errline); + } + + ctx->confidential = 0; + if (ctx->okay_line) + { + xfree (ctx->okay_line); + ctx->okay_line = NULL; + } + return rc; +} + +/** + * assuan_process: + * @ctx: assuan context + * + * This fucntion is used to handle the assuan protocol after a + * connection has been established using assuan_accept(). This is the + * main protocol handler. + * + * Return value: 0 on success or an error code if the assuan operation + * failed. Note, that no error is returned for operational errors. + **/ +int +assuan_process (ASSUAN_CONTEXT ctx) +{ + int rc; + + do { + rc = process_request (ctx); + } while (!rc); + + if (rc == -1) + rc = 0; + + return rc; +} + + +/** + * assuan_process_next: + * @ctx: Assuan context + * + * Same as assuan_process() but the user has to provide the outer + * loop. He should loop as long as the return code is zero and stop + * otherwise; -1 is regular end. + * + * See also: assuan_get_active_fds() + * Return value: -1 for end of server, 0 on success or an error code + **/ +int +assuan_process_next (ASSUAN_CONTEXT ctx) +{ + return process_request (ctx); +} + + +/** + * assuan_get_active_fds: + * @ctx: Assuan context + * @what: 0 for read fds, 1 for write fds + * @fdarray: Caller supplied array to store the FDs + * @fdarraysize: size of that array + * + * Return all active filedescriptors for the given context. This + * function can be used to select on the fds and call + * assuan_process_next() if there is an active one. The first fd in + * the array is the one used for the command connection. + * + * Note, that write FDs are not yet supported. + * + * Return value: number of FDs active and put into @fdarray or -1 on + * error which is most likely a too small fdarray. + **/ +int +assuan_get_active_fds (ASSUAN_CONTEXT ctx, int what, + int *fdarray, int fdarraysize) +{ + int n = 0; + + if (!ctx || fdarraysize < 2 || what < 0 || what > 1) + return -1; + + if (!what) + { + if (ctx->inbound.fd != -1) + fdarray[n++] = ctx->inbound.fd; + } + else + { + if (ctx->outbound.fd != -1) + fdarray[n++] = ctx->outbound.fd; + if (ctx->outbound.data.fp) + fdarray[n++] = fileno (ctx->outbound.data.fp); + } + + return n; +} + +/* Return a FP to be used for data output. The FILE pointer is valid + until the end of a handler. So a close is not needed. Assuan does + all the buffering needed to insert the status line as well as the + required line wappping and quoting for data lines. + + We use GNU's custom streams here. There should be an alternative + implementaion for systems w/o a glibc, a simple implementation + could use a child process */ +FILE * +assuan_get_data_fp (ASSUAN_CONTEXT ctx) +{ + if (ctx->outbound.data.fp) + return ctx->outbound.data.fp; + + + ctx->outbound.data.fp = funopen (ctx, 0, + _assuan_cookie_write_data, + 0, _assuan_cookie_write_flush); + ctx->outbound.data.error = 0; + return ctx->outbound.data.fp; +} + + +/* Set the text used for the next OK reponse. This string is + automatically reset to NULL after the next command. */ +AssuanError +assuan_set_okay_line (ASSUAN_CONTEXT ctx, const char *line) +{ + if (!ctx) + return ASSUAN_Invalid_Value; + if (!line) + { + xfree (ctx->okay_line); + ctx->okay_line = NULL; + } + else + { + /* FIXME: we need to use gcry_is_secure() to test whether + we should allocate the entire line in secure memory */ + char *buf = xtrymalloc (3+strlen(line)+1); + if (!buf) + return ASSUAN_Out_Of_Core; + strcpy (buf, "OK "); + strcpy (buf+3, line); + xfree (ctx->okay_line); + ctx->okay_line = buf; + } + return 0; +} + + + +void +assuan_write_status (ASSUAN_CONTEXT ctx, const char *keyword, const char *text) +{ + char buffer[256]; + char *helpbuf; + size_t n; + + if ( !ctx || !keyword) + return; + if (!text) + text = ""; + + n = 2 + strlen (keyword) + 1 + strlen (text) + 1; + if (n < sizeof (buffer)) + { + strcpy (buffer, "S "); + strcat (buffer, keyword); + if (*text) + { + strcat (buffer, " "); + strcat (buffer, text); + } + assuan_write_line (ctx, buffer); + } + else if ( (helpbuf = xtrymalloc (n)) ) + { + strcpy (helpbuf, "S "); + strcat (helpbuf, keyword); + if (*text) + { + strcat (helpbuf, " "); + strcat (helpbuf, text); + } + assuan_write_line (ctx, helpbuf); + xfree (helpbuf); + } +} diff --git a/tags/gpgme-0-4-3/assuan/assuan-inquire.c b/tags/gpgme-0-4-3/assuan/assuan-inquire.c new file mode 100644 index 0000000..ec9d8e6 --- /dev/null +++ b/tags/gpgme-0-4-3/assuan/assuan-inquire.c @@ -0,0 +1,240 @@ +/* assuan-inquire.c - handle inquire stuff + * Copyright (C) 2001, 2002, 2003 Free Software Foundation, Inc. + * + * This file is part of Assuan. + * + * Assuan 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. + * + * Assuan 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, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA + */ + +#include +#include +#include +#include + +#include "assuan-defs.h" + +#define digitp(a) ((a) >= '0' && (a) <= '9') +#define xtoi_1(p) (*(p) <= '9'? (*(p)- '0'): \ + *(p) <= 'F'? (*(p)-'A'+10):(*(p)-'a'+10)) +#define xtoi_2(p) ((xtoi_1(p) * 16) + xtoi_1((p)+1)) + + +struct membuf +{ + size_t len; + size_t size; + char *buf; + int out_of_core; + int too_large; + size_t maxlen; +}; + + + +/* A simple implemnation of a dynamic buffer. Use init_membuf() to + create a buffer, put_membuf to append bytes and get_membuf to + release and return the buffer. Allocation errors are detected but + only returned at the final get_membuf(), this helps not to clutter + the code with out of core checks. */ + +static void +init_membuf (struct membuf *mb, int initiallen, size_t maxlen) +{ + mb->len = 0; + mb->size = initiallen; + mb->out_of_core = 0; + mb->too_large = 0; + mb->maxlen = maxlen; + /* we need to allocate one byte more for get_membuf */ + mb->buf = xtrymalloc (initiallen+1); + if (!mb->buf) + mb->out_of_core = 1; +} + +static void +put_membuf (struct membuf *mb, const void *buf, size_t len) +{ + if (mb->out_of_core || mb->too_large) + return; + + if (mb->maxlen && mb->len + len > mb->maxlen) + { + mb->too_large = 1; + return; + } + + if (mb->len + len >= mb->size) + { + char *p; + + mb->size += len + 1024; + /* we need to allocate one byte more for get_membuf */ + p = xtryrealloc (mb->buf, mb->size+1); + if (!p) + { + mb->out_of_core = 1; + return; + } + mb->buf = p; + } + memcpy (mb->buf + mb->len, buf, len); + mb->len += len; +} + +static void * +get_membuf (struct membuf *mb, size_t *len) +{ + char *p; + + if (mb->out_of_core || mb->too_large) + { + xfree (mb->buf); + mb->buf = NULL; + return NULL; + } + + mb->buf[mb->len] = 0; /* there is enough space for the hidden eos */ + p = mb->buf; + *len = mb->len; + mb->buf = NULL; + mb->out_of_core = 1; /* don't allow a reuse */ + return p; +} + +static void +free_membuf (struct membuf *mb) +{ + xfree (mb->buf); + mb->buf = NULL; +} + + +/** + * assuan_inquire: + * @ctx: An assuan context + * @keyword: The keyword used for the inquire + * @r_buffer: Returns an allocated buffer + * @r_length: Returns the length of this buffer + * @maxlen: If not 0, the size limit of the inquired data. + * + * A Server may use this to Send an inquire. r_buffer, r_length and + * maxlen may all be NULL/0 to indicate that no real data is expected. + * + * Return value: 0 on success or an ASSUAN error code + **/ +AssuanError +assuan_inquire (ASSUAN_CONTEXT ctx, const char *keyword, + char **r_buffer, size_t *r_length, size_t maxlen) +{ + AssuanError rc; + struct membuf mb; + char cmdbuf[LINELENGTH-10]; /* (10 = strlen ("INQUIRE ")+CR,LF) */ + unsigned char *line, *p; + int linelen; + int nodataexpected; + + if (!ctx || !keyword || (10 + strlen (keyword) >= sizeof (cmdbuf))) + return ASSUAN_Invalid_Value; + nodataexpected = !r_buffer && !r_length && !maxlen; + if (!nodataexpected && (!r_buffer || !r_length)) + return ASSUAN_Invalid_Value; + if (!ctx->is_server) + return ASSUAN_Not_A_Server; + if (ctx->in_inquire) + return ASSUAN_Nested_Commands; + + ctx->in_inquire = 1; + if (nodataexpected) + memset (&mb, 0, sizeof mb); /* avoid compiler warnings */ + else + init_membuf (&mb, maxlen? maxlen:1024, maxlen); + + strcpy (stpcpy (cmdbuf, "INQUIRE "), keyword); + rc = assuan_write_line (ctx, cmdbuf); + if (rc) + goto leave; + + for (;;) + { + do + { + rc = _assuan_read_line (ctx); + if (rc) + goto leave; + line = ctx->inbound.line; + linelen = ctx->inbound.linelen; + } + while (*line == '#' || !linelen); + if (line[0] == 'E' && line[1] == 'N' && line[2] == 'D' + && (!line[3] || line[3] == ' ')) + break; /* END command received*/ + if (line[0] == 'C' && line[1] == 'A' && line[2] == 'N') + { + rc = ASSUAN_Canceled; + goto leave; + } + if (line[0] != 'D' || line[1] != ' ' || nodataexpected) + { + rc = ASSUAN_Unexpected_Command; + goto leave; + } + if (linelen < 3) + continue; + line += 2; + linelen -= 2; + + p = line; + while (linelen) + { + for (;linelen && *p != '%'; linelen--, p++) + ; + put_membuf (&mb, line, p-line); + if (linelen > 2) + { /* handle escaping */ + unsigned char tmp[1]; + p++; + *tmp = xtoi_2 (p); + p += 2; + linelen -= 3; + put_membuf (&mb, tmp, 1); + } + line = p; + } + if (mb.too_large) + { + rc = ASSUAN_Too_Much_Data; + goto leave; + } + } + + if (!nodataexpected) + { + *r_buffer = get_membuf (&mb, r_length); + if (!*r_buffer) + rc = ASSUAN_Out_Of_Core; + } + + leave: + if (!nodataexpected) + free_membuf (&mb); + ctx->in_inquire = 0; + return rc; +} + + + + + + diff --git a/tags/gpgme-0-4-3/assuan/assuan-io.c b/tags/gpgme-0-4-3/assuan/assuan-io.c new file mode 100644 index 0000000..5dca009 --- /dev/null +++ b/tags/gpgme-0-4-3/assuan/assuan-io.c @@ -0,0 +1,58 @@ +/* assuan-io.c - Wraps the read and write functions. + * Copyright (C) 2002 Free Software Foundation, Inc. + * + * This file is part of Assuan. + * + * Assuan 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. + * + * Assuan 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, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA + */ + +#include "assuan-defs.h" +#include +#include + +#ifdef _ASSUAN_IN_GPGME +ssize_t +_assuan_simple_read (ASSUAN_CONTEXT ctx, void *buffer, size_t size) +{ + return read (ctx->inbound.fd, buffer, size); +} + +ssize_t +_assuan_simple_write (ASSUAN_CONTEXT ctx, const void *buffer, size_t size) +{ + return write (ctx->outbound.fd, buffer, size); +} + +#else + +extern ssize_t pth_read (int fd, void *buffer, size_t size); +extern ssize_t pth_write (int fd, const void *buffer, size_t size); + +#pragma weak pth_read +#pragma weak pth_write + +ssize_t +_assuan_simple_read (ASSUAN_CONTEXT ctx, void *buffer, size_t size) +{ + return (pth_read ? pth_read : read) (ctx->inbound.fd, buffer, size); +} + +ssize_t +_assuan_simple_write (ASSUAN_CONTEXT ctx, const void *buffer, size_t size) +{ + return (pth_write ? pth_write : write) (ctx->outbound.fd, buffer, size); +} + +#endif diff --git a/tags/gpgme-0-4-3/assuan/assuan-listen.c b/tags/gpgme-0-4-3/assuan/assuan-listen.c new file mode 100644 index 0000000..aae3f7b --- /dev/null +++ b/tags/gpgme-0-4-3/assuan/assuan-listen.c @@ -0,0 +1,132 @@ +/* assuan-listen.c - Wait for a connection (server) + * Copyright (C) 2001, 2002 Free Software Foundation, Inc. + * + * This file is part of Assuan. + * + * Assuan 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. + * + * Assuan 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, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA + */ + +#include +#include +#include +#include +#include + +#include "assuan-defs.h" + +AssuanError +assuan_set_hello_line (ASSUAN_CONTEXT ctx, const char *line) +{ + if (!ctx) + return ASSUAN_Invalid_Value; + if (!line) + { + xfree (ctx->hello_line); + ctx->hello_line = NULL; + } + else + { + char *buf = xtrymalloc (3+strlen(line)+1); + if (!buf) + return ASSUAN_Out_Of_Core; + strcpy (buf, "OK "); + strcpy (buf+3, line); + xfree (ctx->hello_line); + ctx->hello_line = buf; + } + return 0; +} + + +/** + * assuan_accept: + * @ctx: context + * + * Cancel any existing connection and wait for a connection from a + * client. The initial handshake is performed which may include an + * initial authentication or encryption negotiation. + * + * Return value: 0 on success or an error if the connection could for + * some reason not be established. + **/ +AssuanError +assuan_accept (ASSUAN_CONTEXT ctx) +{ + int rc; + + if (!ctx) + return ASSUAN_Invalid_Value; + + if (ctx->pipe_mode > 1) + return -1; /* second invocation for pipemode -> terminate */ + ctx->finish_handler (ctx); + + rc = ctx->accept_handler (ctx); + if (rc) + return rc; + + /* send the hello */ + rc = assuan_write_line (ctx, ctx->hello_line? ctx->hello_line + : "OK Your orders please"); + if (rc) + return rc; + + if (ctx->pipe_mode) + ctx->pipe_mode = 2; + + return 0; +} + + + +int +assuan_get_input_fd (ASSUAN_CONTEXT ctx) +{ + return ctx? ctx->input_fd : -1; +} + + +int +assuan_get_output_fd (ASSUAN_CONTEXT ctx) +{ + return ctx? ctx->output_fd : -1; +} + + +/* Close the fd descriptor set by the command INPUT FD=n. We handle + this fd inside assuan so that we can do some initial checks */ +AssuanError +assuan_close_input_fd (ASSUAN_CONTEXT ctx) +{ + if (!ctx || ctx->input_fd == -1) + return ASSUAN_Invalid_Value; + close (ctx->input_fd); + ctx->input_fd = -1; + return 0; +} + +/* Close the fd descriptor set by the command OUTPUT FD=n. We handle + this fd inside assuan so that we can do some initial checks */ +AssuanError +assuan_close_output_fd (ASSUAN_CONTEXT ctx) +{ + if (!ctx || ctx->output_fd == -1) + return ASSUAN_Invalid_Value; + + close (ctx->output_fd); + ctx->output_fd = -1; + return 0; +} + diff --git a/tags/gpgme-0-4-3/assuan/assuan-logging.c b/tags/gpgme-0-4-3/assuan/assuan-logging.c new file mode 100644 index 0000000..340ce72 --- /dev/null +++ b/tags/gpgme-0-4-3/assuan/assuan-logging.c @@ -0,0 +1,42 @@ +/* assuan-logging.c - Default logging function. + * Copyright (C) 2002, 2003 Free Software Foundation, Inc. + * + * This file is part of Assuan. + * + * Assuan 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. + * + * Assuan 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, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA + */ + +#include "assuan-defs.h" +#include + +static FILE *_assuan_log; + +void +assuan_set_assuan_log_stream (FILE *fp) +{ + _assuan_log = fp; +} + +FILE * +assuan_get_assuan_log_stream (void) +{ + return _assuan_log ? _assuan_log : stderr; +} + +const char * +assuan_get_assuan_log_prefix (void) +{ + return ""; +} diff --git a/tags/gpgme-0-4-3/assuan/assuan-pipe-connect.c b/tags/gpgme-0-4-3/assuan/assuan-pipe-connect.c new file mode 100644 index 0000000..a3ddc22 --- /dev/null +++ b/tags/gpgme-0-4-3/assuan/assuan-pipe-connect.c @@ -0,0 +1,285 @@ +/* assuan-pipe-connect.c - Establish a pipe connection (client) + * Copyright (C) 2001, 2002, 2003 Free Software Foundation, Inc. + * + * This file is part of Assuan. + * + * Assuan 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. + * + * Assuan 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, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA + */ + +#ifdef HAVE_CONFIG_H +#include +#endif + +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include "assuan-defs.h" + +#ifdef _POSIX_OPEN_MAX +#define MAX_OPEN_FDS _POSIX_OPEN_MAX +#else +#define MAX_OPEN_FDS 20 +#endif + +#define LOG(format, args...) \ + fprintf (assuan_get_assuan_log_stream (), \ + assuan_get_assuan_log_prefix (), \ + "%s" format , ## args) + +static int +writen (int fd, const char *buffer, size_t length) +{ + while (length) + { + int nwritten = write (fd, buffer, length); + + if (nwritten < 0) + { + if (errno == EINTR) + continue; + return -1; /* write error */ + } + length -= nwritten; + buffer += nwritten; + } + return 0; /* okay */ +} + + +static int +do_finish (ASSUAN_CONTEXT ctx) +{ + if (ctx->inbound.fd != -1) + { + close (ctx->inbound.fd); + ctx->inbound.fd = -1; + } + if (ctx->outbound.fd != -1) + { + close (ctx->outbound.fd); + ctx->outbound.fd = -1; + } + if (ctx->pid != -1) + { + waitpid (ctx->pid, NULL, 0); /* FIXME Check return value. */ + ctx->pid = -1; + } + return 0; +} + +static void +do_deinit (ASSUAN_CONTEXT ctx) +{ + do_finish (ctx); +} + + + +/* Connect to a server over a pipe, creating the assuan context and + returning it in CTX. The server filename is NAME, the argument + vector in ARGV. FD_CHILD_LIST is a -1 terminated list of file + descriptors not to close in the child. */ +AssuanError +assuan_pipe_connect (ASSUAN_CONTEXT *ctx, const char *name, char *const argv[], + int *fd_child_list) +{ +#ifndef _ASSUAN_IN_GPGME + static int fixed_signals = 0; +#endif + AssuanError err; + int rp[2]; + int wp[2]; + + if (!ctx || !name || !argv || !argv[0]) + return ASSUAN_Invalid_Value; + +#ifndef _ASSUAN_IN_GPGME + if (!fixed_signals) + { + struct sigaction act; + + sigaction (SIGPIPE, NULL, &act); + if (act.sa_handler == SIG_DFL) + { + act.sa_handler = SIG_IGN; + sigemptyset (&act.sa_mask); + act.sa_flags = 0; + sigaction (SIGPIPE, &act, NULL); + } + fixed_signals = 1; + /* FIXME: This is not MT safe */ + } +#endif + + if (pipe (rp) < 0) + return ASSUAN_General_Error; + + if (pipe (wp) < 0) + { + close (rp[0]); + close (rp[1]); + return ASSUAN_General_Error; + } + + err = _assuan_new_context (ctx); + if (err) + { + close (rp[0]); + close (rp[1]); + close (wp[0]); + close (wp[1]); + return err; + } + (*ctx)->pipe_mode = 1; + (*ctx)->inbound.fd = rp[0]; /* Our inbound is read end of read pipe. */ + (*ctx)->outbound.fd = wp[1]; /* Our outbound is write end of write pipe. */ + (*ctx)->deinit_handler = do_deinit; + (*ctx)->finish_handler = do_finish; + + (*ctx)->pid = fork (); + if ((*ctx)->pid < 0) + { + close (rp[0]); + close (rp[1]); + close (wp[0]); + close (wp[1]); + _assuan_release_context (*ctx); + return ASSUAN_General_Error; + } + + if ((*ctx)->pid == 0) + { + int i, n; + char errbuf[512]; + int *fdp; + + /* Dup handles to stdin/stdout. */ + if (rp[1] != STDOUT_FILENO) + { + if (dup2 (rp[1], STDOUT_FILENO) == -1) + { + LOG ("dup2 failed in child: %s\n", strerror (errno)); + _exit (4); + } + } + if (wp[0] != STDIN_FILENO) + { + if (dup2 (wp[0], STDIN_FILENO) == -1) + { + LOG ("dup2 failed in child: %s\n", strerror (errno)); + _exit (4); + } + } + + /* Dup stderr to /dev/null unless it is in the list of FDs to be + passed to the child. */ + fdp = fd_child_list; + if (fdp) + { + for (; *fdp != -1 && *fdp != STDERR_FILENO; fdp++) + ; + } + if (!fdp || *fdp == -1) + { + int fd = open ("/dev/null", O_WRONLY); + if (fd == -1) + { + LOG ("can't open `/dev/null': %s\n", strerror (errno)); + _exit (4); + } + if (dup2 (fd, STDERR_FILENO) == -1) + { + LOG ("dup2(dev/null, 2) failed: %s\n", strerror (errno)); + _exit (4); + } + } + + + /* Close all files which will not be duped and are not in the + fd_child_list. */ + n = sysconf (_SC_OPEN_MAX); + if (n < 0) + n = MAX_OPEN_FDS; + for (i=0; i < n; i++) + { + if ( i == STDIN_FILENO || i == STDOUT_FILENO || i == STDERR_FILENO) + continue; + fdp = fd_child_list; + if (fdp) + { + while (*fdp != -1 && *fdp != i) + fdp++; + } + + if (!(fdp && *fdp != -1)) + close(i); + } + errno = 0; + + execv (name, argv); + /* oops - use the pipe to tell the parent about it */ + snprintf (errbuf, sizeof(errbuf)-1, "ERR %d can't exec `%s': %.50s\n", + ASSUAN_Problem_Starting_Server, name, strerror (errno)); + errbuf[sizeof(errbuf)-1] = 0; + writen (1, errbuf, strlen (errbuf)); + _exit (4); + } + + close (rp[1]); + close (wp[0]); + + /* initial handshake */ + { + int okay, off; + + err = _assuan_read_from_server (*ctx, &okay, &off); + if (err) + LOG ("can't connect server: %s\n", assuan_strerror (err)); + else if (okay != 1) + { + LOG ("can't connect server: `%s'\n", (*ctx)->inbound.line); + err = ASSUAN_Connect_Failed; + } + } + + if (err) + { + assuan_disconnect (*ctx); + *ctx = NULL; + } + + return err; +} + + + + + + + + + + + + + + diff --git a/tags/gpgme-0-4-3/assuan/assuan-pipe-server.c b/tags/gpgme-0-4-3/assuan/assuan-pipe-server.c new file mode 100644 index 0000000..ba269b0 --- /dev/null +++ b/tags/gpgme-0-4-3/assuan/assuan-pipe-server.c @@ -0,0 +1,129 @@ +/* assuan-pipe-server.c - Assuan server working over a pipe + * Copyright (C) 2001, 2002 Free Software Foundation, Inc. + * + * This file is part of Assuan. + * + * Assuan 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. + * + * Assuan 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, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA + */ + +#include +#include +#include +#include + +#include "assuan-defs.h" + +static void +deinit_pipe_server (ASSUAN_CONTEXT ctx) +{ + /* nothing to do for this simple server */ +} + +static int +accept_connection (ASSUAN_CONTEXT ctx) +{ + /* This is a NOP for a pipe server */ + return 0; +} + +static int +finish_connection (ASSUAN_CONTEXT ctx) +{ + /* This is a NOP for a pipe server */ + return 0; +} + +/* Create a new context. Note that the handlers are set up for a pipe + server/client - this way we don't need extra dummy functions */ +int +_assuan_new_context (ASSUAN_CONTEXT *r_ctx) +{ + static struct assuan_io io = { _assuan_simple_read, + _assuan_simple_write, + 0, 0 }; + + ASSUAN_CONTEXT ctx; + int rc; + + *r_ctx = NULL; + ctx = xtrycalloc (1, sizeof *ctx); + if (!ctx) + return ASSUAN_Out_Of_Core; + ctx->input_fd = -1; + ctx->output_fd = -1; + + ctx->inbound.fd = -1; + ctx->outbound.fd = -1; + ctx->io = &io; + + ctx->listen_fd = -1; + ctx->client_pid = (pid_t)-1; + /* Use the pipe server handler as a default. */ + ctx->deinit_handler = deinit_pipe_server; + ctx->accept_handler = accept_connection; + ctx->finish_handler = finish_connection; + + rc = _assuan_register_std_commands (ctx); + if (rc) + xfree (ctx); + else + *r_ctx = ctx; + return rc; +} + + + +int +assuan_init_pipe_server (ASSUAN_CONTEXT *r_ctx, int filedes[2]) +{ + int rc; + + rc = _assuan_new_context (r_ctx); + if (!rc) + { + ASSUAN_CONTEXT ctx = *r_ctx; + + ctx->is_server = 1; + ctx->inbound.fd = filedes[0]; + ctx->outbound.fd = filedes[1]; + ctx->pipe_mode = 1; + } + return rc; +} + + +void +_assuan_release_context (ASSUAN_CONTEXT ctx) +{ + if (ctx) + { + xfree (ctx->hello_line); + xfree (ctx->okay_line); + xfree (ctx); + } +} + +void +assuan_deinit_server (ASSUAN_CONTEXT ctx) +{ + if (ctx) + { + /* We use this function pointer to avoid linking other server + when not needed but still allow for a generic deinit function. */ + ctx->deinit_handler (ctx); + ctx->deinit_handler = NULL; + _assuan_release_context (ctx); + } +} diff --git a/tags/gpgme-0-4-3/assuan/assuan-socket-connect.c b/tags/gpgme-0-4-3/assuan/assuan-socket-connect.c new file mode 100644 index 0000000..a7246cc --- /dev/null +++ b/tags/gpgme-0-4-3/assuan/assuan-socket-connect.c @@ -0,0 +1,137 @@ +/* assuan-socket-connect.c - Assuan socket based client + * Copyright (C) 2002, 2003 Free Software Foundation, Inc. + * + * This file is part of Assuan. + * + * Assuan 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. + * + * Assuan 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, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA + */ + +#include +#include +#include +#include +#include +#include +#include +#include + +#include "assuan-defs.h" + +#define LOG(format, args...) \ + fprintf (assuan_get_assuan_log_stream (), \ + assuan_get_assuan_log_prefix (), \ + "%s" format , ## args) + +static int +do_finish (ASSUAN_CONTEXT ctx) +{ + if (ctx->inbound.fd != -1) + { + close (ctx->inbound.fd); + } + ctx->inbound.fd = -1; + ctx->outbound.fd = -1; + return 0; +} + +static void +do_deinit (ASSUAN_CONTEXT ctx) +{ + do_finish (ctx); +} +/* Make a connection to the Unix domain socket NAME and return a new + Assuan context in CTX. SERVER_PID is currently not used but may + become handy in the future. */ +AssuanError +assuan_socket_connect (ASSUAN_CONTEXT *r_ctx, + const char *name, pid_t server_pid) +{ + static struct assuan_io io = { _assuan_simple_read, + _assuan_simple_write }; + + AssuanError err; + ASSUAN_CONTEXT ctx; + int fd; + struct sockaddr_un srvr_addr; + size_t len; + + if (!r_ctx || !name) + return ASSUAN_Invalid_Value; + *r_ctx = NULL; + + /* we require that the name starts with a slash, so that we can + alter reuse this function for other socket types */ + if (*name != '/') + return ASSUAN_Invalid_Value; + if (strlen (name)+1 >= sizeof srvr_addr.sun_path) + return ASSUAN_Invalid_Value; + + err = _assuan_new_context (&ctx); + if (err) + return err; + ctx->pid = server_pid; /* save it in case we need it later */ + ctx->deinit_handler = do_deinit; + ctx->finish_handler = do_finish; + + fd = socket (PF_LOCAL, SOCK_STREAM, 0); + if (fd == -1) + { + LOG ("can't create socket: %s\n", strerror (errno)); + _assuan_release_context (ctx); + return ASSUAN_General_Error; + } + + memset (&srvr_addr, 0, sizeof srvr_addr); + srvr_addr.sun_family = AF_LOCAL; + len = strlen (srvr_addr.sun_path) + 1; + memcpy (srvr_addr.sun_path, name, len); + len += (offsetof (struct sockaddr_un, sun_path)); + + if (connect (fd, (struct sockaddr *) &srvr_addr, len) == -1) + { + LOG ("can't connect to `%s': %s\n", name, strerror (errno)); + _assuan_release_context (ctx); + close (fd); + return ASSUAN_Connect_Failed; + } + + ctx->inbound.fd = fd; + ctx->outbound.fd = fd; + ctx->io = &io; + + /* initial handshake */ + { + int okay, off; + + err = _assuan_read_from_server (ctx, &okay, &off); + if (err) + LOG ("can't connect to server: %s\n", assuan_strerror (err)); + else if (okay != 1) + { + LOG ("can't connect to server: `"); + _assuan_log_sanitized_string (ctx->inbound.line); + fprintf (assuan_get_assuan_log_stream (), "'\n"); + err = ASSUAN_Connect_Failed; + } + } + + if (err) + { + assuan_disconnect (ctx); + } + else + *r_ctx = ctx; + return 0; +} diff --git a/tags/gpgme-0-4-3/assuan/assuan-socket-server.c b/tags/gpgme-0-4-3/assuan/assuan-socket-server.c new file mode 100644 index 0000000..8d23a6b --- /dev/null +++ b/tags/gpgme-0-4-3/assuan/assuan-socket-server.c @@ -0,0 +1,174 @@ +/* assuan-socket-server.c - Assuan socket based server + * Copyright (C) 2002 Free Software Foundation, Inc. + * + * This file is part of Assuan. + * + * Assuan 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. + * + * Assuan 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, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA + */ + +#include +#include +#include +#include +#include +#include +#include + +#include "assuan-defs.h" + +static int +accept_connection_bottom (ASSUAN_CONTEXT ctx) +{ + int fd = ctx->connected_fd; + + ctx->client_pid = (pid_t)-1; +#ifdef HAVE_SO_PEERCRED + { + struct ucred cr; + int cl = sizeof cr; + + if ( !getsockopt (fd, SOL_SOCKET, SO_PEERCRED, &cr, &cl) ) + ctx->client_pid = cr.pid; + } +#endif + + ctx->inbound.fd = fd; + ctx->inbound.eof = 0; + ctx->inbound.linelen = 0; + ctx->inbound.attic.linelen = 0; + ctx->inbound.attic.pending = 0; + + ctx->outbound.fd = fd; + ctx->outbound.data.linelen = 0; + ctx->outbound.data.error = 0; + + ctx->confidential = 0; + + return 0; +} + + +static int +accept_connection (ASSUAN_CONTEXT ctx) +{ + int fd; + struct sockaddr_un clnt_addr; + size_t len = sizeof clnt_addr; + + ctx->client_pid = (pid_t)-1; + fd = accept (ctx->listen_fd, (struct sockaddr*)&clnt_addr, &len ); + if (fd == -1) + { + ctx->os_errno = errno; + return ASSUAN_Accept_Failed; + } + + ctx->connected_fd = fd; + return accept_connection_bottom (ctx); +} + +static int +finish_connection (ASSUAN_CONTEXT ctx) +{ + if (ctx->inbound.fd != -1) + { + close (ctx->inbound.fd); + } + ctx->inbound.fd = -1; + ctx->outbound.fd = -1; + return 0; +} + + +static void +deinit_socket_server (ASSUAN_CONTEXT ctx) +{ + finish_connection (ctx); +} + +static struct assuan_io io = { _assuan_simple_read, + _assuan_simple_write }; + +/* Initialize a server for the socket LISTEN_FD which has already be + put into listen mode */ +int +assuan_init_socket_server (ASSUAN_CONTEXT *r_ctx, int listen_fd) +{ + ASSUAN_CONTEXT ctx; + int rc; + + *r_ctx = NULL; + ctx = xtrycalloc (1, sizeof *ctx); + if (!ctx) + return ASSUAN_Out_Of_Core; + ctx->is_server = 1; + ctx->input_fd = -1; + ctx->output_fd = -1; + + ctx->inbound.fd = -1; + ctx->outbound.fd = -1; + + ctx->listen_fd = listen_fd; + ctx->connected_fd = -1; + ctx->deinit_handler = deinit_socket_server; + ctx->accept_handler = accept_connection; + ctx->finish_handler = finish_connection; + + ctx->io = &io; + + rc = _assuan_register_std_commands (ctx); + if (rc) + xfree (ctx); + else + *r_ctx = ctx; + return rc; +} + +/* Initialize a server using the already accepted socket FD. */ +int +assuan_init_connected_socket_server (ASSUAN_CONTEXT *r_ctx, int fd) +{ + ASSUAN_CONTEXT ctx; + int rc; + + *r_ctx = NULL; + ctx = xtrycalloc (1, sizeof *ctx); + if (!ctx) + return ASSUAN_Out_Of_Core; + ctx->is_server = 1; + ctx->pipe_mode = 1; /* we want a second accept to indicate EOF */ + ctx->input_fd = -1; + ctx->output_fd = -1; + + ctx->inbound.fd = -1; + ctx->outbound.fd = -1; + + ctx->io = &io; + + ctx->listen_fd = -1; + ctx->connected_fd = fd; + ctx->deinit_handler = deinit_socket_server; + ctx->accept_handler = accept_connection_bottom; + ctx->finish_handler = finish_connection; + + rc = _assuan_register_std_commands (ctx); + if (rc) + xfree (ctx); + else + *r_ctx = ctx; + return rc; +} + + diff --git a/tags/gpgme-0-4-3/assuan/assuan-util.c b/tags/gpgme-0-4-3/assuan/assuan-util.c new file mode 100644 index 0000000..fc0beed --- /dev/null +++ b/tags/gpgme-0-4-3/assuan/assuan-util.c @@ -0,0 +1,219 @@ +/* assuan-util.c - Utility functions for Assuan + * Copyright (C) 2001, 2002, 2003 Free Software Foundation, Inc. + * + * This file is part of Assuan. + * + * Assuan 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. + * + * Assuan 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, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA + */ + +#include +#include +#include +#include +#include + +#include "assuan-defs.h" + +static void *(*alloc_func)(size_t n) = malloc; +static void *(*realloc_func)(void *p, size_t n) = realloc; +static void (*free_func)(void*) = free; + +void +assuan_set_malloc_hooks ( void *(*new_alloc_func)(size_t n), + void *(*new_realloc_func)(void *p, size_t n), + void (*new_free_func)(void*) ) +{ + alloc_func = new_alloc_func; + realloc_func = new_realloc_func; + free_func = new_free_func; +} + +void * +_assuan_malloc (size_t n) +{ + return alloc_func (n); +} + +void * +_assuan_realloc (void *a, size_t n) +{ + return realloc_func (a, n); +} + +void * +_assuan_calloc (size_t n, size_t m) +{ + void *p = _assuan_malloc (n*m); + if (p) + memset (p, 0, n* m); + return p; +} + +void +_assuan_free (void *p) +{ + if (p) + free_func (p); +} + + +/* Store the error in the context so that the error sending function + can take out a descriptive text. Inside the assuan code, use the + macro set_error instead of this function. */ +int +assuan_set_error (ASSUAN_CONTEXT ctx, int err, const char *text) +{ + ctx->err_no = err; + ctx->err_str = text; + return err; +} + +void +assuan_set_pointer (ASSUAN_CONTEXT ctx, void *pointer) +{ + if (ctx) + ctx->user_pointer = pointer; +} + +void * +assuan_get_pointer (ASSUAN_CONTEXT ctx) +{ + return ctx? ctx->user_pointer : NULL; +} + + +void +assuan_set_log_stream (ASSUAN_CONTEXT ctx, FILE *fp) +{ + if (ctx) + { + if (ctx->log_fp) + fflush (ctx->log_fp); + ctx->log_fp = fp; + } +} + + +void +assuan_begin_confidential (ASSUAN_CONTEXT ctx) +{ + if (ctx) + { + ctx->confidential = 1; + } +} + +void +assuan_end_confidential (ASSUAN_CONTEXT ctx) +{ + if (ctx) + { + ctx->confidential = 0; + } +} + +/* Dump a possibly binary string (used for debugging). Distinguish + ascii text from binary and print it accordingly. */ +void +_assuan_log_print_buffer (FILE *fp, const void *buffer, size_t length) +{ + const unsigned char *s; + int n; + + for (n=length,s=buffer; n; n--, s++) + if (!isascii (*s) || iscntrl (*s) || !isprint (*s)) + break; + + s = buffer; + if (!n && *s != '[') + fwrite (buffer, length, 1, fp); + else + { +#ifdef HAVE_FLOCKFILE + flockfile (fp); +#endif + putc_unlocked ('[', fp); + for (n=0; n < length; n++, s++) + fprintf (fp, " %02x", *s); + putc_unlocked (' ', fp); + putc_unlocked (']', fp); +#ifdef HAVE_FUNLOCKFILE + funlockfile (fp); +#endif + } +} + +/* Log a user supplied string. Escapes non-printable before + printing. */ +void +_assuan_log_sanitized_string (const char *string) +{ + const unsigned char *s = string; + FILE *fp = assuan_get_assuan_log_stream (); + + if (! *s) + return; + +#ifdef HAVE_FLOCKFILE + flockfile (fp); +#endif + + for (; *s; s++) + { + int c = 0; + + switch (*s) + { + case '\r': + c = 'r'; + break; + + case '\n': + c = 'n'; + break; + + case '\f': + c = 'f'; + break; + + case '\v': + c = 'v'; + break; + + case '\b': + c = 'b'; + break; + + default: + if (isascii (*s) && isprint (*s)) + putc_unlocked (*s, fp); + else + { + putc_unlocked ('\\', fp); + fprintf (fp, "x%02x", *s); + } + } + + if (c) + { + putc_unlocked ('\\', fp); + putc_unlocked (c, fp); + } + } + +#ifdef HAVE_FUNLOCKFILE + funlockfile (fp); +#endif +} diff --git a/tags/gpgme-0-4-3/assuan/assuan.h b/tags/gpgme-0-4-3/assuan/assuan.h new file mode 100644 index 0000000..05f0212 --- /dev/null +++ b/tags/gpgme-0-4-3/assuan/assuan.h @@ -0,0 +1,394 @@ +/* assuan.c - Definitions for the Assuan protocol + * Copyright (C) 2001, 2002, 2003 Free Software Foundation, Inc. + * + * This file is part of Assuan. + * + * Assuan 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. + * + * Assuan 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, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA + */ + +#ifndef ASSUAN_H +#define ASSUAN_H + +#include +#include +#include + +#include + +#define _ASSUAN_IN_GPGME +#ifdef _ASSUAN_IN_GPGME +#define _ASSUAN_EXT_SYM_PREFIX _gpgme_ + +#ifdef _ASSUAN_IN_GPGME_BUILD_ASSUAN +int _gpgme_io_read (int fd, void *buffer, size_t count); +int _gpgme_io_write (int fd, const void *buffer, size_t count); +ssize_t _gpgme_ath_select (int nfd, fd_set *rset, fd_set *wset, fd_set *eset, + struct timeval *timeout); +ssize_t _gpgme_ath_waitpid (pid_t pid, int *status, int options); +int _gpgme_ath_accept (int s, struct sockaddr *addr, socklen_t *length_ptr); +int _gpgme_ath_connect (int s, struct sockaddr *addr, socklen_t length); +int _gpgme_ath_sendmsg (int s, const struct msghdr *msg, int flags); +int _gpgme_ath_recvmsg (int s, struct msghdr *msg, int flags); + +#define read _gpgme_io_read +#define write _gpgme_io_write +#define waitpid _gpgme_ath_waitpid +#define select _gpgme_ath_select +#define accept _gpgme_ath_accept +#define connect _gpgme_ath_connect +#define sendmsg _gpgme_ath_sendmsg +#define recvmsg _gpgme_ath_recvmsg +#endif +#endif + +#ifdef _ASSUAN_EXT_SYM_PREFIX +#define _ASSUAN_PREFIX1(x,y) x ## y +#define _ASSUAN_PREFIX2(x,y) _ASSUAN_PREFIX1(x,y) +#define _ASSUAN_PREFIX(x) _ASSUAN_PREFIX2(_ASSUAN_EXT_SYM_PREFIX,x) +#define assuan_ _ASSUAN_PREFIX(assuan_) +#define assuan_register_command _ASSUAN_PREFIX(assuan_register_command) +#define assuan_register_bye_notify _ASSUAN_PREFIX(assuan_register_bye_notify) +#define assuan_register_reset_notify \ + _ASSUAN_PREFIX(assuan_register_reset_notify) +#define assuan_register_cancel_notify \ + _ASSUAN_PREFIX(assuan_register_cancel_notify) +#define assuan_register_input_notify \ + _ASSUAN_PREFIX(assuan_register_input_notify) +#define assuan_register_output_notify \ + _ASSUAN_PREFIX(assuan_register_output_notify) +#define assuan_register_option_handler \ + _ASSUAN_PREFIX(assuan_register_option_handler) +#define assuan_process _ASSUAN_PREFIX(assuan_process) +#define assuan_process_next _ASSUAN_PREFIX(assuan_process_next) +#define assuan_get_active_fds _ASSUAN_PREFIX(assuan_get_active_fds) +#define assuan_get_data_fp _ASSUAN_PREFIX(assuan_get_data_fp) +#define assuan_set_okay_line _ASSUAN_PREFIX(assuan_set_okay_line) +#define assuan_write_status _ASSUAN_PREFIX(assuan_write_status) +#define assuan_command_parse_fd _ASSUAN_PREFIX(assuan_command_parse_fd) +#define assuan_set_hello_line _ASSUAN_PREFIX(assuan_set_hello_line) +#define assuan_accept _ASSUAN_PREFIX(assuan_accept) +#define assuan_get_input_fd _ASSUAN_PREFIX(assuan_get_input_fd) +#define assuan_get_output_fd _ASSUAN_PREFIX(assuan_get_output_fd) +#define assuan_close_input_fd _ASSUAN_PREFIX(assuan_close_input_fd) +#define assuan_close_output_fd _ASSUAN_PREFIX(assuan_close_output_fd) +#define assuan_init_pipe_server _ASSUAN_PREFIX(assuan_init_pipe_server) +#define assuan_deinit_server _ASSUAN_PREFIX(assuan_deinit_server) +#define assuan_init_socket_server _ASSUAN_PREFIX(assuan_init_socket_server) +#define assuan_init_connected_socket_server \ + _ASSUAN_PREFIX(assuan_init_connected_socket_server) +#define assuan_pipe_connect _ASSUAN_PREFIX(assuan_pipe_connect) +#define assuan_socket_connect _ASSUAN_PREFIX(assuan_socket_connect) +#define assuan_domain_connect _ASSUAN_PREFIX(assuan_domain_connect) +#define assuan_init_domain_server _ASSUAN_PREFIX(assuan_init_domain_server) +#define assuan_disconnect _ASSUAN_PREFIX(assuan_disconnect) +#define assuan_get_pid _ASSUAN_PREFIX(assuan_get_pid) +#define assuan_transact _ASSUAN_PREFIX(assuan_transact) +#define assuan_inquire _ASSUAN_PREFIX(assuan_inquire) +#define assuan_read_line _ASSUAN_PREFIX(assuan_read_line) +#define assuan_pending_line _ASSUAN_PREFIX(assuan_pending_line) +#define assuan_write_line _ASSUAN_PREFIX(assuan_write_line) +#define assuan_send_data _ASSUAN_PREFIX(assuan_send_data) +#define assuan_sendfd _ASSUAN_PREFIX(assuan_sendfd) +#define assuan_receivefd _ASSUAN_PREFIX(assuan_receivefd) +#define assuan_set_malloc_hooks _ASSUAN_PREFIX(assuan_set_malloc_hooks) +#define assuan_set_log_stream _ASSUAN_PREFIX(assuan_set_log_stream) +#define assuan_set_error _ASSUAN_PREFIX(assuan_set_error) +#define assuan_set_pointer _ASSUAN_PREFIX(assuan_set_pointer) +#define assuan_get_pointer _ASSUAN_PREFIX(assuan_get_pointer) +#define assuan_begin_confidential _ASSUAN_PREFIX(assuan_begin_confidential) +#define assuan_end_confidential _ASSUAN_PREFIX(assuan_end_confidential) +#define assuan_strerror _ASSUAN_PREFIX(assuan_strerror) +#define assuan_set_assuan_log_stream \ + _ASSUAN_PREFIX(assuan_set_assuan_log_stream) +#define assuan_get_assuan_log_stream \ + _ASSUAN_PREFIX(assuan_get_assuan_log_stream) +#define assuan_get_assuan_log_prefix \ + _ASSUAN_PREFIX(assuan_get_assuan_log_prefix) + +/* And now the internal functions, argh... */ +#define _assuan_read_line _ASSUAN_PREFIX(_assuan_read_line) +#define _assuan_cookie_write_data _ASSUAN_PREFIX(_assuan_cookie_write_data) +#define _assuan_cookie_write_flush _ASSUAN_PREFIX(_assuan_cookie_write_flush) +#define _assuan_read_from_server _ASSUAN_PREFIX(_assuan_read_from_server) +#define _assuan_domain_init _ASSUAN_PREFIX(_assuan_domain_init) +#define _assuan_register_std_commands \ + _ASSUAN_PREFIX(_assuan_register_std_commands) +#define _assuan_simple_read _ASSUAN_PREFIX(_assuan_simple_read) +#define _assuan_simple_write _ASSUAN_PREFIX(_assuan_simple_write) +#define _assuan_simple_read _ASSUAN_PREFIX(_assuan_simple_read) +#define _assuan_simple_write _ASSUAN_PREFIX(_assuan_simple_write) +#define _assuan_new_context _ASSUAN_PREFIX(_assuan_new_context) +#define _assuan_release_context _ASSUAN_PREFIX(_assuan_release_context) +#define _assuan_malloc _ASSUAN_PREFIX(_assuan_malloc) +#define _assuan_realloc _ASSUAN_PREFIX(_assuan_realloc) +#define _assuan_calloc _ASSUAN_PREFIX(_assuan_calloc) +#define _assuan_free _ASSUAN_PREFIX(_assuan_free) +#define _assuan_log_print_buffer _ASSUAN_PREFIX(_assuan_log_print_buffer) +#define _assuan_log_sanitized_string \ + _ASSUAN_PREFIX(_assuan_log_sanitized_string) + +#endif + +#ifdef __cplusplus +extern "C" +{ +#endif + + +typedef enum +{ + ASSUAN_No_Error = 0, + ASSUAN_General_Error = 1, + ASSUAN_Out_Of_Core = 2, + ASSUAN_Invalid_Value = 3, + ASSUAN_Timeout = 4, + ASSUAN_Read_Error = 5, + ASSUAN_Write_Error = 6, + ASSUAN_Problem_Starting_Server = 7, + ASSUAN_Not_A_Server = 8, + ASSUAN_Not_A_Client = 9, + ASSUAN_Nested_Commands = 10, + ASSUAN_Invalid_Response = 11, + ASSUAN_No_Data_Callback = 12, + ASSUAN_No_Inquire_Callback = 13, + ASSUAN_Connect_Failed = 14, + ASSUAN_Accept_Failed = 15, + + /* error codes above 99 are meant as status codes */ + ASSUAN_Not_Implemented = 100, + ASSUAN_Server_Fault = 101, + ASSUAN_Invalid_Command = 102, + ASSUAN_Unknown_Command = 103, + ASSUAN_Syntax_Error = 104, + ASSUAN_Parameter_Error = 105, + ASSUAN_Parameter_Conflict = 106, + ASSUAN_Line_Too_Long = 107, + ASSUAN_Line_Not_Terminated = 108, + ASSUAN_No_Input = 109, + ASSUAN_No_Output = 110, + ASSUAN_Canceled = 111, + ASSUAN_Unsupported_Algorithm = 112, + ASSUAN_Server_Resource_Problem = 113, + ASSUAN_Server_IO_Error = 114, + ASSUAN_Server_Bug = 115, + ASSUAN_No_Data_Available = 116, + ASSUAN_Invalid_Data = 117, + ASSUAN_Unexpected_Command = 118, + ASSUAN_Too_Much_Data = 119, + ASSUAN_Inquire_Unknown = 120, + ASSUAN_Inquire_Error = 121, + ASSUAN_Invalid_Option = 122, + ASSUAN_Invalid_Index = 123, + ASSUAN_Unexpected_Status = 124, + ASSUAN_Unexpected_Data = 125, + ASSUAN_Invalid_Status = 126, + + ASSUAN_Not_Confirmed = 128, + + ASSUAN_Bad_Certificate = 201, + ASSUAN_Bad_Certificate_Chain = 202, + ASSUAN_Missing_Certificate = 203, + ASSUAN_Bad_Signature = 204, + ASSUAN_No_Agent = 205, + ASSUAN_Agent_Error = 206, + ASSUAN_No_Public_Key = 207, + ASSUAN_No_Secret_Key = 208, + ASSUAN_Invalid_Name = 209, + + ASSUAN_Cert_Revoked = 301, + ASSUAN_No_CRL_For_Cert = 302, + ASSUAN_CRL_Too_Old = 303, + ASSUAN_Not_Trusted = 304, + + ASSUAN_Card_Error = 401, + ASSUAN_Invalid_Card = 402, + ASSUAN_No_PKCS15_App = 403, + ASSUAN_Card_Not_Present = 404, + ASSUAN_Invalid_Id = 405 + +} AssuanError; + +/* This is a list of pre-registered ASSUAN commands */ +typedef enum +{ + ASSUAN_CMD_NOP = 0, + ASSUAN_CMD_CANCEL, /* cancel the current request */ + ASSUAN_CMD_BYE, + ASSUAN_CMD_AUTH, + ASSUAN_CMD_RESET, + ASSUAN_CMD_OPTION, + ASSUAN_CMD_DATA, + ASSUAN_CMD_END, + ASSUAN_CMD_INPUT, + ASSUAN_CMD_OUTPUT, + + ASSUAN_CMD_USER = 256 /* Other commands should be used with this offset*/ +} AssuanCommand; + +#define ASSUAN_LINELENGTH 1002 /* 1000 + [CR,]LF */ + +struct assuan_context_s; +typedef struct assuan_context_s *ASSUAN_CONTEXT; + +/*-- assuan-handler.c --*/ +int assuan_register_command (ASSUAN_CONTEXT ctx, + const char *cmd_string, + int (*handler)(ASSUAN_CONTEXT, char *)); +int assuan_register_bye_notify (ASSUAN_CONTEXT ctx, + void (*fnc)(ASSUAN_CONTEXT)); +int assuan_register_reset_notify (ASSUAN_CONTEXT ctx, + void (*fnc)(ASSUAN_CONTEXT)); +int assuan_register_cancel_notify (ASSUAN_CONTEXT ctx, + void (*fnc)(ASSUAN_CONTEXT)); +int assuan_register_input_notify (ASSUAN_CONTEXT ctx, + void (*fnc)(ASSUAN_CONTEXT, const char *)); +int assuan_register_output_notify (ASSUAN_CONTEXT ctx, + void (*fnc)(ASSUAN_CONTEXT, const char *)); + +int assuan_register_option_handler (ASSUAN_CONTEXT ctx, + int (*fnc)(ASSUAN_CONTEXT, + const char*, const char*)); + +int assuan_process (ASSUAN_CONTEXT ctx); +int assuan_process_next (ASSUAN_CONTEXT ctx); +int assuan_get_active_fds (ASSUAN_CONTEXT ctx, int what, + int *fdarray, int fdarraysize); + + +FILE *assuan_get_data_fp (ASSUAN_CONTEXT ctx); +AssuanError assuan_set_okay_line (ASSUAN_CONTEXT ctx, const char *line); +void assuan_write_status (ASSUAN_CONTEXT ctx, + const char *keyword, const char *text); + +/* Negotiate a file descriptor. If LINE contains "FD=N", returns N + assuming a local file descriptor. If LINE contains "FD" reads a + file descriptor via CTX and stores it in *RDF (the CTX must be + capable of passing file descriptors). */ +AssuanError assuan_command_parse_fd (ASSUAN_CONTEXT ctx, char *line, + int *rfd); + +/*-- assuan-listen.c --*/ +AssuanError assuan_set_hello_line (ASSUAN_CONTEXT ctx, const char *line); +AssuanError assuan_accept (ASSUAN_CONTEXT ctx); +int assuan_get_input_fd (ASSUAN_CONTEXT ctx); +int assuan_get_output_fd (ASSUAN_CONTEXT ctx); +AssuanError assuan_close_input_fd (ASSUAN_CONTEXT ctx); +AssuanError assuan_close_output_fd (ASSUAN_CONTEXT ctx); + + +/*-- assuan-pipe-server.c --*/ +int assuan_init_pipe_server (ASSUAN_CONTEXT *r_ctx, int filedes[2]); +void assuan_deinit_server (ASSUAN_CONTEXT ctx); + +/*-- assuan-socket-server.c --*/ +int assuan_init_socket_server (ASSUAN_CONTEXT *r_ctx, int listen_fd); +int assuan_init_connected_socket_server (ASSUAN_CONTEXT *r_ctx, int fd); + + +/*-- assuan-pipe-connect.c --*/ +AssuanError assuan_pipe_connect (ASSUAN_CONTEXT *ctx, const char *name, + char *const argv[], int *fd_child_list); +/*-- assuan-socket-connect.c --*/ +AssuanError assuan_socket_connect (ASSUAN_CONTEXT *ctx, const char *name, + pid_t server_pid); + +/*-- assuan-domain-connect.c --*/ + +/* Connect to a Unix domain socket server. RENDEZVOUSFD is + bidirectional file descriptor (normally returned via socketpair) + which the client can use to rendezvous with the server. SERVER s + the server's pid. */ +AssuanError assuan_domain_connect (ASSUAN_CONTEXT *r_ctx, + int rendezvousfd, + pid_t server); + +/*-- assuan-domain-server.c --*/ + +/* RENDEZVOUSFD is a bidirectional file descriptor (normally returned + via socketpair) that the domain server can use to rendezvous with + the client. CLIENT is the client's pid. */ +AssuanError assuan_init_domain_server (ASSUAN_CONTEXT *r_ctx, + int rendezvousfd, + pid_t client); + + +/*-- assuan-connect.c --*/ +void assuan_disconnect (ASSUAN_CONTEXT ctx); +pid_t assuan_get_pid (ASSUAN_CONTEXT ctx); + +/*-- assuan-client.c --*/ +AssuanError +assuan_transact (ASSUAN_CONTEXT ctx, + const char *command, + AssuanError (*data_cb)(void *, const void *, size_t), + void *data_cb_arg, + AssuanError (*inquire_cb)(void*, const char *), + void *inquire_cb_arg, + AssuanError (*status_cb)(void*, const char *), + void *status_cb_arg); + + +/*-- assuan-inquire.c --*/ +AssuanError assuan_inquire (ASSUAN_CONTEXT ctx, const char *keyword, + char **r_buffer, size_t *r_length, size_t maxlen); + +/*-- assuan-buffer.c --*/ +AssuanError assuan_read_line (ASSUAN_CONTEXT ctx, + char **line, size_t *linelen); +int assuan_pending_line (ASSUAN_CONTEXT ctx); +AssuanError assuan_write_line (ASSUAN_CONTEXT ctx, const char *line ); +AssuanError assuan_send_data (ASSUAN_CONTEXT ctx, + const void *buffer, size_t length); + +/* The file descriptor must be pending before assuan_receivefd is + call. This means that assuan_sendfd should be called *before* the + trigger is sent (normally via assuan_send_data ("I sent you a + descriptor")). */ +AssuanError assuan_sendfd (ASSUAN_CONTEXT ctx, int fd); +AssuanError assuan_receivefd (ASSUAN_CONTEXT ctx, int *fd); + +/*-- assuan-util.c --*/ +void assuan_set_malloc_hooks ( void *(*new_alloc_func)(size_t n), + void *(*new_realloc_func)(void *p, size_t n), + void (*new_free_func)(void*) ); +void assuan_set_log_stream (ASSUAN_CONTEXT ctx, FILE *fp); +int assuan_set_error (ASSUAN_CONTEXT ctx, int err, const char *text); +void assuan_set_pointer (ASSUAN_CONTEXT ctx, void *pointer); +void *assuan_get_pointer (ASSUAN_CONTEXT ctx); + +void assuan_begin_confidential (ASSUAN_CONTEXT ctx); +void assuan_end_confidential (ASSUAN_CONTEXT ctx); + +/*-- assuan-errors.c (built) --*/ +const char *assuan_strerror (AssuanError err); + +/*-- assuan-logging.c --*/ + +/* Set the stream to which assuan should log. By default, this is + stderr. */ +extern void assuan_set_assuan_log_stream (FILE *fp); + +/* Return the stream which is currently being using for logging. */ +extern FILE *assuan_get_assuan_log_stream (void); + +/* User defined call back. Return a prefix to be used at the start of + a line emitted by assuan on the log stream. The default + implementation returns the empty string, i.e. "" */ +extern const char *assuan_get_assuan_log_prefix (void); + +#ifdef __cplusplus +} +#endif +#endif /* ASSUAN_H */ diff --git a/tags/gpgme-0-4-3/assuan/mkerrors b/tags/gpgme-0-4-3/assuan/mkerrors new file mode 100755 index 0000000..1112941 --- /dev/null +++ b/tags/gpgme-0-4-3/assuan/mkerrors @@ -0,0 +1,82 @@ +#!/bin/sh +# mkerrors - Extract error strings from assuan.h +# and create C source for assuan_strerror +# Copyright (C) 2001, 2002 Free Software Foundation, Inc. +# +# This file is part of Assuan. +# +# Assuan 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. +# +# Assuan 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, write to the Free Software +# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA + +cat < +#include "assuan.h" + +/** + * assuan_strerror: + * @err: Error code + * + * This function returns a textual representaion of the given + * errorcode. If this is an unknown value, a string with the value + * is returned (Beware: it is hold in a static buffer). + * + * Return value: String with the error description. + **/ +const char * +assuan_strerror (AssuanError err) +{ + const char *s; + static char buf[50]; + + switch (err) + { +EOF + +awk ' +/ASSUAN_No_Error/ { okay=1 } +!okay {next} +/}/ { exit 0 } +/ASSUAN_[A-Za-z_]*/ { print_code($1) } + + +function print_code( s ) +{ +printf " case %s: s=\"", s ; +gsub(/_/, " ", s ); +printf "%s\"; break;\n", tolower(substr(s,8)); +} +' + +cat <> 24) & 0xff); + code = (err & 0x00ffffff); + if (source) /* Assume this is an libgpg-error. */ + sprintf (buf, "ec=%u.%u", source, code ); + else + sprintf (buf, "ec=%d", err ); + s=buf; break; + } + } + + return s; +} + +EOF \ No newline at end of file diff --git a/tags/gpgme-0-4-3/autogen.sh b/tags/gpgme-0-4-3/autogen.sh new file mode 100755 index 0000000..ddc8d6c --- /dev/null +++ b/tags/gpgme-0-4-3/autogen.sh @@ -0,0 +1,149 @@ +#!/bin/sh +# Run this to generate all the initial makefiles, etc. +# It is only needed for the CVS version. + +PGM=GPGME +lib_config_files="" +autoconf_vers=2.53 +automake_vers=1.7 +aclocal_vers=1.5 +libtool_vers=1.4 + +DIE=no +if test "$1" = "--build-w32"; then + shift + target=i386--mingw32 + if [ ! -f ./config.guess ]; then + echo "./config.guess not found" >&2 + exit 1 + fi + host=`./config.guess` + + if ! mingw32 --version >/dev/null; then + echo "We need at least version 0.3 of MingW32/CPD" >&2 + exit 1 + fi + + if [ -f config.h ]; then + if grep HAVE_DOSISH_SYSTEM config.h | grep undef >/dev/null; then + echo "Pease run a 'make distclean' first" >&2 + exit 1 + fi + fi + + crossinstalldir=`mingw32 --install-dir` + crossbindir=`mingw32 --get-bindir 2>/dev/null` \ + || crossbindir="$crossinstalldir/bin" + crossdatadir=`mingw32 --get-datadir 2>/dev/null` \ + || crossdatadir="$crossinstalldir/share" + crosslibdir=`mingw32 --get-libdir 2>/dev/null` \ + || crosslibdir="$crossinstalldir/i386--mingw32/lib" + crossincdir=`mingw32 --get-includedir 2>/dev/null` \ + || crossincdir="$crossinstalldir/i386--mingw32/include" + CC=`mingw32 --get-path gcc` + CPP=`mingw32 --get-path cpp` + AR=`mingw32 --get-path ar` + RANLIB=`mingw32 --get-path ranlib` + export CC CPP AR RANLIB + + disable_foo_tests="" + if [ -n "$lib_config_files" ]; then + for i in $lib_config_files; do + j=`echo $i | tr '[a-z-]' '[A-Z_]'` + eval "$j=${crossbindir}/$i" + export $j + disable_foo_tests="$disable_foo_tests --disable-`echo $i| \ + sed 's,-config$,,'`-test" + if [ ! -f "${crossbindir}/$i" ]; then + echo "$i not installed for MingW32" >&2 + DIE=yes + fi + done + fi + [ $DIE = yes ] && exit 1 + + ./configure --host=${host} --target=${target} ${disable_foo_tests} \ + --bindir=${crossbindir} --libdir=${crosslibdir} \ + --datadir=${crossdatadir} --includedir=${crossincdir} \ + --enable-maintainer-mode $* + exit $? +fi + + + +if (autoconf --version) < /dev/null > /dev/null 2>&1 ; then + if (autoconf --version | awk 'NR==1 { if( $3 >= '$autoconf_vers') \ + exit 1; exit 0; }'); + then + echo "**Error**: "\`autoconf\'" is too old." + echo ' (version ' $autoconf_vers ' or newer is required)' + DIE="yes" + fi +else + echo + echo "**Error**: You must have "\`autoconf\'" installed to compile $PGM." + echo ' (version ' $autoconf_vers ' or newer is required)' + DIE="yes" +fi + +if (automake --version) < /dev/null > /dev/null 2>&1 ; then + if (automake --version | awk 'NR==1 { if( $4 >= '$automake_vers') \ + exit 1; exit 0; }'); + then + echo "**Error**: "\`automake\'" is too old." + echo ' (version ' $automake_vers ' or newer is required)' + DIE="yes" + fi + if (aclocal --version) < /dev/null > /dev/null 2>&1; then + if (aclocal --version | awk 'NR==1 { if( $4 >= '$aclocal_vers' ) \ + exit 1; exit 0; }' ); + then + echo "**Error**: "\`aclocal\'" is too old." + echo ' (version ' $aclocal_vers ' or newer is required)' + DIE="yes" + fi + else + echo + echo "**Error**: Missing "\`aclocal\'". The version of "\`automake\' + echo " installed doesn't appear recent enough." + DIE="yes" + fi +else + echo + echo "**Error**: You must have "\`automake\'" installed to compile $PGM." + echo ' (version ' $automake_vers ' or newer is required)' + DIE="yes" +fi + + +if (libtool --version) < /dev/null > /dev/null 2>&1 ; then + if (libtool --version | awk 'NR==1 { if( $4 >= '$libtool_vers') \ + exit 1; exit 0; }'); + then + echo "**Error**: "\`libtool\'" is too old." + echo ' (version ' $libtool_vers ' or newer is required)' + DIE="yes" + fi +else + echo + echo "**Error**: You must have "\`libtool\'" installed to compile $PGM." + echo ' (version ' $libtool_vers ' or newer is required)' + DIE="yes" +fi + +if test "$DIE" = "yes"; then + exit 1 +fi + +echo "Running libtoolize... Ignore non-fatal messages." +echo "no" | libtoolize + + +echo "Running aclocal..." +aclocal +echo "Running autoheader..." +autoheader +echo "Running automake --gnu -a ..." +automake --gnu -a +echo "Running autoconf..." +autoconf diff --git a/tags/gpgme-0-4-3/complus/ChangeLog b/tags/gpgme-0-4-3/complus/ChangeLog new file mode 100644 index 0000000..fe34a66 --- /dev/null +++ b/tags/gpgme-0-4-3/complus/ChangeLog @@ -0,0 +1,15 @@ +2001-07-30 Werner Koch + + Encryption basically works. + + + Copyright 2001 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. + \ No newline at end of file diff --git a/tags/gpgme-0-4-3/complus/Makefile.am b/tags/gpgme-0-4-3/complus/Makefile.am new file mode 100644 index 0000000..1965b9f --- /dev/null +++ b/tags/gpgme-0-4-3/complus/Makefile.am @@ -0,0 +1,49 @@ +# Copyright (C) 2000 Werner Koch (dd9jn) +# Copyright (C) 2001 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 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA + +## Process this file with automake to produce Makefile.in + +# Because there is no free IDL compiler for OLE, we have to distribute +# a binary typelibrary. To generate a new one, copy the idl file to a +# system with an install MIDL and run the command +# midl /nocpp gpgcom.idl +# Sorry, there is no other way yet. +EXTRA_DIST = gpgcom.idl gpgcom.tlb gpgcom.rc vbtest.html vbtest.vbs README + +# No need to install this because we are cross-compiling anyway. +noinst_PROGRAMS = gpgcom tgpgcom + +INCLUDES = -I$(top_srcdir)/jnlib +LDADD = ../gpgme/libgpgme.la -L ../jnlib -ljnlib -lole32 -loleaut32 +gpgcom_LDADD = gpgcom_res.o $(LDADD) + +gpgcom_SOURCES = gpgcom.c main.h \ + debug.c utf8.c \ + igpgme.h igpgme.c + +tgpgcom_SOURCES = tgpgcom.c\ + debug.c \ + igpgme.h + +#regtlb_SOURCES = regtlb.c +#guidgen_SOURCES = guidgen.c + +gpgcom_res.o: gpgcom.rc + mingw32 windres $< gpgcom_res.o + diff --git a/tags/gpgme-0-4-3/complus/README b/tags/gpgme-0-4-3/complus/README new file mode 100644 index 0000000..7dc3bb1 --- /dev/null +++ b/tags/gpgme-0-4-3/complus/README @@ -0,0 +1,72 @@ + How to install and use the Gpgcom Windows Component + =================================================== + 2001-07-31 + + +Installation should be pretty easy: +----------------------------------- + + * Get and install the latest GnuPG binary for windows + (ftp://ftp.gnupg.org/gcrypt/binary/gnupg-w32-1.0.6.zip) + + * Check that you have an untampered version of this package by + comparing an MD5SUM against the one on the webpage or by checking + the signature of the package using "gpg --verify". See the + webpacge for details. + + * Because you are reading this file, you probably have already + unpacked it distribution using a unzip utility :-). You should + find these files: + + README - This file + gpgcom.exe - The Gpgcom server + vbtest.html - A Test webpage + vbtest.vbs - A VB script to be used with the cscript utility + + * If you are updating Gpgcom, run the old Gpgcom like this: + + c:\gnupg\gpgcom -UnregServer + + (Replace c:\gnupg with the actually used path) + + * Copy the file gpgcom.exe to a some location. C:\gnupg seems to be + a good choice. + + * Register the component using this command: + + c:\gnupg\gpgcom -RegServer + + * Ready + +Testing the installation: +------------------------- + + * Make sure that you have a working GnuPG (gpg.exe) and that at least + one key is installed. + + * Edit the vbtest.vbs script and replace "alice" in the line + + gpg.AddRecipient "alice" + + with a keyID or user name you have in your key ring. + + * Run the test script: + + cscript vbtest.vbs + + and you should see a valid MIME message with the encrypted text. + + +Using Gpgcom +------------ + +Gpgcom currently support only encryption but will be extended to the +full range of operations GnuPG provides. The 2 examples should goive +yopu a hint on how to use it. We suggest that you always set armor to +true, so that the returned text is a string. If you don't use armor, +the "ciphertext" property will return an array with the binary +message. + + + + diff --git a/tags/gpgme-0-4-3/complus/debug.c b/tags/gpgme-0-4-3/complus/debug.c new file mode 100644 index 0000000..d7cb0a0 --- /dev/null +++ b/tags/gpgme-0-4-3/complus/debug.c @@ -0,0 +1,40 @@ +/* debug.c - COM+ debug helpers + * Copyright (C) 2001 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 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA + */ + +#include +#include +#include +#include + + +const char * +debugstr_guid (const GUID *id) +{ + static char str[100]; + + if (!id) + return "(null)"; + sprintf( str, "{%08lx-%04x-%04x-%02x%02x-%02x%02x%02x%02x%02x%02x}", + id->Data1, id->Data2, id->Data3, + id->Data4[0], id->Data4[1], id->Data4[2], id->Data4[3], + id->Data4[4], id->Data4[5], id->Data4[6], id->Data4[7] ); + return str; +} + diff --git a/tags/gpgme-0-4-3/complus/example.c b/tags/gpgme-0-4-3/complus/example.c new file mode 100644 index 0000000..a7d838d --- /dev/null +++ b/tags/gpgme-0-4-3/complus/example.c @@ -0,0 +1,598 @@ +/* + * Copyright 1999 Marcus Meissner + */ +#include +#include +#include + +#include "winbase.h" +#include "winnls.h" +#include "mmsystem.h" +#include "winerror.h" +#include "debugtools.h" + +#include "initguid.h" +#include "vfw.h" + +DEFAULT_DEBUG_CHANNEL(avifile); + +static HRESULT WINAPI IAVIFile_fnQueryInterface(IAVIFile* iface,REFIID refiid,LPVOID *obj); +static ULONG WINAPI IAVIFile_fnAddRef(IAVIFile* iface); +static ULONG WINAPI IAVIFile_fnRelease(IAVIFile* iface); +static HRESULT WINAPI IAVIFile_fnInfo(IAVIFile*iface,AVIFILEINFOW*afi,LONG size); +static HRESULT WINAPI IAVIFile_fnGetStream(IAVIFile*iface,PAVISTREAM*avis,DWORD fccType,LONG lParam); +static HRESULT WINAPI IAVIFile_fnCreateStream(IAVIFile*iface,PAVISTREAM*avis,AVISTREAMINFOW*asi); +static HRESULT WINAPI IAVIFile_fnWriteData(IAVIFile*iface,DWORD ckid,LPVOID lpData,LONG size); +static HRESULT WINAPI IAVIFile_fnReadData(IAVIFile*iface,DWORD ckid,LPVOID lpData,LONG *size); +static HRESULT WINAPI IAVIFile_fnEndRecord(IAVIFile*iface); +static HRESULT WINAPI IAVIFile_fnDeleteStream(IAVIFile*iface,DWORD fccType,LONG lParam); + +struct ICOM_VTABLE(IAVIFile) iavift = { + ICOM_MSVTABLE_COMPAT_DummyRTTIVALUE + IAVIFile_fnQueryInterface, + IAVIFile_fnAddRef, + IAVIFile_fnRelease, + IAVIFile_fnInfo, + IAVIFile_fnGetStream, + IAVIFile_fnCreateStream, + IAVIFile_fnWriteData, + IAVIFile_fnReadData, + IAVIFile_fnEndRecord, + IAVIFile_fnDeleteStream +}; + +static HRESULT WINAPI IAVIStream_fnQueryInterface(IAVIStream*iface,REFIID refiid,LPVOID *obj); +static ULONG WINAPI IAVIStream_fnAddRef(IAVIStream*iface); +static ULONG WINAPI IAVIStream_fnRelease(IAVIStream* iface); +static HRESULT WINAPI IAVIStream_fnCreate(IAVIStream*iface,LPARAM lParam1,LPARAM lParam2); +static HRESULT WINAPI IAVIStream_fnInfo(IAVIStream*iface,AVISTREAMINFOW *psi,LONG size); +static LONG WINAPI IAVIStream_fnFindSample(IAVIStream*iface,LONG pos,LONG flags); +static HRESULT WINAPI IAVIStream_fnReadFormat(IAVIStream*iface,LONG pos,LPVOID format,LONG *formatsize); +static HRESULT WINAPI IAVIStream_fnSetFormat(IAVIStream*iface,LONG pos,LPVOID format,LONG formatsize); +static HRESULT WINAPI IAVIStream_fnRead(IAVIStream*iface,LONG start,LONG samples,LPVOID buffer,LONG buffersize,LONG *bytesread,LONG *samplesread); +static HRESULT WINAPI IAVIStream_fnWrite(IAVIStream*iface,LONG start,LONG samples,LPVOID buffer,LONG buffersize,DWORD flags,LONG *sampwritten,LONG *byteswritten); +static HRESULT WINAPI IAVIStream_fnDelete(IAVIStream*iface,LONG start,LONG samples); +static HRESULT WINAPI IAVIStream_fnReadData(IAVIStream*iface,DWORD fcc,LPVOID lp,LONG *lpread); +static HRESULT WINAPI IAVIStream_fnWriteData(IAVIStream*iface,DWORD fcc,LPVOID lp,LONG size); +static HRESULT WINAPI IAVIStream_fnSetInfo(IAVIStream*iface,AVISTREAMINFOW*info,LONG infolen); + +struct ICOM_VTABLE(IAVIStream) iavist = { + ICOM_MSVTABLE_COMPAT_DummyRTTIVALUE + IAVIStream_fnQueryInterface, + IAVIStream_fnAddRef, + IAVIStream_fnRelease, + IAVIStream_fnCreate, + IAVIStream_fnInfo, + IAVIStream_fnFindSample, + IAVIStream_fnReadFormat, + IAVIStream_fnSetFormat, + IAVIStream_fnRead, + IAVIStream_fnWrite, + IAVIStream_fnDelete, + IAVIStream_fnReadData, + IAVIStream_fnWriteData, + IAVIStream_fnSetInfo +}; + +typedef struct IAVIStreamImpl { + /* IUnknown stuff */ + ICOM_VFIELD(IAVIStream); + DWORD ref; + /* IAVIStream stuff */ + LPVOID lpInputFormat; + DWORD inputformatsize; + BOOL iscompressing; + DWORD curframe; + + /* Compressor stuff */ + HIC hic; + LPVOID lpCompressFormat; + ICINFO icinfo; + DWORD compbufsize; + LPVOID compbuffer; + + DWORD decompbufsize; + LPVOID decompbuffer; + LPVOID decompformat; + AVICOMPRESSOPTIONS aco; + + LPVOID lpPrev; /* pointer to decompressed frame later */ + LPVOID lpPrevFormat; /* pointer to decompressed info later */ +} IAVIStreamImpl; + +/*********************************************************************** + * AVIFileInit + */ +void WINAPI +AVIFileInit(void) { + FIXME("(),stub!\n"); +} + +typedef struct IAVIFileImpl { + /* IUnknown stuff */ + ICOM_VFIELD(IAVIFile); + DWORD ref; + /* IAVIFile stuff... */ +} IAVIFileImpl; + +static HRESULT WINAPI IAVIFile_fnQueryInterface(IAVIFile* iface,REFIID refiid,LPVOID *obj) { + ICOM_THIS(IAVIFileImpl,iface); + + TRACE("(%p)->QueryInterface(%s,%p)\n",This,debugstr_guid(refiid),obj); + if ( !memcmp(&IID_IUnknown,refiid,sizeof(IID_IUnknown)) || + !memcmp(&IID_IAVIFile,refiid,sizeof(IID_IAVIFile)) + ) { + *obj = iface; + return S_OK; + } + return OLE_E_ENUM_NOMORE; +} + +static ULONG WINAPI IAVIFile_fnAddRef(IAVIFile* iface) { + ICOM_THIS(IAVIFileImpl,iface); + + FIXME("(%p)->AddRef()\n",iface); + return ++(This->ref); +} + +static ULONG WINAPI IAVIFile_fnRelease(IAVIFile* iface) { + ICOM_THIS(IAVIFileImpl,iface); + + FIXME("(%p)->Release()\n",iface); + if (!--(This->ref)) { + HeapFree(GetProcessHeap(),0,iface); + return 0; + } + return This->ref; +} + +static HRESULT WINAPI IAVIFile_fnInfo(IAVIFile*iface,AVIFILEINFOW*afi,LONG size) { + FIXME("(%p)->Info(%p,%ld)\n",iface,afi,size); + + /* FIXME: fill out struct? */ + return E_FAIL; +} + +static HRESULT WINAPI IAVIFile_fnGetStream(IAVIFile*iface,PAVISTREAM*avis,DWORD fccType,LONG lParam) { + FIXME("(%p)->GetStream(%p,0x%08lx,%ld)\n",iface,avis,fccType,lParam); + /* FIXME: create interface etc. */ + return E_FAIL; +} + +static HRESULT WINAPI IAVIFile_fnCreateStream(IAVIFile*iface,PAVISTREAM*avis,AVISTREAMINFOW*asi) { + ICOM_THIS(IAVIStreamImpl,iface); + char fcc[5]; + IAVIStreamImpl *istream; + + FIXME("(%p,%p,%p)\n",This,avis,asi); + istream = (IAVIStreamImpl*)HeapAlloc(GetProcessHeap(),HEAP_ZERO_MEMORY,sizeof(IAVIStreamImpl)); + istream->ref = 1; + ICOM_VTBL(istream) = &iavist; + fcc[4]='\0'; + memcpy(fcc,(char*)&(asi->fccType),4); + FIXME("\tfccType '%s'\n",fcc); + memcpy(fcc,(char*)&(asi->fccHandler),4); + FIXME("\tfccHandler '%s'\n",fcc); + FIXME("\tdwFlags 0x%08lx\n",asi->dwFlags); + FIXME("\tdwCaps 0x%08lx\n",asi->dwCaps); + FIXME("\tname '%s'\n",debugstr_w(asi->szName)); + + istream->curframe = 0; + *avis = (PAVISTREAM)istream; + return S_OK; +} + +static HRESULT WINAPI IAVIFile_fnWriteData(IAVIFile*iface,DWORD ckid,LPVOID lpData,LONG size) { + FIXME("(%p)->WriteData(0x%08lx,%p,%ld)\n",iface,ckid,lpData,size); + /* FIXME: write data to file */ + return E_FAIL; +} + +static HRESULT WINAPI IAVIFile_fnReadData(IAVIFile*iface,DWORD ckid,LPVOID lpData,LONG *size) { + FIXME("(%p)->ReadData(0x%08lx,%p,%p)\n",iface,ckid,lpData,size); + /* FIXME: read at most size bytes from file */ + return E_FAIL; +} + +static HRESULT WINAPI IAVIFile_fnEndRecord(IAVIFile*iface) { + FIXME("(%p)->EndRecord()\n",iface); + /* FIXME: end record? */ + return E_FAIL; +} + +static HRESULT WINAPI IAVIFile_fnDeleteStream(IAVIFile*iface,DWORD fccType,LONG lParam) { + FIXME("(%p)->DeleteStream(0x%08lx,%ld)\n",iface,fccType,lParam); + /* FIXME: delete stream? */ + return E_FAIL; +} + +/*********************************************************************** + * AVIFileOpenA + */ +HRESULT WINAPI AVIFileOpenA( + PAVIFILE * ppfile,LPCSTR szFile,UINT uMode,LPCLSID lpHandler +) { + IAVIFileImpl *iavi; + + FIXME("(%p,%s,0x%08lx,%s),stub!\n",ppfile,szFile,(DWORD)uMode,debugstr_guid(lpHandler)); + iavi = (IAVIFileImpl*)HeapAlloc(GetProcessHeap(),HEAP_ZERO_MEMORY,sizeof(IAVIFileImpl)); + iavi->ref = 1; + ICOM_VTBL(iavi) = &iavift; + *ppfile = (LPVOID)iavi; + return S_OK; +} + +static HRESULT WINAPI IAVIStream_fnQueryInterface(IAVIStream*iface,REFIID refiid,LPVOID *obj) { + ICOM_THIS(IAVIStreamImpl,iface); + + TRACE("(%p)->QueryInterface(%s,%p)\n",This,debugstr_guid(refiid),obj); + if ( !memcmp(&IID_IUnknown,refiid,sizeof(IID_IUnknown)) || + !memcmp(&IID_IAVIStream,refiid,sizeof(IID_IAVIStream)) + ) { + *obj = This; + return S_OK; + } + /* can return IGetFrame interface too */ + return OLE_E_ENUM_NOMORE; +} + +static ULONG WINAPI IAVIStream_fnAddRef(IAVIStream*iface) { + ICOM_THIS(IAVIStreamImpl,iface); + + FIXME("(%p)->AddRef()\n",iface); + return ++(This->ref); +} + +static ULONG WINAPI IAVIStream_fnRelease(IAVIStream* iface) { + ICOM_THIS(IAVIStreamImpl,iface); + + FIXME("(%p)->Release()\n",iface); + if (!--(This->ref)) { + HeapFree(GetProcessHeap(),0,This); + return 0; + } + return This->ref; +} + +static HRESULT WINAPI IAVIStream_fnCreate(IAVIStream*iface,LPARAM lParam1,LPARAM lParam2) { + FIXME("(%p)->Create(0x%08lx,0x%08lx)\n",iface,lParam1,lParam2); + return E_FAIL; +} + +static HRESULT WINAPI IAVIStream_fnInfo(IAVIStream*iface,AVISTREAMINFOW *psi,LONG size) { + FIXME("(%p)->Info(%p,%ld)\n",iface,psi,size); + return E_FAIL; +} + +static LONG WINAPI IAVIStream_fnFindSample(IAVIStream*iface,LONG pos,LONG flags) { + FIXME("(%p)->FindSample(%ld,0x%08lx)\n",iface,pos,flags); + return E_FAIL; +} + +static HRESULT WINAPI IAVIStream_fnReadFormat(IAVIStream*iface,LONG pos,LPVOID format,LONG *formatsize) { + FIXME("(%p)->ReadFormat(%ld,%p,%p)\n",iface,pos,format,formatsize); + return E_FAIL; +} + +/*********************************************************************** + * IAVIStream::SetFormat + */ +static HRESULT WINAPI IAVIStream_fnSetFormat(IAVIStream*iface,LONG pos,LPVOID format,LONG formatsize) { + IAVIStreamImpl *as = (IAVIStreamImpl*)iface; + + FIXME("(%p)->SetFormat(%ld,%p,%ld)\n",iface,pos,format,formatsize); + if (as->lpInputFormat) HeapFree(GetProcessHeap(),0,as->lpInputFormat); + as->inputformatsize = formatsize; + as->lpInputFormat = HeapAlloc(GetProcessHeap(),0,formatsize); + memcpy(as->lpInputFormat,format,formatsize); + if (as->iscompressing) { + int xsize; + /* Set up the Compressor part */ + xsize = ICCompressGetFormatSize(as->hic,as->lpInputFormat); + as->lpCompressFormat = HeapAlloc(GetProcessHeap(),0,xsize); + ICCompressGetFormat(as->hic,as->lpInputFormat,as->lpCompressFormat); + ICCompressBegin(as->hic,as->lpInputFormat,as->lpCompressFormat); + as->compbufsize = ICCompressGetSize(as->hic,as->lpInputFormat,as->lpCompressFormat); + as->compbuffer = HeapAlloc(GetProcessHeap(),0,as->compbufsize); + + /* Set up the Decompressor part (for prev frames?) */ + xsize=ICDecompressGetFormatSize(as->hic,as->lpCompressFormat); + as->decompformat = HeapAlloc(GetProcessHeap(),0,xsize); + ICDecompressGetFormat(as->hic,as->lpCompressFormat,as->decompformat); + as->decompbufsize=((LPBITMAPINFOHEADER)as->decompbuffer)->biSizeImage; + as->decompbuffer = HeapReAlloc(GetProcessHeap(),0,as->decompbuffer,as->decompbufsize); + memset(as->decompbuffer,0xff,as->decompbufsize); + assert(HeapValidate(GetProcessHeap(),0,NULL)); + + ICDecompressGetFormat(as->hic,as->lpCompressFormat,as->decompformat); + ICDecompressBegin(as->hic,as->lpCompressFormat,as->decompformat); + as->lpPrev = as->lpPrevFormat = NULL; + } + return S_OK; +} + +static HRESULT WINAPI IAVIStream_fnRead(IAVIStream*iface,LONG start,LONG samples,LPVOID buffer,LONG buffersize,LONG *bytesread,LONG *samplesread) { + FIXME("(%p)->Read(%ld,%ld,%p,%ld,%p,%p)\n",iface,start,samples,buffer,buffersize,bytesread,samplesread); + return E_FAIL; +} + +static HRESULT WINAPI IAVIStream_fnWrite(IAVIStream*iface,LONG start,LONG samples,LPVOID buffer,LONG buffersize,DWORD flags,LONG *sampwritten,LONG *byteswritten) { + IAVIStreamImpl *as = (IAVIStreamImpl*)iface; + DWORD ckid,xflags; + + FIXME("(%p)->Write(%ld,%ld,%p,%ld,0x%08lx,%p,%p)\n",iface,start,samples,buffer,buffersize,flags,sampwritten,byteswritten); + + ICCompress( + as->hic,flags, + as->lpCompressFormat, + as->compbuffer, + as->lpInputFormat,buffer, + &ckid,&xflags, + as->curframe,0xffffff/*framesize*/,as->aco.dwQuality, + as->lpPrevFormat,as->lpPrev + ); + ICDecompress( + as->hic, + flags, /* FIXME: check */ + as->lpCompressFormat, + as->compbuffer, + as->decompformat, + as->decompbuffer + ); + /* We now have a prev format for the next compress ... */ + as->lpPrevFormat = as->decompformat; + as->lpPrev = as->decompbuffer; + return S_OK; +} + +static HRESULT WINAPI IAVIStream_fnDelete(IAVIStream*iface,LONG start,LONG samples) { + FIXME("(%p)->Delete(%ld,%ld)\n",iface,start,samples); + return E_FAIL; +} +static HRESULT WINAPI IAVIStream_fnReadData(IAVIStream*iface,DWORD fcc,LPVOID lp,LONG *lpread) { + FIXME("(%p)->ReadData(0x%08lx,%p,%p)\n",iface,fcc,lp,lpread); + return E_FAIL; +} + +static HRESULT WINAPI IAVIStream_fnWriteData(IAVIStream*iface,DWORD fcc,LPVOID lp,LONG size) { + FIXME("(%p)->WriteData(0x%08lx,%p,%ld)\n",iface,fcc,lp,size); + return E_FAIL; +} + +static HRESULT WINAPI IAVIStream_fnSetInfo(IAVIStream*iface,AVISTREAMINFOW*info,LONG infolen) { + FIXME("(%p)->SetInfo(%p,%ld)\n",iface,info,infolen); + return E_FAIL; +} + +/*********************************************************************** + * AVIFileCreateStreamA + */ +HRESULT WINAPI AVIFileCreateStreamA(PAVIFILE iface,PAVISTREAM *ppavi,AVISTREAMINFOA * psi) { + AVISTREAMINFOW psiw; + + /* Only the szName at the end is different */ + memcpy(&psiw,psi,sizeof(*psi)-sizeof(psi->szName)); + MultiByteToWideChar( CP_ACP, 0, psi->szName, -1, + psiw.szName, sizeof(psiw.szName) / sizeof(WCHAR) ); + return IAVIFile_CreateStream(iface,ppavi,&psiw); +} + +/*********************************************************************** + * AVIFileCreateStreamW + */ +HRESULT WINAPI AVIFileCreateStreamW(IAVIFile*iface,PAVISTREAM*avis,AVISTREAMINFOW*asi) { + return IAVIFile_CreateStream(iface,avis,asi); +} + + +/*********************************************************************** + * AVIFileGetStream + */ +HRESULT WINAPI AVIFileGetStream(IAVIFile*iface,PAVISTREAM*avis,DWORD fccType,LONG lParam) { + return IAVIFile_GetStream(iface,avis,fccType,lParam); +} + +/*********************************************************************** + * AVIFileInfoA + */ +HRESULT WINAPI AVIFileInfoA(PAVIFILE iface,LPAVIFILEINFOA afi,LONG size) { + AVIFILEINFOW afiw; + HRESULT hres; + + if (size < sizeof(AVIFILEINFOA)) + return AVIERR_BADSIZE; + hres = IAVIFile_Info(iface,&afiw,sizeof(afiw)); + memcpy(afi,&afiw,sizeof(*afi)-sizeof(afi->szFileType)); + WideCharToMultiByte( CP_ACP, 0, afiw.szFileType, -1, + afi->szFileType, sizeof(afi->szFileType), NULL, NULL ); + afi->szFileType[sizeof(afi->szFileType)-1] = 0; + return hres; +} + +/*********************************************************************** + * AVIStreamInfoW + */ +HRESULT WINAPI AVIStreamInfoW(PAVISTREAM iface,AVISTREAMINFOW *asi,LONG + size) { + return IAVIFile_Info(iface,asi,size); +} + +/*********************************************************************** + * AVIStreamInfoA + */ +HRESULT WINAPI AVIStreamInfoA(PAVISTREAM iface,AVISTREAMINFOA *asi,LONG + size) { + AVISTREAMINFOW asiw; + HRESULT hres; + + if (sizeszName, sizeof(asi->szName), NULL, NULL ); + asi->szName[sizeof(asi->szName)-1] = 0; + return hres; +} + +/*********************************************************************** + * AVIFileInfoW + */ +HRESULT WINAPI AVIFileInfoW(PAVIFILE iface,LPAVIFILEINFOW afi,LONG size) { + return IAVIFile_Info(iface,afi,size); +} + +/*********************************************************************** + * AVIMakeCompressedStream + */ +HRESULT WINAPI AVIMakeCompressedStream(PAVISTREAM *ppsCompressed,PAVISTREAM ppsSource,AVICOMPRESSOPTIONS *aco,CLSID *pclsidHandler) { + char fcc[5]; + IAVIStreamImpl *as; + FIXME("(%p,%p,%p,%p)\n",ppsCompressed,ppsSource,aco,pclsidHandler); + fcc[4]='\0'; + memcpy(fcc,&(aco->fccType),4); + FIXME("\tfccType: '%s'\n",fcc); + memcpy(fcc,&(aco->fccHandler),4); + FIXME("\tfccHandler: '%s'\n",fcc); + FIXME("\tdwFlags: 0x%08lx\n",aco->dwFlags); + + /* we just create a duplicate for now */ + IAVIStream_AddRef(ppsSource); + *ppsCompressed = ppsSource; + as = (IAVIStreamImpl*)ppsSource; + + /* this is where the fun begins. Open a compressor and prepare it. */ + as->hic = ICOpen(aco->fccType,aco->fccHandler,ICMODE_COMPRESS); + + /* May happen. for instance if the codec is not able to compress */ + if (!as->hic) + return AVIERR_UNSUPPORTED; + + ICGetInfo(as->hic,&(as->icinfo),sizeof(ICINFO)); + FIXME("Opened compressor: '%s' '%s'\n",debugstr_w(as->icinfo.szName),debugstr_w(as->icinfo.szDescription)); + as->iscompressing = TRUE; + memcpy(&(as->aco),aco,sizeof(*aco)); + if (as->icinfo.dwFlags & VIDCF_COMPRESSFRAMES) { + ICCOMPRESSFRAMES icf; + + /* now what to fill in there ... Hmm */ + memset(&icf,0,sizeof(icf)); + icf.lDataRate = aco->dwBytesPerSecond; + icf.lQuality = aco->dwQuality; + icf.lKeyRate = aco->dwKeyFrameEvery; + + icf.GetData = (void *)0xdead4242; + icf.PutData = (void *)0xdead4243; + ICSendMessage(as->hic,ICM_COMPRESS_FRAMES_INFO,(LPARAM)&icf,sizeof(icf)); + } + return S_OK; +} + +/*********************************************************************** + * AVIStreamSetFormat + */ +HRESULT WINAPI AVIStreamSetFormat(PAVISTREAM iface,LONG pos,LPVOID format,LONG formatsize) { + return IAVIStream_SetFormat(iface,pos,format,formatsize); +} + +/*********************************************************************** + * AVIStreamReadFormat + */ +HRESULT WINAPI AVIStreamReadFormat(PAVISTREAM iface,LONG pos,LPVOID format,LONG *formatsize) { + return IAVIStream_ReadFormat(iface,pos,format,formatsize); +} + +/*********************************************************************** + * AVIStreamWrite( + */ +HRESULT WINAPI AVIStreamWrite(PAVISTREAM iface,LONG start,LONG samples,LPVOID buffer,LONG buffersize,DWORD flags,LONG *sampwritten,LONG *byteswritten) { + return IAVIStream_Write(iface,start,samples,buffer,buffersize,flags,sampwritten,byteswritten); +} + +/*********************************************************************** + * AVIStreamRead + */ +HRESULT WINAPI AVIStreamRead(PAVISTREAM iface,LONG start,LONG samples,LPVOID buffer,LONG buffersize,LONG *bytesread,LONG *samplesread) { + return IAVIStream_Read(iface,start,samples,buffer,buffersize,bytesread,samplesread); +} + +/*********************************************************************** + * AVIStreamWriteData + */ +HRESULT WINAPI AVIStreamWriteData(PAVISTREAM iface,DWORD fcc,LPVOID lp,LONG size) { + return IAVIStream_WriteData(iface,fcc,lp,size); +} + +/*********************************************************************** + * AVIStreamReadData + */ +HRESULT WINAPI AVIStreamReadData(PAVISTREAM iface,DWORD fcc,LPVOID lp,LONG *lpread) { + return IAVIStream_ReadData(iface,fcc,lp,lpread); +} + +/*********************************************************************** + * AVIStreamStart + */ +LONG WINAPI AVIStreamStart(PAVISTREAM iface) { + AVISTREAMINFOW si; + + IAVIStream_Info(iface,&si,sizeof(si)); + return si.dwStart; +} + +/*********************************************************************** + * AVIStreamLength + */ +LONG WINAPI AVIStreamLength(PAVISTREAM iface) { + AVISTREAMINFOW si; + HRESULT ret; + + ret = IAVIStream_Info(iface,&si,sizeof(si)); + if (ret) /* error */ + return 1; + return si.dwLength; +} + +/*********************************************************************** + * AVIStreamRelease + */ +ULONG WINAPI AVIStreamRelease(PAVISTREAM iface) { + return IAVIStream_Release(iface); +} + +/*********************************************************************** + * AVIStreamGetFrameOpen + */ +PGETFRAME WINAPI AVIStreamGetFrameOpen(PAVISTREAM iface,LPBITMAPINFOHEADER bmi) { + FIXME("(%p)->(%p),stub!\n",iface,bmi); + return NULL; +} + +/*********************************************************************** + * AVIStreamGetFrame + */ +LPVOID WINAPI AVIStreamGetFrame(PGETFRAME pg,LONG pos) { + return IGetFrame_GetFrame(pg,pos); +} + +/*********************************************************************** + * AVIStreamGetFrameClose + */ +HRESULT WINAPI AVIStreamGetFrameClose(PGETFRAME pg) { + if (pg) IGetFrame_Release(pg); + return 0; +} + +/*********************************************************************** + * AVIFileRelease + */ +ULONG WINAPI AVIFileRelease(PAVIFILE iface) { + return IAVIFile_Release(iface); +} + +/*********************************************************************** + * AVIFileExit + */ +void WINAPI AVIFileExit(void) { + FIXME("(), stub.\n"); +} diff --git a/tags/gpgme-0-4-3/complus/gpgcom.c b/tags/gpgme-0-4-3/complus/gpgcom.c new file mode 100644 index 0000000..7c967be --- /dev/null +++ b/tags/gpgme-0-4-3/complus/gpgcom.c @@ -0,0 +1,545 @@ +/* gpgcom.c - COM+ component to access GnuPG + * Copyright (C) 2001 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 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA + */ + + +#include +#include +#include +#include +#include +#include +#include +#include + +#include + +#include "argparse.h" + +#include "main.h" +#include "igpgme.h" + +static void register_server (void); +static void unregister_server (void); +static void enter_complus (void); + + +enum cmd_and_opt_values { aNull = 0, + oQuiet = 'q', + oVerbose = 'v', + + oNoVerbose = 500, + oOptions, + oDebug, + oDebugAll, + oNoGreeting, + oNoOptions, + oHomedir, + oGPGBinary, + oRegServer, + oUnregServer, + oEmbedding, +aTest }; + + +static ARGPARSE_OPTS opts[] = { + + { 301, NULL, 0, N_("@Options:\n ") }, + + { oVerbose, "verbose", 0, N_("verbose") }, + { oQuiet, "quiet", 0, N_("be somewhat more quiet") }, + { oOptions, "options" , 2, N_("read options from file")}, + { oDebug, "debug" ,4|16, N_("set debugging flags")}, + { oDebugAll, "debug-all" ,0, N_("enable full debugging")}, + { oGPGBinary, "gpg-program", 2 , "" }, + { oRegServer, "RegServer" , 0, "" }, + { oUnregServer, "UnregServer" , 0, "" }, + { oEmbedding, "Embedding" , 0, "" }, +{0} }; + + + + +static const char * +my_strusage( int level ) +{ + const char *p; + switch( level ) { + case 11: p = "gpgcom"; + break; + case 13: p = VERSION; break; + /*case 17: p = PRINTABLE_OS_NAME; break;*/ + case 19: p = + _("Please report bugs to .\n"); + break; + case 1: + case 40: p = + _("Usage: gpgcom [options] (-h for help)"); + break; + case 41: p = + _("Syntax: gpgcom [options]\n" + "GnuPG COM+ component\n"); + break; + + default: p = NULL; + } + return p; +} + + +int +main (int argc, char **argv ) +{ + ARGPARSE_ARGS pargs; + int orig_argc; + char **orig_argv; + FILE *configfp = NULL; + char *configname = NULL; + unsigned configlineno; + int parse_debug = 0; + int default_config =1; + int greeting = 0; + int nogreeting = 0; + int action = 0; + + set_strusage( my_strusage ); + /*log_set_name ("gpa"); not yet implemented in logging.c */ + + opt.homedir = getenv("GNUPGHOME"); + if( !opt.homedir || !*opt.homedir ) { + #ifdef HAVE_DRIVE_LETTERS + opt.homedir = "c:/gnupg"; + #else + opt.homedir = "~/.gnupg"; + #endif + } + + /* check whether we have a config file on the commandline */ + orig_argc = argc; + orig_argv = argv; + pargs.argc = &argc; + pargs.argv = &argv; + pargs.flags= 1|(1<<6); /* do not remove the args, ignore version */ + while( arg_parse( &pargs, opts) ) { + if( pargs.r_opt == oDebug || pargs.r_opt == oDebugAll ) + parse_debug++; + else if( pargs.r_opt == oOptions ) { + /* yes there is one, so we do not try the default one, but + * read the option file when it is encountered at the commandline + */ + default_config = 0; + } + else if( pargs.r_opt == oNoOptions ) + default_config = 0; /* --no-options */ + else if( pargs.r_opt == oHomedir ) + opt.homedir = pargs.r.ret_str; + } + + if( default_config ) + configname = make_filename(opt.homedir, "gpgme.conf", NULL ); + + + argc = orig_argc; + argv = orig_argv; + pargs.argc = &argc; + pargs.argv = &argv; + pargs.flags= 1 | (1<<5); /* do not remove the args, allow one dash */ + next_pass: + if( configname ) { + configlineno = 0; + configfp = fopen( configname, "r" ); + if( !configfp ) { + if( default_config ) { + if( parse_debug ) + log_info(_("NOTE: no default option file `%s'\n"), + configname ); + } + else { + log_error(_("option file `%s': %s\n"), + configname, strerror(errno) ); + exit(2); + } + free(configname); configname = NULL; + } + if( parse_debug && configname ) + log_info(_("reading options from `%s'\n"), configname ); + default_config = 0; + } + + while( optfile_parse( configfp, configname, &configlineno, + &pargs, opts) ) { + switch( pargs.r_opt ) { + case oQuiet: opt.quiet = 1; break; + case oVerbose: opt.verbose++; break; + + case oDebug: opt.debug |= pargs.r.ret_ulong; break; + case oDebugAll: opt.debug = ~0; break; + + case oOptions: + /* config files may not be nested (silently ignore them) */ + if( !configfp ) { + free(configname); + configname = xstrdup(pargs.r.ret_str); + goto next_pass; + } + break; + case oNoGreeting: nogreeting = 1; break; + case oNoVerbose: opt.verbose = 0; break; + case oNoOptions: break; /* no-options */ + case oHomedir: opt.homedir = pargs.r.ret_str; break; + case oGPGBinary: break; + + case oRegServer: action = 1; break; + case oUnregServer: action = 2; break; + case oEmbedding: action = 3; break; + + default : pargs.err = configfp? 1:2; break; + } + } + if( configfp ) { + fclose( configfp ); + configfp = NULL; + free(configname); configname = NULL; + goto next_pass; + } + free( configname ); configname = NULL; + if( log_get_errorcount(0) ) + exit(2); + if( nogreeting ) + greeting = 0; + + if( greeting ) { + fprintf(stderr, "%s %s; %s\n", + strusage(11), strusage(13), strusage(14) ); + fprintf(stderr, "%s\n", strusage(15) ); + } + #ifdef IS_DEVELOPMENT_VERSION + log_info("NOTE: this is a development version!\n"); + #endif + + if ( action == 1 ) + register_server (); + else if (action == 2 ) + unregister_server (); + else if (action == 3 ) + enter_complus (); + else { + fprintf (stderr, "This is a COM+ component with no user interface.\n" + "gpgme --help will give you a list of options\n" ); + exit (1); + } + + return 0; +} + + +static void +register_progid ( const char *name ) +{ + HKEY hk = 0; + char buf[500]; + + /* Create a ProgID entry to point to the ClassID */ + sprintf (buf, "%.400s", name); + if (RegCreateKeyA (HKEY_CLASSES_ROOT, buf, &hk)) { + fprintf (stderr,"RegCreateKey(`%s') failed\n", buf); + exit (1); + } + sprintf (buf, "g10 Code's GnuPG made easy COMponent" ); + if (RegSetValueExA (hk, 0, 0, REG_SZ, buf, 0)) { + fprintf (stderr,"RegSetValueEx(`%s') failed\n", buf); + exit (1); + } + if (RegCloseKey (hk)) { + fprintf (stderr,"RegCloseKey() failed\n"); + exit (1); + } + sprintf (buf, "%.400s\\CLSID", name); + if (RegCreateKeyA (HKEY_CLASSES_ROOT, buf, &hk)) { + fprintf (stderr,"RegCreateKey(`%s') failed\n", buf); + exit (1); + } + sprintf (buf, "%.100s", debugstr_guid (&CLSID_Gpgme) ); + if (RegSetValueExA (hk, 0, 0, REG_SZ, buf, strlen (buf))) { + fprintf (stderr,"RegSetValueEx(`%s') failed\n", buf); + exit (1); + } + if (RegCloseKey (hk)) { + fprintf (stderr,"RegCloseKey() failed\n"); + exit (1); + } + hk = 0; +} + + +static void +register_typelib (void) +{ + ITypeLib *pTypeLib; + HRESULT hr; + char name[500]; + wchar_t *wname; + size_t n; + + if ( !GetModuleFileNameA (0, name, sizeof (name)-10) ) { + fprintf (stderr,"GetModuleFileName() failed: %d\n", + (int)GetLastError()); + exit (1); + } + n = mbstowcs (NULL, name, strlen(name)+1); + wname = xmalloc ((n+1)*sizeof *wname); + mbstowcs (wname, name, strlen (name)+1); + + hr = CoInitializeEx (NULL, COINIT_APARTMENTTHREADED); + if (hr) + fprintf (stderr, "CoInitializeEx() failed: hr=%lu\n", hr); + + hr = LoadTypeLibEx (wname, REGKIND_REGISTER, &pTypeLib); + if (hr) + fprintf (stderr, "LoadTypeLibEx() failed: hr=%lx\n", hr); + + ITypeLib_Release (pTypeLib); + CoUninitialize (); + free (wname); +} + +static void +unregister_typelib (void) +{ + UnRegisterTypeLib (&TLBID_Gpgcom, 1, 0, LANG_NEUTRAL, SYS_WIN32); +} + +static void +register_server () +{ + HKEY hk = 0; + char buf[500]; + + + register_typelib (); + + /* Create a key for the CLSID */ + sprintf (buf, "CLSID\\%.100s", debugstr_guid (&CLSID_Gpgme) ); + if (RegCreateKeyA (HKEY_CLASSES_ROOT, buf, &hk)) { + fprintf (stderr,"RegCreateKey(`%s') failed\n", buf); + exit (1); + } + /* Store our class name as default value */ + strcpy (buf, "Gpgme"); + if (RegSetValueExA (hk, 0, 0, REG_SZ, buf, strlen (buf))) { + fprintf (stderr,"RegSetValueEx(`%s') failed\n", buf); + exit (1); + } + + /* Set the application ID */ + sprintf (buf, "%.100s", debugstr_guid (&APPID_Gpgcom) ); + if (RegSetValueExA (hk, "AppID", 0, REG_SZ, buf, strlen (buf))) { + fprintf (stderr,"RegSetValueEx(`%s') failed\n", buf); + exit (1); + } + if (RegCloseKey (hk)) { + fprintf (stderr,"RegCloseKey() failed\n"); + exit (1); + } + hk = 0; + + /* Create the LocalServer32 subkey under the CLSID key */ + sprintf (buf, "CLSID\\%.100s\\LocalServer32", + debugstr_guid (&CLSID_Gpgme) ); + if (RegCreateKeyA (HKEY_CLASSES_ROOT, buf, &hk)) { + fprintf (stderr,"RegCreateKey(`%s') failed\n", buf); + exit (1); + } + /* retrieve the module name and add it under the key */ + if ( !GetModuleFileNameA (0, buf, sizeof (buf)-10) ) { + fprintf (stderr,"GetModuleFileName() failed\n"); + exit (1); + } + if (RegSetValueExA (hk, 0, 0, REG_SZ, buf, strlen (buf))) { + fprintf (stderr,"RegSetValueEx(`%s') failed\n", buf); + exit (1); + } + if (RegCloseKey (hk)) { + fprintf (stderr,"RegCloseKey() failed\n"); + exit (1); + } + hk = 0; + + /* Create the ProgID subkey under the CLSID key */ + sprintf (buf, "CLSID\\%.100s\\ProgID", + debugstr_guid (&CLSID_Gpgme) ); + if (RegCreateKeyA (HKEY_CLASSES_ROOT, buf, &hk)) { + fprintf (stderr,"RegCreateKey(`%s') failed\n", buf); + exit (1); + } + if (RegSetValueExA (hk, 0, 0, REG_SZ, "Gpgcom.Gpgme.1", 0)) { + fprintf (stderr,"RegSetValueEx(`%s') failed\n", buf); + exit (1); + } + if (RegCloseKey (hk)) { + fprintf (stderr,"RegCloseKey() failed\n"); + exit (1); + } + hk = 0; + /* Create the VersionIndependentProgID subkey under the CLSID key */ + sprintf (buf, "CLSID\\%.100s\\VersionIndependentProgID", + debugstr_guid (&CLSID_Gpgme) ); + if (RegCreateKeyA (HKEY_CLASSES_ROOT, buf, &hk)) { + fprintf (stderr,"RegCreateKey(`%s') failed\n", buf); + exit (1); + } + if (RegSetValueExA (hk, 0, 0, REG_SZ, "Gpgcom.Gpgme", 0)) { + fprintf (stderr,"RegSetValueEx(`%s') failed\n", buf); + exit (1); + } + if (RegCloseKey (hk)) { + fprintf (stderr,"RegCloseKey() failed\n"); + exit (1); + } + hk = 0; + + + /* Create a key to store AppID info */ + sprintf (buf, "AppID\\%.100s", debugstr_guid (&APPID_Gpgcom) ); + if (RegCreateKeyA (HKEY_CLASSES_ROOT, buf, &hk)) { + fprintf (stderr,"RegCreateKey(`%s') failed\n", buf); + exit (1); + } + /* Store the name as default value */ + strcpy (buf, "Gpgcom"); + if (RegSetValueExA (hk, 0, 0, REG_SZ, buf, strlen (buf))) { + fprintf (stderr,"RegSetValueEx(`%s') failed\n", buf); + exit (1); + } + if (RegCloseKey (hk)) { + fprintf (stderr,"RegCloseKey() failed\n"); + exit (1); + } + hk = 0; + + register_progid ("Gpgcom.Gpgme"); + register_progid ("Gpgcom.Gpgme.1"); + + /* Create a convenience cross reference to the AppID */ + sprintf (buf, "AppID\\gpgcom.exe"); + if (RegCreateKeyA (HKEY_CLASSES_ROOT, buf, &hk)) { + fprintf (stderr,"RegCreateKey(`%s') failed\n", buf); + exit (1); + } + sprintf (buf, "%.100s", debugstr_guid (&APPID_Gpgcom) ); + if (RegSetValueExA (hk, "AppID", 0, REG_SZ, buf, strlen (buf))) { + fprintf (stderr,"RegSetValueEx(`%s') failed\n", buf); + exit (1); + } + if (RegCloseKey (hk)) { + fprintf (stderr,"RegCloseKey() failed\n"); + exit (1); + } + hk = 0; + + fprintf (stderr,"*** Component registered\n"); +} + +static void +unregister_server () +{ + char buf[500]; + + unregister_typelib (); + sprintf (buf, "CLSID\\%.100s\\LocalServer32", + debugstr_guid (&CLSID_Gpgme) ); + if (RegDeleteKey (HKEY_CLASSES_ROOT, buf)) + fprintf (stderr,"RegDeleteKey(`%s') failed\n", buf); + + sprintf (buf, "CLSID\\%.100s\\ProgID", debugstr_guid (&CLSID_Gpgme) ); + if (RegDeleteKey (HKEY_CLASSES_ROOT, buf)) + fprintf (stderr,"RegDeleteKey(`%s') failed\n", buf); + + sprintf (buf, "CLSID\\%.100s", debugstr_guid (&CLSID_Gpgme) ); + if (RegDeleteKey (HKEY_CLASSES_ROOT, buf)) + fprintf (stderr,"RegDeleteKey(`%s') failed\n", buf); + + sprintf (buf, "Gpgcom.Gpgme.1\\CLSID"); + if (RegDeleteKey (HKEY_CLASSES_ROOT, buf)) + fprintf (stderr,"RegDeleteKey(`%s') failed\n", buf); + sprintf (buf, "Gpgcom.Gpgme.1"); + if (RegDeleteKey (HKEY_CLASSES_ROOT, buf)) + fprintf (stderr,"RegDeleteKey(`%s') failed\n", buf); + + sprintf (buf, "Gpgcom.Gpgme\\CLSID"); + if (RegDeleteKey (HKEY_CLASSES_ROOT, buf)) + fprintf (stderr,"RegDeleteKey(`%s') failed\n", buf); + sprintf (buf, "Gpgcom.Gpgme"); + if (RegDeleteKey (HKEY_CLASSES_ROOT, buf)) + fprintf (stderr,"RegDeleteKey(`%s') failed\n", buf); + + + sprintf (buf, "AppID\\%.100s", debugstr_guid (&APPID_Gpgcom) ); + if (RegDeleteKey (HKEY_CLASSES_ROOT, buf)) + fprintf (stderr,"RegDeleteKey(`%s') failed\n", buf); + + sprintf (buf, "AppID\\gpgcom.exe" ); + if (RegDeleteKey (HKEY_CLASSES_ROOT, buf)) + fprintf (stderr,"RegDeleteKey(`%s') failed\n", buf); + + fprintf (stderr,"*** component unregistered\n"); +} + + +static void +enter_complus () +{ + HANDLE running; + DWORD reg; + IClassFactory *factory; + CLSID clsid; + HRESULT hr; + + fprintf (stderr,"*** enter enter_complus()\n"); + CoInitializeEx (NULL, COINIT_MULTITHREADED); + running = CreateEvent (NULL, FALSE, FALSE, NULL ); + fprintf (stderr,"*** CoInitialize() done; event=%lx\n", (unsigned long)running ); + + igpgme_register_exit_event (running); + factory = igpgme_factory_new ( &clsid ); + fprintf (stderr,"*** igpgme_factory_new() done; got=%p\n", factory ); + hr = CoRegisterClassObject (&clsid, (IUnknown*)factory, + CLSCTX_LOCAL_SERVER, + REGCLS_SUSPENDED|REGCLS_MULTIPLEUSE, ® ); + if (hr) { + fprintf (stderr, "CoRegisterClassObject() failed: hr=%lx\n", hr); + exit (1); + } + hr = CoResumeClassObjects (); + if (hr) + fprintf (stderr, "CoRegisterClassObject() failed: hr=%lx\n", hr); + fprintf (stderr,"*** class object registered; waiting\n" ); + + WaitForSingleObject ( running, INFINITE ); + fprintf (stderr,"*** shutting down\n" ); + igpgme_register_exit_event (NULL); + CloseHandle (running); + CoRevokeClassObject ( reg ); + fprintf (stderr,"*** class object revoked\n" ); + igpgme_factory_release (factory); + fprintf (stderr,"*** factory released\n" ); + CoUninitialize (); + fprintf (stderr,"*** leave enter_complus()\n" ); +} + diff --git a/tags/gpgme-0-4-3/complus/gpgcom.idl b/tags/gpgme-0-4-3/complus/gpgcom.idl new file mode 100644 index 0000000..654eec0 --- /dev/null +++ b/tags/gpgme-0-4-3/complus/gpgcom.idl @@ -0,0 +1,62 @@ +/* ignupg.idl - Interface definition for the COM+ class GnuPG + * Copyright (C) 2001 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 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA + */ + + +import "unknwn.idl"; +import "oaidl.idl"; + + +[ object, uuid(3811fd50-7f72-11d5-8c9e-0080ad190cd5), dual] +interface IGpgme : IDispatch +{ + HRESULT GetVersion([out] BSTR *retval); + HRESULT GetEngineInfo([out] BSTR *retval); + HRESULT Cancel(void); + [propput] HRESULT Armor([in] BOOL flag); + [propget] HRESULT Armor([out, retval] BOOL *retval); + [propput] HRESULT Textmode([in] BOOL flag); + [propget] HRESULT Textmode([out, retval] BOOL *retval); + [propput] HRESULT Plaintext([in] VARIANT val); + [propget] HRESULT Plaintext([out, retval] VARIANT *retval); + [propput] HRESULT Ciphertext([in] VARIANT val); + [propget] HRESULT Ciphertext([out,retval] VARIANT *retval); + HRESULT ClearRecipients(void); + HRESULT AddRecipient([in] BSTR name, + [in, optional, defaultvalue(-1)] signed short trust); + HRESULT ResetSignKeys(void); + HRESULT AddSignKey([in] BSTR name); + HRESULT Encrypt(void); + HRESULT Sign([in,optional,defaultvalue(0)] signed short signmode); + HRESULT SignEncrypt([in,optional,defaultvalue(0)] signed short signmode); + +}; + + +[ uuid(3811fd48-7f72-11d5-8c9e-0080ad190cd5), + helpstring("g10Code.gpgcom, type library"), + version(1.0) ] +library GpgcomLib +{ + [ uuid(3811fd40-7f72-11d5-8c9e-0080ad190cd5) ] + coclass Gpgcom + { + [default] interface IGpgme; + } +}; diff --git a/tags/gpgme-0-4-3/complus/gpgcom.rc b/tags/gpgme-0-4-3/complus/gpgcom.rc new file mode 100644 index 0000000..d9ac566 --- /dev/null +++ b/tags/gpgme-0-4-3/complus/gpgcom.rc @@ -0,0 +1,22 @@ +/* gpgcom.rc - Resource file for gpgcom + * Copyright (C) 2001 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 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA + */ + +1 TYPELIB "gpgcom.tlb" + diff --git a/tags/gpgme-0-4-3/complus/gpgcom.tlb b/tags/gpgme-0-4-3/complus/gpgcom.tlb new file mode 100644 index 0000000..ae3d162 Binary files /dev/null and b/tags/gpgme-0-4-3/complus/gpgcom.tlb differ diff --git a/tags/gpgme-0-4-3/complus/guidgen.c b/tags/gpgme-0-4-3/complus/guidgen.c new file mode 100644 index 0000000..a4ac07d --- /dev/null +++ b/tags/gpgme-0-4-3/complus/guidgen.c @@ -0,0 +1,130 @@ +/* guidgen.c - Tool to create GUIDs + * Copyright (C) 2001 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 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA + */ + + +#include +#include +#include +#include +#include +#include +#include +#include + +#include "obj_base.h" + +#include "argparse.h" + + +enum cmd_and_opt_values { aNull = 0, + oVerbose = 'v', + +aTest }; + + +static ARGPARSE_OPTS opts[] = { + + { 301, NULL, 0, "@Options:\n " }, + + { oVerbose, "verbose", 0, "verbose" }, +{0} }; + +static struct { + int verbose; +} opt; + + +static void create_guid (void); + +static const char * +my_strusage( int level ) +{ + const char *p; + switch( level ) { + case 11: p = "guidgen"; + break; + case 13: p = VERSION; break; + /*case 17: p = PRINTABLE_OS_NAME; break;*/ + case 19: p = + "Please report bugs to .\n"; + break; + case 1: + case 40: p = + "Usage: guidgen [options] (-h for help)"; + break; + case 41: p = + "Syntax: guidgen [options]\n" + "Generate GUIDs\n"; + break; + + default: p = NULL; + } + return p; +} + + +int +main (int argc, char **argv ) +{ + ARGPARSE_ARGS pargs; + + set_strusage( my_strusage ); + /*log_set_name ("gpa"); not yet implemented in logging.c */ + + pargs.argc = &argc; + pargs.argv = &argv; + pargs.flags= 0; + while( arg_parse( &pargs, opts) ) { + switch( pargs.r_opt ) { + case oVerbose: opt.verbose++; break; + + default : pargs.err = 2; break; + } + } + + if (!argc) + create_guid(); + else { + int n; + + for (n = atoi (argv[0]); n > 0; n-- ) + create_guid (); + } + + return 0; +} + + +static void +create_guid () +{ + GUID guid, *id; + id = &guid; + if ( CoCreateGuid (id) ) { + fprintf (stderr,"failed to create GUID\n"); + exit (1); + } + printf( "{%08lx-%04x-%04x-%02x%02x-%02x%02x%02x%02x%02x%02x}\n", + id->Data1, id->Data2, id->Data3, + id->Data4[0], id->Data4[1], id->Data4[2], id->Data4[3], + id->Data4[4], id->Data4[5], id->Data4[6], id->Data4[7] ); +} + + diff --git a/tags/gpgme-0-4-3/complus/igpgme.c b/tags/gpgme-0-4-3/complus/igpgme.c new file mode 100644 index 0000000..9aa64a2 --- /dev/null +++ b/tags/gpgme-0-4-3/complus/igpgme.c @@ -0,0 +1,859 @@ +/* igpgme.c - COM+ class IGpgme + * Copyright (C) 2001 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 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA + */ + + +#include +#include +#include +#include +#include +#include +#include +#include + +#include "../gpgme/gpgme.h" + +/* FIXME: Put them into an extra header */ +void *_gpgme_malloc (size_t n ); +void *_gpgme_calloc (size_t n, size_t m ); +void *_gpgme_realloc (void *p, size_t n); +char *_gpgme_strdup (const char *p); +void _gpgme_free ( void *a ); + + + +#define INITGUID +#include "igpgme.h" + +/* + * Declare the interface implementation structures + */ +typedef struct IGpgmeImpl IGpgmeImpl; +typedef struct IClassFactoryImpl IClassFactoryImpl; + +static HANDLE my_exit_event; + +struct IGpgmeImpl { + /* IUnknown required stuff */ + ICOM_VFIELD (IGpgme); + DWORD ref; + /* Delegation to IDispatch */ + struct { + IUnknown *disp; + ITypeInfo *tinfo; + } std_disp; + /* Our stuff */ + GpgmeCtx mainctx; + GpgmeData plaintext; + int plaintext_given_as_bstr; + GpgmeData ciphertext; + int ciphertext_is_armored; + GpgmeRecipients rset; +}; + + +struct IClassFactoryImpl { + /* IUnknown fields */ + ICOM_VFIELD(IClassFactory); + DWORD ref; +}; + +/********************************************************** + ************** helper functions ************************ + *********************************************************/ +static HRESULT +map_gpgme_error (GpgmeError err) +{ + HRESULT hr; + + if (!err) + return 0; + if ( err < 0 || err > 0x1000 ) { + fprintf (stderr,"*** GpgmeError `%s' mapped to GPGME_General_Error\n", + gpgme_strerror (err) ); + err = GPGME_General_Error; + } + hr = MAKE_HRESULT (SEVERITY_ERROR, FACILITY_ITF, 0x1000 + err); + fprintf (stderr,"*** GpgmeError `%s' mapped to %lx\n", + gpgme_strerror (err), (unsigned long)hr ); + return hr; +} + + +/********************************************************** + ************** IGpgme Implementation ******************* + *********************************************************/ + +static HRESULT WINAPI +m_IGpgme_QueryInterface (IGpgme *iface, REFIID refiid, LPVOID *obj) +{ + ICOM_THIS (IGpgmeImpl,iface); + + /*fprintf (stderr,"*** m_IGpgme_QueryInterface(%p,%s)", + This, debugstr_guid(refiid));*/ + if ( IsEqualGUID (&IID_IUnknown, refiid) + || IsEqualGUID (&IID_IGpgme, refiid) ) { + *obj = This; + IGpgme_AddRef (iface); + fprintf (stderr," -> got %p\n", *obj); + return 0; + } + else if ( IsEqualGUID (&IID_IDispatch, refiid) ) { + HRESULT hr = IDispatch_QueryInterface (This->std_disp.disp, + refiid, obj); + /*fprintf (stderr," -> delegated, hr=%lx, got %p\n", + hr, hr? NULL: *obj);*/ + return hr; + } + /*fprintf (stderr," -> none\n");*/ + *obj = NULL; + return E_NOINTERFACE; +} + + +static ULONG WINAPI +m_IGpgme_AddRef (IGpgme *iface) +{ + ICOM_THIS (IGpgmeImpl,iface); + + return ++This->ref; +} + + +static ULONG WINAPI +m_IGpgme_Release (IGpgme *iface) +{ + ICOM_THIS (IGpgmeImpl,iface); + + if (--This->ref) + return This->ref; + + gpgme_release (This->mainctx); This->mainctx = NULL; + gpgme_data_release (This->plaintext); This->plaintext = NULL; + gpgme_data_release (This->ciphertext); This->ciphertext = NULL; + gpgme_recipients_release (This->rset); This->rset = NULL; + if (This->std_disp.disp) + IDispatch_Release (This->std_disp.disp); + if (This->std_disp.tinfo) + ITypeInfo_Release (This->std_disp.tinfo); + HeapFree(GetProcessHeap(),0,iface); + { + ULONG count = CoReleaseServerProcess (); + if (!count && my_exit_event) + SetEvent (my_exit_event); + } + return 0; +} + + +static HRESULT WINAPI +m_stub_IDispatch_GetTypeInfoCount (IGpgme *iface, unsigned int *pctinfo) +{ + return E_NOTIMPL; +} + +static HRESULT WINAPI +m_stub_IDispatch_GetTypeInfo (IGpgme *iface, UINT iTInfo, + LCID lcid, ITypeInfo **ppTInfo) +{ + return E_NOTIMPL; +} + +static HRESULT WINAPI +m_stub_IDispatch_GetIDsOfNames (IGpgme *iface, REFIID riid, + LPOLESTR *rgszNames, UINT cNames, + LCID lcid, DISPID *rgDispId) +{ + return E_NOTIMPL; +} + +static HRESULT WINAPI +m_stub_IDispatch_Invoke (IGpgme *iface, DISPID dispIdMember, + REFIID riid, LCID lcid, WORD wFlags, + DISPPARAMS *pDispParams, VARIANT *pVarResult, + EXCEPINFO *pExepInfo, UINT *puArgErr) +{ + return E_NOTIMPL; +} + + + +static HRESULT WINAPI +m_IGpgme_GetVersion (IGpgme *iface, BSTR *retvat) +{ + return E_NOTIMPL; +} + +static HRESULT WINAPI +m_IGpgme_GetEngineInfo (IGpgme *iface, BSTR *retval) +{ + return E_NOTIMPL; +} + + +static HRESULT WINAPI +m_IGpgme_Cancel (IGpgme *iface) +{ + return E_NOTIMPL; +} + + +static HRESULT WINAPI +m_IGpgme_SetArmor (IGpgme *iface, BOOL yes) +{ + ICOM_THIS (IGpgmeImpl,iface); + + gpgme_set_armor (This->mainctx, yes); + return 0; +} + +static HRESULT WINAPI +m_IGpgme_GetArmor (IGpgme *iface, BOOL *retval) +{ + ICOM_THIS (IGpgmeImpl,iface); + + *retval = gpgme_get_armor (This->mainctx); + return 0; +} + + +static HRESULT WINAPI +m_IGpgme_SetTextmode (IGpgme *iface, BOOL yes) +{ + ICOM_THIS (IGpgmeImpl,iface); + + gpgme_set_textmode (This->mainctx, yes); + return 0; +} + +static HRESULT WINAPI +m_IGpgme_GetTextmode (IGpgme *iface, BOOL *retval) +{ + ICOM_THIS (IGpgmeImpl,iface); + + *retval = gpgme_get_textmode (This->mainctx); + return 0; +} + + +/* + * Put the data from VAL into a a Gpgme data object, which is passed by + * reference. Valid types of the Variant are: BSTR, SAFEARRAY of BYTE and + * SAFEARRAY of VARIANTS of signed or unsigned integers. + */ +static HRESULT WINAPI +set_data_from_variant (GpgmeData *data, VARIANT val, int *given_as_bstr) +{ + GpgmeError err = 0; + HRESULT hr; + unsigned char *buf; + SAFEARRAY *array; + size_t len; + int i; + + if ( val.vt == VT_BSTR) { + len = bstrtoutf8 (val.u.bstrVal, NULL, 0); + buf = _gpgme_malloc (len); + if (!buf) + return E_OUTOFMEMORY; + + if (bstrtoutf8 (val.u.bstrVal, buf, len) < 0) { + fprintf (stderr,"problem with bstrtoutf8\n"); + _gpgme_free (buf); + return E_FAIL; + } + + #if 0 + fprintf (stderr,"Got a BSTR (utf8):"); + for (i=0; i < len; i++) + fprintf (stderr, " %0X", buf[i] ); + putc ('\n', stderr); + #endif + gpgme_data_release (*data); *data = NULL; + err = gpgme_data_new_from_mem (data, buf, len, 0 /*no need to copy*/ ); + if (!err && given_as_bstr) + *given_as_bstr = 1; + } + else if ( val.vt == (VT_ARRAY|VT_UI1)) { + array = val.u.parray; + + /*fprintf (stderr,"Got an ARRAY of bytes:");*/ + hr = SafeArrayAccessData (array, (void**)&buf); + if (hr) { + fprintf (stderr,"*** SafeArrayAccessData failed: hr=%lx\n", hr); + return hr; + } + len = array->rgsabound[0].cElements; + /*for (i=0; i < len; i++) + fprintf (stderr, " %0X", buf[i] ); + putc ('\n', stderr);*/ + + gpgme_data_release (*data); *data = NULL; + err = gpgme_data_new_from_mem (data, buf, len, 1 ); + SafeArrayUnaccessData (array); + if (given_as_bstr) + *given_as_bstr = 0; + } + else if ( val.vt == (VT_ARRAY|VT_VARIANT)) { + VARIANT *vp; + array = val.u.parray; + + /*fprintf (stderr,"Got an ARRAY of VARIANTS:");*/ + hr = SafeArrayAccessData (array, (void**)&vp); + if (hr) { + fprintf (stderr,"*** SafeArrayAccessData failed: hr=%lx\n", hr); + return hr; + } + len = array->rgsabound[0].cElements; + /* allocate the array using the gpgme allocator so that we can + * later use a new without the copy set*/ + buf = _gpgme_malloc (len); + if (!buf) { + SafeArrayUnaccessData (array); + return E_OUTOFMEMORY; + } + /* coerce all array elements into rawtext */ + for (i=0; i < len; i++) { + switch (vp[i].vt) { + case VT_I1: buf[i] = (BYTE)vp[i].u.cVal; break; + case VT_I2: buf[i] = ((UINT)vp[i].u.iVal) & 0xff; break; + case VT_I4: buf[i] = ((ULONG)vp[i].u.lVal) & 0xff; break; + case VT_INT: buf[i] = ((UINT)vp[i].u.intVal) & 0xff; break; + case VT_UI1: buf[i] = vp[i].u.bVal; break; + case VT_UI2: buf[i] = vp[i].u.uiVal & 0xff; break; + case VT_UI4: buf[i] = vp[i].u.ulVal & 0xff; break; + case VT_UINT: buf[i] = vp[i].u.uintVal & 0xff; break; + default: + fprintf (stderr, "Invalid value in array as pos %d\n", i); + _gpgme_free (buf); + SafeArrayUnaccessData (array); + return E_INVALIDARG; + } + } + + /*for (i=0; i < len; i++) + fprintf (stderr, " %0X", buf[i] ); + putc ('\n', stderr);*/ + + gpgme_data_release (*data); *data = NULL; + err = gpgme_data_new_from_mem (data, buf, len, 0); + SafeArrayUnaccessData (array); + if (given_as_bstr) + *given_as_bstr = 0; + } + else { + fprintf (stderr, "Got a variant type = %d (0x%x)\n", + (int)val.vt, (int)val.vt ); + return E_INVALIDARG; /* not a safearray of bytes */ + } + return map_gpgme_error (err); +} + + +static HRESULT WINAPI +set_data_to_variant (GpgmeData data, VARIANT *retval, int use_bstr) +{ + GpgmeError err; + HRESULT hr; + SAFEARRAY *array; + char *p; + size_t nread, len; + int i; + + /* Get some info on the data */ + err = gpgme_data_rewind (data); + if (err ) { + fprintf (stderr, "*** gpgme_data_rewind failed: %d\n", err); + return map_gpgme_error (err); + } + err = gpgme_data_read (data, NULL, 0, &nread); + if (err && err != GPGME_EOF ) { + fprintf (stderr, "*** gpgme_data_read [length] failed: %d\n", err); + return map_gpgme_error (err); + } + len = nread; /*(eof returns a length of 0)*/ + /*fprintf (stderr,"*** %d bytes are availabe\n", (int)len);*/ + + /* convert it to the target data type */ + if (use_bstr) { + BSTR bs; + unsigned char *helpbuf; + + /* It is easier to allocate some helper storage */ + helpbuf = _gpgme_malloc (len); + if (!helpbuf) + return E_OUTOFMEMORY; + err = gpgme_data_read (data, helpbuf, len, &nread); + if (err ) { + _gpgme_free (helpbuf); + fprintf (stderr, "*** gpgme_data_read [data] failed: %d\n", err); + return map_gpgme_error (err); + } + + bs = SysAllocStringLen (NULL, len+1); + if (!bs) { + _gpgme_free (helpbuf); + return E_OUTOFMEMORY; + } + + for (i=0, p=helpbuf; i < len; i++, p++) + bs[i] = *p; + bs[i] = 0; + _gpgme_free (helpbuf); + + /* Ready */ + VariantInit (retval); + retval->vt = VT_BSTR; + retval->u.bstrVal = bs; + } +#if 0 + else if (use_byte_array) { + array = SafeArrayCreateVector (VT_UI1, 0, len); + if (!array) + return E_OUTOFMEMORY; + + p = NULL; + hr = SafeArrayAccessData (array, (void**)&p); + if (hr) { + fprintf (stderr,"*** SafeArrayAccessData failed: hr=%lx\n", hr); + SafeArrayDestroyData (array); + SafeArrayDestroy (array); + return hr; + } + if (len) { + err = gpgme_data_read (data, p, len, &nread); + if (err ) { + SafeArrayUnaccessData (array); + SafeArrayDestroyData (array); + SafeArrayDestroy (array); + fprintf (stderr, "*** gpgme_data_read [data] failed: %d\n", + err); + return map_gpgme_error (err); + } + } + SafeArrayUnaccessData (array); + + /* pass the data to the caller */ + VariantInit (retval); + retval->vt = (VT_ARRAY|VT_UI1); + retval->u.parray = array; + } +#endif + else { /* Create an array of variants of bytes */ + VARIANT *v; + unsigned char *helpbuf; + + /* It is easier to allocate some helper storage */ + helpbuf = _gpgme_malloc (len); + if (!helpbuf) + return E_OUTOFMEMORY; + err = gpgme_data_read (data, helpbuf, len, &nread); + if (err ) { + _gpgme_free (helpbuf); + fprintf (stderr, "*** gpgme_data_read [data] failed: %d\n", err); + return map_gpgme_error (err); + } + + /* The create the array */ + array = SafeArrayCreateVector (VT_VARIANT, 0, len); + if (!array) { + _gpgme_free (helpbuf); + return E_OUTOFMEMORY; + } + + v = NULL; + hr = SafeArrayAccessData (array, (void**)&v); + if (hr) { + fprintf (stderr,"*** SafeArrayAccessData failed: hr=%lx\n", hr); + _gpgme_free (helpbuf); + SafeArrayDestroyData (array); + SafeArrayDestroy (array); + return hr; + } + + for (p=helpbuf; len; len--, v++) { + VariantInit (v); + v->vt = VT_UI1; + v->u.bVal = *p; + } + SafeArrayUnaccessData (array); + _gpgme_free (helpbuf); + + /* pass the data to the caller */ + VariantInit (retval); + retval->vt = (VT_ARRAY|VT_VARIANT); + retval->u.parray = array; + } + return 0; +} + + +static HRESULT WINAPI +m_IGpgme_SetPlaintext (IGpgme *iface, VARIANT val) +{ + ICOM_THIS (IGpgmeImpl,iface); + + return set_data_from_variant (&This->plaintext, val, + &This->plaintext_given_as_bstr); +} + + +static HRESULT WINAPI +m_IGpgme_GetPlaintext (IGpgme *iface, VARIANT *retval) +{ + ICOM_THIS (IGpgmeImpl,iface); + + /*fprintf (stderr,"*** " __PRETTY_FUNCTION__ "(%p)\n", This );*/ + return set_data_to_variant (This->plaintext, retval, + This->plaintext_given_as_bstr); +} + +static HRESULT WINAPI +m_IGpgme_SetCiphertext (IGpgme *iface, VARIANT val) +{ + ICOM_THIS (IGpgmeImpl,iface); + + return set_data_from_variant (&This->ciphertext, val, NULL); +} + +static HRESULT WINAPI +m_IGpgme_GetCiphertext (IGpgme *iface, VARIANT *retval) +{ + ICOM_THIS (IGpgmeImpl,iface); + + return set_data_to_variant (This->ciphertext, retval, + This->ciphertext_is_armored); +} + +static HRESULT WINAPI +m_IGpgme_ClearRecipients (IGpgme *iface) +{ + ICOM_THIS (IGpgmeImpl,iface); + + gpgme_recipients_release (This->rset); This->rset = NULL; + return 0; +} + + +static HRESULT WINAPI +m_IGpgme_AddRecipient (IGpgme *iface, BSTR name, signed short int trust) +{ + GpgmeError err; + int n; + char *p; + ICOM_THIS (IGpgmeImpl,iface); + + /*fprintf (stderr,"*** " __PRETTY_FUNCTION__ "(%p, %d)\n", + This, (int)trust);*/ + if (!This->rset) { + err = gpgme_recipients_new (&This->rset); + if (err) + return map_gpgme_error (err); + } + + n = bstrtoutf8 (name, NULL, 0); + p = HeapAlloc (GetProcessHeap(), 0, n ); + if (!p) { + fprintf (stderr,"HeapAlloc failed: ec=%d\n", (int)GetLastError () ); + return E_OUTOFMEMORY; + } + if (bstrtoutf8 (name, p, n) < 0) { + fprintf (stderr,"problem with bstrtoutf8\n"); + HeapFree (GetProcessHeap(), 0, p); + return E_FAIL; + } + err = gpgme_recipients_add_name (This->rset, p); + HeapFree (GetProcessHeap(), 0, p); + return map_gpgme_error (err); +} + +static HRESULT WINAPI +m_IGpgme_ResetSignKeys (IGpgme *iface) +{ + return E_NOTIMPL; +} + +static HRESULT WINAPI +m_IGpgme_AddSignKey (IGpgme *iface, BSTR name) +{ + return E_NOTIMPL; +} + +static HRESULT WINAPI +m_IGpgme_Encrypt (IGpgme *iface) +{ + GpgmeError err; + ICOM_THIS (IGpgmeImpl,iface); + + gpgme_data_release (This->ciphertext); + err = gpgme_data_new (&This->ciphertext); + if (err) + return map_gpgme_error (err); + + + This->ciphertext_is_armored = gpgme_get_armor (This->mainctx); + err = gpgme_op_encrypt (This->mainctx, This->rset, + This->plaintext, This->ciphertext); +#if 0 + if (!err ) { + char buf[100]; + size_t nread; + + err = gpgme_data_rewind ( This->ciphertext ); + if (err ) + fprintf (stderr, "*** gpgme_data_rewind failed: %d\n", err); + while ( !(err = gpgme_data_read ( This->ciphertext, + buf, 100, &nread )) ) { + fwrite ( buf, nread, 1, stderr ); + } + if (err != GPGME_EOF) + fprintf (stderr, "*** gpgme_data_read failed: %d\n", err); + err = 0; + } +#endif + + return map_gpgme_error (err); +} + +static HRESULT WINAPI +m_IGpgme_Sign (IGpgme *iface, short int signmode) +{ + ICOM_THIS (IGpgmeImpl,iface); + + fprintf (stderr,"*** " __PRETTY_FUNCTION__ "(%p)\n", This ); + + return E_NOTIMPL; +} + +static HRESULT WINAPI +m_IGpgme_SignEncrypt (IGpgme *iface, short int signmode) +{ + ICOM_THIS (IGpgmeImpl,iface); + + fprintf (stderr,"*** " __PRETTY_FUNCTION__ "(%p)\n", This ); + + return E_NOTIMPL; +} + +#if 0 +static HRESULT WINAPI +m_IGpgme_GetSigStatus(GpgmeCtx c, int idx, + GpgmeSigStat *r_stat, time_t *r_created ); +{ + return 0; +} + + +static HRESULT WINAPI +m_IGpgme_GetSigKey (GpgmeCtx c, int idx, GpgmeKey *r_key); +{ + return 0; +} + +static HRESULT WINAPI +m_IGpgme_GetNotation(IGpgme *c, BSTR *retval) +{ + return 0; +} +#endif + + +static ICOM_VTABLE(IGpgme) igpgme_vtbl = +{ + /* IUnknown methods */ + ICOM_MSVTABLE_COMPAT_DummyRTTIVALUE + m_IGpgme_QueryInterface, + m_IGpgme_AddRef, + m_IGpgme_Release, + /* IDispatch methods */ + m_stub_IDispatch_GetTypeInfoCount, + m_stub_IDispatch_GetTypeInfo, + m_stub_IDispatch_GetIDsOfNames, + m_stub_IDispatch_Invoke, + /* Our methods */ + m_IGpgme_GetVersion, + m_IGpgme_GetEngineInfo, + m_IGpgme_Cancel, + m_IGpgme_SetArmor, + m_IGpgme_GetArmor, + m_IGpgme_SetTextmode, + m_IGpgme_GetTextmode, + m_IGpgme_SetPlaintext, + m_IGpgme_GetPlaintext, + m_IGpgme_SetCiphertext, + m_IGpgme_GetCiphertext, + m_IGpgme_ClearRecipients, + m_IGpgme_AddRecipient, + m_IGpgme_ResetSignKeys, + m_IGpgme_AddSignKey, + m_IGpgme_Encrypt, + m_IGpgme_Sign, + m_IGpgme_SignEncrypt +}; + + + +/*************************************************************** + ****************** Gpgme Factory **************************** + ***************************************************************/ + +static HRESULT WINAPI +m_GpgmeFactory_QueryInterface (IClassFactory *iface, + REFIID refiid, LPVOID *obj) +{ + ICOM_THIS (IClassFactoryImpl,iface); + + /*fprintf (stderr,"*** m_GpgmeFactory_QueryInterface(%p,%s)", + This, debugstr_guid(refiid));*/ + if ( IsEqualGUID (&IID_IUnknown, refiid) + || IsEqualGUID (&IID_IClassFactory, refiid) ) { + *obj = This; + /*fprintf (stderr," -> got %p\n", obj);*/ + return 0; + } + *obj = NULL; + /*fprintf (stderr," -> none\n");*/ + return E_NOINTERFACE; +} + +static ULONG WINAPI +m_GpgmeFactory_AddRef (IClassFactory *iface) +{ + ICOM_THIS(IClassFactoryImpl,iface); + return ++(This->ref); +} + +static ULONG WINAPI +m_GpgmeFactory_Release (IClassFactory *iface) +{ + ICOM_THIS(IClassFactoryImpl,iface); + return --(This->ref); +} + +static HRESULT WINAPI +m_GpgmeFactory_CreateInstance (IClassFactory *iface, IUnknown *outer, + REFIID refiid, LPVOID *r_obj ) +{ + /*ICOM_THIS(IClassFactoryImpl,iface);*/ + + fprintf (stderr,"*** m_GpgmeFactory_CreateInstance(%s)", + debugstr_guid(refiid) ); + if ( IsEqualGUID (&IID_IUnknown, refiid) + || IsEqualGUID (&IID_IGpgme, refiid) ) { + IGpgmeImpl *obj; + GpgmeCtx ctx; + GpgmeError err; + + + err = gpgme_new (&ctx); + if (err) { + fprintf (stderr," -> gpgme_new failed: %s\n", gpgme_strerror (err)); + return E_OUTOFMEMORY; + } + + obj = HeapAlloc (GetProcessHeap(), 0, sizeof *obj ); + if ( !obj) { + fprintf (stderr," -> out of core\n"); + gpgme_release (ctx); + return E_OUTOFMEMORY; + } + memset (obj, 0, sizeof *obj); + + ICOM_VTBL(obj) = &igpgme_vtbl; + obj->ref = 1; + obj->mainctx = ctx; + { /* Fixme: need to release some stuff on error */ + HRESULT hr; + ITypeLib *pTypeLib; + + hr = LoadRegTypeLib (&TLBID_Gpgcom, 1, 0, LANG_NEUTRAL, &pTypeLib); + if (hr) { + fprintf (stderr," -> LoadRegTypeLib failed: %lx\n", hr); + return hr; + } + hr = ITypeLib_GetTypeInfoOfGuid (pTypeLib, &IID_IGpgme, + &obj->std_disp.tinfo); + ITypeLib_Release (pTypeLib); + if (hr) { + fprintf (stderr," -> GetTypeInfoOfGuid failed: %lx\n", hr); + return hr; + } + hr = CreateStdDispatch ((IUnknown*)obj, obj, obj->std_disp.tinfo, + &obj->std_disp.disp); + if (hr) { + fprintf (stderr," -> CreateStdDispatch failed: %lx\n", hr); + return hr; + } + } + + CoAddRefServerProcess (); + *r_obj = obj; + fprintf (stderr," -> created %p\n", obj ); + return 0; + } + fprintf (stderr," -> no interface\n" ); + *r_obj = NULL; + return E_NOINTERFACE; +} + +static HRESULT WINAPI +m_GpgmeFactory_LockServer (IClassFactory *iface, BOOL dolock ) +{ + if (dolock) { + CoAddRefServerProcess (); + } + else { + ULONG count = CoReleaseServerProcess (); + if (!count && my_exit_event) + SetEvent (my_exit_event); + } + return 0; +} + +static ICOM_VTABLE(IClassFactory) igpgme_factory_vtbl = { + ICOM_MSVTABLE_COMPAT_DummyRTTIVALUE + m_GpgmeFactory_QueryInterface, + m_GpgmeFactory_AddRef, + m_GpgmeFactory_Release, + m_GpgmeFactory_CreateInstance, + m_GpgmeFactory_LockServer +}; +static IClassFactoryImpl igpgme_CF = {&igpgme_factory_vtbl, 1 }; + +void +igpgme_register_exit_event (HANDLE ev) +{ + my_exit_event = ev; +} + + +IClassFactory * +igpgme_factory_new ( CLSID *r_clsid ) +{ + *r_clsid = CLSID_Gpgme; + IClassFactory_AddRef((IClassFactory*)&igpgme_CF); + return (IClassFactory*)&igpgme_CF; +} + +void +igpgme_factory_release ( IClassFactory *factory ) +{ + /* it's static - nothing to do */ +} diff --git a/tags/gpgme-0-4-3/complus/igpgme.h b/tags/gpgme-0-4-3/complus/igpgme.h new file mode 100644 index 0000000..fa96762 --- /dev/null +++ b/tags/gpgme-0-4-3/complus/igpgme.h @@ -0,0 +1,163 @@ +/* igpgme.h - COM+ class IGpgme + * Copyright (C) 2001 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 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA + */ + +#ifndef IGPGME_H +#define IGPGME_H 1 + +#include + +DEFINE_GUID(CLSID_Gpgme, 0x3811fd40, 0x7f72, 0x11d5, + 0x8c, 0x9e, 0x00, 0x80, 0xad, 0x19, 0x0c, 0xd5); +#if 0 +DEFINE_GUID(CLSID_GpgmeData, 0x3811fd41, 0x7f72, 0x11d5, + 0x8c, 0x9e, 0x00, 0x80, 0xad, 0x19, 0x0c, 0xd5); +DEFINE_GUID(CLSID_GpgmeKey, 0x3811fd42, 0x7f72, 0x11d5, + 0x8c, 0x9e, 0x00, 0x80, 0xad, 0x19, 0x0c, 0xd5); +DEFINE_GUID(CLSID_GpgmeRSet, 0x3811fd43, 0x7f72, 0x11d5, + 0x8c, 0x9e, 0x00, 0x80, 0xad, 0x19, 0x0c, 0xd5); +#endif + +DEFINE_GUID(TLBID_Gpgcom, 0x3811fd48, 0x7f72, 0x11d5, + 0x8c, 0x9e, 0x00, 0x80, 0xad, 0x19, 0x0c, 0xd5); +DEFINE_GUID(APPID_Gpgcom, 0x3811fd4f, 0x7f72, 0x11d5, + 0x8c, 0x9e, 0x00, 0x80, 0xad, 0x19, 0x0c, 0xd5); + + +DEFINE_GUID(IID_IGpgme, 0x3811fd50, 0x7f72, 0x11d5, + 0x8c, 0x9e, 0x00, 0x80, 0xad, 0x19, 0x0c, 0xd5); + +typedef struct IGpgme IGpgme; + +void igpgme_register_exit_event (HANDLE ev); +IClassFactory *igpgme_factory_new( CLSID *r_clsid ); +void igpgme_factory_release ( IClassFactory *factory ); + + +/******************************************** + ***** The IGpgme interface ***************** + ********************************************/ + +#define ICOM_INTERFACE IGpgme + +#define IGpgme_METHODS \ + ICOM_METHOD1(HRESULT,GetVersion, BSTR*,) \ + ICOM_METHOD1(HRESULT,GetEngineInfo, BSTR*,) \ + ICOM_METHOD(HRESULT,Cancel) \ + ICOM_METHOD1(HRESULT,SetArmor,BOOL,) \ + ICOM_METHOD1(HRESULT,GetArmor,BOOL*,) \ + ICOM_METHOD1(HRESULT,SetTextmode,BOOL,) \ + ICOM_METHOD1(HRESULT,GetTextmode,BOOL*,) \ + ICOM_METHOD1(HRESULT,SetPlaintext,VARIANT,) \ + ICOM_METHOD1(HRESULT,GetPlaintext,VARIANT*,) \ + ICOM_METHOD1(HRESULT,SetCiphertext,VARIANT,) \ + ICOM_METHOD1(HRESULT,GetCiphertext,VARIANT*,) \ + ICOM_METHOD(HRESULT,ClearRecipients) \ + ICOM_METHOD2(HRESULT,AddRecipient,BSTR,,signed short int,) \ + ICOM_METHOD(HRESULT,ResetSignKeys) \ + ICOM_METHOD1(HRESULT,AddSignKey,BSTR,) \ + ICOM_METHOD(HRESULT,Encrypt) \ + ICOM_METHOD1(HRESULT,Sign,signed short int,) \ + ICOM_METHOD1(HRESULT,SignEncrypt,signed short int,) + +#if 0 + ICOM_METHOD1(HRESULT,SetKeylistMode,) + ICOM_METHOD1(HRESULT,SetPassphraseCB,) + ICOM_METHOD1(HRESULT,SetProgressCB,) + ICOM_METHOD1(HRESULT,SignersClear,) + ICOM_METHOD1(HRESULT,SignersAdd,) + ICOM_METHOD1(HRESULT,SignersEnum,) + ICOM_METHOD1(HRESULT,GetSigStatus,) + ICOM_METHOD1(HRESULT,GetNotation,) +#endif + +#define IGpgme_IMETHODS \ + IDispatch_IMETHODS \ + IGpgme_METHODS + +ICOM_DEFINE(IGpgme,IDispatch) +#undef ICOM_INTERFACE + + +/*** IUnknown methods ***/ +#define IGpgme_QueryInterface(p,a,b) ICOM_CALL2(QueryInterface,p,a,b) +#define IGpgme_AddRef(p) ICOM_CALL (AddRef,p) +#define IGpgme_Release(p) ICOM_CALL (Release,p) +/*** IGpgme methods ***/ +#define IGpgme_GetVersion(p,r) ICOM_CALL1(GetVersion,p,r) +#define IGpgme_GetEngineInfo(p,r) ICOM_CALL1(GetEngineInfo,p,r) +#define IGpgme_Cancel(p,a) ICOM_CALL1(Cancel,p,a) +#define IGpgme_SetArmor(p,a) ICOM_CALL1(SetArmor,p,a) +#define IGpgme_GetArmor(p,a) ICOM_CALL1(GetArmor,p,a) +#define IGpgme_SetTextmode(p,a) ICOM_CALL1(SetTextmode,p,a) +#define IGpgme_GetTextmode(p,a) ICOM_CALL1(GetTextmode,p,a) +#define IGpgme_SetPlaintext(p,a) ICOM_CALL1(SetPlaintext,p,a) +#define IGpgme_GetPlaintext(p,a) ICOM_CALL1(GetPlaintext,p,a) +#define IGpgme_SetCiphertext(p,a) ICOM_CALL1(SetCiphertext,p,a) +#define IGpgme_GetCiphertext(p,a) ICOM_CALL1(GetCiphertext,p,a) +#define IGpgme_ClearRecipients(p) ICOM_CALL (ClearRecipients,p) +#define IGpgme_AddRecipient(p,a,b) ICOM_CALL2(AddRecipient,p,a,b) +#define IGpgme_ResetSignKeys(p) ICOM_CALL (ResetSignKeys,p) +#define IGpgme_AddSignKey(p,a) ICOM_CALL (AddSignKey,p,a) +#define IGpgme_Encrypt(p) ICOM_CALL (Encrypt,p) +#define IGpgme_Sign(p,a) ICOM_CALL (Sign,p,a) +#define IGpgme_SignEncrypt(p,a) ICOM_CALL (SignEncrypt,p,a) +#if 0 +#define IGpgme_SetKeylistMode(p,a) ICOM_CALL1(SetKeylistMode,p,a) +#define IGpgme_SetPassphraseCB(p,a) ICOM_CALL1(SetPassphraseCB,p,a) +#define IGpgme_SetProgressCB(p,a) ICOM_CALL1(SetProgressCB,p,a) +#define IGpgme_SignersClear(p,a) ICOM_CALL1(SignersClear,p,a) +#define IGpgme_SignersAdd(p,a) ICOM_CALL1(SignersAdd,p,a) +#define IGpgme_SignersEnum(p,a) ICOM_CALL1(SignersEnum,p,a) +#define IGpgme_GetSigStatus(p,a) ICOM_CALL1(GetSigStatus,p,a) +#define IGpgme_GetSigKey(p,a) ICOM_CALL1(GetSigKey,p,a) +#define IGpgme_GetNotation(p,a) ICOM_CALL1(GetNotation,p,a) +#endif + + +#if 0 +/******************************************** + ***** The IGpgmeKey interface ************** + ********************************************/ + +#define ICOM_INTERFACE IGpgmeKey + +#define IGpgmeKey_METHODS \ + ICOM_METHOD1(HRESULT,GetVersion, BSTR,) \ + ICOM_METHOD1(HRESULT,GetEngineInfo, BSTR,) + + +#define IGpgmeKey_IMETHODS \ + IUnknown_IMETHODS \ + IGpgmeKey_METHODS + +ICOM_DEFINE(IGpgmeKey,IUnknown) +#undef ICOM_INTERFACE + +/*** IUnknown methods ***/ +#define IGpgmeKey_QueryInterface(p,a,b) ICOM_CALL2(QueryInterface,p,a,b) +#define IGpgmeKey_AddRef(p) ICOM_CALL (AddRef,p) +#define IGpgmeKey_Release(p) ICOM_CALL (Release,p) +/*** IGpgmeKey methods ***/ +#define IGpgmeKey_GetVersion(p,r) ICOM_CALL1(GetVersion,p,r) +#define IGpgmeKey_GetEngineInfo(p,r) ICOM_CALL1(GetEngineInfo,p,r) +#endif + +#endif /*IGPGME_H*/ + diff --git a/tags/gpgme-0-4-3/complus/main.h b/tags/gpgme-0-4-3/complus/main.h new file mode 100644 index 0000000..7e48ad4 --- /dev/null +++ b/tags/gpgme-0-4-3/complus/main.h @@ -0,0 +1,49 @@ +/* main.h - GPGME COM+ component + * Copyright (C) 2000 Werner Koch (dd9jn) + * + * 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 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA + */ + +#ifndef COMPLUS_MAIN_H +#define COMPLUS_MAIN_H + +#include "xmalloc.h" +#include "stringhelp.h" +#include "logging.h" + + +#define _(a) (a) +#define N_(a) (a) + + +struct { + int verbose; + int quiet; + unsigned int debug; + char *homedir; +} opt; + + + +#endif /* COMPLUS_MAIN_H */ + + + + + + + diff --git a/tags/gpgme-0-4-3/complus/regtlb.c b/tags/gpgme-0-4-3/complus/regtlb.c new file mode 100644 index 0000000..4ea1342 --- /dev/null +++ b/tags/gpgme-0-4-3/complus/regtlb.c @@ -0,0 +1,70 @@ +/* regtlb.c - Register a type library + * Copyright (C) 2001 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 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA + */ + + +#include +#include +#include +#include +#include +#include +#include +#include + +#include "xmalloc.h" +#include "oleauto.h" + +int +main (int argc, char **argv) +{ + ITypeLib *pTypeLib; + wchar_t *fname; + HRESULT hr; + size_t n; + + if ( argc != 2 ) { + fprintf (stderr,"usage: regtlb foo.tlb\n"); + return 1; + } + + n = mbstowcs (NULL, argv[1], strlen(argv[1])+1); + fprintf (stderr, "need %d bytes\n", (int)n); + fname = xmalloc ((n+1)*sizeof *fname); + mbstowcs (fname, argv[1], strlen (argv[1])+1); + + hr = CoInitializeEx (NULL, COINIT_MULTITHREADED); + if (hr) + fprintf (stderr, "CoInitializeEx() failed: hr=%lu\n", hr); + + hr = LoadTypeLibEx (fname, REGKIND_REGISTER, &pTypeLib); + if (hr) + fprintf (stderr, "LoadTypeLibEx() failed: hr=%lx\n", hr); + + ITypeLib_Release (pTypeLib); + + CoUninitialize (); + return 0; +} + + + + + + diff --git a/tags/gpgme-0-4-3/complus/tgpgcom.c b/tags/gpgme-0-4-3/complus/tgpgcom.c new file mode 100644 index 0000000..27516b1 --- /dev/null +++ b/tags/gpgme-0-4-3/complus/tgpgcom.c @@ -0,0 +1,157 @@ +/* tgpgcom.c - Test the IGpgme classes + * Copyright (C) 2001 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 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA + */ + + +#include +#include +#include +#include +#include +#include +#include +#include + +#define INITGUID +#include "igpgme.h" + + +int +main (int argc, char **argv) +{ + IUnknown *pUnknown = NULL; + IGpgme *pGpgme; + HRESULT hr; + BSTR bs; + + hr = CoInitializeEx (NULL, COINIT_APARTMENTTHREADED); + if (hr) + fprintf (stderr, "CoInitializeEx() failed: hr=%lu\n", hr); + + fprintf (stderr, "system initialized\n"); + hr = CoCreateInstance (&CLSID_Gpgme, NULL, CLSCTX_LOCAL_SERVER, + &IID_IUnknown, (void**)&pUnknown ); + if (hr) + fprintf (stderr, "CoCreateInstance() failed: hr=%lx\n", hr); + if (!pUnknown) + exit (1); + + fprintf (stderr,"got object %p - querying %s\n", + pUnknown, debugstr_guid(&IID_IGpgme)); + hr = IGpgme_QueryInterface (pUnknown, &IID_IGpgme, (void**)&pGpgme); + if (hr) { + fprintf (stderr, "QueryInterface() failed: hr=%lx\n", hr); + goto leave; + } + fprintf (stderr, "got interface %p\n", pGpgme); + + hr = IGpgme_SetArmor (pGpgme, 1); + fprintf (stderr, "SetArmor returned %lx\n", hr); + + hr = IGpgme_SetTextmode (pGpgme, 0); + fprintf (stderr, "SetTextmode returned %lx\n", hr); + + hr = IGpgme_ClearRecipients (pGpgme); + fprintf (stderr, "ClearRecipients returned %lx\n", hr); + + bs = SysAllocString (L"alice"); + if (!bs) + fprintf (stderr, "SysAllocString failed: ec=%d\n", (int)GetLastError()); + else { + int i; + + for (i=-4; i < 12; i++ ) + fprintf (stderr," %02X", ((unsigned char*)bs)[i] ); + putc ('\n', stderr); + } + hr = IGpgme_AddRecipient (pGpgme, bs, -1); + fprintf (stderr, "AddRecipients returned %lx\n", hr); + + { + SAFEARRAY *sa; + VARIANT v; + char *p; + + sa = SafeArrayCreateVector (VT_UI1, 0, 20); + if (!sa) { + fprintf (stderr, "SafeArrayCreateVector failed\n"); + goto leave; + } + + hr = SafeArrayAccessData (sa, (void**)&p); + if (hr) { + fprintf (stderr,"SafeArrayAccessData failed: hr=%lx\n", hr); + goto leave; + } + + memcpy (p, "=> Omnis enim res <=", 20 ); + SafeArrayUnaccessData (sa); + + VariantInit (&v); + v.vt = (VT_ARRAY|VT_UI1); + v.u.parray = sa; + + hr = IGpgme_SetPlaintext (pGpgme, v ); + fprintf (stderr, "SetPlaintext returned %lx\n", hr); + SafeArrayDestroyData (sa); + SafeArrayDestroy (sa); + + VariantClear (&v); + } + + hr = IGpgme_Encrypt (pGpgme); + fprintf (stderr, "Encrypt returned %lx\n", hr); + + { + VARIANT v; + + hr = IGpgme_GetCiphertext (pGpgme, &v); + fprintf (stderr, "GetCiphertext returned %lx\n", hr); + if (!hr) { + if (v.vt != (VT_ARRAY|VT_UI1)) + fprintf (stderr, "Invalid array typed returned\n"); + else { + unsigned char *p; + + hr = SafeArrayAccessData (v.u.parray, (void**)&p); + if (hr) + fprintf (stderr,"*** SafeArrayAccessData failed: %lx\n", hr); + else { + size_t arraysize = v.u.parray->rgsabound[0].cElements; + fprintf (stderr,"*** got %d bytes\n", (int)arraysize); + for (;arraysize; arraysize--, p++ ) + putc (*p, stderr); + SafeArrayUnaccessData (v.u.parray); + } + } + } + } + IGpgme_Release (pGpgme); + + leave: + CoUninitialize (); + fprintf (stderr, "system uninitialized\n"); + return 0; +} + + + + + + diff --git a/tags/gpgme-0-4-3/complus/utf8.c b/tags/gpgme-0-4-3/complus/utf8.c new file mode 100644 index 0000000..0237a62 --- /dev/null +++ b/tags/gpgme-0-4-3/complus/utf8.c @@ -0,0 +1,236 @@ +/* + * UTF-8 support routines + * + * Copyright 2000 Alexandre Julliard + * + * Taken from WINE, so the usual WINE copyright applies: +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER +IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN +CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ + +#include +#include +#include +#include + +#include + +/* number of following bytes in sequence based on first byte value (for bytes above 0x7f) */ +static const char utf8_length[128] = +{ + 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, /* 0x80-0x8f */ + 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, /* 0x90-0x9f */ + 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, /* 0xa0-0xaf */ + 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, /* 0xb0-0xbf */ + 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1, /* 0xc0-0xcf */ + 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1, /* 0xd0-0xdf */ + 2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2, /* 0xe0-0xef */ + 3,3,3,3,3,3,3,3,4,4,4,4,5,5,0,0 /* 0xf0-0xff */ +}; + +/* first byte mask depending on UTF-8 sequence length */ +static const unsigned char utf8_mask[6] = { 0x7f, 0x1f, 0x0f, 0x07, 0x03, 0x01 }; + +/* minimum Unicode value depending on UTF-8 sequence length */ +static const unsigned int utf8_minval[6] = { 0x0, 0x80, 0x800, 0x10000, 0x200000, 0x4000000 }; + + +/* query necessary dst length for src string */ +inline static int get_length_wcs_utf8( const WCHAR *src, unsigned int srclen ) +{ + int len; + + for (len = 0; srclen; srclen--, src++, len++) + { + if (*src >= 0x80) + { + len++; + if (*src >= 0x800) len++; + } + } + return len; +} + +/* wide char to UTF-8 string conversion */ +/* return -1 on dst buffer overflow */ +int utf8_wcstombs( const WCHAR *src, int srclen, char *dst, int dstlen ) +{ + char *orig_dst = dst; + + if (!dstlen) return get_length_wcs_utf8( src, srclen ); + + for (; srclen; srclen--, src++) + { + WCHAR ch = *src; + + if (ch < 0x80) /* 0x00-0x7f: 1 byte */ + { + if (!dstlen--) return -1; /* overflow */ + *dst++ = ch; + continue; + } + + if (ch < 0x800) /* 0x80-0x7ff: 2 bytes */ + { + if ((dstlen -= 2) < 0) return -1; /* overflow */ + dst[1] = 0x80 | (ch & 0x3f); + ch >>= 6; + dst[0] = 0xc0 | ch; + dst += 2; + continue; + } + + /* 0x800-0xffff: 3 bytes */ + + if ((dstlen -= 3) < 0) return -1; /* overflow */ + dst[2] = 0x80 | (ch & 0x3f); + ch >>= 6; + dst[1] = 0x80 | (ch & 0x3f); + ch >>= 6; + dst[0] = 0xe0 | ch; + dst += 3; + } + return dst - orig_dst; +} + +/* query necessary dst length for src string */ +inline static int get_length_mbs_utf8( const unsigned char *src, int srclen ) +{ + int ret; + const unsigned char *srcend = src + srclen; + + for (ret = 0; src < srcend; ret++) + { + unsigned char ch = *src++; + if (ch < 0xc0) continue; + + switch(utf8_length[ch-0x80]) + { + case 5: + if (src >= srcend) return ret; /* ignore partial char */ + if ((ch = *src ^ 0x80) >= 0x40) continue; + src++; + case 4: + if (src >= srcend) return ret; /* ignore partial char */ + if ((ch = *src ^ 0x80) >= 0x40) continue; + src++; + case 3: + if (src >= srcend) return ret; /* ignore partial char */ + if ((ch = *src ^ 0x80) >= 0x40) continue; + src++; + case 2: + if (src >= srcend) return ret; /* ignore partial char */ + if ((ch = *src ^ 0x80) >= 0x40) continue; + src++; + case 1: + if (src >= srcend) return ret; /* ignore partial char */ + if ((ch = *src ^ 0x80) >= 0x40) continue; + src++; + } + } + return ret; +} + +/* UTF-8 to wide char string conversion */ +/* return -1 on dst buffer overflow, -2 on invalid input char */ +int utf8_mbstowcs( int flags, const char *src, int srclen, WCHAR *dst, int dstlen ) +{ + int len, count; + unsigned int res; + const char *srcend = src + srclen; + + if (!dstlen) return get_length_mbs_utf8( src, srclen ); + + for (count = dstlen; count && (src < srcend); count--, dst++) + { + unsigned char ch = *src++; + if (ch < 0x80) /* special fast case for 7-bit ASCII */ + { + *dst = ch; + continue; + } + len = utf8_length[ch-0x80]; + res = ch & utf8_mask[len]; + + switch(len) + { + case 5: + if (src >= srcend) goto done; /* ignore partial char */ + if ((ch = *src ^ 0x80) >= 0x40) goto bad; + res = (res << 6) | ch; + src++; + case 4: + if (src >= srcend) goto done; /* ignore partial char */ + if ((ch = *src ^ 0x80) >= 0x40) goto bad; + res = (res << 6) | ch; + src++; + case 3: + if (src >= srcend) goto done; /* ignore partial char */ + if ((ch = *src ^ 0x80) >= 0x40) goto bad; + res = (res << 6) | ch; + src++; + case 2: + if (src >= srcend) goto done; /* ignore partial char */ + if ((ch = *src ^ 0x80) >= 0x40) goto bad; + res = (res << 6) | ch; + src++; + case 1: + if (src >= srcend) goto done; /* ignore partial char */ + if ((ch = *src ^ 0x80) >= 0x40) goto bad; + res = (res << 6) | ch; + src++; + if (res < utf8_minval[len]) goto bad; + if (res >= 0x10000) goto bad; /* FIXME: maybe we should do surrogates here */ + *dst = res; + continue; + } + bad: + if (flags & MB_ERR_INVALID_CHARS) return -2; /* bad char */ + *dst = (WCHAR)'?'; + } + if (src < srcend) return -1; /* overflow */ +done: + return dstlen - count; +} + + +int +bstrtoutf8 ( BSTR src, char *dst, size_t dstlen ) +{ + size_t srclen, needed; + int n; + + srclen = src? SysStringLen (src): 0; + + needed = srclen? (utf8_wcstombs (src, srclen, NULL, 0) + 1) : 1; + if (!dst || !dstlen) + return needed; + if (dstlen < needed) + return -1; + if (srclen) { + n = utf8_wcstombs (src, srclen, dst, dstlen); + if (n < 0) + return -1; + } + else + n = 0; + dst[n] = 0; + return n; +} + + + diff --git a/tags/gpgme-0-4-3/complus/vbtest.html b/tags/gpgme-0-4-3/complus/vbtest.html new file mode 100644 index 0000000..03df463 --- /dev/null +++ b/tags/gpgme-0-4-3/complus/vbtest.html @@ -0,0 +1,47 @@ + +g10 code - GPGCOM test + + + + + + + +

Silly Gpgcom test page

+ +
+ +

+Encrypt for + +

+ +

+ +

+ + + + + + diff --git a/tags/gpgme-0-4-3/complus/vbtest.vbs b/tags/gpgme-0-4-3/complus/vbtest.vbs new file mode 100644 index 0000000..8246b45 --- /dev/null +++ b/tags/gpgme-0-4-3/complus/vbtest.vbs @@ -0,0 +1,39 @@ +' Demo script to generate a RFC2015 compliant message using Gpgcom +Dim gpg, body, crlf + +crlf = chr(10) & chr(13) + +' Create out Gpgcom object +set gpg = CreateObject("Gpgcom.Gpgme") +' We must use the ASCII armor and switch to textmode +gpg.armor = true +gpg.textmode = true + +' Set the secret message +gpg.plaintext = "This is the secret message." 'or: InputBox('Enter message:") + +' Set the Recipient. You may also use a keyID or an fingerprint +gpg.AddRecipient "alice" + +' And encrypt the stuff +gpg.encrypt + +' Build the MIME message +body = "Content-Type: multipart/encrypted; boundary=" +body = body & Chr(34) & "=-=-=-=" & Chr(34) & crlf & " protocol=" & Chr(34) +body = body & "application/pgp-encrypted" & Chr(34) & crlf & crlf +body = body & "--=-=-=-=" & crlf +body = body & "Content-Type: application/pgp-encrypted" & crlf & crlf +body = body & "Version: 1" & crlf & crlf +body = body & "--=-=-=-=" & crlf +body = body & "Content-Type: application/octet-stream" & crlf & crlf +body = body & gpg.ciphertext +body = body & "--=-=-=-=--" & crlf + +' And display it +Print body + +' output function for the windows scripting host +sub Print(x) + WScript.Echo x +end sub diff --git a/tags/gpgme-0-4-3/configure.ac b/tags/gpgme-0-4-3/configure.ac new file mode 100644 index 0000000..1723afb --- /dev/null +++ b/tags/gpgme-0-4-3/configure.ac @@ -0,0 +1,296 @@ +# configure.in for GPGME +# Copyright (C) 2000 Werner Koch (dd9jn) +# Copyright (C) 2001, 2002, 2003 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 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA + +# (Process this file with autoconf to produce a configure script.) + +# Version number: Remember to change it immediately *after* a release. +AC_INIT(gpgme, 0.4.3, [bug-gpgme@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=12 +LIBGPGME_LT_AGE=1 +LIBGPGME_LT_REVISION=0 +NEED_GPG_VERSION=1.2.2 +NEED_GPGSM_VERSION=0.9.0 +############################################## +AC_PREREQ(2.52) +AC_REVISION($Revision$) + +PACKAGE=$PACKAGE_NAME +VERSION=$PACKAGE_VERSION + +AC_CONFIG_SRCDIR(gpgme/gpgme.h) +AM_CONFIG_HEADER(config.h) +AM_INIT_AUTOMAKE($PACKAGE, $VERSION) +AM_MAINTAINER_MODE +AC_CANONICAL_HOST + +AH_VERBATIM([_GNU_SOURCE], +[/* Enable GNU extensions on systems that have them. */ +#ifndef _GNU_SOURCE +# define _GNU_SOURCE +#endif]) + +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_SUBST(LIBGPGME_LT_CURRENT) +AC_SUBST(LIBGPGME_LT_AGE) +AC_SUBST(LIBGPGME_LT_REVISION) +AC_DEFINE_UNQUOTED(NEED_GPG_VERSION, "$NEED_GPG_VERSION", + [Min. needed GnuPG version.]) +AC_DEFINE_UNQUOTED(NEED_GPGSM_VERSION, "$NEED_GPGSM_VERSION", + [Min. needed GPGSM version.]) + +AC_SUBST(PACKAGE) +AC_SUBST(VERSION) +AC_DEFINE_UNQUOTED(PACKAGE, "$PACKAGE", [Name of this package]) +AC_DEFINE_UNQUOTED(VERSION, "$VERSION", [Version of this package]) + +# Don't default to build static libs. +AC_DISABLE_STATIC +AC_PROG_LIBTOOL + +# 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 + ;; +esac +AM_CONDITIONAL(HAVE_LD_VERSION_SCRIPT, test "$have_ld_version_script" = "yes") + +GPG_DEFAULT=no +GPGSM_DEFAULT=no +component_system=None +case "${host}" in + *-*-mingw32* | i?86-emx-os2 | i?86-*-os2*emx | i?86-*-msdosdjgpp* ) + # special stuff for Windoze NT + # OS/2 with the EMX environment + # DOS with the DJGPP environment + AC_DEFINE(HAVE_DRIVE_LETTERS, , + [Defined if we run on some of the PCDOS like systems (DOS, + Windoze, OS/2) with special properties like no file modes.]) + AC_DEFINE(HAVE_DOSISH_SYSTEM, , + [Defined if the filesystem uses driver letters.]) + have_dosish_system=yes + GPG_DEFAULT='c:\\gnupg\\gpg.exe' + # XXX Assuan is not supported in this configuration. + #GPGSM_DEFAULT='c:\\gnupg\\gpgsm.exe' + #component_system='COM+' + ;; + *) + AC_CHECK_PTH(1.2.0,,,no,have_pth=yes) + if test "$have_pth" = yes; then + AC_DEFINE(HAVE_PTH, ,[Define if we have Pth.]) + CFLAGS="$CFLAGS $PTH_CFLAGS" + fi + AC_CHECK_LIB(pthread,pthread_create,have_pthread=yes) + if test "$have_pthread" = yes; then + AC_DEFINE(HAVE_PTHREAD, ,[Define if we have pthread.]) + fi + + # XXX: Probably use exec-prefix here? +# GPG_DEFAULT='/usr/bin/gpg' +# GPGSM_DEFAULT='/usr/bin/gpgsm' + ;; +esac +AM_CONDITIONAL(HAVE_DOSISH_SYSTEM, test "$have_dosish_system" = "yes") +AM_CONDITIONAL(HAVE_PTH, test "$have_pth" = "yes") +AM_CONDITIONAL(HAVE_PTHREAD, test "$have_pthread" = "yes") + + +# Checks for header files. +AC_CHECK_HEADERS(sys/select.h) + + +# Type checks. +AC_CHECK_SIZEOF(unsigned int) + + +# Checks for compiler features. +if test "$GCC" = yes; then + CFLAGS="$CFLAGS -Wall -Wcast-align -Wshadow -Wstrict-prototypes" +fi + + +# Checks for library functions. +AC_REPLACE_FUNCS(stpcpy) + +AC_REPLACE_FUNCS(vasprintf) +if test "$ac_cv_func_vasprintf" != yes; then + GNUPG_CHECK_VA_COPY +fi + +# Try to find a thread-safe version of getenv(). +have_thread_safe_getenv=no +jm_GLIBC21 +if test $GLIBC21 = 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 + +# Checking for libgpg-error. +AM_PATH_GPG_ERROR(0.5,, AC_MSG_ERROR([libgpg-error was not found])) +AC_DEFINE(GPG_ERR_SOURCE_DEFAULT, GPG_ERR_SOURCE_GPGME, + [The default error source for GPGME.]) + + + +# Checks for system services +NO_OVERRIDE=no +AC_ARG_WITH(gpg, + AC_HELP_STRING([--with-gpg=PATH], [use GnuPG binary at PATH]), + GPG=$withval, NO_OVERRIDE=yes) +if test "$NO_OVERRIDE" = "yes" || test "$GPG" = "yes"; then + GPG= + NO_OVERRIDE=yes + if test "$cross_compiling" != "yes"; then + AC_PATH_PROG(GPG, gpg) + fi + if test -z "$GPG"; then + GPG="$GPG_DEFAULT" + fi +fi +if test "$GPG" = no; then + if test "$NO_OVERRIDE" = "yes"; then + if test "$cross_compiling" != "yes"; then + AC_MSG_WARN([Could not find GnuPG, install GnuPG or use --with-gpg=PATH to enable it]) + else + AC_MSG_ERROR([Can not determine path to GnuPG when cross-compiling, use --with-gpg=PATH]) + fi + fi +else + AC_DEFINE_UNQUOTED(GPG_PATH, "$GPG", [Path to the GnuPG binary.]) + AC_SUBST(GPG) +fi +AM_CONDITIONAL(RUN_GPG_TESTS, + [test "$cross_compiling" != "yes" && test -n "$GPG" && test -r "$GPG"]) +AC_SUBST(GPG_PATH) + +NO_OVERRIDE=no +AC_ARG_WITH(gpgsm, + AC_HELP_STRING([--with-gpgsm=PATH], [use GpgSM binary at PATH]), + GPGSM=$withval, NO_OVERRIDE=yes) +if test "$NO_OVERRIDE" = "yes" || test "$GPGSM" = "yes"; then + GPGSM= + NO_OVERRIDE=yes + if test "$cross_compiling" != "yes"; then + AC_PATH_PROG(GPGSM, gpgsm) + fi + if test -z "$GPGSM"; then + GPGSM="$GPGSM_DEFAULT" + fi +fi +if test "$GPGSM" = no; then + if test "$NO_OVERRIDE" = "yes"; then + if test "$cross_compiling" != "yes"; then + AC_MSG_WARN([Could not find GpgSM, install GpgSM or use --with-gpgsm=PATH to enable it]) + else + AC_MSG_ERROR([Can not determine path to GpgSM when cross-compiling, use --with-gpgsm=PATH]) + fi + fi +else + AC_DEFINE_UNQUOTED(GPGSM_PATH, "$GPGSM", [Path to the GPGSM binary.]) + AC_SUBST(GPGSM) +fi +AM_CONDITIONAL(HAVE_GPGSM, [test -n "$GPGSM" && test -r "$GPGSM"]) +AM_CONDITIONAL(RUN_GPGSM_TESTS, + [test "$cross_compiling" != "yes" && test -n "$GPGSM" && test -r "$GPGSM"]) + +# FIXME: Only build if supported. +AM_CONDITIONAL(BUILD_ASSUAN, test "$GPGSM" != "no") + +if test "$GPGSM" != "no"; then + AC_CHECK_FUNCS(funopen) + if test $ac_cv_func_funopen != yes; then + # No funopen but we can implement that in terms of fopencookie. + AC_CHECK_FUNCS(fopencookie, AC_LIBOBJ(funopen), + AC_MSG_ERROR([[ +No implementation of fopencookie or funopen available. +]])) + fi + + AC_REPLACE_FUNCS(isascii) + AC_REPLACE_FUNCS(putc_unlocked) + AC_REPLACE_FUNCS(memrchr) +fi + + +AM_CONDITIONAL(BUILD_COMPLUS, test "$component_system" = "COM+") + +# Make the version number in gpgme/gpgme.h the same as the one here. +# (this is easier than to have a *.in file just for one substitution) +GNUPG_FIX_HDR_VERSION(gpgme/gpgme.h, GPGME_VERSION) + +# Substitution used for gpgme-config +GPGME_CONFIG_LIBS="-lgpgme" +GPGME_CONFIG_CFLAGS="" +AC_SUBST(GPGME_CONFIG_LIBS) +AC_SUBST(GPGME_CONFIG_CFLAGS) + +# Frob'da Variables +LTLIBOBJS=`echo "$LIB@&t@OBJS" | + sed 's,\.[[^.]]* ,.lo ,g;s,\.[[^.]]*$,.lo,'` +AC_SUBST(LTLIBOBJS) + +# +# Create config files + +AC_CONFIG_FILES(Makefile assuan/Makefile gpgme/Makefile + tests/Makefile tests/gpg/Makefile tests/gpgsm/Makefile + doc/Makefile complus/Makefile) +AC_CONFIG_FILES(gpgme/gpgme-config, chmod +x gpgme/gpgme-config) +AC_OUTPUT + +echo " + GPGME v${VERSION} has been configured as follows: + + GnuPG version: min. $NEED_GPG_VERSION + GnuPG path: $GPG + + GpgSM version: min. $NEED_GPGSM_VERSION + GpgSM path: $GPGSM +" diff --git a/tags/gpgme-0-4-3/doc/ChangeLog b/tags/gpgme-0-4-3/doc/ChangeLog new file mode 100644 index 0000000..0064e2d --- /dev/null +++ b/tags/gpgme-0-4-3/doc/ChangeLog @@ -0,0 +1,556 @@ +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. + +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 + 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. + (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. + +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 2002 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/tags/gpgme-0-4-3/doc/Makefile.am b/tags/gpgme-0-4-3/doc/Makefile.am new file mode 100644 index 0000000..6971550 --- /dev/null +++ b/tags/gpgme-0-4-3/doc/Makefile.am @@ -0,0 +1,25 @@ +# doc - Automake template +# Copyright (C) 2001 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 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA + +## Process this file with automake to produce Makefile.in + +DISTCLEANFILES = gpgme.tmp + +info_TEXINFOS = gpgme.texi +gpgme_TEXINFOS = gpl.texi fdl.texi diff --git a/tags/gpgme-0-4-3/doc/fdl.texi b/tags/gpgme-0-4-3/doc/fdl.texi new file mode 100644 index 0000000..50028ab --- /dev/null +++ b/tags/gpgme-0-4-3/doc/fdl.texi @@ -0,0 +1,402 @@ +@node Free Documentation License +@appendix GNU Free Documentation License + +@cindex FDL, GNU Free Documentation License +@center Version 1.1, March 2000 + +@display +Copyright @copyright{} 2000 Free Software Foundation, Inc. +59 Temple Place, Suite 330, Boston, MA 02111-1307, USA + +Everyone is permitted to copy and distribute verbatim copies +of this license document, but changing it is not allowed. +@end display + +@enumerate 0 +@item +PREAMBLE + +The purpose of this License is to make a manual, textbook, or other +written document @dfn{free} in the sense of freedom: to assure everyone +the effective freedom to copy and redistribute it, with or without +modifying it, either commercially or noncommercially. Secondarily, +this License preserves for the author and publisher a way to get +credit for their work, while not being considered responsible for +modifications made by others. + +This License is a kind of ``copyleft'', which means that derivative +works of the document must themselves be free in the same sense. It +complements the GNU General Public License, which is a copyleft +license designed for free software. + +We have designed this License in order to use it for manuals for free +software, because free software needs free documentation: a free +program should come with manuals providing the same freedoms that the +software does. But this License is not limited to software manuals; +it can be used for any textual work, regardless of subject matter or +whether it is published as a printed book. We recommend this License +principally for works whose purpose is instruction or reference. + +@item +APPLICABILITY AND DEFINITIONS + +This License applies to any manual or other work that contains a +notice placed by the copyright holder saying it can be distributed +under the terms of this License. The ``Document'', below, refers to any +such manual or work. Any member of the public is a licensee, and is +addressed as ``you''. + +A ``Modified Version'' of the Document means any work containing the +Document or a portion of it, either copied verbatim, or with +modifications and/or translated into another language. + +A ``Secondary Section'' is a named appendix or a front-matter section of +the Document that deals exclusively with the relationship of the +publishers or authors of the Document to the Document's overall subject +(or to related matters) and contains nothing that could fall directly +within that overall subject. (For example, if the Document is in part a +textbook of mathematics, a Secondary Section may not explain any +mathematics.) The relationship could be a matter of historical +connection with the subject or with related matters, or of legal, +commercial, philosophical, ethical or political position regarding +them. + +The ``Invariant Sections'' are certain Secondary Sections whose titles +are designated, as being those of Invariant Sections, in the notice +that says that the Document is released under this License. + +The ``Cover Texts'' are certain short passages of text that are listed, +as Front-Cover Texts or Back-Cover Texts, in the notice that says that +the Document is released under this License. + +A ``Transparent'' copy of the Document means a machine-readable copy, +represented in a format whose specification is available to the +general public, whose contents can be viewed and edited directly and +straightforwardly with generic text editors or (for images composed of +pixels) generic paint programs or (for drawings) some widely available +drawing editor, and that is suitable for input to text formatters or +for automatic translation to a variety of formats suitable for input +to text formatters. A copy made in an otherwise Transparent file +format whose markup has been designed to thwart or discourage +subsequent modification by readers is not Transparent. A copy that is +not ``Transparent'' is called ``Opaque''. + +Examples of suitable formats for Transparent copies include plain +@sc{ascii} without markup, Texinfo input format, La@TeX{} input format, +@acronym{SGML} or @acronym{XML} using a publicly available +@acronym{DTD}, and standard-conforming simple @acronym{HTML} designed +for human modification. Opaque formats include PostScript, +@acronym{PDF}, proprietary formats that can be read and edited only by +proprietary word processors, @acronym{SGML} or @acronym{XML} for which +the @acronym{DTD} and/or processing tools are not generally available, +and the machine-generated @acronym{HTML} produced by some word +processors for output purposes only. + +The ``Title Page'' means, for a printed book, the title page itself, +plus such following pages as are needed to hold, legibly, the material +this License requires to appear in the title page. For works in +formats which do not have any title page as such, ``Title Page'' means +the text near the most prominent appearance of the work's title, +preceding the beginning of the body of the text. + +@item +VERBATIM COPYING + +You may copy and distribute the Document in any medium, either +commercially or noncommercially, provided that this License, the +copyright notices, and the license notice saying this License applies +to the Document are reproduced in all copies, and that you add no other +conditions whatsoever to those of this License. You may not use +technical measures to obstruct or control the reading or further +copying of the copies you make or distribute. However, you may accept +compensation in exchange for copies. If you distribute a large enough +number of copies you must also follow the conditions in section 3. + +You may also lend copies, under the same conditions stated above, and +you may publicly display copies. + +@item +COPYING IN QUANTITY + +If you publish printed copies of the Document numbering more than 100, +and the Document's license notice requires Cover Texts, you must enclose +the copies in covers that carry, clearly and legibly, all these Cover +Texts: Front-Cover Texts on the front cover, and Back-Cover Texts on +the back cover. Both covers must also clearly and legibly identify +you as the publisher of these copies. The front cover must present +the full title with all words of the title equally prominent and +visible. You may add other material on the covers in addition. +Copying with changes limited to the covers, as long as they preserve +the title of the Document and satisfy these conditions, can be treated +as verbatim copying in other respects. + +If the required texts for either cover are too voluminous to fit +legibly, you should put the first ones listed (as many as fit +reasonably) on the actual cover, and continue the rest onto adjacent +pages. + +If you publish or distribute Opaque copies of the Document numbering +more than 100, you must either include a machine-readable Transparent +copy along with each Opaque copy, or state in or with each Opaque copy +a publicly-accessible computer-network location containing a complete +Transparent copy of the Document, free of added material, which the +general network-using public has access to download anonymously at no +charge using public-standard network protocols. If you use the latter +option, you must take reasonably prudent steps, when you begin +distribution of Opaque copies in quantity, to ensure that this +Transparent copy will remain thus accessible at the stated location +until at least one year after the last time you distribute an Opaque +copy (directly or through your agents or retailers) of that edition to +the public. + +It is requested, but not required, that you contact the authors of the +Document well before redistributing any large number of copies, to give +them a chance to provide you with an updated version of the Document. + +@item +MODIFICATIONS + +You may copy and distribute a Modified Version of the Document under +the conditions of sections 2 and 3 above, provided that you release +the Modified Version under precisely this License, with the Modified +Version filling the role of the Document, thus licensing distribution +and modification of the Modified Version to whoever possesses a copy +of it. In addition, you must do these things in the Modified Version: + +@enumerate A +@item +Use in the Title Page (and on the covers, if any) a title distinct +from that of the Document, and from those of previous versions +(which should, if there were any, be listed in the History section +of the Document). You may use the same title as a previous version +if the original publisher of that version gives permission. + +@item +List on the Title Page, as authors, one or more persons or entities +responsible for authorship of the modifications in the Modified +Version, together with at least five of the principal authors of the +Document (all of its principal authors, if it has less than five). + +@item +State on the Title page the name of the publisher of the +Modified Version, as the publisher. + +@item +Preserve all the copyright notices of the Document. + +@item +Add an appropriate copyright notice for your modifications +adjacent to the other copyright notices. + +@item +Include, immediately after the copyright notices, a license notice +giving the public permission to use the Modified Version under the +terms of this License, in the form shown in the Addendum below. + +@item +Preserve in that license notice the full lists of Invariant Sections +and required Cover Texts given in the Document's license notice. + +@item +Include an unaltered copy of this License. + +@item +Preserve the section entitled ``History'', and its title, and add to +it an item stating at least the title, year, new authors, and +publisher of the Modified Version as given on the Title Page. If +there is no section entitled ``History'' in the Document, create one +stating the title, year, authors, and publisher of the Document as +given on its Title Page, then add an item describing the Modified +Version as stated in the previous sentence. + +@item +Preserve the network location, if any, given in the Document for +public access to a Transparent copy of the Document, and likewise +the network locations given in the Document for previous versions +it was based on. These may be placed in the ``History'' section. +You may omit a network location for a work that was published at +least four years before the Document itself, or if the original +publisher of the version it refers to gives permission. + +@item +In any section entitled ``Acknowledgments'' or ``Dedications'', +preserve the section's title, and preserve in the section all the +substance and tone of each of the contributor acknowledgments +and/or dedications given therein. + +@item +Preserve all the Invariant Sections of the Document, +unaltered in their text and in their titles. Section numbers +or the equivalent are not considered part of the section titles. + +@item +Delete any section entitled ``Endorsements''. Such a section +may not be included in the Modified Version. + +@item +Do not retitle any existing section as ``Endorsements'' +or to conflict in title with any Invariant Section. +@end enumerate + +If the Modified Version includes new front-matter sections or +appendices that qualify as Secondary Sections and contain no material +copied from the Document, you may at your option designate some or all +of these sections as invariant. To do this, add their titles to the +list of Invariant Sections in the Modified Version's license notice. +These titles must be distinct from any other section titles. + +You may add a section entitled ``Endorsements'', provided it contains +nothing but endorsements of your Modified Version by various +parties---for example, statements of peer review or that the text has +been approved by an organization as the authoritative definition of a +standard. + +You may add a passage of up to five words as a Front-Cover Text, and a +passage of up to 25 words as a Back-Cover Text, to the end of the list +of Cover Texts in the Modified Version. Only one passage of +Front-Cover Text and one of Back-Cover Text may be added by (or +through arrangements made by) any one entity. If the Document already +includes a cover text for the same cover, previously added by you or +by arrangement made by the same entity you are acting on behalf of, +you may not add another; but you may replace the old one, on explicit +permission from the previous publisher that added the old one. + +The author(s) and publisher(s) of the Document do not by this License +give permission to use their names for publicity for or to assert or +imply endorsement of any Modified Version. + +@item +COMBINING DOCUMENTS + +You may combine the Document with other documents released under this +License, under the terms defined in section 4 above for modified +versions, provided that you include in the combination all of the +Invariant Sections of all of the original documents, unmodified, and +list them all as Invariant Sections of your combined work in its +license notice. + +The combined work need only contain one copy of this License, and +multiple identical Invariant Sections may be replaced with a single +copy. If there are multiple Invariant Sections with the same name but +different contents, make the title of each such section unique by +adding at the end of it, in parentheses, the name of the original +author or publisher of that section if known, or else a unique number. +Make the same adjustment to the section titles in the list of +Invariant Sections in the license notice of the combined work. + +In the combination, you must combine any sections entitled ``History'' +in the various original documents, forming one section entitled +``History''; likewise combine any sections entitled ``Acknowledgments'', +and any sections entitled ``Dedications''. You must delete all sections +entitled ``Endorsements.'' + +@item +COLLECTIONS OF DOCUMENTS + +You may make a collection consisting of the Document and other documents +released under this License, and replace the individual copies of this +License in the various documents with a single copy that is included in +the collection, provided that you follow the rules of this License for +verbatim copying of each of the documents in all other respects. + +You may extract a single document from such a collection, and distribute +it individually under this License, provided you insert a copy of this +License into the extracted document, and follow this License in all +other respects regarding verbatim copying of that document. + +@item +AGGREGATION WITH INDEPENDENT WORKS + +A compilation of the Document or its derivatives with other separate +and independent documents or works, in or on a volume of a storage or +distribution medium, does not as a whole count as a Modified Version +of the Document, provided no compilation copyright is claimed for the +compilation. Such a compilation is called an ``aggregate'', and this +License does not apply to the other self-contained works thus compiled +with the Document, on account of their being thus compiled, if they +are not themselves derivative works of the Document. + +If the Cover Text requirement of section 3 is applicable to these +copies of the Document, then if the Document is less than one quarter +of the entire aggregate, the Document's Cover Texts may be placed on +covers that surround only the Document within the aggregate. +Otherwise they must appear on covers around the whole aggregate. + +@item +TRANSLATION + +Translation is considered a kind of modification, so you may +distribute translations of the Document under the terms of section 4. +Replacing Invariant Sections with translations requires special +permission from their copyright holders, but you may include +translations of some or all Invariant Sections in addition to the +original versions of these Invariant Sections. You may include a +translation of this License provided that you also include the +original English version of this License. In case of a disagreement +between the translation and the original English version of this +License, the original English version will prevail. + +@item +TERMINATION + +You may not copy, modify, sublicense, or distribute the Document except +as expressly provided for under this License. Any other attempt to +copy, modify, sublicense or distribute the Document is void, and will +automatically terminate your rights under this License. However, +parties who have received copies, or rights, from you under this +License will not have their licenses terminated so long as such +parties remain in full compliance. + +@item +FUTURE REVISIONS OF THIS LICENSE + +The Free Software Foundation may publish new, revised versions +of the GNU Free Documentation License from time to time. Such new +versions will be similar in spirit to the present version, but may +differ in detail to address new problems or concerns. See +@uref{http://www.gnu.org/copyleft/}. + +Each version of the License is given a distinguishing version number. +If the Document specifies that a particular numbered version of this +License ``or any later version'' applies to it, you have the option of +following the terms and conditions either of that specified version or +of any later version that has been published (not as a draft) by the +Free Software Foundation. If the Document does not specify a version +number of this License, you may choose any version ever published (not +as a draft) by the Free Software Foundation. +@end enumerate + +@page +@appendixsubsec ADDENDUM: How to use this License for your documents + +To use this License in a document you have written, include a copy of +the License in the document and put the following copyright and +license notices just after the title page: + +@smallexample +@group + Copyright (C) @var{year} @var{your name}. + Permission is granted to copy, distribute and/or modify this document + under the terms of the GNU Free Documentation License, Version 1.1 + or any later version published by the Free Software Foundation; + with the Invariant Sections being @var{list their titles}, with the + Front-Cover Texts being @var{list}, and with the Back-Cover Texts being @var{list}. + A copy of the license is included in the section entitled ``GNU + Free Documentation License''. +@end group +@end smallexample + +If you have no Invariant Sections, write ``with no Invariant Sections'' +instead of saying which ones are invariant. If you have no +Front-Cover Texts, write ``no Front-Cover Texts'' instead of +``Front-Cover Texts being @var{list}''; likewise for Back-Cover Texts. + +If your document contains nontrivial examples of program code, we +recommend releasing these examples in parallel under your choice of +free software license, such as the GNU General Public License, +to permit their use in free software. + +@c Local Variables: +@c ispell-local-pdict: "ispell-dict" +@c End: + diff --git a/tags/gpgme-0-4-3/doc/gpgme.texi b/tags/gpgme-0-4-3/doc/gpgme.texi new file mode 100644 index 0000000..4809454 --- /dev/null +++ b/tags/gpgme-0-4-3/doc/gpgme.texi @@ -0,0 +1,4831 @@ +\input texinfo @c -*- Texinfo -*- +@setfilename gpgme.info +@settitle The `GnuPG Made Easy' Reference Manual + +@dircategory GNU Libraries +@direntry +* @acronym{GPGME}: (gpgme). Adding support for cryptography to your program. +@end direntry + +@include version.texi + +@c Unify some of the indices. +@syncodeindex tp fn +@syncodeindex pg fn + +@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}. + +Copyright @copyright{} 2002, 2003 g10 Code GmbH. + +Permission is granted to copy, distribute and/or modify this document +under the terms of the GNU Free Documentation License, Version 1.1 or +any later version published by the Free Software Foundation; with the +Invariant Sections being ``Free Software Needs Free Documentation'' and +``GNU Lesser General Public License'', the Front-Cover texts being (a) +(see below), and with the Back-Cover Texts being (b) (see below). A +copy of the license is included in the section entitled ``GNU Free +Documentation License''. + +@end ifinfo + +@iftex +@shorttitlepage The `GnuPG Made Easy' Reference Manual +@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 +Copyright @copyright{} 2002, 2003 g10 Code GmbH. + +Permission is granted to copy, distribute and/or modify this document +under the terms of the GNU Free Documentation License, Version 1.1 or +any later version published by the Free Software Foundation; with the +Invariant Sections being ``Free Software Needs Free Documentation'' and +``GNU Lesser General Public License'', the Front-Cover texts being (a) +(see below), and with the Back-Cover Texts being (b) (see below). A +copy of the license is included in the section entitled ``GNU Free +Documentation License''. +@end titlepage +@page + +@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 + +* Copying:: The GNU General Public License says how you + can copy and share `GnuPG Made Easy'. +* Free Documentation License:: This manual is under the GNU Free + Documentation License. + +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. +* 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. +* 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. + +Contexts + +* Creating Contexts:: Creating new @acronym{GPGME} contexts. +* Destroying Contexts:: Releasing @acronym{GPGME} contexts. +* 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. +* Run Control:: Controlling how operations are run. + +Context Attributes + +* Protocol Selection:: Selecting the protocol used by a context. +* ASCII Armor:: Requesting @acronym{ASCII} armored output. +* Text Mode:: Choosing canonical text 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. +* Locale:: Setting the locale of a context. + +Key Management + +* Listing Keys:: Browsing the list of available keys. +* Information About Keys:: Requesting detailed information about keys. +* Key Signatures:: Listing the signatures on a key. +* Manipulating Keys:: Operations on keys. +* Generating Keys:: Creating new key pairs. +* 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. + +Trust Item Management + +* Listing Trust Items:: Browsing the list of available trust items. +* Information About Trust Items:: Requesting information about 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. + +Encrypt + +* Encrypting a Plaintext:: How to encrypt a plaintext. + +Run Control + +* Waiting For Completion:: Waiting until an operation is completed. +* Using External Event Loops:: Advanced control over what happens when. + +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. + +@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. + + +@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 +General Public License (@pxref{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. +@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. +* 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*} and @code{gpg_str*} 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 want to link to one of the thread-safe versions of +@acronym{GPGME}, you must specify the @option{--thread} option before +any other option to select the thread package you want to link with. +Supported thread packages are @option{--thread=pth} and +@option{--thread=pthread}. + + +@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. + +@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}. +@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 three 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}. + +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. +@end deftypefun + + +After initializing @acronym{GPGME}, you should set the locale +information to the locale required for your output terminal (only +required if your program runs on a text terminal, rather than in the X +Window environment). Here is an example of a complete initialization: + +@example +#include +#include + +void +init_program (void) +@{ + /* Initialize the locale environment. */ + setlocale (LC_ALL, ""); + gpgme_check_version (NULL); + gpgme_set_locale (NULL, LC_CTYPE, setlocale (LC_CTYPE, NULL)); + gpgme_set_locale (NULL, LC_MESSAGES, setlocale (LC_MESSAGES, NULL)); +@} +@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. + + +@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 not entirely thread-safe, but it can +still be used in a multi-threaded environment if some care is taken. +If the following requirements are met, there should be no race +conditions to worry about: + +@itemize @bullet +@item +@acronym{GPGME} supports the thread libraries pthread and GNU Pth. +The support for this has to be enabled at compile time. +@acronym{GPGME} will automatically detect the location in which the +thread libraries are installed and activate the support for them at +build time. + +Support for other thread libraries is very easy to add. Please +contact us if you have the need. + +@item +If you want to use @acronym{GPGME} with threads, you must link to the +right version of the library. The name of the right library is +@code{libgpgme-} followed by the name of the thread package you use. +For example, if you use GNU Pth, the right name is +@code{libgpgme-pth}. Use the Automake macros or +@command{gpgme-config} program for simplicity. + + +@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 +This specifies the OpenPGP protocol. + +@item GPGME_PROTOCOL_CMS +This specifies the Cryptographic Message Syntax. +@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. +* OpenPGP:: Support for the OpenPGP protocol. +* Cryptographic Message Syntax:: Support for the CMS. +@end menu + + +@node Engine Version Check +@section Engine Version Check +@cindex version check, of the engines + +@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 *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 (gpgme_engine_info_t *info) +The function @code{gpgme_get_engine_info} returns a linked list of +engine info structures in @var{info}. Each info structure describes +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->path && !info->version) + fprintf (stderr, "Engine %s not installed properly", + info->path); + else if (info->path && info->version && info->req_version) + fprintf (stderr, "Engine %s version %s installed, " + "but at least version %s required", info->path, + info->version, info->req_version); + else + fprintf (stderr, "Unknown problem with engine for protocol %s", + gpgme_get_protocol_name (info->protocol)); + @} + @} +@end example + + +@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 Algorithms +@chapter Algorithms +@cindex algorithms + +The crypto backends support a variety of algorithms used in public key +cryptography. 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. +@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 + + +@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_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 occured, 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 occured. + +@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 {char *} gpgme_strerror_r (@w{gpgme_error_t @var{err}}) +The function @code{gpgme_strerror_r} returns a pointer to a +dynamically 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. When it is not needed +anymore, the user must deallocate it with @code{free}. +@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 + +@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. + +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. + +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. + +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. + +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 + +The following interface is deprecated and only provided for backward +compatibility. Don't use it. It will be removed in a future version +of @acronym{GPGME}. + +@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 + + +@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{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}. +@end deftypefun + + +@node Manipulating Data Buffers +@section Manipulating Data Buffers +@cindex data buffere, manipulation + +@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{whence} is a count of characters from the +beginning of the data object. + +@item SEEK_CUR +Specifies that @var{whence} is a count of characters from the current +file position. This count may be positive or negative. + +@item SEEK_END +Specifies that @var{whence} 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 + +The following function is deprecated and should not be used. It will +be removed in a future version of @acronym{GPGME}. + +@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 + +@c +@c gpgme_data_encoding_t +@c +@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. This encoding is useful to give the backend +a hint on the type of data. 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. +@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 + + +@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. +* 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. +* 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_data_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. +@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 Context Attributes +@section Context Attributes +@cindex context, attributes + +@menu +* Protocol Selection:: Selecting the protocol used by a context. +* ASCII Armor:: Requesting @acronym{ASCII} armored output. +* Text Mode:: Choosing canonical text 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. +* Locale:: Setting the locale 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 + +@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 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 -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 void 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. + +@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 dependant on the crypto +engine used. For example, it can be a remote keyserver or LDAP +certificate server. + +@item GPGME_KEYLIST_MODE_SIGS +The @code{GPGME_KEYLIST_MODE_SIGS} symbol specifies that the key +signatures should be included in the listed keys. +@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 calulcated 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}. If the user does not return 0 +indicating 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}. +@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. + +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 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}}) +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 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. + +@deftp {Data type} gpgme_sub_key_t +The @code{gpgme_sub_key_t} type is a pointer to a subkey structure. +Sub keys 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_sub_key_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 +This is true if the subkey can be used for authentication. + +@item unsigned int secret : 1 +This is true if the subkey is a secret key. + +@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. This is usually only available for the primary key. + +@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. +@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. + +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. + +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 disabled : 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 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. +@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 gpgme_key_sig_t signatures +This is a linked list with the signatures on this user ID. +@end table +@end deftp + +@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 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. + +@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 +This is true if the key (ie one of its subkeys) can be used for +authentication. + +@item unsigned int secret : 1 +This is true if the key is a secret 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_sub_key_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. +@end table +@end deftp + +@menu +* Listing Keys:: Browsing the list of available keys. +* Information About Keys:: Requesting detailed information about keys. +* Key Signatures:: Listing the signatures on a key. +* Manipulating Keys:: Operations on keys. +* Generating Keys:: Creating new key pairs. +* 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. +@end menu + + +@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. + +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. + +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_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_next} 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 e-mail address of the main user ID: + +@example +gpgme_ctx_t ctx; +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: %s <%s>\n", key->keyid, key->name, key->email); + gpgme_key_release (key); + @} + gpgme_release (ctx); + @} +if (gpg_err_code (err) != GPG_ERR_EOF) + @{ + fprintf (stderr, "%s: can not list keys: %s\n", + argv[0], 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. + +If the key is not found in the keyring, @code{gpgme_get_key} returns +the error code @code{GPG_ERR_NO_ERROR} 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 + + +The following interfaces are deprecated and only provided for backward +compatibility. Don't use them. They will be removed in a future +version of @acronym{GPGME}. + +@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 + + +@node Key Signatures +@subsection Key Signatures +@cindex key, signatures +@cindex signatures, on a key + +The following interfaces are deprecated and only provided for backward +compatibility. Don't use them. They will be removed in a future +version of @acronym{GPGME}. + +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 + + +@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 + + +The following interface is deprecated and only provided for backward +compatibility. Don't use it. It 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 + + +@node Generating Keys +@subsection Generating Keys +@cindex key, creation +@cindex key ring, add + +@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. + +GnuPG 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 XML +string. The details about the format of @var{parms} are specific to +the crypto engine used by @var{ctx}. Here is an example for GnuPG as +the crypto engine: + +@example + +Key-Type: DSA +Key-Length: 1024 +Subkey-Type: ELG-E +Subkey-Length: 1024 +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: + +@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 valid XML string, @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 + +@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 is a flag that is set to 1 if a primary key was created and to 0 +if not. + +@item unsigned int sub : 1 +This is a flag that is set to 1 if a subkey 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 sub key 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. +@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 + + +@node Exporting Keys +@subsection Exporting Keys +@cindex key, export +@cindex key ring, export from + +@deftypefun gpgme_error_t gpgme_op_export (@w{gpgme_ctx_t @var{ctx}}, @w{const char *@var{pattern}}, @w{unsigned int @var{reserved}}, @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}. + +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{reserved} is reserved for future use and must be @code{0}. + +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{unsigned int @var{reserved}}, @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{unsigned int @var{reserved}}, @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}. + +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{reserved} is reserved for future use and must be @code{0}. + +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{unsigned int @var{reserved}}, @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 + + +@node Importing Keys +@subsection Importing Keys +@cindex key, import +@cindex key ring, import to + +@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{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 + +@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 imported_rsa +The number of imported RSA keys. + +@item unchanged +The number of unchanged keys. + +@item new_user_ids +The number of new user IDs. + +@item new_sub_keys +The number of new sub keys. + +@item new_signatures +The number of new signatures. + +@item new_revocations +The number of new revocations. + +@item secret_read +The total number of secret keys read. + +@item secret_imported +The number of imported secret keys. + +@item secret_unchanged +The number of unchanged secret keys. + +@item 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. +@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 + +The following interface is deprecated and only provided for backward +compatibility. Don't use it. It will be removed in a future version +of @acronym{GPGME}. + +@deftypefun gpgme_error_t gpgme_op_import_ext (@w{gpgme_ctx_t @var{ctx}}, @w{gpgme_data_t @var{keydata}}, @w{int *@var{nr}}) +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 + + +@node Deleting Keys +@subsection Deleting Keys +@cindex key, delete +@cindex key ring, delete from + +@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}}) +The function @code{gpgme_op_delete} deletes the key @var{key} from the +key ring of the crypto engine used by @var{ctx}. If +@var{allow_secret} is @code{0}, only public keys are deleted, +otherwise secret keys are deleted as well, if that is supported. + +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_start (@w{gpgme_ctx_t @var{ctx}}, @w{const gpgme_key_t @var{key}}, @w{int @var{allow_secret}}) +The function @code{gpgme_op_delete_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 + + +@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. +* Information About Trust Items:: Requesting information about 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_next} ends a pending key 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 Information About Trust Items +@subsection Information About Trust Items +@cindex trust item, information about +@cindex trust item, attributes +@cindex attributes, of a trust item + +The following interfaces are deprecated and only provided for backward +compatibility. Don't use them. They will be removed in a future +version of @acronym{GPGME}. + +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 + + +@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 + + +The following interface is deprecated and only provided for backward +compatibility. Don't use it. It will be removed in a future version +of @acronym{GPGME}. + +@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 + + +@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 any 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 + +@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 encrypting +data, you can retrieve the pointer to the result with +@code{gpgme_op_decrypt_result}. 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. +@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 + +@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 char *value +The value of the notation field. If @code{name} is @code{NULL}, then +this is a policy URL. +@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. + +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. + @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_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 int wrong_key_usage : 1; +This is true if the key was not used according to its policy. + +@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. + +@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. +@end table +@end deftp + +@deftypefun gpgme_sign_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} or +@code{gpgme_op_verify_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 + + +The following interfaces are deprecated and only provided for backward +compatibility. Don't use them. They will be removed in a future +version of @acronym{GPGME}. + +@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}}) +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, 0); +@end example +@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. + +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 (@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 + + +@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. +@end menu + + +@node Selecting Signers +@subsubsection Selecting Signers +@cindex signature, selecting signers +@cindex signers, selecting + +@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 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 and 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 +The public key algorithm used to create this signature. + +@item gpgme_hash_algo_t +The hash algorithm used to create this signature. + +@item unsigned int 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 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 and text +mode attributes set for the context @var{ctx}. + +@var{key} 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. +@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 + +@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 + + +@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. +@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 +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 mroe 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. +@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 funtion +@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{gpgme_error_t} 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 occured. + +@var{type} will specify the type of event that has occured. +@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_cb_ts} +@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_data +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 is optional, but if you don't specify it, you can +not retrieve the return value of the operation. + +@item void *event_data +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 occured. +@end table +@end deftp + +@deftypefun void gpgme_set_io_cbs (@w{gpgme_ctx_t @var{ctx}}, @w{struct gpgme_io_cb_ts *@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_cb_ts *@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 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 + +/* 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; +@}; + +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; + 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; + + 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; + + pthread_mutex_lock (&loop->lock); + FD_ZERO (&rfds); + FD_ZERO (&wfds); + for (i = 0; i < FDLIST_MAX; i++) + if (fdlist[i].fd != -1) + FD_SET (fdlist[i].fd, fdlist[i].dir ? &rfds : &wfds); + pthread_mutex_unlock (&loop->unlock); + + do + @{ + n = select (FD_SETSIZE, &rfds, &wfds, NULL, 0); + @} + while (n < 0 && errno == EINTR); + + if (n < 0) + return n; /* Error or timeout. */ + + pthread_mutex_lock (&loop->lock); + for (i = 0; i < FDLIST_MAX && 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); + return ret; +@} +@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; + gpgme_sig_stat_t status; + int i; + struct gpgme_io_cb_ts io_cbs = + @{ + add_io_cb, + &loop, + remove_io_cb, + event_io_cb, + &result + @}; + + /* Initialize the loop structure. */ + loop.lock = PTHREAD_MUTEX_INITIALIZER; + 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, &status); + @} + 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 STATUS. */ + @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 + + +@include gpl.texi + + +@include fdl.texi + + +@node Concept Index +@unnumbered Concept Index + +@printindex cp + + +@node Function and Data Index +@unnumbered Function and Data Index + +@printindex fn + + +@summarycontents +@contents +@bye diff --git a/tags/gpgme-0-4-3/doc/gpl.texi b/tags/gpgme-0-4-3/doc/gpl.texi new file mode 100644 index 0000000..ca0508f --- /dev/null +++ b/tags/gpgme-0-4-3/doc/gpl.texi @@ -0,0 +1,397 @@ +@node Copying +@appendix GNU GENERAL PUBLIC LICENSE + +@cindex GPL, GNU General Public License +@center Version 2, June 1991 + +@display +Copyright @copyright{} 1989, 1991 Free Software Foundation, Inc. +59 Temple Place -- Suite 330, Boston, MA 02111-1307, USA + +Everyone is permitted to copy and distribute verbatim copies +of this license document, but changing it is not allowed. +@end display + +@appendixsubsec Preamble + + The licenses for most software are designed to take away your +freedom to share and change it. By contrast, the GNU General Public +License is intended to guarantee your freedom to share and change free +software---to make sure the software is free for all its users. This +General Public License applies to most of the Free Software +Foundation's software and to any other program whose authors commit to +using it. (Some other Free Software Foundation software is covered by +the GNU Library General Public License instead.) You can apply it to +your programs, too. + + When we speak of free software, we are referring to freedom, not +price. Our General Public Licenses are designed to make sure that you +have the freedom to distribute copies of free software (and charge for +this service if you wish), that you receive source code or can get it +if you want it, that you can change the software or use pieces of it +in new free programs; and that you know you can do these things. + + To protect your rights, we need to make restrictions that forbid +anyone to deny you these rights or to ask you to surrender the rights. +These restrictions translate to certain responsibilities for you if you +distribute copies of the software, or if you modify it. + + For example, if you distribute copies of such a program, whether +gratis or for a fee, you must give the recipients all the rights that +you have. You must make sure that they, too, receive or can get the +source code. And you must show them these terms so they know their +rights. + + We protect your rights with two steps: (1) copyright the software, and +(2) offer you this license which gives you legal permission to copy, +distribute and/or modify the software. + + Also, for each author's protection and ours, we want to make certain +that everyone understands that there is no warranty for this free +software. If the software is modified by someone else and passed on, we +want its recipients to know that what they have is not the original, so +that any problems introduced by others will not reflect on the original +authors' reputations. + + Finally, any free program is threatened constantly by software +patents. We wish to avoid the danger that redistributors of a free +program will individually obtain patent licenses, in effect making the +program proprietary. To prevent this, we have made it clear that any +patent must be licensed for everyone's free use or not licensed at all. + + The precise terms and conditions for copying, distribution and +modification follow. + +@iftex +@appendixsubsec TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION +@end iftex +@ifinfo +@center TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION +@end ifinfo + +@enumerate +@item +This License applies to any program or other work which contains +a notice placed by the copyright holder saying it may be distributed +under the terms of this General Public License. The ``Program'', below, +refers to any such program or work, and a ``work based on the Program'' +means either the Program or any derivative work under copyright law: +that is to say, a work containing the Program or a portion of it, +either verbatim or with modifications and/or translated into another +language. (Hereinafter, translation is included without limitation in +the term ``modification''.) Each licensee is addressed as ``you''. + +Activities other than copying, distribution and modification are not +covered by this License; they are outside its scope. The act of +running the Program is not restricted, and the output from the Program +is covered only if its contents constitute a work based on the +Program (independent of having been made by running the Program). +Whether that is true depends on what the Program does. + +@item +You may copy and distribute verbatim copies of the Program's +source code as you receive it, in any medium, provided that you +conspicuously and appropriately publish on each copy an appropriate +copyright notice and disclaimer of warranty; keep intact all the +notices that refer to this License and to the absence of any warranty; +and give any other recipients of the Program a copy of this License +along with the Program. + +You may charge a fee for the physical act of transferring a copy, and +you may at your option offer warranty protection in exchange for a fee. + +@item +You may modify your copy or copies of the Program or any portion +of it, thus forming a work based on the Program, and copy and +distribute such modifications or work under the terms of Section 1 +above, provided that you also meet all of these conditions: + +@enumerate a +@item +You must cause the modified files to carry prominent notices +stating that you changed the files and the date of any change. + +@item +You must cause any work that you distribute or publish, that in +whole or in part contains or is derived from the Program or any +part thereof, to be licensed as a whole at no charge to all third +parties under the terms of this License. + +@item +If the modified program normally reads commands interactively +when run, you must cause it, when started running for such +interactive use in the most ordinary way, to print or display an +announcement including an appropriate copyright notice and a +notice that there is no warranty (or else, saying that you provide +a warranty) and that users may redistribute the program under +these conditions, and telling the user how to view a copy of this +License. (Exception: if the Program itself is interactive but +does not normally print such an announcement, your work based on +the Program is not required to print an announcement.) +@end enumerate + +These requirements apply to the modified work as a whole. If +identifiable sections of that work are not derived from the Program, +and can be reasonably considered independent and separate works in +themselves, then this License, and its terms, do not apply to those +sections when you distribute them as separate works. But when you +distribute the same sections as part of a whole which is a work based +on the Program, the distribution of the whole must be on the terms of +this License, whose permissions for other licensees extend to the +entire whole, and thus to each and every part regardless of who wrote it. + +Thus, it is not the intent of this section to claim rights or contest +your rights to work written entirely by you; rather, the intent is to +exercise the right to control the distribution of derivative or +collective works based on the Program. + +In addition, mere aggregation of another work not based on the Program +with the Program (or with a work based on the Program) on a volume of +a storage or distribution medium does not bring the other work under +the scope of this License. + +@item +You may copy and distribute the Program (or a work based on it, +under Section 2) in object code or executable form under the terms of +Sections 1 and 2 above provided that you also do one of the following: + +@enumerate a +@item +Accompany it with the complete corresponding machine-readable +source code, which must be distributed under the terms of Sections +1 and 2 above on a medium customarily used for software interchange; or, + +@item +Accompany it with a written offer, valid for at least three +years, to give any third party, for a charge no more than your +cost of physically performing source distribution, a complete +machine-readable copy of the corresponding source code, to be +distributed under the terms of Sections 1 and 2 above on a medium +customarily used for software interchange; or, + +@item +Accompany it with the information you received as to the offer +to distribute corresponding source code. (This alternative is +allowed only for noncommercial distribution and only if you +received the program in object code or executable form with such +an offer, in accord with Subsection b above.) +@end enumerate + +The source code for a work means the preferred form of the work for +making modifications to it. For an executable work, complete source +code means all the source code for all modules it contains, plus any +associated interface definition files, plus the scripts used to +control compilation and installation of the executable. However, as a +special exception, the source code distributed need not include +anything that is normally distributed (in either source or binary +form) with the major components (compiler, kernel, and so on) of the +operating system on which the executable runs, unless that component +itself accompanies the executable. + +If distribution of executable or object code is made by offering +access to copy from a designated place, then offering equivalent +access to copy the source code from the same place counts as +distribution of the source code, even though third parties are not +compelled to copy the source along with the object code. + +@item +You may not copy, modify, sublicense, or distribute the Program +except as expressly provided under this License. Any attempt +otherwise to copy, modify, sublicense or distribute the Program is +void, and will automatically terminate your rights under this License. +However, parties who have received copies, or rights, from you under +this License will not have their licenses terminated so long as such +parties remain in full compliance. + +@item +You are not required to accept this License, since you have not +signed it. However, nothing else grants you permission to modify or +distribute the Program or its derivative works. These actions are +prohibited by law if you do not accept this License. Therefore, by +modifying or distributing the Program (or any work based on the +Program), you indicate your acceptance of this License to do so, and +all its terms and conditions for copying, distributing or modifying +the Program or works based on it. + +@item +Each time you redistribute the Program (or any work based on the +Program), the recipient automatically receives a license from the +original licensor to copy, distribute or modify the Program subject to +these terms and conditions. You may not impose any further +restrictions on the recipients' exercise of the rights granted herein. +You are not responsible for enforcing compliance by third parties to +this License. + +@item +If, as a consequence of a court judgment or allegation of patent +infringement or for any other reason (not limited to patent issues), +conditions are imposed on you (whether by court order, agreement or +otherwise) that contradict the conditions of this License, they do not +excuse you from the conditions of this License. If you cannot +distribute so as to satisfy simultaneously your obligations under this +License and any other pertinent obligations, then as a consequence you +may not distribute the Program at all. For example, if a patent +license would not permit royalty-free redistribution of the Program by +all those who receive copies directly or indirectly through you, then +the only way you could satisfy both it and this License would be to +refrain entirely from distribution of the Program. + +If any portion of this section is held invalid or unenforceable under +any particular circumstance, the balance of the section is intended to +apply and the section as a whole is intended to apply in other +circumstances. + +It is not the purpose of this section to induce you to infringe any +patents or other property right claims or to contest validity of any +such claims; this section has the sole purpose of protecting the +integrity of the free software distribution system, which is +implemented by public license practices. Many people have made +generous contributions to the wide range of software distributed +through that system in reliance on consistent application of that +system; it is up to the author/donor to decide if he or she is willing +to distribute software through any other system and a licensee cannot +impose that choice. + +This section is intended to make thoroughly clear what is believed to +be a consequence of the rest of this License. + +@item +If the distribution and/or use of the Program is restricted in +certain countries either by patents or by copyrighted interfaces, the +original copyright holder who places the Program under this License +may add an explicit geographical distribution limitation excluding +those countries, so that distribution is permitted only in or among +countries not thus excluded. In such case, this License incorporates +the limitation as if written in the body of this License. + +@item +The Free Software Foundation may publish revised and/or new versions +of the General Public License from time to time. Such new versions will +be similar in spirit to the present version, but may differ in detail to +address new problems or concerns. + +Each version is given a distinguishing version number. If the Program +specifies a version number of this License which applies to it and ``any +later version'', you have the option of following the terms and conditions +either of that version or of any later version published by the Free +Software Foundation. If the Program does not specify a version number of +this License, you may choose any version ever published by the Free Software +Foundation. + +@item +If you wish to incorporate parts of the Program into other free +programs whose distribution conditions are different, write to the author +to ask for permission. For software which is copyrighted by the Free +Software Foundation, write to the Free Software Foundation; we sometimes +make exceptions for this. Our decision will be guided by the two goals +of preserving the free status of all derivatives of our free software and +of promoting the sharing and reuse of software generally. + +@iftex +@heading NO WARRANTY +@end iftex +@ifinfo +@center NO WARRANTY +@end ifinfo + +@item +BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY +FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN +OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES +PROVIDE THE PROGRAM ``AS IS'' WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED +OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF +MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS +TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE +PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, +REPAIR OR CORRECTION. + +@item +IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING +WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR +REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, +INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING +OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED +TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY +YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER +PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE +POSSIBILITY OF SUCH DAMAGES. +@end enumerate + +@iftex +@heading END OF TERMS AND CONDITIONS +@end iftex +@ifinfo +@center END OF TERMS AND CONDITIONS +@end ifinfo + +@page +@unnumberedsec How to Apply These Terms to Your New Programs + + If you develop a new program, and you want it to be of the greatest +possible use to the public, the best way to achieve this is to make it +free software which everyone can redistribute and change under these terms. + + To do so, attach the following notices to the program. It is safest +to attach them to the start of each source file to most effectively +convey the exclusion of warranty; and each file should have at least +the ``copyright'' line and a pointer to where the full notice is found. + +@smallexample +@var{one line to give the program's name and an idea of what it does.} +Copyright (C) 19@var{yy} @var{name of author} + +This program 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. + +This program 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., +59 Temple Place, Suite 330, Boston, MA 02111-1307, USA. +@end smallexample + +Also add information on how to contact you by electronic and paper mail. + +If the program is interactive, make it output a short notice like this +when it starts in an interactive mode: + +@smallexample +Gnomovision version 69, Copyright (C) 19@var{yy} @var{name of author} +Gnomovision comes with ABSOLUTELY NO WARRANTY; for details +type `show w'. This is free software, and you are welcome +to redistribute it under certain conditions; type `show c' +for details. +@end smallexample + +The hypothetical commands @samp{show w} and @samp{show c} should show +the appropriate parts of the General Public License. Of course, the +commands you use may be called something other than @samp{show w} and +@samp{show c}; they could even be mouse-clicks or menu items---whatever +suits your program. + +You should also get your employer (if you work as a programmer) or your +school, if any, to sign a ``copyright disclaimer'' for the program, if +necessary. Here is a sample; alter the names: + +@smallexample +@group +Yoyodyne, Inc., hereby disclaims all copyright +interest in the program `Gnomovision' +(which makes passes at compilers) written +by James Hacker. + +@var{signature of Ty Coon}, 1 April 1989 +Ty Coon, President of Vice +@end group +@end smallexample + +This General Public License does not permit incorporating your program into +proprietary programs. If your program is a subroutine library, you may +consider it more useful to permit linking proprietary applications with the +library. If this is what you want to do, use the GNU Library General +Public License instead of this License. diff --git a/tags/gpgme-0-4-3/gpgme.spec.in b/tags/gpgme-0-4-3/gpgme.spec.in new file mode 100644 index 0000000..18aa28b --- /dev/null +++ b/tags/gpgme-0-4-3/gpgme.spec.in @@ -0,0 +1,67 @@ +# This is a template. The dist target uses it to create the real file. +Summary: GPGME - GnuPG Made Easy +Name: gpgme +Version: @pkg_version@ +Release: 1 +URL: http://www.gnupg.org/gpgme.html +Source: ftp://ftp.gnupg.org/gcrypt/alpha/gpgme/%{name}-%{version}.tar.gz +Group: Development/Libraries +Copyright: GPL +BuildRoot: %{_tmppath}/%{name}-%{version} +BuildRequires: make +Prereq: /sbin/ldconfig /sbin/install-info +Requires: gnupg + +%description +GnuPG Made Easy (GPGME) is a library designed to make access to GnuPG easier +for applications. It provides a High-Level Crypto API for encryption, +decryption, signing, signature verification and key management. + +%prep +%setup -q + +%build +CFLAGS="$RPM_OPT_FLAGS"; export CFLAGS +./configure --prefix=/usr +make + +%install +rm -fr $RPM_BUILD_ROOT +mkdir -p $RPM_BUILD_ROOT +make install prefix=$RPM_BUILD_ROOT/usr infodir=$RPM_BUILD_ROOT%{_infodir} +rm -f $RPM_BUILD_ROOT%{_infodir}/dir + +%clean +rm -fr $RPM_BUILD_ROOT +make distclean + +%post +/sbin/ldconfig +/sbin/install-info %{_infodir}/gpgme.info.gz %{_infodir}/dir + +%preun +if [ "$1" = 0 ]; then + /sbin/install-info --delete %{_infodir}/gpgme.info.gz %{_infodir}/dir +fi + +%postun +/sbin/ldconfig + +%files +%defattr(-,root,root) +%doc COPYING AUTHORS README INSTALL NEWS ChangeLog TODO THANKS +%attr(0755,root,root) %{_bindir}/gpgme-config +%attr(0755,root,root) %{_libdir}/*gpgme.so* +%attr(0755,root,root) %{_libdir}/*gpgme.la +%attr(0644,root,root) %{_libdir}/*gpgme.a +%{_includedir}/gpgme.h +%{_datadir}/aclocal/gpgme.m4 +%{_infodir}/gpgme.info* + +%changelog +* Sat Aug 30 2003 Robert Schiele +- %{_infodir}/dir is not packaged, remove to prevent checking failure +* Mon Jul 01 2002 Wojciech Polak +- initial specfile release for GPGME. + +# EOF diff --git a/tags/gpgme-0-4-3/gpgme.txt b/tags/gpgme-0-4-3/gpgme.txt new file mode 100644 index 0000000..e2d756f --- /dev/null +++ b/tags/gpgme-0-4-3/gpgme.txt @@ -0,0 +1,90 @@ +%%comments: +Copyright (C) 2001 Free Software Foundation, Inc. + +Permission is granted to copy, distribute and/or modify this document +under the terms of the GNU Free Documentation License, Version 1.1 or +any later version published by the Free Software Foundation; with no +Invariant Sections, with no Front-Cover Texts, and with no Back-Cover +Texts. A copy of the license is included in the file COPYING. + +%%name: GPGME + +%%short-description: GnuPG Made Easy + +%%full-description: GPGME is a library designed to make access to +GnuPG easier for applications. It provides a High-Level Crypto API +for encryption, decryption, signing, signature verification and key +management. Currently it uses GnuPG and GpgSM as its backends to +support OpenPGP and the Cryptographic Message Syntax. + +%%category: security, libraries + +%%license: GPL +%%license verified by: +%%license verified on: + +%%maintainer: g10 Code GmbH + +%%updated: 2002-07-25 + +%%keywords: encryption, public key, digital signature, GnuPG + +%%interface: + +%%programs: + +%%GNU: no + +%%web-page: http://www.gnupg.org/gpgme.html + +%%support: paid extension/consulting from http://www.g10code.com + +%%doc: English programmer reference in Texinfo, Postscript, HTML included + +%%developers: Werner Koch . + +%%contributors: + +%%sponsors: + +%%source: ftp://ftp.gnupg.org/gcrypt/alpha/gpgme/ + +%%debian: + +%%redhat: + +%%repository: See http://www.gnupg.org/cvs-access.html + +%%related: + +%%source-language: C + +%%supported-languages: C, C++ + +%%use-requirements: GnuPG 1.0.7, GpgSM 0.3.8 + +%%build-prerequisites: + +%%weak-prerequisites: + +%%source-prerequisites: + +%%version: 0.3.8 released on 2002-06-25 + +%%announce-list: announce@gnupg.org announce-request@gnupg.org + +%%announce-news: + +%%help-list: + +%%help-news: + +%%dev-list: gnupg-devel@gnupg.org gnupg-devel-request@gnupg.org + +%%dev-news: + +%%bug-list: + +%%bug-database: + +%%entry written by: Werner Koch diff --git a/tags/gpgme-0-4-3/gpgme/ChangeLog b/tags/gpgme-0-4-3/gpgme/ChangeLog new file mode 100644 index 0000000..b67b339 --- /dev/null +++ b/tags/gpgme-0-4-3/gpgme/ChangeLog @@ -0,0 +1,4275 @@ +2003-10-06 Marcus Brinkmann + + * data-compat.c: Include before for + broken systems. + + * engine-gpgsm.c (map_assuan_error): If ERR is -1, return sensible + error. + + * io.h (_gpgme_io_subsystem_init): New prototype. + * posix-io.c (_gpgme_io_subsystem_init): Add function. + (_gpgme_io_spawn): Do not fixup signal handler here. + * version.c (do_subsystem_inits): Call _gpgme_io_subsystem_init. + + * debug.c (debug_init): Drop const qualifier from E. + + * ath.h (struct ath_ops): Make ADDR argument of CONNECT prototype + const. + (ath_connect): Make ADDR argument const. + * ath-pthread.c (ath_connect): Likewise. + * ath-pth.c (ath_connect): Likewise. + * ath-compat.c (ath_connect): Likewise. + * ath.c (ath_connect): Likewise. + + * ath.h [HAVE_SYS_SELECT_H]: Include for fd_set. + [!HAVE_SYS_SELECT_H]: Include . + + * conversion.c (_gpgme_hextobyte): Drop "unsigned" from type of + SRC argument. + * util.h (_gpgme_hextobyte): Likewise for prototype. + + * gpgme.h: Remove trailing comma in enum. + + * rungpg.c: Do not include , , , + , , or "unistd.h". + +2003-10-02 Marcus Brinkmann + + * engine-backend.h (struct engine_ops): Add argument TYPE. + * engine.c (_gpgme_engine_op_edit): Likewise. + * engine.h: Likewise. + * rungpg.c (gpg_edit): Likewise. Use it. + * edit.c (edit_start): Likewise. Pass it on. + (gpgme_op_edit_start, gpgme_op_edit): Likewise. + (gpgme_op_card_edit_start, gpgme_op_card_edit): New functions. + +2003-09-30 Marcus Brinkmann + + * gpgme.h (gpg_strerror_r): Change prototype to match + gpg_strerror_r change. + * error.c (gpg_strerror_r): Likewise, also update implementation. + + * gpgme.c (gpgme_hash_algo_name): Change name of RMD160 to + RIPEMD160, name of TIGER to TIGER192, name of CRC32-RFC1510 to + CRC32RFC1510, and name of CRC24-RFC2440 to CRC24RFC2440. + +2003-09-14 Marcus Brinkmann + + * gpgme.h: Add prototype for gpgme_set_locale. + + * gpgme.h: Define macro _GPGME_INLINE depending on the compiler + characteristics and use that instead __inline__. + + * context.h (struct gpgme_context): New members lc_ctype and + lc_messages. + * gpgme.c: Include . + (def_lc_lock, def_lc_ctype, def_lc_messages): New static + variables. + (gpgme_set_locale): New function. + * engine.c (_gpgme_engine_new): Add arguments lc_ctype and + lc_messages. + * engine.h (_gpgme_engine_new): Likewise. + * engine-gpgsm.c (gpgsm_new): Likewise. + * rungpg.c (gpg_new): Likewise. + * engine-backend.h (struct engine_ops): Likewise to NEW. + * op-support.c (_gpgme_op_reset): Likewise to invocation of + _gpgme_engine_new. + +2003-09-13 Marcus Brinkmann + + * gpgme.h (gpgme_strerror_r): New prototype. + * error.c (gpgme_strerror_r): New function. + + * get-env.c: New file. + * util.h (_gpgme_getenv): Add prototype. + * Makefile.am (libgpgme_real_la_SOURCES): Add get-env.c. + * rungpg.c (build_argv): Use _gpgme_getenv. + * debug.c (debug_init): Likewise. + * engine-gpgsm.c (gpgsm_new): Likewise. + (gpgsm_new): Use ttyname_r. + * w32-io.c (_gpgme_io_spawn): Disable debugging for now. + +2003-09-03 Marcus Brinkmann + + * gpgme-config.in: Use $libdir, not @libdir@, for the echo + command. + + * gpgme-config.in: Rewritten. + * gpgme.m4: Rewritten. + +2003-08-19 Marcus Brinkmann + + The ath files (ath.h, ath.c, ath-pth.c, ath-pthread.c, + ath-compat.c, ath-pth-compat.c and ath-pthread-compat.c) have been + updated to have better thread support, and the Makefile.am was + changed to reflect that. + + * util.h [!HAVE_FOPENCOOKIE]: Remove fopencookie declaration. + * engine-gpgsm.c (gpgsm_assuan_simple_command): Set ERR to return + value of status_fnc. + * rungpg.c (start): Return SAVED_ERRNO, not errno. + +2003-08-18 Marcus Brinkmann + + * rungpg.c (start): Use saved_errno instead errno. + +2003-08-18 Marcus Brinkmann + + * funopen.c, putc_unlocked.c, isascii.c, memrchr.c: New files. + * fopencookie.c: File removed. + +2003-08-15 Marcus Brinkmann + + * gpgme-config.in: Put gpg-error related flags after gpgme's. + +2003-08-14 Marcus Brinkmann + + * gpgme.h (struct _gpgme_new_signature): Rename member CLASS to + _OBSOLETE_CLASS, add member CLASS with type unsigned int. + * sign.c (parse_sig_created): Also set SIG->_unused_class for + backward compatibility. + +2003-08-04 Marcus Brinkmann + + * verify.c (parse_new_sig): Fix status parsing case. + +2003-07-31 Marcus Brinkmann + + * gpgme.h (struct _gpgme_subkey): Add flag CAN_AUTHENTICATE. + Lower _UNUSED to 23 bits. + (struct _gpgme_key): Likewise. + * keylist.c (set_mainkey_capability): Support 'a' and 'A'. + (set_subkey_capability): Support 'a'. + + * keylist.c (gpgme_get_key): Check if there is more than one key + listed, and return GPG_ERR_AMBIGUOUS_NAME in that case. + + * util.h (_gpgme_decode_c_string): Change type of LEN argument to + size_t. + (_gpgme_decode_percent_string): Likewise. + * conversion.c (_gpgme_decode_c_string): Likewise. + (_gpgme_decode_percent_string): Likewise. + (_gpgme_map_gnupg_error): Change type of I to unsigned int. + * signers.c (gpgme_signers_clear): Likewise. + (gpgme_signers_enum): New unsigned variable SEQNO, set to SEQ. + Use SEQNO instead SEQ. + * wait.c (fd_table_put): Change type of I and J to unsigned int. + * wait-global.c (_gpgme_wait_global_event_cb): Change type of IDX + to unsigned int. + (gpgme_wait): Change type of I and IDX to unsigned int. + * wait-private.c (_gpgme_wait_on_condition): Change type of IDX + and I to unsigned int. + * posix-io.c (_gpgme_io_close): Cast return value of macro DIM to + int to suppress gcc warning. + (_gpgme_io_set_close_notify): Likewise. + (_gpgme_io_select): Change type of I to unsigned int. + * engine.c (gpgme_get_engine_info): Change type of PROTO to + unsigned int. + * wait-user.c (_gpgme_user_io_cb_handler): Change type of IDX and + I to unsigned int. + +2003-07-29 Marcus Brinkmann + + * decrypt-verify.c (decrypt_verify_status_handler): Expand silly + and wrong expression. + * encrypt-sign.c (encrypt_sign_status_handler): Likewise. + * encrypt.c (encrypt_sym_status_handler): Likewise. + * sign.c (sign_status_handler): Likewise. + * verify.c (verify_status_handler): Likewise. + * decrypt.c (decrypt_status_handler): Likewise. + + * engine.c (gpgme_get_engine_info): Initialize NULL. + +2003-07-23 Marcus Brinkmann + + * gpgme-config.in (gpg_error_libs): Quote GPG_ERROR_CFLAGS and + GPG_ERROR_LIBS when setting the corresponding variables. + Reported by Stéphane Corthésy. + +2003-07-22 Marcus Brinkmann + + * engine-gpgsm.c (set_recipients): Move declaration of NEWLEN to + the beginning of the block. + +2003-06-22 Marcus Brinkmann + + * data-mem.c (mem_write): Copy original buffer content. + +2003-06-22 Marcus Brinkmann + + * gpgme.h (gpgme_user_ids_release, gpgme_user_ids_append): Remove + prototypes. + +2003-06-06 Marcus Brinkmann + + * Makefile.am (AM_CPPFLAGS): Add @GPG_ERROR_CFLAGS@. + * gpgme-config.in (gpg_error_libs, gpg_error_cflags): New variables. + Print them. + + * op-support.c (_gpgme_parse_inv_userid): Rename to + _gpgme_parse_inv_recp and change to new datatype. + * ops.h (_gpgme_parse_inv_key): Fix prototype. + * gpgme.h (struct _gpgme_invalid_user_id): Rename to + __gpgme_invalid_key. Rename field ID to KEY. + (gpgme_invalid_user_id_t): Rename to gpgme_invalid_key_t. + (struct _gpgme_op_encrypt_result): Here, too. + (struct _gpgme_op_sign_result): Likewise. + * encrypt.c (struct op_data): Likewise. + (release_op_data): Likewise. + * sign.c (struct op_data): Likewise. + (release_op_data): Likewise. + + * posix-io.c (_gpgme_io_read): Save errno across debug calls. + (_gpgme_io_write): Likewise. + (_gpgme_io_pipe): Likewise. + (_gpgme_io_select): Likewise. + + * rungpg.c (struct engine_gpg): Remove arg_error. + (add_arg): Don't set arg_error. + (add_data): Likewise. + (start): Don't check arg_error. + (gpg_new): Check return value of add_arg. + * verify.c (parse_notation): Free allocated memory at error. + +2003-06-05 Marcus Brinkmann + + Everywhere: Use libgpg-error error codes. + + * Makefile.am (EXTRA_DIST): Remove mkerrors. + (BUILT_SOURCES): Remove errors.c. + (MOSTLYCLEANFILES): Likewise. + (libgpgme_la_SOURCES): Likewise. Add error.c. + (errors.c): Remove target. + * mkerrors: File removed. + * error.c: New file. + + * gpgme.h (gpgme_error_t): Change to type gpg_error_t. + (gpgme_err_code_t, gpgme_err_source_t): New types. + (gpgme_err_code, gpgme_err_source, gpgme_error, gpgme_err_make): + New static inline functions. + (gpgme_strsource, gpgme_err_code_from_errno, + gpgme_err_code_to_errno, gpgme_err_make_from_errno, + gpgme_error_from_errno): New prototypes. + +2003-05-29 Marcus Brinkmann + + * gpgme.h (gpgme_op_export_start): Change second arg to const char *. + (gpgme_op_export): Likewise. + (gpgme_op_export_ext_start): New prototype. + (gpgme_op_export_ext): Likewise. + * engine.h: Likewise for _gpgme_engine_op_export and + _gpgme_engine_op_export_ext. + * engine-backend.h (struct engine_ops): Change second argument of + prototype of export to const char *, and add reserverd int as + third argument. Add prototype for export_ext. + * engine.c (_gpgme_engine_op_export_ext): New function. + (_gpgme_engine_op_export): Change second argument of prototype of + export to const char *, and add reserverd int as third argument. + * rungpg.c (gpg_export): Change second argument of prototype of + export to const char *, and add reserverd int as third argument. + (gpg_export_ext): New function. + (gpg_keylist_ext): Break loop at error. + (_gpgme_engine_ops_gpg): Add gpg_export_ext. + * engine-gpgsm.c (gpgsm_export): Change second argument of + prototype of export to const char *, and add reserverd int as + third argument. + (gpgsm_export_ext): New function. + (_gpgme_engine_ops_gpgsm): Add gpgsm_export_ext. + * export.c (export_start): Change second argument of prototype of + export to const char *, and add reserverd int as third argument. + (gpgme_op_export_start): Likewise. + (export_ext_start): New function. + (gpgme_op_export_ext_start): Likewise. + (gpgme_op_export_ext): Likewise. + + * gpgme.h (gpgme_keylist_mode_t): New type for anonymous enum. + (gpgme_sigsum_t): New type for anonymous enum. + + * encrypt-sign.c (encrypt_sign_start): Check for errors earlier, + and return an error if RECP is not set. + + * Makefile.am (libgpgme_la_SOURCES): Remove user-id.c. + * user-id.c: Remove file. + * ops.h: Remove prototype for _gpgme_user_ids_all_valid. + * gpgme.h (gpgme_encrypt_flags_t): New type. + (gpgme_op_encrypt_start): Change second parameter to type + gpgme_key_t[], and add third parameter. + (gpgme_op_encrypt): Likewise. + (gpgme_op_encrypt_sign_start): Likewise. + (gpgme_op_encrypt_sign): Likewise. + * encrypt.c (encrypt_start): Likewise. + (gpgme_op_encrypt_start): Likewise. + (gpgme_op_encrypt): Likewise. Pass flags to engine. + * encrypt-sign.c (encrypt_sign_start): Likewise. + (gpgme_op_encrypt_sign_start): Likewise. + (gpgme_op_encrypt_sign): Likewise. + * engine-backend.h (struct engine_ops): Likewise for prototypes of + encrypt and encrypt_sign. + * engine.h: Likewise for prototypes of _gpgme_engine_op_encrypt + and _gpgme_engine_op_encrypt_sign. + * engine.c (_gpgme_engine_op_encrypt): Likewise. + (_gpgme_engine_op_encrypt_sign): Likewise. + * rungpg.c (gpg_encrypt): Likewise. + (gpg_encrypt_sign): Likewise. + * rungpg.c (gpg_encrypt): Check flags for always trust option. + * engine-gpgsm.c (gpgsm_encrypt): Likewise. + (set_recipients): Rewritten to use keys instead user IDs. + * rungpg.c (append_args_from_recipients): Rewritten to use keys + instead user IDs. + * encrypt.c (_gpgme_encrypt_status_handler): Change errors + returned to GPGME_Invalid_Key and GPGME_General_Error. + +2003-05-28 Marcus Brinkmann + + * engine-gpgsm.c: Rename GpgsmObject to engine_gpgsm_t. + (struct gpgsm_object_s): Rename to struct engine_gpgsm. + * rungpg.c: Rename GpgObject to engine_gpg_t. + (struct gpg_object_s): Rename to struct engine_gpg. + + * context.h (struct gpgme_context): Change EngineObject to + engine_object_t. + (enum ctx_op_data_type): Rename to ctx_op_data_id_t. + (ctx_op_data_t): New type. + (struct gpgme_context): Use it. + * ops.h (_gpgme_op_data_lookup): Use new type name. + * op-support.c (_gpgme_op_data_lookup): Likewise. + * engine.c: Rename EngineObject to engine_t in the file. Also + EngineStatusHandler to engine_status_handler_t, + EngineCommandHandler to engine_command_handler_t and + EngineColonLineHandler to engine_colon_line_handler. + * rungpg.c (start): Likewise. + * engine-gpgsm.c: Likewise. + * engine-backend.h (struct engine_ops): Likewise + * engine.h (struct engine_object_s): Rename to struct engine. + (EngineObject): Rename to engine_t. Also everywhere else in the + file. + (EngineStatusHandler): Rename to engine_status_handler_t. + (EngineColonLineHandler): Rename to engine_colon_line_handler_t. + (EngineCommandHandler): Rename to engine_command_handler_t. + + * engine-gpgsm.c (gpgsm_export): Fix bug in last change. + + * Makefile.am (libgpgme_la_SOURCES): Remove recipient.c, add + user-id.c. + * gpgme.h (gpgme_recipients_t): Removed. + (gpgme_recipients_new, gpgme_recipients_release, + gpgme_recipients_add_name, + gpgme_recipients_add_name_with_validity, gpgme_recipients_count, + gpgme_recipients_enum_open, gpgme_recipients_enum_read, + gpgme_recipients_enum_close): Removed. + (gpgme_op_encrypt, gpgme_op_encrypt_start, gpgme_op_encrypt_sign, + gpgme_op_encrypt_sign_start, gpgme_op_export_start, + gpgme_op_export): Change second argument to gpgme_user_id_t. + (gpgme_user_ids_release): New prototype. + (gpgme_user_ids_append): Likewise. + * ops.h (_gpgme_recipients_all_valid): Remove. + (_gpgme_user_ids_all_valid): Add. + * context.h (struct gpgme_recipients): Removed. + * user-id.c: New file. + * recipient.c: Removed file. + * rungpg.c (append_args_from_recipients): Change last arg to + gpgme_user_id_t. Reimplement. + (gpg_encrypt): Change second arg to gpgme_user_id_t. + (gpg_encrypt_sign): Likewise. + (gpg_export): Likewise. Rewrite user ID list code. + * engine.c (_gpgme_engine_op_encrypt): Change second arg to + gpgme_user_id_t. + (_gpgme_engine_op_encrypt_sign): Likewise. + (_gpgme_engine_op_export): Likewise. + * engine.h (_gpgme_engine_op_encrypt, _gpgme_engine_op_encrypt_sign, + _gpgme_engine_op_export): Likewise. + * engine-gpgsm.c (set_recipients): Likewise. Rewrite loop code. + (gpgsm_encrypt): Likewise. + (gpgsm_export): Likewise. + * engine-backend.h (struct engine_ops): Likewise for members + ENCRYPT, ENCRYPT_SIGN and EXPORT. + * export.c (export_start, gpgme_op_export_start, gpgme_op_export): + Likewise. + * encrypt.c (encrypt_start): Likewise. Don't check for count of + recipients. + (gpgme_op_encrypt_start): Likewise. + (gpgme_op_encrypt): Likewise. + * encrypt-sign.c (encrypt_sign_start): Likewise. + (gpgme_op_encrypt_sign): Likewise. + (gpgme_op_encrypt_sign_start): Likewise. + +2003-05-27 Marcus Brinkmann + + * gpgme.h (struct _gpgme_op_import_result): Add skipped_new_keys. + * import.c (parse_import_res): Add skipped_new_keys parser. + + * op-support.c (_gpgme_parse_inv_userid): Add missing break + statements. + * encrypt.c (gpgme_op_encrypt): Use gpgme_error_t instead of int. + +2003-05-27 Marcus Brinkmann + + * encrypt.c (gpgme_op_encrypt_result): Use intermediate variable + HOOK to avoid compiler warning. Don't ask, you don't want to know. + (_gpgme_encrypt_status_handler): Likewise. + (_gpgme_op_encrypt_init_result): Likewise. + * decrypt.c (gpgme_op_decrypt_result): Likewise. + (_gpgme_decrypt_status_handler): Likewise. + (_gpgme_op_decrypt_init_result): Likewise. + * verify.c (gpgme_op_verify_result): Likewise. + (_gpgme_verify_status_handler): Likewise. + (_gpgme_op_verify_init_result): Likewise. + * edit.c (edit_status_handler): Likewise. + (command_handler): Likewise. + (edit_start): Likewise. + * genkey.c (gpgme_op_genkey_result): Likewise. + (genkey_status_handler): Likewise. + (genkey_start): Likewise. + * import.c (gpgme_op_import_result): Likewise. + (import_status_handler): Likewise. + (_gpgme_op_import_start): Likewise. + * trustlist.c (gpgme_op_trustlist_next): Likewise. + (_gpgme_op_trustlist_event_cb): Likewise. + (gpgme_op_trustlist_start): Likewise. + * keylist.c (gpgme_op_keylist_result): Likewise. + (keylist_colon_handler): Likewise. + (keylist_status_handler): Likewise. + (_gpgme_op_keylist_event_cb): Likewise. + (gpgme_op_keylist_start): Likewise. + (gpgme_op_keylist_ext_start): Likewise. + (gpgme_op_keylist_next): Likewise. + * passphrase.c (_gpgme_passphrase_status_handler): Likewise. + (_gpgme_passphrase_command_handler_internal): Likewise. + * sign.c (gpgme_op_sign_result): Likewise. + (_gpgme_sign_status_handler): Likewise. + (_gpgme_op_sign_init_result): Likewise. + + * passphrase.c (_gpgme_passphrase_command_handler_internal): Fix + access to pointer type. + +2003-05-26 Marcus Brinkmann + + * engine.h (EngineCommandHandler): Change last argument to int fd. + * gpgme.h (gpgme_passphrase_cb_t): Rewritten to take parts of the + description and fd. + (gpgme_edit_cb_t): Change last argument to int fd. + * ops.h (_gpgme_passphrase_command_handler_internal): New prototype. + * passphrase.c: Include . + (op_data_t): Rename userid_hint to uid_hint, remove last_pw_handle. + (release_op_data): Check values before calling free. + (_gpgme_passphrase_status_handler): Likewise. + (_gpgme_passphrase_command_handler_internal): New function. + (_gpgme_passphrase_command_handler): Rewritten. + * edit.c (edit_status_handler): Pass -1 as fd argument. + (command_handler): Update prototype. New variable processed. Use + it to store return value of + _gpgme_passphrase_command_handler_internal which is now used + instead _gpgme_passphrase_command_handler. Use it also to check + if we should call the user's edit function. Pass fd to user's + edit function. + * rungpg.c (struct gpg_object_s): Change type of cmd.cb_data to + void *. + (gpg_release): Check value before calling free. Do not release + cmd.cb_data. + (command_cb): Function removed. + (command_handler): New function. Thus we don't use a data object + for command handler stuff anymore, but handle it directly. This + allows proper error reporting (cancel of passphrase requests, for + example). Also all callbacks work via direct writes to the file + descriptor (so that passphrases are not kept in insecure memory). + (gpg_set_command_handler): Rewritten to use even more ugly hacks. + (read_status): Check cmd.keyword before calling free. Install + command_handler as the I/O callback handler with GPG as private + data. + + * rungpg.c (gpg_new): Add --enable-progress-filter to gpg + invocation. + * decrypt-verify.c (_gpgme_op_decrypt_verify_start): Rename to + decrypt_verify_start. + (gpgme_op_decrypt_verify_start): Call decrypt_verify_start. + (gpgme_op_decrypt_verify): Likewise. + * verify.c (verify_status_handler): New function that also calls + progress status handler. + (_gpgme_op_verify_start): Set status handler to verify_status_handler. + Rename to (verify_start). + (gpgme_op_verify_start): Call verify_start. + (gpgme_op_verify): Likewise. + * encrypt.c (encrypt_status_handler): New function. + (_gpgme_encrypt_sym_status_handler): Call progress status handler. + Make static. Rename to encrypt_sym_status_handler. + (encrypt_start): Set status handler to encrypt_sym_status_handler + or encrypt_status_handler. + * sign.c (sign_status_handler): New function. + (sign_start): Set status handler to sign_status_handler. + * decrypt.c (decrypt_status_handler): New function that also calls + progress status handler. + (decrypt_start): Set status handler to decrypt_status_handler. + * encrypt-sign.c (encrypt_sign_status_handler): Likewise. + * decrypt-verify.c (decrypt_verify_status_handler): Call + _gpgme_progress_status_handler. + + * conversion.c (_gpgme_decode_c_string): Add missing break + statement. + + * recipient.c (gpgme_recipients_add_name_with_validity): Add one + to buffer to allocate. + +2003-05-19 Marcus Brinkmann + + * verify.c (parse_new_sig): Fix ERRSIG case. + Submitted by Benjamin Lee . + +2003-05-18 Marcus Brinkmann + + * gpgme.h: The following types are renamed. The old name is kept + as a deprecated typedef. + (GpgmeCtx): Rename to gpgme_ctx_t. + (GpgmeData): Rename to gpgme_data_t. + (GpgmeRecipients): Rename to gpgme_recipients_t. + (GpgmeError): Rename to gpgme_error_t. + (GpgmeDataEncoding): Rename to gpgme_data_encoding_t. + (GpgmePubKeyAlgo): Rename to gpgme_pubkey_algo_t. + (GpgmeHashAlgo): Rename to gpgme_hash_algo_t. + (GpgmeSigStat): Rename to gpgme_sig_stat_t. + (GpgmeSigMode): Rename to gpgme_sig_mode_t. + (GpgmeAttr): Rename to gpgme_attr_t. + (GpgmeValidity): Rename to gpgme_validity_t. + (GpgmeProtocol): Rename to gpgme_protocol_t. + (GpgmeStatusCode): Rename to gpgme_status_code_t. + (GpgmeEngineInfo): Rename to gpgme_engine_info_t. + (GpgmeSubkey): Rename to gpgme_subkey_t. + (GpgmeKeySig): Rename to gpgme_keysig_t. + (GpgmeUserID): Rename to gpgme_user_id_t. + (GpgmePassphraseCb): Rename to gpgme_passphrase_cb_t. + (GpgmeProgressCb): Rename to gpgme_progress_cb_t. + (GpgmeEditCb): Rename to gpgme_edit_cb_t. + (GpgmeIOCb): Rename to gpgme_io_cb_t. + (GpgmeRegisterIOCb): Rename to gpgme_register_io_cb_t. + (GpgmeRemoveIOCb): Rename to gpgme_remove_io_cb_t. + (GpgmeEventIO): Rename to gpgme_event_io_t. + (GpgmeEventIOCb): Rename to gpgme_event_io_cb_t. + (GpgmeIOCbs): Rename to gpgme_io_cbs. + (gpgme_io_cbs_t): New type. + (GpgmeDataReadCb): Rename to gpgme_data_read_cb_t. + (GpgmeDataWriteCb): Rename to gpgme_data_write_cb_t. + (GpgmeDataSeekCb): Rename to gpgme_data_seek_cb_t. + (GpgmeDataReleaseCb): Rename to gpgme_data_release_cb_t. + (GpgmeDataCbs): Rename to gpgme_data_cbs. + (gpgme_data_cbs_t): New type. + (GpgmeInvalidUserID): Rename to gpgme_invalid_user_id_t. + (GpgmeEncryptResult): Rename to gpgme_encrypt_result_t. + (GpgmeDecryptResult): Rename to gpgme_decrypt_result_t. + (GpgmeNewSignature): Rename to gpgme_new_signature_t. + (GpgmeSignResult): Rename to gpgme_sign_result_t. + (GpgmeSigNotation): Rename to gpgme_sig_notation_t. + (GpgmeSignature): Rename to gpgme_signature_t. + (GpgmeVerifyResult): Rename to gpgme_verify_result_t. + (GpgmeImportStatus): Rename to gpgme_import_status_t. + (GpgmeImportResult): Rename to gpgme_import_result_t. + (GpgmeGenKeyResult): Rename to gpgme_genkey_result_t. + (GpgmeKeyListResult): Rename to gpgme_keylist_result_t. + (GpgmeTrustItem): Rename to gpgme_trust_item_t. + * gpgme.h (gpgme_deprecated_error_t): New type, swallowing macros + GPGME_No_Recipients, GPGME_Invalid_Recipient and + GPGME_No_Passphrase. + * data.h (struct gpgme_data_s): Rename to struct gpgme_data. + * context.h (struct gpgme_context_s): Rename to struct + gpgme_context. + (struct gpgme_recipients_s): Rename to gpgme_recipients. + +2003-05-18 Marcus Brinkmann + + * keylist.c (finish_key): Clear OPD->tmp_uid. + +2003-05-18 Marcus Brinkmann + + * verify.c (_gpgme_verify_status_handler): Return GPGME_No_Data + for NODATA status without signatures. + +2003-05-05 Marcus Brinkmann + + * key.c (_gpgme_key_append_name): Use decoded string to parse user id. + (_gpgme_key_add_sig): Likewise. + +2003-05-04 Marcus Brinkmann + + * context.h (struct gpgme_context_s): Remove member op_info. + + * key.c (_gpgme_key_add_sig): Initialize SIG->uid. + + * gpgme.h (GpgmeError): Add deprecated values for + GPGME_Invalid_Type and GPGME_Invalid_Mode. + +2003-04-30 Marcus Brinkmann + + * gpgme.h (gpgme_get_op_info): Remove prototype. + * ops.h (_gpgme_set_op_info, + _gpgme_data_release_and_return_string, _gpgme_data_get_as_string, + _gpgme_data_append, _gpgme_data_append_string, + _gpgme_data_append_string_for_xml, _gpgme_data_append_for_xml, + _gpgme_data_append_percentstring_for_xml): Likewise. + (_gpgme_progress_status_handler): Change first arg to void *. + * progress.c (_gpgme_progress_status_handler): Likewise. + * conversion.c: Do not include , , , + and , but . + (_gpgme_data_append): Remove function. + (_gpgme_data_append_string): Likewise. + (_gpgme_data_append_for_xml): Likewise. + (_gpgme_data_append_string_for_xml): Likewise. + (_gpgme_data_append_percentstring_for_xml): Likewise. + * data-mem.c (_gpgme_data_get_as_string): Likewise. + (_gpgme_data_release_and_return_string): Likewise. + * gpgme.c (gpgme_get_op_info): Likewise. + (_gpgme_set_op_info): Likewise. + + * gpgme.h (struct _gpgme_key): New structure. + (GpgmeKey): Define using _gpgme_key. + (struct _gpgme_subkey): New structure. + (GpgmeSubKey): New type. + (struct _gpgme_key_sig): New structure. + (GpgmeKeySig): New type. + (struct _gpgme_user_id): New structure. + (GpgmeUserID): New type. + (struct _gpgme_op_keylist_result): New structure. + (GpgmeKeyListResult): New type. + (gpgme_op_keylist_result): New function. + (gpgme_key_get_as_xml): Remove prototype. + * context.h (struct gpgme_context_s): Remove members tmp_key, + tmp_uid, key_cond and key_queue. + (struct key_queue_item_s): Remove structure. + (struct user_id_s): Remove structure. + (struct gpgme_recipients_s): Replace with simple + GpgmeUserID list. + * gpgme.c (gpgme_release): Do not release CTX->tmp_key. + * ops.h (_gpgme_key_add_subkey, _gpgme_key_append_name, + _gpgme_key_add_sig, _gpgme_trust_item_new): New prototypes. + * rungpg.c (command_cb): Return GpgmeError instead int. + New variable ERR. Use it to hold return value of cmd handler. + (gpg_delete): Access fingerprint of key directly. + (append_args_from_signers): Likewise. + (gpg_edit): Likewise. + (append_args_from_recipients): Use GpgmeUserID for recipient list. + * engine-gpgsm.c: Do not include "key.h". + (gpgsm_delete): Access fingerprint of key directly. + (gpgsm_sign): Likewise. + (set_recipients): Use GpgmeUserID for recipients. Invert invalid + user ID flag. + * key.h: File removed. + * key.c: Completely reworked to use exposed GpgmeKey data types. + * keylist.c: Likewise. + * recipient.c: Completely reworked to use GpgmeUserID. + +2003-04-29 Marcus Brinkmann + + * gpgme.h (gpgme_get_key): Remove force_update argument. + * key-cache.c: File removed. + * Makefile.am (libgpgme_la_SOURCES): Remove key-cache.c. + * ops.h (_gpgme_key_cache_add, _gpgme_key_cache_get): Remove + prototypes. + * keylist.c (_gpgme_op_keylist_event_cb): Don't call + _gpgme_key_cache_add. + (gpgme_get_key): New function. + * verify.c (gpgme_get_sig_key): Remove last argument to + gpgme_get_key invocation. + + * gpgme.h (struct _gpgme_trust_item): New structure. + (GpgmeTrustItem): New type. + (gpgme_trust_item_ref, gpgme_trust_item_unref): New prototypes. + * context.h (struct trust_queue_item_s): Remove structure. + (struct gpgme_context_s): Remove trust_queue member. + * Makefile.am (libgpgme_la_SOURCES): Add trust-item.c. + * trust-item.c: New file. + * trustlist.c: Do not include or , but + "gpgme.h". + (struct trust_queue_item_s): Change to new type op_data_t. + (trust_status_handler): Change first argument to void *. + (trust_colon_handler): Likewise. + (_gpgme_op_trustlist_event_cb): Use op_data_t type. + (gpgme_op_trustlist_start): Use op_data_t and rework error + handling. + (gpgme_op_trustlist_next): Use op_data_t. + (gpgme_trust_item_release): Remove function. + (gpgme_trust_item_get_string_attr): Likewise. + (gpgme_trust_item_get_int_attr): Likewise. + + * verify.c (calc_sig_summary): Do not set GPGME_SIGSUM_SYS_ERROR + for bad signatures. + +2003-04-28 Marcus Brinkmann + + * context.h: Remove OPDATA_VERIFY_COLLECTING. + (struct gpgme_context_s): Remove member notation. + * gpgme.h: Make enum for GPGME_KEYLIST_MODE_* values. + + * gpgme.h (struct _gpgme_sig_notation): New structure. + (GpgmeSigNotation): New type. + (struct _gpgme_signature): New structure. + (GpgmeSignature): New type. + (struct _gpgme_op_verify_result): New structure. + (GpgmeVerifyResult): New type. + (gpgme_op_verify_result): New prototype. + (gpgme_get_notation): Remove prototype. + * ops.h (_gpgme_op_verify_init_result): New prototype. + (_gpgme_verify_status_handler): Change first argument to void *. + * util.h (_gpgme_decode_percent_string, _gpgme_map_gnupg_error): + New prototypes. + * conversion.c (_gpgme_decode_percent_string): New function. + (gnupg_errors): New static global. + (_gpgme_map_gnupg_error): New function. + * gpgme.c (gpgme_release): Don't release CTX->notation. + (gpgme_get_notation): Remove function. + * decrypt-verify.c (_gpgme_op_decrypt_verify_start): Call + _gpgme_op_verify_init_result. + * verify.c: Do not include , and "key.h", but + do include "gpgme.h". + (struct verify_result): Replace with ... + (op_data_t): ... this type. + (release_verify_result): Remove function. + (release_op_data): New function. + (is_token): Remove function. + (skip_token): Remove function. + (copy_token): Remove function. + (gpgme_op_verify_result): New function. + (calc_sig_summary): Rewritten. + (finish_sig): Remove function. + (parse_new_sig): New function. + (parse_valid_sig): New function. + (parse_notation): New function. + (parse_trust): New function. + (parse_error): New function. + (_gpgme_verify_status_handler): Rewritten. Change first argument + to void *. + (_gpgme_op_verify_start): Rework error handling. Call + _gpgme_op_verify_init_result. + (gpgme_op_verify): Do not release or clear CTX->notation. + (gpgme_get_sig_status): Rewritten. + (gpgme_get_sig_string_attr): Likewise. + (gpgme_get_sig_ulong_attr): Likewise. + (gpgme_get_sig_key): Likewise. + + * gpgme.h (struct _gpgme_op_decrypt_result): New structure. + (GpgmeDecryptResult): New type. + (gpgme_op_decrypt_result): New prototype. + * ops.h (_gpgme_op_decrypt_init_result): New prototype. + (_gpgme_decrypt_status_handler): Fix prototype. + (_gpgme_decrypt_start): Remove prototype. + * decrypt-verify.c: Do not include , , + and , "util.h" and "context.h", but + "gpgme.h". + (decrypt_verify_status_handler): Change first argument to void *, + and rework error handling. + (_gpgme_op_decrypt_verify_start): New function. + (gpgme_op_decrypt_verify_start): Rewrite using + _gpgme_op_decrypt_verify_start. + (gpgme_op_decrypt_verify): Likewise. + * decrypt.c: Include , "gpgme.h" and "util.h". + (struct decrypt_result): Change to typedef op_data_t, rewritten. + (is_token): Remove function. + (release_op_data): New function. + (skip_token): Remove function. + (gpgme_op_decrypt_result): New function. + (_gpgme_decrypt_status_handler): Change first argument to void *. + Rework error handling. + (_gpgme_decrypt_start): Rename to ... + (decrypt_start): ... this. Call _gpgme_op_decrypt_init_result. + (_gpgme_op_decrypt_init_result): New function. + (gpgme_op_decrypt_start): Use decrypt_start. + (gpgme_op_decrypt): Likewise. + +2003-04-27 Marcus Brinkmann + + * encrypt-sign.c: Do not include , , + , , and "util.h", but "gpgme.h". + (_gpgme_op_encrypt_sign_start): Rename to ... + (encrypt_sign_start): ... this. + (gpgme_op_encrypt_sign_start): Use encrypt_sign_start, not + _gpgme_op_encrypt_sign_start. + (gpgme_op_encrypt_sign): Likewise. + + * gpgme.h (GpgmeEncryptResult): New data type. + (gpgme_op_encrypt_result): New prototype. + * ops.h (_gpgme_op_encrypt_init_result): New prototype. + (_gpgme_op_encrypt_status_handler): Fix prototype. + * encrypt-sign.c (_gpgme_op_encrypt_sign_start): Call + _gpgme_op_encrypt_init_result. + * encrypt.c: Do not include , , "util.h" and + "wait.h". Include and "gpgme.h". + (SKIP_TOKEN_OR_RETURN): Remove macro. + (struct encrypt_result): Rename to ... + (op_data_t): ... new data type. Rewrite for user result data. + (append_xml_encinfo): Remove function. + (release_op_data): New function. + (gpgme_op_encrypt_result): New function. + (_gpgme_op_encrypt_status_handler): Change first argument to void *. + Rewrite result parsing. + (_gpgme_op_encrypt_sym_status_handler): Change first argument to + void *. + (_gpgme_op_encrypt_init_result): New function. + (_gpgme_op_encrypt_start): Rename to ... + (encrypt_start): ... this. + (gpgme_op_encrypt_start): Use encrypt_start, not + gpgme_op_encrypt_start. + (gpgme_op_encrypt): Likewise. + + * gpgme.h (GpgmePubKeyAlgo, GpgmeHashAlgo, GpgmeInvalidUserID, + GpgmeNewSignature, GpgmeSignResult): New data types. + (gpgme_op_sign_result, gpgme_pubkey_algo_name, + gpgme_hash_algo_name): New prototypes. + * gpgme.c (gpgme_pubkey_algo_name): New function. + (gpgme_hash_algo_name): Likewise. + * ops.h (_gpgme_parse_inv_userid, _gpgme_op_sign_init_result): New + prototype. + (_gpgme_op_sign_status_handler): Fix prototype. + * op-support.c: Include and . + (_gpgme_parse_inv_userid): New function. + * sign.c: Include and "gpgme.h", but not , + and "util.h". + (SKIP_TOKEN_OR_RETURN): Remove macro. + (struct sign_result): Change to op_data_t type and rework it. + (release_sign_result): Rename to ... + (release_op_data): ... this and rewrite it. + (append_xml_info): Remove function. + (gpgme_op_sign_result): New function. + (parse_sig_created): New function. + (_gpgme_sign_status_handler): Change first argument to void *. + Rewrite the function to use the new result structure and functions. + (_gpgme_op_sign_init_result): New function. + (_gpgme_op_sign_start): Rename to ... + (sign_start): ... this. Call _gpgme_op_sign_init_result. + (gpgme_op_sign_start): Use sign_start instead _gpgme_op_sign_start. + (gpgme_op_sign): Likewise. + * encrypt-sign.c (_gpgme_op_encrypt_sign_start): Call + _gpgme_op_sign_init_result. + + * delete.c: Include and "gpgme.h", but not "util.h" or + "key.h". + (enum delete_problem): Move into function delete_status_handler. + (delete_status_handler): Change first argument to void *. Parse + delete problem with strtol instead atoi. Return better error + values. + (_gpgme_op_delete_start): Rename to ... + (delete_start): ... this. Rework error handling. + (gpgme_op_delete_start): Use delete_start instead + _gpgme_op_delete_start. + (gpgme_op_delete): Likewise. + * gpgme.h (GpgmeDataType): Removed. + +2003-04-25 Marcus Brinkmann + + * gpgme.h: Change GPGME_IMPORT_PRIVATE to GPGME_IMPORT_SECRET. + * import.c (parse_import_res): Parse unchanged field. + + * gpgme.h: New enum for GPGME_IMPORT_NEW, GPGME_IMPORT_UID, + GPGME_IMPORT_SIG, GPGME_IMPORT_SUBKEY, GPGME_IMPORT_PRIVATE. + (GpgmeError): 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 added as new error codes. + (struct _gpgme_import_status): New structure. + (GpgmeImportStatus): New type. + (struct _gpgme_op_import_result): New structure. + (GpgmeImportResult): New type. + (gpgme_op_import_result): New function. + * import.c: Include and "gpgme.h", but not "util.h". + (struct import_result): Change to type op_data_t. + (release_import_result): Rename to ... + (release_op_data): ... this. + (append_xml_impinfo): Function removed. + (gpgme_op_import_result): New function. + (parse_import): New function. + (parse_import_res): Likewise. + (import_status_handler): Change first argument to void *. Rewrite + to use new functions. + (_gpgme_op_import_start): Rework error handling. + + * edit.c: Do not include , "util.h", but "gpgme.h". + (edit_resut): Change to typedef for op_data_t. + (edit_status_handler): Change first argument to void *. + Rework error handling. + (command_handler): Rework error handling. + (_gpgme_op_edit_start): Rename to ... + (edit_start): ... this. Rework error handling. + (gpgme_op_edit_start): Rewrite using edit_start. + (gpgme_op_edit): Likewise. + + * ops.h (_gpgme_passphrase_start): Remove prototype. + * passphrase.c: Do not include , "util.h" or + "debug.h", but "gpgme.h". + (struct passphrase_result): Change to typedef for op_data_t. + (release_passphrase_result): Rename to release_op_data. + (_gpgme_passphrase_status_handler): Change first argument to void *. + Use new op_data_t type. + (_gpgme_passphrase_command_handler): Use new op_data_t type. + (_gpgme_passphrase_start): Remove function. + * decrypt.c (_gpgme_decrypt_start): Rewrite error handling. Do + not call _gpgme_passphrase_start, but install command handler. + * encrypt.c (_gpgme_op_encrypt_start): Likewise. + * encrypt-sign.c (_gpgme_op_encrypt_sign_start): Likewise. + * sign.c (_gpgme_op_sign_start): Likewise. + + * context.h (struct gpgme_context_s): Remove member initialized, + use_cms and help_data_1. Add member protocol. Make use_armor and + use_textmode bit flags. Make keylist_mode, include_certs, + signers_len and signers_size unsigned. + * gpgme.c (gpgme_new): Initialize CTX->protocol. + (gpgme_set_protocol): Do not check CTX. Use CTX->protocol. + (gpgme_get_protocol): Likewise. + (gpgme_release): Do not release CTX->help_data_1. + * op-support.c (_gpgme_op_reset): Use CTX->protocol. + + * wait-private.c (_gpgme_wait_private_event_cb): Remove variable CTX. + + * data.c: Do not include , but "gpgme.h". + (_gpgme_data_inbound_handler): Expand _gpgme_data_append, because + it will go. Do not assert DH. + (_gpgme_data_outbound_handler): Do not assert DH. + + * export.c: Do not include , "debug.h" and "util.h", but + "gpgme.h". + (export_status_handler): Change type of first argument to void *. + (_gpgme_op_export_start): Rename to ... + (export_start): ... this. Rework error handling. + (gpgme_op_export_start): Rewritten to use export_start instead + _gpgme_op_export_start. + (gpgme_op_export): Likewise. + + * gpgme.h (GpgmeError): Add GPGME_Busy, GPGME_No_Request. + (GPGME_No_Recipients, GPGME_Invalid_Recipient, + GPGME_No_Passphrase): New macros. + + * key.c (gpgme_key_get_string_attr): Fix validity attribute. + +2003-04-24 Marcus Brinkmann + + * gpgme.h (struct _gpgme_op_genkey_result): New structure. + (GpgmeGenKeyResult): New type. + (gpgme_op_genkey): Drop last argument. + (gpgme_op_genkey_result): New function. + * genkey.c: Do not include "util.h", but "gpgme.h". + (struct genkey_result): Replace with ... + (op_data_t): ... this new type. + (release_genkey_result): Replace with ... + (release_op_data): ... this new function. + (gpgme_op_genkey_result): New function. + (genkey_status_handler): Rewritten using new op_data_t type. + (get_key_parameter): New function. + (_gpgme_op_genkey_start): Renamed to + (genkey_start): ... this and rewritten. + (gpgme_op_genkey_start): Use genkey_start instead + _gpgme_op_genkey_start. + (gpgme_op_genkey): Rewritten. Remove FPR argument. + + * context.h (struct gpgme_context_s): Remove member verbosity. + * gpgme.c (gpgme_new): Do not set member verbosity. + * engine.h (_gpgme_engine_set_verbosity): Remove prototype. + * engine.c (_gpgme_engine_set_verbosity): Remove function. + * engine-backend.h (struct engine_ops): Remove set_verbosity. + * engine-gpgsm.c (_gpgme_engine_ops_gpgsm): Remove set_verbosity member. + * rungpg.c (_gpgme_engine_ops_gpg): Likewise. + (gpg_set_verbosity): Remove function. + * decrypt.c (_gpgme_decrypt_start): Don't call + _gpgme_engine_set_verbosity. + * delete.c (_gpgme_op_delete_start): Likewise. + * edit.c (_gpgme_op_edit_start): Likewise. + * encrypt.c (_gpgme_op_encrypt_start): Likewise. + * encrypt-sign.c (_gpgme_op_encrypt_sign_start): Likewise. + * export.c (_gpgme_op_export_start): Likewise. + * genkey.c (_gpgme_op_genkey_start): Likewise. + * import.c (_gpgme_op_import_start): Likewise. + * keylist.c (gpgme_op_keylist_start): Likewise. + (gpgme_op_keylist_ext_start): Likewise. + * sign.c (_gpgme_op_sign_start): Likewise. + * verify.c (_gpgme_op_verify_start): Likewise. + + * Makefile.am (libgpgme_la_SOURCES): Add key-cache.c. + * key.c (key_cache_initialized, key_cache_size, + key_cache_max_chain_length, ): Removed. + (struct key_cache_item_s, key_cache_lock, key_cache, + key_cache_unused_items, hash_key, _gpgme_key_cache_add, + _gpgme_key_cache_get, gpgme_get_key): Moved to ... + * key-cache.c: ... here. New file. + * key.h (_gpgme_key_cache_init): Remove prototypes. + (_gpgme_key_cache_add,_gpgme_key_cache_get): Move to ... + * ops.h: ... here. + * version.c: Do not include "key.h". + (do_subsystem_inits): Do not call _gpgme_key_cache_init. + + * mkstatus: Strip trailing comma. + * gpgme.h (GpgmeStatus): Pretty print. + + * gpgme.h (GpgmeError): Rename GPGME_No_Passphrase to + GPGME_Bad_Passphrase. + * passphrase.c (_gpgme_passphrase_status_handler): Use + GPGME_Bad_Passphrase instead GPGME_No_Passphrase. + + * gpgme.h (GpgmeError): Rename GPGME_No_Recipients to + GPGME_No_UserID and GPGME_Invalid_Recipient to + GPGME_Invalid_UserID. + * encrypt.c (_gpgme_encrypt_status_handler): Use GPGME_No_UserID + instead GPGME_No_Recipients and GPGME_Invalid_UserID instead + GPGME_Invalid_Recipient. + (_gpgme_op_encrypt_start): Likewise. + + * gpgme.h (GpgmeError): Remove GPGME_Busy and GPGME_No_Request. + * wait-user.c (_gpgme_wait_user_event_cb): Don't clear CTX->pending. + * wait-private.c (_gpgme_wait_private_event_cb): Likewise. + * wait-global.c (gpgme_wait): Likewise. + * verify.c (_gpgme_op_verify_start): Likewise. + (gpgme_get_sig_status): Don't check pending flag. + (gpgme_get_sig_string_attr): Likewise. + (gpgme_get_sig_ulong_attr): Likewise. + (gpgme_get_sig_key): Likewise. + * op-support.c (_gpgme_op_reset): Likewise. + * trustlist.c (gpgme_op_trustlist_start): Don't clear pending flag. + (gpgme_op_trustlist_next): Don't check or clear pending flag. + (gpgme_op_trustlist_end): Likewise. + * sign.c (_gpgme_op_sign_start): Likewise. + * context.h (struct gpgme_context_s): Remove member PENDING. + * decrypt.c (_gpgme_decrypt_start): Likewise. + * delete.c (_gpgme_op_delete_start): Likewise. + * edit.c (_gpgme_op_edit_start): Likewise. + * encrypt.c (_gpgme_op_encrypt_start): Likewise. + * encrypt-sign.c (_gpgme_op_encrypt_sign_start): Likewise. + * export.c (_gpgme_op_export_start): Likewise. + * genkey.c (_gpgme_op_genkey_start): Likewise. + * import.c (_gpgme_op_import_start): Likewise. + * key.c (gpgme_get_key): Likewise. + * keylist.c (gpgme_op_keylist_start): Likewise. + (gpgme_op_keylist_ext_start): Likewise. + (gpgme_op_keylist_next): Likewise. + (gpgme_op_keylist_end): Likewise. + * data-compat.c (gpgme_error_to_errno): Don't convert EBUSY. + +2003-02-06 Marcus Brinkmann + + * gpgme.h (GpgmePassphraseCb): Change type to return GpgmeError, + and add argument for returning the result string. + (gpgme_cancel): Remove prototype. + * gpgme.c (gpgme_cancel): Remove function. + * context.h (struct gpgme_context_s): Remove member cancel. + * passphrase.c (_gpgme_passphrase_command_handler): Call the + passphrase callback in the new way. + +2003-01-30 Marcus Brinkmann + + * edit.c (_gpgme_edit_status_handler): Call the progress status + handler. + +2003-02-05 Marcus Brinkmann + + * wait-user.c (_gpgme_wait_user_remove_io_cb): Move check for no + I/O handlers left to ... + (_gpgme_user_io_cb_handler): ... here. + +2003-02-04 Marcus Brinkmann + + * trustlist.c (trustlist_colon_handler): Release ITEM if name + could not be allocated. + (gpgme_trust_item_release): Only release name if it is allocated. + Reported by Marc Mutz . + +2003-02-04 Marcus Brinkmann + + * rungpg.c (read_status): If he status handler returns an error, + return it. + (status_handler): If read_status fails, just return the error. + +2003-02-01 Marcus Brinkmann + + * engine-gpgsm.c (start): Handle all errors, not only most of + them. + (xtoi_1, xtoi_2): Remove macro. + (status_handler): Replace use of xtoi_2 with _gpgme_hextobyte. + +2003-02-01 Marcus Brinkmann + + * engine-gpgsm.c (map_assuan_error): Replace + ASSUAN_Bad_Certificate_Path with ASSUAN_Bad_Certificate_Chain. + (gpgsm_new): Use assuan_pipe_connect instead assuan_pipe_connect2. + + * util.h (DIMof): Remove macro. + + * ops.h (_gpgme_op_event_cb, _gpgme_op_event_cb_user, + _gpgme_data_unread): Prototypes removed. + +2003-01-30 Marcus Brinkmann + + * types.h: File removed. + * Makefile.am (libgpgme_la_SOURCES): Remove types.h. + * io.h (struct spawn_fd_item_s): Do not include "types.h". + * key.h: Likewise. + * context.h: Likewise. + * cengine-gpgsm.h: Likewise. + * engine.h: Include "gpgme.h" instead "types.h". Add prototypes + for EngineStatusHandler, EngineColonLineHandler and + EngineCommandHandler. + (_gpgme_engine_set_status_handler): Change parameter type from + GpgmeStatusHandler to EngineStatusHandler. + (_gpgme_engine_set_command_handler): Change parameter type from + GpgmeCommandHandler to EngineCommandHandler. + (_gpgme_engine_set_colon_line_handler): Change parameter type from + GpgmeColonLineHandler to EngineColonLineHandler. + * engine-backend.h: Include "engine.h" instead "types.h". + (struct engine_ops): Change Gpgme*Handler parameters in members + set_command_handler, set_colon_line_handler and set_status_handler + to Engine*Handler. + * engine.c (_gpgme_engine_set_status_handler): Change parameter + type from GpgmeStatusHandler to EngineStatusHandler. + (_gpgme_engine_set_command_handler): Change parameter type from + GpgmeCommandHandler to EngineCommandHandler. + (_gpgme_engine_set_colon_line_handler): Change parameter type from + GpgmeColonLineHandler to EngineColonLineHandler. + * rungpg.c (struct gpg_object_s): Change type of member status.fnc + from GpgmeStatusHandler to EngineStatusHandler. Change type of + member colon.fnc from GpgmeColonLineHandler to + EngineColonLineHandler. Change type of member cmd.fnc from + GpgmeCommandHandler to EngineCommandHandler. + * engine-gpgsm.c (struct gpgsm_object_s): Likewise. + * rungpg.c (gpg_set_status_handler): Change parameter type from + GpgmeStatusHandler to EngineStatusHandler. + * engine-gpgsm.c (gpgsm_set_status_handler): Likewise. + (assuan_simple_command): Likewise. + * rungpg.c (gpg_set_colon_line_handler): Change parameter type + from GpgmeColonLineHandler to EngineColonLineHandler. + * engine-gpgsm.c (gpgsm_set_colon_line_handler): Likewise. + * rungpg.c (gpg_set_command_handler): Change parameter type from + GpgmeCommandHandler to EngineCommandHandler. + + * engine-gpgsm.c (status_handler): Do not close status fd at end + of function. + + * ops.h (_gpgme_op_data_lookup): Add prototype. + * op-support.c: Include . + (_gpgme_op_data_lookup): New function. + * decrypt.c (_gpgme_release_decrypt_result): Function removed. + (struct decrypt_result_s): Rename to ... + (struct decrypt_resul): ... this. + (DecryptResult): New type. + (_gpgme_decrypt_status_handler): Don't use + test_and_allocate_result, but use _gpgme_op_data_lookup to + retrieve result data object. + * sign.c (_gpgme_release_sign_result): Function removed. + (release_sign_result): New function. + (struct sign_result_s): Rename to ... + (struct sign_result): ... this. + (SignResult): New type. + (_gpgme_sign_status_handler): Don't use + test_and_allocate_result, but use _gpgme_op_data_lookup to + retrieve result data object. + * encrypt.c (struct encrypt_result_s): Rename to ... + (struct encrypt_result): ... this. + (_gpgme_release_encrypt_result): Function removed. + (release_encrypt_result): New function. + (_gpgme_encrypt_status_handler): Don't use + test_and_allocate_result, but use _gpgme_op_data_lookup to + retrieve result data object. + * verify.c (struct verify_result_s): Rename to ... + (struct verify_result): ... this. Remove member next. + (VerifyResult): New type. + (_gpgme_release_verify_result): Function removed. + (release_verify_result): New function. + (finish_sig): Change first argument to type VerifyResult. Diddle + the type of the op_data structure. + (add_notation): Change first argument to type VerifyResult. + (_gpgme_verify_status_handler): Don't use + test_and_allocate_result, but use _gpgme_op_data_lookup to + retrieve result data object. + * passphrase.c (struct passphrase_result_s): Rename to ... + (struct passphrase_result): ... this. Remove member next. + (PassphraseResult): New type. + (_gpgme_release_passphrase_result): Function removed. + (release_passphrase_result): New function. + (_gpgme_passphrase_status_handler): Don't use + test_and_allocate_result, but use _gpgme_op_data_lookup to + retrieve result data object. + (_gpgme_passphrase_command_handler): Likewise. + * keylist.c (struct keylist_result_s): Rename to ... + (struct keylist_result): ... this. Remove member next. + (KeylistResult): New type. + (_gpgme_release_keylist_result): Function removed. + (release_keylist_result): New function. + (keylist_status_handler): Don't use + test_and_allocate_result, but use _gpgme_op_data_lookup to + retrieve result data object. + * edit.c (struct edit_result_s): Rename to ... + (struct edit_result): ... this. Remove member next. + (EditResult): New type. + (_gpgme_release_edit_result): Function removed. + (release_edit_result): New function. + (edit_status_handler): Don't use + test_and_allocate_result, but use _gpgme_op_data_lookup to + retrieve result data object. + (command_handler): Likewise. + * types.h (DecryptResult, SignResult, EncryptResult, + PassphraseResult, ImportResult, DeleteResult, GenKeyResult, + KeylistResult, EditResult): Types removed. + * ops.h: Don't include "types.h", but "gpgme.h" and "context.h". + (test_and_allocate_result): Remove macro. + (_gpgme_release_decrypt_result): Remove prototype. + (_gpgme_decrypt_result): Remove prototype. + (_gpgme_release_sign_result): Remove prototype. + (_gpgme_release_encrypt_result): Remove prototype. + (_gpgme_release_passphrase_result): Remove prototype. + (_gpgme_release_import_result): Remove prototype. + (_gpgme_release_delete_result): Remove prototype. + (_gpgme_release_genkey_result): Remove prototype. + (_gpgme_release_keylist_result): Remove prototype. + (_gpgme_release_edit_result): Remove prototype. + (_gpgme_release_verify_result): Remove prototype. + * gpgme.c (_gpgme_release_result): Rewritten. + * context.h (enum ctx_op_data_type): New enum. + (struct ctx_op_data): New structure. + (struct gpgme_context_s): Replace the member result with a member + op_data. + (fail_on_pending_request): Remove macro. + * op-support.c (_gpgme_op_reset): Expand macro + fail_on_pending_request. + * util.h: Don't include "types.h" or "debug.h", but include "gpgme.h". + +2003-01-30 Marcus Brinkmann + + * types.h (EngineObject): Move typedef to ... + * engine.h: ... here. + * types.h (GpgObject): Move typedef to ... + * rungpg.c: ... here. + * types.h (GpgsmObject): Move typedef to ... + * engine-gpgsm.c: ... here. + + * util.h (return_if_fail, return_null_if_fail, + return_val_if_fail): Remove macro. + * gpgme.c (gpgme_cancel): Don't use return_if_fail. + * key.c (gpgme_key_ref): Likewise. + * signers.c (gpgme_signers_enum): Likewise. + (gpgme_signers_clear): Likewise. + + * engine-backend.h (struct engine_ops): Rename get_path to + get_file_name. + * gpgme.h (struct _gpgme_engine_info): Rename member path to + file_name. + * version.c: Do not include , , context.h and + util.h. Other clean ups. + (parse_version_number): Protect more seriously against + overflow. + (gpgme_get_engine_info): Move to ... + * engine.c (gpgme_get_engine_info): ... here. + (_gpgme_engine_get_info): Function removed. + (_gpgme_engine_get_path): Make static and rename to ... + (engine_get_file_name): .. this. + (_gpgme_engine_get_version): Make static and rename to ... + (engine_get_version): ... this. + (_gpgme_engine_get_req_version): Make static and rename to ... + (engine_get_req_version): ... this. + * engine.h (_gpgme_engine_get_path, _gpgme_engine_get_version, + _gpgme_engine_req_version, _gpgme_engine_get_info.): Remove + prototypes. + + * gpgme.h (enum GpgmeProtocol): Remove GPGME_PROTOCOL_AUTO. + * gpgme.c (gpgme_set_protocol): Don't handle GPGME_PROTOCOL_AUTO. + (gpgme_get_protocol_name): New function. + + * engine-backend.h (struct engine_ops): New member + get_req_version, remove member check_version. + * engine.h (_gpgme_Engine_get_version): New prototype. + * rungpg.c (gpg_get_req_version): New function. + (gpg_check_version): Function removed. + (_gpgme_engine_ops_gpg): Add gpg_get_req_version, remove + gpg_check_version. + * engine-gpgsm.c (gpgsm_get_req_version): New function. + (gpgsm_check_version): Function removed. + (_gpgme_engine_ops_gpgsm): Add gpgsm_get_req_version, remove + gpgsm_check_version. + * engine.c: Include ops.h. + (_gpgme_engine_get_req_version): New function. + (gpgme_engine_check_version): Rewritten. + * version.c (gpgme_get_engine_info): Rewritten. + * gpgme.h (gpgme_engine_info): New structure. + (GpgmeEngineInfo): New type. + +2003-01-29 Marcus Brinkmann + + * types.h: Remove byte and ulong types. + * util.h (_gpgme_hextobyte): Change prototype to unsigned char + instead byte. + * conversion.c (_gpgme_hextobyte): Change argument to unsigned + char instead byte. + (_gpgme_decode_c_string): Likewise, and beautify. Also support a + few more escaped characters. Be more strict about buffer size. + (_gpgme_data_append_percentstring_for_xml): Change type of SRC, + BUF and DST to unsigned char instead byte. + * progress.c (_gpgme_progress_status_handler): Use unsigned char + instead byte. + * debug.c (trim_spaces): Likewise. + + * util.h (mk_error): Remove macro. + * conversion.c, data.c, data-compat.c, decrypt.c, delete.c, + edit.c, encrypt.c, encrypt-sign.c, engine.c, engine-gpgsm.c, + export.c, genkey.c, gpgme.c, import.c, key.c, keylist.c, + passphrase.c, progress.c, recipient.c, rungpg.c, sign.c, + signers.c, trustlist.c, verify.c, wait.c, wait-global.c, + wait-private (literally everywhere): Expand the mk_error macro. + + * context.h (wait_on_request_or_fail): Remove macro. + + * context.h (gpgme_context_s): Remove member ERROR. + * types.h (GpgmeStatusHandler): Change return type to GpgmeError. + (GpgmeCommandHandler): Change return type to GpgmeError and add + new argument RESULT. + * gpgme.h (GpgmeIOCb): Change return type to GpgmeError. + (GpgmeEventIO): New event GPGME_EVENT_START. + (GpgmeIdleFunc): Remove type. + (gpgme_register_idle): Remove prototype. + * data.c: Include . + (_gpgme_data_inbound_handler): Change return type to GpgmeError. + Return any error instead ignoring it, don't close file descriptor + on error. + (_gpgme_data_outbound_handler): Likewise. + * decrypt.c: Do not include , and . + (_gpgme_decrypt_status_handler): Change return type to GpgmeError. + Return error instead setting ctx->error. Return success at end of + function. + (gpgme_op_decrypt): Don't work around the old kludge anymore. + * decrypt-verify.c (decrypt_verify_status_handler): Change return + type to GpgmeError. Return possible errors. + * delete.c: Do not include , , and + . + (delete_status_handler): Change return type to GpgmeError. Return + error instead setting ctx->error. Return success at end of + function. + * edit.c: Do not include and . + (_gpgme_edit_status_handler): Change type to GpgmeError, + make static and rename to ... + (edit_status_handler): ... this. Return error directly. + (command_handler): Change return type to GpgmeError, add result + argument. Return error directly. + * encrypt.c (status_handler_finish): Remove function. + (_gpgme_encrypt_status_handler): Change return type to GpgmeError. + Return error directly. + (_gpgme_encrypt_sym_status_handler): Likewise. + * encrypt-sign.c (encrypt_sign_status_handler): Likewise. + * engine-gpgsm.c (close_notify_handler): Do not signal done event + anymore. + (status_handler): Change return type to GpgmeError. Diddle things + around a bit to return errors directly. + (start): Send start event. + * export.c: Do not include , and . + (export_status_handler): Change return type to GpgmeError. Don't + check ctx->error. + * genkey.c: Do not include and . + (genkey_status_handler): Change return type to GpgmeError. Don't + check ctx->error. Return errors directly. + * gpgme.c (_gpgme_release_result): Do not initialize ctx->error. + (_gpgme_op_event_cb): Function removed. + (_gpgme_op_event_cb_user): Likewise. + * import.c: Do not include , and . + (import_status_handler): Change return type to GpgmeError. Don't + check ctx->error. + * keylist.c (keylist_colon_handler, keylist_status_handler, finish_key): + Change return type to GpgmeError, return error directly. + * Makefile (libgpgme_la_SOURCES): Add wait-global.c, + wait-private.c and wait-user.c + * ops.h (test_and_allocate_result): Return error instead setting + ctx->error. + (_gpgme_data_inbound_handler, _gpgme_data_outbound_handler, + _gpgme_verify_status_handler, _gpgme_decrypt_status_handler, + _gpgme_sign_status_handler, _gpgme_encrypt_staus_handler, + _gpgme_passphrase_status_handler, _gpgme_progress_status_handler): + Change return type to GpgmeError. + (_gpgme_passphease_command_handler): Change return type to + GpgmeError and add new argument RESULT. + * op-support.c: Use new callback functions, and change private + data to ctx everywhere. + * passphrase.c (_gpgme_passphrase_status_handler): Change return + type to GpgmeError, return error directly. + (_gpgme_passphrase_command_handler): Change return type to + GpgmeError, add result argument. Return results accordingly. + * progress.c (_gpgme_progress_status_handler): Change return type + to GpgmeError, return errors directly. + * rungpg.c (status_handler): Change return type to GpgmeError. + Return error directly. + (close_notify_handler): Don't send done event. + (colon_line_handler): Change return type to GpgmeError, return + errors directly. + * rungpg.c (start): Send start event. + * sign.c (_gpgme_sign_status_handler): Change return type to + GpgmeError, return errors directly. + * trustlist.c (trustlist_status_handler): Change return type to + GpgmeError. Return 0. + (trustlist_colon_handler): Change return type GpgmeError. Return + errors directly. + * verify.c (add_notation): Change return type to GpgmeError, + return errors directly. + (_gpgme_verify_status_handler): Likewise. + * wait.h (struct fd_table): Remove lock member. + (struct wait_item_s): Moved here from wait.c. + (struct tag): New structure. + (_gpgme_wait_event_cb): Remove prototype. + (_gpgme_wait_private_event_cb, _gpgme_wait_global_event_cb, + _gpgme_wait_user_add_io_cb, _gpgme_wait_user_remove_io_cb, + _gpgme_wait_user_event_io_cb): New prototypes. + * wait.c: Don't include . + (ftd_global, ctx_done_list, ctx_done_list_size, + ctx_done_list_length, ctx_done_list_lock, idle_function): Remove + global variable. + (gpgme_register_idle, do_select, _gpgme_wait_event_cb): Remove + function. + (gpgme_wait): Move to file wait-global.c. + (_gpgme_add_io_cb): Take ctx as private argument, initialize ctx + member in wait item and tag. + (_gpgme_remove_io_cb): Take ctx from tag. Don't use FDT lock. + (_gpgme_wait_one, _gpgme_wait_on_condition): Move to + wait-private.c. + (gpgme_fd_table_init): Don't initialize FDT->lock. + (gpgme_fd_table_deinit): Don't destroy FDT->lock. + (_gpgme_fd_table_put): Make static and rename to ... + (fd_table_put): ... this function. Don't use FDT->lock. + (struct wait_item_s): Move to wait.h. + * wait-global.c: New file. + * wait-private.c: New file. + * wait-user.c: New file. + + * key.c (gpgme_key_sig_get_string_attr): Use validity_to_string + instead otrust_to_string to calculate validity. + +2003-01-19 Miguel Coca + + * w32-io.c (_gpgme_io_select): Add missing argument in calls to + DEBUG_BEGIN. + * w32-util.c: Include "sema.h". + (find_program_in_registry): Change DEBUG1 to DEBUG2, fixes compilation + error. + +2003-01-19 Marcus Brinkmann + + * rungpg.c (_gpgme_engine_ops_gpg): Remove gpg_start. + (gpg_start): Rename to ... + (start): ... this function. Change arguments to GpgObject. + (gpg_decrypt): Call start. + (gpg_edit): Likewise. + (gpg_encrypt): Likewise. + (gpg_encrypt_sign): Likewise. + (gpg_export): Likewise. + (gpg_import): Likewise. + (gpg_keylist): Likewise. + (gpg_keylist_ext): Likewise. + (gpg_trustlist): Likewise. + (gpg_verify): Likewise. + + * engine-gpgsm.c (_gpgme_engine_ops_encrypt): Remove gpgsm_start. + (gpgsm_start): Rename to ... + (struct gpgsm_object_s): Remove member command. + (gpgsm_release): Don't free command. + (start): ... this function. Change arguments to GpgsmObject and + const char *. + (gpgsm_decrypt): Call start. + (gpgsm_delete): Likewise. + (gpgsm_encrypt): Likewise. + (gpgsm_export): Likewise. + (gpgsm_genkey): Likewise. + (gpgsm_import): Likewise. + (gpgsm_keylist): Likewise. + (gpgsm_keylist_ext): Likewise. + (gpgsm_verify): Likewise. + + * decrypt.c (_gpgme_decrypt_start): Don't call + _gpgme_engine_start. + * delete.c (_gpgme_op_delete_start): Likewise. + * edit.c (_gpgme_op_edit_start): Likewise. + * encrypt.c (_gpgme_op_encrypt_start): + * encrypt-sign.c (_gpgme_op_encrypt_sign_start): + * export.c (_gpgme_op_export_start): Likewise. + * genkey.c (_gpgme_op_genkey_start): Likewise. + * import.c (_gpgme_op_import_start): Likewise. + * keylist.c (gpgme_op_keylist_ext_start): Likewise. + (gpgme_op_keylist_start): Likewise. + * sign.c (_gpgme_op_sign_start): Likewise. + * trustlist.c (gpgme_op_trustlist_start): Likewise. + * verify.c (_gpgme_op_verify_start): Likewise. + + * engine-backend.h (struct engine_ops): Remove member start. + + * engine.h (_gpgme_engine_start): Remove prototype. + * engine.c (_gpgme_engine_start): Remove function. + +2003-01-06 Werner Koch + + * keylist.c (set_mainkey_capability): Handle 'd' and 'D' used + since gpg 1.3 to denote disabled keys. + +2003-01-06 Marcus Brinkmann + + * data-mem.c: Include . + * engine.c: Likewise. + +2003-01-06 Marcus Brinkmann + + * Makefile.am (libgpgme_la_DEPENDENCIES): Correct bug in last change. + +2002-12-24 Marcus Brinkmann + + * gpgme.h (gpgme_op_verify, gpgme_op_decrypt_verify): Drop R_STAT + argument. + * decrypt-verify.c (gpgme_op_decrypt_verify): Drop R_STAT + argument. + * verify.c (gpgme_op_verify): Drop R_STAT argument. + (_gpgme_intersect_stati): Function removed. + * ops.h (_gpgme_intersect_stati): Remove prototype. + +2002-12-24 Marcus Brinkmann + + * libgpgme.vers: New file. + * Makefile.am (EXTRA_DIST): Add libgpgme.vers. + (libgpgme_version_script_cmd): New variable. + (libgpgme_la_LDFLAGS): Add libgpgme_version_script_cmd here. + (libgpgme_la_DEPENDENCIES): New variable. + +2002-12-23 Marcus Brinkmann + + * key.c (gpgme_key_get_string_attr): Don't accept GPGME_ATTR_IS_SECRET. + (otrust_to_string): New function. + (gpgme_key_get_as_xml): Use it. + (validity_to_string): New function. + (gpgme_key_get_string_attr): Beautify using above functions. + (gpgme_key_get_ulong_attr): Likewise. + +2002-12-23 Marcus Brinkmann + + * data-mem.c (mem_release): Fix gcc warning. + * data-user.c (user_release): Likewise. + +2002-12-06 Marcus Brinkmann + + * data.h (gpgme_data_release_cb): Change return type to void. + (gpgme_data_read_cb): Change return type to ssize_t. + * data.c (gpgme_data_read): Likewise. + * data-stream.c (stream_read): Likewise. + * data-fd.c (fd_read): Likewise. + * data-mem.c (mem_read): Likewise. + (mem_release): Change return type to void. + * data-user.c (user_read): Change return type to ssize_t. + (user_release): Change return type to void. + * data-compat.c (old_user_read): Change return type to ssize_t. + * gpgme.h (GpgmeDataReadCb): Likewise. + (gpgme_data_read): Likewise. + (GpgmeDataSeekCb): Change return type to off_t. + +2002-12-04 Marcus Brinkmann + + * gpgme.h: Add prototype for gpgme_get_key. + * key.c (gpgme_get_key): New function. + * verify.c (gpgme_get_sig_key): Rewrite using gpgme_get_key. + + * gpgme.h: Add prototypes for new interfaces + gpgme_key_sig_get_string_attr and gpgme_key_get_ulong_attr. + (enum GpgmeAttr): New attribute GPGME_ATTR_SIG_CLASS. + * gpgme.c (gpgme_set_keylist_mode): Allow GPGME_KEYLIST_MODE_SIGS. + * key.h (struct certsig_s): New members ALGO, NAME_PART, + EMAIL_PART, COMMENT_PART, NAME, SIG_STAT and SIG_CLASS. + + * conversion.c (_gpgme_decode_c_string): Add new parameter LEN. + Use that to determine if allocation is desired or not. + * util.h: Adjust prototype of _gpgme_decode_c_string. + * keylist.c (keylist_colon_handler): Adjust caller of + _gpgme_decode_c_string. + + * key.h (struct gpgme_key_s): New member last_uid. + * key.c (_gpgme_key_append_name): Rewritten using + _gpgme_decode_c_string and the last_uid pointer. + (my_isdigit): Macro removed. + (ALLOC_CHUNK): Likewise. + * keylist.c (set_userid_flags): Use last_uid member of KEY. + + * context.h (struct user_id_s): New member last_certsig. + * key.h: Add prototype for _gpgme_key_add_certsig. + * key.c (_gpgme_key_add_certsig): New function. + (set_user_id_part): Move function before _gpgme_key_add_certsig. + (parse_user_id): Change first argument to SRC, add new arguments + NAME, EMAIL and COMMENT. Change code to use these arguments + instead going through UID. Move function before + _gpgme_add_certsig. + (parse_x509_user_id): Likewise. + (_gpgme_key_append_name): Adjust arguments to parse_x509_user_id + and parse_user_id invocation. + (one_certsig_as_xml): New function. + (one_uid_as_xml): Print signatures. + * context.h (struct gpgme_context_s): New member TMP_UID. + * keylist.c (keylist_colon_handler): Rewritten, implement "sig" + record entries. + + * key.c (get_certsig): New function. + (gpgme_key_sig_get_string_attr): Likewise. + (gpgme_key_sig_get_ulong_attr): Likewise. + + * keylist.c: Include . + (my_isdigit): Macro removed. + (set_mainkey_trust_info): Use isdigit, not my_isdigit. + (set_userid_flags): Likewise. + (set_subkey_trust_info): Likewise. + (set_ownertrust): Likewise. + (finish_key): Move function up a bit and remove prototype. + + * rungpg.c (gpg_keylist_ext): Correct precedence of signature + listing mode. + (gpg_keylist_ext): Implement signature listing mode. + +2002-11-25 Marcus Brinkmann + + * rungpg.c (_gpgme_gpg_spawn): Do not set parent fds to -1. + * posix-io.c (_gpgme_io_spawn): Call _gpgme_io_close instead close + for parent fds. + * w32-io.c (_gpgme_io_spawn): Call _gpgme_io_close instead + CloseHandle for parent fds. + +2002-11-22 Marcus Brinkmann + + * gpgme.h [_MSC_VER]: Define ssize_t as long. + +2002-11-22 Werner Koch + + * engine-gpgsm.c (_gpgme_gpgsm_new): Save the result of a first + setlocale before doing another setlocale. + +2002-11-21 Marcus Brinkmann + + * decrypt.c: Some beautyfication. + + * verify.c (_gpgme_verify_status_handler): Treat + GPGME_STATUS_UNEXPECTED like GPGME_STATUS_NODATA. + Reported by Miguel Coca . + +2002-11-19 Marcus Brinkmann + + * genkey.c: Only include if [HAVE_CONFIG_H]. + (struct genkey_result_s): Add new member FPR. + (_gpgme_release_genkey_result): Free RESULT->fpr if set. + (genkey_status_handler): Extract the fingerprint from the status + line. + (gpgme_op_genkey): Add new argument FPR and return the fingerprint + in it. + * gpgme.h: Adjust prototype of gpgme_op_genkey. + +2002-11-19 Marcus Brinkmann + + * rungpg.c (gpg_keylist): Add --with-fingerprint to gpg invocation + twice, to get fingerprints on subkeys. Suggested by Timo Schulz + . + (gpg_keylist_ext): Likewise. + +2002-11-05 Marcus Brinkmann + + * import.c (append_xml_impinfo): Use + _gpgme_data_append_string_for_xml rather than + _gpgme_data_append_string for the field content. + Submitted by Miguel Coca . + +2002-10-10 Marcus Brinkmann + + * rungpg.h, engine-gpgsm.h: File removed. + * engine-backend.h: New file. + * Makefile.am (gpgsm_components): New variable, set depending on + automake conditional HAVE_GPGSM. + (libgpgme_la_SOURCES): Add engine-backend.h, remove rungpg.h and + engine-gpgsm.h. Replace engine-gpgsm.c with ${gpgsm_components}. + (status-table.h): Depend on gpgme.h, not rungpg.h. + * conversion.c: Include . + * engine-gpgsm.c: Do not set ENABLE_GPGSM here. Include + "engine-backend.h" instead "engine-gpgsm.h". Reorder some + functions and remove all function prototypes. + (_gpgme_gpgsm_get_version): Make static and rename to ... + (gpgsm_get_version): ... this. + (_gpgme_gpgsm_check_version): Make static and rename to ... + (gpgsm_check_version): ... this. + (_gpgme_gpgsm_new): Make static. Change argument type from + GpgsmObject * to void **. Call gpgsm_release instead + _gpgme_gpgsm_release. + (_gpgme_gpgsm_op_decrypt): Make static and rename to ... + (gpgsm_check_decrypt): ... this. + (_gpgme_gpgsm_op_delete): Make static and rename to ... + (gpgsm_check_delete): ... this. + (_gpgme_gpgsm_set_recipients): Make static and rename to ... + (gpgsm_check_set_recipients): ... this. + (_gpgme_gpgsm_op_encrypt): Make static and rename to ... + (gpgsm_encrypt): ... this. + (_gpgme_gpgsm_op_export): Make static and rename to ... + (gpgsm_export): ... this. + (_gpgme_gpgsm_op_genkey): Make static and rename to ... + (gpgsm_genkey): ... this. + (_gpgme_gpgsm_op_import): Make static and rename to ... + (gpgsm_import): ... this. + (_gpgme_gpgsm_op_keylist): Make static and rename to ... + (gpgsm_keylist): ... this. + (_gpgme_gpgsm_op_keylist_ext): Make static and rename to ... + (gpgsm_keylist_ext): ... this. + (_gpgme_gpgsm_op_sign): Make static and rename to ... + (gpgsm_sign): ... this. + (_gpgme_gpgsm_op_trustlist): Make static and rename to ... + (gpgsm_trustlist): ... this. + (_gpgme_gpgsm_op_verify): Make static and rename to ... + (gpgsm_verify): ... this. + (gpgsm_status_handler): Rename to ... + (status_handler): ... this. + (_gpgme_gpgsm_set_status_handler): Make static and rename to ... + (gpgsm_set_status_handler): ... this. + (_gpgme_gpgsm_set_colon_line_handler): Make static and rename to ... + (gpgsm_set_colon_line_handler): ... this. + (_gpgme_gpgsm_add_io_cb): Rename to ... + (add_io_cb): ... this. + (_gpgme_gpgsm_start): Make static and rename to ... + (gpgsm_start): ... this. + (_gpgme_gpgsm_set_io_cb): Make static and rename to ... + (gpgsm_set_io_cb): ... this. + (_gpgme_gpgsm_io_event): Make static and rename to ... + (gpgsm_io_event): ... this. + (struct _gpgme_engine_ops_gpgsm): New variable. + [!ENABLE_GPGSM]: Removed. + * engine.c: Do not include , , , + , "io.h", "rungpg.h" and "engine-gpgsm.h". Include + and "engine-backend.h". + (struct engine_object_s): Rewritten. + (engine_ops): New variable. + * engine.c (_gpgme_engine_get_path, _gpgme_engine_get_version, + _gpgme_engine_check_version, _gpgme_engine_new, + _gpgme_engine_release, _gpgme_engine_set_verbosity, + _gpgme_engine_set_status_handler, + _gpgme_engine_set_command_handler, + _gpgme_engine_set_colon_line_handler, _gpgme_engine_op_decrypt, + _gpgme_engine_op_delete, _gpgme_engine_op_edit, + _gpgme_engine_op_encrypt, _gpgme_engine_op_encrypt_sign, + _gpgme_engine_op_export, _gpgme_engine_op_genkey, + _gpgme_engine_op_import, _gpgme_engine_op_keylist, + _gpgme_engine_op_keylist_ext, _gpgme_engine_op_sign, + _gpgme_engine_op_trustlist, _gpgme_engine_op_verify, + _gpgme_engine_start, _gpgme_engine_set_io_cbs, + _gpgme_engine_io_event): Reimplement. + * engine.h: Fix a few comments and a variable name in a prototype. + * ops.h: Do not include "rungpg.h". + * passphrase.c: Include config.h only if [HAVE_CONFIG_H]. Do not + include "rungpg.h". + * recipient.c: Likewise. + * signers.c: Likewise. + * version.c: Likewise. + * rungpg.c: Likewise. Include "engine-backend.h". Reorder + functions and remove prototypes. + (_gpgme_gpg_get_version): Make static and rename to ... + (gpg_get_version): ... this. + (_gpgme_gpg_check_version): Make static and rename to ... + (gpg_check_version): ... this. + (_gpgme_gpg_new): Make static. Change argument type from + GpgObject * to void **. Call gpg_release instead + _gpgme_gpg_release. + (_gpgme_gpg_op_decrypt): Make static and rename to ... + (gpg_check_decrypt): ... this. + (_gpgme_gpg_op_delete): Make static and rename to ... + (gpg_check_delete): ... this. + (_gpgme_gpg_set_recipients): Make static and rename to ... + (gpg_check_set_recipients): ... this. + (_gpgme_gpg_op_encrypt): Make static and rename to ... + (gpg_encrypt): ... this. + (_gpgme_gpg_op_export): Make static and rename to ... + (gpg_export): ... this. + (_gpgme_gpg_op_genkey): Make static and rename to ... + (gpg_genkey): ... this. + (_gpgme_gpg_op_import): Make static and rename to ... + (gpg_import): ... this. + (_gpgme_gpg_op_keylist): Make static and rename to ... + (gpg_keylist): ... this. + (_gpgme_gpg_op_keylist_ext): Make static and rename to ... + (gpg_keylist_ext): ... this. + (_gpgme_gpg_op_sign): Make static and rename to ... + (gpg_sign): ... this. + (_gpgme_gpg_op_trustlist): Make static and rename to ... + (gpg_trustlist): ... this. + (_gpgme_gpg_op_verify): Make static and rename to ... + (gpg_verify): ... this. + (gpg_status_handler): Rename to ... + (status_handler): ... this. + (_gpgme_gpg_set_status_handler): Make static and rename to ... + (gpg_set_status_handler): ... this. + (_gpgme_gpg_set_colon_line_handler): Make static and rename to ... + (gpg_set_colon_line_handler): ... this. + (gpgme_gpg_add_io_cb): Rename to ... + (add_io_cb): ... this. + (_gpgme_gpg_start): Make static and rename to ... + (gpg_start): ... this. + (_gpgme_gpg_set_io_cb): Make static and rename to ... + (gpg_set_io_cb): ... this. + (_gpgme_gpg_io_event): Make static and rename to ... + (gpg_io_event): ... this. + (struct _gpgme_engine_ops_gpg): New variable. + +2002-10-10 Marcus Brinkmann + + * engine-gpgsm.c (_gpgme_gpgsm_op_verify) [!ENABLE_GPGSM]: Add + missing argument. + +2002-10-09 Marcus Brinkmann + + * data.h, data-user.c, data-stream.c, data-mem.c, data-fd.c, + data-compat.c: New file. Really check them in this time, completes + 2002-10-08 change. + + * rungpg.h (GpgStatusHandler): Rename type to GpgmeStatusHandler + and move to ... + * types.h (GpgmeStatusHandler): ... here. + * rungpg.h (GpgColonLineHandler): Rename type to GpgmeColonLineHandler. + and move to ... + * types.h (GpgmeColonLineHandler): ... here. + * rungpg.h (GpgCommandHandler): Rename type to GpgmeCommandHandler. + and move to ... + * types.h (GpgmeCommandHandler): ... here. + * engine.h: Don't include "rungpg.h". + (_gpgme_engine_set_status_handler): Change type of + argument from GpgStatusHandler to GpgmeStatusHandler. + (_gpgme_engine_set_colon_line_handler): Change type of + argument from GpgColonLineHandler to GpgmeColonLineHandler. + (_gpgme_engine_set_command_handler): Change type of + argument from GpgCommandHandler to GpgmeCommandHandler. + * engine-gpgsm.h: Don't include "rungpg.h". + (_gpgme_gpgsm_set_status_handler): Change type of + argument from GpgStatusHandler to GpgmeStatusHandler. + (_gpgme_gpgsm_set_colon_line_handler): Change type of + argument from GpgColonLineHandler to GpgmeColonLineHandler. + * engine-gpgsm.c: Do not include "rungpg.h". + (struct gpgsm_object_s): Change type of + status.fnc to GpgmeStatusHandler. Change type of colon.fnc to + GpgmeColonLineHandler. + (gpgsm_assuan_simple_command): Change type of argument from + GpgStatusHandler to GpgmeStatusHandler. + (_gpgme_gpgsm_set_status_handler): Likewise. + (_gpgme_gpgsm_set_colon_line_handler): Change type of argument from + GpgColonLineHandler to GpgmeColonLineHandler. + * rungpg.h (_gpgme_gpg_set_status_handler): Change type of + argument from GpgStatusHandler to GpgmeStatusHandler. + (_gpgme_gpg_set_colon_line_handler): Change type of + argument from GpgColonLineHandler to GpgmeColonLineHandler. + (_gpgme_gpg_set_command_handler): Change type of + argument from GpgCommandHandler to GpgmeCommandHandler. + * rungpg.c (struct gpg_object_s): Change type of status.fnc to + GpgmeStatusHandler. Change type of colon.fnc to + GpgmeColonLineHandler. Change type of cmd.fnc to + GpgmeCommandLineHandler. + (_gpgme_gpg_set_status_handler): Change type of argument FNC to + GpgmeStatusHandler. + (_gpgme_gpg_set_colon_line_handler): Change type of argument FNC + to GpgmeColonLineHandler. + (_gpgme_gpg_set_command_handler): Change type of argument FNC to + GpgmeCommandHandler. + * engine.c (_gpgme_engine_set_status_handler): Change type of + argument FNC to GpgmeStatusHandler. + (_gpgme_engine_set_colon_line_handler): Change type of argument FNC + to GpgmeColonLineHandler. + (_gpgme_engine_set_command_handler): Change type of argument FNC to + GpgmeCommandHandler. + + * rungpg.h (_gpgme_gpg_enable_pipemode): Remove prototype. + * rungpg.c (struct gpg_object_s): Remove PM. + (pipemode_cb): Prototype removed. + (add_pm_data): Function removed. + (_gpgme_gpg_enable_pipemode): Likewise. + (pipemode_copy): Likewise. + (pipemode_cb): Likewise. + (add_arg): Don't check for pipemode. + (add_data): Likewise. + (_gpgme_gpg_set_status_handler): Likewise. + (_gpgme_gpg_set_colon_line_handler): Likewise. + (_gpgme_gpg_set_command_handler): Likewise. + (_gpgme_gpg_spawn): Likewise. + (_gpgme_gpg_spawn): Don't set PM.active. + (_gpgme_gpg_op_verify): Remove pipemode case. + * verify.c (_gpgme_op_verify_start): Remove pipemode case. + + * rungpg.h (_gpgme_gpg_add_arg, _gpgme_gpg_add_data, + _gpgme_gpg_add_pm_data, _gpgme_gpg_housecleaning, + _gpgme_gpg_set_simple_line_handler): Prototype removed. + (_gpgme_gpg_set_verbosity): New prototype. + * rungpg.c (_gpgme_gpg_add_data): Make static and rename to ... + (add_data): ... this. + (_gpgme_gpg_add_pm_data): Call add_data, not _gpgme_gpg_add_data. + (_gpgme_gpg_set_command_handler): Likewise. + (_gpgme_gpg_op_decrypt, _gpgme_gpg_op_edit, _gpgme_gpg_op_encrypt, + _gpgme_gpg_op_encrypt_sign, _gpgme_gpg_op_export, + _gpgme_gpg_op_genkey, _gpgme_gpg_op_import, _gpgme_gpg_op_sign, + _gpgme_gpg_op_verify): Likewise. + (_gpgme_gpg_add_pm_data): Rename to ... + (add_pm_data): ... this. + (_gpgme_gpg_op_verify): Call add_pm_data, not + _gpgme_gpg_add_pm_data. + (_gpgme_gpg_add_arg): Make static and rename to ... + (add_arg): ... this. + (_gpgme_gpg_set_command_handler, _gpgme_gpg_new, + _gpgme_gpg_op_decrypt, _gpgme_gpg_op_delete, + _gpgme_append_gpg_args_from_signers, _gpgme_gpg_op_edit, + _gpgme_append_gpg_args_from_recipients, _gpgme_gpg_op_encrypt, + _gpgme_gpg_op_encrypt_sign, _gpgme_gpg_op_export, + _gpgme_gpg_op_genkey, _gpgme_gpg_op_import, _gpgme_gpg_op_keylist, + _gpgme_gpg_op_keylist_ext, _gpgme_gpg_op_trustlist, + _gpgme_gpg_op_sign, _gpgme_gpg_op_verify): Use add_arg, not + _gpgme_gpg_add_arg. + (_gpgme_gpg_set_verbosity): New function. + (struct gpg_object_s): Remove member simple from colon. + (_gpgme_gpg_set_colon_line_handler): Don't initialize simple. + (_gpgme_gpg_set_simple_line_handler): Removed function. + (read_colon_line): Don't check the GPG->colon.simple. + * engine.c (_gpgme_engine_set_verbosity): Call + _gpgme_gpg_set_verbosity instead _gpgme_gpg_add_arg. + +2002-10-08 Marcus Brinkmann + + * util.h (_gpgme_malloc, _gpgme_realloc, _gpgme_calloc, + _gpgme_strdup, _gpgme_free): Remove prototypes. + (xtrymalloc, xtrycalloc, xtryrealloc, xtrystrdup, xfree): Remove + macros. + * util.c: File removed. + * Makefile.am (libgpgme_la_SOURCES): Remove util.h. + * conversion.c (_gpgme_decode_c_string): Use malloc instead of + xtrymalloc, realloc instead of xtryrealloc, calloc instead of + xtrycalloc, free instead of xfree. + (_gpgme_data_append_percentstring_for_xml): Likewise. + * data.c (_gpgme_data_new, _gpgme_data_release): Likewise. + * data-compat.c (gpgme_data_new_from_filepart): Likewise. + * data-mem.c (mem_write, mem_release, gpgme_data_new_from_mem, + _gpgme_data_get_as_string): Likewise. + * debug.c (debug_init): Likewise. + * decrypt.c (_gpgme_release_decrypt_result): Likewise. + * delete.c (_gpgme_release_delete_result): Likewise. + * edit.c (_gpgme_release_edit_result, _gpgme_op_edit_start): + Likewise. + * encrypt.c (_gpgme_release_encrypt_result): Likewise. + * engine.c (_gpgme_engine_get_info, _gpgme_engine_new, + _gpgme_engine_release): Likewise. + * engine-gpgsm.c (_gpgme_gpgsm_new, _gpgme_gpgsm_release, + _gpgme_gpgsm_op_decrypt, _gpgme_gpgsm_op_delete, + gpgsm_set_recipients, _gpgme_gpgsm_op_encrypt, + _gpgme_gpgsm_op_export, _gpgme_gpgsm_op_genkey, + _gpgme_gpgsm_op_import, _gpgme_gpgsm_op_keylist, + _gpgme_gpgsm_op_keylist_ext, _gpgme_gpgsm_op_sign, + _gpgme_gpgsm_op_verify, gpgsm_status_handler): Likewise. + * genkey.c (_gpgme_release_genkey_result): Likewise. + * gpgme.c (gpgme_new, gpgme_release): Likewise. + * import.c (_gpgme_release_import_result): Likewise. + * key.c (_gpgme_key_cache_init, _gpgme_key_cache_add, key_new, + add_subkey, gpgme_key_release, _gpgme_key_append_name): Likewise. + * keylist.c (_gpgme_release_keylist_result, keylist_colon_handler, + _gpgme_op_keylist_event_cb, gpgme_op_keylist_next): Likewise. + * ops.h (test_and_allocate_result): Likewise. + * passphrase.c (_gpgme_release_passphrase_result, + _gpgme_passphrase_status_handler, + _gpgme_passphrase_command_handler): Likewise. + * progress.c (_gpgme_progress_status_handler): Likewise. + * recipient.c (gpgme_recipients_new, gpgme_recipients_release, + gpgme_recipients_add_name_with_validity): Likewise. + * rungpg.c (_gpgme_gpg_new, _gpgme_gpg_release, + _gpgme_gpg_add_arg, _gpgme_gpg_add_data, + _gpgme_gpg_set_colon_line_handler, free_argv, free_fd_data_map, + build_argv, _gpgme_gpg_spawn, read_status, read_colon_line): + Likewise. + * sign.c (_gpgme_release_sign_result): Likewise. + * signers.c (_gpgme_signers_add): Likewise. + * trustlist.c (trust_item_new, trustlist_colon_handler, + _gpgme_op_trustlist_event_cb, gpgme_op_trustlist_next, + gpgme_trustitem_release): Likewise. + * verify.c (_gpgme_release_verify_result, finish_sig): Likewise. + * version.c (gpgme_get_engine_info, _gpgme_get_program_version): + Likewise. + * w32-io.c (create_reader, create_writer, destroy_reader, + destroy_writer, build_commandline, _gpgme_io_spawn): Likewise. + * w32-sema.c (critsect_init, _gpgme_sema_cs_destroy): Likewise. + * w32-util.c (read_w32_registry_string): Likewise. + * wait.c (_gpgme_fd_table_deinit, _gpgme_fd_table_put, + _gpgme_wait_event_cb, _gpgme_add_io_cb, _gpgme_remove_io_cb) + * data-compat.c: Include . + +2002-10-08 Marcus Brinkmann + + New data object component: + + * gpgme.h (GpgmeDataReadCb, GpgmeDataWriteCb, GpgmeDataSeekCb, + GpgmeDataReleaseCb): New types. + (struct GpgmeDataCbs): New structure. + (gpgme_data_read): Changed prototype to match that of read() closely. + (gpgme_data_write): Similar for write(). + (gpgme_data_seek, gpgme_data_new_from_cbs, gpgme_data_new_from_fd, + gpgme_data_new_from_stream): New prototypes. + (gpgme_data_get_type, gpgme_check_engine): Prototype removed. + + * Makefile.am (libgpgme_la_SOURCES): Add data.h, data-fd.c, + data-stream.c, data-mem.c, data-user.c and data-compat.c. + * data.c: Reimplemented from scratch. + * (data-compat.c, data-fd.c, data.h, data-mem.c, data-stream.c, + data-user.c): New file. + * context.h (struct gpgme_data_s): Removed. + * conversion.c: Include and . + (_gpgme_data_append): New function. + * data.c (_gpgme_data_append_string): Move to ... + * conversion.c (_gpgme_data_append_string): ... here. + * data.c (_gpgme_data_append_for_xml): Move to ... + * conversion.c (_gpgme_data_append_for_xml): ... here. + * data.c (_gpgme_data_append_string_for_xml): Move to ... + * conversion.c (_gpgme_data_append_string_for_xml): ... here. + * data.c (_gpgme_data_append_percentstring_for_xml): Move to ... + * conversion.c (_gpgme_data_append_percentstring_for_xml): ... here. + + * ops.h (_gpgme_data_get_mode, _gpgme_data_set_mode): Prototype + removed. + * types.h (GpgmeDataMode): Type removed. + + * decrypt.c (_gpgme_decrypt_start): Don't check data type or mode. + * edit.c (_gpgme_op_edit_start): Likewise. + * encrypt.c (_gpgme_op_encrypt_start): Likewise. + * encrypt-sign.c (_gpgme_op_encrypt_sign_start): Likewise. + * encrypt-sign.c (_gpgme_op_encrypt_sign_start): Likewise. + * export.c (_gpgme_op_export_start): Likewise. + * genkey.c (_gpgme_op_genkey_start): Likewise. + * import.c (_gpgme_op_import_start): Likewise. + * sign.c (_gpgme_op_sign_start): Likewise. + * verify.c (_gpgme_op_verify_start): Likewise. + + * encrypt.c (gpgme_op_encrypt): Remove hack that returns invalid + no recipient if no data was returned. + * encrypt-sign.c (gpgme_op_encrypt_sign): Remove hack that returns + no recipient if no data was returned. + * encrypt-sign.c (gpgme_op_encrypt_sign): Remove hack that returns + no recipient if no data was returned. + + * engine.c (_gpgme_engine_op_verify): Add new argument to + differentiate detached from normal signatures. + * engine.h (_gpgme_engine_op_verify): Likewise for prototype. + * engine-gpgsm.c (_gpgme_gpgsm_op_verify): Likewise. Don't check + mode of data argument. + * engine-gpgsm.h (_gpgme_gpgsm_op_verify): Likewise for prototype. + * gpgme.h (gpgme_op_verify_start): Likewise for prototype. + (gpgme_op_verify): Likewise for prototype. + * rungpg.c (_gpgme_gpg_op_verify): Likewise. + * rungpg.h (_gpgme_gpg_op_verify): Likewise for prototype. + * verify.c (_gpgme_op_verify_start): Likewise. + (gpgme_op_verify_start): Likewise. + (gpgme_op_verify): Likewise. + + * rungpg.c (struct arg_and_data_s): New member INBOUND to hold + direction of data object. + (_gpgme_gpg_add_data): Add new argument INBOUND. Use it to + determine direction of data object. + (_gpgme_gpg_add_pm_data, _gpgme_gpg_set_command_handler, + _gpgme_gpg_op_decrypt, _gpgme_gpg_op_edit, _gpgme_gpg_op_encrypt, + _gpgme_gpg_op_encrypt_sign, _gpgme_gpg_op_export, + _gpgme_gpg_op_genkey, _gpgme_gpg_op_import, _gpgme_gpg_op_sign, + _gpgme_gpg_op_verify): Add new argument to _gpgme_gpg_add_data + invocation. + (build_argv): Use new member INBOUND to determine direction of + file descriptor. Don't check the data type. + * rungpg.h (_gpgme_gpg_add_data): Add new argument to prototype. + + * gpgme.c (gpgme_get_op_info): Don't call + _gpgme_data_get_as_string if CTX->op_info is NULL. + + * version.c (gpgme_check_engine): Function removed. + +2002-09-30 Werner Koch + + * keylist.c (keylist_colon_handler): Take care when printing a + NULL with the DEBUG. + + * engine-gpgsm.c (struct gpgsm_object_s): New member ANY. + (gpgsm_status_handler): Run the colon function to indicate EOF. + (_gpgme_gpgsm_set_colon_line_handler): Better reset ANY here. + +2002-09-28 Marcus Brinkmann + + * conversion.c (_gpgme_hextobyte): Prevent superfluous + multiplication with base. Reported by Stéphane Corthésy. + + * keylist.c (gpgme_op_keylist_ext_start): Use private asynchronous + operation type in invocation of _gpgme_op_reset. + +2002-09-20 Werner Koch + + * ath.c: Include sys/time.h if sys/select.h is not available. + +2002-09-13 Marcus Brinkmann + + * keylist.c (keylist_status_handler): Do not call finish_key() here. + (gpgme_op_keylist_ext_start): Set CTX->tmp_key to NULL. + +2002-09-03 Marcus Brinkmann + + * Makefile.am (assuan_libobjs): Remove @LTLIBOBJS@ as we link them + into gpgme unconditionally. + (libgpgme_la_LIBADD): Change @LIBOBJS@ into @LTLIBOBJS@. + +2002-09-02 Marcus Brinkmann + + * Makefile.am (assuan_libobjs): Use @LTLIBOBJS@ instead @LIBOBJS@. + +2002-09-02 Marcus Brinkmann + + * debug.c (_gpgme_debug_add): Test *LINE, not LINE. + (_gpgme_debug_end): Likewise. + Reported by Dr. Stefan Dalibor . + +2002-09-02 Marcus Brinkmann + + * posix-io.c (_gpgme_io_select): Don't use a non-constant struct + initializer. + * version.c (_gpgme_get_program_version): Likewise. + Reported by Dr. Stefan Dalibor . + +2002-09-02 Marcus Brinkmann + + * conversion.c (_gpgme_decode_c_string): Set DESTP before + modifying DEST. + + * conversion.c (_gpgme_decode_c_string): Fix off by one error in + last change. + * rungpg.c (_gpgme_append_gpg_args_from_signers): Move before + _gpgme_op_edit so its prototype is known early on. + + * conversion.c: New file. + * util.h: Add prototypes for _gpgme_decode_c_string and + _gpgme_hextobyte. + * keylist.c (keylist_colon_handler): Call _gpgme_decode_c_string + on issuer name. + * Makefile.am (libgpgme_la_SOURCES): Add conversion.c + * key.c (_gpgme_key_append_name): Replace calls to hextobyte by + calls to _gpgme_hextobyte. + (hash_key): Likewise. + +2002-09-01 Marcus Brinkmann + + * op-support.c (_gpgme_op_reset): Set CTX->pending after calling + _gpgme_engine_release, as this will reset pending to zero in the + event done callback on cancelled operations. + +2002-08-30 Marcus Brinkmann + + * rungpg.c (_gpgme_gpg_op_edit): Add args from signers. + Suggested by Miguel Coca . + + * rungpg.c (_gpgme_gpg_op_edit): Add bogus ctx argument. + * rungpg.h: Also to prototype. + * engine.c (_gpgme_engine_op_edit): Likewise. + * engine.h: Likewise. + * edit.c (_gpgme_op_edit_start): Likewise. + +2002-08-29 Werner Koch + + * engine-gpgsm.c (_gpgme_gpgsm_op_sign): Implement signer + selection. + * vasprintf.c (va_copy): Define macro if not yet defined. + +2002-08-29 Marcus Brinkmann + + * passphrase.c (_gpgme_passphrase_status_handler): Reset + CTX->result.passphrase->no_passphrase if passphrase is given (good + or bad). Submitted by Jean DIRAISON . + +2002-08-28 Marcus Brinkmann + + * posix-io.c (_gpgme_io_spawn): Use a double-fork approach. + Return 0 on success, -1 on error. + * version.c (_gpgme_get_program_version): Don't wait for the child. + * engine.c (_gpgme_engine_housecleaning): Function removed. + (do_reaping): Likewise. + (_gpgme_engine_add_child_to_reap_list): Likewise. + (struct reap_s): Removed. + (reap_list): Likewise. + (reap_list_lock): Likewise. + * engine.h (_gpgme_engine_io_event): Remove prototypes for + _gpgme_engine_housecleaning and + _gpgme_engine_add_child_to_reap_list. + * rungpg.c (_gpgme_gpg_release): Don't add child to reap list. + (struct gpg_object_s): Remove PID member. + (_gpgme_gpg_new): Don't initialize GPG->pid. + (_gpgme_gpg_spawn): Don't set GPG->pid. + * wait.c (run_idle): Removed. + (gpgme_wait): Run idle_function directly. + +2002-08-21 Marcus Brinkmann + + * encrypt-sign.c (encrypt_sign_status_handler): Remove dead + variables encrypt_info and encrypt_info_len. + * trustlist.c (gpgme_op_trustlist_start): Set colon line handler. + * posix-sema.c (sema_fatal): Remove function. + All these reported by Stéphane Corthésy. + +2002-08-23 Werner Koch + + * gpgme-config.in: Made --prefix work for --libs. + +2002-08-21 Marcus Brinkmann + + * ath.h: Update list of symbols that get a prefix: Rename the + ath_mutex_*_available symbols to ath_*_available. + +2002-08-21 Marcus Brinkmann + + * stpcpy.c: New file from gnulib. + * Makefile.am (assuan_libobjs): Remove jnlib. + +2002-08-20 Marcus Brinkmann + + * gpgme.h: Add prototype for gpgme_op_import_ext. + * import.c (struct import_result_s): New member `nr_considered'. + Rename `any_imported' to `nr_imported'. + (import_status_handler): Increment nr_imported. Set nr_considered + if appropriate. + (gpgme_op_import_ext): New function. + (gpgme_op_import): Implement in terms of gpgme_op_import_ext. + +2002-08-20 Werner Koch + + * gpgme.m4: Replaced with a new and faster version. This does not + anymore try to build test programs. If we really need test + programs, we should add an option to gpgme-config to do so. + + * vasprintf.c (int_vasprintf): Hack to handle NULL passed for %s. + +2002-08-20 Marcus Brinkmann + + * gpgme.c (_gpgme_set_op_info): Append data on subsequent calls. + * encrypt-sign.c (encrypt_sign_status_handler): Remove op_info + handling. + +2002-08-19 Werner Koch + + * decrypt.c (is_token,skip_token): Duplicated from verify.c + (gpgme_op_decrypt): Hack to properly return Decryption_Failed.. + (_gpgme_decrypt_status_handler): Create an operation info. + +2002-08-14 Werner Koch + + * key.h (struct certsig_s): New. Use it in gpgme_key_s. + * key.c (gpgme_key_release): Release it. We need to add more code + of course. + (_gpgme_key_append_name): Use memset to intialize the struct. + * gpgme.h (GPGME_KEYLIST_MODE_SIGS): New. + * rungpg.c (_gpgme_gpg_op_keylist): Include sigs in listing depending + non the list mode. + + * key.c (gpgme_key_get_string_attr): Use GPGME_ATTR_TYPE to return + information about the key type (PGP or X.509). + (gpgme_key_get_ulong_attr): Likewise. + + * keylist.c (keylist_colon_handler): Include 1 in the check for + valid algorithms so that RSA is usable. Store the issuer name and + serial number also for "crs" records. Parse the expire date for + subkeys. + (set_userid_flags): Put them onto the last appended key. + +2002-07-29 Marcus Brinkmann + + * rungpg.c (_gpgme_gpg_op_edit): Use --with-colons. + +2002-07-28 Marcus Brinkmann + + * data.c (gpgme_data_read): For GPGME_DATA_TYPE_NONE, return EOF + instead an error. + + The following changes make it possible to flush an inbound data + pipe before invoking a command handler: + + * posix-io.c (_gpgme_io_select): Accept new argument NONBLOCK to + _gpgme_io_select. Set timeout of 0 if this is set. + * w32-io.c (_gpgme_io_select): Likewise. + * io.h: Add new argument NONBLOCK to _gpgme_io_select prototype. + * wait.c (do_select): Add new argument to _gpgme_io_select + invocation. + * rungpg.h (_gpgme_gpg_set_command_handler): Add new argument + linked_data to prototype. + * engine.h (_gpgme_engine_set_command_handler): Likewise. + * engine.c (_gpgme_engine_set_command_handler): Likewise. + * passphrase.c (_gpgme_passphrase_start): Pass NULL as linked_data + argument to _gpgme_engine_set_command_handler. + * rungpg.c (struct gpg_object_s): New members linked_data and + linked_idx in CMD. + (_gpgme_gpg_new): Initialize those new members. + (_gpgme_gpg_set_command_handler): Accept new argument linked_data. + (build_argv): Handle linked_data in the same hack as cb_data. + (read_status): If linked_data is in use, flush the pipe before + activating the command handler. + * gpgme.h: Add prototypes for gpgme_op_edit_start and + gpgme_op_edit. + + The next changes export the status codes to the user: + + * decrypt.c (_gpgme_decrypt_status_handler): Likewise, also prefix + all STATUS_ with GPGME_. + * delete.c (delete_status_handler): Likewise. + * decrypt-verify.c (decrypt_verify_status_handler): Likewise. + * encrypt.c (_gpgme_encrypt_status_handler): Likewise. + (_gpgme_encrypt_sym_status_handler): Likewise. + * encrypt-sign.c (encrypt_sign_status_handler): Likewise. + * engine-gpgsm.c (parse_status): Likewise. + (gpgsm_status_handler): Likewise. + (gpgsm_set_recipients): Likewise. + * export.c (export_status_handler): Likewise. + * genkey.c (genkey_status_handler): Likewise. + * import.c (append_xml_impinfo): Likewise. + (import_status_handler): Likewise. + * keylist.c (keylist_status_handler): Likewise. + * passphrase.c (_gpgme_passphrase_status_handler): Likewise. + (command_handler): Likewise. + * progress.c (_gpgme_progress_status_handler): Likewise. + * sign.c (_gpgme_sign_status_handler): Likewise. + * trustlist.c (trustlist_status_handler): Likewise. + * verify.c (_gpgme_verify_status_handler): Likewise. + * gpgme.h (GpgmeEditCb): New type. + * rungpg.h (GpgStatusCode): Rename and move to ... + * gpgme.h (GpgmeStatusCode): ... this and here. + * Makefile.am (status-table.h): Run mkstatus on gpgme.h, not rungpg.h. + * mkstatus: Prefix STATUS with GPGME_. + * rungpg.h (GpgStatusHandler, GpgCommandHandler): Change type + accordingly. + * ops.h (_gpgme_verify_status_handler, + _gpgme_decrypt_status_handler, _gpgme_sign_status_handler, + _gpgme_encrypt_status_handler, _gpgme_passphrase_status_handler, + _gpgme_progress_status_handler): Likewise. + * rungpg.c (struct gpg_object_s): Likewise for CMD.code. + + These changes add an edit operation to GPGME: + + * context.h (struct gpgme_context_s): New member RESULT.edit. * + ops.h: Add prototype for _gpgme_release_edit_result and + _gpgme_passphrase_command_handler. + * passphrase.c (command_handler): Make non-static and rename to ... + (_gpgme_passphrase_command_handler): ... this. + (_gpgme_passphrase_start): Use new name for command handler. + * types.h: Add EditResult type. + * gpgme.c (_gpgme_release_result): Release EDIT result. + * edit.c: New file. + * Makefile.am (libgpgme_la_SOURCES): Add edit.c. + (libgpgme_la_LDADD): Rename to libgpgme_la_LIBADD, and include + assuan_libobjs. + (assuan_libobjs): New variable, set this instead + libgpgme_la_LIBADD. + * engine.h (_gpgme_engine_op_edit): New prototype. + * engine.c (_gpgme_engine_op_edit): New function. + * rungpg.h (_gpgme_gpg_op_edit): New prototype. + * rungpg.c (_gpgme_gpg_op_edit): New function. + +2002-07-27 Marcus Brinkmann + + * delete.c (delete_problem): New case ambigious specification. + (delete_status_handler): Handle new case (poorly). + +2002-07-25 Marcus Brinkmann + + * engine-gpgsm.c (_gpgme_gpgsm_op_delete): Implement this. + +2002-07-25 Marcus Brinkmann + + * Makefile.am (libgpgme_la_LDADD): Add @LIBOBJS@ for vasprintf and + fopencookie. + * vasprintf.c: Update to more recent libiberty version. + * debug.h: Replace #elsif with #elif. + + Submitted by Stéphane Corthésy: + * util.h (vasprintf): Correct prototype. + * encrypt-sign.c: Include . + (encrypt_sign_status_handler): Change type of ENCRYPT_INFO_LEN to + size_t. + * ath-pthread.c: Include , not . + * ath-pth.c: Likewise. + +2002-07-25 Marcus Brinkmann + + * wait.c (fdt_global): Make static. Reported by Stéphane + Corthésy. + + * rungpg.c (_gpgme_gpg_op_keylist_ext): Skip empty string + patterns. Reported by Stéphane Corthésy. + + * key.c (gpgme_key_get_as_xml): Add OTRUST attribute. Requested + by Stéphane Corthésy. + (gpgme_key_get_string_attr): Add GPGME_ATTR_SIG_SUMMARY case to + silence gcc warning. + + * rungpg.c (_gpgme_gpg_new): Always set utf8 as charset. + +2002-07-03 Marcus Brinkmann + + * gpgme.c (gpgme_set_io_cbs): Deal with CTX being NULL. + + * gpgme.c (_gpgme_op_event_cb_user): New function. + * op-support.c (_gpgme_op_reset): Support a new mode of operation + for private or user event loop. Use new user event callback + wrapper. + * trustlist.c (gpgme_op_trustlist_start): Use this new mode. + * keylist.c (gpgme_op_keylist_start): Likewise. + + * rungpg.c (_gpgme_gpg_io_event): New function. + * rungpg.h (_gpgme_gpg_io_event): New prototype. + * engine-gpgsm.c (_gpgme_gpg_io_event): New function. + * engine-gpgsm.h (_gpgme_gpgsm_io_event): New prototype. + * engine.c (_gpgme_engine_io_event): New function. + * engine.h (_gpgme_engine_io_event): New prototype. + * keylist.c (finish_key): Call _gpgme_engine_io_event, and move + the real work for the default IO callback routines to ... + (_gpgme_op_keylist_event_cb): ... here. New function. + * trustlist.c (trustlist_colon_handler): Signal + GPGME_EVENT_NEXT_TRUSTITEM. Move queue manipulation to ... + (_gpgme_op_trustlist_event_cb): ... here. New function. + * gpgme.c (_gpgme_op_event_cb): Call _gpgme_op_keylist_event_cb + and _gpgme_op_trustlist_event_cb when appropriate. + * ops.h (_gpgme_op_keylist_event_cb): New prototype. + (_gpgme_op_trustlist_event_cb): Likewise. + * op-support.c (_gpgme_op_reset): Add comment why we don't use the + user provided event handler directly. + * gpgme.h (GpgmeRegisterIOCb): Return GpgmeError value, and TAG in + a pointer argument. + * wait.c (_gpgme_add_io_cb): Likewise. + * wait.h (_gpgme_add_io_cb): Likewise for prototype. + * rungpg.c (_gpgme_gpg_add_io_cb): Call IO_CBS->add with new + argument. Fix up error handling. + * engine-gpgsm.c (_gpgme_gpgsm_add_io_cb): Call IO_CBS->add with + new argument, fix up error handling. + +2002-07-03 Werner Koch + + * encrypt.c (status_handler_finish): New. + (_gpgme_encrypt_status_handler): Moved some code out to the new + function and call this function also in case we get into the + status handler with an error which might happen due to a kludge in + engine-gpgsm.c + +2002-06-28 Marcus Brinkmann + + * keylist.c (gpgme_op_keylist_ext_start): Always use our own FD + table (eg use synchronous mode). + +2002-06-28 Marcus Brinkmann + + * ops.h (_gpgme_wait_on_condition): Remove HANG argument from + prototype and change return type to GpgmeError. + (_gpgme_wait_one): New prototype. + * wait.c (gpgme_wait): Replace with the meat from + _gpgme_wait_on_condition here, and remove the support for + conditions. + (_gpgme_wait_on_condition): Remove HANG argument from prototype + and change return type to GpgmeError. Replace with meat from + _gpgme_wait_one and add support for conditions. + (_gpgme_wait_one): Just call _gpgme_wait_on_condition without + condition. + * keylist.c (gpgme_op_keylist_ext_start): Always use our own FD + table (eg use synchronous mode). + (gpgme_op_keylist_next): Remove HANG argument from + _gpgme_wait_on_condition. Check its return value. + * trustlist.c (gpgme_op_trustlist_start): Always use our own FD + table (eg use synchronous mode). + (gpgme_op_trustlist_next): Remove HANG argument from + _gpgme_wait_on_condition. Check its return value. + +2002-06-27 Marcus Brinkmann + + * gpgme.h: Fix documentation of key attribute retrieval functions. + +2002-06-26 Werner Koch + + * engine-gpgsm.c (map_assuan_error): Map No_Data_Available to EOF. + + * import.c (append_xml_impinfo): Kludge to print fingerprint + instead of keyid for use with gpgsm. + (import_status_handler): Set a flag to know whether any import + occured. + (gpgme_op_import): Reurn -1 if no certificate ewas imported. + +2002-06-25 Werner Koch + + * engine-gpgsm.c (_gpgme_gpgsm_set_io_cbs) [ENABLE_GPGSM]: Fixed + function arguments. + +2002-06-25 Marcus Brinkmann + + * engine-gpgsm.c (_gpgme_gpgsm_op_export): Only export the keys + listed in RECP. + * export.c (gpgme_op_export): If no data was returned, return + GPGME_No_Recipients. + +2002-06-25 Marcus Brinkmann + + * engine-gpgsm.c (_gpgme_gpgsm_op_export): Implement. + +2002-06-21 Marcus Brinkmann + + * engine-gpgsm.c (gpgsm_assuan_simple_command): Return ERR. + (parse_status): New function. + (gpgsm_status_handler): Use parse_status. + (gpgsm_assuan_simple_command): Accept new arguments STATUS_FNC and + STATUS_FNC_VALUE and process status messages. + (gpgsm_set_recipients): Pass new arugments to gpgsm_assuan_simple_command. + (gpgsm_set_fd): Likewise. + (_gpgme_gpgsm_op_keylist): Likewise. + (_gpgme_gpgsm_op_keylist_ext): Likewise. + (_gpgme_gpgsm_op_sign): Likewise. + +2002-06-21 Marcus Brinkmann + + * wait.c (_gpgme_remove_io_cb): Unlock FDT->lock. + +2002-06-20 Werner Koch + + * rungpg.c (build_argv): Ignore GPG_AGENT_INFO if set but empty. + + * verify.c (calc_sig_summary): Set bad policy for wrong key usage. + (skip_token): New. + (_gpgme_verify_status_handler): Watch out for wrong key usage. + (gpgme_get_sig_string_attr): Hack to return info on the key + usage. Does now make use of the former RESERVED argument which + has been renamed to WHATIDX. + (gpgme_get_sig_ulong_attr): Renamed RESERVED to WHATIDX. + +2002-06-14 Marcus Brinkmann + + * wait.c (do_select): Return -1 on error, and 0 if nothing to run. + (_gpgme_wait_one): Only set HANG to zero if do_select returned an + error, or there are no more file descriptors to wait on. + (_gpgme_wait_on_condition): Ignore return value from do_select for + now. + +2002-06-13 Werner Koch + + * verify.c (gpgme_op_verify): Make sure that we never access an + unitialized result structure. + +2002-06-12 Werner Koch + + * keylist.c (struct keylist_result_s): New. + (_gpgme_release_keylist_result): Release it here + (keylist_status_handler): Handle truncated. + (append_xml_keylistinfo): New. + * gpgme.c (_gpgme_release_result): and use it here. + * types.h: Declare the new type here. + * context.h (struct gpgme_context_s): Use it here. + +2002-06-11 Marcus Brinkmann + + * engine-gpgsm.c (_gpgme_gpgsm_release): Close status_cb.fd. + (_gpgme_gpgsm_new): Duplicate status file descriptor, so we can + use our own close notification mechanism without interfering with + assuan. + +2002-06-11 Werner Koch + + * gpgme.h: Add GPGME_ATTR_SIG_SUMMARY and the GPGME_SIGSUM_ + constants. + * verify.c (calc_sig_summary): New. + (gpgme_get_sig_ulong_attr): And use it here. + +2002-06-10 Werner Koch + + * rungpg.h: Add new status codes TRUNCATED and ERROR. + * verify.c (is_token, copy_token): New. + (_gpgme_verify_status_handler): Use copy_token, handle the new + ERROR status and store the errorcode used withgpgsm and trust + status codes. + * gpgme.h: New attribute ERRTOK. + * key.c (gpgme_key_get_string_attr): Add dummy case for it. + (gpgme_get_sig_string_attr): Use it here to return the last error. + +2002-06-10 Marcus Brinkmann + + * engine-gpgsm.c (_gpgme_gpgsm_start): Move the code that sets the + close notification for the status fd to ... + (_gpgme_gpgsm_new): ... here. + * wait.h: Include "sema.h". Remove prototypes of + _gpgme_remove_proc_from_wait_queue and + _gpgme_register_pipe_handler. Add prototypes of + _gpgme_fd_table_init, _gpgme_fd_table_deinit, _gpgme_fd_table_put, + _gpgme_add_io_cb, _gpgme_remove_io_cb, _gpgme_wait_event_cb and + _gpgme_wait_one.. + * wait.c: Remove global variables PROC_QUEUE, PROC_QUEUE_LOCK, + FD_TABLE_SIZE, FD_TABLE, FD_TABLE_LOCK. New global variables + FDT_GLOBAL, CTX_DONE_LIST, CTX_DONE_LIST_SIZE, + CTX_DONE_LIST_LENGTH and CTX_DONE_LIST_LOCK. Remove struct + proc_s. Replace struct wait_item_s. + (_gpgme_fd_table_init): New function. + (_gpgme_fd_table_deinit): Likewise. + (_gpgme_fd_table_put): Likewise. + (set_process_done): Remove function. + (do_select): Take argument FDT. Use that to decide which fds to + select on. + (_gpgme_remove_proc_from_wait_queue): Remove function. + (_gpgme_wait_event_cb): New function. + (_gpgme_wait_one): Likewise. + (_gpgme_register_pipe_hanldler): Remove function. + (_gpgme_add_io_cb): New function. + (_gpgme_remove_io_cb): Likewise. + (_gpgme_freeze_fd): Remove function. + (_gpgme_thaw_fd): Remove function. + * rungpg.c (struct fd_data_map_s): Add new member TAG. + (struct gpg_object_s): Likewise for STATUS and COLON. Add member + IDX to CMD. Add new member IO_CBS. + (close_notify_handler): New variables POSSIBLY_DONE and NOT_DONE. + For each I/O callback, check if it should be unregistered. If all + callbacks have been unregistered, trigger GPGME_EVENT_DONE. + Remove member RUNNING. + (_gpgme_gpg_new): Initialize new members. + (_gpgme_gpg_release): Check PID not RUNNING. Don't call + _gpgme_remove_proc_from_wait_queue. Close GPG->CMD.FD if set. + (build_argv): Store away the index instead the file descriptor for + CMD. + (_gpgme_gpg_add_io_cb): New function. + (_gpgme_gpg_spawn): Use _gpgme_gpg_add_io_cb to register IO + callbacks. + (gpg_status_handler): Change return type to void, remove PID + argument, close filedescriptor if EOF or error occurs. + (read_status): Use _gpgme_gpg_add_io_cb instead _gpgme_thaw_fd. + Use IO_CBS->remove instead _gpgme_freeze_fd. + (gpg_colon_line_handler): Change return type to void, remove PID + argument, close filedescriptor if EOF or error occurs. + (command_cb): Use IO_CBS->remove instead _gpgme_freeze_fd. + (_gpgme_gpg_set_io_cbs): New function. + * rungpg.h (_gpgme_gpg_set_io_cbs): Prototype for + _gpgme_gpg_set_io_cbs. + * gpgme.h (GpgmeIOCb): New type. + (GpgmeRegisterIOCb): Likewise. + (GpgmeRemoveIOCb): Likewise. + (GpgmeEventIO): Likewise. + (GpgmeEventIOCb): Likewise. + (struct GpgmeIOCbs): New structure to hold I/O callbacks. + (gpgme_set_op_io_cbs): New prototype. + (gpgme_get_op_io_cbs): Likewise. + * ops.h: New prototype for _gpgme_op_event_cb. Remove prototypes + for _gpgme_freeze_fd and _gpgme_thaw_fd. Remove PID argument from + _gpgme_data_inbound_handler and _gpgme_data_outbound_handler + prototype. Add prototype for _gpgme_op_reset. + Add synchronous argument to _gpgme_decrypt_start prototype. + * io.h: Beautification. + * gpgme.c: Include "wait.h". + (gpgme_new): Initialize FDT. + (gpgme_set_io_cbs): New function. + (gpgme_get_io_cbs): Likewise. + (_gpgme_op_event_cb): Likewise. + * data.c (_gpgme_data_inbound_handler): Change return type to + void. Drop PID argument. Close FD on error and EOF. + (write_mem_data): Don't close FD here ... + (write_cb_data): ... or here ... + (_gpgme_data_outbound_handler): ... but here. Change return type + to void. Drop PID argument. + * context.h: Include "wait.h". + (struct gpgme_context_s): New members FDT and IO_CBS. + * op-support.c: New file. + * Makefile.am (libgpgme_la_SOURCES): Add op-support.c. + * ops.h: Add prototype for _gpgme_op_reset(). + * decrypt.c (_gpgme_decrypt_start): New argument SYNCHRONOUS. Use + _gpgme_op_reset. + (gpgme_op_decrypt_start): Add synchronous argument. + (gpgme_op_decrypt): Likewise. Use _gpgme_wait_one instead + gpgme_wait. + * delete.c (gpgme_op_delete_start): Rename to ... + (_gpgme_op_delete_start): ... this. New argument SYNCHRONOUS. + Use _gpgme_op_reset. Make function static. + (gpgme_op_delete_start): Just a wrapper around + _gpgme_op_delete_start now. + (gpgme_op_delete): Add synchronous argument. Use _gpgme_wait_one + instead gpgme_wait. + * encrypt.c: Include "wait.h". + (ggpgme_op_encrypt_start): Rename to ... + (_gpgme_op_encrypt_start): ... this. New argument SYNCHRONOUS. + Use _gpgme_op_reset. Make function static. + (gpgme_op_encrypt_start): Just a wrapper around + _gpgme_op_encrypt_start now. + (gpgme_op_encrypt): Add synchronous argument. Use _gpgme_wait_one + instead gpgme_wait. + * encrypt_sign.c (gpgme_op_encrypt_sign_start): Rename to ... + (_gpgme_op_encrypt_sign_start): ... this. New argument + SYNCHRONOUS. Use _gpgme_op_reset. Make function static. + (gpgme_op_encrypt_sign_start): Just a wrapper around + _gpgme_op_encrypt_sign_start now. + (gpgme_op_encrypt_sign): Add synchronous argument. Use + _gpgme_wait_one instead gpgme_wait. + * export.c (gpgme_op_export_start): Rename to ... + (_gpgme_op_export_start): ... this. New argument SYNCHRONOUS. + Use _gpgme_op_reset. Make function static. + (gpgme_op_export_start): Just a wrapper around + _gpgme_op_export_start now. + (gpgme_op_export): Add synchronous argument. Use _gpgme_wait_one + instead gpgme_wait. + * genkey.c (gpgme_op_genkey_start): Rename to ... + (_gpgme_op_genkey_start): ... this. New argument SYNCHRONOUS. + Use _gpgme_op_reset. Make function static. + (gpgme_op_genkey_start): Just a wrapper around + _gpgme_op_genkey_start now. + (gpgme_op_genkey): Add synchronous argument. Use _gpgme_wait_one + instead gpgme_wait. + * import.c (gpgme_op_import_start): Rename to ... + (_gpgme_op_import_start): ... this. New argument SYNCHRONOUS. + Use _gpgme_op_reset. Make function static. + (gpgme_op_import_start): Just a wrapper around + _gpgme_op_import_start now. + (gpgme_op_import): Add synchronous argument. Use _gpgme_wait_one + instead gpgme_wait. + * keylist.c (gpgme_op_keylist_start): Use _gpgme_op_reset. + (gpgme_op_keylist_ext_start): Likewise. + * sign.c (gpgme_op_sign_start): Rename to ... + (_gpgme_op_sign_start): ... this. New argument SYNCHRONOUS. Use + _gpgme_op_reset. Make function static. + (gpgme_op_sign_start): Just a wrapper around _gpgme_op_sign_start + now. + (gpgme_op_sign): Add synchronous argument. Use _gpgme_wait_one + instead gpgme_wait. + * trustlist.c (gpgme_op_trustlist_start): Use _gpgme_op_reset. + * verify.c (gpgme_op_verify_start): Rename to ... + (_gpgme_op_verify_start): ... this. New argument SYNCHRONOUS. + Use _gpgme_op_reset. Make function static. + (gpgme_op_verify_start): Just a wrapper around + _gpgme_op_verify_start now. + (gpgme_op_verify): Add synchronous argument. Use _gpgme_wait_one + instead gpgme_wait. + * engine-gpgsm.c (iocb_data_t): New type. + (struct gpgsm_object_s): New member status_cb. Replace input_fd + and input_data with input_cb. Replace output_fd and output_data + with output_cb. Replace message_fd and message_data with + message_cb. New member io_cbs. + (_gpgme_gpgsm_new): Initialize all new members (and drop the old + ones). + (close_notify_handler): New variable POSSIBLY_DONE. For each I/O + callback, check if it should be unregistered. If all callbacks + have been unregistered, trigger GPGME_EVENT_DONE. + (_gpgme_gpgsm_release): Remove variable PID. Use new variable + names to close the file descriptors. + (_gpgme_gpgsm_op_decrypt): Use new variable names, + (_gpgme_gpgsm_op_encrypt): Likewise. + (_gpgme_gpgsm_op_genkey): Likewise. + (_gpgme_gpgsm_op_import): Likewise. + (_gpgme_gpgsm_op_keylist): Likewise. + (_gpgme_gpgsm_op_keylist_ext): Likewise. + (_gpgme_gpgsm_op_sign): Likewise. + (_gpgme_gpgsm_op_verify): Likewise. + (gpgsm_status_handler): Drop argument PID. Change return type to + void. Close status pipe before returning because of EOF or error. + (_gpgme_gpgsm_add_io_cb): New function. + (_gpgme_gpgsm_start): Use _gpgme_gpgsm_add_io_cb to register + callback function. + (_gpgme_gpgsm_set_io_cbs): New function. + * engine-gpgsm.h: New prototype for _gpgme_gpgsm_set_io_cbs. + * engine.c (_gpgme_engine_set_io_cbs): New function. + * engine.h: New prototype for _gpgme_engine_set_io_cbs. + +2002-06-04 Marcus Brinkmann + + * Makefile.am (libgpgme_la_SOURCES): Remove mutex.h. + +2002-06-03 Marcus Brinkmann + + * key.c: Include . + (_gpgme_key_append_name): Skip one more char when + processing escaped char. Submitted by Marc Mutz . + Handle hexadecimal encodings. Also reported by Marc. Thanks! + +2002-06-02 Marcus Brinkmann + + * ath.h: Enable the _gpgme_ prefix. Fix all those prefix macros. + * posix-sema.c: Use that prefix here. + * posix-io.c: Include "ath.h". + (_gpgme_io_read): Use _gpgme_ath_read instead read. + (_gpgme_io_write): Use _gpgme_ath_write instead write. + (_gpgme_io_waitpid): Use _gpgme_ath_waitpid instead waitpid. + (_gpgme_io_select): Use _gpgme_ath_select instead select. + +2002-06-02 Marcus Brinkmann + + * Makefile.am (ath_components): New variable. + (ath_components_pthread): Likewise. + (ath_components_pth): Likewise. + (system_components): Add ath_componentes. + + * ath.h: New file. + * ath.c: Likewise. + * ath-pthread.c: Likewise. + * ath-pth.c: Likewise. + * posix-sema.c (_gpgme_sema_cs_enter): Rework to use the ATH + interface. + * mutex.h: Remove file. + +2002-05-30 Werner Koch + + * key.c (gpgme_key_get_string_attr): Return NULL when asking for + an issuer with IDX > 0. We don't support altIssuerNames for now. + +2002-05-22 Werner Koch + + * engine-gpgsm.c (_gpgme_gpgsm_op_keylist_ext): Aehmm, added + missing variable definition. Oohh - Marcus was faster. + +2002-05-22 Marcus Brinkmann + + * engine-gpgsm.c (_gpgme_gpgsm_op_keylist_ext): Fix last change. + +2002-05-21 Werner Koch + + * engine-gpgsm.c (_gpgme_gpgsm_op_keylist) + (_gpgme_gpgsm_op_keylist_ext): Pass the keylist mode to gpgsm. + +2002-05-10 Werner Koch + + * key.h (gpgme_key_s): Add OTRUST. + * keylist.c (set_ownertrust): New. + (keylist_colon_handler): Get the ownertrust value + * key.c (gpgme_key_get_string_attr,gpgme_key_get_ulong_attr): + Return that value. + +2002-05-08 Marcus Brinkmann + + * w32-util.c: New static variable GET_PATH_LOCK. + (_gpgme_get_gpg_path): Remove superfluous NULL initializer. + Take lock while determining path. + (_gpgme_get_gpgsm_path): Likewise. + * version.c (do_subsystem_inits): Set DONE to 1 after + initialization. + (gpgme_get_engine_info): New variable ENGINE_INFO_LOCK. Take lock + while determining engine info. + * rungpg.c (_gpgme_gpg_get_version): New variable + GPG_VERSION_LOCK. Take the lock while determining the program + version. + * posix-io.c: Include "sema.h". + (_gpgme_io_spawn): New variable FIXED_SIGNALS_LOCK. Take the lock + while fixing the signals. + (_gpgme_io_select): Make READFDS and WRITEFDS non-static. + * key.c: Include "sema.h". New globals KEY_CACHE_LOCK and + KEY_REF_LOCK. + (capabilities_to_string): Make STRINGS very const. + (_gpgme_key_cache_add): Lock the key cache. + (_gpgme_key_cache_get): Likewise. + (gpgme_key_ref, gpgme_key_release): Lock the key_ref_lock. + * import.c (append_xml_impinfo): Make IMPORTED_FIELDS and + IMPORT_RES_FIELDS very const. Make FIELD and FIELD_NAME a litle + const. + * engine.c (_gpgme_engine_get_info): New variable + ENGINE_INFO_LOCK. Take lock while determining engine info. + * engine-gpgsm.c: Include "sema.h". + (_gpgme_gpgsm_get_version): New variable GPGSM_VERSION_LOCK. Take + lock while getting program version. + +2002-05-08 Marcus Brinkmann + + * debug.h: New file. + * Makefile.am (libgpgme_la_SOURCES): Add debug.h. + * util.h: Removed all prototypes and declarations related to + debugging. Include "debug.h". + + * debug.c (debug_level): Comment variable and remove superfluous + zero initializer. + (errfp): Likewise. + (_gpgme_debug_enabled): Function removed. + (struct debug_control_s): Definition removed. + (_gpgme_debug_level): Function removed. + (_gpgme_debug_begin): Rewritten to use vasprintf. Accept a + pritnf-style format specification and a variable number of + arguments. + (_gpgme_debug_add): Rewritten using vasprintf. Expect that format + starts out with "%s" for simplicity. + (_gpgme_debug_end): Rewritten using vasprintf. Do not accept a + TEXT argument anymore. + + * posix-io.c (_gpgme_io_select): Use new level argument for + DEBUG_BEGIN instead explicit if construct. + + * debug.c (debug_init): Remove superfluous zero initializer, + remove volatile flag of INITIALIZED. Do not use the + double-checked locking algorithm, it is fundamentally flawed and + will empty your fridge (on a more serious note, despite the + volatile flag it doesn't give you the guarantee you would expect, + for example on a DEC Alpha or an SMP machine. The volatile only + serializes accesses to the volatile variable, but not to the other + variables). + +2002-05-03 Werner Koch + + * engine-gpgsm.c (_gpgme_gpgsm_new): Redirect any gpgsm error + output to /dev/null. + + * verify.c (gpgme_get_sig_key): Set the protocol of the listctx. + * gpgme.c (gpgme_get_protocol): New. + + * data.c (gpgme_data_write): Changed type of BUFFER to void*. + (gpgme_data_read): Ditto. + + * verify.c (_gpgme_verify_status_handler): Handle TRUST_* status + lines so that a claim can be made without looking up the key. + (gpgme_get_sig_string_attr): New. + (gpgme_get_sig_ulong_attr): New. + + * gpgme.h (GpgmeAttr): Added GPGME_ATTR_SIG_STATUS. + + * rungpg.h: Add new status codes from gpg 1.0.7 and formatted the + list to align with the status.h file from gnupg. + + * gpgme.h (GpgmeSigStat): Add _GOOD_EXP and _GOOD_EXPKEY. + * verify.c (_gpgme_verify_status_handler, finish_sig): Handle + these new status codes. Store the expiration time + +2002-04-27 Werner Koch + + * gpgme.h (GpgmeData_Encoding): New. + * data.c (gpgme_data_get_encoding,gpgme_data_set_encoding): New. + * engine-gpgsm.c (map_input_enc): New. Use it in all local + functions where the INPUT command gets send. + +2002-04-27 Marcus Brinkmann + + * engine-gpgsm.c (_gpgme_gpgsm_op_verify): Close the output + descriptor only when we don't need it anymore. Close the message + descriptor if we don't need it. + +2002-04-26 Werner Koch + + * Makefile.am (libgpgme_la_LIBADD): Use libtool libraries. + +2002-04-25 Marcus Brinkmann + + * rungpg.c (_gpgme_gpg_release): Call gpgme_data_release on + GPG->cmd.cb_data, not xfree. + +2002-04-25 Marcus Brinkmann + + * engine-gpgsm.c (_gpgme_gpgsm_new): Set the display, ttyname, + ttytype, lc_ctype and lc_messages options in the server. + +2002-04-24 Marcus Brinkmann + + * engine-gpgsm.c (map_assuan_error): Add new error codes. + +2002-04-23 Werner Koch + + * key.c (gpgme_key_get_ulong_attr): Swapped use of can_encrypt and + can_certify to return the requested values. + +2002-04-23 Marcus Brinkmann + + * gpgme.c (gpgme_get_progress_cb): Allow either return parameter + to be NULL. + (gpgme_get_passphrase_cb): Likewise. + +2002-04-22 Marcus Brinkmann + + * gpgme.c (gpgme_get_passphrase_cb): New function. + (gpgme_get_progress_cb): New function. + * gpgme.h: Add new prototypes for gpgme_get_passphrase_cb and + gpgme_get_progress_cb. + +2002-03-28 Werner Koch + + * gpgme.h (GpgmeAttr): Add values for issuer and chaining. + * key.h (gpgme_key_s): Add issuer and chaining elements for X509. + * keylist.c (keylist_colon_handler): Store them. + * key.c (gpgme_key_release): Free them. + (gpgme_key_get_as_xml,gpgme_key_get_string_attr): Print them. + +2002-03-26 Werner Koch + + * Makefile.am (libgpgme_la_SOURCES): Add mutex.h + +2002-03-21 Werner Koch + + * util.h [!HAVE_FOPENCOOKIE]: Make sure off_t and ssize_t are + defined. + +2002-03-18 Marcus Brinkmann + + * Makefile.am (system_components): New variable, set depending on + HAVE_DOSISH_SYSTEM. + (libgpgme_la_SOURCES): Use system_components. Remove `syshdr.h'. + * syshdr.h: File removed. + + * posix-io.c: Remove !HAVE_DOSISH_SYSTEM safeguard. Clean up source. + * posix-sema.c: Likewise. + * posix-util.c: Likewise. + + * w32-io.c: Remove HAVE_DOSISH_SYSTEM safeguard. + * w32-sema.c: Likewise. + * w32-util.c: Likewise. + + * posix-io.c: Include `unistd.h', do not include `syshdr.h'. + * posix-sema.c: Likewise. + * w32-io.c: Include `io.h', do not include `syshdr.h' + * w32-sema.c: Likewise. + * w32-util.c: Likewise. + * data.c: Do not include `syshdr.h'. + * wait.c: Likewise. + * wait.h: Code cleanup. + + * mutex.h: New file. + * posix-sema.c: Implement. + +2002-03-08 Werner Koch + + * util.h [!HAVE_FOPENCOOKIE]: Fixed type. Thanks to Frank Heckenbach. + +2002-03-07 Werner Koch + + * gpgme.h (gpgme_op_keylist_ext_start): Add prototype. + +2002-03-06 Marcus Brinkmann + + * encrypt.c (_gpgme_encrypt_sym_status_handler): New function. + (gpgme_op_encrypt_start): New variable SYMMETRIC, set it if RECP + is null, and if it is set, use _gpgme_encrypt_sym_status_handler + as status handler and run _gpgme_passphrase_start. + * rungpg.c (_gpgme_gpg_op_encrypt): If RECP is zero, do symmetric + encryption. + * engine-gpgsm.c (_gpgme_gpgsm_op_encrypt): If RECP is zero, + return error value. + + * rungpg.c (_gpgme_gpg_op_verify): Add "--" argument. + +2002-03-03 Marcus Brinkmann + + * passphrase.c (_gpgme_passphrase_status_handler): Also set the + error No_Passphrase if only a bad passphrase was provided. + +2002-03-03 Marcus Brinkmann + + * rungpg.c (_gpgme_gpg_op_verify): If TEXT is of mode + GPGME_DATA_MODE_IN, construct a command line that stores the + plaintext in TEXT. + * verify.c (gpgme_op_verify_start): Accept TEXT being + uninitialized, and in this case interpret SIG as a normal or + cleartext signature and TEXT as a return data object. + * engine-gpgsm.c (_gpgme_gpgsm_op_verify): Likewise. + +2002-03-03 Marcus Brinkmann + + * engine-gpgsm.c (_gpgme_gpgsm_op_keylist_ext) [!ENABLE_GPGSM]: + Add stub function. + +2002-02-28 Werner Koch + + * key.h (subkey_s): New member expires_at. + * keylist.c (keylist_colon_handler): Set it here + * key.c (gpgme_key_get_as_xml,gpgme_key_get_ulong_attr): Return it. + +2002-02-27 Marcus Brinkmann + + * rungpg.h (_gpgme_gpg_op_keylist_ext): New prototype. + * rungpg.c (_gpgme_gpg_op_keylist_ext): New function. + * engine-gpgsm.h (_gpgme_gpgsm_op_keylist_ext): New prototype. + * engine-gpgsm.c (_gpgme_gpgsm_op_keylist_ext): New function. + * engine.h (_gpgme_engine_op_keylist_ext): New prototype. + * engine.c (_gpgme_engine_op_keylist_ext): New function. + * keylist.c (gpgme_op_keylist_ext_start): New function. + +2002-02-27 Marcus Brinkmann + + * gpgme.h: Add new error code GPGME_Invalid_Recipient. + * encrypt.c (struct encrypt_result_s): New member invalid_recipients, + rename no_recipients to no_valid_recipients. + (_gpgme_encrypt_status_handler): Include error for invalid + recipients. + * engine-gpgsm.c (gpgsm_set_recipients): Change type of first + argument to GpgsmObject. Use that to report back the status about + the recipients. + +2002-02-26 Marcus Brinkmann + + * verify.c (_gpgme_verify_status_handler): Fix the last change. + +2002-02-25 Marcus Brinkmann + + * engine.c (_gpgme_engine_op_encrypt_sign): New function. + * engine.h (_gpgme_engine_op_encrypt_sign): New prototype. + * rungpg.c (_gpgme_append_gpg_args_from_signers): New function. + (_gpgme_gpg_op_sign): Use that new function. + (_gpgme_gpg_op_encrypt_sign): New function. + * rungpg.h (_gpgme_gpg_op_encrypt_sign): New prototype. + * gpgme.h (gpgme_op_encrypt_sign_start): New prototype. + (gpgme_op_encrypt_sign): Likewise. + * Makefile.am (libgpgme_la_SOURCES): Add encrypt-sign.c. + * ops.h (_gpgme_encrypt_status_handler): Add prototype. + (_gpgme_sign_status_handler): Add prototype. + * sign.c (sign_status_handler): Rename to ... + (_gpgme_sign_status_handler): ... this and make non-static. + * encrypt.c (encrypt_status_handler): Rename to ... + (_gpgme_encrypt_status_handler): ... this and make non-static. + * encrypt.c (gpgme_op_encrypt_start): Use new status handler name. + * sign.c (gpgme_op_sign_start): Likewise. + +2002-02-25 Marcus Brinkmann + + * verify.c (_gpgme_verify_status_handler): Parse the args line to + see if the problem is due to a missing key, and report that back + to the user. + +2002-02-25 Marcus Brinkmann + + * context.h (struct gpgme_context_s): New member include_certs. + * gpgme.h (gpgme_set_include_certs): Add prototype. + (gpgme_get_include_certs): Likewise. + * gpgme.c (gpgme_set_include_certs): New function. + (gpgme_get_include_certs): Likewise. + (gpgme_new): Set include_certs to 1 (the default). + * engine.c (_gpgme_engine_op_sign): Accept new argument include_certs, + and pass it to _gpgme_gpgsm_op_sign. + * engine.h (_gpgme_engine_op_sign): Likewise for prototype. + * engine-gpgsm.c (_gpgme_gpgsm_op_sign): Accept new argument + include_certs and handle it. + * engine-gpgsm.h (_gpgme_gpgsm_start): Add new argument include_certs. + * sign.c (gpgme_op_sign_start): Add new argument to + _gpgme_engine_op_sign call. + +2002-02-14 Werner Koch + + * keylist.c (gpgme_op_keylist_start): Do not use a verbose listing. + +2002-02-13 Werner Koch + + * vasprintf.c, fopencookie.c: Add replacement functions. + * util.h: Add prototypes for them. + +2002-02-09 Marcus Brinkmann + + * engine-gpgsm.c (gpgsm_assuan_simple_command): Return 0 if we + reach the end of the function. + +2002-02-09 Marcus Brinkmann + + * genkey.c (gpgme_op_genkey_start): Fix logic in validity check. + (gpgme_op_genkey_start): Skip newlines after opening tag. + + * engine-gpgsm.c (_gpgme_gpgsm_start): Remove cruft. + +2002-02-08 Marcus Brinkmann + + * genkey.c (gpgme_op_genkey_start): Allow PUBKEY and SECKEY to be + set, and pass them down to the crypto engine. + * engine-gpgsm.h (_gpgme_gpgsm_start): New arguments PUBKEY and SECKEY. + * engine.h: Likewise. + * rungpg.h (_gpgme_gpg_spawn): Likewise. + * engine.c (_gpgme_engine_op_genkey): Likewise. Use those + arguments. + * rungpg.c (_gpgme_gpg_op_genkey): Likewise. Complain if those + arguments are set. + * engine-gpgsm.c (_gpgme_gpgsm_op_genkey): Likewise. Implement + function. + + * engine-gpgsm.c (_gpgme_gpgsm_op_keylist): Beautify comment. + +2002-02-06 Marcus Brinkmann + + * rungpg.c (_gpgme_gpg_op_keylist): Remove handling of keylist + mode (for now). + +2002-02-06 Marcus Brinkmann + + * wait.c (gpgme_wait): Add new argument STATUS, in which the + status of the returned context is returned. + (_gpgme_wait_on_condition): Rework the function a bit, to make it + aware of cancelled processes, and to allow to use gpgme_wait with + CTX being NULL (as documented in the source). + (struct proc_s): New member REPORTED. + * gpgme.h: Fix prototype. + * verify.c (gpgme_op_verify): Fix use of gpgme_wait. + * sign.c (gpgme_op_sign): Likewise. + * import.c (gpgme_op_import): Likewise. + * genkey.c (gpgme_op_genkey): Likewise. + * export.c (gpgme_op_export): Likewise. + * encrypt.c (gpgme_op_encrypt): Likewise. + * delete.c (gpgme_op_delete): Likewise. + * decrypt-verify.c (gpgme_op_decrypt_verify): Likewise. + +2002-02-06 Marcus Brinkmann + + * gpgme.c (gpgme_set_keylist_mode): Possibly return an error + value. + (gpgme_get_keylist_mode): New function. + (gpgme_new): Set the default for keylist_mode member of CTX. + + * gpgme.h (gpgme_set_keylist_mode): Fix prototype. + (gpgme_get_keylist_mode): New prototype. + (GPGME_KEYLIST_MODE_LOCAL): New macro. + (GPGME_KEYLIST_MODE_EXTERN): Likewise.. + +2002-02-02 Marcus Brinkmann + + This patch has gotten a bit large... mmh. The main thing that + happens here is that error values are now not determined in the + operation function after gpgme_wait completed, but in the status + handler when EOF is received. It should always be the case that + either an error is flagged or EOF is received, so that after a + gpgme_wait you should never have the situation that no error is + flagged and EOF is not received. One problem is that the engine + status handlers don't have access to the context, a horrible + kludge works around this for now. All errors that happen during a + pending operation should be catched and reported in ctx->error, + including out-of-core and cancellation. This rounds up neatly a + couple of loose ends, and makes it possible to pass up any errors + in the communication with the backend as well. As a bonus, there + will be a function to access gpgme->wait, so that the operations + can truly be implemented with their _start function. + + * engine-gpgsm.c (gpgsm_status_handler): Horrible kludge to report + error back to the context. + * rungpg.c (gpg_status_handler): Same horrible kludge applied here. + + * engine-gpgsm.c (gpgsm_assuan_simple_command): Add error checking. + + * wait.c (_gpgme_wait_on_condition): If canceled, set CTX->error + to a value indication that. + + * verify.c (add_notation): Set error, not out_of_core. + (finish_sig): Likewise. + (gpgme_op_verify_start): Don't clear out_of_core. + (_gpgme_verify_status_handler): At EOF, clean up the notation data. + (gpgme_op_verify): And don't do it here. + + * trustlist.c (trustlist_status_handler): Check error, not out_of_core. + (gpgme_op_trustlist_start): Don't clear out_of_core. + (gpgme_op_trustlist_next): Check error, not out_of_core. + (gpgme_op_trustlist_end): Likewise. + + * ops.h (test_and_allocate_result): New macro. + (_gpgme_passphrase_result): Remove prototype. + * delete.c (gpgme_op_delete): Return error from context. + (delete_status_handler): Use macro test_and_allocate_result. + Perform error checking at EOF. + (gpgme_op_delete_start): Release result. + * passphrase.c (_gpgme_passphrase_status_handler): Use macro + test_and_allocate_result, and perform error checking here. + (_gpgme_passphrase_result): Function removed. + * sign.c (gpgme_op_sign_start): Do not set out_of_core to zero. + (gpgme_op_sign): Just return the error value from the context. + (sign_status_handler): Only progress if no error is set yet. If + we process an EOF, set the resulting error value (if any). + * decrypt.c (_gpgme_decrypt_result): Function removed. + (create_result_struct): Function removed. + (_gpgme_decrypt_status_handler): Use macro test_and_allocate_result, + caclulate error on EOF, do not progress with errors. + (_gpgme_decrypt_start): Do not set out_of_core to zero. + (gpgme_op_decrypt): Just return the error value from the context. + * encrypt.c (encrypt_status_handler): Perform the error checking + here. + (gpgme_op_encrypt_start): Do not clear out_of_core. + * export.c (export_status_handler): Return if error is set in context. + (gpgme_op_export_start): Release result. + (gpgme_op_export): Return error from context. + * decrypt-verify.c (gpgme_op_decrypt_verify): Return the error in + the context. + * genkey.c (genkey_status_handler): Use macro + test_and_allocate_result. Perform error checking at EOF. + (gpgme_op_genkey): Just return the error from context. + * import.c (gpgme_op_import): Return the error from context. + (import_status_handler): Use macro test_and_allocate_result. + * keylist.c (gpgme_op_keylist_start): Do not clear out_of_core. + (gpgme_op_keylist_next): Return error of context. + (keylist_colon_handler): Set error instead out_of_code. + (finish_key): Likewise. + + * context.h: Remove member out_of_core, add member error. + * gpgme.c (_gpgme_release_result): Clear error flag. + + * engine.h (_gpgme_engine_get_error): New prototype. + * engine.c (_gpgme_engine_get_error): New function. + * engine-gpgsm.c (_gpgme_gpgsm_get_error): New function. + + * engine-gpgsm.c (map_assuan_error): New function. + (gpgsm_assuan_simple_command): Change return type to GpgmeError, + use the new function to map error values. + (gpgsm_set_fd): Change return type tp GpgmeError. + (_gpgme_gpgsm_op_decrypt): Change type of ERR to GpgmeError. + (gpgsm_set_recipients): Likewise. Change type of return value + equivalently. Adjust error values. + (_gpgme_gpgsm_op_import): Likewise. + (_gpgme_gpgsm_op_sign): Likewise. + (struct gpgsm_object_s): New member error. + (gpgsm_status_handler): Set error if error occurs. Determine + error number from ERR line received. If assuan_read_line fails, + terminate the connection. + +2002-02-01 Marcus Brinkmann + + * Makefile.am (MOSTLYCLEANFILES): New variable. + +2002-02-01 Marcus Brinkmann + + * engine-gpgsm.c (gpgsm_status_handler): At error, terminate the + connection to the server. + +2002-01-31 Marcus Brinkmann + + * rungpg.h: Add STATUS_KEY_CREATED. + + * progress.c: New file. + * Makefile.am (libgpgme_la_SOURCES): Add progress.c. + + * genkey.c (genkey_status_handler): Use + _gpgme_progress_status_handler. Add check for status. + (struct genkey_result_s): New structure. + (_gpgme_release_genkey_result): New function. + (gpgme_op_genkey): Check for error. + * gpgme.c (_gpgme_release_result): Call + _gpgme_release_genkey_result. + * ops.h (_gpgme_release_genkey_result): Add prototype. + * types.h (GenKeyResult): New type. + * context.h (gpgme_context_s): Add GenKeyResult to member result. + +2002-01-30 Marcus Brinkmann + + * gpgme.c (_gpgme_release_result): Call + _gpgme_release_delete_result. + * ops.h (_gpgme_release_delete_result): Add prototype. + * types.h (DeleteResult): New type. + * context.h (gpgme_context_s): Add DeleteResult to member result. + + * delete.c (enum delete_problem): New type. + (struct delete_result_s): New structure. + (_gpgme_release_delete_result): New function. + (delete_status_handler): Implement more status codes. + (gpgme_op_delete): Return error on failure. + + * import.c (MAX_IMPORTED_FIELDS): Bump up to 14. + +2002-01-30 Marcus Brinkmann + + * import.c (struct import_result_s): New structure. + (_gpgme_release_import_result): New function. + (append_xml_impinfo): Likewise. + (import_status_handler): Implement. + * gpgme.c (_gpgme_release_result): Add call to + _gpgme_release_import_result. + * ops.h (_gpgme_release_import_result): Add prototype. + * types.h (ImportResult): New type. + * context.h (gpgme_context_s): Add ImportResult to member result. + + * encrypt.c (gpgme_op_encrypt): Code clean up. + +2002-01-30 Marcus Brinkmann + + * gpgme.h: Add lots of comment and fix the formatting. Add + gpgme_trustlist_end prototype. + +2002-01-29 Marcus Brinkmann + + * gpgme.h: Add new type GpgmeIdleFunc. Change type of + gpgme_register_idle to return and accept this type. + * wait.c (gpgme_register_idle): Fix type. + Save and return old value of idle_function. + +2002-01-29 Werner Koch + + * engine-gpgsm.c (_gpgme_gpgsm_op_keylist): Implement secret only mode. + + * keylist.c (keylist_colon_handler): Add support for the new "crs" + record type. + +2002-01-22 Marcus Brinkmann + + * engine-gpgsm.c (_gpgme_gpgsm_release): Call assuan_disconnect, + not assuan_pipe_disconnect. + + * Makefile.am (libgpgme_la_LIBADD): Change to link assuan and + jnlib (needed by assuan) statically into libgpgme. Linking a + static library into a shared library this way is not portable. + +2002-01-22 Marcus Brinkmann + + * gpgme.h (GpgmePassphraseCb): Change type of R_HD from void* to + void**. + +2002-01-22 Marcus Brinkmann + + * data.c (gpgme_data_new_from_filepart): Change type of LENGTH + from off_t to size_t. + * gpgme.h: Likewise. + +2002-01-22 Marcus Brinkmann + + * wait.c (_gpgme_wait_on_condition): If the process finished, + reset the pending flag. Also if the operation was cancelled. + + (struct proc_s): Rename READY to DONE. + (wait_item_s): Likewise. + (set_process_ready): Rename to ... + (set_process_done): ... this. + (_gpgme_remove_proc_from_wait_queue): Call set_process_done + instead set_process_ready. + (_gpgme_wait_on_condition): Likewise. + (do_select): Rename READY to DONE. + + * verify.c (gpgme_op_verify): Do not set pending to zero here. + * sign.c (gpgme_op_sign): Likewise. + * import.c (gpgme_op_import): Likewise. + * genkey.c (gpgme_op_genkey): Likewise. + * export.c (gpgme_op_export): Likewise. + * encrypt.c (gpgme_op_encrypt): Likewise. + * delete.c (gpgme_op_delete): Likewise. + * decrypt-verify.c (gpgme_op_decrypt_verify): Likewise. + * decrypt.c (gpgme_op_decrypt): Likewise. + +2002-01-22 Marcus Brinkmann + + * export.c: Cleanup. + +2002-01-15 Marcus Brinkmann + + * trustlist.c: Various source clean ups. + (my_isdigit): Removed. + (gpgme_op_trustlist_end): New function. + +2002-01-13 Marcus Brinkmann + + * gpgme.c: Various source clean ups, like renaming C to CTX where + appropriate. + (gpgme_new): Clear R_CTX before starting the work. + (my_isdigit): Removed. + (my_isxdigit): Likewise. + + * data.c: Various source clean ups. + (gpgme_data_new_from_mem): Check BUFFER after clearing R_DH. + (gpgme_data_new_with_read_cb): Similar for READ_CB. + (gpgme_data_new_from_file): Loop over fread while EINTR. + (gpgme_data_new_from_filepart): Rediddled a bit. Allow LENGTH to + be zero. Loop over fread while EINTR. + + (my_isdigit): Removed. + (my_isxdigit): Likewise. + +2001-12-21 Marcus Brinkmann + + * engine-gpgsm.c (_gpgme_gpgsm_new): Replace General_Error with + Pipe_Error where appropriate. + +2001-12-19 Marcus Brinkmann + + * engine.c: Include `string.h'. Reported by Stéphane Corthésy. + + * version.c (get_engine_info): Remove prototype. + +2001-12-19 Marcus Brinkmann + + * engine-gpgsm.c (_gpgme_gpgsm_new): New variable CHILD_FDS. + Fill it with the servers fds, and pass it to assuan_pipe_connect. + +2001-12-18 Marcus Brinkmann + + * keylist.c (gpgme_op_keylist_end): New function. + * gpgme.h (gpgme_op_keylist_end): New prototype. + + * engine.h (gpgme_engine_check_version): Move prototype to ... + * gpgme.h (gpgme_engine_check_version): ... here. + + * genkey.c (gpgme_op_genkey_start): Remove unused variable. + +2001-12-18 Marcus Brinkmann + + * version.c (gpgme_get_engine_info): Reimplemented. + (gpgme_check_engine): Reimplemented. + (_gpgme_compare_versions): Return NULL if MY_VERSION is NULL. + + * engine.c: Include `io.h'. + (gpgme_engine_get_info): New function. + * engine.h (gpgme_engine_check_version, _gpgme_engine_get_info): + Add prototype. + +2001-12-18 Marcus Brinkmann + + * rungpg.c (struct reap_s, reap_list, reap_list_lock): Moved to ... + * engine.c (struct reap_s, reap_list, reap_list_lock): ... here. + Include `time.h', `sys/types.h', `assert.h', and `sema.h'. + + * rungpg.c (_gpgme_engine_add_child_to_reap_list): New function. + (do_reaping, _gpgme_gpg_housecleaning): Moved to ... + * engine.c (do_reaping, _gpgme_engine_housecleaning): ... here. + * rungpg.c (_gpgme_gpg_release): Replace code that is now in its + own function by call to _gpgme_engine_add_child_to_reap_list(). + + * wait.c: Include `engine.h'. + (run_idle): Call _gpgme_engine_housecleaning(), not + _gpgme_gpg_housecleaning(). + +2001-12-18 Marcus Brinkmann + + * key.c (_gpgme_key_append_name): Append, not prepend, the uid. + Initialize the next field of the uid structure. + (gpgme_key_get_as_xml): Do not list last uid first. + +2001-12-17 Marcus Brinkmann + + * engine-gpgsm.c (_gpgme_gpgsm_set_colon_line_handler): New + function [!ENABLE_GPGSM]. + +2001-12-14 Marcus Brinkmann + + * engine-gpgsm.c (_gpgme_gpgsm_op_verify): Put TEXT into + message_data, not SIG. + (_gpgme_gpgsm_op_sign): Use `--detached', not `--detach'. + + * sign.c (sign_status_handler): Call + _gpgme_passphrase_status_handler early. + +2001-12-14 Marcus Brinkmann + + * engine-gpgsm.c: Revert last change. + +2001-12-14 Marcus Brinkmann + + * engine-gpgsm.c (gpgsm_status_handler): Freeze the output file + handler when ending this operation, otherwise the wait function + will sit on it. + +2001-12-14 Marcus Brinkmann + + * engine-gpgsm.c (struct gpgsm_object_s): New member colon.attic. + (_gpgme_gpgsm_new): Initialize some more members. + (_gpgme_gpgsm_release): Free the colon line handler's attic line. + (gpgsm_status_handler): Rework the inline-data processing. + +2001-12-13 Marcus Brinkmann + + * rungpg.c (_gpgme_gpg_spawn): Do not add the fds to the child + list that are not dup'ed, for those the close-on-exec flag is set + now. + * version.c (_gpgme_get_program_version): Remove first entry in + CFD, as the close-on-exec flag is now set for this fd. + +2001-12-13 Marcus Brinkmann + + * engine-gpgsm.c (_gpgme_gpgsm_op_encrypt): Do not add `armor' + option to `ENCRYPT'. + * engine-gpgsm.c (gpgsm_set_recipients): Free LINE when returning + successfully. + +2001-12-13 Marcus Brinkmann + + * engine-gpgsm.c (close_notify_handler): New function. + (_gpgme_gpgsm_new): Manage the file descriptors a + bit differently. Do not set close-on-exec flags. + (_gpgme_gpgsm_op_decrypt): Do not set message_fd + to -1, this is done by the close handler. + (_gpgme_gpgsm_op_encrypt): Likewise. + (_gpgme_gpgsm_op_import): Likewise (also for output_fd). + (_gpgme_gpgsm_op_keylist): Likewise (also for input_fd and output_fd). + (_gpgme_gpgsm_op_sign): Likewise. + (_gpgme_gpgsm_op_verify): Likewise, but for output_fd. + + * posix-io.c (_gpgme_io_pipe): Set the close-on-exec flag for the + non-inherited file descriptor index of the pipe. + +2001-12-13 Werner Koch + + * engine-gpgsm.c (_gpgme_gpgsm_set_colon_line_handler): New. + (gpgsm_status_handler): Pass datalines to a colon handler + * engine.c (_gpgme_engine_set_colon_line_handler): Set the colon + handler for gpgsm. + + * engine-gpgsm.c (_gpgme_gpgsm_op_keylist): Allow NULL for + pattern. + (gpgsm_assuan_simple_command): Removed underscore from + assuan_write_line. + (_gpgme_gpgsm_start): Ditto. + (gpgsm_assuan_simple_command): Replaced interal Assuan read + function by the new assuan_read_line. Removed the use of the + internal header. + (gpgsm_status_handler): Ditto. Use the new assuan_pending_line. + (_gpgme_gpgsm_start): Use the documented way to get an fd from + assuan. + + * keylist.c (keylist_colon_handler): Handle "crt" records + * key.h (gpgme_key_s): Add an x509 flag. + * key.c (parse_x509_user_id): New. + (_gpgme_key_append_name): Handle x.509 names. + +2001-12-05 Marcus Brinkmann + + * engine-gpgsm.c (gpgsm_status_handler): Make it work with current + version of assuan. + +2001-12-05 Marcus Brinkmann + + * engine-gpgsm.c (gpgsm_set_fd): Accept one more argument OPT. + (_gpgme_gpgsm_op_encrypt): Pass armor argument to gpgsm_set_fd for + output descriptor. + (_gpgme_gpgsm_op_sign): Likewise. + +2001-12-05 Marcus Brinkmann + + * keylist.c (gpgme_op_keylist_next): Set pending to 0 if EOF + occurs. + +2001-11-26 Marcus Brinkmann + + * engine-gpgsm.c (_gpgme_gpgsm_op_sign): Fix stupid typo. + +2001-11-24 Marcus Brinkmann + + * engine-gpgsm.c (gpgsm_status_handler): Don't break if bsearch fails. + Deal with assuan read line returning more than one line (for now). + +2001-11-23 Marcus Brinkmann + + * engine-gpgsm.c (_gpgme_gpgsm_op_sign): Implement it according to + the current protocol definition. + +2001-11-23 Marcus Brinkmann + + * engine-gpgsm.c (_gpgme_gpgsm_new): Set CLOEXEC flag for parent + ends of the pipe. + +2001-11-22 Marcus Brinkmann + + * engine-gpgsm.c: Include stdlib.h and string.h. Also include, + for now, rungpg.h and status-table.h. + (gpgsm_status_handler): Implement more of the status handler. + +2001-11-22 Marcus Brinkmann + + * engine.c (_gpgme_engine_op_decrypt): Implement CMS case. + (_gpgme_engine_op_delete): Likewise. + (_gpgme_engine_op_encrypt): Likewise. + (_gpgme_engine_op_export): Likewise. + (_gpgme_engine_op_genkey): Likewise. + (_gpgme_engine_op_keylist): Likewise. + (_gpgme_engine_op_sign): Likewise. + (_gpgme_engine_op_trustlist): Likewise. + + * engine-gpgsm.c (_gpgme_gpgsm_op_encrypt): New function. + (gpgsm_assuan_simple_command): Likewise. + (gpgsm_set_recipients): Likewise. + (gpgsm_set_fd): Reimplement using gpgsm_assuan_simple_command. + (_gpgme_gpgsm_op_delete): New function. + (_gpgme_gpgsm_op_export): Likewise. + (_gpgme_gpgsm_op_genkey): Likewise. + (_gpgme_gpgsm_op_sign): Likewise. + (_gpgme_gpgsm_op_keylist): Likewise. + (_gpgme_gpgsm_op_trustlist): Likewise. + (_gpgme_gpgsm_release): Release command. + (_gpgme_gpgsm_op_decrypt): Allocate command. + (_gpgme_gpgsm_op_import): Likewise. + (gpgsm_status_handler): Also treat `ERR' strings as EOF. + +2001-11-22 Marcus Brinkmann + + * gpgme.h (gpgme_set_protocol): New prototype. + +2001-11-22 Marcus Brinkmann + + * engine-gpgsm.c (_gpgme_gpgsm_op_decrypt): New function. + (_gpgme_gpgsm_op_import): Likewise. + +2001-11-22 Marcus Brinkmann + + * engine-gpgsm.c: Shuffle around header inclusion a bit, to still + keep them seperate. + (_gpgme_set_status_handler) [!ENABLE_GPGSM]: New function. + +2001-11-22 Werner Koch + + * engine-gpgsm.c: Include more headers so that NULL and mk_error + is defined even with an undefined GPGSM_PATH. + +2001-11-22 Marcus Brinkmann + + * rungpg.c (gpg_inbound_handler, write_mem_data, write_cb_data, + gpg_outbound_handler): Moved to ... + * data.c (_gpgme_data_inbound_handler, write_mem_data, + write_cb_data, _gpgme_data_outbound_handler): ... here. Make the + _gpgme_* ones non-static. + * data.c: Include io.h. + + * ops.h (_gpgme_data_inbound_handler): New prototype. + (_gpgme_data_outbound_handler): Likewise. + (_gpgme_gpg_spawn): Use these new functions. + + * engine-gpgsm.h (_gpgme_gpgsm_op_decrypt, _gpgme_gpgsm_op_delete, + _gpgme_gpgsm_op_encrypt, _gpgme_gpgsm_op_export, + _gpgme_gpgsm_op_genkey, _gpgme_gpgsm_op_import, + _gpgme_gpgsm_op_keylist, _gpgme_gpgsm_op_sign, + _gpgme_gpgsm_op_trustlist, _gpgme_gpgsm_op_verify, + _gpgme_gpgsm_start, _gpgme_gpgsm_set_status_handler): New prototype. + Include for status handler function. + + * engine-gpgsm.c (struct gpgsm_object_s): New members input_fd, + input_data, output_fd, output_data, message_fd, message_data, command + and status. + (_gpgme_gpgsm_new): Open input, output and message pipes before + connecting to the client. Close server's ends afterwards. + (_gpgme_gpgsm_release): Close open file descriptors. Remove + server process from wait queue. + (_gpgme_gpgsm_op_verify, _gpgme_gpgsm_start, + _gpgme_gpgsm_set_status_handler, gpgms_status_handler): New function. + + * engine.c (_gpgme_engine_start): Implement for GPGME_PROTOCOL_CMS. + (_gpgme_engine_set_status_handler): Likewise. + (_gpgme_engine_op_verify): Likewise. + +2001-11-21 Marcus Brinkmann + + * context.h: Do not include rungpg.h, but engine.h. + (struct gpgme_context_s): Replace member gpg with engine. + * gpgme.c (gpgme_release): Release engine, not gpg. + + * recipient.c (_gpgme_append_gpg_args_from_recifgpients): Function + moved ... + * rungpg.c (_gpgme_append_gpg_args_from_recipients): ... here. + Make static, change order of arguments, and return an error value. + * ops.h (_gpgme_append_gpg_args_from_recipients): Removed prototype. + + * rungpg.h (_gpgme_gpg_op_verify): Add prototype. + (_gpgme_gpg_op_encrypt): Likewise. + (_gpgme_gpg_op_decrypt): Likewise. + (_gpgme_gpg_op_delete): Likewise. + (_gpgme_gpg_op_export): Likewise. + (_gpgme_gpg_op_genkey): Likewise. + (_gpgme_gpg_op_import): Likewise. + (_gpgme_gpg_op_keylist): Likewise. + (_gpgme_gpg_op_sign): Likewise. + (_gpgme_gpg_op_trustlist): Likewise. + * rungpg.c (_gpgme_gpg_op_verify): New function. + (_gpgme_gpg_op_encrypt): Likewise. + (_gpgme_gpg_op_decrypt): Likewise. + (_gpgme_gpg_op_delete): Likewise. + (_gpgme_gpg_op_export): Likewise. + (_gpgme_gpg_op_genkey): Likewise. + (_gpgme_gpg_op_import): Likewise. + (_gpgme_gpg_op_keylist): Likewise. + (_gpgme_gpg_op_sign): Likewise. + (_gpgme_gpg_op_trustlist): Likewise. + + * engine.h (_gpgme_engine_set_status_handler): Add prototype. + (_gpgme_engine_set_command_handler): Likewise. + (_gpgme_engine_set_colon_line_handler): Likewise. + (_gpgme_engine_op_decrypt): Likewise. + (_gpgme_engine_op_delete): Likewise. + (_gpgme_engine_op_encrypt): Likewise. + (_gpgme_engine_op_export): Likewise. + (_gpgme_engine_op_genkey): Likewise. + (_gpgme_engine_op_import): Likewise. + (_gpgme_engine_op_keylist): Likewise. + (_gpgme_engine_op_sign): Likewise. + (_gpgme_engine_op_trustlist): Likewise. + (_gpgme_engine_op_verify): Likewise. + (_gpgme_engine_start): Likewise. + * engine.c (_gpgme_engine_set_status_handler): New function. + (_gpgme_engine_set_command_handler): Likewise. + (_gpgme_engine_set_colon_line_handler): Likewise. + (_gpgme_engine_op_decrypt): Likewise. + (_gpgme_engine_op_delete): Likewise. + (_gpgme_engine_op_encrypt): Likewise. + (_gpgme_engine_op_export): Likewise. + (_gpgme_engine_op_genkey): Likewise. + (_gpgme_engine_op_import): Likewise. + (_gpgme_engine_op_keylist): Likewise. + (_gpgme_engine_op_sign): Likewise. + (_gpgme_engine_op_trustlist): Likewise. + (_gpgme_engine_op_verify): Likewise. + (_gpgme_engine_start): Likewise. + + * verify.c (gpgme_op_verify_start): Reimplement in terms of above + functions. + * encrypt.c (gpgme_op_encrypt_start): Likewise. + * decrypt.c (_gpgme_decrypt_start): Likewise. + * passphrase.c (_gpgme_passphrase_start): Likewise. + * keylist.c (gpgme_op_keylist_start): Likewise. + +2001-11-20 Marcus Brinkmann + + * types.h: Add types EngineObject and GpgsmObject. + + * Makefile.am (libgpgme_la_SOURCES): Add engine-gpgsm.h, + engine-gpgsm.c, engine.h and engine.c. + * engine.h: New file. + * engine.c: Likewise. + * engine-gpgsm.h: Likewise. + * engine-gpgsm.c: Likewise. + + * rungpg.c (_gpgme_gpg_get_version): New function. + (_gpgme_gpg_check_version): Likewise. + * rungpg.h: Add prototypes for _gpgme_gpg_get_version and + _gpgme_gpg_check_version. + + * version.c (compare_versions): Rename to ... + (_gpgme_compare_versions): ... this. Make non-static. + (gpgme_check_version): Use _gpgme_compare_versions rather than + compare_versions. + (gpgme_check_engine): Likewise. + * ops.h (_gpgme_get_program_version): Add prototype. + +2001-11-20 Marcus Brinkmann + + * Makefile.am (libgpgme_la_INCLUDES): Remove obsolete directive. + (AM_CPPFLAGS): New directive [BUILD_ASSUAN]. + (libgpgme_la_LIBADD): Likewise. + +2001-11-20 Marcus Brinkmann + + * version.c: Remove global variables lineno and + tmp_engine_version. + (version_handler): Removed. + (_gpgme_get_program_version): New function. + (get_engine_info): Don't use context and version_handler, + but _gpgme_get_program_version. + * ops.h (_gpgme_get_program_version): Add prototype for + _gpgme_get_program_version (we expect to use it elsewhere soon). + +2001-11-18 Marcus Brinkmann + + * version.c (get_engine_info): If GnuPG is not available, return + an error message. + * posix-util.c (_gpgme_get_gpg_path): Allow GPG_PATH to be + undefined. + (_gpgme_get_gpgsm_path): New function. + * w32-util.c (find_program_in_registry): New static function. + (_gpgme_get_gpg_path): Allow GPG_PATH to be undefined. Rework + to use find_program_in_registry. + (_gpgme_get_gpgsm_path): New function. + (util.h): Prototype _gpgme_get_gpgsm_path). + * rungpg.c (_gpgme_gpg_spawn): Verify that _gpgme_get_gpg_path() + returns non-null. + +2001-11-16 Marcus Brinkmann + + * decrypt-verify.c: New file. + * Makefile.am (libgpgme_la_SOURCES): Add decrypt-verify.c. + * types.h: Add decrypt-verify types. + * ops.h: Likewise. + * context.h: Add result type for decrypt-verify. + * gpgme.h: Add decrypt-verify prototypes. + + * decrypt.c (decrypt_status_handler): Renamed to ... + (_gpgme_decrypt_status_handler): ... this. Make non-static. + (_gpgme_decrypt_start): New function, derived from + gpgme_op_decrypt_start. + (gpgme_op_decrypt_start): Reimplement in terms of + _gpgme_decrypt_start. + (_gpgme_decrypt_result): New function to retrieve error value. + (gpgme_op_decrypt): Use _gpgme_decrypt_result. + * ops.h: Add prototypes for new functions. + + * verify.c (verify_status_handler): Renamed to ... + (_gpgme_verify_status_handler): ... this. Make non-static. + (gpgme_op_verify_start): Use new function name. + (intersect_stati): Renamed to ... + (_gpgme_intersect_stati): ... this. Make non-static. + (gpgme_op_verify): Use new name. + * ops.h: Add prototypes for new functions. + +2001-11-16 Marcus Brinkmann + + * passphrase.c: New file. + * Makefile.am (libgpgme_la_SOURCES): Add passphrase.c. + * ops.h (_gpgme_passphrase_result): Add prototypes from + passphrase.c. + * types.h: Likewise. + * context.h: Add member passphrase to result. + * gpgme.c (_gpgme_release_result): Release passphrase member. + + * decrypt.c: Some formatting and variable name changes (like + CTX instead C). + (struct decrypt_result_s): Remove members now found in + passphrase result. + (_gpgme_release_decrypt_result): Don't release removed members. + (decrypt_status_handler): Call _gpgme_passphrase_status_handler, + and don't handle the cases catched there. + (command_handler): Removed. + (gpgme_op_decrypt_start): Don't set command handler, but invoke + _gpgme_passphrase_start which does it. + (gpgme_op_decrypt): Invoke _gpgme_passphrase_result and drop the + cases covered by it. + + * sign.c Some formatting and variable name changes (like + CTX instead C). + (struct sign_result_s): Remove members now found in + passphrase result. + (_gpgme_release_sign_result): Don't release removed members. + (sign_status_handler): Call _gpgme_passphrase_status_handler, + and don't handle the cases catched there. + (command_handler): Removed. + (gpgme_op_sign_start): Don't set command handler, but invoke + _gpgme_passphrase_start which does it. + (gpgme_op_sign): Invoke _gpgme_passphrase_result and drop the + cases covered by it. + +2001-11-15 Marcus Brinkmann + + * decrypt.c (command_handler): Fix last change. + +2001-11-15 Marcus Brinkmann + + * verify.c (_gpgme_release_verify_result): Rename RES to RESULT. + Rename R2 to NEXT_RESULT. + (intersect_stati): Rename RES to RESULT. + (gpgme_get_sig_status): Likewise. Do not check return_type, but + the member verify of result. + (gpgme_get_sig_key): Likewise. + + * sign.c (_gpgme_release_sign_result): Rename RES to RESULT. If + RESULT is zero, return. + (sign_status_handler, command_handler): Do not check return_type, + but the member sign of result. + (gpgme_op_sign): Likewise. Drop assertion. + + * encrypt.c (_gpgme_release_encrypt_result): Rename RES to RESULT. + If RESULT is zero, return. + (encrypt_status_handler): Do not check return_type, but the member + encrypt of result. + (gpgme_op_encrypt): Likewise. Drop assertion. + + * decrypt.c (_gpgme_release_decrypt_result): Rename RES to RESULT. + (create_result_struct): Do not set result_type. + (command_handler, decrypt_status_handler): Do not check + return_type, but the member decrypt of result. + (gpgme_op_decrypt): Likewise. Drop assertion. + + * context.h (enum ResultType): Removed. + (struct gpgme_context_s): Remove member result_type. + (struct result): Replaces union result. + * gpgme.c: Include string.h. + (_gpgme_release_result): Release all members of c->result, which + is now a struct. Zero out all members of the struct afterwards. + +2001-11-11 Marcus Brinkmann + + * rungpg.c (_gpgme_gpg_release): Release GPG->cmd.cb_data. + Release all members of the list GPG->arglist. + Reported by Michael Schmidt . + +2001-11-02 Marcus Brinkmann + + * rungpg.c (pipemode_copy): Change type of NBYTES to size_t. + + * key.c: Include string.h. + * data.c: Likewise. + * recipient.c: Likewise. + +2001-10-29 Marcus Brinkmann + + * context.h: New member signers_len. + * signers.c (gpgme_signers_clear): Require that signers are + non-NULL with assertion. Use signers_len to determine how much + keys to release. Add documentation. + (gpgme_signers_add): Use signers_len to determine if the buffer is + large enough. Use xtryrealloc rather than xtrymalloc and copying. + Add documentation. + (gpgme_signers_enum): Use signers_len to determine if key is + available. Add documentation. + +2001-10-22 Marcus Brinkmann + + * data.c (_gpgme_data_append): Check if LENGTH is smaller than + ALLOC_CHUNK, not DH->length. + +2001-10-17 Marcus Brinkmann + + * gpgme.c (gpgme_set_protocol): Fix last change. + +2001-10-15 Werner Koch + + * gpgme.h (GpgmeProtocol): New. + * gpgme.c (gpgme_set_protocol): New. + +2001-09-26 Werner Koch + + * gpgme.c (gpgme_set_passphrase_cb): Ignore a NULL context. + (gpgme_set_progress_cb): Ditto. Suggested by Mark Mutz. + +2001-09-17 Werner Koch + + * keylist.c (finish_key): Shortcut for no tmp_key. Changed all + callers to use this function without a check for tmp_key. + + * keylist.c (gpgme_op_keylist_next): Reset the key_cond after + emptying the queue. Bug reported by Stéphane Corthésy. + +2001-09-12 Werner Koch + + * data.c (gpgme_data_rewind): Allow rewind for callbacks. + +2001-09-07 Werner Koch + + * rungpg.h: Add NO_RECP. + * encrypt.c (encrypt_status_handler): Take on No_RECP. + (gpgme_op_encrypt): Better error return. + + * verify.c (verify_status_handler): Take on NODATA. + +2001-09-03 Werner Koch + + * rungpg.h: Added STATUS_INV_RECP. + * gpgme.c (_gpgme_release_result): Add support for new + EncryptResult object. + * encrypt.c (append_xml_encinfo): New. + (encrypt_status_handler): Add some status parsing. + (_gpgme_release_encrypt_result): New. + +2001-08-29 Werner Koch + + * recipient.c (gpgme_recipients_release): Free the list. By Timo. + + * keylist.c (keylist_colon_handler): Do a finish key if we receive + an EOF here. This is probably the reason for a lot of bugs + related to keylisting. It is so obvious. Kudos to Enno Cramer + for pointing that out. + +2001-08-28 Werner Koch + + * gpgme.c, gpgme.h (gpgme_get_op_info): New. + (_gpgme_set_op_info): New. + (_gpgme_release_result): Reset the op_info here. + * sign.c (append_xml_siginfo): New. + (sign_status_handler): Store the sig create information. + +2001-07-31 Werner Koch + + * encrypt.c (gpgme_op_encrypt): Hack to detect no valid recipients. + +2001-07-30 Werner Koch + + * gpgme.c (gpgme_get_armor,gpgme_get_textmode): New. + + * rungpg.c (build_argv): Disable armor comments + * w32-io.c (build_commandline): Need to add quotes here + +2001-07-24 Werner Koch + + * data.c (gpgme_data_read): Add a a way to return the available bytes. + +2001-07-23 Werner Koch + + * util.c: Removed stpcpy() because we use the version from jnlib. + +2001-07-19 Werner Koch + + * mkstatus: Define the collating sequence for sort. + +2001-06-26 Werner Koch + + * rungpg.h: Add STATUS_UNEXPECTED as suggested by Timo. + +2001-06-15 Werner Koch + + * keylist.c (set_userid_flags): Fixed the assigned values. Kudos + to Timo for pointing this out. + +2001-06-01 Werner Koch + + * debug.c (_gpgme_debug_begin): Fixed a /tmp race. Noted by + Johannes Poehlmann. + +2001-05-28 Werner Koch + + * version.c (gpgme_check_engine): Stop version number parsing at + the opening angle and not the closing one. By Tommy Reynolds. + +2001-05-01 José Carlos García Sogo + + * encrypt.c (gpgme_op_encrypt_start): Deleted the assert ( !c->gpg ) + line, because it gave an error if another operation had been made + before using the same context. + + * decrypt.c (gpgme_op_decrypt_start): The same as above. Also added + one line to release the gpg object in the context (if any). + +2001-04-26 Werner Koch + + * key.c, key.h (_gpgme_key_cache_init): New. + (_gpgme_key_cache_add): New. + (_gpgme_key_cache_get): New. + * version.c (do_subsystem_inits): Init the cache. + * keylist.c (finish_key): Put key into the cache + * verify.c (gpgme_get_sig_key): First look into the cache. + +2001-04-19 Werner Koch + + * keylist.c (parse_timestamp): Adjusted for the changed + --fixed-list-mode of gpg 1.0.4h. + +2001-04-05 Werner Koch + + * verify.c (gpgme_op_verify_start): Enabled pipemode for detached sigs. + +2001-04-04 Werner Koch + + * w32-io.c (_gpgme_io_select): Don't select on the writer if there + are still bytes pending. Timo found this not easy to track down + race condition. + +2001-04-02 Werner Koch + + * gpgme.h: Add GPGME_ATTR_KEY_{EXPIRED,DISABLED}. + * key.c (gpgme_key_get_ulong_attr): And return those attribs. + + * verify.c (gpgme_get_sig_key): Set keyliosting mode depending on + the mode set in the current context. Suggested by Timo. + + * key.c (gpgme_key_get_ulong_attr): Return can_certify and not + can_encrypt. By Timo. + +2001-03-30 Werner Koch + + * debug.c (debug_init): Allow to specify a debug file. + (_gpgme_debug_level): New. + + * posix-io.c (_gpgme_io_read, _gpgme_io_write): Print output. + (_gpgme_io_select): Debug only with level > 2. + +2001-03-15 Werner Koch + + * rungpg.c: Included time.h. + + * key.h: New keyflags for capabilities. + * keylist.c (set_mainkey_capability, set_subkey_capability): New. + (keylist_colon_handler): Parse them. + * gpgme.h: New attribute values for capabilties. + * key.c (gpgme_key_get_string_attr): Return them. + (capabilities_to_string): New. + (gpgme_key_get_ulong_attr): Return the global caps. + +2001-03-14 Werner Koch + + * w32-io.c (destroy_reader,destroy_writer): Fixed syntax error. + Thanks to Jan Oliver Wagner. + +2001-03-13 Werner Koch + + * context.h: Add invalid and revoke flags to user_id structure. + * keylist.c (gpgme_op_keylist_start): Use --fixed-list-mode. + (keylist_colon_handler): Adjust for that. + (set_userid_flags): New. + (set_mainkey_trust_info): Handle new key invalid flag + (set_subkey_trust_info): Ditto. + * gpgme.h: Add new attributes for key and user ID flags. + * key.c (_gpgme_key_append_name): Init these flags + (gpgme_key_get_as_xml): Print them. + (one_uid_as_xml): New helper for above. + (gpgme_key_get_string_attr, gpgme_key_get_ulong_attr): + Return the new attributes. Enhanced, so that subkey information + can be returned now. + +2001-02-28 Werner Koch + + * w32-io.c (destroy_reader): Set stop_me flag. + (writer,create_writer,destroy_writer,find_writer,kill_writer): New. + (_gpgme_io_write): Use a writer thread to avaoid blocking. + (_gpgme_io_close): Cleanup a writer thread + (_gpgme_io_select): Repalce tthe faked wait on writing by a real + waiting which is now possible due to the use of a writer thread. + +2001-02-20 Werner Koch + + * w32-io.c (destroy_reader,kill_reader): New. + (create_reader, reader): Add a new event to stop the thread. + (_gpgme_io_close): Kill the reader thread. + + * posix-io.c (_gpgme_io_select): Handle frozen fds here. + * 32-io.c (_gpgme_io_select): Ditto. Removed a bunch of unused code. + + * wait.c: Reworked the whole thing. + * rungpg.c (_gpgme_gpg_new): Init pid to -1. + (_gpgme_gpg_release): Remove the process from the wait queue. + +2001-02-19 Werner Koch + + * w32-io.c (_gpgme_io_set_close_notify): New. + (_gpgme_io_close): Do the notification. + + * posix-io.c (_gpgme_io_select): Use a 1 sec timeout and not 200 + microseconds. + + * wait.c (remove_process): Don't close the fd here. + (do_select): Set the fd to -1 and remove the is_closed flag everywhere. + (_gpgme_wait_on_condition): Remove the assert on the queue and + break out if we could not find the queue. The whole thing should + be reworked. + + * posix-io.c (_gpgme_io_set_close_notify): New. + (_gpgme_io_close): Do the notification. + + * rungpg.c (close_notify_handler): New. + (_gpgme_gpg_new): Register a callback for the fd. + (_gpgme_gpg_set_colon_line_handler): Ditto. + (build_argv): Ditto + +2001-02-13 Werner Koch + + * rungpg.c (struct reap_s): Replaced pid_t by int. + + * types.h: Add ulong typedef. + + * rungpg.c (do_reaping,_gpgme_gpg_housecleaning): New. + (_gpgme_gpg_release): Reap children. + * io.h, posix-io.c (_gpgme_io_kill): New. + * w32-io.c (_gpgme_io_kill): New (dummy). + + * keylist.c (gpgme_op_keylist_start): Cancel a pending request. + + * posix-io.c (_gpgme_io_read): Add some debug output. + (_gpgme_io_write): Ditto. + (_gpgme_io_select): Increased the timeout. + +2001-02-12 Werner Koch + + Enhanced the signature verification, so that it can how handle + more than one signature and is able to return more information on + the signatures. + * verify.c (gpgme_get_sig_key): New. + (gpgme_get_sig_status): New. + + * gpgme.h: Add stdio.h. + (GpgmeSigStat): New status DIFF. + +2001-02-01 Werner Koch + + * w32-io.c (set_synchronize): Add EVENT_MODIFY_STATE. Add Debug + code to all Set/ResetEvent(). + + * rungpg.c (read_status): Check for end of stream only if we have + an r. By Timo. + +2001-01-31 Werner Koch + + * wait.c (_gpgme_wait_on_condition): Removed all exit code processing. + (propagate_term_results,clear_active_fds): Removed. + (count_active_fds): Renamed to .. + (count_active_and_thawed_fds): .. this and count only thawed fds. + + * rungpg.c (gpg_colon_line_handler): Return colon.eof and not + status.eof ;-) + +2001-01-30 Werner Koch + + * w32-io.c (_gpgme_io_spawn): Use the supplied path arg. + + * version.c (get_engine_info): Return better error information. + + * posix-util.c, w32-util.c: New. + (_gpgme_get_gpg_path): New, suggested by Jan-Oliver. + * rungpg.c (_gpgme_gpg_spawn): Use new function to get GPG's path. + + * signers.c (gpgme_signers_add): Ooops, one should test code and + not just write it; the newarr was not assigned. Thanks to José + for pointing this out. Hmmm, still not tested, why shoudl a coder + test his fix :-) + + * w32-io.c: Does now use reader threads, so that we can use + WaitForMultipleObjects. + * sema.h, posix-sema.c, w32-sema.c: Support for Critcial sections. + Does currently only work for W32. + + * debug.c, util.h : New. Changed all fprintfs to use this new + set of debugging functions. + +2001-01-23 Werner Koch + + * data.c (_gpgme_data_release_and_return_string): Fixed string + termination. + +2001-01-22 Werner Koch + + * delete.c: New. + + * signers.c: New. + * key.c (gpgme_key_ref, gpgme_key_unref): New. + * sign.c (gpgme_op_sign_start): Allow the use of other keys. + + * version.c (gpgme_get_engine_info,gpgme_check_engine): New. + * rungpg.c (_gpgme_gpg_set_simple_line_handler): New. + +2001-01-05 Werner Koch + + * data.c (gpgme_data_rewind): Allow to rewind data_type_none. + + + Copyright 2001, 2002 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/tags/gpgme-0-4-3/gpgme/Makefile.am b/tags/gpgme-0-4-3/gpgme/Makefile.am new file mode 100644 index 0000000..00f8c4d --- /dev/null +++ b/tags/gpgme-0-4-3/gpgme/Makefile.am @@ -0,0 +1,126 @@ +# Copyright (C) 2000 Werner Koch (dd9jn) +# Copyright (C) 2001, 2002, 2003 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 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA + +## Process this file with automake to produce Makefile.in + +EXTRA_DIST = gpgme-config.in gpgme.m4 mkstatus libgpgme.vers +BUILT_SOURCES = status-table.h +MOSTLYCLEANFILES = status-table.h +bin_SCRIPTS = gpgme-config +m4datadir = $(datadir)/aclocal +m4data_DATA = gpgme.m4 +include_HEADERS = gpgme.h + +if HAVE_PTHREAD +ltlib_gpgme_pthread = libgpgme-pthread.la +else +ltlib_gpgme_pthread = +endif +if HAVE_PTH +ltlib_gpgme_pth = libgpgme-pth.la +else +ltlib_gpgme_pth = +endif + +noinst_LTLIBRARIES = libgpgme-real.la +lib_LTLIBRARIES = libgpgme.la $(ltlib_gpgme_pthread) $(ltlib_gpgme_pth) + +if HAVE_LD_VERSION_SCRIPT +libgpgme_version_script_cmd = -Wl,--version-script=$(srcdir)/libgpgme.vers +else +libgpgme_version_script_cmd = +endif + +if BUILD_ASSUAN +assuan_cppflags = -I$(top_srcdir)/assuan +assuan_libobjs = ../assuan/libassuan.la +else +assuan_cppflags = +assuan_libobjs = +endif + +if HAVE_DOSISH_SYSTEM +system_components = w32-util.c w32-sema.c w32-io.c +else +system_components = ath.h posix-util.c posix-sema.c posix-io.c +endif + +if HAVE_GPGSM +gpgsm_components = engine-gpgsm.c +else +gpgsm_components = +endif + +libgpgme_real_la_SOURCES = \ + gpgme.h util.h conversion.c get-env.c context.h ops.h \ + data.h data.c data-fd.c data-stream.c data-mem.c data-user.c \ + data-compat.c \ + signers.c \ + wait.c wait-global.c wait-private.c wait-user.c wait.h \ + op-support.c \ + encrypt.c encrypt-sign.c decrypt.c decrypt-verify.c verify.c \ + sign.c passphrase.c progress.c \ + key.c keylist.c trust-item.c trustlist.c \ + import.c export.c genkey.c delete.c edit.c \ + engine.h engine-backend.h engine.c rungpg.c status-table.h \ + $(gpgsm_components) sema.h io.h $(system_components) \ + debug.c debug.h gpgme.c version.c error.c + +# libgpgme_la_SOURCES = ath.h ath.c +if HAVE_PTH + ath_pth_src = ath-pth-compat.c +else + ath_pth_src = +endif +if HAVE_PTHREAD + ath_pthread_src = ath-pthread-compat.c +else + ath_pthread_src = +endif +libgpgme_la_SOURCES = ath.h ath-compat.c $(ath_pth_src) $(ath_pthread_src) +libgpgme_pthread_la_SOURCES = ath.h ath-pthread.c +libgpgme_pth_la_SOURCES = ath.h ath-pth.c + +AM_CPPFLAGS = $(assuan_cppflags) @GPG_ERROR_CFLAGS@ + +libgpgme_la_LDFLAGS = $(libgpgme_version_script_cmd) -version-info \ + @LIBGPGME_LT_CURRENT@:@LIBGPGME_LT_REVISION@:@LIBGPGME_LT_AGE@ +libgpgme_la_DEPENDENCIES = libgpgme-real.la $(assuan_libobjs) \ + @LTLIBOBJS@ $(srcdir)/libgpgme.vers +libgpgme_la_LIBADD = libgpgme-real.la $(assuan_libobjs) @LTLIBOBJS@ \ + @GPG_ERROR_LIBS@ + +libgpgme_pthread_la_LDFLAGS = $(libgpgme_version_script_cmd) -version-info \ + @LIBGPGME_LT_CURRENT@:@LIBGPGME_LT_REVISION@:@LIBGPGME_LT_AGE@ +libgpgme_pthread_la_DEPENDENCIES = libgpgme-real.la $(assuan_libobjs) \ + @LTLIBOBJS@ $(srcdir)/libgpgme.vers +libgpgme_pthread_la_LIBADD = libgpgme-real.la $(assuan_libobjs) @LTLIBOBJS@ \ + -lpthread @GPG_ERROR_LIBS@ + +libgpgme_pth_la_CPPFLAGS = $(AM_CPPFLAGS) @PTH_CPPFLAGS@ +libgpgme_pth_la_LDFLAGS = @PTH_LDFLAGS@ \ + $(libgpgme_version_script_cmd) -version-info \ + @LIBGPGME_LT_CURRENT@:@LIBGPGME_LT_REVISION@:@LIBGPGME_LT_AGE@ +libgpgme_pth_la_DEPENDENCIES = libgpgme-real.la $(assuan_libobjs) \ + @LTLIBOBJS@ $(srcdir)/libgpgme.vers +libgpgme_pth_la_LIBADD = libgpgme-real.la $(assuan_libobjs) @LTLIBOBJS@ \ + @PTH_LIBS@ @GPG_ERROR_LIBS@ + +status-table.h : gpgme.h + $(srcdir)/mkstatus < $(srcdir)/gpgme.h > status-table.h diff --git a/tags/gpgme-0-4-3/gpgme/ath-compat.c b/tags/gpgme-0-4-3/gpgme/ath-compat.c new file mode 100644 index 0000000..02ccc58 --- /dev/null +++ b/tags/gpgme-0-4-3/gpgme/ath-compat.c @@ -0,0 +1,183 @@ +/* ath.c - self-adapting thread-safeness library + * Copyright (C) 2002 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 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA + */ + +#ifdef HAVE_CONFIG_H +#include +#endif + +#include +#ifdef HAVE_SYS_SELECT_H +# include +#else +# include +#endif +#include +#include + +#include "ath.h" + +static struct ath_ops *ath_ops; + +void +ath_init (void) +{ + if (0) + ; +#ifdef HAVE_PTHREAD + else if (!ath_ops) + ath_ops = ath_pthread_available (); +#endif +#ifdef HAVE_PTH + else if (!ath_ops) + ath_ops = ath_pth_available (); +#endif +} + + +int +ath_mutex_init (ath_mutex_t *lock) +{ + if (!ath_ops) + return 0; + + return ath_ops->mutex_init (lock, 0); +} + + +int +ath_mutex_destroy (ath_mutex_t *lock) +{ + int err; + if (!ath_ops) + return 0; + err = ath_ops->mutex_init (lock, 1); + if (!err) + err = ath_ops->mutex_destroy (*lock); + return err; +} + + +int +ath_mutex_lock (ath_mutex_t *lock) +{ + int err; + + if (!ath_ops) + return 0; + err = ath_ops->mutex_init (lock, 1); + if (!err) + err = ath_ops->mutex_lock (*lock); + return err; +} + + +int +ath_mutex_unlock (ath_mutex_t *lock) +{ + int err; + + if (!ath_ops) + return 0; + err = ath_ops->mutex_init (lock, 1); + if (!err) + err = ath_ops->mutex_unlock (*lock); + return err; +} + + +ssize_t +ath_read (int fd, void *buf, size_t nbytes) +{ + if (ath_ops && ath_ops->read) + return ath_ops->read (fd, buf, nbytes); + else + return read (fd, buf, nbytes); +} + + +ssize_t +ath_write (int fd, const void *buf, size_t nbytes) +{ + if (ath_ops && ath_ops->write) + return ath_ops->write (fd, buf, nbytes); + else + return write (fd, buf, nbytes); +} + + +ssize_t +ath_select (int nfd, fd_set *rset, fd_set *wset, fd_set *eset, + struct timeval *timeout) +{ + if (ath_ops && ath_ops->select) + return ath_ops->select (nfd, rset, wset, eset, timeout); + else + return select (nfd, rset, wset, eset, timeout); +} + + +ssize_t +ath_waitpid (pid_t pid, int *status, int options) +{ + if (ath_ops && ath_ops->waitpid) + return ath_ops->waitpid (pid, status, options); + else + return waitpid (pid, status, options); +} + + +int +ath_accept (int s, struct sockaddr *addr, socklen_t *length_ptr) +{ + if (ath_ops && ath_ops->accept) + return ath_ops->accept (s, addr, length_ptr); + else + return accept (s, addr, length_ptr); +} + + +int +ath_connect (int s, const struct sockaddr *addr, socklen_t length) +{ + if (ath_ops && ath_ops->connect) + return ath_ops->connect (s, addr, length); + else + return connect (s, addr, length); +} + + +int +ath_sendmsg (int s, const struct msghdr *msg, int flags) +{ + if (ath_ops && ath_ops->sendmsg) + return ath_ops->sendmsg (s, msg, flags); + else + return sendmsg (s, msg, flags); +} + + +int +ath_recvmsg (int s, struct msghdr *msg, int flags) +{ + if (ath_ops && ath_ops->recvmsg) + return ath_ops->recvmsg (s, msg, flags); + else + return recvmsg (s, msg, flags); +} diff --git a/tags/gpgme-0-4-3/gpgme/ath-pth-compat.c b/tags/gpgme-0-4-3/gpgme/ath-pth-compat.c new file mode 100644 index 0000000..75b6fb4 --- /dev/null +++ b/tags/gpgme-0-4-3/gpgme/ath-pth-compat.c @@ -0,0 +1,123 @@ +/* ath-pth.c - Pth module for self-adapting thread-safeness library + * Copyright (C) 2002 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 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA + */ + +#include +#include +#include + +#include "ath.h" + +#pragma weak pth_mutex_init +#pragma weak pth_mutex_acquire +#pragma weak pth_mutex_release +#pragma weak pth_read +#pragma weak pth_write +#pragma weak pth_select +#pragma weak pth_waitpid +#pragma weak pth_accept +#pragma weak pth_connect + +/* The lock we take while checking for lazy lock initialization. */ +static pth_mutex_t check_init_lock = PTH_MUTEX_INIT; + +/* Initialize the mutex *PRIV. If JUST_CHECK is true, only do this if + it is not already initialized. */ +static int +mutex_pth_init (void **priv, int just_check) +{ + int err = 0; + + if (just_check) + pth_mutex_acquire (&check_init_lock, 0, NULL); + if (!*priv || !just_check) + { + pth_mutex_t *lock = malloc (sizeof (pth_mutex_t)); + if (!lock) + err = ENOMEM; + if (!err) + { + err = pth_mutex_init (lock); + if (err == FALSE) + err = errno; + else + err = 0; + + if (err) + free (lock); + else + *priv = lock; + } + } + if (just_check) + pth_mutex_release (&check_init_lock); + return err; +} + + +static int +mutex_pth_destroy (void *priv) +{ + free (priv); + return 0; +} + + +static int +mutex_pth_lock (void *priv) +{ + int ret = pth_mutex_acquire ((pth_mutex_t *) priv, 0, NULL); + return ret == FALSE ? errno : 0; +} + + +static int +mutex_pth_unlock (void *priv) +{ + int ret = pth_mutex_release ((pth_mutex_t *) priv); + return ret == FALSE ? errno : 0; +} + + +static struct ath_ops ath_pth_ops = + { + mutex_pth_init, + mutex_pth_destroy, + mutex_pth_lock, + mutex_pth_unlock, + pth_read, + pth_write, + pth_select, + pth_waitpid, + pth_accept, + pth_connect, + NULL, /* FIXME: When GNU PTh has sendmsg. */ + NULL /* FIXME: When GNU PTh has recvmsg. */ + }; + + +struct ath_ops * +ath_pth_available (void) +{ + if (pth_mutex_init && pth_mutex_acquire && pth_mutex_release + && pth_read && pth_write && pth_select && pth_waitpid) + return &ath_pth_ops; + else + return 0; +} diff --git a/tags/gpgme-0-4-3/gpgme/ath-pth.c b/tags/gpgme-0-4-3/gpgme/ath-pth.c new file mode 100644 index 0000000..2c7cd5a --- /dev/null +++ b/tags/gpgme-0-4-3/gpgme/ath-pth.c @@ -0,0 +1,177 @@ +/* ath-pth.c - Pth module for self-adapting thread-safeness library + Copyright (C) 2002, 2003 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 + 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. */ + + +#ifdef HAVE_CONFIG_H +#include +#endif + +#include +#include + +#include + +#include "ath.h" + + +/* The lock we take while checking for lazy lock initialization. */ +static pth_mutex_t check_init_lock = PTH_MUTEX_INIT; + +/* Initialize the mutex *PRIV. If JUST_CHECK is true, only do this if + it is not already initialized. */ +static int +mutex_pth_init (ath_mutex_t *priv, int just_check) +{ + int err = 0; + + if (just_check) + pth_mutex_acquire (&check_init_lock, 0, NULL); + if (!*priv || !just_check) + { + pth_mutex_t *lock = malloc (sizeof (pth_mutex_t)); + if (!lock) + err = ENOMEM; + if (!err) + { + err = pth_mutex_init (lock); + if (err == FALSE) + err = errno; + else + err = 0; + + if (err) + free (lock); + else + *priv = (ath_mutex_t) lock; + } + } + if (just_check) + pth_mutex_release (&check_init_lock); + return err; +} + + +void +ath_init (void) +{ + /* Nothing to do. */ +} + + +int +ath_mutex_init (ath_mutex_t *lock) +{ + return mutex_pth_init (lock, 0); +} + + +int +ath_mutex_destroy (ath_mutex_t *lock) +{ + int err = mutex_pth_init (lock, 1); + if (!err) + { + /* GNU Pth has no destructor function. */ + free (*lock); + } + return err; +} + + +int +ath_mutex_lock (ath_mutex_t *lock) +{ + int ret = mutex_pth_init (lock, 1); + if (ret) + return ret; + + ret = pth_mutex_acquire ((pth_mutex_t *) *lock, 0, NULL); + return ret == FALSE ? errno : 0; +} + + +int +ath_mutex_unlock (ath_mutex_t *lock) +{ + int ret = mutex_pth_init (lock, 1); + if (ret) + return ret; + + ret = pth_mutex_release ((pth_mutex_t *) *lock); + return ret == FALSE ? errno : 0; +} + + +ssize_t +ath_read (int fd, void *buf, size_t nbytes) +{ + return pth_read (fd, buf, nbytes); +} + + +ssize_t +ath_write (int fd, const void *buf, size_t nbytes) +{ + return pth_write (fd, buf, nbytes); +} + + +ssize_t +ath_select (int nfd, fd_set *rset, fd_set *wset, fd_set *eset, + struct timeval *timeout) +{ + return pth_select (nfd, rset, wset, eset, timeout); +} + + +ssize_t +ath_waitpid (pid_t pid, int *status, int options) +{ + return pth_waitpid (pid, status, options); +} + + +int +ath_accept (int s, struct sockaddr *addr, socklen_t *length_ptr) +{ + return pth_accept (s, addr, length_ptr); +} + + +int +ath_connect (int s, const struct sockaddr *addr, socklen_t length) +{ + return pth_connect (s, addr, length); +} + +int +ath_sendmsg (int s, const struct msghdr *msg, int flags) +{ + /* FIXME: GNU Pth is missing pth_sendmsg. */ + return sendmsg (s, msg, flags); +} + + +int +ath_recvmsg (int s, struct msghdr *msg, int flags) +{ + /* FIXME: GNU Pth is missing pth_recvmsg. */ + return recvmsg (s, msg, flags); +} + diff --git a/tags/gpgme-0-4-3/gpgme/ath-pthread-compat.c b/tags/gpgme-0-4-3/gpgme/ath-pthread-compat.c new file mode 100644 index 0000000..365cf97 --- /dev/null +++ b/tags/gpgme-0-4-3/gpgme/ath-pthread-compat.c @@ -0,0 +1,104 @@ +/* ath-pthread.c - pthread module for self-adapting thread-safeness library + * Copyright (C) 2002 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 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA + */ + +#include +#include +#include + +#include "ath.h" + +/* Need to include pthread_create in our check, as the GNU C library + has the pthread_mutex_* functions in their public interface. */ +#pragma weak pthread_create +#pragma weak pthread_mutex_init +#pragma weak pthread_mutex_destroy +#pragma weak pthread_mutex_lock +#pragma weak pthread_mutex_unlock + +/* The lock we take while checking for lazy lock initialization. */ +static pthread_mutex_t check_init_lock = PTHREAD_MUTEX_INITIALIZER; + +/* Initialize the mutex *PRIV. If JUST_CHECK is true, only do this if + it is not already initialized. */ +static int +mutex_pthread_init (void **priv, int just_check) +{ + int err = 0; + + if (just_check) + pthread_mutex_lock (&check_init_lock); + if (!*priv || !just_check) + { + pthread_mutex_t *lock = malloc (sizeof (pthread_mutex_t)); + if (!lock) + err = ENOMEM; + if (!err) + { + err = pthread_mutex_init (lock, NULL); + if (err) + free (lock); + else + *priv = lock; + } + } + if (just_check) + pthread_mutex_unlock (&check_init_lock); + return err; +} + + +static int +mutex_pthread_destroy (void *priv) +{ + int err = pthread_mutex_destroy ((pthread_mutex_t *) priv); + free (priv); + return err; +} + + +static struct ath_ops ath_pthread_ops = + { + mutex_pthread_init, + mutex_pthread_destroy, + (int (*) (void *)) pthread_mutex_lock, + (int (*) (void *)) pthread_mutex_unlock, + NULL, /* read */ + NULL, /* write */ + NULL, /* select */ + NULL, /* waitpid */ + NULL, /* accept */ + NULL, /* connect */ + NULL, /* sendmsg */ + NULL /* recvmsg */ + }; + + +struct ath_ops * +ath_pthread_available (void) +{ + /* Need to include pthread_create in our check, as the GNU C library + has the pthread_mutex_* functions in their public interface. */ + if (pthread_create + && pthread_mutex_init && pthread_mutex_destroy + && pthread_mutex_lock && pthread_mutex_unlock) + return &ath_pthread_ops; + else + return 0; +} diff --git a/tags/gpgme-0-4-3/gpgme/ath-pthread.c b/tags/gpgme-0-4-3/gpgme/ath-pthread.c new file mode 100644 index 0000000..94a4f59 --- /dev/null +++ b/tags/gpgme-0-4-3/gpgme/ath-pthread.c @@ -0,0 +1,175 @@ +/* ath-pthread.c - pthread module for self-adapting thread-safeness library + Copyright (C) 2002, 2003 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 + 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. */ + + +#ifdef HAVE_CONFIG_H +#include +#endif + +#include +#include +#include +#ifdef HAVE_SYS_SELECT_H +# include +#else +# include +#endif +#include +#include + +#include + +#include "ath.h" + + +/* The lock we take while checking for lazy lock initialization. */ +static pthread_mutex_t check_init_lock = PTHREAD_MUTEX_INITIALIZER; + +/* Initialize the mutex *PRIV. If JUST_CHECK is true, only do this if + it is not already initialized. */ +static int +mutex_pthread_init (ath_mutex_t *priv, int just_check) +{ + int err = 0; + + if (just_check) + pthread_mutex_lock (&check_init_lock); + if (!*priv || !just_check) + { + pthread_mutex_t *lock = malloc (sizeof (pthread_mutex_t)); + if (!lock) + err = ENOMEM; + if (!err) + { + err = pthread_mutex_init (lock, NULL); + if (err) + free (lock); + else + *priv = (ath_mutex_t) lock; + } + } + if (just_check) + pthread_mutex_unlock (&check_init_lock); + return err; +} + + +void +ath_init (void) +{ + /* Nothing to do. */ +} + + +int +ath_mutex_init (ath_mutex_t *lock) +{ + return mutex_pthread_init (lock, 0); +} + + +int +ath_mutex_destroy (ath_mutex_t *lock) +{ + int err = mutex_pthread_init (lock, 1); + if (!err) + { + err = pthread_mutex_destroy ((pthread_mutex_t *) *lock); + free (*lock); + } + return err; +} + + +int +ath_mutex_lock (ath_mutex_t *lock) +{ + int ret = mutex_pthread_init (lock, 1); + if (ret) + return ret; + + return pthread_mutex_lock ((pthread_mutex_t *) *lock); +} + + +int +ath_mutex_unlock (ath_mutex_t *lock) +{ + int ret = mutex_pthread_init (lock, 1); + if (ret) + return ret; + + return pthread_mutex_unlock ((pthread_mutex_t *) *lock); +} + + +ssize_t +ath_read (int fd, void *buf, size_t nbytes) +{ + return read (fd, buf, nbytes); +} + + +ssize_t +ath_write (int fd, const void *buf, size_t nbytes) +{ + return write (fd, buf, nbytes); +} + + +ssize_t +ath_select (int nfd, fd_set *rset, fd_set *wset, fd_set *eset, + struct timeval *timeout) +{ + return select (nfd, rset, wset, eset, timeout); +} + + +ssize_t +ath_waitpid (pid_t pid, int *status, int options) +{ + return waitpid (pid, status, options); +} + + +int +ath_accept (int s, struct sockaddr *addr, socklen_t *length_ptr) +{ + return accept (s, addr, length_ptr); +} + + +int +ath_connect (int s, const struct sockaddr *addr, socklen_t length) +{ + return connect (s, addr, length); +} + +int +ath_sendmsg (int s, const struct msghdr *msg, int flags) +{ + return sendmsg (s, msg, flags); +} + + +int +ath_recvmsg (int s, struct msghdr *msg, int flags) +{ + return recvmsg (s, msg, flags); +} diff --git a/tags/gpgme-0-4-3/gpgme/ath.c b/tags/gpgme-0-4-3/gpgme/ath.c new file mode 100644 index 0000000..6390ecc --- /dev/null +++ b/tags/gpgme-0-4-3/gpgme/ath.c @@ -0,0 +1,142 @@ +/* ath.c - Thread-safeness library. + Copyright (C) 2002, 2003 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 + 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. */ + +#ifdef HAVE_CONFIG_H +#include +#endif + +#include +#include +#ifdef HAVE_SYS_SELECT_H +# include +#else +# include +#endif +#include +#include + +#include "ath.h" + + +#define MUTEX_UNLOCKED ((ath_mutex_t) 0) +#define MUTEX_LOCKED ((ath_mutex_t) 1) +#define MUTEX_DESTROYED ((ath_mutex_t) 2) + + +int +ath_mutex_init (ath_mutex_t *lock) +{ +#ifndef NDEBUG + *lock = MUTEX_UNLOCKED; +#endif + return 0; +} + + +int +ath_mutex_destroy (ath_mutex_t *lock) +{ +#ifndef NDEBUG + assert (*lock == MUTEX_UNLOCKED); + + *lock = MUTEX_DESTROYED; +#endif + return 0; +} + + +int +ath_mutex_lock (ath_mutex_t *lock) +{ +#ifndef NDEBUG + assert (*lock == MUTEX_UNLOCKED); + + *lock = MUTEX_LOCKED; +#endif + return 0; +} + + +int +ath_mutex_unlock (ath_mutex_t *lock) +{ +#ifndef NDEBUG + assert (*lock == MUTEX_LOCKED); + + *lock = MUTEX_UNLOCKED; +#endif + return 0; +} + + +ssize_t +ath_read (int fd, void *buf, size_t nbytes) +{ + return read (fd, buf, nbytes); +} + + +ssize_t +ath_write (int fd, const void *buf, size_t nbytes) +{ + return write (fd, buf, nbytes); +} + + +ssize_t +ath_select (int nfd, fd_set *rset, fd_set *wset, fd_set *eset, + struct timeval *timeout) +{ + return select (nfd, rset, wset, eset, timeout); +} + + +ssize_t +ath_waitpid (pid_t pid, int *status, int options) +{ + return waitpid (pid, status, options); +} + + +int +ath_accept (int s, struct sockaddr *addr, socklen_t *length_ptr) +{ + return accept (s, addr, length_ptr); +} + + +int +ath_connect (int s, const struct sockaddr *addr, socklen_t length) +{ + return connect (s, addr, length); +} + + +int +ath_sendmsg (int s, const struct msghdr *msg, int flags) +{ + return sendmsg (s, msg, flags); +} + + +int +ath_recvmsg (int s, struct msghdr *msg, int flags) +{ + return recvmsg (s, msg, flags); +} diff --git a/tags/gpgme-0-4-3/gpgme/ath.h b/tags/gpgme-0-4-3/gpgme/ath.h new file mode 100644 index 0000000..04dfb28 --- /dev/null +++ b/tags/gpgme-0-4-3/gpgme/ath.h @@ -0,0 +1,106 @@ +/* ath.h - Interfaces for thread-safeness library. + Copyright (C) 2002, 2003 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 + 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. */ + +#ifndef ATH_H +#define ATH_H + +#ifdef HAVE_SYS_SELECT_H +# include +#else +# include +#endif +#include +#include + + +/* Define _ATH_EXT_SYM_PREFIX if you want to give all external symbols + a prefix. */ +#define _ATH_EXT_SYM_PREFIX _gpgme_ + +#ifdef _ATH_EXT_SYM_PREFIX +#define _ATH_PREFIX1(x,y) x ## y +#define _ATH_PREFIX2(x,y) _ATH_PREFIX1(x,y) +#define _ATH_PREFIX(x) _ATH_PREFIX2(_ATH_EXT_SYM_PREFIX,x) +#define ath_mutex_init _ATH_PREFIX(ath_mutex_init) +#define ath_mutex_destroy _ATH_PREFIX(ath_mutex_destroy) +#define ath_mutex_lock _ATH_PREFIX(ath_mutex_lock) +#define ath_mutex_unlock _ATH_PREFIX(ath_mutex_unlock) +#define ath_read _ATH_PREFIX(ath_read) +#define ath_write _ATH_PREFIX(ath_write) +#define ath_select _ATH_PREFIX(ath_select) +#define ath_waitpid _ATH_PREFIX(ath_waitpid) +#define ath_connect _ATH_PREFIX(ath_connect) +#define ath_accept _ATH_PREFIX(ath_accept) +#define ath_sendmsg _ATH_PREFIX(ath_sendmsg) +#define ath_recvmsg _ATH_PREFIX(ath_recvmsg) +#endif + + +typedef void *ath_mutex_t; +#define ATH_MUTEX_INITIALIZER 0; + +/* Functions for mutual exclusion. */ +int ath_mutex_init (ath_mutex_t *mutex); +int ath_mutex_destroy (ath_mutex_t *mutex); +int ath_mutex_lock (ath_mutex_t *mutex); +int ath_mutex_unlock (ath_mutex_t *mutex); + +/* Replacement for the POSIX functions, which can be used to allow + other (user-level) threads to run. */ +ssize_t ath_read (int fd, void *buf, size_t nbytes); +ssize_t ath_write (int fd, const void *buf, size_t nbytes); +ssize_t ath_select (int nfd, fd_set *rset, fd_set *wset, fd_set *eset, + struct timeval *timeout); +ssize_t ath_waitpid (pid_t pid, int *status, int options); +int ath_accept (int s, struct sockaddr *addr, socklen_t *length_ptr); +int ath_connect (int s, const struct sockaddr *addr, socklen_t length); +int ath_sendmsg (int s, const struct msghdr *msg, int flags); +int ath_recvmsg (int s, struct msghdr *msg, int flags); + +#define _ATH_COMPAT +#ifdef _ATH_COMPAT +struct ath_ops +{ + int (*mutex_init) (void **priv, int just_check); + int (*mutex_destroy) (void *priv); + int (*mutex_lock) (void *priv); + int (*mutex_unlock) (void *priv); + ssize_t (*read) (int fd, void *buf, size_t nbytes); + ssize_t (*write) (int fd, const void *buf, size_t nbytes); + ssize_t (*select) (int nfd, fd_set *rset, fd_set *wset, fd_set *eset, + struct timeval *timeout); + ssize_t (*waitpid) (pid_t pid, int *status, int options); + int (*accept) (int s, struct sockaddr *addr, socklen_t *length_ptr); + int (*connect) (int s, const struct sockaddr *addr, socklen_t length); + int (*sendmsg) (int s, const struct msghdr *msg, int flags); + int (*recvmsg) (int s, struct msghdr *msg, int flags); +}; + +/* Initialize the any-thread package. */ +#define ath_init _ATH_PREFIX(ath_init) +void ath_init (void); + +/* Used by ath_pkg_init. */ +#define ath_pthread_available _ATH_PREFIX(ath_pthread_available) +struct ath_ops *ath_pthread_available (void); +#define ath_pth_available _ATH_PREFIX(ath_pth_available) +struct ath_ops *ath_pth_available (void); +#endif + +#endif /* ATH_H */ diff --git a/tags/gpgme-0-4-3/gpgme/context.h b/tags/gpgme-0-4-3/gpgme/context.h new file mode 100644 index 0000000..64c5276 --- /dev/null +++ b/tags/gpgme-0-4-3/gpgme/context.h @@ -0,0 +1,111 @@ +/* context.h - Definitions for a GPGME context. + Copyright (C) 2000 Werner Koch (dd9jn) + Copyright (C) 2001, 2002, 2003 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 + 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. */ + +#ifndef CONTEXT_H +#define CONTEXT_H + +#include "gpgme.h" +#include "engine.h" +#include "wait.h" + + +/* Operations might require to remember arbitrary information and data + objects during invocations of the status handler. The + ctx_op_data structure provides a generic framework to hook in + such additional data. */ +typedef enum + { + OPDATA_DECRYPT, OPDATA_SIGN, OPDATA_ENCRYPT, OPDATA_PASSPHRASE, + OPDATA_IMPORT, OPDATA_GENKEY, OPDATA_KEYLIST, OPDATA_EDIT, + OPDATA_VERIFY, OPDATA_TRUSTLIST + } ctx_op_data_id_t; + + +struct ctx_op_data +{ + /* The next element in the linked list, or NULL if this is the last + element. */ + struct ctx_op_data *next; + + /* The type of the hook data, which can be used by a routine to + lookup the hook data. */ + ctx_op_data_id_t type; + + /* The function to release HOOK and all its associated resources. + Can be NULL if no special dealllocation routine is necessary. */ + void (*cleanup) (void *hook); + + /* The hook that points to the operation data. */ + void *hook; +}; +typedef struct ctx_op_data *ctx_op_data_t; + + +/* The context defines an environment in which crypto operations can + be performed (sequentially). */ +struct gpgme_context +{ + /* The protocol used by this context. */ + gpgme_protocol_t protocol; + + /* The running engine process. */ + engine_t engine; + + /* True if armor mode should be used. */ + unsigned int use_armor : 1; + + /* True if text mode should be used. */ + unsigned int use_textmode : 1; + + /* Flags for keylist mode. */ + gpgme_keylist_mode_t keylist_mode; + + /* Number of certs to be included. */ + unsigned int include_certs; + + /* The number of keys in signers. */ + unsigned int signers_len; + + /* Size of the following array. */ + unsigned int signers_size; + gpgme_key_t *signers; + + /* The locale for the pinentry. */ + char *lc_ctype; + char *lc_messages; + + /* The operation data hooked into the context. */ + ctx_op_data_t op_data; + + /* The user provided passphrase callback and its hook value. */ + gpgme_passphrase_cb_t passphrase_cb; + void *passphrase_cb_value; + + /* The user provided progress callback and its hook value. */ + gpgme_progress_cb_t progress_cb; + void *progress_cb_value; + + /* A list of file descriptors in active use by the current + operation. */ + struct fd_table fdt; + struct gpgme_io_cbs io_cbs; +}; + +#endif /* CONTEXT_H */ diff --git a/tags/gpgme-0-4-3/gpgme/conversion.c b/tags/gpgme-0-4-3/gpgme/conversion.c new file mode 100644 index 0000000..25de269 --- /dev/null +++ b/tags/gpgme-0-4-3/gpgme/conversion.c @@ -0,0 +1,333 @@ +/* conversion.c - String conversion helper functions. + Copyright (C) 2000 Werner Koch (dd9jn) + Copyright (C) 2001, 2002, 2003 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 + 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. */ + +#if HAVE_CONFIG_H +#include +#endif + +#include +#include +#include + +#include "gpgme.h" +#include "util.h" + + +/* Convert two hexadecimal digits from STR to the value they + represent. Returns -1 if one of the characters is not a + hexadecimal digit. */ +int +_gpgme_hextobyte (const char *str) +{ + int val = 0; + int i; + +#define NROFHEXDIGITS 2 + for (i = 0; i < NROFHEXDIGITS; i++) + { + if (*str >= '0' && *str <= '9') + val += *str - '0'; + else if (*str >= 'A' && *str <= 'F') + val += 10 + *str - 'A'; + else if (*str >= 'a' && *str <= 'f') + val += 10 + *str - 'a'; + else + return -1; + if (i < NROFHEXDIGITS - 1) + val *= 16; + str++; + } + return val; +} + + +/* Decode the C formatted string SRC and store the result in the + buffer *DESTP which is LEN bytes long. If LEN is zero, then a + large enough buffer is allocated with malloc and *DESTP is set to + the result. Currently, LEN is only used to specify if allocation + is desired or not, the caller is expected to make sure that *DESTP + is large enough if LEN is not zero. */ +gpgme_error_t +_gpgme_decode_c_string (const char *src, char **destp, size_t len) +{ + char *dest; + + /* Set up the destination buffer. */ + if (len) + { + if (len < strlen (src) + 1) + return gpg_error (GPG_ERR_INTERNAL); + + dest = *destp; + } + else + { + /* The converted string will never be larger than the original + string. */ + dest = malloc (strlen (src) + 1); + if (!dest) + return gpg_error_from_errno (errno); + + *destp = dest; + } + + /* Convert the string. */ + while (*src) + { + if (*src != '\\') + { + *(dest++) = *(src++); + continue; + } + + switch (src[1]) + { +#define DECODE_ONE(match,result) \ + case match: \ + src += 2; \ + *(dest++) = result; \ + break; + + DECODE_ONE ('\'', '\''); + DECODE_ONE ('\"', '\"'); + DECODE_ONE ('\?', '\?'); + DECODE_ONE ('\\', '\\'); + DECODE_ONE ('a', '\a'); + DECODE_ONE ('b', '\b'); + DECODE_ONE ('f', '\f'); + DECODE_ONE ('n', '\n'); + DECODE_ONE ('r', '\r'); + DECODE_ONE ('t', '\t'); + DECODE_ONE ('v', '\v'); + + case 'x': + { + int val = _gpgme_hextobyte (&src[2]); + + if (val == -1) + { + /* Should not happen. */ + *(dest++) = *(src++); + *(dest++) = *(src++); + if (*src) + *(dest++) = *(src++); + if (*src) + *(dest++) = *(src++); + } + else + { + if (!val) + { + /* A binary zero is not representable in a C + string. */ + *(dest++) = '\\'; + *(dest++) = '0'; + } + else + *((unsigned char *) dest++) = val; + src += 4; + } + } + break; + + default: + { + /* Should not happen. */ + *(dest++) = *(src++); + *(dest++) = *(src++); + } + } + } + *(dest++) = 0; + + return 0; +} + + +/* Decode the percent escaped string SRC and store the result in the + buffer *DESTP which is LEN bytes long. If LEN is zero, then a + large enough buffer is allocated with malloc and *DESTP is set to + the result. Currently, LEN is only used to specify if allocation + is desired or not, the caller is expected to make sure that *DESTP + is large enough if LEN is not zero. */ +gpgme_error_t +_gpgme_decode_percent_string (const char *src, char **destp, size_t len) +{ + char *dest; + + /* Set up the destination buffer. */ + if (len) + { + if (len < strlen (src) + 1) + return gpg_error (GPG_ERR_INTERNAL); + + dest = *destp; + } + else + { + /* The converted string will never be larger than the original + string. */ + dest = malloc (strlen (src) + 1); + if (!dest) + return gpg_error_from_errno (errno); + + *destp = dest; + } + + /* Convert the string. */ + while (*src) + { + if (*src != '%') + { + *(dest++) = *(src++); + continue; + } + else + { + int val = _gpgme_hextobyte (&src[1]); + + if (val == -1) + { + /* Should not happen. */ + *(dest++) = *(src++); + if (*src) + *(dest++) = *(src++); + if (*src) + *(dest++) = *(src++); + } + else + { + if (!val) + { + /* A binary zero is not representable in a C + string. */ + *(dest++) = '\\'; + *(dest++) = '0'; + } + else + *((unsigned char *) dest++) = val; + src += 3; + } + } + } + *(dest++) = 0; + + return 0; +} + + +static struct +{ + char *name; + gpgme_error_t err; +} gnupg_errors[] = + { + { "EOF", GPG_ERR_EOF }, + { "No_Error", GPG_ERR_NO_ERROR }, + { "General_Error", GPG_ERR_GENERAL }, + { "Out_Of_Core", GPG_ERR_ENOMEM }, + { "Invalid_Value", GPG_ERR_INV_VALUE }, + { "IO_Error", GPG_ERR_GENERAL }, + { "Resource_Limit", GPG_ERR_RESOURCE_LIMIT }, + { "Internal_Error", GPG_ERR_INTERNAL }, + { "Bad_Certificate", GPG_ERR_BAD_CERT }, + { "Bad_Certificate_Chain", GPG_ERR_BAD_CERT_CHAIN}, + { "Missing_Certificate", GPG_ERR_MISSING_CERT }, + { "No_Data", GPG_ERR_NO_DATA }, + { "Bad_Signature", GPG_ERR_BAD_SIGNATURE }, + { "Not_Implemented", GPG_ERR_NOT_IMPLEMENTED }, + { "Conflict", GPG_ERR_CONFLICT }, + { "Bug", GPG_ERR_BUG }, + { "Read_Error", GPG_ERR_GENERAL }, + { "Write_Error", GPG_ERR_GENERAL }, + { "Invalid_Line", GPG_ERR_GENERAL }, + { "Incomplete_Line", GPG_ERR_INCOMPLETE_LINE }, + { "Invalid_Response", GPG_ERR_INV_RESPONSE }, + { "Agent_Error", GPG_ERR_AGENT }, + { "No_Public_Key", GPG_ERR_NO_PUBKEY }, + { "No_Secret_Key", GPG_ERR_NO_SECKEY }, + { "File_Open_Error", GPG_ERR_GENERAL }, + { "File_Create_Error", GPG_ERR_GENERAL }, + { "File_Error", GPG_ERR_GENERAL }, + { "Not_Supported", GPG_ERR_NOT_SUPPORTED }, + { "Invalid_Data", GPG_ERR_INV_DATA }, + { "Assuan_Server_Fault", GPG_ERR_ASSUAN_SERVER_FAULT }, + { "Assuan_Error", GPG_ERR_ASSUAN }, + { "Invalid_Session_Key", GPG_ERR_INV_SESSION_KEY }, + { "Invalid_Sexp", GPG_ERR_INV_SEXP }, + { "Unsupported_Algorithm", GPG_ERR_UNSUPPORTED_ALGORITHM }, + { "No_PIN_Entry", GPG_ERR_NO_PIN_ENTRY }, + { "PIN_Entry_Error", GPG_ERR_NO_PIN_ENTRY }, + { "Bad_PIN", GPG_ERR_BAD_PIN }, + { "Bad_Passphrase", GPG_ERR_BAD_PASSPHRASE }, + { "Invalid_Name", GPG_ERR_INV_NAME }, + { "Bad_Public_Key", GPG_ERR_BAD_PUBKEY }, + { "Bad_Secret_Key", GPG_ERR_BAD_SECKEY }, + { "Bad_Data", GPG_ERR_BAD_DATA }, + { "Invalid_Parameter", GPG_ERR_INV_PARAMETER }, + { "Tribute_to_D_A", GPG_ERR_TRIBUTE_TO_D_A }, + { "No_Dirmngr", GPG_ERR_NO_DIRMNGR }, + { "Dirmngr_Error", GPG_ERR_DIRMNGR }, + { "Certificate_Revoked", GPG_ERR_CERT_REVOKED }, + { "No_CRL_Known", GPG_ERR_NO_CRL_KNOWN }, + { "CRL_Too_Old", GPG_ERR_CRL_TOO_OLD }, + { "Line_Too_Long", GPG_ERR_LINE_TOO_LONG }, + { "Not_Trusted", GPG_ERR_NOT_TRUSTED }, + { "Canceled", GPG_ERR_CANCELED }, + { "Bad_CA_Certificate", GPG_ERR_BAD_CA_CERT }, + { "Certificate_Expired", GPG_ERR_CERT_EXPIRED }, + { "Certificate_Too_Young", GPG_ERR_CERT_TOO_YOUNG }, + { "Unsupported_Certificate", GPG_ERR_UNSUPPORTED_CERT }, + { "Unknown_Sexp", GPG_ERR_UNKNOWN_SEXP }, + { "Unsupported_Protection", GPG_ERR_UNSUPPORTED_PROTECTION }, + { "Corrupted_Protection", GPG_ERR_CORRUPTED_PROTECTION }, + { "Ambiguous_Name", GPG_ERR_AMBIGUOUS_NAME }, + { "Card_Error", GPG_ERR_CARD }, + { "Card_Reset", GPG_ERR_CARD_RESET }, + { "Card_Removed", GPG_ERR_CARD_REMOVED }, + { "Invalid_Card", GPG_ERR_INV_CARD }, + { "Card_Not_Present", GPG_ERR_CARD_NOT_PRESENT }, + { "No_PKCS15_App", GPG_ERR_NO_PKCS15_APP }, + { "Not_Confirmed", GPG_ERR_NOT_CONFIRMED }, + { "Configuration_Error", GPG_ERR_CONFIGURATION }, + { "No_Policy_Match", GPG_ERR_NO_POLICY_MATCH }, + { "Invalid_Index", GPG_ERR_INV_INDEX }, + { "Invalid_Id", GPG_ERR_INV_ID }, + { "No_Scdaemon", GPG_ERR_NO_SCDAEMON }, + { "Scdaemon_Error", GPG_ERR_SCDAEMON }, + { "Unsupported_Protocol", GPG_ERR_UNSUPPORTED_PROTOCOL }, + { "Bad_PIN_Method", GPG_ERR_BAD_PIN_METHOD }, + { "Card_Not_Initialized", GPG_ERR_CARD_NOT_INITIALIZED }, + { "Unsupported_Operation", GPG_ERR_UNSUPPORTED_OPERATION }, + { "Wrong_Key_Usage", GPG_ERR_WRONG_KEY_USAGE } + }; + + +gpgme_error_t +_gpgme_map_gnupg_error (char *err) +{ + unsigned int i; + + for (i = 0; i < DIM (gnupg_errors); i++) + if (!strcmp (gnupg_errors[i].name, err)) + return gpg_err_make (GPG_ERR_SOURCE_GPG, gnupg_errors[i].err); + + return gpg_err_make (GPG_ERR_SOURCE_GPG, GPG_ERR_GENERAL); +} diff --git a/tags/gpgme-0-4-3/gpgme/data-compat.c b/tags/gpgme-0-4-3/gpgme/data-compat.c new file mode 100644 index 0000000..473fb6f --- /dev/null +++ b/tags/gpgme-0-4-3/gpgme/data-compat.c @@ -0,0 +1,200 @@ +/* data-compat.c - Compatibility interfaces for data objects. + Copyright (C) 2002, 2003 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 + 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. */ + +#if HAVE_CONFIG_H +#include +#endif + +#include +#include +#include +#include + +#include "data.h" +#include "util.h" + + +/* Create a new data buffer filled with LENGTH bytes starting from + OFFSET within the file FNAME or stream STREAM (exactly one must be + non-zero). */ +gpgme_error_t +gpgme_data_new_from_filepart (gpgme_data_t *dh, const char *fname, + FILE *stream, off_t offset, size_t length) +{ + gpgme_error_t err; + char *buf = NULL; + + if (stream && fname) + return gpg_error (GPG_ERR_INV_VALUE); + + if (fname) + stream = fopen (fname, "rb"); + if (!stream) + return gpg_error_from_errno (errno); + + if (fseek (stream, offset, SEEK_SET)) + { + int saved_errno = errno; + if (fname) + fclose (stream); + return gpg_error_from_errno (saved_errno); + } + + buf = malloc (length); + if (!buf) + { + int saved_errno = errno; + if (fname) + fclose (stream); + return gpg_error_from_errno (saved_errno); + } + + while (fread (buf, length, 1, stream) < 1 + && ferror (stream) && errno == EINTR); + if (ferror (stream)) + { + int saved_errno = errno; + if (buf) + free (buf); + if (fname) + fclose (stream); + return gpg_error_from_errno (saved_errno); + } + + if (fname) + fclose (stream); + + err = gpgme_data_new (dh); + if (err) + { + if (buf) + free (buf); + return err; + } + + (*dh)->data.mem.buffer = buf; + (*dh)->data.mem.size = length; + (*dh)->data.mem.length = length; + return 0; +} + + +/* Create a new data buffer filled with the content of file FNAME. + COPY must be non-zero (delayed reads are not supported yet). */ +gpgme_error_t +gpgme_data_new_from_file (gpgme_data_t *dh, const char *fname, int copy) +{ + struct stat statbuf; + + if (!fname || !copy) + return gpg_error (GPG_ERR_INV_VALUE); + + if (stat (fname, &statbuf) < 0) + return gpg_error_from_errno (errno); + + return gpgme_data_new_from_filepart (dh, fname, NULL, 0, statbuf.st_size); +} + + +static int +gpgme_error_to_errno (gpgme_error_t err) +{ + int no = gpg_err_code_to_errno (err); + + if (no) + { + errno = no; + return -1; + } + + switch (gpg_err_code (err)) + { + case GPG_ERR_EOF: + return 0; + case GPG_ERR_INV_VALUE: + errno = EINVAL; + return -1; + case GPG_ERR_NOT_SUPPORTED: + errno = EOPNOTSUPP; + return -1; + default: + /* FIXME: Yeah, well. */ + errno = EINVAL; + return -1; + } +} + + +static ssize_t +old_user_read (gpgme_data_t dh, void *buffer, size_t size) +{ + size_t amt; + gpgme_error_t err = (*dh->data.old_user.cb) (dh->data.old_user.handle, + buffer, size, &amt); + if (err) + return gpgme_error_to_errno (err); + return amt; +} + + +static off_t +old_user_seek (gpgme_data_t dh, off_t offset, int whence) +{ + gpgme_error_t err; + if (whence != SEEK_SET || offset) + return EINVAL; + err = (*dh->data.old_user.cb) (dh->data.old_user.handle, NULL, 0, NULL); + if (err) + return gpgme_error_to_errno (err); + return 0; +} + + +static struct _gpgme_data_cbs old_user_cbs = + { + old_user_read, + NULL, + old_user_seek, + NULL + }; + + +/* Create a new data buffer which retrieves the data from the callback + function READ_CB. */ +gpgme_error_t +gpgme_data_new_with_read_cb (gpgme_data_t *dh, + int (*read_cb) (void *, char *, size_t, size_t *), + void *read_cb_value) +{ + gpgme_error_t err = _gpgme_data_new (dh, &old_user_cbs); + if (err) + return err; + + (*dh)->data.old_user.cb = read_cb; + (*dh)->data.old_user.handle = read_cb_value; + return 0; +} + + +gpgme_error_t +gpgme_data_rewind (gpgme_data_t dh) +{ + return (gpgme_data_seek (dh, 0, SEEK_SET) == -1) + ? gpg_error_from_errno (errno) : 0; +} diff --git a/tags/gpgme-0-4-3/gpgme/data-fd.c b/tags/gpgme-0-4-3/gpgme/data-fd.c new file mode 100644 index 0000000..b120ca0 --- /dev/null +++ b/tags/gpgme-0-4-3/gpgme/data-fd.c @@ -0,0 +1,69 @@ +/* data-fd.c - A file descripor based data object. + Copyright (C) 2002 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 + 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. */ + +#if HAVE_CONFIG_H +#include +#endif + +#include +#include + +#include "data.h" + + +static ssize_t +fd_read (gpgme_data_t dh, void *buffer, size_t size) +{ + return read (dh->data.fd, buffer, size); +} + + +static ssize_t +fd_write (gpgme_data_t dh, const void *buffer, size_t size) +{ + return write (dh->data.fd, buffer, size); +} + + +static off_t +fd_seek (gpgme_data_t dh, off_t offset, int whence) +{ + return lseek (dh->data.fd, offset, whence); +} + + +static struct _gpgme_data_cbs fd_cbs = + { + fd_read, + fd_write, + fd_seek, + NULL + }; + + +gpgme_error_t +gpgme_data_new_from_fd (gpgme_data_t *dh, int fd) +{ + gpgme_error_t err = _gpgme_data_new (dh, &fd_cbs); + if (err) + return err; + + (*dh)->data.fd = fd; + return 0; +} diff --git a/tags/gpgme-0-4-3/gpgme/data-mem.c b/tags/gpgme-0-4-3/gpgme/data-mem.c new file mode 100644 index 0000000..6d11899 --- /dev/null +++ b/tags/gpgme-0-4-3/gpgme/data-mem.c @@ -0,0 +1,223 @@ +/* data-mem.c - A memory based data object. + Copyright (C) 2002, 2003 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 + 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. */ + +#if HAVE_CONFIG_H +#include +#endif + +#include +#include +#include +#include +#include + +#include "data.h" +#include "util.h" + + +static ssize_t +mem_read (gpgme_data_t dh, void *buffer, size_t size) +{ + size_t amt = dh->data.mem.length - dh->data.mem.offset; + const char *src; + + if (!amt) + return 0; + + if (size < amt) + amt = size; + + src = dh->data.mem.buffer ? dh->data.mem.buffer : dh->data.mem.orig_buffer; + memcpy (buffer, src + dh->data.mem.offset, amt); + dh->data.mem.offset += amt; + return amt; +} + + +static ssize_t +mem_write (gpgme_data_t dh, const void *buffer, size_t size) +{ + size_t unused; + + if (!dh->data.mem.buffer && dh->data.mem.orig_buffer) + { + size_t new_size = dh->data.mem.size; + char *new_buffer; + + if (new_size < dh->data.mem.offset + size) + new_size = dh->data.mem.offset + size; + + new_buffer = malloc (new_size); + if (!new_buffer) + return -1; + memcpy (new_buffer, dh->data.mem.orig_buffer, dh->data.mem.length); + + dh->data.mem.buffer = new_buffer; + dh->data.mem.size = new_size; + } + + unused = dh->data.mem.size - dh->data.mem.offset; + if (unused < size) + { + /* Allocate a large enough buffer with exponential backoff. */ +#define INITIAL_ALLOC 512 + size_t new_size = dh->data.mem.size + ? (2 * dh->data.mem.size) : INITIAL_ALLOC; + char *new_buffer; + + if (new_size < dh->data.mem.offset + size) + new_size = dh->data.mem.offset + size; + + new_buffer = realloc (dh->data.mem.buffer, new_size); + if (!new_buffer && new_size > dh->data.mem.offset + size) + { + /* Maybe we were too greedy, try again. */ + new_size = dh->data.mem.offset + size; + new_buffer = realloc (dh->data.mem.buffer, new_size); + } + if (!new_buffer) + return -1; + dh->data.mem.buffer = new_buffer; + dh->data.mem.size = new_size; + } + + memcpy (dh->data.mem.buffer + dh->data.mem.offset, buffer, size); + dh->data.mem.offset += size; + if (dh->data.mem.length < dh->data.mem.offset) + dh->data.mem.length = dh->data.mem.offset; + return size; +} + + +static off_t +mem_seek (gpgme_data_t dh, off_t offset, int whence) +{ + switch (whence) + { + case SEEK_SET: + if (offset < 0 || offset > dh->data.mem.length) + { + errno = EINVAL; + return -1; + } + dh->data.mem.offset = offset; + break; + case SEEK_CUR: + if ((offset > 0 && dh->data.mem.length - dh->data.mem.offset < offset) + || (offset < 0 && dh->data.mem.offset < -offset)) + { + errno = EINVAL; + return -1; + } + dh->data.mem.offset += offset; + break; + case SEEK_END: + if (offset > 0 || -offset > dh->data.mem.length) + { + errno = EINVAL; + return -1; + } + dh->data.mem.offset = dh->data.mem.length - offset; + break; + default: + errno = EINVAL; + return -1; + } + return dh->data.mem.offset; +} + + +static void +mem_release (gpgme_data_t dh) +{ + if (dh->data.mem.buffer) + free (dh->data.mem.buffer); +} + + +static struct _gpgme_data_cbs mem_cbs = + { + mem_read, + mem_write, + mem_seek, + mem_release + }; + + +gpgme_error_t +gpgme_data_new (gpgme_data_t *dh) +{ + gpgme_error_t err = _gpgme_data_new (dh, &mem_cbs); + if (err) + return err; + + return 0; +} + + +/* Create a new data buffer filled with SIZE bytes starting from + BUFFER. If COPY is zero, copying is delayed until necessary, and + the data is taken from the original location when needed. */ +gpgme_error_t +gpgme_data_new_from_mem (gpgme_data_t *dh, const char *buffer, + size_t size, int copy) +{ + gpgme_error_t err = _gpgme_data_new (dh, &mem_cbs); + if (err) + return err; + + if (copy) + { + char *bufcpy = malloc (size); + if (!bufcpy) + _gpgme_data_release (*dh); + memcpy (bufcpy, buffer, size); + (*dh)->data.mem.buffer = bufcpy; + } + else + (*dh)->data.mem.orig_buffer = buffer; + + (*dh)->data.mem.size = size; + (*dh)->data.mem.length = size; + return 0; +} + + +char * +gpgme_data_release_and_get_mem (gpgme_data_t dh, size_t *r_len) +{ + char *str = NULL; + + if (!dh || dh->cbs != &mem_cbs) + return NULL; + + str = dh->data.mem.buffer; + if (!str && dh->data.mem.orig_buffer) + { + str = malloc (dh->data.mem.length); + if (!str) + return NULL; + memcpy (str, dh->data.mem.orig_buffer, dh->data.mem.length); + } + + if (r_len) + *r_len = dh->data.mem.length; + + return str; +} diff --git a/tags/gpgme-0-4-3/gpgme/data-stream.c b/tags/gpgme-0-4-3/gpgme/data-stream.c new file mode 100644 index 0000000..9945e39 --- /dev/null +++ b/tags/gpgme-0-4-3/gpgme/data-stream.c @@ -0,0 +1,75 @@ +/* data-stream.c - A stream based data object. + Copyright (C) 2002 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 + 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. */ + +#if HAVE_CONFIG_H +#include +#endif + +#include +#include + +#include "data.h" + + +static ssize_t +stream_read (gpgme_data_t dh, void *buffer, size_t size) +{ + size_t amt = fread (buffer, 1, size, dh->data.stream); + if (amt > 0) + return amt; + return ferror (dh->data.stream) ? -1 : 0; +} + + +static ssize_t +stream_write (gpgme_data_t dh, const void *buffer, size_t size) +{ + size_t amt = fwrite (buffer, 1, size, dh->data.stream); + if (amt > 0) + return amt; + return ferror (dh->data.stream) ? -1 : 0; +} + + +static off_t +stream_seek (gpgme_data_t dh, off_t offset, int whence) +{ + return fseek (dh->data.stream, offset, whence); +} + + +static struct _gpgme_data_cbs stream_cbs = + { + stream_read, + stream_write, + stream_seek, + NULL + }; + + +gpgme_error_t +gpgme_data_new_from_stream (gpgme_data_t *dh, FILE *stream) +{ + gpgme_error_t err = _gpgme_data_new (dh, &stream_cbs); + if (err) + return err; + + (*dh)->data.stream = stream; + return 0; +} diff --git a/tags/gpgme-0-4-3/gpgme/data-user.c b/tags/gpgme-0-4-3/gpgme/data-user.c new file mode 100644 index 0000000..6f12c35 --- /dev/null +++ b/tags/gpgme-0-4-3/gpgme/data-user.c @@ -0,0 +1,76 @@ +/* data-user.c - A user callback based data object. + Copyright (C) 2002 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 + 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. */ + +#if HAVE_CONFIG_H +#include +#endif + +#include + +#include "data.h" + + +static ssize_t +user_read (gpgme_data_t dh, void *buffer, size_t size) +{ + return (*dh->data.user.cbs->read) (dh->data.user.handle, buffer, size); +} + + +static ssize_t +user_write (gpgme_data_t dh, const void *buffer, size_t size) +{ + return (*dh->data.user.cbs->write) (dh->data.user.handle, buffer, size); +} + + +static off_t +user_seek (gpgme_data_t dh, off_t offset, int whence) +{ + return (*dh->data.user.cbs->seek) (dh->data.user.handle, offset, whence); +} + + +static void +user_release (gpgme_data_t dh) +{ + (*dh->data.user.cbs->release) (dh->data.user.handle); +} + + +static struct _gpgme_data_cbs user_cbs = + { + user_read, + user_write, + user_seek, + user_release + }; + + +gpgme_error_t +gpgme_data_new_from_cbs (gpgme_data_t *dh, gpgme_data_cbs_t cbs, void *handle) +{ + gpgme_error_t err = _gpgme_data_new (dh, &user_cbs); + if (err) + return err; + + (*dh)->data.user.cbs = cbs; + (*dh)->data.user.handle = handle; + return 0; +} diff --git a/tags/gpgme-0-4-3/gpgme/data.c b/tags/gpgme-0-4-3/gpgme/data.c new file mode 100644 index 0000000..80a3fb4 --- /dev/null +++ b/tags/gpgme-0-4-3/gpgme/data.c @@ -0,0 +1,222 @@ +/* data.c - An abstraction for data objects. + Copyright (C) 2002, 2003 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 + 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. */ + +#if HAVE_CONFIG_H +#include +#endif + +#include +#include +#include +#include + +#include "gpgme.h" +#include "data.h" +#include "util.h" +#include "ops.h" +#include "io.h" + + +gpgme_error_t +_gpgme_data_new (gpgme_data_t *r_dh, struct _gpgme_data_cbs *cbs) +{ + gpgme_data_t dh; + + if (!r_dh) + return gpg_error (GPG_ERR_INV_VALUE); + + *r_dh = NULL; + dh = calloc (1, sizeof (*dh)); + if (!dh) + return gpg_error_from_errno (errno); + + dh->cbs = cbs; + + *r_dh = dh; + return 0; +} + + +void +_gpgme_data_release (gpgme_data_t dh) +{ + if (dh) + free (dh); +} + + +/* Read up to SIZE bytes into buffer BUFFER from the data object with + the handle DH. Return the number of characters read, 0 on EOF and + -1 on error. If an error occurs, errno is set. */ +ssize_t +gpgme_data_read (gpgme_data_t dh, void *buffer, size_t size) +{ + if (!dh) + { + errno = EINVAL; + return -1; + } + if (!dh->cbs->read) + { + errno = EOPNOTSUPP; + return -1; + } + return (*dh->cbs->read) (dh, buffer, size); +} + + +/* Write up to SIZE bytes from buffer BUFFER to the data object with + the handle DH. Return the number of characters written, or -1 on + error. If an error occurs, errno is set. */ +ssize_t +gpgme_data_write (gpgme_data_t dh, const void *buffer, size_t size) +{ + if (!dh) + { + errno = EINVAL; + return -1; + } + if (!dh->cbs->write) + { + errno = EOPNOTSUPP; + return -1; + } + return (*dh->cbs->write) (dh, buffer, size); +} + + +/* Set the current position from where the next read or write starts + in the data object with the handle DH to OFFSET, relativ to + WHENCE. */ +off_t +gpgme_data_seek (gpgme_data_t dh, off_t offset, int whence) +{ + if (!dh) + { + errno = EINVAL; + return -1; + } + if (!dh->cbs->read) + { + errno = EOPNOTSUPP; + return -1; + } + return (*dh->cbs->seek) (dh, offset, whence); +} + + +/* Release the data object with the handle DH. */ +void +gpgme_data_release (gpgme_data_t dh) +{ + if (!dh) + return; + + if (dh->cbs->release) + (*dh->cbs->release) (dh); + _gpgme_data_release (dh); +} + + +/* Get the current encoding meta information for the data object with + handle DH. */ +gpgme_data_encoding_t +gpgme_data_get_encoding (gpgme_data_t dh) +{ + return dh ? dh->encoding : GPGME_DATA_ENCODING_NONE; +} + + +/* Set the encoding meta information for the data object with handle + DH to ENC. */ +gpgme_error_t +gpgme_data_set_encoding (gpgme_data_t dh, gpgme_data_encoding_t enc) +{ + if (!dh) + return gpg_error (GPG_ERR_INV_VALUE); + if (enc < 0 || enc > GPGME_DATA_ENCODING_ARMOR) + return gpg_error (GPG_ERR_INV_VALUE); + dh->encoding = enc; + return 0; +} + + +/* Functions to support the wait interface. */ + +gpgme_error_t +_gpgme_data_inbound_handler (void *opaque, int fd) +{ + gpgme_data_t dh = (gpgme_data_t) opaque; + char buffer[BUFFER_SIZE]; + char *bufp = buffer; + ssize_t buflen; + + buflen = read (fd, buffer, BUFFER_SIZE); + if (buflen < 0) + return gpg_error_from_errno (errno); + if (buflen == 0) + { + _gpgme_io_close (fd); + return 0; + } + + do + { + ssize_t amt = gpgme_data_write (dh, bufp, buflen); + if (amt == 0 || (amt < 0 && errno != EINTR)) + return gpg_error_from_errno (errno); + bufp += amt; + buflen -= amt; + } + while (buflen > 0); + return 0; +} + + +gpgme_error_t +_gpgme_data_outbound_handler (void *opaque, int fd) +{ + gpgme_data_t dh = (gpgme_data_t) opaque; + ssize_t nwritten; + + if (!dh->pending_len) + { + ssize_t amt = gpgme_data_read (dh, dh->pending, BUFFER_SIZE); + if (amt < 0) + return gpg_error_from_errno (errno); + if (amt == 0) + { + _gpgme_io_close (fd); + return 0; + } + dh->pending_len = amt; + } + + nwritten = _gpgme_io_write (fd, dh->pending, dh->pending_len); + if (nwritten == -1 && errno == EAGAIN ) + return 0; + + if (nwritten <= 0) + return gpg_error_from_errno (errno); + + if (nwritten < dh->pending_len) + memmove (dh->pending, dh->pending + nwritten, dh->pending_len - nwritten); + dh->pending_len -= nwritten; + return 0; +} diff --git a/tags/gpgme-0-4-3/gpgme/data.h b/tags/gpgme-0-4-3/gpgme/data.h new file mode 100644 index 0000000..57815ef --- /dev/null +++ b/tags/gpgme-0-4-3/gpgme/data.h @@ -0,0 +1,120 @@ +/* data.h - Internal data object abstraction interface. + Copyright (C) 2002 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 + 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. */ + +#ifndef DATA_H +#define DATA_H + +#if HAVE_CONFIG_H +#include +#endif + +#include +#include + +#include "gpgme.h" + + +/* Read up to SIZE bytes into buffer BUFFER from the data object with + the handle DH. Return the number of characters read, 0 on EOF and + -1 on error. If an error occurs, errno is set. */ +typedef ssize_t (*gpgme_data_read_cb) (gpgme_data_t dh, void *buffer, + size_t size); + +/* Write up to SIZE bytes from buffer BUFFER to the data object with + the handle DH. Return the number of characters written, or -1 on + error. If an error occurs, errno is set. */ +typedef ssize_t (*gpgme_data_write_cb) (gpgme_data_t dh, const void *buffer, + size_t size); + +/* Set the current position from where the next read or write starts + in the data object with the handle DH to OFFSET, relativ to + WHENCE. */ +typedef off_t (*gpgme_data_seek_cb) (gpgme_data_t dh, off_t offset, + int whence); + +/* Release the data object with the handle DH. */ +typedef void (*gpgme_data_release_cb) (gpgme_data_t dh); + +struct _gpgme_data_cbs +{ + gpgme_data_read_cb read; + gpgme_data_write_cb write; + gpgme_data_seek_cb seek; + gpgme_data_release_cb release; +}; + +struct gpgme_data +{ + struct _gpgme_data_cbs *cbs; + gpgme_data_encoding_t encoding; + +#ifdef PIPE_BUF +#define BUFFER_SIZE PIPE_BUF +#else +#ifdef _POSIX_PIPE_BUF +#define BUFFER_SIZE _POSIX_PIPE_BUF +#else +#define BUFFER_SIZE 512 +#endif +#endif + char pending[BUFFER_SIZE]; + int pending_len; + + union + { + /* For gpgme_data_new_from_fd. */ + int fd; + + /* For gpgme_data_new_from_stream. */ + FILE *stream; + + /* For gpgme_data_new_from_cbs. */ + struct + { + gpgme_data_cbs_t cbs; + void *handle; + } user; + + /* For gpgme_data_new_from_mem. */ + struct + { + char *buffer; + const char *orig_buffer; + /* Allocated size of BUFFER. */ + size_t size; + size_t length; + size_t offset; + } mem; + + /* For gpgme_data_new_from_read_cb. */ + struct + { + int (*cb) (void *, char *, size_t, size_t *); + void *handle; + } old_user; + } data; +}; + + +gpgme_error_t _gpgme_data_new (gpgme_data_t *r_dh, + struct _gpgme_data_cbs *cbs); + +void _gpgme_data_release (gpgme_data_t dh); + +#endif /* DATA_H */ diff --git a/tags/gpgme-0-4-3/gpgme/debug.c b/tags/gpgme-0-4-3/gpgme/debug.c new file mode 100644 index 0000000..f913646 --- /dev/null +++ b/tags/gpgme-0-4-3/gpgme/debug.c @@ -0,0 +1,220 @@ +/* debug.c - helpful output in desperate situations + Copyright (C) 2000 Werner Koch (dd9jn) + Copyright (C) 2001, 2002, 2003 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 + 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. */ + +#if HAVE_CONFIG_H +#include +#endif +#include +#include +#include +#include +#include +#include +#ifndef HAVE_DOSISH_SYSTEM + #include + #include + #include +#endif +#include + +#include "util.h" +#include "sema.h" + + +/* Lock to serialize initialization of the debug output subsystem and + output of actual debug messages. */ +DEFINE_STATIC_LOCK (debug_lock); + +/* The amount of detail requested by the user, per environment + variable GPGME_DEBUG. */ +static int debug_level; + +/* The output stream for the debug messages. */ +static FILE *errfp; + + +/* Remove leading and trailing white spaces. */ +static char * +trim_spaces (char *str) +{ + char *string, *p, *mark; + + string = str; + /* Find first non space character. */ + for (p = string; *p && isspace (*(unsigned char *) p); p++) + ; + /* Move characters. */ + for (mark = NULL; (*string = *p); string++, p++) + if (isspace (*(unsigned char *) p)) + { + if (!mark) + mark = string; + } + else + mark = NULL; + if (mark) + *mark = '\0'; /* Remove trailing spaces. */ + + return str; +} + + +static void +debug_init (void) +{ + static int initialized; + + LOCK (debug_lock); + if (!initialized) + { + gpgme_error_t err; + char *e; + const char *s1, *s2;; + + err = _gpgme_getenv ("GPGME_DEBUG", &e); + if (err) + { + UNLOCK (debug_lock); + return; + } + + initialized = 1; + errfp = stderr; + if (e) + { + debug_level = atoi (e); + s1 = strchr (e, ':'); + if (s1) + { +#ifndef HAVE_DOSISH_SYSTEM + if (getuid () == geteuid ()) + { +#endif + char *p; + FILE *fp; + + s1++; + if (!(s2 = strchr (s1, ':'))) + s2 = s1 + strlen (s1); + p = malloc (s2 - s1 + 1); + if (p) + { + memcpy (p, s1, s2 - s1); + p[s2-s1] = 0; + trim_spaces (p); + fp = fopen (p,"a"); + if (fp) + { + setvbuf (fp, NULL, _IOLBF, 0); + errfp = fp; + } + free (p); + } +#ifndef HAVE_DOSISH_SYSTEM + } +#endif + } + free (e); + } + + if (debug_level > 0) + fprintf (errfp, "gpgme_debug: level=%d\n", debug_level); + } + UNLOCK (debug_lock); +} + + +/* Log the formatted string FORMAT at debug level LEVEL or higher. */ +void +_gpgme_debug (int level, const char *format, ...) +{ + va_list arg_ptr; + + debug_init (); + if (debug_level < level) + return; + + va_start (arg_ptr, format); + LOCK (debug_lock); + vfprintf (errfp, format, arg_ptr); + va_end (arg_ptr); + if(format && *format && format[strlen (format) - 1] != '\n') + putc ('\n', errfp); + UNLOCK (debug_lock); + fflush (errfp); +} + + +/* Start a new debug line in *LINE, logged at level LEVEL or higher, + and starting with the formatted string FORMAT. */ +void +_gpgme_debug_begin (void **line, int level, const char *format, ...) +{ + va_list arg_ptr; + + debug_init (); + if (debug_level < level) + { + /* Disable logging of this line. */ + *line = NULL; + return; + } + + va_start (arg_ptr, format); + vasprintf ((char **) line, format, arg_ptr); + va_end (arg_ptr); +} + + +/* Add the formatted string FORMAT to the debug line *LINE. */ +void +_gpgme_debug_add (void **line, const char *format, ...) +{ + va_list arg_ptr; + char *toadd; + char *result; + + if (!*line) + return; + + va_start (arg_ptr, format); + vasprintf (&toadd, format, arg_ptr); + va_end (arg_ptr); + asprintf (&result, "%s%s", *(char **) line, toadd); + free (*line); + free (toadd); + *line = result; +} + + +/* Finish construction of *LINE and send it to the debug output + stream. */ +void +_gpgme_debug_end (void **line) +{ + if (!*line) + return; + + /* The smallest possible level is 1, so force logging here by + using that. */ + _gpgme_debug (1, "%s", *line); + free (*line); + *line = NULL; +} diff --git a/tags/gpgme-0-4-3/gpgme/debug.h b/tags/gpgme-0-4-3/gpgme/debug.h new file mode 100644 index 0000000..4bc42cf --- /dev/null +++ b/tags/gpgme-0-4-3/gpgme/debug.h @@ -0,0 +1,110 @@ +/* debug.h - interface to debugging functions + * Copyright (C) 2002 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 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA + */ + +#ifndef DEBUG_H +#define DEBUG_H + +/* Log the formatted string FORMAT at debug level LEVEL or higher. */ +void _gpgme_debug (int level, const char *format, ...); + +/* Start a new debug line in *LINE, logged at level LEVEL or higher, + and starting with the formatted string FORMAT. */ +void _gpgme_debug_begin (void **helper, int level, const char *format, ...); + +/* Add the formatted string FORMAT to the debug line *LINE. */ +void _gpgme_debug_add (void **helper, const char *format, ...); + +/* Finish construction of *LINE and send it to the debug output + stream. */ +void _gpgme_debug_end (void **helper); + +/* Indirect stringification, requires __STDC__ to work. */ +#define STRINGIFY(v) #v +#define XSTRINGIFY(v) STRINGIFY(v) + +#if 0 +/* Only works in GNU. */ +#define DEBUG(fmt, arg...) \ + _gpgme_debug (1, "%s:%s: " fmt, __FILE__, XSTRINGIFY (__LINE__) , ##arg) +#define DEBUG_BEGIN(hlp, lvl, fmt, arg...) \ + _gpgme_debug_begin (&(hlp), lvl, "%s:%s: " fmt, __FILE__, \ + XSTRINGIFY (__LINE__) , ##arg) +#define DEBUG_ADD(hlp, fmt, arg...) \ + _gpgme_debug_add (&(hlp), fmt , ##arg) +#define DEBUG_END(hlp, fmt, arg...) \ + _gpgme_debug_add (&(hlp), fmt , ##arg); \ + _gpgme_debug_end (&(hlp)) +#elif 0 +/* Only works in C99. */ +#define DEBUG0(fmt) \ + _gpgme_debug (1, "%s:%s: " fmt, __FILE__, XSTRINGIFY (__LINE__)) +#define DEBUG(fmt, ...) \ + _gpgme_debug (1, "%s:%s: " fmt, __FILE__, XSTRINGIFY (__LINE__), __VA_ARGS__) +#define DEBUG_BEGIN(hlp, lvl, fmt) \ + _gpgme_debug_begin (&(hlp), lvl, "%s:%s: " fmt, __FILE__, \ + XSTRINGIFY (__LINE__)) +#define DEBUG_BEGINX(hlp, lvl, fmt, ...) \ + _gpgme_debug_begin (&(hlp), lvl, "%s:%s: " fmt, __FILE__, \ + XSTRINGIFY (__LINE__), __VA_ARGS__) +#define DEBUG_ADD0(hlp, fmt) \ + _gpgme_debug_add (&(hlp), fmt) +#define DEBUG_ADD(hlp, fmt, ...) \ + _gpgme_debug_add (&(hlp), fmt, __VA_ARGS__) +#define DEBUG_END(hlp, fmt) \ + _gpgme_debug_add (&(hlp), fmt); \ + _gpgme_debug_end (&(hlp)) +#define DEBUG_ENDX(hlp, fmt, ...) \ + _gpgme_debug_add (&(hlp), fmt, __VA_ARGS__); \ + _gpgme_debug_end (&(hlp)) +#else +/* This finally works everywhere, horror. */ +#define DEBUG0(fmt) \ + _gpgme_debug (1, "%s:%s: " fmt, __FILE__, XSTRINGIFY (__LINE__)) +#define DEBUG1(fmt,a) \ + _gpgme_debug (1, "%s:%s: " fmt, __FILE__, XSTRINGIFY (__LINE__), (a)) +#define DEBUG2(fmt,a,b) \ + _gpgme_debug (1, "%s:%s: " fmt, __FILE__, XSTRINGIFY (__LINE__), (a), (b)) +#define DEBUG3(fmt,a,b,c) \ + _gpgme_debug (1, "%s:%s: " fmt, __FILE__, XSTRINGIFY (__LINE__), (a), (b), \ + (c)) +#define DEBUG4(fmt,a,b,c,d) \ + _gpgme_debug (1, "%s:%s: " fmt, __FILE__, XSTRINGIFY (__LINE__), (a), (b), \ + (c), (d)) +#define DEBUG5(fmt,a,b,c,d,e) \ + _gpgme_debug (1, "%s:%s: " fmt, __FILE__, XSTRINGIFY (__LINE__), (a), (b), \ + (c), (d), (e)) +#define DEBUG_BEGIN(hlp,lvl,fmt) \ + _gpgme_debug_begin (&(hlp), lvl, "%s:%s: " fmt, __FILE__, XSTRINGIFY (__LINE__)) +#define DEBUG_ADD0(hlp,fmt) \ + _gpgme_debug_add (&(hlp), fmt) +#define DEBUG_ADD1(hlp,fmt,a) \ + _gpgme_debug_add (&(hlp), fmt, (a)) +#define DEBUG_ADD2(hlp,fmt,a,b) \ + _gpgme_debug_add (&(hlp), fmt, (a), (b)) +#define DEBUG_ADD3(hlp,fmt,a,b,c) \ + _gpgme_debug_add (&(hlp), fmt, (a), (b), (c)) +#define DEBUG_END(hlp,fmt) \ + _gpgme_debug_add (&(hlp), fmt); \ + _gpgme_debug_end (&(hlp)) +#endif + +#define DEBUG_ENABLED(hlp) (!!(hlp)) + +#endif /* DEBUG_H */ diff --git a/tags/gpgme-0-4-3/gpgme/decrypt-verify.c b/tags/gpgme-0-4-3/gpgme/decrypt-verify.c new file mode 100644 index 0000000..40818bf --- /dev/null +++ b/tags/gpgme-0-4-3/gpgme/decrypt-verify.c @@ -0,0 +1,102 @@ +/* decrypt-verify.c - Decrypt and verify function. + Copyright (C) 2000 Werner Koch (dd9jn) + Copyright (C) 2001, 2002, 2003 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 + 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. */ + +#if HAVE_CONFIG_H +#include +#endif + +#include "gpgme.h" +#include "ops.h" + + +static gpgme_error_t +decrypt_verify_status_handler (void *priv, gpgme_status_code_t code, + char *args) +{ + gpgme_error_t err; + + err = _gpgme_progress_status_handler (priv, code, args); + if (!err) + err = _gpgme_decrypt_status_handler (priv, code, args); + if (!err) + err = _gpgme_verify_status_handler (priv, code, args); + return err; +} + + +static gpgme_error_t +decrypt_verify_start (gpgme_ctx_t ctx, int synchronous, + gpgme_data_t cipher, gpgme_data_t plain) +{ + gpgme_error_t err; + + err = _gpgme_op_reset (ctx, synchronous); + if (err) + return err; + + err = _gpgme_op_decrypt_init_result (ctx); + if (err) + return err; + + err = _gpgme_op_verify_init_result (ctx); + if (err) + return err; + + if (!cipher) + return gpg_error (GPG_ERR_NO_DATA); + if (!plain) + return gpg_error (GPG_ERR_INV_VALUE); + + if (ctx->passphrase_cb) + { + err = _gpgme_engine_set_command_handler + (ctx->engine, _gpgme_passphrase_command_handler, ctx, NULL); + if (err) + return err; + } + + _gpgme_engine_set_status_handler (ctx->engine, + decrypt_verify_status_handler, ctx); + + return _gpgme_engine_op_decrypt (ctx->engine, cipher, plain); +} + + +/* Decrypt ciphertext CIPHER and make a signature verification within + CTX and store the resulting plaintext in PLAIN. */ +gpgme_error_t +gpgme_op_decrypt_verify_start (gpgme_ctx_t ctx, gpgme_data_t cipher, + gpgme_data_t plain) +{ + return decrypt_verify_start (ctx, 0, cipher, plain); +} + + +/* Decrypt ciphertext CIPHER and make a signature verification within + CTX and store the resulting plaintext in PLAIN. */ +gpgme_error_t +gpgme_op_decrypt_verify (gpgme_ctx_t ctx, gpgme_data_t cipher, + gpgme_data_t plain) +{ + gpgme_error_t err = decrypt_verify_start (ctx, 1, cipher, plain); + if (!err) + err = _gpgme_wait_one (ctx); + return err; +} diff --git a/tags/gpgme-0-4-3/gpgme/decrypt.c b/tags/gpgme-0-4-3/gpgme/decrypt.c new file mode 100644 index 0000000..030073f --- /dev/null +++ b/tags/gpgme-0-4-3/gpgme/decrypt.c @@ -0,0 +1,223 @@ +/* decrypt.c - Decrypt function. + Copyright (C) 2000 Werner Koch (dd9jn) + Copyright (C) 2001, 2002, 2003 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 + 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. */ + +#if HAVE_CONFIG_H +#include +#endif +#include +#include +#include + +#include "gpgme.h" +#include "util.h" +#include "context.h" +#include "ops.h" + + +typedef struct +{ + struct _gpgme_op_decrypt_result result; + + int okay; + int failed; +} *op_data_t; + + +static void +release_op_data (void *hook) +{ + op_data_t opd = (op_data_t) hook; + + if (opd->result.unsupported_algorithm) + free (opd->result.unsupported_algorithm); +} + + +gpgme_decrypt_result_t +gpgme_op_decrypt_result (gpgme_ctx_t ctx) +{ + void *hook; + op_data_t opd; + gpgme_error_t err; + + err = _gpgme_op_data_lookup (ctx, OPDATA_DECRYPT, &hook, -1, NULL); + opd = hook; + if (err || !opd) + return NULL; + + return &opd->result; +} + + +gpgme_error_t +_gpgme_decrypt_status_handler (void *priv, gpgme_status_code_t code, + char *args) +{ + gpgme_ctx_t ctx = (gpgme_ctx_t) priv; + gpgme_error_t err; + void *hook; + op_data_t opd; + + err = _gpgme_passphrase_status_handler (priv, code, args); + if (err) + return err; + + err = _gpgme_op_data_lookup (ctx, OPDATA_DECRYPT, &hook, -1, NULL); + opd = hook; + if (err) + return err; + + switch (code) + { + case GPGME_STATUS_EOF: + /* FIXME: These error values should probably be attributed to + the underlying crypto engine (as error source). */ + if (opd->failed) + return gpg_error (GPG_ERR_DECRYPT_FAILED); + else if (!opd->okay) + return gpg_error (GPG_ERR_NO_DATA); + break; + + case GPGME_STATUS_DECRYPTION_OKAY: + opd->okay = 1; + break; + + case GPGME_STATUS_DECRYPTION_FAILED: + opd->failed = 1; + break; + + case GPGME_STATUS_ERROR: + { + const char d_alg[] = "decrypt.algorithm"; + const char u_alg[] = "Unsupported_Algorithm"; + if (!strncmp (args, d_alg, sizeof (d_alg) - 1)) + { + args += sizeof (d_alg); + while (*args == ' ') + args++; + + if (!strncmp (args, u_alg, sizeof (u_alg) - 1)) + { + char *end; + + args += sizeof (u_alg); + while (*args == ' ') + args++; + + end = strchr (args, ' '); + if (end) + *end = '\0'; + + if (!(*args == '?' && *(args + 1) == '\0')) + { + opd->result.unsupported_algorithm = strdup (args); + if (!opd->result.unsupported_algorithm) + return gpg_error_from_errno (errno); + } + } + } + } + break; + + default: + break; + } + + return 0; +} + + +static gpgme_error_t +decrypt_status_handler (void *priv, gpgme_status_code_t code, char *args) +{ + gpgme_error_t err; + + err = _gpgme_progress_status_handler (priv, code, args); + if (!err) + err = _gpgme_decrypt_status_handler (priv, code, args); + return err; +} + + +gpgme_error_t +_gpgme_op_decrypt_init_result (gpgme_ctx_t ctx) +{ + void *hook; + op_data_t opd; + + return _gpgme_op_data_lookup (ctx, OPDATA_DECRYPT, &hook, + sizeof (*opd), release_op_data); +} + + +static gpgme_error_t +decrypt_start (gpgme_ctx_t ctx, int synchronous, + gpgme_data_t cipher, gpgme_data_t plain) +{ + gpgme_error_t err; + + err = _gpgme_op_reset (ctx, synchronous); + if (err) + return err; + + err = _gpgme_op_decrypt_init_result (ctx); + if (err) + return err; + + if (!cipher) + return gpg_error (GPG_ERR_NO_DATA); + if (!plain) + return gpg_error (GPG_ERR_INV_VALUE); + + if (err) + return err; + + if (ctx->passphrase_cb) + { + err = _gpgme_engine_set_command_handler + (ctx->engine, _gpgme_passphrase_command_handler, ctx, NULL); + if (err) + return err; + } + + _gpgme_engine_set_status_handler (ctx->engine, decrypt_status_handler, ctx); + + return _gpgme_engine_op_decrypt (ctx->engine, cipher, plain); +} + + +gpgme_error_t +gpgme_op_decrypt_start (gpgme_ctx_t ctx, gpgme_data_t cipher, + gpgme_data_t plain) +{ + return decrypt_start (ctx, 0, cipher, plain); +} + + +/* Decrypt ciphertext CIPHER within CTX and store the resulting + plaintext in PLAIN. */ +gpgme_error_t +gpgme_op_decrypt (gpgme_ctx_t ctx, gpgme_data_t cipher, gpgme_data_t plain) +{ + gpgme_error_t err = decrypt_start (ctx, 1, cipher, plain); + if (!err) + err = _gpgme_wait_one (ctx); + return err; +} diff --git a/tags/gpgme-0-4-3/gpgme/delete.c b/tags/gpgme-0-4-3/gpgme/delete.c new file mode 100644 index 0000000..30dd450 --- /dev/null +++ b/tags/gpgme-0-4-3/gpgme/delete.c @@ -0,0 +1,108 @@ +/* delete.c - Delete a key. + Copyright (C) 2001, 2002, 2003 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 + 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. */ + +#if HAVE_CONFIG_H +#include +#endif +#include +#include + +#include "gpgme.h" +#include "context.h" +#include "ops.h" + + +static gpgme_error_t +delete_status_handler (void *priv, gpgme_status_code_t code, char *args) +{ + if (code == GPGME_STATUS_DELETE_PROBLEM) + { + enum delete_problem + { + DELETE_No_Problem = 0, + DELETE_No_Such_Key = 1, + DELETE_Must_Delete_Secret_Key = 2, + DELETE_Ambiguous_Specification = 3 + }; + long problem; + char *tail; + + errno = 0; + problem = strtol (args, &tail, 0); + if (errno || (*tail && *tail != ' ')) + return gpg_error (GPG_ERR_INV_ENGINE); + + switch (problem) + { + case DELETE_No_Problem: + break; + + case DELETE_No_Such_Key: + return gpg_error (GPG_ERR_NO_PUBKEY); + + case DELETE_Must_Delete_Secret_Key: + return gpg_error (GPG_ERR_CONFLICT); + + case DELETE_Ambiguous_Specification: + return gpg_error (GPG_ERR_AMBIGUOUS_NAME); + + default: + return gpg_error (GPG_ERR_GENERAL); + } + } + return 0; +} + + +static gpgme_error_t +delete_start (gpgme_ctx_t ctx, int synchronous, const gpgme_key_t key, + int allow_secret) +{ + gpgme_error_t err; + + err = _gpgme_op_reset (ctx, synchronous); + if (err) + return err; + + _gpgme_engine_set_status_handler (ctx->engine, delete_status_handler, ctx); + + return _gpgme_engine_op_delete (ctx->engine, key, allow_secret); +} + + +/* Delete KEY from the keyring. If ALLOW_SECRET is non-zero, secret + keys are also deleted. */ +gpgme_error_t +gpgme_op_delete_start (gpgme_ctx_t ctx, const gpgme_key_t key, + int allow_secret) +{ + return delete_start (ctx, 0, key, allow_secret); +} + + +/* Delete KEY from the keyring. If ALLOW_SECRET is non-zero, secret + keys are also deleted. */ +gpgme_error_t +gpgme_op_delete (gpgme_ctx_t ctx, const gpgme_key_t key, int allow_secret) +{ + gpgme_error_t err = delete_start (ctx, 1, key, allow_secret); + if (!err) + err = _gpgme_wait_one (ctx); + return err; +} diff --git a/tags/gpgme-0-4-3/gpgme/edit.c b/tags/gpgme-0-4-3/gpgme/edit.c new file mode 100644 index 0000000..8c538f3 --- /dev/null +++ b/tags/gpgme-0-4-3/gpgme/edit.c @@ -0,0 +1,169 @@ +/* edit.c - Key edit function. + Copyright (C) 2002, 2003 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 + 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. */ + +#if HAVE_CONFIG_H +#include +#endif +#include + +#include "gpgme.h" +#include "context.h" +#include "ops.h" + + +typedef struct +{ + /* The user callback function and its hook value. */ + gpgme_edit_cb_t fnc; + void *fnc_value; +} *op_data_t; + + +static gpgme_error_t +edit_status_handler (void *priv, gpgme_status_code_t status, char *args) +{ + gpgme_ctx_t ctx = (gpgme_ctx_t) priv; + gpgme_error_t err; + void *hook; + op_data_t opd; + + err = _gpgme_passphrase_status_handler (priv, status, args); + if (err) + return err; + + err = _gpgme_progress_status_handler (priv, status, args); + if (err) + return err; + + err = _gpgme_op_data_lookup (ctx, OPDATA_EDIT, &hook, -1, NULL); + opd = hook; + if (err) + return err; + + return (*opd->fnc) (opd->fnc_value, status, args, -1); +} + + +static gpgme_error_t +command_handler (void *priv, gpgme_status_code_t status, const char *args, + int fd) +{ + gpgme_ctx_t ctx = (gpgme_ctx_t) priv; + gpgme_error_t err; + int processed = 0; + + if (ctx->passphrase_cb) + { + err = _gpgme_passphrase_command_handler_internal (ctx, status, args, + fd, &processed); + if (err) + return err; + } + + if (!processed) + { + void *hook; + op_data_t opd; + + err = _gpgme_op_data_lookup (ctx, OPDATA_EDIT, &hook, -1, NULL); + opd = hook; + if (err) + return err; + + return (*opd->fnc) (opd->fnc_value, status, args, fd); + } + return 0; +} + + +static gpgme_error_t +edit_start (gpgme_ctx_t ctx, int synchronous, int type, gpgme_key_t key, + gpgme_edit_cb_t fnc, void *fnc_value, gpgme_data_t out) +{ + gpgme_error_t err; + void *hook; + op_data_t opd; + + err = _gpgme_op_reset (ctx, synchronous); + if (err) + return err; + + if (!fnc || !out) + return gpg_error (GPG_ERR_INV_VALUE); + + err = _gpgme_op_data_lookup (ctx, OPDATA_EDIT, &hook, sizeof (*opd), NULL); + opd = hook; + if (err) + return err; + + opd->fnc = fnc; + opd->fnc_value = fnc_value; + + err = _gpgme_engine_set_command_handler (ctx->engine, command_handler, + ctx, out); + if (err) + return err; + + _gpgme_engine_set_status_handler (ctx->engine, edit_status_handler, ctx); + + return _gpgme_engine_op_edit (ctx->engine, type, key, out, ctx); +} + + +gpgme_error_t +gpgme_op_edit_start (gpgme_ctx_t ctx, gpgme_key_t key, + gpgme_edit_cb_t fnc, void *fnc_value, gpgme_data_t out) +{ + return edit_start (ctx, 0, 0, key, fnc, fnc_value, out); +} + + +/* Edit the key KEY. Send status and command requests to FNC and + output of edit commands to OUT. */ +gpgme_error_t +gpgme_op_edit (gpgme_ctx_t ctx, gpgme_key_t key, + gpgme_edit_cb_t fnc, void *fnc_value, gpgme_data_t out) +{ + gpgme_error_t err = edit_start (ctx, 1, 0, key, fnc, fnc_value, out); + if (!err) + err = _gpgme_wait_one (ctx); + return err; +} + + +gpgme_error_t +gpgme_op_card_edit_start (gpgme_ctx_t ctx, gpgme_key_t key, + gpgme_edit_cb_t fnc, void *fnc_value, + gpgme_data_t out) +{ + return edit_start (ctx, 0, 1, key, fnc, fnc_value, out); +} + + +/* Edit the card for the key KEY. Send status and command requests to + FNC and output of edit commands to OUT. */ +gpgme_error_t +gpgme_op_card_edit (gpgme_ctx_t ctx, gpgme_key_t key, + gpgme_edit_cb_t fnc, void *fnc_value, gpgme_data_t out) +{ + gpgme_error_t err = edit_start (ctx, 1, 1, key, fnc, fnc_value, out); + if (!err) + err = _gpgme_wait_one (ctx); + return err; +} diff --git a/tags/gpgme-0-4-3/gpgme/encrypt-sign.c b/tags/gpgme-0-4-3/gpgme/encrypt-sign.c new file mode 100644 index 0000000..ae4b594 --- /dev/null +++ b/tags/gpgme-0-4-3/gpgme/encrypt-sign.c @@ -0,0 +1,109 @@ +/* encrypt-sign.c - encrypt and verify functions + Copyright (C) 2000 Werner Koch (dd9jn) + Copyright (C) 2001, 2002, 2003 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 + 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. */ + +#if HAVE_CONFIG_H +#include +#endif + +#include "gpgme.h" +#include "context.h" +#include "ops.h" + + +static gpgme_error_t +encrypt_sign_status_handler (void *priv, gpgme_status_code_t code, char *args) +{ + gpgme_error_t err; + + err = _gpgme_progress_status_handler (priv, code, args); + if (!err) + err = _gpgme_encrypt_status_handler (priv, code, args); + if (!err) + err = _gpgme_sign_status_handler (priv, code, args); + return err; +} + + +static gpgme_error_t +encrypt_sign_start (gpgme_ctx_t ctx, int synchronous, gpgme_key_t recp[], + gpgme_encrypt_flags_t flags, + gpgme_data_t plain, gpgme_data_t cipher) +{ + gpgme_error_t err; + + err = _gpgme_op_reset (ctx, synchronous); + if (err) + return err; + + if (!plain) + return gpg_error (GPG_ERR_NO_DATA); + if (!cipher || !recp) + return gpg_error (GPG_ERR_INV_VALUE); + + err = _gpgme_op_encrypt_init_result (ctx); + if (err) + return err; + + err = _gpgme_op_sign_init_result (ctx); + if (err) + return err; + + if (ctx->passphrase_cb) + { + err = _gpgme_engine_set_command_handler + (ctx->engine, _gpgme_passphrase_command_handler, ctx, NULL); + if (err) + return err; + } + + _gpgme_engine_set_status_handler (ctx->engine, + encrypt_sign_status_handler, ctx); + + return _gpgme_engine_op_encrypt_sign (ctx->engine, recp, flags, plain, + cipher, ctx->use_armor, + ctx /* FIXME */); +} + + +/* Encrypt plaintext PLAIN within CTX for the recipients RECP and + store the resulting ciphertext in CIPHER. Also sign the ciphertext + with the signers in CTX. */ +gpgme_error_t +gpgme_op_encrypt_sign_start (gpgme_ctx_t ctx, gpgme_key_t recp[], + gpgme_encrypt_flags_t flags, + gpgme_data_t plain, gpgme_data_t cipher) +{ + return encrypt_sign_start (ctx, 0, recp, flags, plain, cipher); +} + + +/* Encrypt plaintext PLAIN within CTX for the recipients RECP and + store the resulting ciphertext in CIPHER. Also sign the ciphertext + with the signers in CTX. */ +gpgme_error_t +gpgme_op_encrypt_sign (gpgme_ctx_t ctx, gpgme_key_t recp[], + gpgme_encrypt_flags_t flags, + gpgme_data_t plain, gpgme_data_t cipher) +{ + gpgme_error_t err = encrypt_sign_start (ctx, 1, recp, flags, plain, cipher); + if (!err) + err = _gpgme_wait_one (ctx); + return err; +} diff --git a/tags/gpgme-0-4-3/gpgme/encrypt.c b/tags/gpgme-0-4-3/gpgme/encrypt.c new file mode 100644 index 0000000..6eb177e --- /dev/null +++ b/tags/gpgme-0-4-3/gpgme/encrypt.c @@ -0,0 +1,221 @@ +/* encrypt.c - Encrypt function. + Copyright (C) 2000 Werner Koch (dd9jn) + Copyright (C) 2001, 2002, 2003 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 + 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. */ + +#if HAVE_CONFIG_H +#include +#endif +#include +#include +#include + +#include "gpgme.h" +#include "context.h" +#include "ops.h" + + +typedef struct +{ + struct _gpgme_op_encrypt_result result; + + /* A pointer to the next pointer of the last invalid recipient in + the list. This makes appending new invalid recipients painless + while preserving the order. */ + gpgme_invalid_key_t *lastp; +} *op_data_t; + + +static void +release_op_data (void *hook) +{ + op_data_t opd = (op_data_t) hook; + gpgme_invalid_key_t invalid_recipient = opd->result.invalid_recipients; + + while (invalid_recipient) + { + gpgme_invalid_key_t next = invalid_recipient->next; + if (invalid_recipient->fpr) + free (invalid_recipient->fpr); + invalid_recipient = next; + } +} + + +gpgme_encrypt_result_t +gpgme_op_encrypt_result (gpgme_ctx_t ctx) +{ + void *hook; + op_data_t opd; + gpgme_error_t err; + + err = _gpgme_op_data_lookup (ctx, OPDATA_ENCRYPT, &hook, -1, NULL); + opd = hook; + + if (err || !opd) + return NULL; + + return &opd->result; +} + + +gpgme_error_t +_gpgme_encrypt_status_handler (void *priv, gpgme_status_code_t code, + char *args) +{ + gpgme_ctx_t ctx = (gpgme_ctx_t) priv; + gpgme_error_t err; + void *hook; + op_data_t opd; + + err = _gpgme_op_data_lookup (ctx, OPDATA_ENCRYPT, &hook, -1, NULL); + opd = hook; + if (err) + return err; + + switch (code) + { + case GPGME_STATUS_EOF: + if (opd->result.invalid_recipients) + return gpg_error (GPG_ERR_UNUSABLE_PUBKEY); + break; + + case GPGME_STATUS_INV_RECP: + err = _gpgme_parse_inv_recp (args, opd->lastp); + if (err) + return err; + + opd->lastp = &(*opd->lastp)->next; + break; + + case GPGME_STATUS_NO_RECP: + /* Should not happen, because we require at least one recipient. */ + return gpg_error (GPG_ERR_GENERAL); + + default: + break; + } + return 0; +} + + +static gpgme_error_t +encrypt_sym_status_handler (void *priv, gpgme_status_code_t code, char *args) +{ + gpgme_error_t err; + + err = _gpgme_progress_status_handler (priv, code, args); + if (!err) + err = _gpgme_passphrase_status_handler (priv, code, args); + return err; +} + + +static gpgme_error_t +encrypt_status_handler (void *priv, gpgme_status_code_t code, char *args) +{ + return _gpgme_progress_status_handler (priv, code, args) + || _gpgme_encrypt_status_handler (priv, code, args); +} + + +gpgme_error_t +_gpgme_op_encrypt_init_result (gpgme_ctx_t ctx) +{ + gpgme_error_t err; + void *hook; + op_data_t opd; + + err = _gpgme_op_data_lookup (ctx, OPDATA_ENCRYPT, &hook, sizeof (*opd), + release_op_data); + opd = hook; + if (err) + return err; + + opd->lastp = &opd->result.invalid_recipients; + return 0; +} + + +static gpgme_error_t +encrypt_start (gpgme_ctx_t ctx, int synchronous, gpgme_key_t recp[], + gpgme_encrypt_flags_t flags, + gpgme_data_t plain, gpgme_data_t cipher) +{ + gpgme_error_t err; + int symmetric = 0; + + err = _gpgme_op_reset (ctx, synchronous); + if (err) + return err; + + err = _gpgme_op_encrypt_init_result (ctx); + if (err) + return err; + + if (!recp) + symmetric = 1; + + if (!plain) + return gpg_error (GPG_ERR_NO_DATA); + if (!cipher) + return gpg_error (GPG_ERR_INV_VALUE); + if (recp && ! *recp) + return gpg_error (GPG_ERR_INV_VALUE); + + if (symmetric && ctx->passphrase_cb) + { + /* Symmetric encryption requires a passphrase. */ + err = _gpgme_engine_set_command_handler + (ctx->engine, _gpgme_passphrase_command_handler, ctx, NULL); + if (err) + return err; + } + + _gpgme_engine_set_status_handler (ctx->engine, + symmetric + ? encrypt_sym_status_handler + : encrypt_status_handler, + ctx); + + return _gpgme_engine_op_encrypt (ctx->engine, recp, flags, plain, cipher, + ctx->use_armor); +} + + +gpgme_error_t +gpgme_op_encrypt_start (gpgme_ctx_t ctx, gpgme_key_t recp[], + gpgme_encrypt_flags_t flags, + gpgme_data_t plain, gpgme_data_t cipher) +{ + return encrypt_start (ctx, 0, recp, flags, plain, cipher); +} + + +/* Encrypt plaintext PLAIN within CTX for the recipients RECP and + store the resulting ciphertext in CIPHER. */ +gpgme_error_t +gpgme_op_encrypt (gpgme_ctx_t ctx, gpgme_key_t recp[], + gpgme_encrypt_flags_t flags, + gpgme_data_t plain, gpgme_data_t cipher) +{ + gpgme_error_t err = encrypt_start (ctx, 1, recp, flags, plain, cipher); + if (!err) + err = _gpgme_wait_one (ctx); + return err; +} diff --git a/tags/gpgme-0-4-3/gpgme/engine-backend.h b/tags/gpgme-0-4-3/gpgme/engine-backend.h new file mode 100644 index 0000000..0632fb6 --- /dev/null +++ b/tags/gpgme-0-4-3/gpgme/engine-backend.h @@ -0,0 +1,95 @@ +/* engine-backend.h - A crypto backend for the engine interface. + Copyright (C) 2002, 2003 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 + 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. */ + +#ifndef ENGINE_BACKEND_H +#define ENGINE_BACKEND_H + +#include "engine.h" + +/* FIXME: Correct check? */ +#ifdef GPGSM_PATH +#define ENABLE_GPGSM 1 +#endif + +struct engine_ops +{ + /* Static functions. */ + const char *(*get_file_name) (void); + const char *(*get_version) (void); + const char *(*get_req_version) (void); + gpgme_error_t (*new) (void **r_engine, + const char *lc_ctype, const char *lc_messages); + + /* Member functions. */ + void (*release) (void *engine); + void (*set_status_handler) (void *engine, engine_status_handler_t fnc, + void *fnc_value); + gpgme_error_t (*set_command_handler) (void *engine, + engine_command_handler_t fnc, + void *fnc_value, gpgme_data_t data); + gpgme_error_t (*set_colon_line_handler) (void *engine, + engine_colon_line_handler_t fnc, + void *fnc_value); + gpgme_error_t (*decrypt) (void *engine, gpgme_data_t ciph, + gpgme_data_t plain); + gpgme_error_t (*delete) (void *engine, gpgme_key_t key, int allow_secret); + gpgme_error_t (*edit) (void *engine, int type, gpgme_key_t key, + gpgme_data_t out, gpgme_ctx_t ctx /* FIXME */); + gpgme_error_t (*encrypt) (void *engine, gpgme_key_t recp[], + gpgme_encrypt_flags_t flags, + gpgme_data_t plain, gpgme_data_t ciph, + int use_armor); + gpgme_error_t (*encrypt_sign) (void *engine, gpgme_key_t recp[], + gpgme_encrypt_flags_t flags, + gpgme_data_t plain, gpgme_data_t ciph, + int use_armor, gpgme_ctx_t ctx /* FIXME */); + gpgme_error_t (*export) (void *engine, const char *pattern, + unsigned int reserved, gpgme_data_t keydata, + int use_armor); + gpgme_error_t (*export_ext) (void *engine, const char *pattern[], + unsigned int reserved, gpgme_data_t keydata, + int use_armor); + gpgme_error_t (*genkey) (void *engine, gpgme_data_t help_data, int use_armor, + gpgme_data_t pubkey, gpgme_data_t seckey); + gpgme_error_t (*import) (void *engine, gpgme_data_t keydata); + gpgme_error_t (*keylist) (void *engine, const char *pattern, + int secret_only, gpgme_keylist_mode_t mode); + gpgme_error_t (*keylist_ext) (void *engine, const char *pattern[], + int secret_only, int reserved, + gpgme_keylist_mode_t mode); + gpgme_error_t (*sign) (void *engine, gpgme_data_t in, gpgme_data_t out, + gpgme_sig_mode_t mode, int use_armor, + int use_textmode, + int include_certs, gpgme_ctx_t ctx /* FIXME */); + gpgme_error_t (*trustlist) (void *engine, const char *pattern); + gpgme_error_t (*verify) (void *engine, gpgme_data_t sig, + gpgme_data_t signed_text, + gpgme_data_t plaintext); + + void (*set_io_cbs) (void *engine, gpgme_io_cbs_t io_cbs); + void (*io_event) (void *engine, gpgme_event_io_t type, void *type_data); +}; + + +extern struct engine_ops _gpgme_engine_ops_gpg; /* OpenPGP. */ +#ifdef ENABLE_GPGSM +extern struct engine_ops _gpgme_engine_ops_gpgsm; /* CMS. */ +#endif + +#endif /* ENGINE_BACKEND_H */ diff --git a/tags/gpgme-0-4-3/gpgme/engine-gpgsm.c b/tags/gpgme-0-4-3/gpgme/engine-gpgsm.c new file mode 100644 index 0000000..486c745 --- /dev/null +++ b/tags/gpgme-0-4-3/gpgme/engine-gpgsm.c @@ -0,0 +1,1534 @@ +/* engine-gpgsm.c - GpgSM engine. + Copyright (C) 2000 Werner Koch (dd9jn) + Copyright (C) 2001, 2002, 2003 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 + 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. */ + +#if HAVE_CONFIG_H +#include +#endif + +#include +#include +#include +#include +#include +#include +#include /* FIXME */ +#include + +#include "gpgme.h" +#include "util.h" +#include "ops.h" +#include "wait.h" +#include "io.h" +#include "sema.h" + +#include "assuan.h" +#include "status-table.h" + +#include "engine-backend.h" + + +typedef struct +{ + int fd; /* FD we talk about. */ + int dir; /* Inbound/Outbound, maybe given implicit? */ + void *data; /* Handler-specific data. */ + void *tag; /* ID from the user for gpgme_remove_io_callback. */ +} iocb_data_t; + + +struct engine_gpgsm +{ + ASSUAN_CONTEXT assuan_ctx; + + iocb_data_t status_cb; + + /* Input, output etc are from the servers perspective. */ + iocb_data_t input_cb; + int input_fd_server; + + iocb_data_t output_cb; + int output_fd_server; + + iocb_data_t message_cb; + int message_fd_server; + + struct + { + engine_status_handler_t fnc; + void *fnc_value; + } status; + + struct + { + engine_colon_line_handler_t fnc; + void *fnc_value; + struct + { + unsigned char *line; + int linesize; + int linelen; + } attic; + int any; /* any data line seen */ + } colon; + + struct gpgme_io_cbs io_cbs; +}; + +typedef struct engine_gpgsm *engine_gpgsm_t; + + +static const char * +gpgsm_get_version (void) +{ + static const char *gpgsm_version; + DEFINE_STATIC_LOCK (gpgsm_version_lock); + + LOCK (gpgsm_version_lock); + if (!gpgsm_version) + gpgsm_version = _gpgme_get_program_version (_gpgme_get_gpgsm_path ()); + UNLOCK (gpgsm_version_lock); + + return gpgsm_version; +} + + +static const char * +gpgsm_get_req_version (void) +{ + return NEED_GPGSM_VERSION; +} + + +static void +close_notify_handler (int fd, void *opaque) +{ + engine_gpgsm_t gpgsm = opaque; + + assert (fd != -1); + if (gpgsm->status_cb.fd == fd) + { + if (gpgsm->status_cb.tag) + (*gpgsm->io_cbs.remove) (gpgsm->status_cb.tag); + gpgsm->status_cb.fd = -1; + } + else if (gpgsm->input_cb.fd == fd) + { + if (gpgsm->input_cb.tag) + (*gpgsm->io_cbs.remove) (gpgsm->input_cb.tag); + gpgsm->input_cb.fd = -1; + } + else if (gpgsm->output_cb.fd == fd) + { + if (gpgsm->output_cb.tag) + (*gpgsm->io_cbs.remove) (gpgsm->output_cb.tag); + gpgsm->output_cb.fd = -1; + } + else if (gpgsm->message_cb.fd == fd) + { + if (gpgsm->message_cb.tag) + (*gpgsm->io_cbs.remove) (gpgsm->message_cb.tag); + gpgsm->message_cb.fd = -1; + } +} + + +static gpgme_error_t +map_assuan_error (AssuanError err) +{ + if (err == -1) + return gpg_error (GPG_ERR_INV_ENGINE); + + /* New code will use gpg_error_t values. */ + if (gpg_err_source (err)) + return (gpgme_error_t) err; + + /* Legacy code will use old values. */ + switch (err) + { + case ASSUAN_No_Error: + return gpg_error (GPG_ERR_NO_ERROR); + case ASSUAN_General_Error: + return gpg_error (GPG_ERR_GENERAL); + case ASSUAN_Out_Of_Core: + return gpg_error (GPG_ERR_ENOMEM); + case ASSUAN_Invalid_Value: + return gpg_error (GPG_ERR_INV_VALUE); + case ASSUAN_Timeout: + return gpg_error (GPG_ERR_ETIMEDOUT); + case ASSUAN_Read_Error: + return gpg_error (GPG_ERR_GENERAL); + case ASSUAN_Write_Error: + return gpg_error (GPG_ERR_GENERAL); + + case ASSUAN_Problem_Starting_Server: + case ASSUAN_Not_A_Server: + case ASSUAN_Not_A_Client: + case ASSUAN_Nested_Commands: + case ASSUAN_No_Data_Callback: + case ASSUAN_No_Inquire_Callback: + case ASSUAN_Connect_Failed: + case ASSUAN_Accept_Failed: + case ASSUAN_Invalid_Command: + case ASSUAN_Unknown_Command: + case ASSUAN_Syntax_Error: + case ASSUAN_Parameter_Error: + case ASSUAN_Parameter_Conflict: + case ASSUAN_No_Input: + case ASSUAN_No_Output: + case ASSUAN_No_Data_Available: + case ASSUAN_Too_Much_Data: + case ASSUAN_Inquire_Unknown: + case ASSUAN_Inquire_Error: + case ASSUAN_Invalid_Option: + case ASSUAN_Unexpected_Status: + case ASSUAN_Unexpected_Data: + case ASSUAN_Invalid_Status: + return gpg_error (GPG_ERR_ASSUAN); + + case ASSUAN_Invalid_Response: + return gpg_error (GPG_ERR_INV_RESPONSE); + + case ASSUAN_Not_Implemented: + return gpg_error (GPG_ERR_NOT_IMPLEMENTED); + case ASSUAN_Line_Too_Long: + return gpg_error (GPG_ERR_LINE_TOO_LONG); + case ASSUAN_Line_Not_Terminated: + return gpg_error (GPG_ERR_INCOMPLETE_LINE); + case ASSUAN_Canceled: + return gpg_error (GPG_ERR_CANCELED); + + case ASSUAN_Unsupported_Algorithm: + return gpg_error (GPG_ERR_UNSUPPORTED_ALGORITHM); + case ASSUAN_Server_Resource_Problem: + return gpg_error (GPG_ERR_RESOURCE_LIMIT); + case ASSUAN_Server_IO_Error: + return gpg_error (GPG_ERR_GENERAL); + case ASSUAN_Server_Bug: + return gpg_error (GPG_ERR_BUG); + case ASSUAN_Invalid_Data: + return gpg_error (GPG_ERR_INV_DATA); + case ASSUAN_Invalid_Index: + return gpg_error (GPG_ERR_INV_INDEX); + case ASSUAN_Not_Confirmed: + return gpg_error (GPG_ERR_NOT_CONFIRMED); + case ASSUAN_Bad_Certificate: + return gpg_error (GPG_ERR_BAD_CERT); + case ASSUAN_Bad_Certificate_Chain: + return gpg_error (GPG_ERR_BAD_CERT_CHAIN); + case ASSUAN_Missing_Certificate: + return gpg_error (GPG_ERR_MISSING_CERT); + case ASSUAN_Bad_Signature: + return gpg_error (GPG_ERR_BAD_SIGNATURE); + case ASSUAN_No_Agent: + return gpg_error (GPG_ERR_NO_AGENT); + case ASSUAN_Agent_Error: + return gpg_error (GPG_ERR_AGENT); + case ASSUAN_No_Public_Key: + return gpg_error (GPG_ERR_NO_PUBKEY); + case ASSUAN_No_Secret_Key: + return gpg_error (GPG_ERR_NO_SECKEY); + case ASSUAN_Invalid_Name: + return gpg_error (GPG_ERR_INV_NAME); + + case ASSUAN_Cert_Revoked: + return gpg_error (GPG_ERR_CERT_REVOKED); + case ASSUAN_No_CRL_For_Cert: + return gpg_error (GPG_ERR_NO_CRL_KNOWN); + case ASSUAN_CRL_Too_Old: + return gpg_error (GPG_ERR_CRL_TOO_OLD); + case ASSUAN_Not_Trusted: + return gpg_error (GPG_ERR_NOT_TRUSTED); + + case ASSUAN_Card_Error: + return gpg_error (GPG_ERR_CARD); + case ASSUAN_Invalid_Card: + return gpg_error (GPG_ERR_INV_CARD); + case ASSUAN_No_PKCS15_App: + return gpg_error (GPG_ERR_NO_PKCS15_APP); + case ASSUAN_Card_Not_Present: + return gpg_error (GPG_ERR_CARD_NOT_PRESENT); + case ASSUAN_Invalid_Id: + return gpg_error (GPG_ERR_INV_ID); + default: + return gpg_error (GPG_ERR_GENERAL); + } +} + + +static void +gpgsm_release (void *engine) +{ + engine_gpgsm_t gpgsm = engine; + + if (!gpgsm) + return; + + if (gpgsm->status_cb.fd != -1) + _gpgme_io_close (gpgsm->status_cb.fd); + if (gpgsm->input_cb.fd != -1) + _gpgme_io_close (gpgsm->input_cb.fd); + if (gpgsm->output_cb.fd != -1) + _gpgme_io_close (gpgsm->output_cb.fd); + if (gpgsm->message_cb.fd != -1) + _gpgme_io_close (gpgsm->message_cb.fd); + + assuan_disconnect (gpgsm->assuan_ctx); + + free (gpgsm->colon.attic.line); + free (gpgsm); +} + + +static gpgme_error_t +gpgsm_new (void **engine, const char *lc_ctype, const char *lc_messages) +{ + gpgme_error_t err = 0; + engine_gpgsm_t gpgsm; + char *argv[3]; + int fds[2]; + int child_fds[4]; + char *dft_display = NULL; + char dft_ttyname[64]; + char *dft_ttytype = NULL; + char *optstr; + int fdlist[5]; + int nfds; + + gpgsm = calloc (1, sizeof *gpgsm); + if (!gpgsm) + return gpg_error_from_errno (errno); + + gpgsm->status_cb.fd = -1; + gpgsm->status_cb.tag = 0; + + gpgsm->input_cb.fd = -1; + gpgsm->input_cb.tag = 0; + gpgsm->input_fd_server = -1; + gpgsm->output_cb.fd = -1; + gpgsm->output_cb.tag = 0; + gpgsm->output_fd_server = -1; + gpgsm->message_cb.fd = -1; + gpgsm->message_cb.tag = 0; + gpgsm->message_fd_server = -1; + + gpgsm->status.fnc = 0; + gpgsm->colon.fnc = 0; + gpgsm->colon.attic.line = 0; + gpgsm->colon.attic.linesize = 0; + gpgsm->colon.attic.linelen = 0; + gpgsm->colon.any = 0; + + gpgsm->io_cbs.add = NULL; + gpgsm->io_cbs.add_priv = NULL; + gpgsm->io_cbs.remove = NULL; + gpgsm->io_cbs.event = NULL; + gpgsm->io_cbs.event_priv = NULL; + + if (_gpgme_io_pipe (fds, 0) < 0) + { + err = gpg_error_from_errno (errno); + goto leave; + } + gpgsm->input_cb.fd = fds[1]; + gpgsm->input_cb.dir = 0; + gpgsm->input_fd_server = fds[0]; + + if (_gpgme_io_pipe (fds, 1) < 0) + { + err = gpg_error_from_errno (errno); + goto leave; + } + gpgsm->output_cb.fd = fds[0]; + gpgsm->output_cb.dir = 1; + gpgsm->output_fd_server = fds[1]; + + if (_gpgme_io_pipe (fds, 0) < 0) + { + err = gpg_error_from_errno (errno); + goto leave; + } + gpgsm->message_cb.fd = fds[1]; + gpgsm->message_cb.dir = 0; + gpgsm->message_fd_server = fds[0]; + + child_fds[0] = gpgsm->input_fd_server; + child_fds[1] = gpgsm->output_fd_server; + child_fds[2] = gpgsm->message_fd_server; + child_fds[3] = -1; + + argv[0] = "gpgsm"; + argv[1] = "--server"; + argv[2] = NULL; + + err = assuan_pipe_connect (&gpgsm->assuan_ctx, + _gpgme_get_gpgsm_path (), argv, child_fds); + + /* We need to know the fd used by assuan for reads. We do this by + using the assumption that the first returned fd from + assuan_get_active_fds() is always this one. */ + nfds = assuan_get_active_fds (gpgsm->assuan_ctx, 0 /* read fds */, + fdlist, DIM (fdlist)); + if (nfds < 1) + { + err = gpg_error (GPG_ERR_GENERAL); /* FIXME */ + goto leave; + } + /* We duplicate the file descriptor, so we can close it without + disturbing assuan. Alternatively, we could special case + status_fd and register/unregister it manually as needed, but this + increases code duplication and is more complicated as we can not + use the close notifications etc. */ + gpgsm->status_cb.fd = dup (fdlist[0]); + if (gpgsm->status_cb.fd < 0) + { + err = gpg_error (GPG_ERR_GENERAL); /* FIXME */ + goto leave; + } + gpgsm->status_cb.dir = 1; + gpgsm->status_cb.data = gpgsm; + + err = _gpgme_getenv ("DISPLAY", &dft_display); + if (err) + goto leave; + if (dft_display) + { + if (asprintf (&optstr, "OPTION display=%s", dft_display) < 0) + { + free (dft_display); + err = gpg_error_from_errno (errno); + goto leave; + } + free (dft_display); + + err = assuan_transact (gpgsm->assuan_ctx, optstr, NULL, NULL, NULL, + NULL, NULL, NULL); + free (optstr); + if (err) + { + err = map_assuan_error (err); + goto leave; + } + } + + if (ttyname_r (1, dft_ttyname, sizeof (dft_ttyname))) + { + err = gpg_error_from_errno (errno); + goto leave; + } + else + { + if (asprintf (&optstr, "OPTION ttyname=%s", dft_ttyname) < 0) + { + err = gpg_error_from_errno (errno); + goto leave; + } + err = assuan_transact (gpgsm->assuan_ctx, optstr, NULL, NULL, NULL, + NULL, NULL, NULL); + free (optstr); + if (err) + { + err = map_assuan_error (err); + goto leave; + } + + err = _gpgme_getenv ("TERM", &dft_ttytype); + if (err) + goto leave; + if (dft_ttytype) + { + if (asprintf (&optstr, "OPTION ttytype=%s", dft_ttytype) < 0) + { + free (dft_ttytype); + err = gpg_error_from_errno (errno); + goto leave; + } + free (dft_ttytype); + + err = assuan_transact (gpgsm->assuan_ctx, optstr, NULL, NULL, NULL, + NULL, NULL, NULL); + free (optstr); + if (err) + { + err = map_assuan_error (err); + goto leave; + } + } + + if (lc_ctype) + { + if (asprintf (&optstr, "OPTION lc-ctype=%s", lc_ctype) < 0) + err = gpg_error_from_errno (errno); + else + { + err = assuan_transact (gpgsm->assuan_ctx, optstr, NULL, NULL, + NULL, NULL, NULL, NULL); + free (optstr); + if (err) + err = map_assuan_error (err); + } + } + if (err) + goto leave; + + if (lc_messages) + { + if (asprintf (&optstr, "OPTION lc-messages=%s", lc_messages) < 0) + err = gpg_error_from_errno (errno); + else + { + err = assuan_transact (gpgsm->assuan_ctx, optstr, NULL, NULL, + NULL, NULL, NULL, NULL); + free (optstr); + if (err) + err = map_assuan_error (err); + } + } + if (err) + goto leave; + } + + if (!err + && (_gpgme_io_set_close_notify (gpgsm->status_cb.fd, + close_notify_handler, gpgsm) + || _gpgme_io_set_close_notify (gpgsm->input_cb.fd, + close_notify_handler, gpgsm) + || _gpgme_io_set_close_notify (gpgsm->output_cb.fd, + close_notify_handler, gpgsm) + || _gpgme_io_set_close_notify (gpgsm->message_cb.fd, + close_notify_handler, gpgsm))) + { + err = gpg_error (GPG_ERR_GENERAL); + goto leave; + } + + leave: + /* Close the server ends of the pipes. Our ends are closed in + gpgsm_release(). */ + if (gpgsm->input_fd_server != -1) + _gpgme_io_close (gpgsm->input_fd_server); + if (gpgsm->output_fd_server != -1) + _gpgme_io_close (gpgsm->output_fd_server); + if (gpgsm->message_fd_server != -1) + _gpgme_io_close (gpgsm->message_fd_server); + + if (err) + gpgsm_release (gpgsm); + else + *engine = gpgsm; + + return err; +} + + +/* Forward declaration. */ +static gpgme_status_code_t parse_status (const char *name); + +static gpgme_error_t +gpgsm_assuan_simple_command (ASSUAN_CONTEXT ctx, char *cmd, + engine_status_handler_t status_fnc, + void *status_fnc_value) +{ + AssuanError err; + char *line; + size_t linelen; + + err = assuan_write_line (ctx, cmd); + if (err) + return map_assuan_error (err); + + do + { + err = assuan_read_line (ctx, &line, &linelen); + if (err) + return map_assuan_error (err); + + if (*line == '#' || !linelen) + continue; + + if (linelen >= 2 + && line[0] == 'O' && line[1] == 'K' + && (line[2] == '\0' || line[2] == ' ')) + return 0; + else if (linelen >= 4 + && line[0] == 'E' && line[1] == 'R' && line[2] == 'R' + && line[3] == ' ') + err = map_assuan_error (atoi (&line[4])); + else if (linelen >= 2 + && line[0] == 'S' && line[1] == ' ') + { + char *rest; + gpgme_status_code_t r; + + rest = strchr (line + 2, ' '); + if (!rest) + rest = line + linelen; /* set to an empty string */ + else + *(rest++) = 0; + + r = parse_status (line + 2); + + if (r >= 0 && status_fnc) + err = status_fnc (status_fnc_value, r, rest); + else + err = gpg_error (GPG_ERR_GENERAL); + } + else + err = gpg_error (GPG_ERR_GENERAL); + } + while (!err); + + return err; +} + + +#define COMMANDLINELEN 40 +static gpgme_error_t +gpgsm_set_fd (ASSUAN_CONTEXT ctx, const char *which, int fd, const char *opt) +{ + char line[COMMANDLINELEN]; + + if (opt) + snprintf (line, COMMANDLINELEN, "%s FD=%i %s", which, fd, opt); + else + snprintf (line, COMMANDLINELEN, "%s FD=%i", which, fd); + + return gpgsm_assuan_simple_command (ctx, line, NULL, NULL); +} + + +static const char * +map_input_enc (gpgme_data_t d) +{ + switch (gpgme_data_get_encoding (d)) + { + case GPGME_DATA_ENCODING_NONE: + break; + case GPGME_DATA_ENCODING_BINARY: + return "--binary"; + case GPGME_DATA_ENCODING_BASE64: + return "--base64"; + case GPGME_DATA_ENCODING_ARMOR: + return "--armor"; + default: + break; + } + return NULL; +} + + +static int +status_cmp (const void *ap, const void *bp) +{ + const struct status_table_s *a = ap; + const struct status_table_s *b = bp; + + return strcmp (a->name, b->name); +} + + +static gpgme_status_code_t +parse_status (const char *name) +{ + struct status_table_s t, *r; + t.name = name; + r = bsearch (&t, status_table, DIM(status_table) - 1, + sizeof t, status_cmp); + return r ? r->code : -1; +} + + +static gpgme_error_t +status_handler (void *opaque, int fd) +{ + AssuanError assuan_err; + gpgme_error_t err = 0; + engine_gpgsm_t gpgsm = opaque; + char *line; + size_t linelen; + + do + { + assuan_err = assuan_read_line (gpgsm->assuan_ctx, &line, &linelen); + if (assuan_err) + { + /* Try our best to terminate the connection friendly. */ + /* assuan_write_line (gpgsm->assuan_ctx, "BYE"); */ + err = map_assuan_error (assuan_err); + } + else if (linelen >= 3 + && line[0] == 'E' && line[1] == 'R' && line[2] == 'R' + && (line[3] == '\0' || line[3] == ' ')) + { + if (line[3] == ' ') + err = map_assuan_error (atoi (&line[4])); + else + err = gpg_error (GPG_ERR_GENERAL); + } + else if (linelen >= 2 + && line[0] == 'O' && line[1] == 'K' + && (line[2] == '\0' || line[2] == ' ')) + { + if (gpgsm->status.fnc) + err = gpgsm->status.fnc (gpgsm->status.fnc_value, + GPGME_STATUS_EOF, ""); + + if (!err && gpgsm->colon.fnc && gpgsm->colon.any ) + { + /* We must tell a colon function about the EOF. We do + this only when we have seen any data lines. Note + that this inlined use of colon data lines will + eventually be changed into using a regular data + channel. */ + gpgsm->colon.any = 0; + err = gpgsm->colon.fnc (gpgsm->colon.fnc_value, NULL); + } + _gpgme_io_close (gpgsm->status_cb.fd); + return err; + } + else if (linelen > 2 + && line[0] == 'D' && line[1] == ' ' + && gpgsm->colon.fnc) + { + /* We are using the colon handler even for plain inline data + - strange name for that function but for historic reasons + we keep it. */ + /* FIXME We can't use this for binary data because we + assume this is a string. For the current usage of colon + output it is correct. */ + unsigned char *src = line + 2; + unsigned char *end = line + linelen; + unsigned char *dst; + unsigned char **aline = &gpgsm->colon.attic.line; + int *alinelen = &gpgsm->colon.attic.linelen; + + if (gpgsm->colon.attic.linesize + < *alinelen + linelen + 1) + { + unsigned char *newline = realloc (*aline, + *alinelen + linelen + 1); + if (!newline) + err = gpg_error_from_errno (errno); + else + { + *aline = newline; + gpgsm->colon.attic.linesize += linelen + 1; + } + } + if (!err) + { + dst = *aline + *alinelen; + + while (!err && src < end) + { + if (*src == '%' && src + 2 < end) + { + /* Handle escaped characters. */ + ++src; + *dst = (unsigned char) _gpgme_hextobyte (src); + (*alinelen)++; + src += 2; + } + else + { + *dst = *src++; + (*alinelen)++; + } + + if (*dst == '\n') + { + /* Terminate the pending line, pass it to the colon + handler and reset it. */ + + gpgsm->colon.any = 1; + if (*alinelen > 1 && *(dst - 1) == '\r') + dst--; + *dst = '\0'; + + /* FIXME How should we handle the return code? */ + err = gpgsm->colon.fnc (gpgsm->colon.fnc_value, *aline); + if (!err) + { + dst = *aline; + *alinelen = 0; + } + } + else + dst++; + } + } + } + else if (linelen > 2 + && line[0] == 'S' && line[1] == ' ') + { + char *rest; + gpgme_status_code_t r; + + rest = strchr (line + 2, ' '); + if (!rest) + rest = line + linelen; /* set to an empty string */ + else + *(rest++) = 0; + + r = parse_status (line + 2); + + if (r >= 0) + { + if (gpgsm->status.fnc) + err = gpgsm->status.fnc (gpgsm->status.fnc_value, r, rest); + } + else + fprintf (stderr, "[UNKNOWN STATUS]%s %s", line + 2, rest); + } + } + while (!err && assuan_pending_line (gpgsm->assuan_ctx)); + + return err; +} + + +static gpgme_error_t +add_io_cb (engine_gpgsm_t gpgsm, iocb_data_t *iocbd, gpgme_io_cb_t handler) +{ + gpgme_error_t err; + + err = (*gpgsm->io_cbs.add) (gpgsm->io_cbs.add_priv, + iocbd->fd, iocbd->dir, + handler, iocbd->data, &iocbd->tag); + if (err) + return err; + if (!iocbd->dir) + /* FIXME Kludge around poll() problem. */ + err = _gpgme_io_set_nonblocking (iocbd->fd); + return err; +} + + +static gpgme_error_t +start (engine_gpgsm_t gpgsm, const char *command) +{ + gpgme_error_t err; + + err = add_io_cb (gpgsm, &gpgsm->status_cb, status_handler); + if (!err && gpgsm->input_cb.fd != -1) + err = add_io_cb (gpgsm, &gpgsm->input_cb, _gpgme_data_outbound_handler); + if (!err && gpgsm->output_cb.fd != -1) + err = add_io_cb (gpgsm, &gpgsm->output_cb, _gpgme_data_inbound_handler); + if (!err && gpgsm->message_cb.fd != -1) + err = add_io_cb (gpgsm, &gpgsm->message_cb, _gpgme_data_outbound_handler); + + if (!err) + err = assuan_write_line (gpgsm->assuan_ctx, command); + + if (!err) + (*gpgsm->io_cbs.event) (gpgsm->io_cbs.event_priv, GPGME_EVENT_START, NULL); + + return err; +} + + +static gpgme_error_t +gpgsm_decrypt (void *engine, gpgme_data_t ciph, gpgme_data_t plain) +{ + engine_gpgsm_t gpgsm = engine; + gpgme_error_t err; + + if (!gpgsm) + return gpg_error (GPG_ERR_INV_VALUE); + + gpgsm->input_cb.data = ciph; + err = gpgsm_set_fd (gpgsm->assuan_ctx, "INPUT", gpgsm->input_fd_server, + map_input_enc (gpgsm->input_cb.data)); + if (err) + return gpg_error (GPG_ERR_GENERAL); /* FIXME */ + gpgsm->output_cb.data = plain; + err = gpgsm_set_fd (gpgsm->assuan_ctx, "OUTPUT", gpgsm->output_fd_server, 0); + if (err) + return gpg_error (GPG_ERR_GENERAL); /* FIXME */ + _gpgme_io_close (gpgsm->message_cb.fd); + + err = start (engine, "DECRYPT"); + return err; +} + + +static gpgme_error_t +gpgsm_delete (void *engine, gpgme_key_t key, int allow_secret) +{ + engine_gpgsm_t gpgsm = engine; + gpgme_error_t err; + char *fpr = key->subkeys ? key->subkeys->fpr : NULL; + char *linep = fpr; + char *line; + int length = 8; /* "DELKEYS " */ + + if (!fpr) + return gpg_error (GPG_ERR_INV_VALUE); + + while (*linep) + { + length++; + if (*linep == '%' || *linep == ' ' || *linep == '+') + length += 2; + linep++; + } + length++; + + line = malloc (length); + if (!line) + return gpg_error_from_errno (errno); + + strcpy (line, "DELKEYS "); + linep = &line[8]; + + while (*fpr) + { + switch (*fpr) + { + case '%': + *(linep++) = '%'; + *(linep++) = '2'; + *(linep++) = '5'; + break; + case ' ': + *(linep++) = '%'; + *(linep++) = '2'; + *(linep++) = '0'; + break; + case '+': + *(linep++) = '%'; + *(linep++) = '2'; + *(linep++) = 'B'; + break; + default: + *(linep++) = *fpr; + break; + } + fpr++; + } + *linep = '\0'; + + _gpgme_io_close (gpgsm->output_cb.fd); + _gpgme_io_close (gpgsm->input_cb.fd); + _gpgme_io_close (gpgsm->message_cb.fd); + + err = start (gpgsm, line); + free (line); + + return err; +} + + +static gpgme_error_t +set_recipients (engine_gpgsm_t gpgsm, gpgme_key_t recp[]) +{ + gpgme_error_t err = 0; + ASSUAN_CONTEXT ctx = gpgsm->assuan_ctx; + char *line; + int linelen; + int invalid_recipients = 0; + int i = 0; + + linelen = 10 + 40 + 1; /* "RECIPIENT " + guess + '\0'. */ + line = malloc (10 + 40 + 1); + if (!line) + return gpg_error_from_errno (errno); + strcpy (line, "RECIPIENT "); + while (!err && recp[i]) + { + char *fpr; + int newlen; + + if (!recp[i]->subkeys || !recp[i]->subkeys->fpr) + { + invalid_recipients++; + continue; + } + fpr = recp[i]->subkeys->fpr; + + newlen = 11 + strlen (fpr); + if (linelen < newlen) + { + char *newline = realloc (line, newlen); + if (! newline) + { + int saved_errno = errno; + free (line); + return gpg_error_from_errno (saved_errno); + } + line = newline; + linelen = newlen; + } + strcpy (&line[10], fpr); + + err = gpgsm_assuan_simple_command (ctx, line, gpgsm->status.fnc, + gpgsm->status.fnc_value); + /* FIXME: This requires more work. */ + if (gpg_err_code (err) == GPG_ERR_NO_PUBKEY) + invalid_recipients++; + else if (err) + { + free (line); + return err; + } + i++; + } + free (line); + return gpg_error (invalid_recipients + ? GPG_ERR_UNUSABLE_PUBKEY : GPG_ERR_NO_ERROR); +} + + +static gpgme_error_t +gpgsm_encrypt (void *engine, gpgme_key_t recp[], gpgme_encrypt_flags_t flags, + gpgme_data_t plain, gpgme_data_t ciph, int use_armor) +{ + engine_gpgsm_t gpgsm = engine; + gpgme_error_t err; + + if (!gpgsm) + return gpg_error (GPG_ERR_INV_VALUE); + if (!recp) + return gpg_error (GPG_ERR_NOT_IMPLEMENTED); + + gpgsm->input_cb.data = plain; + err = gpgsm_set_fd (gpgsm->assuan_ctx, "INPUT", gpgsm->input_fd_server, + map_input_enc (gpgsm->input_cb.data)); + if (err) + return err; + gpgsm->output_cb.data = ciph; + err = gpgsm_set_fd (gpgsm->assuan_ctx, "OUTPUT", gpgsm->output_fd_server, + use_armor ? "--armor" : 0); + if (err) + return err; + _gpgme_io_close (gpgsm->message_cb.fd); + + err = set_recipients (gpgsm, recp); + + if (!err) + err = start (gpgsm, "ENCRYPT"); + + return err; +} + + +static gpgme_error_t +gpgsm_export (void *engine, const char *pattern, unsigned int reserved, + gpgme_data_t keydata, int use_armor) +{ + engine_gpgsm_t gpgsm = engine; + gpgme_error_t err = 0; + char *cmd; + + if (!gpgsm || reserved) + return gpg_error (GPG_ERR_INV_VALUE); + + if (!pattern) + pattern = ""; + + cmd = malloc (7 + strlen (pattern) + 1); + if (!cmd) + return gpg_error_from_errno (errno); + strcpy (cmd, "EXPORT "); + strcpy (&cmd[7], pattern); + + gpgsm->output_cb.data = keydata; + err = gpgsm_set_fd (gpgsm->assuan_ctx, "OUTPUT", gpgsm->output_fd_server, + use_armor ? "--armor" : 0); + if (err) + return err; + _gpgme_io_close (gpgsm->input_cb.fd); + _gpgme_io_close (gpgsm->message_cb.fd); + + err = start (gpgsm, cmd); + free (cmd); + return err; +} + + +static gpgme_error_t +gpgsm_export_ext (void *engine, const char *pattern[], unsigned int reserved, + gpgme_data_t keydata, int use_armor) +{ + engine_gpgsm_t gpgsm = engine; + gpgme_error_t err = 0; + char *line; + /* Length is "EXPORT " + p + '\0'. */ + int length = 7 + 1; + char *linep; + + if (!gpgsm || reserved) + return gpg_error (GPG_ERR_INV_VALUE); + + if (pattern && *pattern) + { + const char **pat = pattern; + + while (*pat) + { + const char *patlet = *pat; + + while (*patlet) + { + length++; + if (*patlet == '%' || *patlet == ' ' || *patlet == '+') + length += 2; + patlet++; + } + pat++; + /* This will allocate one byte more than necessary. */ + length++; + } + } + line = malloc (length); + if (!line) + return gpg_error_from_errno (errno); + + strcpy (line, "EXPORT "); + linep = &line[7]; + + if (pattern && *pattern) + { + while (*pattern) + { + const char *patlet = *pattern; + + while (*patlet) + { + switch (*patlet) + { + case '%': + *(linep++) = '%'; + *(linep++) = '2'; + *(linep++) = '5'; + break; + case ' ': + *(linep++) = '%'; + *(linep++) = '2'; + *(linep++) = '0'; + break; + case '+': + *(linep++) = '%'; + *(linep++) = '2'; + *(linep++) = 'B'; + break; + default: + *(linep++) = *patlet; + break; + } + patlet++; + } + pattern++; + } + } + *linep = '\0'; + + gpgsm->output_cb.data = keydata; + err = gpgsm_set_fd (gpgsm->assuan_ctx, "OUTPUT", gpgsm->output_fd_server, + use_armor ? "--armor" : 0); + if (err) + return err; + _gpgme_io_close (gpgsm->input_cb.fd); + _gpgme_io_close (gpgsm->message_cb.fd); + + err = start (gpgsm, line); + free (line); + return err; +} + + +static gpgme_error_t +gpgsm_genkey (void *engine, gpgme_data_t help_data, int use_armor, + gpgme_data_t pubkey, gpgme_data_t seckey) +{ + engine_gpgsm_t gpgsm = engine; + gpgme_error_t err; + + if (!gpgsm || !pubkey || seckey) + return gpg_error (GPG_ERR_INV_VALUE); + + gpgsm->input_cb.data = help_data; + err = gpgsm_set_fd (gpgsm->assuan_ctx, "INPUT", gpgsm->input_fd_server, + map_input_enc (gpgsm->input_cb.data)); + if (err) + return err; + gpgsm->output_cb.data = pubkey; + err = gpgsm_set_fd (gpgsm->assuan_ctx, "OUTPUT", gpgsm->output_fd_server, + use_armor ? "--armor" : 0); + if (err) + return err; + _gpgme_io_close (gpgsm->message_cb.fd); + + err = start (gpgsm, "GENKEY"); + return err; +} + + +static gpgme_error_t +gpgsm_import (void *engine, gpgme_data_t keydata) +{ + engine_gpgsm_t gpgsm = engine; + gpgme_error_t err; + + if (!gpgsm) + return gpg_error (GPG_ERR_INV_VALUE); + + gpgsm->input_cb.data = keydata; + err = gpgsm_set_fd (gpgsm->assuan_ctx, "INPUT", gpgsm->input_fd_server, + map_input_enc (gpgsm->input_cb.data)); + if (err) + return err; + _gpgme_io_close (gpgsm->output_cb.fd); + _gpgme_io_close (gpgsm->message_cb.fd); + + err = start (gpgsm, "IMPORT"); + return err; +} + + +static gpgme_error_t +gpgsm_keylist (void *engine, const char *pattern, int secret_only, + gpgme_keylist_mode_t mode) +{ + engine_gpgsm_t gpgsm = engine; + char *line; + gpgme_error_t err; + int list_mode = 0; + + if (mode & GPGME_KEYLIST_MODE_LOCAL) + list_mode |= 1; + if (mode & GPGME_KEYLIST_MODE_EXTERN) + list_mode |= 2; + + if (!pattern) + pattern = ""; + + if (asprintf (&line, "OPTION list-mode=%d", (list_mode & 3)) < 0) + return gpg_error_from_errno (errno); + err = gpgsm_assuan_simple_command (gpgsm->assuan_ctx, line, NULL, NULL); + free (line); + if (err) + return err; + + /* Length is "LISTSECRETKEYS " + p + '\0'. */ + line = malloc (15 + strlen (pattern) + 1); + if (!line) + return gpg_error_from_errno (errno); + if (secret_only) + { + strcpy (line, "LISTSECRETKEYS "); + strcpy (&line[15], pattern); + } + else + { + strcpy (line, "LISTKEYS "); + strcpy (&line[9], pattern); + } + + _gpgme_io_close (gpgsm->input_cb.fd); + _gpgme_io_close (gpgsm->output_cb.fd); + _gpgme_io_close (gpgsm->message_cb.fd); + + err = start (gpgsm, line); + free (line); + return err; +} + + +static gpgme_error_t +gpgsm_keylist_ext (void *engine, const char *pattern[], int secret_only, + int reserved, gpgme_keylist_mode_t mode) +{ + engine_gpgsm_t gpgsm = engine; + char *line; + gpgme_error_t err; + /* Length is "LISTSECRETKEYS " + p + '\0'. */ + int length = 15 + 1; + char *linep; + int list_mode = 0; + + if (reserved) + return gpg_error (GPG_ERR_INV_VALUE); + + if (mode & GPGME_KEYLIST_MODE_LOCAL) + list_mode |= 1; + if (mode & GPGME_KEYLIST_MODE_EXTERN) + list_mode |= 2; + + if (asprintf (&line, "OPTION list-mode=%d", (list_mode & 3)) < 0) + return gpg_error_from_errno (errno); + err = gpgsm_assuan_simple_command (gpgsm->assuan_ctx, line, NULL, NULL); + free (line); + if (err) + return err; + + if (pattern && *pattern) + { + const char **pat = pattern; + + while (*pat) + { + const char *patlet = *pat; + + while (*patlet) + { + length++; + if (*patlet == '%' || *patlet == ' ' || *patlet == '+') + length += 2; + patlet++; + } + pat++; + /* This will allocate one byte more than necessary. */ + length++; + } + } + line = malloc (length); + if (!line) + return gpg_error_from_errno (errno); + if (secret_only) + { + strcpy (line, "LISTSECRETKEYS "); + linep = &line[15]; + } + else + { + strcpy (line, "LISTKEYS "); + linep = &line[9]; + } + + if (pattern && *pattern) + { + while (*pattern) + { + const char *patlet = *pattern; + + while (*patlet) + { + switch (*patlet) + { + case '%': + *(linep++) = '%'; + *(linep++) = '2'; + *(linep++) = '5'; + break; + case ' ': + *(linep++) = '%'; + *(linep++) = '2'; + *(linep++) = '0'; + break; + case '+': + *(linep++) = '%'; + *(linep++) = '2'; + *(linep++) = 'B'; + break; + default: + *(linep++) = *patlet; + break; + } + patlet++; + } + pattern++; + } + } + *linep = '\0'; + + _gpgme_io_close (gpgsm->input_cb.fd); + _gpgme_io_close (gpgsm->output_cb.fd); + _gpgme_io_close (gpgsm->message_cb.fd); + + err = start (gpgsm, line); + free (line); + return err; +} + + +static gpgme_error_t +gpgsm_sign (void *engine, gpgme_data_t in, gpgme_data_t out, + gpgme_sig_mode_t mode, int use_armor, int use_textmode, + int include_certs, gpgme_ctx_t ctx /* FIXME */) +{ + engine_gpgsm_t gpgsm = engine; + gpgme_error_t err; + char *assuan_cmd; + int i; + gpgme_key_t key; + + if (!gpgsm) + return gpg_error (GPG_ERR_INV_VALUE); + + if (asprintf (&assuan_cmd, "OPTION include-certs %i", include_certs) < 0) + return gpg_error_from_errno (errno); + err = gpgsm_assuan_simple_command (gpgsm->assuan_ctx, assuan_cmd, NULL,NULL); + free (assuan_cmd); + if (err) + return err; + + /* We must do a reset becuase we need to reset the list of signers. Note + that RESET does not reset OPTION commands. */ + err = gpgsm_assuan_simple_command (gpgsm->assuan_ctx, "RESET", NULL, NULL); + if (err) + return err; + + for (i = 0; (key = gpgme_signers_enum (ctx, i)); i++) + { + const char *s = key->subkeys ? key->subkeys->fpr : NULL; + if (s && strlen (s) < 80) + { + char buf[100]; + + strcpy (stpcpy (buf, "SIGNER "), s); + err = gpgsm_assuan_simple_command (gpgsm->assuan_ctx, buf, + NULL, NULL); + } + else + err = gpg_error (GPG_ERR_INV_VALUE); + gpgme_key_unref (key); + if (err) + return err; + } + + gpgsm->input_cb.data = in; + err = gpgsm_set_fd (gpgsm->assuan_ctx, "INPUT", gpgsm->input_fd_server, + map_input_enc (gpgsm->input_cb.data)); + if (err) + return err; + gpgsm->output_cb.data = out; + err = gpgsm_set_fd (gpgsm->assuan_ctx, "OUTPUT", gpgsm->output_fd_server, + use_armor ? "--armor" : 0); + if (err) + return err; + _gpgme_io_close (gpgsm->message_cb.fd); + + err = start (gpgsm, mode == GPGME_SIG_MODE_DETACH + ? "SIGN --detached" : "SIGN"); + return err; +} + + +static gpgme_error_t +gpgsm_verify (void *engine, gpgme_data_t sig, gpgme_data_t signed_text, + gpgme_data_t plaintext) +{ + engine_gpgsm_t gpgsm = engine; + gpgme_error_t err; + + if (!gpgsm) + return gpg_error (GPG_ERR_INV_VALUE); + + gpgsm->input_cb.data = sig; + err = gpgsm_set_fd (gpgsm->assuan_ctx, "INPUT", gpgsm->input_fd_server, + map_input_enc (gpgsm->input_cb.data)); + if (err) + return err; + if (plaintext) + { + /* Normal or cleartext signature. */ + gpgsm->output_cb.data = plaintext; + err = gpgsm_set_fd (gpgsm->assuan_ctx, "OUTPUT", gpgsm->output_fd_server, + 0); + _gpgme_io_close (gpgsm->message_cb.fd); + } + else + { + /* Detached signature. */ + gpgsm->message_cb.data = signed_text; + err = gpgsm_set_fd (gpgsm->assuan_ctx, "MESSAGE", + gpgsm->message_fd_server, 0); + _gpgme_io_close (gpgsm->output_cb.fd); + } + + if (!err) + err = start (gpgsm, "VERIFY"); + + return err; +} + + +static void +gpgsm_set_status_handler (void *engine, engine_status_handler_t fnc, + void *fnc_value) +{ + engine_gpgsm_t gpgsm = engine; + + gpgsm->status.fnc = fnc; + gpgsm->status.fnc_value = fnc_value; +} + + +static gpgme_error_t +gpgsm_set_colon_line_handler (void *engine, engine_colon_line_handler_t fnc, + void *fnc_value) +{ + engine_gpgsm_t gpgsm = engine; + + gpgsm->colon.fnc = fnc; + gpgsm->colon.fnc_value = fnc_value; + gpgsm->colon.any = 0; + return 0; +} + + +static void +gpgsm_set_io_cbs (void *engine, gpgme_io_cbs_t io_cbs) +{ + engine_gpgsm_t gpgsm = engine; + gpgsm->io_cbs = *io_cbs; +} + + +static void +gpgsm_io_event (void *engine, gpgme_event_io_t type, void *type_data) +{ + engine_gpgsm_t gpgsm = engine; + + if (gpgsm->io_cbs.event) + (*gpgsm->io_cbs.event) (gpgsm->io_cbs.event_priv, type, type_data); +} + + +struct engine_ops _gpgme_engine_ops_gpgsm = + { + /* Static functions. */ + _gpgme_get_gpgsm_path, + gpgsm_get_version, + gpgsm_get_req_version, + gpgsm_new, + + /* Member functions. */ + gpgsm_release, + gpgsm_set_status_handler, + NULL, /* set_command_handler */ + gpgsm_set_colon_line_handler, + gpgsm_decrypt, + gpgsm_delete, + NULL, /* edit */ + gpgsm_encrypt, + NULL, /* encrypt_sign */ + gpgsm_export, + gpgsm_export_ext, + gpgsm_genkey, + gpgsm_import, + gpgsm_keylist, + gpgsm_keylist_ext, + gpgsm_sign, + NULL, /* trustlist */ + gpgsm_verify, + gpgsm_set_io_cbs, + gpgsm_io_event + }; diff --git a/tags/gpgme-0-4-3/gpgme/engine.c b/tags/gpgme-0-4-3/gpgme/engine.c new file mode 100644 index 0000000..4c52599 --- /dev/null +++ b/tags/gpgme-0-4-3/gpgme/engine.c @@ -0,0 +1,486 @@ +/* engine.c - GPGME engine support. + Copyright (C) 2000 Werner Koch (dd9jn) + Copyright (C) 2001, 2002, 2003 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 + 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. */ + +#ifdef HAVE_CONFIG_H +#include +#endif +#include +#include +#include + +#include "gpgme.h" +#include "util.h" +#include "sema.h" +#include "ops.h" + +#include "engine.h" +#include "engine-backend.h" + + +struct engine +{ + struct engine_ops *ops; + void *engine; +}; + + +static struct engine_ops *engine_ops[] = + { + &_gpgme_engine_ops_gpg, /* OpenPGP. */ +#ifdef ENABLE_GPGSM + &_gpgme_engine_ops_gpgsm /* CMS. */ +#else + NULL +#endif + }; + + +/* Get the file name of the engine for PROTOCOL. */ +static const char * +engine_get_file_name (gpgme_protocol_t proto) +{ + if (proto > DIM (engine_ops)) + return NULL; + + if (engine_ops[proto] && engine_ops[proto]->get_file_name) + return (*engine_ops[proto]->get_file_name) (); + else + return NULL; +} + + +/* Get the version number of the engine for PROTOCOL. */ +static const char * +engine_get_version (gpgme_protocol_t proto) +{ + if (proto > DIM (engine_ops)) + return NULL; + + if (engine_ops[proto] && engine_ops[proto]->get_version) + return (*engine_ops[proto]->get_version) (); + else + return NULL; +} + + +/* Get the required version number of the engine for PROTOCOL. */ +static const char * +engine_get_req_version (gpgme_protocol_t proto) +{ + if (proto > DIM (engine_ops)) + return NULL; + + if (engine_ops[proto] && engine_ops[proto]->get_req_version) + return (*engine_ops[proto]->get_req_version) (); + else + return NULL; +} + + +/* Verify the version requirement for the engine for PROTOCOL. */ +gpgme_error_t +gpgme_engine_check_version (gpgme_protocol_t proto) +{ + return _gpgme_compare_versions (engine_get_version (proto), + engine_get_req_version (proto)) + ? 0 : gpg_error (GPG_ERR_INV_ENGINE); +} + + +/* Get the information about the configured and installed engines. A + pointer to the first engine in the statically allocated linked list + is returned in *INFO. If an error occurs, it is returned. */ +gpgme_error_t +gpgme_get_engine_info (gpgme_engine_info_t *info) +{ + static gpgme_engine_info_t engine_info; + DEFINE_STATIC_LOCK (engine_info_lock); + + LOCK (engine_info_lock); + if (!engine_info) + { + gpgme_engine_info_t *lastp = &engine_info; + gpgme_protocol_t proto_list[] = { GPGME_PROTOCOL_OpenPGP, + GPGME_PROTOCOL_CMS }; + unsigned int proto; + + for (proto = 0; proto < DIM (proto_list); proto++) + { + const char *file_name = engine_get_file_name (proto_list[proto]); + + if (!file_name) + continue; + + *lastp = malloc (sizeof (*engine_info)); + if (!*lastp) + { + int saved_errno = errno; + + while (engine_info) + { + gpgme_engine_info_t next_info = engine_info->next; + free (engine_info); + engine_info = next_info; + } + UNLOCK (engine_info_lock); + return gpg_error_from_errno (saved_errno); + } + + (*lastp)->protocol = proto_list[proto]; + (*lastp)->file_name = file_name; + (*lastp)->version = engine_get_version (proto_list[proto]); + (*lastp)->req_version = engine_get_req_version (proto_list[proto]); + (*lastp)->next = NULL; + lastp = &(*lastp)->next; + } + } + UNLOCK (engine_info_lock); + *info = engine_info; + return 0; +} + + +gpgme_error_t +_gpgme_engine_new (gpgme_protocol_t proto, engine_t *r_engine, + const char *lc_ctype, const char *lc_messages) +{ + engine_t engine; + + const char *file_name; + const char *version; + + if (proto > DIM (engine_ops)) + return gpg_error (GPG_ERR_INV_VALUE); + + if (!engine_ops[proto]) + return gpg_error (GPG_ERR_INV_ENGINE); + + file_name = engine_get_file_name (proto); + version = engine_get_version (proto); + if (!file_name || !version) + return gpg_error (GPG_ERR_INV_ENGINE); + + engine = calloc (1, sizeof *engine); + if (!engine) + return gpg_error_from_errno (errno); + + engine->ops = engine_ops[proto]; + if (engine_ops[proto]->new) + { + gpgme_error_t err = (*engine_ops[proto]->new) (&engine->engine, + lc_ctype, + lc_messages); + if (err) + { + free (engine); + return err; + } + } + else + engine->engine = NULL; + + *r_engine = engine; + return 0; +} + + +void +_gpgme_engine_release (engine_t engine) +{ + if (!engine) + return; + + if (engine->ops->release) + (*engine->ops->release) (engine->engine); + free (engine); +} + + +void +_gpgme_engine_set_status_handler (engine_t engine, + engine_status_handler_t fnc, void *fnc_value) +{ + if (!engine) + return; + + if (engine->ops->set_status_handler) + (*engine->ops->set_status_handler) (engine->engine, fnc, fnc_value); +} + + +gpgme_error_t +_gpgme_engine_set_command_handler (engine_t engine, + engine_command_handler_t fnc, + void *fnc_value, + gpgme_data_t linked_data) +{ + if (!engine) + return gpg_error (GPG_ERR_INV_VALUE); + + if (!engine->ops->set_command_handler) + return gpg_error (GPG_ERR_NOT_IMPLEMENTED); + + return (*engine->ops->set_command_handler) (engine->engine, + fnc, fnc_value, linked_data); +} + +gpgme_error_t +_gpgme_engine_set_colon_line_handler (engine_t engine, + engine_colon_line_handler_t fnc, + void *fnc_value) +{ + if (!engine) + return gpg_error (GPG_ERR_INV_VALUE); + + if (!engine->ops->set_colon_line_handler) + return gpg_error (GPG_ERR_NOT_IMPLEMENTED); + + return (*engine->ops->set_colon_line_handler) (engine->engine, + fnc, fnc_value); +} + +gpgme_error_t +_gpgme_engine_op_decrypt (engine_t engine, gpgme_data_t ciph, + gpgme_data_t plain) +{ + if (!engine) + return gpg_error (GPG_ERR_INV_VALUE); + + if (!engine->ops->decrypt) + return gpg_error (GPG_ERR_NOT_IMPLEMENTED); + + return (*engine->ops->decrypt) (engine->engine, ciph, plain); +} + +gpgme_error_t +_gpgme_engine_op_delete (engine_t engine, gpgme_key_t key, + int allow_secret) +{ + if (!engine) + return gpg_error (GPG_ERR_INV_VALUE); + + if (!engine->ops->delete) + return gpg_error (GPG_ERR_NOT_IMPLEMENTED); + + return (*engine->ops->delete) (engine->engine, key, allow_secret); +} + + +gpgme_error_t +_gpgme_engine_op_edit (engine_t engine, int type, gpgme_key_t key, + gpgme_data_t out, gpgme_ctx_t ctx /* FIXME */) +{ + if (!engine) + return gpg_error (GPG_ERR_INV_VALUE); + + if (!engine->ops->edit) + return gpg_error (GPG_ERR_NOT_IMPLEMENTED); + + return (*engine->ops->edit) (engine->engine, type, key, out, ctx); +} + + +gpgme_error_t +_gpgme_engine_op_encrypt (engine_t engine, gpgme_key_t recp[], + gpgme_encrypt_flags_t flags, + gpgme_data_t plain, gpgme_data_t ciph, int use_armor) +{ + if (!engine) + return gpg_error (GPG_ERR_INV_VALUE); + + if (!engine->ops->encrypt) + return gpg_error (GPG_ERR_NOT_IMPLEMENTED); + + return (*engine->ops->encrypt) (engine->engine, recp, flags, plain, ciph, + use_armor); +} + + +gpgme_error_t +_gpgme_engine_op_encrypt_sign (engine_t engine, gpgme_key_t recp[], + gpgme_encrypt_flags_t flags, + gpgme_data_t plain, gpgme_data_t ciph, + int use_armor, gpgme_ctx_t ctx /* FIXME */) +{ + if (!engine) + return gpg_error (GPG_ERR_INV_VALUE); + + if (!engine->ops->encrypt_sign) + return gpg_error (GPG_ERR_NOT_IMPLEMENTED); + + return (*engine->ops->encrypt_sign) (engine->engine, recp, flags, + plain, ciph, use_armor, ctx); +} + + +gpgme_error_t +_gpgme_engine_op_export (engine_t engine, const char *pattern, + unsigned int reserved, gpgme_data_t keydata, + int use_armor) +{ + if (!engine) + return gpg_error (GPG_ERR_INV_VALUE); + + if (!engine->ops->export) + return gpg_error (GPG_ERR_NOT_IMPLEMENTED); + + return (*engine->ops->export) (engine->engine, pattern, reserved, + keydata, use_armor); +} + + +gpgme_error_t +_gpgme_engine_op_export_ext (engine_t engine, const char *pattern[], + unsigned int reserved, gpgme_data_t keydata, + int use_armor) +{ + if (!engine) + return gpg_error (GPG_ERR_INV_VALUE); + + if (!engine->ops->export_ext) + return gpg_error (GPG_ERR_NOT_IMPLEMENTED); + + return (*engine->ops->export_ext) (engine->engine, pattern, reserved, + keydata, use_armor); +} + + +gpgme_error_t +_gpgme_engine_op_genkey (engine_t engine, gpgme_data_t help_data, + int use_armor, gpgme_data_t pubkey, + gpgme_data_t seckey) +{ + if (!engine) + return gpg_error (GPG_ERR_INV_VALUE); + + if (!engine->ops->genkey) + return gpg_error (GPG_ERR_NOT_IMPLEMENTED); + + return (*engine->ops->genkey) (engine->engine, help_data, use_armor, + pubkey, seckey); +} + + +gpgme_error_t +_gpgme_engine_op_import (engine_t engine, gpgme_data_t keydata) +{ + if (!engine) + return gpg_error (GPG_ERR_INV_VALUE); + + if (!engine->ops->import) + return gpg_error (GPG_ERR_NOT_IMPLEMENTED); + + return (*engine->ops->import) (engine->engine, keydata); +} + + +gpgme_error_t +_gpgme_engine_op_keylist (engine_t engine, const char *pattern, + int secret_only, gpgme_keylist_mode_t mode) +{ + if (!engine) + return gpg_error (GPG_ERR_INV_VALUE); + + if (!engine->ops->keylist) + return gpg_error (GPG_ERR_NOT_IMPLEMENTED); + + return (*engine->ops->keylist) (engine->engine, pattern, secret_only, mode); +} + + +gpgme_error_t +_gpgme_engine_op_keylist_ext (engine_t engine, const char *pattern[], + int secret_only, int reserved, + gpgme_keylist_mode_t mode) +{ + if (!engine) + return gpg_error (GPG_ERR_INV_VALUE); + + if (!engine->ops->keylist_ext) + return gpg_error (GPG_ERR_NOT_IMPLEMENTED); + + return (*engine->ops->keylist_ext) (engine->engine, pattern, secret_only, + reserved, mode); +} + + +gpgme_error_t +_gpgme_engine_op_sign (engine_t engine, gpgme_data_t in, gpgme_data_t out, + gpgme_sig_mode_t mode, int use_armor, + int use_textmode, int include_certs, + gpgme_ctx_t ctx /* FIXME */) +{ + if (!engine) + return gpg_error (GPG_ERR_INV_VALUE); + + if (!engine->ops->sign) + return gpg_error (GPG_ERR_NOT_IMPLEMENTED); + + return (*engine->ops->sign) (engine->engine, in, out, mode, use_armor, + use_textmode, include_certs, ctx); +} + + +gpgme_error_t +_gpgme_engine_op_trustlist (engine_t engine, const char *pattern) +{ + if (!engine) + return gpg_error (GPG_ERR_INV_VALUE); + + if (!engine->ops->trustlist) + return gpg_error (GPG_ERR_NOT_IMPLEMENTED); + + return (*engine->ops->trustlist) (engine->engine, pattern); +} + + +gpgme_error_t +_gpgme_engine_op_verify (engine_t engine, gpgme_data_t sig, + gpgme_data_t signed_text, gpgme_data_t plaintext) +{ + if (!engine) + return gpg_error (GPG_ERR_INV_VALUE); + + if (!engine->ops->verify) + return gpg_error (GPG_ERR_NOT_IMPLEMENTED); + + return (*engine->ops->verify) (engine->engine, sig, signed_text, plaintext); +} + + +void +_gpgme_engine_set_io_cbs (engine_t engine, gpgme_io_cbs_t io_cbs) +{ + if (!engine) + return; + + (*engine->ops->set_io_cbs) (engine->engine, io_cbs); +} + + +void +_gpgme_engine_io_event (engine_t engine, + gpgme_event_io_t type, void *type_data) +{ + if (!engine) + return; + + (*engine->ops->io_event) (engine->engine, type, type_data); +} diff --git a/tags/gpgme-0-4-3/gpgme/engine.h b/tags/gpgme-0-4-3/gpgme/engine.h new file mode 100644 index 0000000..d3a5403 --- /dev/null +++ b/tags/gpgme-0-4-3/gpgme/engine.h @@ -0,0 +1,113 @@ +/* engine.h - GPGME engine interface. + Copyright (C) 2000 Werner Koch (dd9jn) + Copyright (C) 2001, 2002, 2003 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 + 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. */ + +#ifndef ENGINE_H +#define ENGINE_H + +#include "gpgme.h" + +struct engine; +typedef struct engine *engine_t; + +typedef gpgme_error_t (*engine_status_handler_t) (void *priv, + gpgme_status_code_t code, + char *args); +typedef gpgme_error_t (*engine_colon_line_handler_t) (void *priv, char *line); +typedef gpgme_error_t (*engine_command_handler_t) (void *priv, + gpgme_status_code_t code, + const char *keyword, + int fd); + +gpgme_error_t _gpgme_engine_new (gpgme_protocol_t proto, + engine_t *r_engine, + const char *lc_ctype, + const char *lc_messages); +void _gpgme_engine_release (engine_t engine); +void _gpgme_engine_set_status_handler (engine_t engine, + engine_status_handler_t fnc, + void *fnc_value); +gpgme_error_t _gpgme_engine_set_command_handler (engine_t engine, + engine_command_handler_t fnc, + void *fnc_value, + gpgme_data_t data); +gpgme_error_t +_gpgme_engine_set_colon_line_handler (engine_t engine, + engine_colon_line_handler_t fnc, + void *fnc_value); +gpgme_error_t _gpgme_engine_op_decrypt (engine_t engine, + gpgme_data_t ciph, + gpgme_data_t plain); +gpgme_error_t _gpgme_engine_op_delete (engine_t engine, gpgme_key_t key, + int allow_secret); +gpgme_error_t _gpgme_engine_op_edit (engine_t engine, int type, + gpgme_key_t key, gpgme_data_t out, + gpgme_ctx_t ctx /* FIXME */); +gpgme_error_t _gpgme_engine_op_encrypt (engine_t engine, + gpgme_key_t recp[], + gpgme_encrypt_flags_t flags, + gpgme_data_t plain, gpgme_data_t ciph, + int use_armor); +gpgme_error_t _gpgme_engine_op_encrypt_sign (engine_t engine, + gpgme_key_t recp[], + gpgme_encrypt_flags_t flags, + gpgme_data_t plain, + gpgme_data_t ciph, + int use_armor, + gpgme_ctx_t ctx /* FIXME */); +gpgme_error_t _gpgme_engine_op_export (engine_t engine, const char *pattern, + unsigned int reserved, + gpgme_data_t keydata, int use_armor); +gpgme_error_t _gpgme_engine_op_export_ext (engine_t engine, + const char *pattern[], + unsigned int reserved, + gpgme_data_t keydata, + int use_armor); +gpgme_error_t _gpgme_engine_op_genkey (engine_t engine, + gpgme_data_t help_data, + int use_armor, gpgme_data_t pubkey, + gpgme_data_t seckey); +gpgme_error_t _gpgme_engine_op_import (engine_t engine, + gpgme_data_t keydata); +gpgme_error_t _gpgme_engine_op_keylist (engine_t engine, + const char *pattern, + int secret_only, + gpgme_keylist_mode_t mode); +gpgme_error_t _gpgme_engine_op_keylist_ext (engine_t engine, + const char *pattern[], + int secret_only, + int reserved, + gpgme_keylist_mode_t mode); +gpgme_error_t _gpgme_engine_op_sign (engine_t engine, gpgme_data_t in, + gpgme_data_t out, gpgme_sig_mode_t mode, + int use_armor, int use_textmode, + int include_certs, + gpgme_ctx_t ctx /* FIXME */); +gpgme_error_t _gpgme_engine_op_trustlist (engine_t engine, + const char *pattern); +gpgme_error_t _gpgme_engine_op_verify (engine_t engine, gpgme_data_t sig, + gpgme_data_t signed_text, + gpgme_data_t plaintext); + +void _gpgme_engine_set_io_cbs (engine_t engine, + gpgme_io_cbs_t io_cbs); +void _gpgme_engine_io_event (engine_t engine, + gpgme_event_io_t type, void *type_data); + +#endif /* ENGINE_H */ diff --git a/tags/gpgme-0-4-3/gpgme/error.c b/tags/gpgme-0-4-3/gpgme/error.c new file mode 100644 index 0000000..b17bb09 --- /dev/null +++ b/tags/gpgme-0-4-3/gpgme/error.c @@ -0,0 +1,91 @@ +/* error.c - Error handling for GPGME. + Copyright (C) 2003 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 + 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. */ + +#if HAVE_CONFIG_H +#include +#endif + +#include + +/* Return a pointer to a string containing a description of the error + code in the error value ERR. */ +const char * +gpgme_strerror (gpgme_error_t err) +{ + return gpg_strerror (err); +} + + +/* Return the error string for ERR in the user-supplied buffer BUF of + size BUFLEN. This function is, in contrast to gpg_strerror, + thread-safe if a thread-safe strerror_r() function is provided by + the system. If the function succeeds, 0 is returned and BUF + contains the string describing the error. If the buffer was not + large enough, ERANGE is returned and BUF contains as much of the + beginning of the error string as fits into the buffer. */ +int +gpgme_strerror_r (gpg_error_t err, char *buf, size_t buflen) +{ + return gpg_strerror_r (err, buf, buflen); +} + + +/* Return a pointer to a string containing a description of the error + source in the error value ERR. */ +const char * +gpgme_strsource (gpgme_error_t err) +{ + return gpg_strsource (err); +} + + +/* Retrieve the error code for the system error ERR. This returns + GPG_ERR_UNKNOWN_ERRNO if the system error is not mapped (report + this). */ +gpgme_err_code_t +gpgme_err_code_from_errno (int err) +{ + return gpg_err_code_from_errno (err); +} + + +/* Retrieve the system error for the error code CODE. This returns 0 + if CODE is not a system error code. */ +int +gpgme_err_code_to_errno (gpgme_err_code_t code) +{ + return gpg_err_code_from_errno (code); +} + + +/* Return an error value with the error source SOURCE and the system + error ERR. */ +gpgme_error_t +gpgme_err_make_from_errno (gpg_err_source_t source, int err) +{ + return gpg_err_make_from_errno (source, err); +} + + +/* Return an error value with the system error ERR. */ +gpgme_err_code_t +gpgme_error_from_errno (int err) +{ + return gpgme_error (gpg_err_code_from_errno (err)); +} diff --git a/tags/gpgme-0-4-3/gpgme/export.c b/tags/gpgme-0-4-3/gpgme/export.c new file mode 100644 index 0000000..59c6896 --- /dev/null +++ b/tags/gpgme-0-4-3/gpgme/export.c @@ -0,0 +1,116 @@ +/* export.c - Export a key. + Copyright (C) 2000 Werner Koch (dd9jn) + Copyright (C) 2001, 2002, 2003 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 + 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. */ + +#if HAVE_CONFIG_H +#include +#endif + +#include "gpgme.h" +#include "context.h" +#include "ops.h" + + +static gpgme_error_t +export_status_handler (void *priv, gpgme_status_code_t code, char *args) +{ + return 0; +} + + +static gpgme_error_t +export_start (gpgme_ctx_t ctx, int synchronous, const char *pattern, + unsigned int reserved, gpgme_data_t keydata) +{ + gpgme_error_t err; + + if (!keydata) + return gpg_error (GPG_ERR_INV_VALUE); + + err = _gpgme_op_reset (ctx, synchronous); + if (err) + return err; + + _gpgme_engine_set_status_handler (ctx->engine, export_status_handler, ctx); + + return _gpgme_engine_op_export (ctx->engine, pattern, reserved, keydata, + ctx->use_armor); +} + + +/* Export the keys listed in RECP into KEYDATA. */ +gpgme_error_t +gpgme_op_export_start (gpgme_ctx_t ctx, const char *pattern, + unsigned int reserved, gpgme_data_t keydata) +{ + return export_start (ctx, 0, pattern, reserved, keydata); +} + + +/* Export the keys listed in RECP into KEYDATA. */ +gpgme_error_t +gpgme_op_export (gpgme_ctx_t ctx, const char *pattern, unsigned int reserved, + gpgme_data_t keydata) +{ + gpgme_error_t err = export_start (ctx, 1, pattern, reserved, keydata); + if (!err) + err = _gpgme_wait_one (ctx); + return err; +} + + +static gpgme_error_t +export_ext_start (gpgme_ctx_t ctx, int synchronous, const char *pattern[], + unsigned int reserved, gpgme_data_t keydata) +{ + gpgme_error_t err; + + if (!keydata) + return gpg_error (GPG_ERR_INV_VALUE); + + err = _gpgme_op_reset (ctx, synchronous); + if (err) + return err; + + _gpgme_engine_set_status_handler (ctx->engine, export_status_handler, ctx); + + return _gpgme_engine_op_export_ext (ctx->engine, pattern, reserved, keydata, + ctx->use_armor); +} + + +/* Export the keys listed in RECP into KEYDATA. */ +gpgme_error_t +gpgme_op_export_ext_start (gpgme_ctx_t ctx, const char *pattern[], + unsigned int reserved, gpgme_data_t keydata) +{ + return export_ext_start (ctx, 0, pattern, reserved, keydata); +} + + +/* Export the keys listed in RECP into KEYDATA. */ +gpgme_error_t +gpgme_op_export_ext (gpgme_ctx_t ctx, const char *pattern[], + unsigned int reserved, gpgme_data_t keydata) +{ + gpgme_error_t err = export_ext_start (ctx, 1, pattern, reserved, keydata); + if (!err) + err = _gpgme_wait_one (ctx); + return err; +} diff --git a/tags/gpgme-0-4-3/gpgme/funopen.c b/tags/gpgme-0-4-3/gpgme/funopen.c new file mode 100644 index 0000000..e768b05 --- /dev/null +++ b/tags/gpgme-0-4-3/gpgme/funopen.c @@ -0,0 +1,44 @@ +/* funopen.c - Replacement for funopen. + * Copyright (C) 2003 Free Software Foundation, Inc. + * + * This file is part of GnuPG. + * + * GnuPG 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. + * + * GnuPG 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA + */ + +#ifdef HAVE_CONFIG_H +#include +#endif + +#include + +#ifdef HAVE_FOPENCOOKIE +FILE * +funopen(const void *cookie, cookie_read_function_t *readfn, + cookie_write_function_t *writefn, + cookie_seek_function_t *seekfn, + cookie_close_function_t *closefn) +{ + cookie_io_functions_t io = { read: readfn, write: writefn, + seek: seekfn, + close: closefn }; + + return fopencookie ((void *) cookie, + readfn ? ( writefn ? "rw" : "r" ) + : ( writefn ? "w" : ""), io); +} +#else +#error No known way to implement funopen. +#endif diff --git a/tags/gpgme-0-4-3/gpgme/genkey.c b/tags/gpgme-0-4-3/gpgme/genkey.c new file mode 100644 index 0000000..9353213 --- /dev/null +++ b/tags/gpgme-0-4-3/gpgme/genkey.c @@ -0,0 +1,204 @@ +/* genkey.c - Key generation. + Copyright (C) 2000 Werner Koch (dd9jn) + Copyright (C) 2001, 2002, 2003 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 + 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. */ + +#if HAVE_CONFIG_H +#include +#endif +#include +#include +#include + +#include "gpgme.h" +#include "context.h" +#include "ops.h" + + +typedef struct +{ + struct _gpgme_op_genkey_result result; + + /* The key parameters passed to the crypto engine. */ + gpgme_data_t key_parameter; +} *op_data_t; + + +static void +release_op_data (void *hook) +{ + op_data_t opd = (op_data_t) hook; + + if (opd->result.fpr) + free (opd->result.fpr); + if (opd->key_parameter) + gpgme_data_release (opd->key_parameter); +} + + +gpgme_genkey_result_t +gpgme_op_genkey_result (gpgme_ctx_t ctx) +{ + void *hook; + op_data_t opd; + gpgme_error_t err; + + err = _gpgme_op_data_lookup (ctx, OPDATA_GENKEY, &hook, -1, NULL); + opd = hook; + if (err || !opd) + return NULL; + + return &opd->result; +} + + +static gpgme_error_t +genkey_status_handler (void *priv, gpgme_status_code_t code, char *args) +{ + gpgme_ctx_t ctx = (gpgme_ctx_t) priv; + gpgme_error_t err; + void *hook; + op_data_t opd; + + /* Pipe the status code through the progress status handler. */ + err = _gpgme_progress_status_handler (ctx, code, args); + if (err) + return err; + + err = _gpgme_op_data_lookup (ctx, OPDATA_GENKEY, &hook, -1, NULL); + opd = hook; + if (err) + return err; + + switch (code) + { + case GPGME_STATUS_KEY_CREATED: + if (args && *args) + { + if (*args == 'B' || *args == 'P') + opd->result.primary = 1; + if (*args == 'B' || *args == 'S') + opd->result.sub = 1; + if (args[1] == ' ') + { + if (opd->result.fpr) + free (opd->result.fpr); + opd->result.fpr = strdup (&args[2]); + if (!opd->result.fpr) + return gpg_error_from_errno (errno); + } + } + break; + + case GPGME_STATUS_EOF: + /* FIXME: Should return some more useful error value. */ + if (!opd->result.primary && !opd->result.sub) + return gpg_error (GPG_ERR_GENERAL); + break; + + default: + break; + } + return 0; +} + + +static gpgme_error_t +get_key_parameter (const char *parms, gpgme_data_t *key_parameter) +{ + const char *content; + const char *attrib; + const char *endtag; + + /* Extract the key parameter from the XML structure. */ + parms = strstr (parms, "'); + if (!content) + return gpg_error (GPG_ERR_INV_VALUE); + content++; + + attrib = strstr (parms, "format=\"internal\""); + if (!attrib || attrib >= content) + return gpg_error (GPG_ERR_INV_VALUE); + + endtag = strstr (content, ""); + /* FIXME: Check that there are no control statements inside. */ + while (*content == '\n') + content++; + + return gpgme_data_new_from_mem (key_parameter, content, + endtag - content, 0); +} + + +static gpgme_error_t +genkey_start (gpgme_ctx_t ctx, int synchronous, const char *parms, + gpgme_data_t pubkey, gpgme_data_t seckey) +{ + gpgme_error_t err; + void *hook; + op_data_t opd; + err = _gpgme_op_reset (ctx, synchronous); + if (err) + return err; + + err = _gpgme_op_data_lookup (ctx, OPDATA_GENKEY, &hook, + sizeof (*opd), release_op_data); + opd = hook; + if (err) + return err; + + err = get_key_parameter (parms, &opd->key_parameter); + if (err) + return err; + + _gpgme_engine_set_status_handler (ctx->engine, genkey_status_handler, ctx); + + return _gpgme_engine_op_genkey (ctx->engine, opd->key_parameter, + ctx->use_armor, pubkey, seckey); +} + + +/* Generate a new keypair and add it to the keyring. PUBKEY and + SECKEY should be null for now. PARMS specifies what keys should be + generated. */ +gpgme_error_t +gpgme_op_genkey_start (gpgme_ctx_t ctx, const char *parms, + gpgme_data_t pubkey, gpgme_data_t seckey) +{ + return genkey_start (ctx, 0, parms, pubkey, seckey); +} + + +/* Generate a new keypair and add it to the keyring. PUBKEY and + SECKEY should be null for now. PARMS specifies what keys should be + generated. */ +gpgme_error_t +gpgme_op_genkey (gpgme_ctx_t ctx, const char *parms, gpgme_data_t pubkey, + gpgme_data_t seckey) +{ + gpgme_error_t err; + + err = genkey_start (ctx, 1, parms, pubkey, seckey); + if (!err) + err = _gpgme_wait_one (ctx); + return err; +} diff --git a/tags/gpgme-0-4-3/gpgme/get-env.c b/tags/gpgme-0-4-3/gpgme/get-env.c new file mode 100644 index 0000000..577498f --- /dev/null +++ b/tags/gpgme-0-4-3/gpgme/get-env.c @@ -0,0 +1,58 @@ +/* get_env.c - A getenv() replacement. + Copyright (C) 2003 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 + 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. */ + +#if HAVE_CONFIG_H +#include +#endif +#include +#include +#include + +#include "util.h" + + +#if defined(HAVE_THREAD_SAFE_GETENV) || !defined (HAVE_GETENV_R) +/* We prefer using getenv() if it is thread-safe. */ + +/* Retrieve the environment variable NAME and return a copy of it in a + malloc()'ed buffer in *VALUE. If the environment variable is not + set, return NULL in *VALUE. */ +gpgme_error_t +_gpgme_getenv (const char *name, char **value) +{ + char *env_value; + + env_value = getenv (name); + if (!env_value) + *value = NULL; + else + { + *value = strdup (env_value); + if (!*value) + return gpg_error_from_errno (errno); + } + return 0; +} + +#else + +/* FIXME: Implement this when we have the specification for it. */ +#error Use of getenv_r not implemented. + +#endif diff --git a/tags/gpgme-0-4-3/gpgme/gpgme-config.in b/tags/gpgme-0-4-3/gpgme/gpgme-config.in new file mode 100644 index 0000000..b21013e --- /dev/null +++ b/tags/gpgme-0-4-3/gpgme/gpgme-config.in @@ -0,0 +1,117 @@ +#!/bin/sh +# Copyright (C) 1999, 2002, 2003 Free Software Foundation, Inc. +# +# 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. + +prefix=@prefix@ +exec_prefix=@exec_prefix@ +includedir=@includedir@ +libdir=@libdir@ + +# Configure libgpg-error. +gpg_error_cflags="@GPG_ERROR_CFLAGS@" +gpg_error_libs="@GPG_ERROR_LIBS@" + +# Configure thread packages. +thread_modules="" + +@HAVE_PTH_TRUE@thread_modules="$thread_modules pth" +libs_pth="@PTH_LDFLAGS@ @PTH_LIBS@" +cflags_pth="@PTH_CFLAGS@" + +@HAVE_PTHREAD_TRUE@thread_modules="$thread_modules pthread" +libs_pthread="-lpthread" +cflags_pthread="" + +output="" + +usage() +{ + cat <&2 +fi + +while test $# -gt 0; do + case "$1" in + -*=*) + optarg=`echo "$1" | sed 's/[-_a-zA-Z0-9]*=//'` + ;; + *) + optarg= + ;; + esac + + case $1 in + --prefix) + output="$output $prefix" + ;; + --exec-prefix) + output="$output $exec_prefix" + ;; + --version) + echo "@VERSION@" + exit 0 + ;; + --cflags) + output="$output -I$includedir" + case "$thread_module" in + pthread) + output="$output $cflags_pthread" + ;; + pth) + output="$output $cflags_pth" + ;; + esac + output="$output $gpg_error_cflags" + ;; + --libs) + output="$output -L$libdir" + case "$thread_module" in + pthread) + output="$output -lgpgme-pthread $libs_pthread" + ;; + pth) + output="$output -lgpgme-pth $libs_pth" + ;; + *) + output="$output -lgpgme" + esac + output="$output $gpg_error_libs" + ;; + --thread=*) + for thread_mod in $thread_modules; do + if test "$thread_mod" = "$optarg"; then + thread_module="$optarg"; + fi + done + if test "x$thread_module" = "x"; then + usage 1 1>&2 + fi + ;; + *) + usage 1 1>&2 + ;; + esac + shift +done + +echo $output diff --git a/tags/gpgme-0-4-3/gpgme/gpgme.c b/tags/gpgme-0-4-3/gpgme/gpgme.c new file mode 100644 index 0000000..84862fe --- /dev/null +++ b/tags/gpgme-0-4-3/gpgme/gpgme.c @@ -0,0 +1,453 @@ +/* gpgme.c - GnuPG Made Easy. + Copyright (C) 2000 Werner Koch (dd9jn) + Copyright (C) 2001, 2002, 2003 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 + 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. */ + +#if HAVE_CONFIG_H +#include +#endif +#include +#include +#include +#include +#include +#include + +#include "util.h" +#include "context.h" +#include "ops.h" +#include "wait.h" + + +/* The default locale. */ +DEFINE_STATIC_LOCK (def_lc_lock); +static char *def_lc_ctype; +static char *def_lc_messages; + + +/* Create a new context as an environment for GPGME crypto + operations. */ +gpgme_error_t +gpgme_new (gpgme_ctx_t *r_ctx) +{ + gpgme_ctx_t ctx; + + ctx = calloc (1, sizeof *ctx); + if (!ctx) + return gpg_error_from_errno (errno); + ctx->keylist_mode = GPGME_KEYLIST_MODE_LOCAL; + ctx->include_certs = 1; + ctx->protocol = GPGME_PROTOCOL_OpenPGP; + _gpgme_fd_table_init (&ctx->fdt); + + LOCK (def_lc_lock); + if (def_lc_ctype) + { + ctx->lc_ctype = strdup (def_lc_ctype); + if (!ctx->lc_ctype) + { + UNLOCK (def_lc_lock); + free (ctx); + return gpg_error_from_errno (errno); + } + } + else + def_lc_ctype = NULL; + + if (def_lc_messages) + { + ctx->lc_messages = strdup (def_lc_messages); + if (!ctx->lc_messages) + { + UNLOCK (def_lc_lock); + if (ctx->lc_ctype) + free (ctx->lc_ctype); + free (ctx); + return gpg_error_from_errno (errno); + } + } + else + def_lc_messages = NULL; + UNLOCK (def_lc_lock); + + *r_ctx = ctx; + return 0; +} + + +/* Release all resources associated with the given context. */ +void +gpgme_release (gpgme_ctx_t ctx) +{ + _gpgme_engine_release (ctx->engine); + _gpgme_fd_table_deinit (&ctx->fdt); + _gpgme_release_result (ctx); + gpgme_signers_clear (ctx); + if (ctx->signers) + free (ctx->signers); + if (ctx->lc_ctype) + free (ctx->lc_ctype); + if (ctx->lc_messages) + free (ctx->lc_messages); + free (ctx); +} + + +void +_gpgme_release_result (gpgme_ctx_t ctx) +{ + struct ctx_op_data *data = ctx->op_data; + + while (data) + { + struct ctx_op_data *next_data = data->next; + if (data->cleanup) + (*data->cleanup) (data->hook); + free (data); + data = next_data; + } + ctx->op_data = NULL; +} + + +gpgme_error_t +gpgme_set_protocol (gpgme_ctx_t ctx, gpgme_protocol_t protocol) +{ + if (protocol != GPGME_PROTOCOL_OpenPGP && protocol != GPGME_PROTOCOL_CMS) + return gpg_error (GPG_ERR_INV_VALUE); + + ctx->protocol = protocol; + return 0; +} + + +gpgme_protocol_t +gpgme_get_protocol (gpgme_ctx_t ctx) +{ + return ctx->protocol; +} + + +const char * +gpgme_get_protocol_name (gpgme_protocol_t protocol) +{ + switch (protocol) + { + case GPGME_PROTOCOL_OpenPGP: + return "OpenPGP"; + + case GPGME_PROTOCOL_CMS: + return "CMS"; + + default: + return NULL; + } +} + +/* Enable or disable the use of an ascii armor for all output. */ +void +gpgme_set_armor (gpgme_ctx_t ctx, int yes) +{ + ctx->use_armor = yes; +} + + +/* Return the state of the armor flag. */ +int +gpgme_get_armor (gpgme_ctx_t ctx) +{ + return ctx->use_armor; +} + + +/* Enable or disable the use of the special textmode. Textmode is for + example used for the RFC2015 signatures; note that the updated RFC + 3156 mandates that the MUA does some preparations so that textmode + is not needed anymore. */ +void +gpgme_set_textmode (gpgme_ctx_t ctx, int yes) +{ + ctx->use_textmode = yes; +} + +/* Return the state of the textmode flag. */ +int +gpgme_get_textmode (gpgme_ctx_t ctx) +{ + return ctx->use_textmode; +} + + +/* Set the number of certifications to include in an S/MIME message. + The default is 1 (only the cert of the sender). -1 means all + certs, and -2 means all certs except the root cert. */ +void +gpgme_set_include_certs (gpgme_ctx_t ctx, int nr_of_certs) +{ + if (nr_of_certs < -2) + ctx->include_certs = -2; + else + ctx->include_certs = nr_of_certs; +} + + +/* Get the number of certifications to include in an S/MIME + message. */ +int +gpgme_get_include_certs (gpgme_ctx_t ctx) +{ + return ctx->include_certs; +} + + +/* This function changes the default behaviour of the keylisting + functions. MODE is a bitwise-OR of the GPGME_KEYLIST_* flags. The + default mode is GPGME_KEYLIST_MODE_LOCAL. */ +gpgme_error_t +gpgme_set_keylist_mode (gpgme_ctx_t ctx, gpgme_keylist_mode_t mode) +{ + if (!((mode & GPGME_KEYLIST_MODE_LOCAL) + || (mode & GPGME_KEYLIST_MODE_EXTERN) + || (mode & GPGME_KEYLIST_MODE_SIGS))) + return gpg_error (GPG_ERR_INV_VALUE); + + ctx->keylist_mode = mode; + return 0; +} + +/* This function returns the default behaviour of the keylisting + functions. */ +gpgme_keylist_mode_t +gpgme_get_keylist_mode (gpgme_ctx_t ctx) +{ + return ctx->keylist_mode; +} + + +/* This function sets a callback function to be used to pass a + passphrase to gpg. */ +void +gpgme_set_passphrase_cb (gpgme_ctx_t ctx, gpgme_passphrase_cb_t cb, + void *cb_value) +{ + ctx->passphrase_cb = cb; + ctx->passphrase_cb_value = cb_value; +} + + +/* This function returns the callback function to be used to pass a + passphrase to the crypto engine. */ +void +gpgme_get_passphrase_cb (gpgme_ctx_t ctx, gpgme_passphrase_cb_t *r_cb, + void **r_cb_value) +{ + if (r_cb) + *r_cb = ctx->passphrase_cb; + if (r_cb_value) + *r_cb_value = ctx->passphrase_cb_value; +} + + +/* This function sets a callback function to be used as a progress + indicator. */ +void +gpgme_set_progress_cb (gpgme_ctx_t ctx, gpgme_progress_cb_t cb, void *cb_value) +{ + ctx->progress_cb = cb; + ctx->progress_cb_value = cb_value; +} + + +/* This function returns the callback function to be used as a + progress indicator. */ +void +gpgme_get_progress_cb (gpgme_ctx_t ctx, gpgme_progress_cb_t *r_cb, + void **r_cb_value) +{ + if (r_cb) + *r_cb = ctx->progress_cb; + if (r_cb_value) + *r_cb_value = ctx->progress_cb_value; +} + + +/* Set the I/O callback functions for CTX to IO_CBS. */ +void +gpgme_set_io_cbs (gpgme_ctx_t ctx, gpgme_io_cbs_t io_cbs) +{ + if (io_cbs) + ctx->io_cbs = *io_cbs; + else + { + ctx->io_cbs.add = NULL; + ctx->io_cbs.add_priv = NULL; + ctx->io_cbs.remove = NULL; + ctx->io_cbs.event = NULL; + ctx->io_cbs.event_priv = NULL; + } +} + + +/* This function returns the callback function for I/O. */ +void +gpgme_get_io_cbs (gpgme_ctx_t ctx, gpgme_io_cbs_t io_cbs) +{ + *io_cbs = ctx->io_cbs; +} + + +/* This function sets the locale for the context CTX, or the default + locale if CTX is a null pointer. */ +gpgme_error_t +gpgme_set_locale (gpgme_ctx_t ctx, int category, const char *value) +{ + int failed = 0; + char *new_lc_ctype; + char *new_lc_messages; + +#define PREPARE_ONE_LOCALE(lcat, ucat) \ + if (!failed && value \ + && (category == LC_ALL || category == LC_ ## ucat)) \ + { \ + new_lc_ ## lcat = strdup (value); \ + if (!new_lc_ ## lcat) \ + failed = 1; \ + } \ + else \ + new_lc_ ## lcat = NULL; + + PREPARE_ONE_LOCALE (ctype, CTYPE); + PREPARE_ONE_LOCALE (messages, MESSAGES); + + if (failed) + { + int saved_errno = errno; + + if (new_lc_ctype) + free (new_lc_ctype); + if (new_lc_messages) + free (new_lc_messages); + + return gpg_error_from_errno (saved_errno); + } + +#define SET_ONE_LOCALE(lcat, ucat) \ + if (category == LC_ALL || category == LC_ ## ucat) \ + { \ + if (ctx) \ + { \ + if (ctx->lc_ ## lcat) \ + free (ctx->lc_ ## lcat); \ + ctx->lc_ ## lcat = new_lc_ ## lcat; \ + } \ + else \ + { \ + if (def_lc_ ## lcat) \ + free (def_lc_ ## lcat); \ + def_lc_ ## lcat = new_lc_ ## lcat; \ + } \ + } + + if (!ctx) + LOCK (def_lc_lock); + SET_ONE_LOCALE (ctype, CTYPE); + SET_ONE_LOCALE (messages, MESSAGES); + if (!ctx) + UNLOCK (def_lc_lock); + + return 0; +} + + +const char * +gpgme_pubkey_algo_name (gpgme_pubkey_algo_t algo) +{ + switch (algo) + { + case GPGME_PK_RSA: + return "RSA"; + + case GPGME_PK_RSA_E: + return "RSA-E"; + + case GPGME_PK_RSA_S: + return "RSA-S"; + + case GPGME_PK_ELG_E: + return "ELG-E"; + + case GPGME_PK_DSA: + return "DSA"; + + case GPGME_PK_ELG: + return "ELG"; + + default: + return NULL; + } +} + + +const char * +gpgme_hash_algo_name (gpgme_hash_algo_t algo) +{ + switch (algo) + { + case GPGME_MD_MD5: + return "MD5"; + + case GPGME_MD_SHA1: + return "SHA1"; + + case GPGME_MD_RMD160: + return "RIPEMD160"; + + case GPGME_MD_MD2: + return "MD2"; + + case GPGME_MD_TIGER: + return "TIGER192"; + + case GPGME_MD_HAVAL: + return "HAVAL"; + + case GPGME_MD_SHA256: + return "SHA256"; + + case GPGME_MD_SHA384: + return "SHA384"; + + case GPGME_MD_SHA512: + return "SHA512"; + + case GPGME_MD_MD4: + return "MD4"; + + case GPGME_MD_CRC32: + return "CRC32"; + + case GPGME_MD_CRC32_RFC1510: + return "CRC32RFC1510"; + + case GPGME_MD_CRC24_RFC2440: + return "CRC24RFC2440"; + + default: + return NULL; + } +} diff --git a/tags/gpgme-0-4-3/gpgme/gpgme.h b/tags/gpgme-0-4-3/gpgme/gpgme.h new file mode 100644 index 0000000..aa46fe8 --- /dev/null +++ b/tags/gpgme-0-4-3/gpgme/gpgme.h @@ -0,0 +1,1526 @@ +/* gpgme.h - Public interface to GnuPG Made Easy. + Copyright (C) 2000 Werner Koch (dd9jn) + Copyright (C) 2001, 2002, 2003 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 + 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. */ + +#ifndef GPGME_H +#define GPGME_H + +#ifdef __GNUC__ +#define _GPGME_INLINE __inline__ +#elif __STDC_VERSION__ >= 199901L +#define _GPGME_INLINE inline +#else +#define _GPGME_INLINE +#endif + +/* Include stdio.h for the FILE type definition. */ +#include + +#ifdef _MSC_VER + typedef long off_t; + typedef long ssize_t; +#else +# include +#endif + +#ifdef __cplusplus +extern "C" { +#if 0 /* just to make Emacs auto-indent happy */ +} +#endif +#endif + +#include + + +/* Check for compiler features. */ +#if __GNUC__ +#define _GPGME_GCC_VERSION (__GNUC__ * 10000 \ + + __GNUC_MINOR__ * 100 \ + + __GNUC_PATCHLEVEL__) + +#if _GPGME_GCC_VERSION > 30100 +#define _GPGME_DEPRECATED __attribute__ ((__deprecated__)) +#endif +#endif + +#ifndef _GPGME_DEPRECATED +#define _GPGME_DEPRECATED +#endif + + +/* The version of this header should match the one of the library. Do + not use this symbol in your application, use gpgme_check_version + instead. The purpose of this macro is to let autoconf (using the + AM_PATH_GPGME macro) check that this header matches the installed + library. Warning: Do not edit the next line. configure will do + that for you! */ +#define GPGME_VERSION "0.4.3" + + +/* Some opaque data types used by GPGME. */ + +/* The context holds some global state and configration options, as + well as the results of a crypto operation. */ +struct gpgme_context; +typedef struct gpgme_context *gpgme_ctx_t; + +/* The data object is used by GPGME to exchange arbitrary data. */ +struct gpgme_data; +typedef struct gpgme_data *gpgme_data_t; + + +/* Wrappers for the libgpg-error library. */ + +typedef gpg_error_t gpgme_error_t; +typedef gpg_err_code_t gpgme_err_code_t; +typedef gpg_err_source_t gpgme_err_source_t; + + +static _GPGME_INLINE gpgme_error_t +gpgme_err_make (gpgme_err_source_t source, gpgme_err_code_t code) +{ + return gpg_err_make (source, code); +} + + +/* The user can define GPGME_ERR_SOURCE_DEFAULT before including this + file to specify a default source for gpgme_error. */ +#ifndef GPGME_ERR_SOURCE_DEFAULT +#define GPGME_ERR_SOURCE_DEFAULT GPG_ERR_SOURCE_USER_1 +#endif + +static _GPGME_INLINE gpgme_error_t +gpgme_error (gpgme_err_code_t code) +{ + return gpgme_err_make (GPGME_ERR_SOURCE_DEFAULT, code); +} + + +static _GPGME_INLINE gpgme_err_code_t +gpgme_err_code (gpgme_error_t err) +{ + return gpg_err_code (err); +} + + +static _GPGME_INLINE gpgme_err_source_t +gpgme_err_source (gpgme_error_t err) +{ + return gpg_err_source (err); +} + + +/* Return a pointer to a string containing a description of the error + code in the error value ERR. This function is not thread safe. */ +const char *gpgme_strerror (gpgme_error_t err); + +/* Return the error string for ERR in the user-supplied buffer BUF of + size BUFLEN. This function is, in contrast to gpg_strerror, + thread-safe if a thread-safe strerror_r() function is provided by + the system. If the function succeeds, 0 is returned and BUF + contains the string describing the error. If the buffer was not + large enough, ERANGE is returned and BUF contains as much of the + beginning of the error string as fits into the buffer. */ +int gpgme_strerror_r (gpg_error_t err, char *buf, size_t buflen); + + +/* Return a pointer to a string containing a description of the error + source in the error value ERR. */ +const char *gpgme_strsource (gpgme_error_t err); + + +/* Retrieve the error code for the system error ERR. This returns + GPG_ERR_UNKNOWN_ERRNO if the system error is not mapped (report + this). */ +gpgme_err_code_t gpgme_err_code_from_errno (int err); + + +/* Retrieve the system error for the error code CODE. This returns 0 + if CODE is not a system error code. */ +int gpgme_err_code_to_errno (gpgme_err_code_t code); + + +/* Return an error value with the error source SOURCE and the system + error ERR. */ +gpgme_error_t gpgme_err_make_from_errno (gpgme_err_source_t source, int err); + + +/* Return an error value with the system error ERR. */ +gpgme_err_code_t gpgme_error_from_errno (int err); + + +/* The possible encoding mode of gpgme_data_t objects. */ +typedef enum + { + GPGME_DATA_ENCODING_NONE = 0, /* Not specified. */ + GPGME_DATA_ENCODING_BINARY = 1, + GPGME_DATA_ENCODING_BASE64 = 2, + GPGME_DATA_ENCODING_ARMOR = 3 /* Either PEM or OpenPGP Armor. */ + } +gpgme_data_encoding_t; + + +/* Public key algorithms from libgcrypt. */ +typedef enum + { + GPGME_PK_RSA = 1, + GPGME_PK_RSA_E = 2, + GPGME_PK_RSA_S = 3, + GPGME_PK_ELG_E = 16, + GPGME_PK_DSA = 17, + GPGME_PK_ELG = 20 + } +gpgme_pubkey_algo_t; + + +/* Hash algorithms from libgcrypt. */ +typedef enum + { + GPGME_MD_NONE = 0, + GPGME_MD_MD5 = 1, + GPGME_MD_SHA1 = 2, + GPGME_MD_RMD160 = 3, + GPGME_MD_MD2 = 5, + GPGME_MD_TIGER = 6, /* TIGER/192. */ + GPGME_MD_HAVAL = 7, /* HAVAL, 5 pass, 160 bit. */ + GPGME_MD_SHA256 = 8, + GPGME_MD_SHA384 = 9, + GPGME_MD_SHA512 = 10, + GPGME_MD_MD4 = 301, + GPGME_MD_CRC32 = 302, + GPGME_MD_CRC32_RFC1510 = 303, + GPGME_MD_CRC24_RFC2440 = 304 + } +gpgme_hash_algo_t; + + +/* The possible signature stati. Deprecated, use error value in sig + status. */ +typedef enum + { + GPGME_SIG_STAT_NONE = 0, + GPGME_SIG_STAT_GOOD = 1, + GPGME_SIG_STAT_BAD = 2, + GPGME_SIG_STAT_NOKEY = 3, + GPGME_SIG_STAT_NOSIG = 4, + GPGME_SIG_STAT_ERROR = 5, + GPGME_SIG_STAT_DIFF = 6, + GPGME_SIG_STAT_GOOD_EXP = 7, + GPGME_SIG_STAT_GOOD_EXPKEY = 8 + } +_gpgme_sig_stat_t; +typedef _gpgme_sig_stat_t gpgme_sig_stat_t _GPGME_DEPRECATED; + + +/* The available signature modes. */ +typedef enum + { + GPGME_SIG_MODE_NORMAL = 0, + GPGME_SIG_MODE_DETACH = 1, + GPGME_SIG_MODE_CLEAR = 2 + } +gpgme_sig_mode_t; + + +/* The available key and signature attributes. Deprecated, use the + individual result structures instead. */ +typedef enum + { + GPGME_ATTR_KEYID = 1, + GPGME_ATTR_FPR = 2, + GPGME_ATTR_ALGO = 3, + GPGME_ATTR_LEN = 4, + GPGME_ATTR_CREATED = 5, + GPGME_ATTR_EXPIRE = 6, + GPGME_ATTR_OTRUST = 7, + GPGME_ATTR_USERID = 8, + GPGME_ATTR_NAME = 9, + GPGME_ATTR_EMAIL = 10, + GPGME_ATTR_COMMENT = 11, + GPGME_ATTR_VALIDITY = 12, + GPGME_ATTR_LEVEL = 13, + GPGME_ATTR_TYPE = 14, + GPGME_ATTR_IS_SECRET = 15, + GPGME_ATTR_KEY_REVOKED = 16, + GPGME_ATTR_KEY_INVALID = 17, + GPGME_ATTR_UID_REVOKED = 18, + GPGME_ATTR_UID_INVALID = 19, + GPGME_ATTR_KEY_CAPS = 20, + GPGME_ATTR_CAN_ENCRYPT = 21, + GPGME_ATTR_CAN_SIGN = 22, + GPGME_ATTR_CAN_CERTIFY = 23, + GPGME_ATTR_KEY_EXPIRED = 24, + GPGME_ATTR_KEY_DISABLED = 25, + GPGME_ATTR_SERIAL = 26, + GPGME_ATTR_ISSUER = 27, + GPGME_ATTR_CHAINID = 28, + GPGME_ATTR_SIG_STATUS = 29, + GPGME_ATTR_ERRTOK = 30, + GPGME_ATTR_SIG_SUMMARY = 31, + GPGME_ATTR_SIG_CLASS = 32 + } +_gpgme_attr_t; +typedef _gpgme_attr_t gpgme_attr_t _GPGME_DEPRECATED; + + +/* The available validities for a trust item or key. */ +typedef enum + { + GPGME_VALIDITY_UNKNOWN = 0, + GPGME_VALIDITY_UNDEFINED = 1, + GPGME_VALIDITY_NEVER = 2, + GPGME_VALIDITY_MARGINAL = 3, + GPGME_VALIDITY_FULL = 4, + GPGME_VALIDITY_ULTIMATE = 5 + } +gpgme_validity_t; + + +/* The available protocols. */ +typedef enum + { + GPGME_PROTOCOL_OpenPGP = 0, /* The default mode. */ + GPGME_PROTOCOL_CMS = 1 + } +gpgme_protocol_t; + + +/* The possible stati for the edit operation. */ +typedef enum + { + GPGME_STATUS_EOF, + /* mkstatus processing starts here */ + GPGME_STATUS_ENTER, + GPGME_STATUS_LEAVE, + GPGME_STATUS_ABORT, + + GPGME_STATUS_GOODSIG, + GPGME_STATUS_BADSIG, + GPGME_STATUS_ERRSIG, + + GPGME_STATUS_BADARMOR, + + GPGME_STATUS_RSA_OR_IDEA, + GPGME_STATUS_KEYEXPIRED, + GPGME_STATUS_KEYREVOKED, + + GPGME_STATUS_TRUST_UNDEFINED, + GPGME_STATUS_TRUST_NEVER, + GPGME_STATUS_TRUST_MARGINAL, + GPGME_STATUS_TRUST_FULLY, + GPGME_STATUS_TRUST_ULTIMATE, + + GPGME_STATUS_SHM_INFO, + GPGME_STATUS_SHM_GET, + GPGME_STATUS_SHM_GET_BOOL, + GPGME_STATUS_SHM_GET_HIDDEN, + + GPGME_STATUS_NEED_PASSPHRASE, + GPGME_STATUS_VALIDSIG, + GPGME_STATUS_SIG_ID, + GPGME_STATUS_ENC_TO, + GPGME_STATUS_NODATA, + GPGME_STATUS_BAD_PASSPHRASE, + GPGME_STATUS_NO_PUBKEY, + GPGME_STATUS_NO_SECKEY, + GPGME_STATUS_NEED_PASSPHRASE_SYM, + GPGME_STATUS_DECRYPTION_FAILED, + GPGME_STATUS_DECRYPTION_OKAY, + GPGME_STATUS_MISSING_PASSPHRASE, + GPGME_STATUS_GOOD_PASSPHRASE, + GPGME_STATUS_GOODMDC, + GPGME_STATUS_BADMDC, + GPGME_STATUS_ERRMDC, + GPGME_STATUS_IMPORTED, + GPGME_STATUS_IMPORT_OK, + GPGME_STATUS_IMPORT_PROBLEM, + GPGME_STATUS_IMPORT_RES, + GPGME_STATUS_FILE_START, + GPGME_STATUS_FILE_DONE, + GPGME_STATUS_FILE_ERROR, + + GPGME_STATUS_BEGIN_DECRYPTION, + GPGME_STATUS_END_DECRYPTION, + GPGME_STATUS_BEGIN_ENCRYPTION, + GPGME_STATUS_END_ENCRYPTION, + + GPGME_STATUS_DELETE_PROBLEM, + GPGME_STATUS_GET_BOOL, + GPGME_STATUS_GET_LINE, + GPGME_STATUS_GET_HIDDEN, + GPGME_STATUS_GOT_IT, + GPGME_STATUS_PROGRESS, + GPGME_STATUS_SIG_CREATED, + GPGME_STATUS_SESSION_KEY, + GPGME_STATUS_NOTATION_NAME, + GPGME_STATUS_NOTATION_DATA, + GPGME_STATUS_POLICY_URL, + GPGME_STATUS_BEGIN_STREAM, + GPGME_STATUS_END_STREAM, + GPGME_STATUS_KEY_CREATED, + GPGME_STATUS_USERID_HINT, + GPGME_STATUS_UNEXPECTED, + GPGME_STATUS_INV_RECP, + GPGME_STATUS_NO_RECP, + GPGME_STATUS_ALREADY_SIGNED, + GPGME_STATUS_SIGEXPIRED, + GPGME_STATUS_EXPSIG, + GPGME_STATUS_EXPKEYSIG, + GPGME_STATUS_TRUNCATED, + GPGME_STATUS_ERROR + } +gpgme_status_code_t; + + +/* The engine information structure. */ +struct _gpgme_engine_info +{ + struct _gpgme_engine_info *next; + + /* The protocol ID. */ + gpgme_protocol_t protocol; + + /* The file name of the engine binary. */ + const char *file_name; + + /* The version string of the installed engine. */ + const char *version; + + /* The minimum version required for GPGME. */ + const char *req_version; +}; +typedef struct _gpgme_engine_info *gpgme_engine_info_t; + + +/* A subkey from a key. */ +struct _gpgme_subkey +{ + struct _gpgme_subkey *next; + + /* True if subkey is revoked. */ + unsigned int revoked : 1; + + /* True if subkey is expired. */ + unsigned int expired : 1; + + /* True if subkey is disabled. */ + unsigned int disabled : 1; + + /* True if subkey is invalid. */ + unsigned int invalid : 1; + + /* True if subkey can be used for encryption. */ + unsigned int can_encrypt : 1; + + /* True if subkey can be used for signing. */ + unsigned int can_sign : 1; + + /* True if subkey can be used for certification. */ + unsigned int can_certify : 1; + + /* True if subkey is secret. */ + unsigned int secret : 1; + + /* True if subkey can be used for authentication. */ + unsigned int can_authenticate : 1; + + /* Internal to GPGME, do not use. */ + unsigned int _unused : 23; + + /* Public key algorithm supported by this subkey. */ + gpgme_pubkey_algo_t pubkey_algo; + + /* Length of the subkey. */ + unsigned int length; + + /* The key ID of the subkey. */ + char *keyid; + + /* Internal to GPGME, do not use. */ + char _keyid[16 + 1]; + + /* The fingerprint of the subkey in hex digit form. */ + char *fpr; + + /* The creation timestamp, -1 if invalid, 0 if not available. */ + long int timestamp; + + /* The expiration timestamp, 0 if the subkey does not expire. */ + long int expires; +}; +typedef struct _gpgme_subkey *gpgme_subkey_t; + + +/* A signature on a user ID. */ +struct _gpgme_key_sig +{ + struct _gpgme_key_sig *next; + + /* True if the signature is revoked. */ + unsigned int revoked : 1; + + /* True if the signature is expired. */ + unsigned int expired : 1; + + /* True if the signature is invalid. */ + unsigned int invalid : 1; + + /* True if the signature should be exported. */ + unsigned int exportable : 1; + + /* Internal to GPGME, do not use. */ + unsigned int _unused : 28; + + /* The public key algorithm used to create the signature. */ + gpgme_pubkey_algo_t pubkey_algo; + + /* The key ID of key used to create the signature. */ + char *keyid; + + /* Internal to GPGME, do not use. */ + char _keyid[16 + 1]; + + /* The creation timestamp, -1 if invalid, 0 if not available. */ + long int timestamp; + + /* The expiration timestamp, 0 if the subkey does not expire. */ + long int expires; + + /* Same as in gpgme_signature_t. */ + gpgme_error_t status; + + /* Crypto backend specific signature class. */ + unsigned int class; + + /* The user ID string. */ + char *uid; + + /* The name part of the user ID. */ + char *name; + + /* The email part of the user ID. */ + char *email; + + /* The comment part of the user ID. */ + char *comment; +}; +typedef struct _gpgme_key_sig *gpgme_key_sig_t; + + +/* An user ID from a key. */ +struct _gpgme_user_id +{ + struct _gpgme_user_id *next; + + /* True if the user ID is revoked. */ + unsigned int revoked : 1; + + /* True if the user ID is invalid. */ + unsigned int invalid : 1; + + /* Internal to GPGME, do not use. */ + unsigned int _unused : 30; + + /* The validity of the user ID. */ + gpgme_validity_t validity; + + /* The user ID string. */ + char *uid; + + /* The name part of the user ID. */ + char *name; + + /* The email part of the user ID. */ + char *email; + + /* The comment part of the user ID. */ + char *comment; + + /* The signatures of the user ID. */ + gpgme_key_sig_t signatures; + + /* Internal to GPGME, do not use. */ + gpgme_key_sig_t _last_keysig; +}; +typedef struct _gpgme_user_id *gpgme_user_id_t; + + +/* A key from the keyring. */ +struct _gpgme_key +{ + /* Internal to GPGME, do not use. */ + unsigned int _refs; + + /* True if key is revoked. */ + unsigned int revoked : 1; + + /* True if key is expired. */ + unsigned int expired : 1; + + /* True if key is disabled. */ + unsigned int disabled : 1; + + /* True if key is invalid. */ + unsigned int invalid : 1; + + /* True if key can be used for encryption. */ + unsigned int can_encrypt : 1; + + /* True if key can be used for signing. */ + unsigned int can_sign : 1; + + /* True if key can be used for certification. */ + unsigned int can_certify : 1; + + /* True if key is secret. */ + unsigned int secret : 1; + + /* True if key can be used for authentication. */ + unsigned int can_authenticate : 1; + + /* Internal to GPGME, do not use. */ + unsigned int _unused : 23; + + /* This is the protocol supported by this key. */ + gpgme_protocol_t protocol; + + /* If protocol is GPGME_PROTOCOL_CMS, this string contains the + issuer serial. */ + char *issuer_serial; + + /* If protocol is GPGME_PROTOCOL_CMS, this string contains the + issuer name. */ + char *issuer_name; + + /* If protocol is GPGME_PROTOCOL_CMS, this string contains the chain + ID. */ + char *chain_id; + + /* If protocol is GPGME_PROTOCOL_OpenPGP, this field contains the + owner trust. */ + gpgme_validity_t owner_trust; + + /* The subkeys of the key. */ + gpgme_subkey_t subkeys; + + /* The user IDs of the key. */ + gpgme_user_id_t uids; + + /* Internal to GPGME, do not use. */ + gpgme_subkey_t _last_subkey; + + /* Internal to GPGME, do not use. */ + gpgme_user_id_t _last_uid; +}; +typedef struct _gpgme_key *gpgme_key_t; + + + +/* Types for callback functions. */ + +/* Request a passphrase from the user. */ +typedef gpgme_error_t (*gpgme_passphrase_cb_t) (void *hook, + const char *uid_hint, + const char *passphrase_info, + int prev_was_bad, int fd); + +/* Inform the user about progress made. */ +typedef void (*gpgme_progress_cb_t) (void *opaque, const char *what, + int type, int current, int total); + +/* Interact with the user about an edit operation. */ +typedef gpgme_error_t (*gpgme_edit_cb_t) (void *opaque, + gpgme_status_code_t status, + const char *args, int fd); + + +/* Context management functions. */ + +/* Create a new context and return it in CTX. */ +gpgme_error_t gpgme_new (gpgme_ctx_t *ctx); + +/* Release the context CTX. */ +void gpgme_release (gpgme_ctx_t ctx); + +/* Set the protocol to be used by CTX to PROTO. */ +gpgme_error_t gpgme_set_protocol (gpgme_ctx_t ctx, gpgme_protocol_t proto); + +/* Get the protocol used with CTX */ +gpgme_protocol_t gpgme_get_protocol (gpgme_ctx_t ctx); + +/* Get the string describing protocol PROTO, or NULL if invalid. */ +const char *gpgme_get_protocol_name (gpgme_protocol_t proto); + +/* If YES is non-zero, enable armor mode in CTX, disable it otherwise. */ +void gpgme_set_armor (gpgme_ctx_t ctx, int yes); + +/* Return non-zero if armor mode is set in CTX. */ +int gpgme_get_armor (gpgme_ctx_t ctx); + +/* If YES is non-zero, enable text mode in CTX, disable it otherwise. */ +void gpgme_set_textmode (gpgme_ctx_t ctx, int yes); + +/* Return non-zero if text mode is set in CTX. */ +int gpgme_get_textmode (gpgme_ctx_t ctx); + +/* Include up to NR_OF_CERTS certificates in an S/MIME message. */ +void gpgme_set_include_certs (gpgme_ctx_t ctx, int nr_of_certs); + +/* Return the number of certs to include in an S/MIME message. */ +int gpgme_get_include_certs (gpgme_ctx_t ctx); + +/* The available keylist mode flags. */ +typedef enum + { + GPGME_KEYLIST_MODE_LOCAL = 1, + GPGME_KEYLIST_MODE_EXTERN = 2, + GPGME_KEYLIST_MODE_SIGS = 4 + } +gpgme_keylist_mode_t; + +/* Set keylist mode in CTX to MODE. */ +gpgme_error_t gpgme_set_keylist_mode (gpgme_ctx_t ctx, + gpgme_keylist_mode_t mode); + +/* Get keylist mode in CTX. */ +gpgme_keylist_mode_t gpgme_get_keylist_mode (gpgme_ctx_t ctx); + +/* Set the passphrase callback function in CTX to CB. HOOK_VALUE is + passed as first argument to the passphrase callback function. */ +void gpgme_set_passphrase_cb (gpgme_ctx_t ctx, + gpgme_passphrase_cb_t cb, void *hook_value); + +/* Get the current passphrase callback function in *CB and the current + hook value in *HOOK_VALUE. */ +void gpgme_get_passphrase_cb (gpgme_ctx_t ctx, gpgme_passphrase_cb_t *cb, + void **hook_value); + +/* Set the progress callback function in CTX to CB. HOOK_VALUE is + passed as first argument to the progress callback function. */ +void gpgme_set_progress_cb (gpgme_ctx_t c, gpgme_progress_cb_t cb, + void *hook_value); + +/* Get the current progress callback function in *CB and the current + hook value in *HOOK_VALUE. */ +void gpgme_get_progress_cb (gpgme_ctx_t ctx, gpgme_progress_cb_t *cb, + void **hook_value); + +/* This function sets the locale for the context CTX, or the default + locale if CTX is a null pointer. */ +gpgme_error_t gpgme_set_locale (gpgme_ctx_t ctx, int category, + const char *value); + +/* Return a statically allocated string with the name of the public + key algorithm ALGO, or NULL if that name is not known. */ +const char *gpgme_pubkey_algo_name (gpgme_pubkey_algo_t algo); + +/* Return a statically allocated string with the name of the hash + algorithm ALGO, or NULL if that name is not known. */ +const char *gpgme_hash_algo_name (gpgme_hash_algo_t algo); + + +/* Delete all signers from CTX. */ +void gpgme_signers_clear (gpgme_ctx_t ctx); + +/* Add KEY to list of signers in CTX. */ +gpgme_error_t gpgme_signers_add (gpgme_ctx_t ctx, const gpgme_key_t key); + +/* Return the SEQth signer's key in CTX. */ +gpgme_key_t gpgme_signers_enum (const gpgme_ctx_t ctx, int seq); + +/* Retrieve the signature status of signature IDX in CTX after a + successful verify operation in R_STAT (if non-null). The creation + time stamp of the signature is returned in R_CREATED (if non-null). + The function returns a string containing the fingerprint. + Deprecated, use verify result directly. */ +const char *gpgme_get_sig_status (gpgme_ctx_t ctx, int idx, + _gpgme_sig_stat_t *r_stat, + time_t *r_created) _GPGME_DEPRECATED; + +/* Retrieve certain attributes of a signature. IDX is the index + number of the signature after a successful verify operation. WHAT + is an attribute where GPGME_ATTR_EXPIRE is probably the most useful + one. WHATIDX is to be passed as 0 for most attributes . */ +unsigned long gpgme_get_sig_ulong_attr (gpgme_ctx_t c, int idx, + _gpgme_attr_t what, int whatidx) + _GPGME_DEPRECATED; +const char *gpgme_get_sig_string_attr (gpgme_ctx_t c, int idx, + _gpgme_attr_t what, int whatidx) + _GPGME_DEPRECATED; + + +/* Get the key used to create signature IDX in CTX and return it in + R_KEY. */ +gpgme_error_t gpgme_get_sig_key (gpgme_ctx_t ctx, int idx, gpgme_key_t *r_key) + _GPGME_DEPRECATED; + + +/* Run control. */ + +/* The type of an I/O callback function. */ +typedef gpgme_error_t (*gpgme_io_cb_t) (void *data, int fd); + +/* The type of a function that can register FNC as the I/O callback + function for the file descriptor FD with direction dir (0: for writing, + 1: for reading). FNC_DATA should be passed as DATA to FNC. The + function should return a TAG suitable for the corresponding + gpgme_remove_io_cb_t, and an error value. */ +typedef gpgme_error_t (*gpgme_register_io_cb_t) (void *data, int fd, int dir, + gpgme_io_cb_t fnc, + void *fnc_data, void **tag); + +/* The type of a function that can remove a previously registered I/O + callback function given TAG as returned by the register + function. */ +typedef void (*gpgme_remove_io_cb_t) (void *tag); + +typedef enum + { + GPGME_EVENT_START, + GPGME_EVENT_DONE, + GPGME_EVENT_NEXT_KEY, + GPGME_EVENT_NEXT_TRUSTITEM + } +gpgme_event_io_t; + +/* The type of a function that is called when a context finished an + operation. */ +typedef void (*gpgme_event_io_cb_t) (void *data, gpgme_event_io_t type, + void *type_data); + +struct gpgme_io_cbs +{ + gpgme_register_io_cb_t add; + void *add_priv; + gpgme_remove_io_cb_t remove; + gpgme_event_io_cb_t event; + void *event_priv; +}; +typedef struct gpgme_io_cbs *gpgme_io_cbs_t; + +/* Set the I/O callback functions in CTX to IO_CBS. */ +void gpgme_set_io_cbs (gpgme_ctx_t ctx, gpgme_io_cbs_t io_cbs); + +/* Get the current I/O callback functions. */ +void gpgme_get_io_cbs (gpgme_ctx_t ctx, gpgme_io_cbs_t io_cbs); + +/* Process the pending operation and, if HANG is non-zero, wait for + the pending operation to finish. */ +gpgme_ctx_t gpgme_wait (gpgme_ctx_t ctx, gpgme_error_t *status, int hang); + + +/* Functions to handle data objects. */ + +/* Read up to SIZE bytes into buffer BUFFER from the data object with + the handle HANDLE. Return the number of characters read, 0 on EOF + and -1 on error. If an error occurs, errno is set. */ +typedef ssize_t (*gpgme_data_read_cb_t) (void *handle, void *buffer, + size_t size); + +/* Write up to SIZE bytes from buffer BUFFER to the data object with + the handle HANDLE. Return the number of characters written, or -1 + on error. If an error occurs, errno is set. */ +typedef ssize_t (*gpgme_data_write_cb_t) (void *handle, const void *buffer, + size_t size); + +/* Set the current position from where the next read or write starts + in the data object with the handle HANDLE to OFFSET, relativ to + WHENCE. */ +typedef off_t (*gpgme_data_seek_cb_t) (void *handle, off_t offset, int whence); + +/* Close the data object with the handle DL. */ +typedef void (*gpgme_data_release_cb_t) (void *handle); + +struct gpgme_data_cbs +{ + gpgme_data_read_cb_t read; + gpgme_data_write_cb_t write; + gpgme_data_seek_cb_t seek; + gpgme_data_release_cb_t release; +}; +typedef struct gpgme_data_cbs *gpgme_data_cbs_t; + +/* Read up to SIZE bytes into buffer BUFFER from the data object with + the handle DH. Return the number of characters read, 0 on EOF and + -1 on error. If an error occurs, errno is set. */ +ssize_t gpgme_data_read (gpgme_data_t dh, void *buffer, size_t size); + +/* Write up to SIZE bytes from buffer BUFFER to the data object with + the handle DH. Return the number of characters written, or -1 on + error. If an error occurs, errno is set. */ +ssize_t gpgme_data_write (gpgme_data_t dh, const void *buffer, size_t size); + +/* Set the current position from where the next read or write starts + in the data object with the handle DH to OFFSET, relativ to + WHENCE. */ +off_t gpgme_data_seek (gpgme_data_t dh, off_t offset, int whence); + +/* Create a new data buffer and return it in R_DH. */ +gpgme_error_t gpgme_data_new (gpgme_data_t *r_dh); + +/* Destroy the data buffer DH. */ +void gpgme_data_release (gpgme_data_t dh); + +/* Create a new data buffer filled with SIZE bytes starting from + BUFFER. If COPY is zero, copying is delayed until necessary, and + the data is taken from the original location when needed. */ +gpgme_error_t gpgme_data_new_from_mem (gpgme_data_t *r_dh, + const char *buffer, size_t size, + int copy); + +/* Destroy the data buffer DH and return a pointer to its content. + The memory has be to released with free by the user. It's size is + returned in R_LEN. */ +char *gpgme_data_release_and_get_mem (gpgme_data_t dh, size_t *r_len); + +gpgme_error_t gpgme_data_new_from_cbs (gpgme_data_t *dh, + gpgme_data_cbs_t cbs, + void *handle); + +gpgme_error_t gpgme_data_new_from_fd (gpgme_data_t *dh, int fd); + +gpgme_error_t gpgme_data_new_from_stream (gpgme_data_t *dh, FILE *stream); + +/* Return the encoding attribute of the data buffer DH */ +gpgme_data_encoding_t gpgme_data_get_encoding (gpgme_data_t dh); + +/* Set the encoding attribute of data buffer DH to ENC */ +gpgme_error_t gpgme_data_set_encoding (gpgme_data_t dh, + gpgme_data_encoding_t enc); + + + +/* Create a new data buffer which retrieves the data from the callback + function READ_CB. Deprecated, please use gpgme_data_new_from_cbs + instead. */ +gpgme_error_t gpgme_data_new_with_read_cb (gpgme_data_t *r_dh, + int (*read_cb) (void*,char *, + size_t,size_t*), + void *read_cb_value) + _GPGME_DEPRECATED; + +/* Create a new data buffer filled with the content of file FNAME. + COPY must be non-zero. For delayed read, please use + gpgme_data_new_from_fd or gpgme_data_new_from stream instead. */ +gpgme_error_t gpgme_data_new_from_file (gpgme_data_t *r_dh, + const char *fname, + int copy); + +/* Create a new data buffer filled with LENGTH bytes starting from + OFFSET within the file FNAME or stream FP (exactly one must be + non-zero). */ +gpgme_error_t gpgme_data_new_from_filepart (gpgme_data_t *r_dh, + const char *fname, FILE *fp, + off_t offset, size_t length); + +/* Reset the read pointer in DH. Deprecated, please use + gpgme_data_seek instead. */ +gpgme_error_t gpgme_data_rewind (gpgme_data_t dh) _GPGME_DEPRECATED; + + +/* Key and trust functions. */ + +/* Get the key with the fingerprint FPR from the crypto backend. If + SECRET is true, get the secret key. */ +gpgme_error_t gpgme_get_key (gpgme_ctx_t ctx, const char *fpr, + gpgme_key_t *r_key, int secret); + +/* Acquire a reference to KEY. */ +void gpgme_key_ref (gpgme_key_t key); + +/* Release a reference to KEY. If this was the last one the key is + destroyed. */ +void gpgme_key_unref (gpgme_key_t key); +void gpgme_key_release (gpgme_key_t key); + +/* Return the value of the attribute WHAT of KEY, which has to be + representable by a string. IDX specifies the sub key or user ID + for attributes related to sub keys or user IDs. Deprecated, use + key structure directly instead. */ +const char *gpgme_key_get_string_attr (gpgme_key_t key, _gpgme_attr_t what, + const void *reserved, int idx) + _GPGME_DEPRECATED; + +/* Return the value of the attribute WHAT of KEY, which has to be + representable by an unsigned integer. IDX specifies the sub key or + user ID for attributes related to sub keys or user IDs. + Deprecated, use key structure directly instead. */ +unsigned long gpgme_key_get_ulong_attr (gpgme_key_t key, _gpgme_attr_t what, + const void *reserved, int idx) + _GPGME_DEPRECATED; + +/* Return the value of the attribute WHAT of a signature on user ID + UID_IDX in KEY, which has to be representable by a string. IDX + specifies the signature. Deprecated, use key structure directly + instead. */ +const char *gpgme_key_sig_get_string_attr (gpgme_key_t key, int uid_idx, + _gpgme_attr_t what, + const void *reserved, int idx) + _GPGME_DEPRECATED; + +/* Return the value of the attribute WHAT of a signature on user ID + UID_IDX in KEY, which has to be representable by an unsigned + integer string. IDX specifies the signature. Deprecated, use key + structure directly instead. */ +unsigned long gpgme_key_sig_get_ulong_attr (gpgme_key_t key, int uid_idx, + _gpgme_attr_t what, + const void *reserved, int idx) + _GPGME_DEPRECATED; + + +/* Crypto Operations. */ + +struct _gpgme_invalid_key +{ + struct _gpgme_invalid_key *next; + char *fpr; + gpgme_error_t reason; +}; +typedef struct _gpgme_invalid_key *gpgme_invalid_key_t; + + +/* Encryption. */ +struct _gpgme_op_encrypt_result +{ + /* The list of invalid recipients. */ + gpgme_invalid_key_t invalid_recipients; +}; +typedef struct _gpgme_op_encrypt_result *gpgme_encrypt_result_t; + +/* Retrieve a pointer to the result of the encrypt operation. */ +gpgme_encrypt_result_t gpgme_op_encrypt_result (gpgme_ctx_t ctx); + +/* The valid encryption flags. */ +typedef enum + { + GPGME_ENCRYPT_ALWAYS_TRUST = 1 + } +gpgme_encrypt_flags_t; + +/* Encrypt plaintext PLAIN within CTX for the recipients RECP and + store the resulting ciphertext in CIPHER. */ +gpgme_error_t gpgme_op_encrypt_start (gpgme_ctx_t ctx, gpgme_key_t recp[], + gpgme_encrypt_flags_t flags, + gpgme_data_t plain, gpgme_data_t cipher); +gpgme_error_t gpgme_op_encrypt (gpgme_ctx_t ctx, gpgme_key_t recp[], + gpgme_encrypt_flags_t flags, + gpgme_data_t plain, gpgme_data_t cipher); + +/* Encrypt plaintext PLAIN within CTX for the recipients RECP and + store the resulting ciphertext in CIPHER. Also sign the ciphertext + with the signers in CTX. */ +gpgme_error_t gpgme_op_encrypt_sign_start (gpgme_ctx_t ctx, + gpgme_key_t recp[], + gpgme_encrypt_flags_t flags, + gpgme_data_t plain, + gpgme_data_t cipher); +gpgme_error_t gpgme_op_encrypt_sign (gpgme_ctx_t ctx, gpgme_key_t recp[], + gpgme_encrypt_flags_t flags, + gpgme_data_t plain, gpgme_data_t cipher); + + +/* Decryption. */ +struct _gpgme_op_decrypt_result +{ + char *unsupported_algorithm; +}; +typedef struct _gpgme_op_decrypt_result *gpgme_decrypt_result_t; + +/* Retrieve a pointer to the result of the decrypt operation. */ +gpgme_decrypt_result_t gpgme_op_decrypt_result (gpgme_ctx_t ctx); + +/* Decrypt ciphertext CIPHER within CTX and store the resulting + plaintext in PLAIN. */ +gpgme_error_t gpgme_op_decrypt_start (gpgme_ctx_t ctx, gpgme_data_t cipher, + gpgme_data_t plain); +gpgme_error_t gpgme_op_decrypt (gpgme_ctx_t ctx, + gpgme_data_t cipher, gpgme_data_t plain); + +/* Decrypt ciphertext CIPHER and make a signature verification within + CTX and store the resulting plaintext in PLAIN. */ +gpgme_error_t gpgme_op_decrypt_verify_start (gpgme_ctx_t ctx, + gpgme_data_t cipher, + gpgme_data_t plain); +gpgme_error_t gpgme_op_decrypt_verify (gpgme_ctx_t ctx, gpgme_data_t cipher, + gpgme_data_t plain); + + +/* Signing. */ +struct _gpgme_new_signature +{ + struct _gpgme_new_signature *next; + + /* The type of the signature. */ + gpgme_sig_mode_t type; + + /* The public key algorithm used to create the signature. */ + gpgme_pubkey_algo_t pubkey_algo; + + /* The hash algorithm used to create the signature. */ + gpgme_hash_algo_t hash_algo; + + /* Internal to GPGME, do not use. Must be set to the same value as + CLASS below. */ + unsigned long _obsolete_class; + + /* Signature creation time. */ + long int timestamp; + + /* The fingerprint of the signature. */ + char *fpr; + + /* Crypto backend specific signature class. */ + unsigned int class; +}; +typedef struct _gpgme_new_signature *gpgme_new_signature_t; + +struct _gpgme_op_sign_result +{ + /* The list of invalid signers. */ + gpgme_invalid_key_t invalid_signers; + gpgme_new_signature_t signatures; +}; +typedef struct _gpgme_op_sign_result *gpgme_sign_result_t; + +/* Retrieve a pointer to the result of the signing operation. */ +gpgme_sign_result_t gpgme_op_sign_result (gpgme_ctx_t ctx); + +/* Sign the plaintext PLAIN and store the signature in SIG. */ +gpgme_error_t gpgme_op_sign_start (gpgme_ctx_t ctx, + gpgme_data_t plain, gpgme_data_t sig, + gpgme_sig_mode_t mode); +gpgme_error_t gpgme_op_sign (gpgme_ctx_t ctx, + gpgme_data_t plain, gpgme_data_t sig, + gpgme_sig_mode_t mode); + + +/* Verify. */ +struct _gpgme_sig_notation +{ + struct _gpgme_sig_notation *next; + + /* If NAME is a null pointer, then VALUE contains a policy URL + rather than a notation. */ + char *name; + char *value; +}; +typedef struct _gpgme_sig_notation *gpgme_sig_notation_t; + +/* Flags used for the SUMMARY field in a gpgme_signature_t. */ +typedef enum + { + GPGME_SIGSUM_VALID = 0x0001, /* The signature is fully valid. */ + GPGME_SIGSUM_GREEN = 0x0002, /* The signature is good. */ + GPGME_SIGSUM_RED = 0x0004, /* The signature is bad. */ + GPGME_SIGSUM_KEY_REVOKED = 0x0010, /* One key has been revoked. */ + GPGME_SIGSUM_KEY_EXPIRED = 0x0020, /* One key has expired. */ + GPGME_SIGSUM_SIG_EXPIRED = 0x0040, /* The signature has expired. */ + GPGME_SIGSUM_KEY_MISSING = 0x0080, /* Can't verify: key missing. */ + GPGME_SIGSUM_CRL_MISSING = 0x0100, /* CRL not available. */ + GPGME_SIGSUM_CRL_TOO_OLD = 0x0200, /* Available CRL is too old. */ + GPGME_SIGSUM_BAD_POLICY = 0x0400, /* A policy was not met. */ + GPGME_SIGSUM_SYS_ERROR = 0x0800 /* A system error occured. */ + } +gpgme_sigsum_t; + +struct _gpgme_signature +{ + struct _gpgme_signature *next; + + /* A summary of the signature status. */ + gpgme_sigsum_t summary; + + /* The fingerprint or key ID of the signature. */ + char *fpr; + + /* The status of the signature. */ + gpgme_error_t status; + + /* Notation data and policy URLs. */ + gpgme_sig_notation_t notations; + + /* Signature creation time. */ + unsigned long timestamp; + + /* Signature exipration time or 0. */ + unsigned long exp_timestamp; + + int wrong_key_usage : 1; + + /* Internal to GPGME, do not use. */ + int _unused : 31; + + gpgme_validity_t validity; + gpgme_error_t validity_reason; +}; +typedef struct _gpgme_signature *gpgme_signature_t; + +struct _gpgme_op_verify_result +{ + gpgme_signature_t signatures; +}; +typedef struct _gpgme_op_verify_result *gpgme_verify_result_t; + +/* Retrieve a pointer to the result of the verify operation. */ +gpgme_verify_result_t gpgme_op_verify_result (gpgme_ctx_t ctx); + +/* Verify within CTX that SIG is a valid signature for TEXT. */ +gpgme_error_t gpgme_op_verify_start (gpgme_ctx_t ctx, gpgme_data_t sig, + gpgme_data_t signed_text, + gpgme_data_t plaintext); +gpgme_error_t gpgme_op_verify (gpgme_ctx_t ctx, gpgme_data_t sig, + gpgme_data_t signed_text, + gpgme_data_t plaintext); + + +/* Import. */ +enum + { + /* The key was new. */ + GPGME_IMPORT_NEW = 1, + + /* The key contained new user IDs. */ + GPGME_IMPORT_UID = 2, + + /* The key contained new signatures. */ + GPGME_IMPORT_SIG = 4, + + /* The key contained new sub keys. */ + GPGME_IMPORT_SUBKEY = 8, + + /* The key contained a secret key. */ + GPGME_IMPORT_SECRET = 16 + }; + +struct _gpgme_import_status +{ + struct _gpgme_import_status *next; + + /* Fingerprint. */ + char *fpr; + + /* If a problem occured, the reason why the key could not be + imported. Otherwise GPGME_No_Error. */ + gpgme_error_t result; + + /* The result of the import, the GPGME_IMPORT_* values bit-wise + ORed. 0 means the key was already known and no new components + have been added. */ + unsigned int status; +}; +typedef struct _gpgme_import_status *gpgme_import_status_t; + +/* Import. */ +struct _gpgme_op_import_result +{ + /* Number of considered keys. */ + int considered; + + /* Keys without user ID. */ + int no_user_id; + + /* Imported keys. */ + int imported; + + /* Imported RSA keys. */ + int imported_rsa; + + /* Unchanged keys. */ + int unchanged; + + /* Number of new user ids. */ + int new_user_ids; + + /* Number of new sub keys. */ + int new_sub_keys; + + /* Number of new signatures. */ + int new_signatures; + + /* Number of new revocations. */ + int new_revocations; + + /* Number of secret keys read. */ + int secret_read; + + /* Number of secret keys imported. */ + int secret_imported; + + /* Number of secret keys unchanged. */ + int secret_unchanged; + + /* Number of new keys skipped. */ + int skipped_new_keys; + + /* Number of keys not imported. */ + int not_imported; + + /* List of keys for which an import was attempted. */ + gpgme_import_status_t imports; +}; +typedef struct _gpgme_op_import_result *gpgme_import_result_t; + +/* Retrieve a pointer to the result of the import operation. */ +gpgme_import_result_t gpgme_op_import_result (gpgme_ctx_t ctx); + +/* Import the key in KEYDATA into the keyring. */ +gpgme_error_t gpgme_op_import_start (gpgme_ctx_t ctx, gpgme_data_t keydata); +gpgme_error_t gpgme_op_import (gpgme_ctx_t ctx, gpgme_data_t keydata); +gpgme_error_t gpgme_op_import_ext (gpgme_ctx_t ctx, gpgme_data_t keydata, + int *nr) _GPGME_DEPRECATED; + + +/* Export the keys found by PATTERN into KEYDATA. */ +gpgme_error_t gpgme_op_export_start (gpgme_ctx_t ctx, const char *pattern, + unsigned int reserved, + gpgme_data_t keydata); +gpgme_error_t gpgme_op_export (gpgme_ctx_t ctx, const char *pattern, + unsigned int reserved, gpgme_data_t keydata); + +gpgme_error_t gpgme_op_export_ext_start (gpgme_ctx_t ctx, + const char *pattern[], + unsigned int reserved, + gpgme_data_t keydata); +gpgme_error_t gpgme_op_export_ext (gpgme_ctx_t ctx, const char *pattern[], + unsigned int reserved, + gpgme_data_t keydata); + + +/* Key generation. */ +struct _gpgme_op_genkey_result +{ + /* A primary key was generated. */ + unsigned int primary : 1; + + /* A sub key was generated. */ + unsigned int sub : 1; + + /* Internal to GPGME, do not use. */ + unsigned int _unused : 30; + + /* The fingerprint of the generated key. */ + char *fpr; +}; +typedef struct _gpgme_op_genkey_result *gpgme_genkey_result_t; + +/* Generate a new keypair and add it to the keyring. PUBKEY and + SECKEY should be null for now. PARMS specifies what keys should be + generated. */ +gpgme_error_t gpgme_op_genkey_start (gpgme_ctx_t ctx, const char *parms, + gpgme_data_t pubkey, gpgme_data_t seckey); +gpgme_error_t gpgme_op_genkey (gpgme_ctx_t ctx, const char *parms, + gpgme_data_t pubkey, gpgme_data_t seckey); + +/* Retrieve a pointer to the result of the genkey operation. */ +gpgme_genkey_result_t gpgme_op_genkey_result (gpgme_ctx_t ctx); + + +/* Delete KEY from the keyring. If ALLOW_SECRET is non-zero, secret + keys are also deleted. */ +gpgme_error_t gpgme_op_delete_start (gpgme_ctx_t ctx, const gpgme_key_t key, + int allow_secret); +gpgme_error_t gpgme_op_delete (gpgme_ctx_t ctx, const gpgme_key_t key, + int allow_secret); + + +/* Edit the key KEY. Send status and command requests to FNC and + output of edit commands to OUT. */ +gpgme_error_t gpgme_op_edit_start (gpgme_ctx_t ctx, gpgme_key_t key, + gpgme_edit_cb_t fnc, void *fnc_value, + gpgme_data_t out); +gpgme_error_t gpgme_op_edit (gpgme_ctx_t ctx, gpgme_key_t key, + gpgme_edit_cb_t fnc, void *fnc_value, + gpgme_data_t out); + +/* Edit the card for the key KEY. Send status and command requests to + FNC and output of edit commands to OUT. */ +gpgme_error_t gpgme_op_card_edit_start (gpgme_ctx_t ctx, gpgme_key_t key, + gpgme_edit_cb_t fnc, void *fnc_value, + gpgme_data_t out); +gpgme_error_t gpgme_op_card_edit (gpgme_ctx_t ctx, gpgme_key_t key, + gpgme_edit_cb_t fnc, void *fnc_value, + gpgme_data_t out); + + +/* Key management functions. */ +struct _gpgme_op_keylist_result +{ + unsigned int truncated : 1; + + /* Internal to GPGME, do not use. */ + unsigned int _unused : 31; +}; +typedef struct _gpgme_op_keylist_result *gpgme_keylist_result_t; + +/* Retrieve a pointer to the result of the key listing operation. */ +gpgme_keylist_result_t gpgme_op_keylist_result (gpgme_ctx_t ctx); + +/* Start a keylist operation within CTX, searching for keys which + match PATTERN. If SECRET_ONLY is true, only secret keys are + returned. */ +gpgme_error_t gpgme_op_keylist_start (gpgme_ctx_t ctx, const char *pattern, + int secret_only); +gpgme_error_t gpgme_op_keylist_ext_start (gpgme_ctx_t ctx, + const char *pattern[], + int secret_only, int reserved); + +/* Return the next key from the keylist in R_KEY. */ +gpgme_error_t gpgme_op_keylist_next (gpgme_ctx_t ctx, gpgme_key_t *r_key); + +/* Terminate a pending keylist operation within CTX. */ +gpgme_error_t gpgme_op_keylist_end (gpgme_ctx_t ctx); + + +/* Trust items and operations. */ + +struct _gpgme_trust_item +{ + /* Internal to GPGME, do not use. */ + unsigned int _refs; + + /* The key ID to which the trust item belongs. */ + char *keyid; + + /* Internal to GPGME, do not use. */ + char _keyid[16 + 1]; + + /* The type of the trust item, 1 refers to a key, 2 to a user ID. */ + int type; + + /* The trust level. */ + int level; + + /* The owner trust if TYPE is 1. */ + char *owner_trust; + + /* Internal to GPGME, do not use. */ + char _owner_trust[2]; + + /* The calculated validity. */ + char *validity; + + /* Internal to GPGME, do not use. */ + char _validity[2]; + + /* The user name if TYPE is 2. */ + char *name; +}; +typedef struct _gpgme_trust_item *gpgme_trust_item_t; + +/* Start a trustlist operation within CTX, searching for trust items + which match PATTERN. */ +gpgme_error_t gpgme_op_trustlist_start (gpgme_ctx_t ctx, + const char *pattern, int max_level); + +/* Return the next trust item from the trustlist in R_ITEM. */ +gpgme_error_t gpgme_op_trustlist_next (gpgme_ctx_t ctx, + gpgme_trust_item_t *r_item); + +/* Terminate a pending trustlist operation within CTX. */ +gpgme_error_t gpgme_op_trustlist_end (gpgme_ctx_t ctx); + +/* Acquire a reference to ITEM. */ +void gpgme_trust_item_ref (gpgme_trust_item_t item); + +/* Release a reference to ITEM. If this was the last one the trust + item is destroyed. */ +void gpgme_trust_item_unref (gpgme_trust_item_t item); + +/* Release the trust item ITEM. Deprecated, use + gpgme_trust_item_unref. */ +void gpgme_trust_item_release (gpgme_trust_item_t item) _GPGME_DEPRECATED; + +/* Return the value of the attribute WHAT of ITEM, which has to be + representable by a string. Deprecated, use trust item structure + directly. */ +const char *gpgme_trust_item_get_string_attr (gpgme_trust_item_t item, + _gpgme_attr_t what, + const void *reserved, int idx) + _GPGME_DEPRECATED; + +/* Return the value of the attribute WHAT of KEY, which has to be + representable by an integer. IDX specifies a running index if the + attribute appears more than once in the key. Deprecated, use trust + item structure directly. */ +int gpgme_trust_item_get_int_attr (gpgme_trust_item_t item, _gpgme_attr_t what, + const void *reserved, int idx) + _GPGME_DEPRECATED; + + +/* Various functions. */ + +/* Check that the library fulfills the version requirement. */ +const char *gpgme_check_version (const char *req_version); + +/* Retrieve information about the backend engines. */ +gpgme_error_t gpgme_get_engine_info (gpgme_engine_info_t *engine_info); + + +/* Engine support functions. */ + +/* Verify that the engine implementing PROTO is installed and + available. */ +gpgme_error_t gpgme_engine_check_version (gpgme_protocol_t proto); + + +/* Deprecated types. */ +typedef gpgme_ctx_t GpgmeCtx _GPGME_DEPRECATED; +typedef gpgme_data_t GpgmeData _GPGME_DEPRECATED; +typedef gpgme_error_t GpgmeError _GPGME_DEPRECATED; +typedef gpgme_data_encoding_t GpgmeDataEncoding _GPGME_DEPRECATED; +typedef gpgme_pubkey_algo_t GpgmePubKeyAlgo _GPGME_DEPRECATED; +typedef gpgme_hash_algo_t GpgmeHashAlgo _GPGME_DEPRECATED; +typedef gpgme_sig_stat_t GpgmeSigStat _GPGME_DEPRECATED; +typedef gpgme_sig_mode_t GpgmeSigMode _GPGME_DEPRECATED; +typedef gpgme_attr_t GpgmeAttr _GPGME_DEPRECATED; +typedef gpgme_validity_t GpgmeValidity _GPGME_DEPRECATED; +typedef gpgme_protocol_t GpgmeProtocol _GPGME_DEPRECATED; +typedef gpgme_engine_info_t GpgmeEngineInfo _GPGME_DEPRECATED; +typedef gpgme_subkey_t GpgmeSubkey _GPGME_DEPRECATED; +typedef gpgme_key_sig_t GpgmeKeySig _GPGME_DEPRECATED; +typedef gpgme_user_id_t GpgmeUserID _GPGME_DEPRECATED; +typedef gpgme_key_t GpgmeKey _GPGME_DEPRECATED; +typedef gpgme_passphrase_cb_t GpgmePassphraseCb _GPGME_DEPRECATED; +typedef gpgme_progress_cb_t GpgmeProgressCb _GPGME_DEPRECATED; +typedef gpgme_io_cb_t GpgmeIOCb _GPGME_DEPRECATED; +typedef gpgme_register_io_cb_t GpgmeRegisterIOCb _GPGME_DEPRECATED; +typedef gpgme_remove_io_cb_t GpgmeRemoveIOCb _GPGME_DEPRECATED; +typedef gpgme_event_io_t GpgmeEventIO _GPGME_DEPRECATED; +typedef gpgme_event_io_cb_t GpgmeEventIOCb _GPGME_DEPRECATED; +#define GpgmeIOCbs gpgme_io_cbs +typedef gpgme_data_read_cb_t GpgmeDataReadCb _GPGME_DEPRECATED; +typedef gpgme_data_write_cb_t GpgmeDataWriteCb _GPGME_DEPRECATED; +typedef gpgme_data_seek_cb_t GpgmeDataSeekCb _GPGME_DEPRECATED; +typedef gpgme_data_release_cb_t GpgmeDataReleaseCb _GPGME_DEPRECATED; +#define GpgmeDataCbs gpgme_data_cbs +typedef gpgme_encrypt_result_t GpgmeEncryptResult _GPGME_DEPRECATED; +typedef gpgme_sig_notation_t GpgmeSigNotation _GPGME_DEPRECATED; +typedef gpgme_signature_t GpgmeSignature _GPGME_DEPRECATED; +typedef gpgme_verify_result_t GpgmeVerifyResult _GPGME_DEPRECATED; +typedef gpgme_import_status_t GpgmeImportStatus _GPGME_DEPRECATED; +typedef gpgme_import_result_t GpgmeImportResult _GPGME_DEPRECATED; +typedef gpgme_genkey_result_t GpgmeGenKeyResult _GPGME_DEPRECATED; +typedef gpgme_trust_item_t GpgmeTrustItem _GPGME_DEPRECATED; +typedef gpgme_status_code_t GpgmeStatusCode _GPGME_DEPRECATED; + +#ifdef __cplusplus +} +#endif +#endif /* GPGME_H */ diff --git a/tags/gpgme-0-4-3/gpgme/gpgme.m4 b/tags/gpgme-0-4-3/gpgme/gpgme.m4 new file mode 100644 index 0000000..5cdbca8 --- /dev/null +++ b/tags/gpgme-0-4-3/gpgme/gpgme.m4 @@ -0,0 +1,167 @@ +dnl Autoconf macros for libgpgme +dnl $Id$ + +AC_DEFUN(_AM_PATH_GPGME_CONFIG, +[ AC_ARG_WITH(gpgme-prefix, + AC_HELP_STRING([--with-gpgme-prefix=PFX], + [prefix where GPGME is installed (optional)]), + gpgme_config_prefix="$withval", gpgme_config_prefix="") + if test "x$gpgme_config_prefix" != x ; then + GPGME_CONFIG="$gpgme_config_prefix/bin/gpgme-config" + fi + AC_PATH_PROG(GPGME_CONFIG, gpgme-config, no) + + gpgme_version=`$GPGME_CONFIG --version` + gpgme_version_major=`echo $gpgme_version | \ + sed 's/\([[0-9]]*\)\.\([[0-9]]*\)\.\([[0-9]]*\).*/\1/'` + gpgme_version_minor=`echo $gpgme_version | \ + sed 's/\([[0-9]]*\)\.\([[0-9]]*\)\.\([[0-9]]*\).*/\2/'` + gpgme_version_micro=`echo $gpgme_version | \ + sed 's/\([[0-9]]*\)\.\([[0-9]]*\)\.\([[0-9]]*\).*/\3/'` +]) + +dnl AM_PATH_GPGME([MINIMUM-VERSION, +dnl [ACTION-IF-FOUND [, ACTION-IF-NOT-FOUND ]]]) +dnl Test for libgpgme and define GPGME_CFLAGS and GPGME_LIBS. +dnl +AC_DEFUN([AM_PATH_GPGME], +[ AC_REQUIRE([_AM_PATH_GPGME_CONFIG])dnl + min_gpgme_version=ifelse([$1], ,0.4.2,$1) + AC_MSG_CHECKING(for GPGME - version >= $min_gpgme_version) + ok=no + if test "$GPGME_CONFIG" != "no" ; then + req_major=`echo $min_gpgme_version | \ + sed 's/\([[0-9]]*\)\.\([[0-9]]*\)\.\([[0-9]]*\)/\1/'` + req_minor=`echo $min_gpgme_version | \ + sed 's/\([[0-9]]*\)\.\([[0-9]]*\)\.\([[0-9]]*\)/\2/'` + req_micro=`echo $min_gpgme_version | \ + sed 's/\([[0-9]]*\)\.\([[0-9]]*\)\.\([[0-9]]*\)/\3/'` + if test "$gpgme_version_major" -gt "$req_major"; then + ok=yes + else + if test "$gpgme_version_major" -eq "$req_major"; then + if test "$gpgme_version_minor" -gt "$req_minor"; then + ok=yes + else + if test "$gpgme_version_minor" -eq "$req_minor"; then + if test "$gpgme_version_micro" -ge "$req_micro"; then + ok=yes + fi + fi + fi + fi + fi + fi + if test $ok = yes; then + GPGME_CFLAGS=`$GPGME_CONFIG --cflags` + GPGME_LIBS=`$GPGME_CONFIG --libs` + AC_MSG_RESULT(yes) + ifelse([$2], , :, [$2]) + else + GPGME_CFLAGS="" + GPGME_LIBS="" + AC_MSG_RESULT(no) + ifelse([$3], , :, [$3]) + fi + AC_SUBST(GPGME_CFLAGS) + AC_SUBST(GPGME_LIBS) +]) + +dnl AM_PATH_GPGME_PTH([MINIMUM-VERSION, +dnl [ACTION-IF-FOUND [, ACTION-IF-NOT-FOUND ]]]) +dnl Test for libgpgme and define GPGME_PTH_CFLAGS and GPGME_PTH_LIBS. +dnl +AC_DEFUN([AM_PATH_GPGME_PTH], +[ AC_REQUIRE([_AM_PATH_GPGME_CONFIG])dnl + min_gpgme_version=ifelse([$1], ,0.4.2,$1) + AC_MSG_CHECKING(for GPGME Pth - version >= $min_gpgme_version) + ok=no + if test "$GPGME_CONFIG" != "no" ; then + if `$GPGME_CONFIG --thread=pth 2> /dev/null` ; then + req_major=`echo $min_gpgme_version | \ + sed 's/\([[0-9]]*\)\.\([[0-9]]*\)\.\([[0-9]]*\)/\1/'` + req_minor=`echo $min_gpgme_version | \ + sed 's/\([[0-9]]*\)\.\([[0-9]]*\)\.\([[0-9]]*\)/\2/'` + req_micro=`echo $min_gpgme_version | \ + sed 's/\([[0-9]]*\)\.\([[0-9]]*\)\.\([[0-9]]*\)/\3/'` + if test "$gpgme_version_major" -gt "$req_major"; then + ok=yes + else + if test "$gpgme_version_major" -eq "$req_major"; then + if test "$gpgme_version_minor" -gt "$req_minor"; then + ok=yes + else + if test "$gpgme_version_minor" -eq "$req_minor"; then + if test "$gpgme_version_micro" -ge "$req_micro"; then + ok=yes + fi + fi + fi + fi + fi + fi + fi + if test $ok = yes; then + GPGME_PTH_CFLAGS=`$GPGME_CONFIG --thread=pth --cflags` + GPGME_PTH_LIBS=`$GPGME_CONFIG --thread=pth --libs` + AC_MSG_RESULT(yes) + ifelse([$2], , :, [$2]) + else + GPGME_PTH_CFLAGS="" + GPGME_PTH_LIBS="" + AC_MSG_RESULT(no) + ifelse([$3], , :, [$3]) + fi + AC_SUBST(GPGME_PTH_CFLAGS) + AC_SUBST(GPGME_PTH_LIBS) +]) + +dnl AM_PATH_GPGME_PTHREAD([MINIMUM-VERSION, +dnl [ACTION-IF-FOUND [, ACTION-IF-NOT-FOUND ]]]) +dnl Test for libgpgme and define GPGME_PTHREAD_CFLAGS +dnl and GPGME_PTHREAD_LIBS. +dnl +AC_DEFUN([AM_PATH_GPGME_PTHREAD], +[ AC_REQUIRE([_AM_PATH_GPGME_CONFIG])dnl + min_gpgme_version=ifelse([$1], ,0.4.2,$1) + AC_MSG_CHECKING(for GPGME pthread - version >= $min_gpgme_version) + ok=no + if test "$GPGME_CONFIG" != "no" ; then + if `$GPGME_CONFIG --thread=pthread 2> /dev/null` ; then + req_major=`echo $min_gpgme_version | \ + sed 's/\([[0-9]]*\)\.\([[0-9]]*\)\.\([[0-9]]*\)/\1/'` + req_minor=`echo $min_gpgme_version | \ + sed 's/\([[0-9]]*\)\.\([[0-9]]*\)\.\([[0-9]]*\)/\2/'` + req_micro=`echo $min_gpgme_version | \ + sed 's/\([[0-9]]*\)\.\([[0-9]]*\)\.\([[0-9]]*\)/\3/'` + if test "$gpgme_version_major" -gt "$req_major"; then + ok=yes + else + if test "$gpgme_version_major" -eq "$req_major"; then + if test "$gpgme_version_minor" -gt "$req_minor"; then + ok=yes + else + if test "$gpgme_version_minor" -eq "$req_minor"; then + if test "$gpgme_version_micro" -ge "$req_micro"; then + ok=yes + fi + fi + fi + fi + fi + fi + fi + if test $ok = yes; then + GPGME_PTHREAD_CFLAGS=`$GPGME_CONFIG --thread=pthread --cflags` + GPGME_PTHREAD_LIBS=`$GPGME_CONFIG --thread=pthread --libs` + AC_MSG_RESULT(yes) + ifelse([$2], , :, [$2]) + else + GPGME_PTHREAD_CFLAGS="" + GPGME_PTHREAD_LIBS="" + AC_MSG_RESULT(no) + ifelse([$3], , :, [$3]) + fi + AC_SUBST(GPGME_PTHREAD_CFLAGS) + AC_SUBST(GPGME_PTHREAD_LIBS) +]) diff --git a/tags/gpgme-0-4-3/gpgme/import.c b/tags/gpgme-0-4-3/gpgme/import.c new file mode 100644 index 0000000..46ae72e --- /dev/null +++ b/tags/gpgme-0-4-3/gpgme/import.c @@ -0,0 +1,272 @@ +/* import.c - Import a key. + Copyright (C) 2000 Werner Koch (dd9jn) + Copyright (C) 2001, 2002, 2003 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 + 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. */ + +#if HAVE_CONFIG_H +#include +#endif +#include +#include +#include + +#include "gpgme.h" +#include "context.h" +#include "ops.h" + + +typedef struct +{ + struct _gpgme_op_import_result result; + + /* A pointer to the next pointer of the last import status in the + list. This makes appending new imports painless while preserving + the order. */ + gpgme_import_status_t *lastp; +} *op_data_t; + + +static void +release_op_data (void *hook) +{ + op_data_t opd = (op_data_t) hook; + gpgme_import_status_t import = opd->result.imports; + + while (import) + { + gpgme_import_status_t next = import->next; + free (import->fpr); + free (import); + import = next; + } +} + + +gpgme_import_result_t +gpgme_op_import_result (gpgme_ctx_t ctx) +{ + void *hook; + op_data_t opd; + gpgme_error_t err; + + err = _gpgme_op_data_lookup (ctx, OPDATA_IMPORT, &hook, -1, NULL); + opd = hook; + if (err || !opd) + return NULL; + + return &opd->result; +} + + +static gpgme_error_t +parse_import (char *args, gpgme_import_status_t *import_status, int problem) +{ + gpgme_import_status_t import; + char *tail; + long int nr; + + import = malloc (sizeof (*import)); + if (!import) + return gpg_error_from_errno (errno); + import->next = NULL; + + errno = 0; + nr = strtol (args, &tail, 0); + if (errno || args == tail || *tail != ' ') + { + /* The crypto backend does not behave. */ + free (import); + return gpg_error (GPG_ERR_INV_ENGINE); + } + args = tail; + + if (problem) + { + switch (nr) + { + case 0: + case 4: + default: + import->result = gpg_error (GPG_ERR_GENERAL); + break; + + case 1: + import->result = gpg_error (GPG_ERR_BAD_CERT); + break; + + case 2: + import->result = gpg_error (GPG_ERR_MISSING_CERT); + break; + + case 3: + import->result = gpg_error (GPG_ERR_BAD_CERT_CHAIN); + break; + } + import->status = 0; + } + else + { + import->result = gpg_error (GPG_ERR_NO_ERROR); + import->status = nr; + } + + while (*args == ' ') + args++; + tail = strchr (args, ' '); + if (tail) + *tail = '\0'; + + import->fpr = strdup (args); + if (!import->fpr) + { + int saved_errno = errno; + free (import); + return gpg_error_from_errno (saved_errno); + } + + *import_status = import; + return 0; +} + + + +gpgme_error_t +parse_import_res (char *args, gpgme_import_result_t result) +{ + char *tail; + + errno = 0; + +#define PARSE_NEXT(x) \ + (x) = strtol (args, &tail, 0); \ + if (errno || args == tail || *tail != ' ') \ + /* The crypto backend does not behave. */ \ + return gpg_error (GPG_ERR_INV_ENGINE); \ + args = tail; + + PARSE_NEXT (result->considered); + PARSE_NEXT (result->no_user_id); + PARSE_NEXT (result->imported); + PARSE_NEXT (result->imported_rsa); + PARSE_NEXT (result->unchanged); + PARSE_NEXT (result->new_user_ids); + PARSE_NEXT (result->new_sub_keys); + PARSE_NEXT (result->new_signatures); + PARSE_NEXT (result->new_revocations); + PARSE_NEXT (result->secret_read); + PARSE_NEXT (result->secret_imported); + PARSE_NEXT (result->secret_unchanged); + PARSE_NEXT (result->skipped_new_keys); + PARSE_NEXT (result->not_imported); + + return 0; +} + + +static gpgme_error_t +import_status_handler (void *priv, gpgme_status_code_t code, char *args) +{ + gpgme_ctx_t ctx = (gpgme_ctx_t) priv; + gpgme_error_t err; + void *hook; + op_data_t opd; + + err = _gpgme_op_data_lookup (ctx, OPDATA_IMPORT, &hook, -1, NULL); + opd = hook; + if (err) + return err; + + switch (code) + { + case GPGME_STATUS_IMPORT_OK: + case GPGME_STATUS_IMPORT_PROBLEM: + err = parse_import (args, opd->lastp, + code == GPGME_STATUS_IMPORT_OK ? 0 : 1); + if (err) + return err; + + opd->lastp = &(*opd->lastp)->next; + break; + + case GPGME_STATUS_IMPORT_RES: + err = parse_import_res (args, &opd->result); + break; + + default: + break; + } + return 0; +} + + +static gpgme_error_t +_gpgme_op_import_start (gpgme_ctx_t ctx, int synchronous, gpgme_data_t keydata) +{ + gpgme_error_t err; + void *hook; + op_data_t opd; + + err = _gpgme_op_reset (ctx, synchronous); + if (err) + return err; + + err = _gpgme_op_data_lookup (ctx, OPDATA_IMPORT, &hook, + sizeof (*opd), release_op_data); + opd = hook; + if (err) + return err; + opd->lastp = &opd->result.imports; + + if (!keydata) + return gpg_error (GPG_ERR_NO_DATA); + + _gpgme_engine_set_status_handler (ctx->engine, import_status_handler, ctx); + + return _gpgme_engine_op_import (ctx->engine, keydata); +} + + +gpgme_error_t +gpgme_op_import_start (gpgme_ctx_t ctx, gpgme_data_t keydata) +{ + return _gpgme_op_import_start (ctx, 0, keydata); +} + + +/* Import the key in KEYDATA into the keyring. */ +gpgme_error_t +gpgme_op_import (gpgme_ctx_t ctx, gpgme_data_t keydata) +{ + gpgme_error_t err = _gpgme_op_import_start (ctx, 1, keydata); + if (!err) + err = _gpgme_wait_one (ctx); + return err; +} + + +gpgme_error_t +gpgme_op_import_ext (gpgme_ctx_t ctx, gpgme_data_t keydata, int *nr) +{ + gpgme_error_t err = gpgme_op_import (ctx, keydata); + if (!err && nr) + { + gpgme_import_result_t result = gpgme_op_import_result (ctx); + *nr = result->considered; + } + return err; +} diff --git a/tags/gpgme-0-4-3/gpgme/io.h b/tags/gpgme-0-4-3/gpgme/io.h new file mode 100644 index 0000000..9cc5eb2 --- /dev/null +++ b/tags/gpgme-0-4-3/gpgme/io.h @@ -0,0 +1,65 @@ +/* io.h - Interface to the I/O functions. + Copyright (C) 2000 Werner Koch (dd9jn) + Copyright (C) 2001, 2002, 2003 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 + 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. */ + +#ifndef IO_H +#define IO_H + +/* A single file descriptor passed to spawn. For child fds, dup_to + specifies the fd it should become in the child. */ +struct spawn_fd_item_s +{ + int fd; + int dup_to; +}; + +struct io_select_fd_s +{ + int fd; + int for_read; + int for_write; + int signaled; + int frozen; + void *opaque; +}; + +/* These function are either defined in posix-io.c or w32-io.c. */ +void _gpgme_io_subsystem_init (void); +int _gpgme_io_read (int fd, void *buffer, size_t count); +int _gpgme_io_write (int fd, const void *buffer, size_t count); +int _gpgme_io_pipe (int filedes[2], int inherit_idx); +int _gpgme_io_close (int fd); +int _gpgme_io_set_close_notify (int fd, void (*handler) (int, void *), + void *value); +int _gpgme_io_set_nonblocking (int fd); + +/* Spawn the executable PATH with ARGV as arguments, after forking + close all fds in FD_PARENT_LIST in the parent and close or dup all + fds in FD_CHILD_LIST in the child. */ +int _gpgme_io_spawn (const char *path, char **argv, + struct spawn_fd_item_s *fd_child_list, + struct spawn_fd_item_s *fd_parent_list); +int _gpgme_io_waitpid (int pid, int hang, int *r_status, int *r_signal); +int _gpgme_io_kill (int pid, int hard); +int _gpgme_io_select (struct io_select_fd_s *fds, size_t nfds, int nonblock); + +#endif /* IO_H */ + + + diff --git a/tags/gpgme-0-4-3/gpgme/isascii.c b/tags/gpgme-0-4-3/gpgme/isascii.c new file mode 100644 index 0000000..565c716 --- /dev/null +++ b/tags/gpgme-0-4-3/gpgme/isascii.c @@ -0,0 +1,29 @@ +/* isascii.c - Replacement for isascii. + * Copyright (C) 2002 Free Software Foundation, Inc. + * + * This file is part of GnuPG. + * + * GnuPG 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. + * + * GnuPG 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA + */ + +#ifdef HAVE_CONFIG_H +#include +#endif + +int +isascii (int c) +{ + return (((c) & ~0x7f) == 0); +} diff --git a/tags/gpgme-0-4-3/gpgme/key.c b/tags/gpgme-0-4-3/gpgme/key.c new file mode 100644 index 0000000..3c0d736 --- /dev/null +++ b/tags/gpgme-0-4-3/gpgme/key.c @@ -0,0 +1,706 @@ +/* key.c - Key objects. + Copyright (C) 2000 Werner Koch (dd9jn) + Copyright (C) 2001, 2002, 2003 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 + 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. */ + +#if HAVE_CONFIG_H +#include +#endif +#include +#include +#include +#include + +#include "util.h" +#include "ops.h" +#include "sema.h" + + +/* Protects all reference counters in keys. All other accesses to a + key are read only. */ +DEFINE_STATIC_LOCK (key_ref_lock); + + +/* Create a new key. */ +gpgme_error_t +_gpgme_key_new (gpgme_key_t *r_key) +{ + gpgme_key_t key; + + key = calloc (1, sizeof *key); + if (!key) + return gpg_error_from_errno (errno); + key->_refs = 1; + + *r_key = key; + return 0; +} + + +gpgme_error_t +_gpgme_key_add_subkey (gpgme_key_t key, gpgme_subkey_t *r_subkey) +{ + gpgme_subkey_t subkey; + + subkey = calloc (1, sizeof *subkey); + if (!subkey) + return gpg_error_from_errno (errno); + subkey->keyid = subkey->_keyid; + subkey->_keyid[16] = '\0'; + + if (!key->subkeys) + key->subkeys = subkey; + if (key->_last_subkey) + key->_last_subkey->next = subkey; + key->_last_subkey = subkey; + + *r_subkey = subkey; + return 0; +} + + +static char * +set_user_id_part (char *tail, const char *buf, size_t len) +{ + while (len && (buf[len - 1] == ' ' || buf[len - 1] == '\t')) + len--; + for (; len; len--) + *tail++ = *buf++; + *tail++ = 0; + return tail; +} + + +static void +parse_user_id (char *src, char **name, char **email, + char **comment, char *tail) +{ + const char *start = NULL; + int in_name = 0; + int in_email = 0; + int in_comment = 0; + + while (*src) + { + if (in_email) + { + if (*src == '<') + /* Not legal but anyway. */ + in_email++; + else if (*src == '>') + { + if (!--in_email && !*email) + { + *email = tail; + tail = set_user_id_part (tail, start, src - start); + } + } + } + else if (in_comment) + { + if (*src == '(') + in_comment++; + else if (*src == ')') + { + if (!--in_comment && !*comment) + { + *comment = tail; + tail = set_user_id_part (tail, start, src - start); + } + } + } + else if (*src == '<') + { + if (in_name) + { + if (!*name) + { + *name = tail; + tail = set_user_id_part (tail, start, src - start); + } + in_name = 0; + } + in_email = 1; + start = src + 1; + } + else if (*src == '(') + { + if (in_name) + { + if (!*name) + { + *name = tail; + tail = set_user_id_part (tail, start, src - start); + } + in_name = 0; + } + in_comment = 1; + start = src + 1; + } + else if (!in_name && *src != ' ' && *src != '\t') + { + in_name = 1; + start = src; + } + src++; + } + + if (in_name) + { + if (!*name) + { + *name = tail; + tail = set_user_id_part (tail, start, src - start); + } + } + + /* Let unused parts point to an EOS. */ + tail--; + if (!*name) + *name = tail; + if (!*email) + *email = tail; + if (!*comment) + *comment = tail; +} + + +static void +parse_x509_user_id (char *src, char **name, char **email, + char **comment, char *tail) +{ + if (*src == '<' && src[strlen (src) - 1] == '>') + *email = src; + + /* Let unused parts point to an EOS. */ + tail--; + if (!*name) + *name = tail; + if (!*email) + *email = tail; + if (!*comment) + *comment = tail; +} + + +/* Take a name from the --with-colon listing, remove certain escape + sequences sequences and put it into the list of UIDs. */ +gpgme_error_t +_gpgme_key_append_name (gpgme_key_t key, char *src) +{ + gpgme_user_id_t uid; + char *dst; + int src_len = strlen (src); + + assert (key); + /* We can malloc a buffer of the same length, because the converted + string will never be larger. Actually we allocate it twice the + size, so that we are able to store the parsed stuff there too. */ + uid = malloc (sizeof (*uid) + 2 * src_len + 3); + if (!uid) + return gpg_error_from_errno (errno); + memset (uid, 0, sizeof *uid); + + uid->uid = ((char *) uid) + sizeof (*uid); + dst = uid->uid; + _gpgme_decode_c_string (src, &dst, src_len + 1); + + dst += src_len + 1; + if (key->protocol == GPGME_PROTOCOL_CMS) + parse_x509_user_id (uid->uid, &uid->name, &uid->email, + &uid->comment, dst); + else + parse_user_id (uid->uid, &uid->name, &uid->email, + &uid->comment, dst); + + if (!key->uids) + key->uids = uid; + if (key->_last_uid) + key->_last_uid->next = uid; + key->_last_uid = uid; + + return 0; +} + + +gpgme_key_sig_t +_gpgme_key_add_sig (gpgme_key_t key, char *src) +{ + int src_len = src ? strlen (src) : 0; + gpgme_user_id_t uid; + gpgme_key_sig_t sig; + + assert (key); /* XXX */ + + uid = key->_last_uid; + assert (uid); /* XXX */ + + /* We can malloc a buffer of the same length, because the converted + string will never be larger. Actually we allocate it twice the + size, so that we are able to store the parsed stuff there too. */ + sig = calloc (1, sizeof (*sig) + 2 * src_len + 3); + if (!sig) + return NULL; + sig->keyid = sig->_keyid; + sig->_keyid[16] = '\0'; + sig->uid = ((char *) sig) + sizeof (*sig); + + if (src) + { + char *dst = sig->uid; + _gpgme_decode_c_string (src, &dst, src_len + 1); + dst += src_len + 1; + if (key->protocol == GPGME_PROTOCOL_CMS) + parse_x509_user_id (sig->uid, &sig->name, &sig->email, + &sig->comment, dst); + else + parse_user_id (sig->uid, &sig->name, &sig->email, + &sig->comment, dst); + } + + if (!uid->signatures) + uid->signatures = sig; + if (uid->_last_keysig) + uid->_last_keysig->next = sig; + uid->_last_keysig = sig; + + return sig; +} + + +/* Acquire a reference to KEY. */ +void +gpgme_key_ref (gpgme_key_t key) +{ + LOCK (key_ref_lock); + key->_refs++; + UNLOCK (key_ref_lock); +} + + +/* gpgme_key_unref releases the key object. Note, that this function + may not do an actual release if there are other shallow copies of + the objects. You have to call this function for every newly + created key object as well as for every gpgme_key_ref() done on the + key object. */ +void +gpgme_key_unref (gpgme_key_t key) +{ + gpgme_user_id_t uid; + gpgme_subkey_t subkey; + + LOCK (key_ref_lock); + assert (key->_refs > 0); + if (--key->_refs) + { + UNLOCK (key_ref_lock); + return; + } + UNLOCK (key_ref_lock); + + subkey = key->subkeys; + while (subkey) + { + gpgme_subkey_t next = subkey->next; + if (subkey->fpr) + free (subkey->fpr); + free (subkey); + subkey = next; + } + + uid = key->uids; + while (uid) + { + gpgme_user_id_t next_uid = uid->next; + gpgme_key_sig_t keysig = uid->signatures; + + while (keysig) + { + gpgme_key_sig_t next = keysig->next; + free (keysig); + keysig = next; + } + free (uid); + uid = next_uid; + } + + if (key->issuer_serial) + free (key->issuer_serial); + if (key->issuer_name) + free (key->issuer_name); + + if (key->chain_id) + free (key->chain_id); + + free (key); +} + + +/* Compatibility interfaces. */ + +void +gpgme_key_release (gpgme_key_t key) +{ + gpgme_key_unref (key); +} + + +static const char * +otrust_to_string (int otrust) +{ + switch (otrust) + { + case GPGME_VALIDITY_NEVER: + return "n"; + + case GPGME_VALIDITY_MARGINAL: + return "m"; + + case GPGME_VALIDITY_FULL: + return "f"; + + case GPGME_VALIDITY_ULTIMATE: + return "u"; + + default: + return "?"; + } +} + + +static const char * +validity_to_string (int validity) +{ + switch (validity) + { + case GPGME_VALIDITY_UNDEFINED: + return "q"; + + case GPGME_VALIDITY_NEVER: + return "n"; + + case GPGME_VALIDITY_MARGINAL: + return "m"; + + case GPGME_VALIDITY_FULL: + return "f"; + + case GPGME_VALIDITY_ULTIMATE: + return "u"; + + case GPGME_VALIDITY_UNKNOWN: + default: + return "?"; + } +} + + +static const char * +capabilities_to_string (gpgme_subkey_t subkey) +{ + static const char *const strings[8] = + { + "", + "c", + "s", + "sc", + "e", + "ec", + "es", + "esc" + }; + return strings[(!!subkey->can_encrypt << 2) + | (!!subkey->can_sign << 1) + | (!!subkey->can_certify)]; +} + + +/* Return the value of the attribute WHAT of ITEM, which has to be + representable by a string. */ +const char * +gpgme_key_get_string_attr (gpgme_key_t key, _gpgme_attr_t what, + const void *reserved, int idx) +{ + gpgme_subkey_t subkey; + gpgme_user_id_t uid; + int i; + + if (!key || reserved || idx < 0) + return NULL; + + /* Select IDXth subkey. */ + subkey = key->subkeys; + for (i = 0; i < idx; i++) + { + subkey = subkey->next; + if (!subkey) + break; + } + + /* Select the IDXth user ID. */ + uid = key->uids; + for (i = 0; i < idx; i++) + { + uid = uid->next; + if (!uid) + break; + } + + switch (what) + { + case GPGME_ATTR_KEYID: + return subkey ? subkey->keyid : NULL; + + case GPGME_ATTR_FPR: + return subkey ? subkey->fpr : NULL; + + case GPGME_ATTR_ALGO: + return subkey ? gpgme_pubkey_algo_name (subkey->pubkey_algo) : NULL; + + case GPGME_ATTR_TYPE: + return key->protocol == GPGME_PROTOCOL_CMS ? "X.509" : "PGP"; + + case GPGME_ATTR_OTRUST: + return otrust_to_string (key->owner_trust); + + case GPGME_ATTR_USERID: + return uid ? uid->uid : NULL; + + case GPGME_ATTR_NAME: + return uid ? uid->name : NULL; + + case GPGME_ATTR_EMAIL: + return uid ? uid->email : NULL; + + case GPGME_ATTR_COMMENT: + return uid ? uid->comment : NULL; + + case GPGME_ATTR_VALIDITY: + return uid ? validity_to_string (uid->validity) : NULL; + + case GPGME_ATTR_KEY_CAPS: + return subkey ? capabilities_to_string (subkey) : NULL; + + case GPGME_ATTR_SERIAL: + return key->issuer_serial; + + case GPGME_ATTR_ISSUER: + return idx ? NULL : key->issuer_name; + + case GPGME_ATTR_CHAINID: + return key->chain_id; + + default: + return NULL; + } +} + + +unsigned long +gpgme_key_get_ulong_attr (gpgme_key_t key, _gpgme_attr_t what, + const void *reserved, int idx) +{ + gpgme_subkey_t subkey; + gpgme_user_id_t uid; + int i; + + if (!key || reserved || idx < 0) + return 0; + + /* Select IDXth subkey. */ + subkey = key->subkeys; + for (i = 0; i < idx; i++) + { + subkey = subkey->next; + if (!subkey) + break; + } + + /* Select the IDXth user ID. */ + uid = key->uids; + for (i = 0; i < idx; i++) + { + uid = uid->next; + if (!uid) + break; + } + + switch (what) + { + case GPGME_ATTR_ALGO: + return subkey ? (unsigned long) subkey->pubkey_algo : 0; + + case GPGME_ATTR_LEN: + return subkey ? (unsigned long) subkey->length : 0; + + case GPGME_ATTR_TYPE: + return key->protocol == GPGME_PROTOCOL_CMS ? 1 : 0; + + case GPGME_ATTR_CREATED: + return (subkey && subkey->timestamp >= 0) + ? (unsigned long) subkey->timestamp : 0; + + case GPGME_ATTR_EXPIRE: + return (subkey && subkey->expires >= 0) + ? (unsigned long) subkey->expires : 0; + + case GPGME_ATTR_VALIDITY: + return uid ? uid->validity : 0; + + case GPGME_ATTR_OTRUST: + return key->owner_trust; + + case GPGME_ATTR_IS_SECRET: + return !!key->secret; + + case GPGME_ATTR_KEY_REVOKED: + return subkey ? subkey->revoked : 0; + + case GPGME_ATTR_KEY_INVALID: + return subkey ? subkey->invalid : 0; + + case GPGME_ATTR_KEY_EXPIRED: + return subkey ? subkey->expired : 0; + + case GPGME_ATTR_KEY_DISABLED: + return subkey ? subkey->disabled : 0; + + case GPGME_ATTR_UID_REVOKED: + return uid ? uid->revoked : 0; + + case GPGME_ATTR_UID_INVALID: + return uid ? uid->invalid : 0; + + case GPGME_ATTR_CAN_ENCRYPT: + return key->can_encrypt; + + case GPGME_ATTR_CAN_SIGN: + return key->can_sign; + + case GPGME_ATTR_CAN_CERTIFY: + return key->can_certify; + + default: + return 0; + } +} + + +static gpgme_key_sig_t +get_keysig (gpgme_key_t key, int uid_idx, int idx) +{ + gpgme_user_id_t uid; + gpgme_key_sig_t sig; + + if (!key || uid_idx < 0 || idx < 0) + return NULL; + + uid = key->uids; + while (uid && uid_idx > 0) + { + uid = uid->next; + uid_idx--; + } + if (!uid) + return NULL; + + sig = uid->signatures; + while (sig && idx > 0) + { + sig = sig->next; + idx--; + } + return sig; +} + + +const char * +gpgme_key_sig_get_string_attr (gpgme_key_t key, int uid_idx, + _gpgme_attr_t what, + const void *reserved, int idx) +{ + gpgme_key_sig_t certsig = get_keysig (key, uid_idx, idx); + + if (!certsig || reserved) + return NULL; + + switch (what) + { + case GPGME_ATTR_KEYID: + return certsig->keyid; + + case GPGME_ATTR_ALGO: + return gpgme_pubkey_algo_name (certsig->pubkey_algo); + + case GPGME_ATTR_USERID: + return certsig->uid; + + case GPGME_ATTR_NAME: + return certsig->name; + + case GPGME_ATTR_EMAIL: + return certsig->email; + + case GPGME_ATTR_COMMENT: + return certsig->comment; + + default: + return NULL; + } +} + + +unsigned long +gpgme_key_sig_get_ulong_attr (gpgme_key_t key, int uid_idx, _gpgme_attr_t what, + const void *reserved, int idx) +{ + gpgme_key_sig_t certsig = get_keysig (key, uid_idx, idx); + + if (!certsig || reserved) + return 0; + + switch (what) + { + case GPGME_ATTR_ALGO: + return (unsigned long) certsig->pubkey_algo; + + case GPGME_ATTR_CREATED: + return certsig->timestamp < 0 ? 0L : (unsigned long) certsig->timestamp; + + case GPGME_ATTR_EXPIRE: + return certsig->expires < 0 ? 0L : (unsigned long) certsig->expires; + + case GPGME_ATTR_KEY_REVOKED: + return certsig->revoked; + + case GPGME_ATTR_KEY_INVALID: + return certsig->invalid; + + case GPGME_ATTR_KEY_EXPIRED: + return certsig->expired; + + case GPGME_ATTR_SIG_CLASS: + return certsig->class; + + case GPGME_ATTR_SIG_STATUS: + return certsig->status; + + default: + return 0; + } +} diff --git a/tags/gpgme-0-4-3/gpgme/keylist.c b/tags/gpgme-0-4-3/gpgme/keylist.c new file mode 100644 index 0000000..07c9385 --- /dev/null +++ b/tags/gpgme-0-4-3/gpgme/keylist.c @@ -0,0 +1,882 @@ +/* keylist.c - Listing keys. + Copyright (C) 2000 Werner Koch (dd9jn) + Copyright (C) 2001, 2002, 2003 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 + 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. */ + +#if HAVE_CONFIG_H +#include +#endif +#include +#include +#include +#include +#include +#include +#include + +#include "gpgme.h" +#include "util.h" +#include "context.h" +#include "ops.h" +#include "debug.h" + + +struct key_queue_item_s +{ + struct key_queue_item_s *next; + gpgme_key_t key; +}; + +typedef struct +{ + struct _gpgme_op_keylist_result result; + + gpgme_key_t tmp_key; + gpgme_user_id_t tmp_uid; + /* Something new is available. */ + int key_cond; + struct key_queue_item_s *key_queue; +} *op_data_t; + + +static void +release_op_data (void *hook) +{ + op_data_t opd = (op_data_t) hook; + struct key_queue_item_s *key = opd->key_queue; + + if (opd->tmp_key) + gpgme_key_unref (opd->tmp_key); + if (opd->tmp_uid) + free (opd->tmp_uid); + while (key) + { + struct key_queue_item_s *next = key->next; + + gpgme_key_unref (key->key); + key = next; + } +} + + +gpgme_keylist_result_t +gpgme_op_keylist_result (gpgme_ctx_t ctx) +{ + void *hook; + op_data_t opd; + gpgme_error_t err; + + err = _gpgme_op_data_lookup (ctx, OPDATA_KEYLIST, &hook, -1, NULL); + opd = hook; + if (err || !opd) + return NULL; + + return &opd->result; +} + + +static gpgme_error_t +keylist_status_handler (void *priv, gpgme_status_code_t code, char *args) +{ + gpgme_ctx_t ctx = (gpgme_ctx_t) priv; + gpgme_error_t err; + void *hook; + op_data_t opd; + + err = _gpgme_op_data_lookup (ctx, OPDATA_KEYLIST, &hook, -1, NULL); + opd = hook; + if (err) + return err; + + switch (code) + { + case GPGME_STATUS_TRUNCATED: + opd->result.truncated = 1; + break; + + default: + break; + } + return 0; +} + + +static time_t +parse_timestamp (char *timestamp) +{ + if (!*timestamp) + return 0; + + return (time_t) strtoul (timestamp, NULL, 10); +} + + +static void +set_mainkey_trust_info (gpgme_key_t key, const char *src) +{ + /* Look at letters and stop at the first digit. */ + while (*src && !isdigit (*src)) + { + switch (*src) + { + case 'e': + key->subkeys->expired = 1; + break; + + case 'r': + key->subkeys->revoked = 1; + break; + + case 'd': + /* Note that gpg 1.3 won't print that anymore but only uses + the capabilities field. */ + key->subkeys->disabled = 1; + break; + + case 'i': + key->subkeys->invalid = 1; + break; + } + src++; + } +} + + +static void +set_userid_flags (gpgme_key_t key, const char *src) +{ + gpgme_user_id_t uid = key->_last_uid; + + assert (uid); + /* Look at letters and stop at the first digit. */ + while (*src && !isdigit (*src)) + { + switch (*src) + { + case 'r': + uid->revoked = 1; + break; + + case 'i': + uid->invalid = 1; + break; + + case 'n': + uid->validity = GPGME_VALIDITY_NEVER; + break; + + case 'm': + uid->validity = GPGME_VALIDITY_MARGINAL; + break; + + case 'f': + uid->validity = GPGME_VALIDITY_FULL; + break; + + case 'u': + uid->validity = GPGME_VALIDITY_ULTIMATE; + break; + } + src++; + } +} + + +static void +set_subkey_trust_info (gpgme_subkey_t subkey, const char *src) +{ + /* Look at letters and stop at the first digit. */ + while (*src && !isdigit (*src)) + { + switch (*src) + { + case 'e': + subkey->expired = 1; + break; + + case 'r': + subkey->revoked = 1; + break; + + case 'd': + subkey->disabled = 1; + break; + + case 'i': + subkey->invalid = 1; + break; + } + src++; + } +} + + +static void +set_mainkey_capability (gpgme_key_t key, const char *src) +{ + while (*src) + { + switch (*src) + { + case 'e': + key->subkeys->can_encrypt = 1; + break; + + case 's': + key->subkeys->can_sign = 1; + break; + + case 'c': + key->subkeys->can_certify = 1; + break; + + case 'a': + key->subkeys->can_authenticate = 1; + break; + + case 'd': + case 'D': + /* Note, that this flag is also set using the key validity + field for backward compatibility with gpg 1.2. We use d + and D, so that a future gpg version will be able to + disable certain subkeys. Currently it is expected that + gpg sets this for the primary key. */ + key->subkeys->disabled = 1; + break; + + case 'E': + key->can_encrypt = 1; + break; + + case 'S': + key->can_sign = 1; + break; + + case 'C': + key->can_certify = 1; + break; + + case 'A': + key->can_authenticate = 1; + break; + } + src++; + } +} + + +static void +set_subkey_capability (gpgme_subkey_t subkey, const char *src) +{ + while (*src) + { + switch (*src) + { + case 'e': + subkey->can_encrypt = 1; + break; + + case 's': + subkey->can_sign = 1; + break; + + case 'c': + subkey->can_certify = 1; + break; + + case 'a': + subkey->can_authenticate = 1; + break; + } + src++; + } +} + +static void +set_ownertrust (gpgme_key_t key, const char *src) +{ + /* Look at letters and stop at the first digit. */ + while (*src && !isdigit (*src)) + { + switch (*src) + { + case 'n': + key->owner_trust = GPGME_VALIDITY_NEVER; + break; + + case 'm': + key->owner_trust = GPGME_VALIDITY_MARGINAL; + break; + + case 'f': + key->owner_trust = GPGME_VALIDITY_FULL; + break; + + case 'u': + key->owner_trust = GPGME_VALIDITY_ULTIMATE; + break; + + default: + key->owner_trust = GPGME_VALIDITY_UNKNOWN; + break; + } + src++; + } +} + + +/* We have read an entire key into tmp_key and should now finish it. + It is assumed that this releases tmp_key. */ +static void +finish_key (gpgme_ctx_t ctx, op_data_t opd) +{ + gpgme_key_t key = opd->tmp_key; + + opd->tmp_key = NULL; + opd->tmp_uid = NULL; + + if (key) + _gpgme_engine_io_event (ctx->engine, GPGME_EVENT_NEXT_KEY, key); +} + + +/* Note: We are allowed to modify LINE. */ +static gpgme_error_t +keylist_colon_handler (void *priv, char *line) +{ + gpgme_ctx_t ctx = (gpgme_ctx_t) priv; + enum + { + RT_NONE, RT_SIG, RT_UID, RT_SUB, RT_PUB, RT_FPR, + RT_SSB, RT_SEC, RT_CRT, RT_CRS, RT_REV + } + rectype = RT_NONE; +#define NR_FIELDS 13 + char *field[NR_FIELDS]; + int fields = 0; + void *hook; + op_data_t opd; + gpgme_error_t err; + gpgme_key_t key; + gpgme_subkey_t subkey = NULL; + gpgme_key_sig_t keysig = NULL; + + DEBUG3 ("keylist_colon_handler ctx = %p, key = %p, line = %s\n", + ctx, key, line ? line : "(null)"); + + err = _gpgme_op_data_lookup (ctx, OPDATA_KEYLIST, &hook, -1, NULL); + opd = hook; + if (err) + return err; + + key = opd->tmp_key; + + if (!line) + { + /* End Of File. */ + finish_key (ctx, opd); + return 0; + } + + while (line && fields < NR_FIELDS) + { + field[fields++] = line; + line = strchr (line, ':'); + if (line) + *(line++) = '\0'; + } + + if (!strcmp (field[0], "sig")) + rectype = RT_SIG; + else if (!strcmp (field[0], "rev")) + rectype = RT_REV; + else if (!strcmp (field[0], "pub")) + rectype = RT_PUB; + else if (!strcmp (field[0], "sec")) + rectype = RT_SEC; + else if (!strcmp (field[0], "crt")) + rectype = RT_CRT; + else if (!strcmp (field[0], "crs")) + rectype = RT_CRS; + else if (!strcmp (field[0], "fpr") && key) + rectype = RT_FPR; + else if (!strcmp (field[0], "uid") && key) + rectype = RT_UID; + else if (!strcmp (field[0], "sub") && key) + rectype = RT_SUB; + else if (!strcmp (field[0], "ssb") && key) + rectype = RT_SSB; + else + rectype = RT_NONE; + + /* Only look at signatures immediately following a user ID. For + this, clear the user ID pointer when encountering anything but a + signature. */ + if (rectype != RT_SIG && rectype != RT_REV) + opd->tmp_uid = NULL; + + switch (rectype) + { + case RT_PUB: + case RT_SEC: + case RT_CRT: + case RT_CRS: + /* Start a new keyblock. */ + err = _gpgme_key_new (&key); + if (err) + return err; + err = _gpgme_key_add_subkey (key, &subkey); + if (err) + { + gpgme_key_unref (key); + return err; + } + + if (rectype == RT_SEC || rectype == RT_CRS) + key->secret = 1; + if (rectype == RT_CRT || rectype == RT_CRS) + key->protocol = GPGME_PROTOCOL_CMS; + finish_key (ctx, opd); + opd->tmp_key = key; + + /* Field 2 has the trust info. */ + if (fields >= 2) + set_mainkey_trust_info (key, field[1]); + + /* Field 3 has the key length. */ + if (fields >= 3) + { + int i = atoi (field[2]); + /* Ignore invalid values. */ + if (i > 1) + subkey->length = i; + } + + /* Field 4 has the public key algorithm. */ + if (fields >= 4) + { + int i = atoi (field[3]); + if (i >= 1 && i < 128) + subkey->pubkey_algo = i; + } + + /* Field 5 has the long keyid. */ + if (fields >= 5 && strlen (field[4]) == DIM(subkey->_keyid) - 1) + strcpy (subkey->_keyid, field[4]); + + /* Field 6 has the timestamp (seconds). */ + if (fields >= 6) + subkey->timestamp = parse_timestamp (field[5]); + + /* Field 7 has the expiration time (seconds). */ + if (fields >= 7) + subkey->expires = parse_timestamp (field[6]); + + /* Field 8 has the X.509 serial number. */ + if (fields >= 8 && (rectype == RT_CRT || rectype == RT_CRS)) + { + key->issuer_serial = strdup (field[7]); + if (!key->issuer_serial) + return gpg_error_from_errno (errno); + } + + /* Field 9 has the ownertrust. */ + if (fields >= 9) + set_ownertrust (key, field[8]); + + /* Field 10 is not used for gpg due to --fixed-list-mode option + but GPGSM stores the issuer name. */ + if (fields >= 10 && (rectype == RT_CRT || rectype == RT_CRS)) + if (_gpgme_decode_c_string (field[9], &key->issuer_name, 0)) + return gpg_error (GPG_ERR_ENOMEM); /* FIXME */ + + /* Field 11 has the signature class. */ + + /* Field 12 has the capabilities. */ + if (fields >= 12) + set_mainkey_capability (key, field[11]); + break; + + case RT_SUB: + case RT_SSB: + /* Start a new subkey. */ + err = _gpgme_key_add_subkey (key, &subkey); + if (err) + return err; + + if (rectype == RT_SSB) + subkey->secret = 1; + + /* Field 2 has the trust info. */ + if (fields >= 2) + set_subkey_trust_info (subkey, field[1]); + + /* Field 3 has the key length. */ + if (fields >= 3) + { + int i = atoi (field[2]); + /* Ignore invalid values. */ + if (i > 1) + subkey->length = i; + } + + /* Field 4 has the public key algorithm. */ + if (fields >= 4) + { + int i = atoi (field[3]); + if (i >= 1 && i < 128) + subkey->pubkey_algo = i; + } + + /* Field 5 has the long keyid. */ + if (fields >= 5 && strlen (field[4]) == DIM(subkey->_keyid) - 1) + strcpy (subkey->_keyid, field[4]); + + /* Field 6 has the timestamp (seconds). */ + if (fields >= 6) + subkey->timestamp = parse_timestamp (field[5]); + + /* Field 7 has the expiration time (seconds). */ + if (fields >= 7) + subkey->expires = parse_timestamp (field[6]); + + /* Field 8 is reserved (LID). */ + /* Field 9 has the ownertrust. */ + /* Field 10, the user ID, is n/a for a subkey. */ + + /* Field 11 has the signature class. */ + + /* Field 12 has the capabilities. */ + if (fields >= 12) + set_subkey_capability (subkey, field[11]); + break; + + case RT_UID: + /* Field 2 has the trust info, and field 10 has the user ID. */ + if (fields >= 10) + { + if (_gpgme_key_append_name (key, field[9])) + return gpg_error_from_errno (GPG_ERR_ENOMEM); /* FIXME */ + else + { + if (field[1]) + set_userid_flags (key, field[1]); + opd->tmp_uid = key->_last_uid; + } + } + break; + + case RT_FPR: + /* Field 10 has the fingerprint (take only the first one). */ + if (fields >= 10 && !key->subkeys->fpr && field[9] && *field[9]) + { + key->subkeys->fpr = strdup (field[9]); + if (!key->subkeys->fpr) + return gpg_error_from_errno (errno); + } + + /* Field 13 has the gpgsm chain ID (take only the first one). */ + if (fields >= 13 && !key->chain_id && *field[12]) + { + key->chain_id = strdup (field[12]); + if (!key->chain_id) + return gpg_error_from_errno (errno); + } + break; + + case RT_SIG: + case RT_REV: + if (!opd->tmp_uid) + return 0; + + /* Start a new (revoked) signature. */ + assert (opd->tmp_uid == key->_last_uid); + keysig = _gpgme_key_add_sig (key, (fields >= 10) ? field[9] : NULL); + if (!keysig) + return gpg_error (GPG_ERR_ENOMEM); /* FIXME */ + + /* Field 2 has the calculated trust ('!', '-', '?', '%'). */ + if (fields >= 2) + switch (field[1][0]) + { + case '!': + keysig->status = gpg_error (GPG_ERR_NO_ERROR); + break; + + case '-': + keysig->status = gpg_error (GPG_ERR_BAD_SIGNATURE); + break; + + case '?': + keysig->status = gpg_error (GPG_ERR_NO_PUBKEY); + break; + + case '%': + keysig->status = gpg_error (GPG_ERR_GENERAL); + break; + + default: + keysig->status = gpg_error (GPG_ERR_NO_ERROR); + break; + } + + /* Field 4 has the public key algorithm. */ + if (fields >= 4) + { + int i = atoi (field[3]); + if (i >= 1 && i < 128) + keysig->pubkey_algo = i; + } + + /* Field 5 has the long keyid. */ + if (fields >= 5 && strlen (field[4]) == DIM(keysig->_keyid) - 1) + strcpy (keysig->_keyid, field[4]); + + /* Field 6 has the timestamp (seconds). */ + if (fields >= 6) + keysig->timestamp = parse_timestamp (field[5]); + + /* Field 7 has the expiration time (seconds). */ + if (fields >= 7) + keysig->expires = parse_timestamp (field[6]); + + /* Field 11 has the signature class (eg, 0x30 means revoked). */ + if (fields >= 11) + if (field[10][0] && field[10][1]) + { + int class = _gpgme_hextobyte (field[10]); + if (class >= 0) + { + keysig->class = class; + if (class == 0x30) + keysig->revoked = 1; + } + if (field[10][2] == 'x') + keysig->exportable = 1; + } + break; + + case RT_NONE: + /* Unknown record. */ + break; + } + return 0; +} + + +void +_gpgme_op_keylist_event_cb (void *data, gpgme_event_io_t type, void *type_data) +{ + gpgme_error_t err; + gpgme_ctx_t ctx = (gpgme_ctx_t) data; + gpgme_key_t key = (gpgme_key_t) type_data; + void *hook; + op_data_t opd; + struct key_queue_item_s *q, *q2; + + assert (type == GPGME_EVENT_NEXT_KEY); + + err = _gpgme_op_data_lookup (ctx, OPDATA_KEYLIST, &hook, -1, NULL); + opd = hook; + if (err) + return; + + q = malloc (sizeof *q); + if (!q) + { + gpgme_key_unref (key); + /* FIXME return GPGME_Out_Of_Core; */ + return; + } + q->key = key; + q->next = NULL; + /* FIXME: Use a tail pointer? */ + if (!(q2 = opd->key_queue)) + opd->key_queue = q; + else + { + for (; q2->next; q2 = q2->next) + ; + q2->next = q; + } + opd->key_cond = 1; +} + + +/* Start a keylist operation within CTX, searching for keys which + match PATTERN. If SECRET_ONLY is true, only secret keys are + returned. */ +gpgme_error_t +gpgme_op_keylist_start (gpgme_ctx_t ctx, const char *pattern, int secret_only) +{ + gpgme_error_t err; + void *hook; + op_data_t opd; + + err = _gpgme_op_reset (ctx, 2); + if (err) + return err; + + err = _gpgme_op_data_lookup (ctx, OPDATA_KEYLIST, &hook, + sizeof (*opd), release_op_data); + opd = hook; + if (err) + return err; + + _gpgme_engine_set_status_handler (ctx->engine, keylist_status_handler, ctx); + + err = _gpgme_engine_set_colon_line_handler (ctx->engine, + keylist_colon_handler, ctx); + if (err) + return err; + + return _gpgme_engine_op_keylist (ctx->engine, pattern, secret_only, + ctx->keylist_mode); +} + + +/* Start a keylist operation within CTX, searching for keys which + match PATTERN. If SECRET_ONLY is true, only secret keys are + returned. */ +gpgme_error_t +gpgme_op_keylist_ext_start (gpgme_ctx_t ctx, const char *pattern[], + int secret_only, int reserved) +{ + gpgme_error_t err; + void *hook; + op_data_t opd; + + err = _gpgme_op_reset (ctx, 2); + if (err) + return err; + + err = _gpgme_op_data_lookup (ctx, OPDATA_KEYLIST, &hook, + sizeof (*opd), release_op_data); + opd = hook; + if (err) + return err; + + _gpgme_engine_set_status_handler (ctx->engine, keylist_status_handler, ctx); + err = _gpgme_engine_set_colon_line_handler (ctx->engine, + keylist_colon_handler, ctx); + if (err) + return err; + + return _gpgme_engine_op_keylist_ext (ctx->engine, pattern, secret_only, + reserved, ctx->keylist_mode); +} + + +/* Return the next key from the keylist in R_KEY. */ +gpgme_error_t +gpgme_op_keylist_next (gpgme_ctx_t ctx, gpgme_key_t *r_key) +{ + gpgme_error_t err; + struct key_queue_item_s *queue_item; + void *hook; + op_data_t opd; + + if (!ctx || !r_key) + return gpg_error (GPG_ERR_INV_VALUE); + *r_key = NULL; + if (!ctx) + return gpg_error (GPG_ERR_INV_VALUE); + + err = _gpgme_op_data_lookup (ctx, OPDATA_KEYLIST, &hook, -1, NULL); + opd = hook; + if (err) + return err; + + if (!opd->key_queue) + { + err = _gpgme_wait_on_condition (ctx, &opd->key_cond); + if (err) + return err; + + if (!opd->key_cond) + return gpg_error (GPG_ERR_EOF); + + opd->key_cond = 0; + assert (opd->key_queue); + } + queue_item = opd->key_queue; + opd->key_queue = queue_item->next; + if (!opd->key_queue) + opd->key_cond = 0; + + *r_key = queue_item->key; + free (queue_item); + return 0; +} + + +/* Terminate a pending keylist operation within CTX. */ +gpgme_error_t +gpgme_op_keylist_end (gpgme_ctx_t ctx) +{ + if (!ctx) + return gpg_error (GPG_ERR_INV_VALUE); + + return 0; +} + + +/* Get the key with the fingerprint FPR from the crypto backend. If + SECRET is true, get the secret key. */ +gpgme_error_t +gpgme_get_key (gpgme_ctx_t ctx, const char *fpr, gpgme_key_t *r_key, + int secret) +{ + gpgme_ctx_t listctx; + gpgme_error_t err; + gpgme_key_t key; + + if (!ctx || !r_key) + return gpg_error (GPG_ERR_INV_VALUE); + + if (strlen (fpr) < 16) /* We have at least a key ID. */ + return gpg_error (GPG_ERR_INV_VALUE); + + /* FIXME: We use our own context because we have to avoid the user's + I/O callback handlers. */ + err = gpgme_new (&listctx); + if (err) + return err; + gpgme_set_protocol (listctx, gpgme_get_protocol (ctx)); + gpgme_set_keylist_mode (listctx, ctx->keylist_mode); + err = gpgme_op_keylist_start (listctx, fpr, secret); + if (!err) + err = gpgme_op_keylist_next (listctx, r_key); + if (!err) + { + err = gpgme_op_keylist_next (listctx, &key); + if (gpgme_err_code (err) == GPG_ERR_EOF) + err = gpg_error (GPG_ERR_NO_ERROR); + else + { + if (!err) + { + gpgme_key_unref (key); + err = gpg_error (GPG_ERR_AMBIGUOUS_NAME); + } + gpgme_key_unref (*r_key); + } + } + gpgme_release (listctx); + return err; +} diff --git a/tags/gpgme-0-4-3/gpgme/libgpgme.vers b/tags/gpgme-0-4-3/gpgme/libgpgme.vers new file mode 100644 index 0000000..4b88bb6 --- /dev/null +++ b/tags/gpgme-0-4-3/gpgme/libgpgme.vers @@ -0,0 +1,24 @@ +# libgpgme.vers - List of symbols to export. +# Copyright (C) 2002 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, write to the Free Software +# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA + + +{ + global: gpgme_*; + local: *; +}; diff --git a/tags/gpgme-0-4-3/gpgme/memrchr.c b/tags/gpgme-0-4-3/gpgme/memrchr.c new file mode 100644 index 0000000..3e60c55 --- /dev/null +++ b/tags/gpgme-0-4-3/gpgme/memrchr.c @@ -0,0 +1,36 @@ +/* memrchr.c - Replacement for memrchr. + * Copyright (C) 2002 Free Software Foundation, Inc. + * + * This file is part of GnuPG. + * + * GnuPG 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. + * + * GnuPG 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA + */ + +#ifdef HAVE_CONFIG_H +#include +#endif + +#include + +void * +memrchr (const void *block, int c, size_t size) +{ + void *p; + + for (p = block + size; p != block; p --) + if (*p == c) + return p; + return 0; +} diff --git a/tags/gpgme-0-4-3/gpgme/mkstatus b/tags/gpgme-0-4-3/gpgme/mkstatus new file mode 100755 index 0000000..cc57969 --- /dev/null +++ b/tags/gpgme-0-4-3/gpgme/mkstatus @@ -0,0 +1,52 @@ +#!/bin/sh +# mkstatus - Extract error strings from rungpg.h +# and create a lookup table +# Copyright (C) 2000 Werner Koch (dd9jn) +# Copyright (C) 2001 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 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA + +# resetting collate is important, so that the bsearch works properly +LC_ALL=C +LC_COLLATE=C +export LC_ALL LC_COLLATE + +cat < +#endif +#include +#include +#include + +#include "gpgme.h" +#include "context.h" +#include "ops.h" + + +gpgme_error_t +_gpgme_op_data_lookup (gpgme_ctx_t ctx, ctx_op_data_id_t type, void **hook, + int size, void (*cleanup) (void *)) +{ + struct ctx_op_data *data = ctx->op_data; + while (data && data->type != type) + data = data->next; + if (!data) + { + if (size < 0) + { + *hook = NULL; + return 0; + } + + data = calloc (1, sizeof (struct ctx_op_data) + size); + if (!data) + return gpg_error_from_errno (errno); + data->next = ctx->op_data; + data->type = type; + data->cleanup = cleanup; + data->hook = ((void *) data) + sizeof (struct ctx_op_data); + ctx->op_data = data; + } + *hook = data->hook; + return 0; +} + + +/* type is: 0: asynchronous operation (use global or user event loop). + 1: synchronous operation (always use private event loop). + 2: asynchronous private operation (use private or user + event loop). */ +gpgme_error_t +_gpgme_op_reset (gpgme_ctx_t ctx, int type) +{ + gpgme_error_t err = 0; + struct gpgme_io_cbs io_cbs; + + _gpgme_release_result (ctx); + + /* Create an engine object. */ + if (ctx->engine) + { + _gpgme_engine_release (ctx->engine); + ctx->engine = NULL; + } + err = _gpgme_engine_new (ctx->protocol, &ctx->engine, + ctx->lc_ctype, ctx->lc_messages); + if (err) + return err; + + if (type == 1 || (type == 2 && !ctx->io_cbs.add)) + { + /* Use private event loop. */ + io_cbs.add = _gpgme_add_io_cb; + io_cbs.add_priv = ctx; + io_cbs.remove = _gpgme_remove_io_cb; + io_cbs.event = _gpgme_wait_private_event_cb; + io_cbs.event_priv = ctx; + } + else if (! ctx->io_cbs.add) + { + /* Use global event loop. */ + io_cbs.add = _gpgme_add_io_cb; + io_cbs.add_priv = ctx; + io_cbs.remove = _gpgme_remove_io_cb; + io_cbs.event = _gpgme_wait_global_event_cb; + io_cbs.event_priv = ctx; + } + else + { + /* Use user event loop. */ + io_cbs.add = _gpgme_wait_user_add_io_cb; + io_cbs.add_priv = ctx; + io_cbs.remove = _gpgme_wait_user_remove_io_cb; + io_cbs.event = _gpgme_wait_user_event_cb; + io_cbs.event_priv = ctx; + } + _gpgme_engine_set_io_cbs (ctx->engine, &io_cbs); + return err; +} + + +gpgme_error_t +_gpgme_parse_inv_recp (char *args, gpgme_invalid_key_t *key) +{ + gpgme_invalid_key_t inv_key; + char *tail; + long int reason; + + inv_key = malloc (sizeof (*inv_key)); + if (!inv_key) + return gpg_error_from_errno (errno); + inv_key->next = NULL; + errno = 0; + reason = strtol (args, &tail, 0); + if (errno || args == tail || *tail != ' ') + { + /* The crypto backend does not behave. */ + free (inv_key); + return gpg_error (GPG_ERR_INV_ENGINE); + } + + switch (reason) + { + default: + case 0: + inv_key->reason = gpg_error (GPG_ERR_GENERAL); + break; + + case 1: + inv_key->reason = gpg_error (GPG_ERR_NO_PUBKEY); + break; + + case 2: + inv_key->reason = gpg_error (GPG_ERR_AMBIGUOUS_NAME); + break; + + case 3: + inv_key->reason = gpg_error (GPG_ERR_WRONG_KEY_USAGE); + break; + + case 4: + inv_key->reason = gpg_error (GPG_ERR_CERT_REVOKED); + break; + + case 5: + inv_key->reason = gpg_error (GPG_ERR_CERT_EXPIRED); + break; + + case 6: + inv_key->reason = gpg_error (GPG_ERR_NO_CRL_KNOWN); + break; + + case 7: + inv_key->reason = gpg_error (GPG_ERR_CRL_TOO_OLD); + break; + + case 8: + inv_key->reason = gpg_error (GPG_ERR_NO_POLICY_MATCH); + break; + + case 9: + inv_key->reason = gpg_error (GPG_ERR_NO_SECKEY); + break; + + case 10: + inv_key->reason = gpg_error (GPG_ERR_PUBKEY_NOT_TRUSTED); + break; + } + + while (*tail == ' ') + tail++; + if (*tail) + { + inv_key->fpr = strdup (tail); + if (!inv_key->fpr) + { + int saved_errno = errno; + free (inv_key); + return gpg_error_from_errno (saved_errno); + } + } + else + inv_key->fpr = NULL; + + *key = inv_key; + return 0; +} diff --git a/tags/gpgme-0-4-3/gpgme/ops.h b/tags/gpgme-0-4-3/gpgme/ops.h new file mode 100644 index 0000000..f01cc9a --- /dev/null +++ b/tags/gpgme-0-4-3/gpgme/ops.h @@ -0,0 +1,143 @@ +/* ops.h - Internal operation support. + Copyright (C) 2000 Werner Koch (dd9jn) + Copyright (C) 2001, 2002, 2003 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 + 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. */ + +#ifndef OPS_H +#define OPS_H + +#include "gpgme.h" +#include "context.h" + + +/* From gpgme.c. */ +void _gpgme_release_result (gpgme_ctx_t ctx); + + +/* From wait.c. */ +gpgme_error_t _gpgme_wait_one (gpgme_ctx_t ctx); +gpgme_error_t _gpgme_wait_on_condition (gpgme_ctx_t ctx, volatile int *cond); + + +/* From data.c. */ +gpgme_error_t _gpgme_data_inbound_handler (void *opaque, int fd); +gpgme_error_t _gpgme_data_outbound_handler (void *opaque, int fd); + + +/* From op-support.c. */ + +/* Find or create the op data object of type TYPE. */ +gpgme_error_t _gpgme_op_data_lookup (gpgme_ctx_t ctx, ctx_op_data_id_t type, + void **hook, int size, + void (*cleanup) (void *)); + +/* Prepare a new operation on CTX. */ +gpgme_error_t _gpgme_op_reset (gpgme_ctx_t ctx, int synchronous); + +/* Parse the INV_RECP status line in ARGS and return the result in + KEY. */ +gpgme_error_t _gpgme_parse_inv_recp (char *args, gpgme_invalid_key_t *key); + + +/* From verify.c. */ +gpgme_error_t _gpgme_op_verify_init_result (gpgme_ctx_t ctx); +gpgme_error_t _gpgme_verify_status_handler (void *priv, + gpgme_status_code_t code, + char *args); + + +/* From decrypt.c. */ +gpgme_error_t _gpgme_op_decrypt_init_result (gpgme_ctx_t ctx); +gpgme_error_t _gpgme_decrypt_status_handler (void *priv, + gpgme_status_code_t code, + char *args); + + +/* From sign.c. */ + +/* Create an initial op data object for signing. Needs to be called + once before calling _gpgme_sign_status_handler. */ +gpgme_error_t _gpgme_op_sign_init_result (gpgme_ctx_t ctx); + +/* Process a status line for signing operations. */ +gpgme_error_t _gpgme_sign_status_handler (void *priv, + gpgme_status_code_t code, + char *args); + + +/* From encrypt.c. */ + +/* Create an initial op data object for encrypt. Needs to be called + once before calling _gpgme_encrypt_status_handler. */ +gpgme_error_t _gpgme_op_encrypt_init_result (gpgme_ctx_t ctx); + +/* Process a status line for encryption operations. */ +gpgme_error_t _gpgme_encrypt_status_handler (void *priv, + gpgme_status_code_t code, + char *args); + + +/* From passphrase.c. */ +gpgme_error_t _gpgme_passphrase_status_handler (void *priv, + gpgme_status_code_t code, + char *args); +gpgme_error_t _gpgme_passphrase_command_handler (void *opaque, + gpgme_status_code_t code, + const char *key, int fd); +gpgme_error_t _gpgme_passphrase_command_handler_internal (void *opaque, + gpgme_status_code_t code, + const char *key, int fd, + int *processed); + + +/* From progress.c. */ +gpgme_error_t _gpgme_progress_status_handler (void *priv, + gpgme_status_code_t code, + char *args); + + +/* From key.c. */ +gpgme_error_t _gpgme_key_new (gpgme_key_t *r_key); +gpgme_error_t _gpgme_key_add_subkey (gpgme_key_t key, + gpgme_subkey_t *r_subkey); +gpgme_error_t _gpgme_key_append_name (gpgme_key_t key, char *src); +gpgme_key_sig_t _gpgme_key_add_sig (gpgme_key_t key, char *src); + + +/* From keylist.c. */ +void _gpgme_op_keylist_event_cb (void *data, gpgme_event_io_t type, + void *type_data); + + +/* From trust-item.c. */ + +/* Create a new trust item. */ +gpgme_error_t _gpgme_trust_item_new (gpgme_trust_item_t *r_item); + + +/* From trustlist.c. */ +void _gpgme_op_trustlist_event_cb (void *data, gpgme_event_io_t type, + void *type_data); + + +/*-- version.c --*/ +const char *_gpgme_compare_versions (const char *my_version, + const char *req_version); +char *_gpgme_get_program_version (const char *const path); + +#endif /* OPS_H */ diff --git a/tags/gpgme-0-4-3/gpgme/passphrase.c b/tags/gpgme-0-4-3/gpgme/passphrase.c new file mode 100644 index 0000000..9fa6a13 --- /dev/null +++ b/tags/gpgme-0-4-3/gpgme/passphrase.c @@ -0,0 +1,163 @@ +/* passphrase.c - Passphrase callback. + Copyright (C) 2000 Werner Koch (dd9jn) + Copyright (C) 2001, 2002, 2003 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 + 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. */ + +#if HAVE_CONFIG_H +#include +#endif +#include +#include +#include +#include +#include + +#include "gpgme.h" +#include "context.h" +#include "ops.h" + + +typedef struct +{ + int no_passphrase; + char *uid_hint; + char *passphrase_info; + int bad_passphrase; +} *op_data_t; + + +static void +release_op_data (void *hook) +{ + op_data_t opd = (op_data_t) hook; + + if (opd->passphrase_info) + free (opd->passphrase_info); + if (opd->uid_hint) + free (opd->uid_hint); +} + + +gpgme_error_t +_gpgme_passphrase_status_handler (void *priv, gpgme_status_code_t code, + char *args) +{ + gpgme_ctx_t ctx = (gpgme_ctx_t) priv; + gpgme_error_t err; + void *hook; + op_data_t opd; + + if (!ctx->passphrase_cb) + return 0; + + err = _gpgme_op_data_lookup (ctx, OPDATA_PASSPHRASE, &hook, + sizeof (*opd), release_op_data); + opd = hook; + if (err) + return err; + + switch (code) + { + case GPGME_STATUS_USERID_HINT: + if (opd->uid_hint) + free (opd->uid_hint); + if (!(opd->uid_hint = strdup (args))) + return gpg_error_from_errno (errno); + break; + + case GPGME_STATUS_BAD_PASSPHRASE: + opd->bad_passphrase++; + opd->no_passphrase = 0; + break; + + case GPGME_STATUS_GOOD_PASSPHRASE: + opd->bad_passphrase = 0; + opd->no_passphrase = 0; + break; + + case GPGME_STATUS_NEED_PASSPHRASE: + case GPGME_STATUS_NEED_PASSPHRASE_SYM: + if (opd->passphrase_info) + free (opd->passphrase_info); + opd->passphrase_info = strdup (args); + if (!opd->passphrase_info) + return gpg_error_from_errno (errno); + break; + + case GPGME_STATUS_MISSING_PASSPHRASE: + opd->no_passphrase = 1; + break; + + case GPGME_STATUS_EOF: + if (opd->no_passphrase || opd->bad_passphrase) + return gpg_error (GPG_ERR_BAD_PASSPHRASE); + break; + + default: + /* Ignore all other codes. */ + break; + } + return 0; +} + + +gpgme_error_t +_gpgme_passphrase_command_handler_internal (void *priv, + gpgme_status_code_t code, + const char *key, int fd, + int *processed) +{ + gpgme_ctx_t ctx = (gpgme_ctx_t) priv; + gpgme_error_t err; + void *hook; + op_data_t opd; + + assert (ctx->passphrase_cb); + + err = _gpgme_op_data_lookup (ctx, OPDATA_PASSPHRASE, &hook, + sizeof (*opd), release_op_data); + opd = hook; + if (err) + return err; + + if (code == GPGME_STATUS_GET_HIDDEN && !strcmp (key, "passphrase.enter")) + { + if (processed) + *processed = 1; + + err = ctx->passphrase_cb (ctx->passphrase_cb_value, + opd->uid_hint, opd->passphrase_info, + opd->bad_passphrase, fd); + + /* Reset bad passphrase flag, in case it is correct now. */ + opd->bad_passphrase = 0; + + return err; + } + + return 0; +} + + +gpgme_error_t +_gpgme_passphrase_command_handler (void *priv, gpgme_status_code_t code, + const char *key, int fd) +{ + return _gpgme_passphrase_command_handler_internal (priv, code, key, fd, + NULL); +} diff --git a/tags/gpgme-0-4-3/gpgme/posix-io.c b/tags/gpgme-0-4-3/gpgme/posix-io.c new file mode 100644 index 0000000..5c9baac --- /dev/null +++ b/tags/gpgme-0-4-3/gpgme/posix-io.c @@ -0,0 +1,410 @@ +/* posix-io.c - Posix I/O functions + Copyright (C) 2000 Werner Koch (dd9jn) + Copyright (C) 2001, 2002 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 + 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. */ + +#ifdef HAVE_CONFIG_H +#include +#endif +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include "util.h" +#include "io.h" +#include "sema.h" +#include "ath.h" +#include "debug.h" + + +void +_gpgme_io_subsystem_init (void) +{ + struct sigaction act; + + sigaction (SIGPIPE, NULL, &act); + if (act.sa_handler == SIG_DFL) + { + act.sa_handler = SIG_IGN; + sigemptyset (&act.sa_mask); + act.sa_flags = 0; + sigaction (SIGPIPE, &act, NULL); + } +} + + +static struct +{ + void (*handler) (int,void*); + void *value; +} notify_table[256]; + +int +_gpgme_io_read (int fd, void *buffer, size_t count) +{ + int nread; + int saved_errno; + + DEBUG2 ("fd %d: about to read %d bytes\n", fd, (int) count); + do + { + nread = _gpgme_ath_read (fd, buffer, count); + } + while (nread == -1 && errno == EINTR); + saved_errno = errno; + DEBUG2 ("fd %d: got %d bytes\n", fd, nread); + if (nread > 0) + _gpgme_debug (2, "fd %d: got `%.*s'\n", fd, nread, buffer); + errno = saved_errno; + return nread; +} + + +int +_gpgme_io_write (int fd, const void *buffer, size_t count) +{ + int saved_errno; + int nwritten; + + DEBUG2 ("fd %d: about to write %d bytes\n", fd, (int) count); + _gpgme_debug (2, "fd %d: write `%.*s'\n", fd, (int) count, buffer); + do + { + nwritten = _gpgme_ath_write (fd, buffer, count); + } + while (nwritten == -1 && errno == EINTR); + saved_errno = errno; + DEBUG2 ("fd %d: wrote %d bytes\n", fd, (int) nwritten); + errno = saved_errno; + return nwritten; +} + + +int +_gpgme_io_pipe (int filedes[2], int inherit_idx) +{ + int saved_errno; + int err; + + err = pipe (filedes); + if (err < 0) + return err; + /* FIXME: Should get the old flags first. */ + err = fcntl (filedes[1 - inherit_idx], F_SETFD, FD_CLOEXEC); + saved_errno = errno; + if (err < 0) + { + close (filedes[0]); + close (filedes[1]); + } + errno = saved_errno; + return err; +} + + +int +_gpgme_io_close (int fd) +{ + if (fd == -1) + return -1; + /* First call the notify handler. */ + DEBUG1 ("closing fd %d", fd); + if (fd >= 0 && fd < (int) DIM (notify_table)) + { + if (notify_table[fd].handler) + { + notify_table[fd].handler (fd, notify_table[fd].value); + notify_table[fd].handler = NULL; + notify_table[fd].value = NULL; + } + } + /* Then do the close. */ + return close (fd); +} + + +int +_gpgme_io_set_close_notify (int fd, void (*handler)(int, void*), void *value) +{ + assert (fd != -1); + + if (fd < 0 || fd >= (int) DIM (notify_table)) + return -1; + DEBUG1 ("set notification for fd %d", fd); + notify_table[fd].handler = handler; + notify_table[fd].value = value; + return 0; +} + + +int +_gpgme_io_set_nonblocking (int fd) +{ + int flags; + + flags = fcntl (fd, F_GETFL, 0); + if (flags == -1) + return -1; + flags |= O_NONBLOCK; + return fcntl (fd, F_SETFL, flags); +} + + +/* Returns 0 on success, -1 on error. */ +int +_gpgme_io_spawn (const char *path, char **argv, + struct spawn_fd_item_s *fd_child_list, + struct spawn_fd_item_s *fd_parent_list) +{ + pid_t pid; + int i; + int status, signo; + + pid = fork (); + if (pid == -1) + return -1; + + if (!pid) + { + /* Intermediate child to prevent zombie processes. */ + if ((pid = fork ()) == 0) + { + /* Child. */ + int duped_stdin = 0; + int duped_stderr = 0; + + /* First close all fds which will not be duped. */ + for (i=0; fd_child_list[i].fd != -1; i++) + if (fd_child_list[i].dup_to == -1) + close (fd_child_list[i].fd); + + /* And now dup and close the rest. */ + for (i=0; fd_child_list[i].fd != -1; i++) + { + if (fd_child_list[i].dup_to != -1) + { + if (dup2 (fd_child_list[i].fd, + fd_child_list[i].dup_to) == -1) + { + DEBUG1 ("dup2 failed in child: %s\n", strerror (errno)); + _exit (8); + } + if (fd_child_list[i].dup_to == 0) + duped_stdin=1; + if (fd_child_list[i].dup_to == 2) + duped_stderr=1; + close (fd_child_list[i].fd); + } + } + + if (!duped_stdin || !duped_stderr) + { + int fd = open ("/dev/null", O_RDWR); + if (fd == -1) + { + DEBUG1 ("can't open `/dev/null': %s\n", strerror (errno)); + _exit (8); + } + /* Make sure that the process has a connected stdin. */ + if (!duped_stdin) + { + if (dup2 (fd, 0) == -1) + { + DEBUG1("dup2(/dev/null, 0) failed: %s\n", + strerror (errno)); + _exit (8); + } + } + if (!duped_stderr) + if (dup2 (fd, 2) == -1) + { + DEBUG1 ("dup2(dev/null, 2) failed: %s\n", + strerror (errno)); + _exit (8); + } + close (fd); + } + + execv ( path, argv ); + /* Hmm: in that case we could write a special status code to the + status-pipe. */ + DEBUG1 ("exec of `%s' failed\n", path); + _exit (8); + } /* End child. */ + if (pid == -1) + _exit (1); + else + _exit (0); + } + + _gpgme_io_waitpid (pid, 1, &status, &signo); + if (status) + return -1; + + /* .dup_to is not used in the parent list. */ + for (i = 0; fd_parent_list[i].fd != -1; i++) + _gpgme_io_close (fd_parent_list[i].fd); + + return 0; +} + + +int +_gpgme_io_waitpid (int pid, int hang, int *r_status, int *r_signal) +{ + int status; + + *r_status = 0; + *r_signal = 0; + if (_gpgme_ath_waitpid (pid, &status, hang? 0 : WNOHANG) == pid) + { + if (WIFSIGNALED (status)) + { + *r_status = 4; /* Need some value here. */ + *r_signal = WTERMSIG (status); + } + else if (WIFEXITED (status)) + *r_status = WEXITSTATUS (status); + else + *r_status = 4; /* Oops. */ + return 1; + } + return 0; +} + + +int +_gpgme_io_kill (int pid, int hard) +{ + return kill (pid, hard ? SIGKILL : SIGTERM); +} + + +/* + * Select on the list of fds. + * Returns: -1 = error + * 0 = timeout or nothing to select + * >0 = number of signaled fds + */ +int +_gpgme_io_select (struct io_select_fd_s *fds, size_t nfds, int nonblock) +{ + fd_set readfds; + fd_set writefds; + unsigned int i; + int any, max_fd, n, count; + struct timeval timeout = { 1, 0 }; /* Use a 1s timeout. */ + void *dbg_help = NULL; + + FD_ZERO (&readfds); + FD_ZERO (&writefds); + max_fd = 0; + if (nonblock) + timeout.tv_sec = 0; + + DEBUG_BEGIN (dbg_help, 3, "gpgme:select on [ "); + any = 0; + for (i = 0; i < nfds; i++) + { + if (fds[i].fd == -1) + continue; + if (fds[i].frozen) + DEBUG_ADD1 (dbg_help, "f%d ", fds[i].fd); + else if (fds[i].for_read) + { + assert (!FD_ISSET (fds[i].fd, &readfds)); + FD_SET (fds[i].fd, &readfds); + if (fds[i].fd > max_fd) + max_fd = fds[i].fd; + DEBUG_ADD1 (dbg_help, "r%d ", fds[i].fd); + any = 1; + } + else if (fds[i].for_write) + { + assert (!FD_ISSET (fds[i].fd, &writefds)); + FD_SET (fds[i].fd, &writefds); + if (fds[i].fd > max_fd) + max_fd = fds[i].fd; + DEBUG_ADD1 (dbg_help, "w%d ", fds[i].fd); + any = 1; + } + fds[i].signaled = 0; + } + DEBUG_END (dbg_help, "]"); + if (!any) + return 0; + + do + { + count = _gpgme_ath_select (max_fd + 1, &readfds, &writefds, NULL, + &timeout); + } + while (count < 0 && errno == EINTR); + if (count < 0) + { + int saved_errno = errno; + DEBUG1 ("_gpgme_io_select failed: %s\n", strerror (errno)); + errno = saved_errno; + return -1; /* error */ + } + + DEBUG_BEGIN (dbg_help, 3, "select OK [ "); + if (DEBUG_ENABLED (dbg_help)) + { + for (i = 0; i <= max_fd; i++) + { + if (FD_ISSET (i, &readfds)) + DEBUG_ADD1 (dbg_help, "r%d ", i); + if (FD_ISSET (i, &writefds)) + DEBUG_ADD1 (dbg_help, "w%d ", i); + } + DEBUG_END (dbg_help, "]"); + } + + /* n is used to optimize it a little bit. */ + for (n = count, i = 0; i < nfds && n; i++) + { + if (fds[i].fd == -1) + ; + else if (fds[i].for_read) + { + if (FD_ISSET (fds[i].fd, &readfds)) + { + fds[i].signaled = 1; + n--; + } + } + else if (fds[i].for_write) + { + if (FD_ISSET (fds[i].fd, &writefds)) + { + fds[i].signaled = 1; + n--; + } + } + } + return count; +} diff --git a/tags/gpgme-0-4-3/gpgme/posix-sema.c b/tags/gpgme-0-4-3/gpgme/posix-sema.c new file mode 100644 index 0000000..45ca728 --- /dev/null +++ b/tags/gpgme-0-4-3/gpgme/posix-sema.c @@ -0,0 +1,63 @@ +/* posix-sema.c + Copyright (C) 2001 Werner Koch (dd9jn) + Copyright (C) 2001, 2002 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 + 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. */ + +#ifdef HAVE_CONFIG_H +#include +#endif +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include "util.h" +#include "sema.h" +#include "ath.h" + +void +_gpgme_sema_subsystem_init () +{ + /* FIXME: we should check that there is only one thread running */ + _gpgme_ath_init (); +} + +void +_gpgme_sema_cs_enter (struct critsect_s *s) +{ + _gpgme_ath_mutex_lock (&s->private); +} + +void +_gpgme_sema_cs_leave (struct critsect_s *s) +{ + _gpgme_ath_mutex_unlock (&s->private); +} + +void +_gpgme_sema_cs_destroy (struct critsect_s *s) +{ + _gpgme_ath_mutex_destroy (&s->private); + s->private = NULL; +} diff --git a/tags/gpgme-0-4-3/gpgme/posix-util.c b/tags/gpgme-0-4-3/gpgme/posix-util.c new file mode 100644 index 0000000..47d4cca --- /dev/null +++ b/tags/gpgme-0-4-3/gpgme/posix-util.c @@ -0,0 +1,49 @@ +/* posix-util.c - Utility functions for Posix + Copyright (C) 2001 Werner Koch (dd9jn) + Copyright (C) 2001, 2002 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 + 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. */ + +#ifdef HAVE_CONFIG_H +#include +#endif +#include +#include +#include +#include + +#include "util.h" + +const char * +_gpgme_get_gpg_path (void) +{ +#ifdef GPG_PATH + return GPG_PATH; +#else + return NULL; +#endif +} + +const char * +_gpgme_get_gpgsm_path (void) +{ +#ifdef GPGSM_PATH + return GPGSM_PATH; +#else + return NULL; +#endif +} diff --git a/tags/gpgme-0-4-3/gpgme/progress.c b/tags/gpgme-0-4-3/gpgme/progress.c new file mode 100644 index 0000000..eb40421 --- /dev/null +++ b/tags/gpgme-0-4-3/gpgme/progress.c @@ -0,0 +1,80 @@ +/* progress.c - status handler for progress status + Copyright (C) 2000 Werner Koch (dd9jn) + Copyright (C) 2001, 2002, 2003 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 + 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. */ + +#ifdef HAVE_CONFIG_H +#include +#endif +#include +#include +#include + +#include "util.h" +#include "context.h" + + +gpgme_error_t +_gpgme_progress_status_handler (void *priv, gpgme_status_code_t code, + char *args) +{ + gpgme_ctx_t ctx = (gpgme_ctx_t) priv; + char *p; + char *args_cpy; + int type = 0; + int current = 0; + int total = 0; + + if (code != GPGME_STATUS_PROGRESS || !*args || !ctx->progress_cb) + return 0; + + args_cpy = strdup (args); + if (!args_cpy) + return gpg_error_from_errno (errno); + + p = strchr (args_cpy, ' '); + if (p) + { + *p++ = 0; + if (*p) + { + type = *(unsigned char *)p; + p = strchr (p+1, ' '); + if (p) + { + *p++ = 0; + if (*p) + { + current = atoi (p); + p = strchr (p+1, ' '); + if (p) + { + *p++ = 0; + total = atoi (p); + } + } + } + } + } + + if (type != 'X') + ctx->progress_cb (ctx->progress_cb_value, args_cpy, type, current, total); + + free (args_cpy); + return 0; +} diff --git a/tags/gpgme-0-4-3/gpgme/putc_unlocked.c b/tags/gpgme-0-4-3/gpgme/putc_unlocked.c new file mode 100644 index 0000000..02c6461 --- /dev/null +++ b/tags/gpgme-0-4-3/gpgme/putc_unlocked.c @@ -0,0 +1,31 @@ +/* putc_unlocked.c - Replacement for putc_unlocked. + * Copyright (C) 2002 Free Software Foundation, Inc. + * + * This file is part of GnuPG. + * + * GnuPG 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. + * + * GnuPG 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA + */ + +#ifdef HAVE_CONFIG_H +#include +#endif + +#include + +int +putc_unlocked (int c, FILE *stream) +{ + return putc (c, stream); +} diff --git a/tags/gpgme-0-4-3/gpgme/rungpg.c b/tags/gpgme-0-4-3/gpgme/rungpg.c new file mode 100644 index 0000000..8885278 --- /dev/null +++ b/tags/gpgme-0-4-3/gpgme/rungpg.c @@ -0,0 +1,1677 @@ +/* rungpg.c - Gpg Engine. + Copyright (C) 2000 Werner Koch (dd9jn) + Copyright (C) 2001, 2002, 2003 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 + 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. */ + +#if HAVE_CONFIG_H +#include +#endif +#include +#include +#include +#include +#include + +#include "gpgme.h" +#include "util.h" +#include "ops.h" +#include "wait.h" +#include "context.h" /*temp hack until we have GpmeData methods to do I/O */ +#include "io.h" +#include "sema.h" +#include "debug.h" + +#include "status-table.h" +#include "engine-backend.h" + + +/* This type is used to build a list of gpg arguments and data + sources/sinks. */ +struct arg_and_data_s +{ + struct arg_and_data_s *next; + gpgme_data_t data; /* If this is not NULL, use arg below. */ + int inbound; /* True if this is used for reading from gpg. */ + int dup_to; + int print_fd; /* Print the fd number and not the special form of it. */ + char arg[1]; /* Used if data above is not used. */ +}; + + +struct fd_data_map_s +{ + gpgme_data_t data; + int inbound; /* true if this is used for reading from gpg */ + int dup_to; + int fd; /* the fd to use */ + int peer_fd; /* the outher side of the pipe */ + void *tag; +}; + + +struct engine_gpg +{ + struct arg_and_data_s *arglist; + struct arg_and_data_s **argtail; + + struct + { + int fd[2]; + size_t bufsize; + char *buffer; + size_t readpos; + int eof; + engine_status_handler_t fnc; + void *fnc_value; + void *tag; + } status; + + /* This is a kludge - see the comment at colon_line_handler. */ + struct + { + int fd[2]; + size_t bufsize; + char *buffer; + size_t readpos; + int eof; + engine_colon_line_handler_t fnc; /* this indicate use of this structrue */ + void *fnc_value; + void *tag; + } colon; + + char **argv; + struct fd_data_map_s *fd_data_map; + + /* stuff needed for interactive (command) mode */ + struct + { + int used; + int fd; + void *cb_data; + int idx; /* Index in fd_data_map */ + gpgme_status_code_t code; /* last code */ + char *keyword; /* what has been requested (malloced) */ + engine_command_handler_t fnc; + void *fnc_value; + /* The kludges never end. This is used to couple command handlers + with output data in edit key mode. */ + gpgme_data_t linked_data; + int linked_idx; + } cmd; + + struct gpgme_io_cbs io_cbs; +}; + +typedef struct engine_gpg *engine_gpg_t; + + +static void +gpg_io_event (void *engine, gpgme_event_io_t type, void *type_data) +{ + engine_gpg_t gpg = engine; + + if (gpg->io_cbs.event) + (*gpg->io_cbs.event) (gpg->io_cbs.event_priv, type, type_data); +} + + +static void +close_notify_handler (int fd, void *opaque) +{ + engine_gpg_t gpg = opaque; + assert (fd != -1); + + if (gpg->status.fd[0] == fd) + { + if (gpg->status.tag) + (*gpg->io_cbs.remove) (gpg->status.tag); + gpg->status.fd[0] = -1; + } + else if (gpg->status.fd[1] == fd) + gpg->status.fd[1] = -1; + else if (gpg->colon.fd[0] == fd) + { + if (gpg->colon.tag) + (*gpg->io_cbs.remove) (gpg->colon.tag); + gpg->colon.fd[0] = -1; + } + else if (gpg->colon.fd[1] == fd) + gpg->colon.fd[1] = -1; + else if (gpg->fd_data_map) + { + int i; + + for (i = 0; gpg->fd_data_map[i].data; i++) + { + if (gpg->fd_data_map[i].fd == fd) + { + if (gpg->fd_data_map[i].tag) + (*gpg->io_cbs.remove) (gpg->fd_data_map[i].tag); + gpg->fd_data_map[i].fd = -1; + break; + } + if (gpg->fd_data_map[i].peer_fd == fd) + { + gpg->fd_data_map[i].peer_fd = -1; + break; + } + } + } +} + +static gpgme_error_t +add_arg (engine_gpg_t gpg, const char *arg) +{ + struct arg_and_data_s *a; + + assert (gpg); + assert (arg); + + a = malloc (sizeof *a + strlen (arg)); + if (!a) + return gpg_error_from_errno (errno); + a->next = NULL; + a->data = NULL; + a->dup_to = -1; + strcpy (a->arg, arg); + *gpg->argtail = a; + gpg->argtail = &a->next; + return 0; +} + +static gpgme_error_t +add_data (engine_gpg_t gpg, gpgme_data_t data, int dup_to, int inbound) +{ + struct arg_and_data_s *a; + + assert (gpg); + assert (data); + + a = malloc (sizeof *a - 1); + if (!a) + return gpg_error_from_errno (errno); + a->next = NULL; + a->data = data; + a->inbound = inbound; + if (dup_to == -2) + { + a->print_fd = 1; + a->dup_to = -1; + } + else + { + a->print_fd = 0; + a->dup_to = dup_to; + } + *gpg->argtail = a; + gpg->argtail = &a->next; + return 0; +} + + +static const char * +gpg_get_version (void) +{ + static const char *gpg_version; + DEFINE_STATIC_LOCK (gpg_version_lock); + + LOCK (gpg_version_lock); + if (!gpg_version) + gpg_version = _gpgme_get_program_version (_gpgme_get_gpg_path ()); + UNLOCK (gpg_version_lock); + return gpg_version; +} + + +static const char * +gpg_get_req_version (void) +{ + return NEED_GPG_VERSION; +} + + +static void +free_argv (char **argv) +{ + int i; + + for (i = 0; argv[i]; i++) + free (argv[i]); + free (argv); +} + + +static void +free_fd_data_map (struct fd_data_map_s *fd_data_map) +{ + int i; + + if (!fd_data_map) + return; + + for (i = 0; fd_data_map[i].data; i++) + { + if (fd_data_map[i].fd != -1) + _gpgme_io_close (fd_data_map[i].fd); + if (fd_data_map[i].peer_fd != -1) + _gpgme_io_close (fd_data_map[i].peer_fd); + /* Don't release data because this is only a reference. */ + } + free (fd_data_map); +} + + +static void +gpg_release (void *engine) +{ + engine_gpg_t gpg = engine; + + if (!gpg) + return; + + while (gpg->arglist) + { + struct arg_and_data_s *next = gpg->arglist->next; + + if (gpg->arglist) + free (gpg->arglist); + gpg->arglist = next; + } + + if (gpg->status.buffer) + free (gpg->status.buffer); + if (gpg->colon.buffer) + free (gpg->colon.buffer); + if (gpg->argv) + free_argv (gpg->argv); + if (gpg->cmd.keyword) + free (gpg->cmd.keyword); + + if (gpg->status.fd[0] != -1) + _gpgme_io_close (gpg->status.fd[0]); + if (gpg->status.fd[1] != -1) + _gpgme_io_close (gpg->status.fd[1]); + if (gpg->colon.fd[0] != -1) + _gpgme_io_close (gpg->colon.fd[0]); + if (gpg->colon.fd[1] != -1) + _gpgme_io_close (gpg->colon.fd[1]); + if (gpg->fd_data_map) + free_fd_data_map (gpg->fd_data_map); + if (gpg->cmd.fd != -1) + _gpgme_io_close (gpg->cmd.fd); + free (gpg); +} + + +static gpgme_error_t +gpg_new (void **engine, const char *lc_ctype, const char *lc_messages) +{ + engine_gpg_t gpg; + gpgme_error_t rc = 0; + + gpg = calloc (1, sizeof *gpg); + if (!gpg) + return gpg_error_from_errno (errno); + + gpg->argtail = &gpg->arglist; + gpg->status.fd[0] = -1; + gpg->status.fd[1] = -1; + gpg->colon.fd[0] = -1; + gpg->colon.fd[1] = -1; + gpg->cmd.fd = -1; + gpg->cmd.idx = -1; + gpg->cmd.linked_data = NULL; + gpg->cmd.linked_idx = -1; + + /* Allocate the read buffer for the status pipe. */ + gpg->status.bufsize = 1024; + gpg->status.readpos = 0; + gpg->status.buffer = malloc (gpg->status.bufsize); + if (!gpg->status.buffer) + { + rc = gpg_error_from_errno (errno); + goto leave; + } + /* In any case we need a status pipe - create it right here and + don't handle it with our generic gpgme_data_t mechanism. */ + if (_gpgme_io_pipe (gpg->status.fd, 1) == -1) + { + rc = gpg_error_from_errno (errno); + goto leave; + } + if (_gpgme_io_set_close_notify (gpg->status.fd[0], + close_notify_handler, gpg) + || _gpgme_io_set_close_notify (gpg->status.fd[1], + close_notify_handler, gpg)) + { + rc = gpg_error (GPG_ERR_GENERAL); + goto leave; + } + gpg->status.eof = 0; + rc = add_arg (gpg, "--status-fd"); + if (rc) + goto leave; + + { + char buf[25]; + sprintf (buf, "%d", gpg->status.fd[1]); + rc = add_arg (gpg, buf); + if (rc) + goto leave; + } + + rc = add_arg (gpg, "--no-tty"); + if (!rc) + rc = add_arg (gpg, "--charset"); + if (!rc) + rc = add_arg (gpg, "utf8"); + if (!rc) + rc = add_arg (gpg, "--enable-progress-filter"); + + leave: + if (rc) + gpg_release (gpg); + else + *engine = gpg; + return rc; +} + + +/* Note, that the status_handler is allowed to modifiy the args + value. */ +static void +gpg_set_status_handler (void *engine, engine_status_handler_t fnc, + void *fnc_value) +{ + engine_gpg_t gpg = engine; + + gpg->status.fnc = fnc; + gpg->status.fnc_value = fnc_value; +} + +/* Kludge to process --with-colon output. */ +static gpgme_error_t +gpg_set_colon_line_handler (void *engine, engine_colon_line_handler_t fnc, + void *fnc_value) +{ + engine_gpg_t gpg = engine; + + gpg->colon.bufsize = 1024; + gpg->colon.readpos = 0; + gpg->colon.buffer = malloc (gpg->colon.bufsize); + if (!gpg->colon.buffer) + return gpg_error_from_errno (errno); + + if (_gpgme_io_pipe (gpg->colon.fd, 1) == -1) + { + int saved_errno = errno; + free (gpg->colon.buffer); + gpg->colon.buffer = NULL; + return gpg_error_from_errno (saved_errno); + } + if (_gpgme_io_set_close_notify (gpg->colon.fd[0], close_notify_handler, gpg) + || _gpgme_io_set_close_notify (gpg->colon.fd[1], + close_notify_handler, gpg)) + return gpg_error (GPG_ERR_GENERAL); + gpg->colon.eof = 0; + gpg->colon.fnc = fnc; + gpg->colon.fnc_value = fnc_value; + return 0; +} + + +static gpgme_error_t +command_handler (void *opaque, int fd) +{ + gpgme_error_t err; + engine_gpg_t gpg = (engine_gpg_t) opaque; + + assert (gpg->cmd.used); + assert (gpg->cmd.code); + assert (gpg->cmd.fnc); + + err = gpg->cmd.fnc (gpg->cmd.fnc_value, gpg->cmd.code, gpg->cmd.keyword, fd); + if (err) + return err; + + gpg->cmd.code = 0; + /* And sleep again until read_status will wake us up again. */ + /* XXX We must check if there are any more fds active after removing + this one. */ + (*gpg->io_cbs.remove) (gpg->fd_data_map[gpg->cmd.idx].tag); + gpg->cmd.fd = gpg->fd_data_map[gpg->cmd.idx].fd; + gpg->fd_data_map[gpg->cmd.idx].fd = -1; + + return 0; +} + + + +/* The Fnc will be called to get a value for one of the commands with + a key KEY. If the Code pssed to FNC is 0, the function may release + resources associated with the returned value from another call. To + match such a second call to a first call, the returned value from + the first call is passed as keyword. */ +static gpgme_error_t +gpg_set_command_handler (void *engine, engine_command_handler_t fnc, + void *fnc_value, gpgme_data_t linked_data) +{ + engine_gpg_t gpg = engine; + gpgme_error_t rc; + + rc = add_arg (gpg, "--command-fd"); + if (rc) + return rc; + + /* This is a hack. We don't have a real data object. The only + thing that matters is that we use something unique, so we use the + address of the cmd structure in the gpg object. */ + rc = add_data (gpg, (void *) &gpg->cmd, -2, 0); + if (rc) + return rc; + + gpg->cmd.fnc = fnc; + gpg->cmd.cb_data = (void *) &gpg->cmd; + gpg->cmd.fnc_value = fnc_value; + gpg->cmd.linked_data = linked_data; + gpg->cmd.used = 1; + return 0; +} + + +static gpgme_error_t +build_argv (engine_gpg_t gpg) +{ + gpgme_error_t err; + struct arg_and_data_s *a; + struct fd_data_map_s *fd_data_map; + size_t datac=0, argc=0; + char **argv; + int need_special = 0; + int use_agent = 0; + char *p; + + /* We don't want to use the agent with a malformed environment + variable. This is only a very basic test but sufficient to make + our life in the regression tests easier. */ + err = _gpgme_getenv ("GPG_AGENT_INFO", &p); + if (err) + return err; + use_agent = (p && strchr (p, ':')); + if (p) + free (p); + + if (gpg->argv) + { + free_argv (gpg->argv); + gpg->argv = NULL; + } + if (gpg->fd_data_map) + { + free_fd_data_map (gpg->fd_data_map); + gpg->fd_data_map = NULL; + } + + argc++; /* For argv[0]. */ + for (a = gpg->arglist; a; a = a->next) + { + argc++; + if (a->data) + { + /*fprintf (stderr, "build_argv: data\n" );*/ + datac++; + if (a->dup_to == -1 && !a->print_fd) + need_special = 1; + } + else + { + /* fprintf (stderr, "build_argv: arg=`%s'\n", a->arg );*/ + } + } + if (need_special) + argc++; + if (use_agent) + argc++; + if (!gpg->cmd.used) + argc++; /* --batch */ + argc += 2; /* --comment */ + + argv = calloc (argc + 1, sizeof *argv); + if (!argv) + return gpg_error_from_errno (errno); + fd_data_map = calloc (datac + 1, sizeof *fd_data_map); + if (!fd_data_map) + { + int saved_errno = errno; + free_argv (argv); + return gpg_error_from_errno (saved_errno); + } + + argc = datac = 0; + argv[argc] = strdup ("gpg"); /* argv[0] */ + if (!argv[argc]) + { + int saved_errno = errno; + free (fd_data_map); + free_argv (argv); + return gpg_error_from_errno (saved_errno); + } + argc++; + if (need_special) + { + argv[argc] = strdup ("--enable-special-filenames"); + if (!argv[argc]) + { + int saved_errno = errno; + free (fd_data_map); + free_argv (argv); + return gpg_error_from_errno (saved_errno); + } + argc++; + } + if (use_agent) + { + argv[argc] = strdup ("--use-agent"); + if (!argv[argc]) + { + int saved_errno = errno; + free (fd_data_map); + free_argv (argv); + return gpg_error_from_errno (saved_errno); + } + argc++; + } + if (!gpg->cmd.used) + { + argv[argc] = strdup ("--batch"); + if (!argv[argc]) + { + int saved_errno = errno; + free (fd_data_map); + free_argv (argv); + return gpg_error_from_errno (saved_errno); + } + argc++; + } + argv[argc] = strdup ("--comment"); + if (!argv[argc]) + { + int saved_errno = errno; + free (fd_data_map); + free_argv (argv); + return gpg_error_from_errno (saved_errno); + } + argc++; + argv[argc] = strdup (""); + if (!argv[argc]) + { + int saved_errno = errno; + free (fd_data_map); + free_argv (argv); + return gpg_error_from_errno (saved_errno); + } + argc++; + for (a = gpg->arglist; a; a = a->next) + { + if (a->data) + { + /* Create a pipe to pass it down to gpg. */ + fd_data_map[datac].inbound = a->inbound; + + /* Create a pipe. */ + { + int fds[2]; + + if (_gpgme_io_pipe (fds, fd_data_map[datac].inbound ? 1 : 0) + == -1) + { + int saved_errno = errno; + free (fd_data_map); + free_argv (argv); + return gpg_error (saved_errno); + } + if (_gpgme_io_set_close_notify (fds[0], + close_notify_handler, gpg) + || _gpgme_io_set_close_notify (fds[1], + close_notify_handler, + gpg)) + { + return gpg_error (GPG_ERR_GENERAL); + } + /* If the data_type is FD, we have to do a dup2 here. */ + if (fd_data_map[datac].inbound) + { + fd_data_map[datac].fd = fds[0]; + fd_data_map[datac].peer_fd = fds[1]; + } + else + { + fd_data_map[datac].fd = fds[1]; + fd_data_map[datac].peer_fd = fds[0]; + } + } + + /* Hack to get hands on the fd later. */ + if (gpg->cmd.used) + { + if (gpg->cmd.cb_data == a->data) + { + assert (gpg->cmd.idx == -1); + gpg->cmd.idx = datac; + } + else if (gpg->cmd.linked_data == a->data) + { + assert (gpg->cmd.linked_idx == -1); + gpg->cmd.linked_idx = datac; + } + } + + fd_data_map[datac].data = a->data; + fd_data_map[datac].dup_to = a->dup_to; + if (a->dup_to == -1) + { + argv[argc] = malloc (25); + if (!argv[argc]) + { + int saved_errno = errno; + free (fd_data_map); + free_argv (argv); + return gpg_error_from_errno (saved_errno); + } + sprintf (argv[argc], + a->print_fd ? "%d" : "-&%d", + fd_data_map[datac].peer_fd); + argc++; + } + datac++; + } + else + { + argv[argc] = strdup (a->arg); + if (!argv[argc]) + { + int saved_errno = errno; + free (fd_data_map); + free_argv (argv); + return gpg_error_from_errno (saved_errno); + } + argc++; + } + } + + gpg->argv = argv; + gpg->fd_data_map = fd_data_map; + return 0; +} + + +static gpgme_error_t +add_io_cb (engine_gpg_t gpg, int fd, int dir, gpgme_io_cb_t handler, void *data, + void **tag) +{ + gpgme_error_t err; + + err = (*gpg->io_cbs.add) (gpg->io_cbs.add_priv, fd, dir, handler, data, tag); + if (err) + return err; + if (!dir) + /* FIXME Kludge around poll() problem. */ + err = _gpgme_io_set_nonblocking (fd); + return err; +} + + +static int +status_cmp (const void *ap, const void *bp) +{ + const struct status_table_s *a = ap; + const struct status_table_s *b = bp; + + return strcmp (a->name, b->name); +} + + +/* Handle the status output of GnuPG. This function does read entire + lines and passes them as C strings to the callback function (we can + use C Strings because the status output is always UTF-8 encoded). + Of course we have to buffer the lines to cope with long lines + e.g. with a large user ID. Note: We can optimize this to only cope + with status line code we know about and skip all other stuff + without buffering (i.e. without extending the buffer). */ +static gpgme_error_t +read_status (engine_gpg_t gpg) +{ + char *p; + int nread; + size_t bufsize = gpg->status.bufsize; + char *buffer = gpg->status.buffer; + size_t readpos = gpg->status.readpos; + + assert (buffer); + if (bufsize - readpos < 256) + { + /* Need more room for the read. */ + bufsize += 1024; + buffer = realloc (buffer, bufsize); + if (!buffer) + return gpg_error_from_errno (errno); + } + + nread = _gpgme_io_read (gpg->status.fd[0], + buffer + readpos, bufsize-readpos); + if (nread == -1) + return gpg_error_from_errno (errno); + + if (!nread) + { + gpg->status.eof = 1; + if (gpg->status.fnc) + { + gpgme_error_t err; + err = gpg->status.fnc (gpg->status.fnc_value, GPGME_STATUS_EOF, ""); + if (err) + return err; + } + return 0; + } + + while (nread > 0) + { + for (p = buffer + readpos; nread; nread--, p++) + { + if (*p == '\n') + { + /* (we require that the last line is terminated by a LF) */ + *p = 0; + if (!strncmp (buffer, "[GNUPG:] ", 9) + && buffer[9] >= 'A' && buffer[9] <= 'Z') + { + struct status_table_s t, *r; + char *rest; + + rest = strchr (buffer + 9, ' '); + if (!rest) + rest = p; /* Set to an empty string. */ + else + *rest++ = 0; + + t.name = buffer+9; + /* (the status table has one extra element) */ + r = bsearch (&t, status_table, DIM(status_table) - 1, + sizeof t, status_cmp); + if (r) + { + if (gpg->cmd.used + && (r->code == GPGME_STATUS_GET_BOOL + || r->code == GPGME_STATUS_GET_LINE + || r->code == GPGME_STATUS_GET_HIDDEN)) + { + gpg->cmd.code = r->code; + if (gpg->cmd.keyword) + free (gpg->cmd.keyword); + gpg->cmd.keyword = strdup (rest); + if (!gpg->cmd.keyword) + return gpg_error_from_errno (errno); + /* This should be the last thing we have + received and the next thing will be that + the command handler does its action. */ + if (nread > 1) + DEBUG0 ("ERROR, unexpected data in read_status"); + + /* Before we can actually add the command + fd, we might have to flush the linked + output data pipe. */ + if (gpg->cmd.linked_idx != -1 + && gpg->fd_data_map[gpg->cmd.linked_idx].fd != -1) + { + struct io_select_fd_s fds; + fds.fd = gpg->fd_data_map[gpg->cmd.linked_idx].fd; + fds.for_read = 1; + fds.for_write = 0; + fds.frozen = 0; + fds.opaque = NULL; + do + { + fds.signaled = 0; + _gpgme_io_select (&fds, 1, 1); + if (fds.signaled) + _gpgme_data_inbound_handler + (gpg->cmd.linked_data, fds.fd); + } + while (fds.signaled); + } + + add_io_cb (gpg, gpg->cmd.fd, 0, + command_handler, gpg, + &gpg->fd_data_map[gpg->cmd.idx].tag); + gpg->fd_data_map[gpg->cmd.idx].fd = gpg->cmd.fd; + gpg->cmd.fd = -1; + } + else if (gpg->status.fnc) + { + gpgme_error_t err; + err = gpg->status.fnc (gpg->status.fnc_value, + r->code, rest); + if (err) + return err; + } + + if (r->code == GPGME_STATUS_END_STREAM) + { + if (gpg->cmd.used) + { + /* XXX We must check if there are any + more fds active after removing this + one. */ + (*gpg->io_cbs.remove) + (gpg->fd_data_map[gpg->cmd.idx].tag); + gpg->cmd.fd = gpg->fd_data_map[gpg->cmd.idx].fd; + gpg->fd_data_map[gpg->cmd.idx].fd = -1; + } + } + } + } + /* To reuse the buffer for the next line we have to + shift the remaining data to the buffer start and + restart the loop Hmmm: We can optimize this function + by looking forward in the buffer to see whether a + second complete line is available and in this case + avoid the memmove for this line. */ + nread--; p++; + if (nread) + memmove (buffer, p, nread); + readpos = 0; + break; /* the for loop */ + } + else + readpos++; + } + } + + /* Update the gpg object. */ + gpg->status.bufsize = bufsize; + gpg->status.buffer = buffer; + gpg->status.readpos = readpos; + return 0; +} + + +static gpgme_error_t +status_handler (void *opaque, int fd) +{ + engine_gpg_t gpg = opaque; + int err; + + assert (fd == gpg->status.fd[0]); + err = read_status (gpg); + if (err) + return err; + if (gpg->status.eof) + _gpgme_io_close (fd); + return 0; +} + + +static gpgme_error_t +read_colon_line (engine_gpg_t gpg) +{ + char *p; + int nread; + size_t bufsize = gpg->colon.bufsize; + char *buffer = gpg->colon.buffer; + size_t readpos = gpg->colon.readpos; + + assert (buffer); + if (bufsize - readpos < 256) + { + /* Need more room for the read. */ + bufsize += 1024; + buffer = realloc (buffer, bufsize); + if (!buffer) + return gpg_error_from_errno (errno); + } + + nread = _gpgme_io_read (gpg->colon.fd[0], buffer+readpos, bufsize-readpos); + if (nread == -1) + return gpg_error_from_errno (errno); + + if (!nread) + { + gpg->colon.eof = 1; + assert (gpg->colon.fnc); + gpg->colon.fnc (gpg->colon.fnc_value, NULL); + return 0; + } + + while (nread > 0) + { + for (p = buffer + readpos; nread; nread--, p++) + { + if ( *p == '\n' ) + { + /* (we require that the last line is terminated by a LF) + and we skip empty lines. Note: we use UTF8 encoding + and escaping of special characters We require at + least one colon to cope with some other printed + information. */ + *p = 0; + if (*buffer && strchr (buffer, ':')) + { + assert (gpg->colon.fnc); + gpg->colon.fnc (gpg->colon.fnc_value, buffer); + } + + /* To reuse the buffer for the next line we have to + shift the remaining data to the buffer start and + restart the loop Hmmm: We can optimize this function + by looking forward in the buffer to see whether a + second complete line is available and in this case + avoid the memmove for this line. */ + nread--; p++; + if (nread) + memmove (buffer, p, nread); + readpos = 0; + break; /* The for loop. */ + } + else + readpos++; + } + } + + /* Update the gpg object. */ + gpg->colon.bufsize = bufsize; + gpg->colon.buffer = buffer; + gpg->colon.readpos = readpos; + return 0; +} + + +/* This colonline handler thing is not the clean way to do it. It + might be better to enhance the gpgme_data_t object to act as a wrapper + for a callback. Same goes for the status thing. For now we use + this thing here because it is easier to implement. */ +static gpgme_error_t +colon_line_handler (void *opaque, int fd) +{ + engine_gpg_t gpg = opaque; + gpgme_error_t rc = 0; + + assert (fd == gpg->colon.fd[0]); + rc = read_colon_line (gpg); + if (rc) + return rc; + if (gpg->colon.eof) + _gpgme_io_close (fd); + return 0; +} + + +static gpgme_error_t +start (engine_gpg_t gpg) +{ + gpgme_error_t rc; + int saved_errno; + int i, n; + int status; + struct spawn_fd_item_s *fd_child_list, *fd_parent_list; + + if (!gpg) + return gpg_error (GPG_ERR_INV_VALUE); + + if (! _gpgme_get_gpg_path ()) + return gpg_error (GPG_ERR_INV_ENGINE); + + rc = build_argv (gpg); + if (rc) + return rc; + + n = 3; /* status_fd, colon_fd and end of list */ + for (i = 0; gpg->fd_data_map[i].data; i++) + n++; + fd_child_list = calloc (n + n, sizeof *fd_child_list); + if (!fd_child_list) + return gpg_error_from_errno (errno); + fd_parent_list = fd_child_list + n; + + /* build the fd list for the child */ + n = 0; + if (gpg->colon.fnc) + { + fd_child_list[n].fd = gpg->colon.fd[1]; + fd_child_list[n].dup_to = 1; /* dup to stdout */ + n++; + } + for (i = 0; gpg->fd_data_map[i].data; i++) + { + if (gpg->fd_data_map[i].dup_to != -1) + { + fd_child_list[n].fd = gpg->fd_data_map[i].peer_fd; + fd_child_list[n].dup_to = gpg->fd_data_map[i].dup_to; + n++; + } + } + fd_child_list[n].fd = -1; + fd_child_list[n].dup_to = -1; + + /* Build the fd list for the parent. */ + n = 0; + if (gpg->status.fd[1] != -1) + { + fd_parent_list[n].fd = gpg->status.fd[1]; + fd_parent_list[n].dup_to = -1; + n++; + } + if (gpg->colon.fd[1] != -1) + { + fd_parent_list[n].fd = gpg->colon.fd[1]; + fd_parent_list[n].dup_to = -1; + n++; + } + for (i = 0; gpg->fd_data_map[i].data; i++) + { + fd_parent_list[n].fd = gpg->fd_data_map[i].peer_fd; + fd_parent_list[n].dup_to = -1; + n++; + } + fd_parent_list[n].fd = -1; + fd_parent_list[n].dup_to = -1; + + status = _gpgme_io_spawn (_gpgme_get_gpg_path (), + gpg->argv, fd_child_list, fd_parent_list); + saved_errno = errno; + free (fd_child_list); + if (status == -1) + return gpg_error_from_errno (saved_errno); + + /*_gpgme_register_term_handler ( closure, closure_value, pid );*/ + + rc = add_io_cb (gpg, gpg->status.fd[0], 1, status_handler, gpg, + &gpg->status.tag); + if (rc) + /* FIXME: kill the child */ + return rc; + + if (gpg->colon.fnc) + { + assert (gpg->colon.fd[0] != -1); + rc = add_io_cb (gpg, gpg->colon.fd[0], 1, colon_line_handler, gpg, + &gpg->colon.tag); + if (rc) + /* FIXME: kill the child */ + return rc; + } + + for (i = 0; gpg->fd_data_map[i].data; i++) + { + if (gpg->cmd.used && i == gpg->cmd.idx) + { + /* Park the cmd fd. */ + gpg->cmd.fd = gpg->fd_data_map[i].fd; + gpg->fd_data_map[i].fd = -1; + } + else + { + rc = add_io_cb (gpg, gpg->fd_data_map[i].fd, + gpg->fd_data_map[i].inbound, + gpg->fd_data_map[i].inbound + ? _gpgme_data_inbound_handler + : _gpgme_data_outbound_handler, + gpg->fd_data_map[i].data, &gpg->fd_data_map[i].tag); + + if (rc) + /* FIXME: kill the child */ + return rc; + } + } + + (*gpg->io_cbs.event) (gpg->io_cbs.event_priv, GPGME_EVENT_START, NULL); + + /* fixme: check what data we can release here */ + return 0; +} + + +static gpgme_error_t +gpg_decrypt (void *engine, gpgme_data_t ciph, gpgme_data_t plain) +{ + engine_gpg_t gpg = engine; + gpgme_error_t err; + + err = add_arg (gpg, "--decrypt"); + + /* Tell the gpg object about the data. */ + if (!err) + err = add_arg (gpg, "--output"); + if (!err) + err = add_arg (gpg, "-"); + if (!err) + err = add_data (gpg, plain, 1, 1); + if (!err) + err = add_data (gpg, ciph, 0, 0); + + if (!err) + start (gpg); + return err; +} + +static gpgme_error_t +gpg_delete (void *engine, gpgme_key_t key, int allow_secret) +{ + engine_gpg_t gpg = engine; + gpgme_error_t err; + + err = add_arg (gpg, allow_secret ? "--delete-secret-and-public-key" + : "--delete-key"); + if (!err) + err = add_arg (gpg, "--"); + if (!err) + { + if (!key->subkeys || !key->subkeys->fpr) + return gpg_error (GPG_ERR_INV_VALUE); + else + err = add_arg (gpg, key->subkeys->fpr); + } + + if (!err) + start (gpg); + return err; +} + + +static gpgme_error_t +append_args_from_signers (engine_gpg_t gpg, gpgme_ctx_t ctx /* FIXME */) +{ + gpgme_error_t err = 0; + int i; + gpgme_key_t key; + + for (i = 0; (key = gpgme_signers_enum (ctx, i)); i++) + { + const char *s = key->subkeys ? key->subkeys->keyid : NULL; + if (s) + { + if (!err) + err = add_arg (gpg, "-u"); + if (!err) + err = add_arg (gpg, s); + } + gpgme_key_unref (key); + if (err) break; + } + return err; +} + + +static gpgme_error_t +gpg_edit (void *engine, int type, gpgme_key_t key, gpgme_data_t out, + gpgme_ctx_t ctx /* FIXME */) +{ + engine_gpg_t gpg = engine; + gpgme_error_t err; + + err = add_arg (gpg, "--with-colons"); + if (!err) + err = append_args_from_signers (gpg, ctx); + if (!err) + err = add_arg (gpg, type == 0 ? "--edit-key" : "--card-edit"); + if (!err) + err = add_data (gpg, out, 1, 1); + if (!err) + err = add_arg (gpg, "--"); + if (!err) + { + const char *s = key->subkeys ? key->subkeys->fpr : NULL; + if (!s) + err = gpg_error (GPG_ERR_INV_VALUE); + else + err = add_arg (gpg, s); + } + if (!err) + err = start (gpg); + + return err; +} + + +static gpgme_error_t +append_args_from_recipients (engine_gpg_t gpg, gpgme_key_t recp[]) +{ + gpgme_error_t err = 0; + int i = 0; + + while (recp[i]) + { + if (!recp[i]->subkeys || !recp[i]->subkeys->fpr) + err = gpg_error (GPG_ERR_INV_VALUE); + if (!err) + err = add_arg (gpg, "-r"); + if (!err) + err = add_arg (gpg, recp[i]->subkeys->fpr); + if (err) + break; + i++; + } + return err; +} + + +static gpgme_error_t +gpg_encrypt (void *engine, gpgme_key_t recp[], gpgme_encrypt_flags_t flags, + gpgme_data_t plain, gpgme_data_t ciph, int use_armor) +{ + engine_gpg_t gpg = engine; + gpgme_error_t err; + int symmetric = !recp; + + err = add_arg (gpg, symmetric ? "--symmetric" : "--encrypt"); + + if (!err && use_armor) + err = add_arg (gpg, "--armor"); + + if (!symmetric) + { + /* If we know that all recipients are valid (full or ultimate trust) + we can suppress further checks. */ + if (!err && !symmetric && (flags & GPGME_ENCRYPT_ALWAYS_TRUST)) + err = add_arg (gpg, "--always-trust"); + + if (!err) + err = append_args_from_recipients (gpg, recp); + } + + /* Tell the gpg object about the data. */ + if (!err) + err = add_arg (gpg, "--output"); + if (!err) + err = add_arg (gpg, "-"); + if (!err) + err = add_data (gpg, ciph, 1, 1); + if (!err) + err = add_arg (gpg, "--"); + if (!err) + err = add_data (gpg, plain, 0, 0); + + if (!err) + err = start (gpg); + + return err; +} + + +static gpgme_error_t +gpg_encrypt_sign (void *engine, gpgme_key_t recp[], + gpgme_encrypt_flags_t flags, gpgme_data_t plain, + gpgme_data_t ciph, int use_armor, + gpgme_ctx_t ctx /* FIXME */) +{ + engine_gpg_t gpg = engine; + gpgme_error_t err; + + err = add_arg (gpg, "--encrypt"); + if (!err) + err = add_arg (gpg, "--sign"); + if (!err && use_armor) + err = add_arg (gpg, "--armor"); + + /* If we know that all recipients are valid (full or ultimate trust) + we can suppress further checks. */ + if (!err && (flags & GPGME_ENCRYPT_ALWAYS_TRUST)) + err = add_arg (gpg, "--always-trust"); + + if (!err) + err = append_args_from_recipients (gpg, recp); + + if (!err) + err = append_args_from_signers (gpg, ctx); + + /* Tell the gpg object about the data. */ + if (!err) + err = add_arg (gpg, "--output"); + if (!err) + err = add_arg (gpg, "-"); + if (!err) + err = add_data (gpg, ciph, 1, 1); + if (!err) + err = add_arg (gpg, "--"); + if (!err) + err = add_data (gpg, plain, 0, 0); + + if (!err) + err = start (gpg); + + return err; +} + + +static gpgme_error_t +gpg_export (void *engine, const char *pattern, unsigned int reserved, + gpgme_data_t keydata, int use_armor) +{ + engine_gpg_t gpg = engine; + gpgme_error_t err; + + if (reserved) + return gpg_error (GPG_ERR_INV_VALUE); + + err = add_arg (gpg, "--export"); + if (!err && use_armor) + err = add_arg (gpg, "--armor"); + if (!err) + err = add_data (gpg, keydata, 1, 1); + if (!err) + err = add_arg (gpg, "--"); + + if (!err && pattern && *pattern) + err = add_arg (gpg, pattern); + + if (!err) + err = start (gpg); + + return err; +} + + +static gpgme_error_t +gpg_export_ext (void *engine, const char *pattern[], unsigned int reserved, + gpgme_data_t keydata, int use_armor) +{ + engine_gpg_t gpg = engine; + gpgme_error_t err; + + if (reserved) + return gpg_error (GPG_ERR_INV_VALUE); + + err = add_arg (gpg, "--export"); + if (!err && use_armor) + err = add_arg (gpg, "--armor"); + if (!err) + err = add_data (gpg, keydata, 1, 1); + if (!err) + err = add_arg (gpg, "--"); + + if (pattern) + { + while (!err && *pattern && **pattern) + err = add_arg (gpg, *(pattern++)); + } + + if (!err) + err = start (gpg); + + return err; +} + + +static gpgme_error_t +gpg_genkey (void *engine, gpgme_data_t help_data, int use_armor, + gpgme_data_t pubkey, gpgme_data_t seckey) +{ + engine_gpg_t gpg = engine; + gpgme_error_t err; + + if (!gpg) + return gpg_error (GPG_ERR_INV_VALUE); + + /* We need a special mechanism to get the fd of a pipe here, so that + we can use this for the %pubring and %secring parameters. We + don't have this yet, so we implement only the adding to the + standard keyrings. */ + if (pubkey || seckey) + return gpg_error (GPG_ERR_NOT_IMPLEMENTED); + + err = add_arg (gpg, "--gen-key"); + if (!err && use_armor) + err = add_arg (gpg, "--armor"); + if (!err) + err = add_data (gpg, help_data, 0, 0); + + if (!err) + err = start (gpg); + + return err; +} + + +static gpgme_error_t +gpg_import (void *engine, gpgme_data_t keydata) +{ + engine_gpg_t gpg = engine; + gpgme_error_t err; + + err = add_arg (gpg, "--import"); + if (!err) + err = add_data (gpg, keydata, 0, 0); + + if (!err) + err = start (gpg); + + return err; +} + + +static gpgme_error_t +gpg_keylist (void *engine, const char *pattern, int secret_only, + gpgme_keylist_mode_t mode) +{ + engine_gpg_t gpg = engine; + gpgme_error_t err; + + err = add_arg (gpg, "--with-colons"); + if (!err) + err = add_arg (gpg, "--fixed-list-mode"); + if (!err) + err = add_arg (gpg, "--with-fingerprint"); + if (!err) + err = add_arg (gpg, "--with-fingerprint"); + if (!err) + err = add_arg (gpg, secret_only ? "--list-secret-keys" + : ((mode & GPGME_KEYLIST_MODE_SIGS) + ? "--check-sigs" : "--list-keys")); + + /* Tell the gpg object about the data. */ + if (!err) + err = add_arg (gpg, "--"); + if (!err && pattern && *pattern) + err = add_arg (gpg, pattern); + + if (!err) + err = start (gpg); + + return err; +} + + +static gpgme_error_t +gpg_keylist_ext (void *engine, const char *pattern[], int secret_only, + int reserved, gpgme_keylist_mode_t mode) +{ + engine_gpg_t gpg = engine; + gpgme_error_t err; + + if (reserved) + return gpg_error (GPG_ERR_INV_VALUE); + + err = add_arg (gpg, "--with-colons"); + if (!err) + err = add_arg (gpg, "--fixed-list-mode"); + if (!err) + err = add_arg (gpg, "--with-fingerprint"); + if (!err) + err = add_arg (gpg, "--with-fingerprint"); + if (!err) + err = add_arg (gpg, secret_only ? "--list-secret-keys" + : ((mode & GPGME_KEYLIST_MODE_SIGS) + ? "--check-sigs" : "--list-keys")); + if (!err) + err = add_arg (gpg, "--"); + + if (pattern) + { + while (!err && *pattern && **pattern) + err = add_arg (gpg, *(pattern++)); + } + + if (!err) + err = start (gpg); + + return err; +} + + +static gpgme_error_t +gpg_sign (void *engine, gpgme_data_t in, gpgme_data_t out, + gpgme_sig_mode_t mode, int use_armor, int use_textmode, + int include_certs, gpgme_ctx_t ctx /* FIXME */) +{ + engine_gpg_t gpg = engine; + gpgme_error_t err; + + if (mode == GPGME_SIG_MODE_CLEAR) + err = add_arg (gpg, "--clearsign"); + else + { + err = add_arg (gpg, "--sign"); + if (!err && mode == GPGME_SIG_MODE_DETACH) + err = add_arg (gpg, "--detach"); + if (!err && use_armor) + err = add_arg (gpg, "--armor"); + if (!err && use_textmode) + err = add_arg (gpg, "--textmode"); + } + + if (!err) + err = append_args_from_signers (gpg, ctx); + + /* Tell the gpg object about the data. */ + if (!err) + err = add_data (gpg, in, 0, 0); + if (!err) + err = add_data (gpg, out, 1, 1); + + if (!err) + start (gpg); + + return err; +} + +static gpgme_error_t +gpg_trustlist (void *engine, const char *pattern) +{ + engine_gpg_t gpg = engine; + gpgme_error_t err; + + err = add_arg (gpg, "--with-colons"); + if (!err) + err = add_arg (gpg, "--list-trust-path"); + + /* Tell the gpg object about the data. */ + if (!err) + err = add_arg (gpg, "--"); + if (!err) + err = add_arg (gpg, pattern); + + if (!err) + err = start (gpg); + + return err; +} + + +static gpgme_error_t +gpg_verify (void *engine, gpgme_data_t sig, gpgme_data_t signed_text, + gpgme_data_t plaintext) +{ + engine_gpg_t gpg = engine; + gpgme_error_t err = 0; + + if (plaintext) + { + /* Normal or cleartext signature. */ + + err = add_arg (gpg, "--output"); + if (!err) + err = add_arg (gpg, "-"); + if (!err) + err = add_arg (gpg, "--"); + if (!err) + err = add_data (gpg, sig, 0, 0); + if (!err) + err = add_data (gpg, plaintext, 1, 1); + } + else + { + err = add_arg (gpg, "--verify"); + if (!err) + err = add_arg (gpg, "--"); + if (!err) + err = add_data (gpg, sig, -1, 0); + if (signed_text) + { + if (!err) + err = add_arg (gpg, "-"); + if (!err) + err = add_data (gpg, signed_text, 0, 0); + } + } + + if (!err) + err = start (gpg); + + return err; +} + + +static void +gpg_set_io_cbs (void *engine, gpgme_io_cbs_t io_cbs) +{ + engine_gpg_t gpg = engine; + + gpg->io_cbs = *io_cbs; +} + + +struct engine_ops _gpgme_engine_ops_gpg = + { + /* Static functions. */ + _gpgme_get_gpg_path, + gpg_get_version, + gpg_get_req_version, + gpg_new, + + /* Member functions. */ + gpg_release, + gpg_set_status_handler, + gpg_set_command_handler, + gpg_set_colon_line_handler, + gpg_decrypt, + gpg_delete, + gpg_edit, + gpg_encrypt, + gpg_encrypt_sign, + gpg_export, + gpg_export_ext, + gpg_genkey, + gpg_import, + gpg_keylist, + gpg_keylist_ext, + gpg_sign, + gpg_trustlist, + gpg_verify, + gpg_set_io_cbs, + gpg_io_event + }; diff --git a/tags/gpgme-0-4-3/gpgme/sema.h b/tags/gpgme-0-4-3/gpgme/sema.h new file mode 100644 index 0000000..2c0842e --- /dev/null +++ b/tags/gpgme-0-4-3/gpgme/sema.h @@ -0,0 +1,66 @@ +/* sema.h - Definitions for semaphores. + Copyright (C) 2000 Werner Koch (dd9jn) + Copyright (C) 2001, 2003 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 + 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. */ + +#ifndef SEMA_H +#define SEMA_H + +struct critsect_s +{ + const char *name; + void *private; +}; + +#define DEFINE_GLOBAL_LOCK(name) \ + struct critsect_s name = { #name, NULL } +#define DEFINE_STATIC_LOCK(name) \ + static struct critsect_s name = { #name, NULL } + +#define DECLARE_LOCK(name) \ + struct critsect_s name +#define INIT_LOCK(a) \ + do \ + { \ + (a).name = #a; \ + (a).private = NULL; \ + } \ + while (0) +#define DESTROY_LOCK(name) _gpgme_sema_cs_destroy (&(name)) + + +#define LOCK(name) \ + do \ + { \ + _gpgme_sema_cs_enter (&(name)); \ + } \ + while (0) + +#define UNLOCK(name) \ + do \ + { \ + _gpgme_sema_cs_leave (&(name)); \ + } \ + while (0) + +void _gpgme_sema_subsystem_init (void); +void _gpgme_sema_cs_enter (struct critsect_s *s); +void _gpgme_sema_cs_leave (struct critsect_s *s); +void _gpgme_sema_cs_destroy (struct critsect_s *s); + +#endif /* SEMA_H */ diff --git a/tags/gpgme-0-4-3/gpgme/sign.c b/tags/gpgme-0-4-3/gpgme/sign.c new file mode 100644 index 0000000..089b34c --- /dev/null +++ b/tags/gpgme-0-4-3/gpgme/sign.c @@ -0,0 +1,325 @@ +/* sign.c - Signing function. + Copyright (C) 2000 Werner Koch (dd9jn) + Copyright (C) 2001, 2002, 2003 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 + 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. */ + +#if HAVE_CONFIG_H +#include +#endif +#include +#include +#include + +#include "gpgme.h" +#include "context.h" +#include "ops.h" + + +typedef struct +{ + struct _gpgme_op_sign_result result; + + /* A pointer to the next pointer of the last invalid signer in + the list. This makes appending new invalid signers painless + while preserving the order. */ + gpgme_invalid_key_t *last_signer_p; + + /* Likewise for signature information. */ + gpgme_new_signature_t *last_sig_p; +} *op_data_t; + + +static void +release_op_data (void *hook) +{ + op_data_t opd = (op_data_t) hook; + gpgme_invalid_key_t invalid_signer = opd->result.invalid_signers; + gpgme_new_signature_t sig = opd->result.signatures; + + while (invalid_signer) + { + gpgme_invalid_key_t next = invalid_signer->next; + if (invalid_signer->fpr) + free (invalid_signer->fpr); + free (invalid_signer); + invalid_signer = next; + } + + while (sig) + { + gpgme_new_signature_t next = sig->next; + free (sig->fpr); + free (sig); + sig = next; + } +} + + +gpgme_sign_result_t +gpgme_op_sign_result (gpgme_ctx_t ctx) +{ + void *hook; + op_data_t opd; + gpgme_error_t err; + + err = _gpgme_op_data_lookup (ctx, OPDATA_SIGN, &hook, -1, NULL); + opd = hook; + if (err || !opd) + return NULL; + + return &opd->result; +} + + +static gpgme_error_t +parse_sig_created (char *args, gpgme_new_signature_t *sigp) +{ + gpgme_new_signature_t sig; + char *tail; + + sig = malloc (sizeof (*sig)); + if (!sig) + return gpg_error_from_errno (errno); + + sig->next = NULL; + switch (*args) + { + case 'S': + sig->type = GPGME_SIG_MODE_NORMAL; + break; + + case 'D': + sig->type = GPGME_SIG_MODE_DETACH; + break; + + case 'C': + sig->type = GPGME_SIG_MODE_CLEAR; + break; + + default: + /* The backend engine is not behaving. */ + free (sig); + return gpg_error (GPG_ERR_INV_ENGINE); + } + + args++; + if (*args != ' ') + { + free (sig); + return gpg_error (GPG_ERR_INV_ENGINE); + } + + errno = 0; + sig->pubkey_algo = strtol (args, &tail, 0); + if (errno || args == tail || *tail != ' ') + { + /* The crypto backend does not behave. */ + free (sig); + return gpg_error (GPG_ERR_INV_ENGINE); + } + args = tail; + + sig->hash_algo = strtol (args, &tail, 0); + if (errno || args == tail || *tail != ' ') + { + /* The crypto backend does not behave. */ + free (sig); + return gpg_error (GPG_ERR_INV_ENGINE); + } + args = tail; + + sig->class = strtol (args, &tail, 0); + sig->_obsolete_class = sig->class; + if (errno || args == tail || *tail != ' ') + { + /* The crypto backend does not behave. */ + free (sig); + return gpg_error (GPG_ERR_INV_ENGINE); + } + args = tail; + + sig->timestamp = strtol (args, &tail, 0); + if (errno || args == tail || *tail != ' ') + { + /* The crypto backend does not behave. */ + free (sig); + return gpg_error (GPG_ERR_INV_ENGINE); + } + args = tail; + while (*args == ' ') + args++; + + if (!*args) + { + /* The crypto backend does not behave. */ + free (sig); + return gpg_error (GPG_ERR_INV_ENGINE); + } + + tail = strchr (args, ' '); + if (tail) + *tail = '\0'; + + sig->fpr = strdup (args); + if (!sig->fpr) + { + int saved_errno = errno; + free (sig); + return gpg_error_from_errno (saved_errno); + } + *sigp = sig; + return 0; +} + + +gpgme_error_t +_gpgme_sign_status_handler (void *priv, gpgme_status_code_t code, char *args) +{ + gpgme_ctx_t ctx = (gpgme_ctx_t) priv; + gpgme_error_t err; + void *hook; + op_data_t opd; + + err = _gpgme_passphrase_status_handler (priv, code, args); + if (err) + return err; + + err = _gpgme_op_data_lookup (ctx, OPDATA_SIGN, &hook, -1, NULL); + opd = hook; + if (err) + return err; + + switch (code) + { + case GPGME_STATUS_SIG_CREATED: + err = parse_sig_created (args, opd->last_sig_p); + if (err) + return err; + + opd->last_sig_p = &(*opd->last_sig_p)->next; + break; + + case GPGME_STATUS_INV_RECP: + err = _gpgme_parse_inv_recp (args, opd->last_signer_p); + if (err) + return err; + + opd->last_signer_p = &(*opd->last_signer_p)->next; + break; + + case GPGME_STATUS_EOF: + if (opd->result.invalid_signers) + return gpg_error (GPG_ERR_UNUSABLE_SECKEY); + break; + + default: + break; + } + return err; +} + + +static gpgme_error_t +sign_status_handler (void *priv, gpgme_status_code_t code, char *args) +{ + gpgme_error_t err; + + err = _gpgme_progress_status_handler (priv, code, args); + if (!err) + err = _gpgme_sign_status_handler (priv, code, args); + return err; +} + + +gpgme_error_t +_gpgme_op_sign_init_result (gpgme_ctx_t ctx) +{ + gpgme_error_t err; + void *hook; + op_data_t opd; + + err = _gpgme_op_data_lookup (ctx, OPDATA_SIGN, &hook, + sizeof (*opd), release_op_data); + opd = hook; + if (err) + return err; + opd->last_signer_p = &opd->result.invalid_signers; + opd->last_sig_p = &opd->result.signatures; + return 0; +} + + +static gpgme_error_t +sign_start (gpgme_ctx_t ctx, int synchronous, gpgme_data_t plain, + gpgme_data_t sig, gpgme_sig_mode_t mode) +{ + gpgme_error_t err; + + err = _gpgme_op_reset (ctx, synchronous); + if (err) + return err; + + err = _gpgme_op_sign_init_result (ctx); + if (err) + return err; + + if (mode != GPGME_SIG_MODE_NORMAL && mode != GPGME_SIG_MODE_DETACH + && mode != GPGME_SIG_MODE_CLEAR) + return gpg_error (GPG_ERR_INV_VALUE); + + if (!plain) + return gpg_error (GPG_ERR_NO_DATA); + if (!sig) + return gpg_error (GPG_ERR_INV_VALUE); + + if (ctx->passphrase_cb) + { + err = _gpgme_engine_set_command_handler + (ctx->engine, _gpgme_passphrase_command_handler, ctx, NULL); + if (err) + return err; + } + + _gpgme_engine_set_status_handler (ctx->engine, sign_status_handler, + ctx); + + return _gpgme_engine_op_sign (ctx->engine, plain, sig, mode, ctx->use_armor, + ctx->use_textmode, ctx->include_certs, + ctx /* FIXME */); +} + + +/* Sign the plaintext PLAIN and store the signature in SIG. */ +gpgme_error_t +gpgme_op_sign_start (gpgme_ctx_t ctx, gpgme_data_t plain, gpgme_data_t sig, + gpgme_sig_mode_t mode) +{ + return sign_start (ctx, 0, plain, sig, mode); +} + + +/* Sign the plaintext PLAIN and store the signature in SIG. */ +gpgme_error_t +gpgme_op_sign (gpgme_ctx_t ctx, gpgme_data_t plain, gpgme_data_t sig, + gpgme_sig_mode_t mode) +{ + gpgme_error_t err = sign_start (ctx, 1, plain, sig, mode); + if (!err) + err = _gpgme_wait_one (ctx); + return err; +} diff --git a/tags/gpgme-0-4-3/gpgme/signers.c b/tags/gpgme-0-4-3/gpgme/signers.c new file mode 100644 index 0000000..a5662a2 --- /dev/null +++ b/tags/gpgme-0-4-3/gpgme/signers.c @@ -0,0 +1,94 @@ +/* signers.c - Maintain signer sets. + Copyright (C) 2001 Werner Koch (dd9jn) + Copyright (C) 2001, 2002, 2003 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 + 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. */ + +#if HAVE_CONFIG_H +#include +#endif + +#include +#include +#include +#include + +#include "util.h" +#include "context.h" + + +/* Delete all signers from CTX. */ +void +gpgme_signers_clear (gpgme_ctx_t ctx) +{ + unsigned int i; + + if (!ctx || !ctx->signers) + return; + + for (i = 0; i < ctx->signers_len; i++) + { + assert (ctx->signers[i]); + gpgme_key_unref (ctx->signers[i]); + ctx->signers[i] = NULL; + } + ctx->signers_len = 0; +} + +/* Add KEY to list of signers in CTX. */ +gpgme_error_t +gpgme_signers_add (gpgme_ctx_t ctx, const gpgme_key_t key) +{ + if (!ctx || !key) + return gpg_error (GPG_ERR_INV_VALUE); + + if (ctx->signers_len == ctx->signers_size) + { + gpgme_key_t *newarr; + int n = ctx->signers_size + 5; + int j; + + newarr = realloc (ctx->signers, n * sizeof (*newarr)); + if (!newarr) + return gpg_error_from_errno (errno); + for (j = ctx->signers_size; j < n; j++) + newarr[j] = NULL; + ctx->signers = newarr; + ctx->signers_size = n; + } + + gpgme_key_ref (key); + ctx->signers[ctx->signers_len++] = key; + return 0; +} + + +/* Return the SEQth signer's key in CTX with one reference. */ +gpgme_key_t +gpgme_signers_enum (const gpgme_ctx_t ctx, int seq) +{ + unsigned int seqno; + + if (!ctx || seq < 0) + return NULL; + + seqno = (unsigned int) seq; + if (seqno >= ctx->signers_len) + return NULL; + gpgme_key_ref (ctx->signers[seqno]); + return ctx->signers[seqno]; +} diff --git a/tags/gpgme-0-4-3/gpgme/stpcpy.c b/tags/gpgme-0-4-3/gpgme/stpcpy.c new file mode 100644 index 0000000..a01636c --- /dev/null +++ b/tags/gpgme-0-4-3/gpgme/stpcpy.c @@ -0,0 +1,50 @@ +/* stpcpy.c -- copy a string and return pointer to end of new string + Copyright (C) 1992, 1995, 1997, 1998 Free Software Foundation, Inc. + + NOTE: The canonical source of this file is maintained with the GNU C Library. + Bugs can be reported to bug-glibc@prep.ai.mit.edu. + + This program 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, or (at your option) any + later version. + + This program 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, + USA. */ + +#ifdef HAVE_CONFIG_H +# include +#endif + +#include + +#undef __stpcpy +#undef stpcpy + +#ifndef weak_alias +# define __stpcpy stpcpy +#endif + +/* Copy SRC to DEST, returning the address of the terminating '\0' in DEST. */ +char * +__stpcpy (char *dest, const char *src) +{ + register char *d = dest; + register const char *s = src; + + do + *d++ = *s; + while (*s++ != '\0'); + + return d - 1; +} +#ifdef weak_alias +weak_alias (__stpcpy, stpcpy) +#endif diff --git a/tags/gpgme-0-4-3/gpgme/trust-item.c b/tags/gpgme-0-4-3/gpgme/trust-item.c new file mode 100644 index 0000000..bc60df4 --- /dev/null +++ b/tags/gpgme-0-4-3/gpgme/trust-item.c @@ -0,0 +1,170 @@ +/* trust-item.c - Trust item objects. + Copyright (C) 2000 Werner Koch (dd9jn) + Copyright (C) 2001, 2002, 2003 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 + 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. */ + +#if HAVE_CONFIG_H +#include +#endif +#include +#include +#include +#include + +#include "util.h" +#include "ops.h" +#include "sema.h" + + +/* Protects all reference counters in trust items. All other accesses + to a trust item are either read only or happen before the trust + item is available to the user. */ +DEFINE_STATIC_LOCK (trust_item_ref_lock); + + +/* Create a new trust item. */ +gpgme_error_t +_gpgme_trust_item_new (gpgme_trust_item_t *r_item) +{ + gpgme_trust_item_t item; + + item = calloc (1, sizeof *item); + if (!item) + return gpg_error_from_errno (errno); + item->_refs = 1; + item->keyid = item->_keyid; + item->_keyid[16] = '\0'; + item->owner_trust = item->_owner_trust; + item->_owner_trust[1] = '\0'; + item->validity = item->_validity; + item->_validity[1] = '\0'; + *r_item = item; + return 0; +} + + +/* Acquire a reference to ITEM. */ +void +gpgme_trust_item_ref (gpgme_trust_item_t item) +{ + LOCK (trust_item_ref_lock); + item->_refs++; + UNLOCK (trust_item_ref_lock); +} + + +/* gpgme_trust_item_unref releases the trust item object. Note that + this function may not do an actual release if there are other + shallow copies of the object. You have to call this function for + every newly created trust item object as well as for every + gpgme_trust_item_ref() done on the trust item object. */ +void +gpgme_trust_item_unref (gpgme_trust_item_t item) +{ + LOCK (trust_item_ref_lock); + assert (item->_refs > 0); + if (--item->_refs) + { + UNLOCK (trust_item_ref_lock); + return; + } + UNLOCK (trust_item_ref_lock); + + if (item->name) + free (item->name); + free (item); +} + + +/* Compatibility interfaces. */ +void +gpgme_trust_item_release (gpgme_trust_item_t item) +{ + gpgme_trust_item_unref (item); +} + +/* Return the value of the attribute WHAT of ITEM, which has to be + representable by a string. */ +const char *gpgme_trust_item_get_string_attr (gpgme_trust_item_t item, + _gpgme_attr_t what, + const void *reserved, int idx) +{ + const char *val = NULL; + + if (!item) + return NULL; + if (reserved) + return NULL; + if (idx) + return NULL; + + switch (what) + { + case GPGME_ATTR_KEYID: + val = item->keyid; + break; + + case GPGME_ATTR_OTRUST: + val = item->owner_trust; + break; + + case GPGME_ATTR_VALIDITY: + val = item->validity; + break; + + case GPGME_ATTR_USERID: + val = item->name; + break; + + default: + break; + } + return val; +} + + +/* Return the value of the attribute WHAT of KEY, which has to be + representable by an integer. IDX specifies a running index if the + attribute appears more than once in the key. */ +int gpgme_trust_item_get_int_attr (gpgme_trust_item_t item, _gpgme_attr_t what, + const void *reserved, int idx) +{ + int val = 0; + + if (!item) + return 0; + if (reserved) + return 0; + if (idx) + return 0; + + switch (what) + { + case GPGME_ATTR_LEVEL: + val = item->level; + break; + + case GPGME_ATTR_TYPE: + val = item->type; + break; + + default: + break; + } + return val; +} diff --git a/tags/gpgme-0-4-3/gpgme/trustlist.c b/tags/gpgme-0-4-3/gpgme/trustlist.c new file mode 100644 index 0000000..942cc53 --- /dev/null +++ b/tags/gpgme-0-4-3/gpgme/trustlist.c @@ -0,0 +1,245 @@ +/* trustlist.c - Trust item listing. + Copyright (C) 2000 Werner Koch (dd9jn) + Copyright (C) 2001, 2002, 2003 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 + 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. */ + +#if HAVE_CONFIG_H +#include +#endif +#include +#include +#include +#include + +#include "gpgme.h" +#include "util.h" +#include "context.h" +#include "ops.h" + + +struct trust_queue_item_s +{ + struct trust_queue_item_s *next; + gpgme_trust_item_t item; +}; + +typedef struct +{ + /* Something new is available. */ + int trust_cond; + struct trust_queue_item_s *trust_queue; +} *op_data_t; + + + +static gpgme_error_t +trustlist_status_handler (void *priv, gpgme_status_code_t code, char *args) +{ + return 0; +} + + +/* This handler is used to parse the output of --list-trust-path: + Format: + level:keyid:type:recno:ot:val:mc:cc:name: + With TYPE = U for a user ID + K for a key + The RECNO is either the one of the dir record or the one of the uid + record. OT is the the usual trust letter and only availabel on K + lines. VAL is the calcualted validity MC is the marginal trust + counter and only available on U lines CC is the same for the + complete count NAME ist the username and only printed on U + lines. */ +static gpgme_error_t +trustlist_colon_handler (void *priv, char *line) +{ + gpgme_ctx_t ctx = (gpgme_ctx_t) priv; + gpgme_error_t err; + char *p, *pend; + int field = 0; + gpgme_trust_item_t item = NULL; + + if (!line) + return 0; /* EOF */ + + for (p = line; p; p = pend) + { + field++; + pend = strchr (p, ':'); + if (pend) + *pend++ = 0; + + switch (field) + { + case 1: /* level */ + err = _gpgme_trust_item_new (&item); + if (err) + return err; + item->level = atoi (p); + break; + case 2: /* long keyid */ + if (strlen (p) == DIM(item->keyid) - 1) + strcpy (item->keyid, p); + break; + case 3: /* type */ + item->type = *p == 'K'? 1 : *p == 'U'? 2 : 0; + break; + case 5: /* owner trust */ + item->_owner_trust[0] = *p; + break; + case 6: /* validity */ + item->_validity[0] = *p; + break; + case 9: /* user ID */ + item->name = strdup (p); + if (!item->name) + { + int saved_errno = errno; + gpgme_trust_item_unref (item); + return gpg_error_from_errno (saved_errno); + } + break; + } + } + + if (item) + _gpgme_engine_io_event (ctx->engine, GPGME_EVENT_NEXT_TRUSTITEM, item); + return 0; +} + + +void +_gpgme_op_trustlist_event_cb (void *data, gpgme_event_io_t type, + void *type_data) +{ + gpgme_ctx_t ctx = (gpgme_ctx_t) data; + gpgme_error_t err; + void *hook; + op_data_t opd; + gpgme_trust_item_t item = (gpgme_trust_item_t) type_data; + struct trust_queue_item_s *q, *q2; + + assert (type == GPGME_EVENT_NEXT_TRUSTITEM); + + err = _gpgme_op_data_lookup (ctx, OPDATA_TRUSTLIST, &hook, -1, NULL); + opd = hook; + if (err) + return; + + q = malloc (sizeof *q); + if (!q) + { + gpgme_trust_item_unref (item); + /* FIXME: GPGME_Out_Of_Core; */ + return; + } + q->item = item; + q->next = NULL; + /* FIXME: Use a tail pointer */ + q2 = opd->trust_queue; + if (!q2) + opd->trust_queue = q; + else + { + while (q2->next) + q2 = q2->next; + q2->next = q; + } + /* FIXME: unlock queue */ + opd->trust_cond = 1; +} + + +gpgme_error_t +gpgme_op_trustlist_start (gpgme_ctx_t ctx, const char *pattern, int max_level) +{ + gpgme_error_t err = 0; + void *hook; + op_data_t opd; + + if (!pattern || !*pattern) + return gpg_error (GPG_ERR_INV_VALUE); + + err = _gpgme_op_reset (ctx, 2); + if (err) + return err; + + err = _gpgme_op_data_lookup (ctx, OPDATA_TRUSTLIST, &hook, + sizeof (*opd), NULL); + opd = hook; + if (err) + return err; + + _gpgme_engine_set_status_handler (ctx->engine, + trustlist_status_handler, ctx); + err = _gpgme_engine_set_colon_line_handler (ctx->engine, + trustlist_colon_handler, ctx); + if (err) + return err; + + return _gpgme_engine_op_trustlist (ctx->engine, pattern); +} + + +gpgme_error_t +gpgme_op_trustlist_next (gpgme_ctx_t ctx, gpgme_trust_item_t *r_item) +{ + gpgme_error_t err; + void *hook; + op_data_t opd; + struct trust_queue_item_s *q; + + if (!r_item) + return gpg_error (GPG_ERR_INV_VALUE); + *r_item = NULL; + if (!ctx) + return gpg_error (GPG_ERR_INV_VALUE); + + err = _gpgme_op_data_lookup (ctx, OPDATA_TRUSTLIST, &hook, -1, NULL); + opd = hook; + if (err) + return err; + + if (!opd->trust_queue) + { + err = _gpgme_wait_on_condition (ctx, &opd->trust_cond); + if (err) + return err; + if (!opd->trust_cond) + return gpg_error (GPG_ERR_EOF); + opd->trust_cond = 0; + assert (opd->trust_queue); + } + q = opd->trust_queue; + opd->trust_queue = q->next; + + *r_item = q->item; + free (q); + return 0; +} + + +/* Terminate a pending trustlist operation within CTX. */ +gpgme_error_t +gpgme_op_trustlist_end (gpgme_ctx_t ctx) +{ + if (!ctx) + return gpg_error (GPG_ERR_INV_VALUE); + + return 0; +} diff --git a/tags/gpgme-0-4-3/gpgme/util.h b/tags/gpgme-0-4-3/gpgme/util.h new file mode 100644 index 0000000..c087355 --- /dev/null +++ b/tags/gpgme-0-4-3/gpgme/util.h @@ -0,0 +1,81 @@ +/* util.h + Copyright (C) 2000 Werner Koch (dd9jn) + Copyright (C) 2001, 2002, 2003 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 + 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. */ + +#ifndef UTIL_H +#define UTIL_H + +#include "gpgme.h" + + +#define DIM(v) (sizeof(v)/sizeof((v)[0])) + + +/*-- {posix,w32}-util.c --*/ +const char *_gpgme_get_gpg_path (void); +const char *_gpgme_get_gpgsm_path (void); + + +/*-- replacement functions in .c --*/ +#ifdef HAVE_CONFIG_H +#ifndef HAVE_STPCPY +char *stpcpy (char *a, const char *b); +#endif + +#if !HAVE_VASPRINTF +#include +int vasprintf (char **result, const char *format, va_list args); +int asprintf (char **result, const char *format, ...); +#endif +#endif + + +/*-- conversion.c --*/ +/* Convert two hexadecimal digits from STR to the value they + represent. Returns -1 if one of the characters is not a + hexadecimal digit. */ +int _gpgme_hextobyte (const char *str); + +/* Decode the C formatted string SRC and store the result in the + buffer *DESTP which is LEN bytes long. If LEN is zero, then a + large enough buffer is allocated with malloc and *DESTP is set to + the result. Currently, LEN is only used to specify if allocation + is desired or not, the caller is expected to make sure that *DESTP + is large enough if LEN is not zero. */ +gpgme_error_t _gpgme_decode_c_string (const char *src, char **destp, + size_t len); + +/* Decode the percent escaped string SRC and store the result in the + buffer *DESTP which is LEN bytes long. If LEN is zero, then a + large enough buffer is allocated with malloc and *DESTP is set to + the result. Currently, LEN is only used to specify if allocation + is desired or not, the caller is expected to make sure that *DESTP + is large enough if LEN is not zero. */ +gpgme_error_t _gpgme_decode_percent_string (const char *src, char **destp, + size_t len); + +gpgme_error_t _gpgme_map_gnupg_error (char *err); + + +/* Retrieve the environment variable NAME and return a copy of it in a + malloc()'ed buffer in *VALUE. If the environment variable is not + set, return NULL in *VALUE. */ +gpgme_error_t _gpgme_getenv (const char *name, char **value); + +#endif /* UTIL_H */ diff --git a/tags/gpgme-0-4-3/gpgme/vasprintf.c b/tags/gpgme-0-4-3/gpgme/vasprintf.c new file mode 100644 index 0000000..0159867 --- /dev/null +++ b/tags/gpgme-0-4-3/gpgme/vasprintf.c @@ -0,0 +1,192 @@ +/* Like vsprintf but provides a pointer to malloc'd storage, which must + be freed by the caller. + Copyright (C) 1994, 2002 Free Software Foundation, Inc. + +This file is part of the libiberty library. +Libiberty 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. + +Libiberty 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 libiberty; see the file COPYING.LIB. If +not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, +Boston, MA 02111-1307, USA. */ + +#ifdef HAVE_CONFIG_H +#include +#endif +#include +#include +#include +#include + + +#ifndef va_copy /* accroding to POSIX, va_copy is a macro */ +#if defined (__GNUC__) && defined (__PPC__) \ + && (defined (_CALL_SYSV) || defined (_WIN32)) +#define va_copy(d, s) (*(d) = *(s)) +#elif defined (MUST_COPY_VA_BYVAL) +#define va_copy(d, s) ((d) = (s)) +#else +#define va_copy(d, s) memcpy ((d), (s), sizeof (va_list)) +#endif +#endif + + +#ifdef TEST +int global_total_width; +#endif + +static int int_vasprintf (char **, const char *, va_list *); + +static int +int_vasprintf (result, format, args) + char **result; + const char *format; + va_list *args; +{ + const char *p = format; + /* Add one to make sure that it is never zero, which might cause malloc + to return NULL. */ + int total_width = strlen (format) + 1; + va_list ap; + + va_copy (ap, *args); + + while (*p != '\0') + { + if (*p++ == '%') + { + while (strchr ("-+ #0", *p)) + ++p; + if (*p == '*') + { + ++p; + total_width += abs (va_arg (ap, int)); + } + else + total_width += strtoul (p, (char **) &p, 10); + if (*p == '.') + { + ++p; + if (*p == '*') + { + ++p; + total_width += abs (va_arg (ap, int)); + } + else + total_width += strtoul (p, (char **) &p, 10); + } + while (strchr ("hlL", *p)) + ++p; + /* Should be big enough for any format specifier except %s and floats. */ + total_width += 30; + switch (*p) + { + case 'd': + case 'i': + case 'o': + case 'u': + case 'x': + case 'X': + case 'c': + (void) va_arg (ap, int); + break; + case 'f': + case 'e': + case 'E': + case 'g': + case 'G': + (void) va_arg (ap, double); + /* Since an ieee double can have an exponent of 307, we'll + make the buffer wide enough to cover the gross case. */ + total_width += 307; + break; + case 's': + { + char *tmp = va_arg (ap, char *); + if (tmp) + total_width += strlen (tmp); + else /* in case the vsprintf does prints a text */ + total_width += 25; /* e.g. "(null pointer reference)" */ + } + break; + case 'p': + case 'n': + (void) va_arg (ap, char *); + break; + } + p++; + } + } +#ifdef TEST + global_total_width = total_width; +#endif + *result = malloc (total_width); + if (*result != NULL) + return vsprintf (*result, format, *args); + else + return 0; +} + +int +vasprintf (result, format, args) + char **result; + const char *format; +#if defined (_BSD_VA_LIST_) && defined (__FreeBSD__) + _BSD_VA_LIST_ args; +#else + va_list args; +#endif +{ + return int_vasprintf (result, format, &args); +} + + +int +asprintf (char **buf, const char *fmt, ...) +{ + int status; + va_list ap; + + va_start (ap, fmt); + status = vasprintf (buf, fmt, ap); + va_end (ap); + return status; +} + + +#ifdef TEST +void +checkit (const char* format, ...) +{ + va_list args; + char *result; + + va_start (args, format); + vasprintf (&result, format, args); + if (strlen (result) < global_total_width) + printf ("PASS: "); + else + printf ("FAIL: "); + printf ("%d %s\n", global_total_width, result); +} + +int +main (void) +{ + checkit ("%d", 0x12345678); + checkit ("%200d", 5); + checkit ("%.300d", 6); + checkit ("%100.150d", 7); + checkit ("%s", "jjjjjjjjjiiiiiiiiiiiiiiioooooooooooooooooppppppppppppaa\n\ +777777777777777777333333333333366666666666622222222222777777777777733333"); + checkit ("%f%s%d%s", 1.0, "foo", 77, "asdjffffffffffffffiiiiiiiiiiixxxxx"); +} +#endif /* TEST */ diff --git a/tags/gpgme-0-4-3/gpgme/verify.c b/tags/gpgme-0-4-3/gpgme/verify.c new file mode 100644 index 0000000..3f70851 --- /dev/null +++ b/tags/gpgme-0-4-3/gpgme/verify.c @@ -0,0 +1,789 @@ +/* verify.c - Signature verification. + Copyright (C) 2000 Werner Koch (dd9jn) + Copyright (C) 2001, 2002, 2003 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 + 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. */ + +#if HAVE_CONFIG_H +#include +#endif +#include +#include +#include + +#include "gpgme.h" +#include "util.h" +#include "context.h" +#include "ops.h" + + +typedef struct +{ + struct _gpgme_op_verify_result result; + + gpgme_signature_t current_sig; +} *op_data_t; + + +static void +release_op_data (void *hook) +{ + op_data_t opd = (op_data_t) hook; + gpgme_signature_t sig = opd->result.signatures; + + while (sig) + { + gpgme_signature_t next = sig->next; + gpgme_sig_notation_t notation = sig->notations; + + while (notation) + { + gpgme_sig_notation_t next_nota = notation->next; + + if (notation->name) + free (notation->name); + if (notation->value) + free (notation->value); + notation = next_nota; + } + + if (sig->fpr) + free (sig->fpr); + free (sig); + sig = next; + } +} + + +gpgme_verify_result_t +gpgme_op_verify_result (gpgme_ctx_t ctx) +{ + void *hook; + op_data_t opd; + gpgme_error_t err; + + err = _gpgme_op_data_lookup (ctx, OPDATA_VERIFY, &hook, -1, NULL); + opd = hook; + if (err || !opd) + return NULL; + + return &opd->result; +} + + +/* Build a summary vector from RESULT. */ +static void +calc_sig_summary (gpgme_signature_t sig) +{ + unsigned long sum = 0; + + if (sig->validity == GPGME_VALIDITY_FULL + || sig->validity == GPGME_VALIDITY_ULTIMATE) + { + if (gpg_err_code (sig->status) == GPG_ERR_NO_ERROR + || gpg_err_code (sig->status) == GPG_ERR_SIG_EXPIRED + || gpg_err_code (sig->status) == GPG_ERR_KEY_EXPIRED) + sum |= GPGME_SIGSUM_GREEN; + } + else if (sig->validity == GPGME_VALIDITY_NEVER) + { + if (gpg_err_code (sig->status) == GPG_ERR_NO_ERROR + || gpg_err_code (sig->status) == GPG_ERR_SIG_EXPIRED + || gpg_err_code (sig->status) == GPG_ERR_KEY_EXPIRED) + sum |= GPGME_SIGSUM_RED; + } + else if (gpg_err_code (sig->status) == GPG_ERR_BAD_SIGNATURE) + sum |= GPGME_SIGSUM_RED; + + /* FIXME: handle the case when key and message are expired. */ + switch (gpg_err_code (sig->status)) + { + case GPG_ERR_SIG_EXPIRED: + sum |= GPGME_SIGSUM_SIG_EXPIRED; + break; + + case GPG_ERR_KEY_EXPIRED: + sum |= GPGME_SIGSUM_KEY_EXPIRED; + break; + + case GPG_ERR_NO_PUBKEY: + sum |= GPGME_SIGSUM_KEY_MISSING; + break; + + case GPG_ERR_BAD_SIGNATURE: + case GPG_ERR_NO_ERROR: + break; + + default: + sum |= GPGME_SIGSUM_SYS_ERROR; + break; + } + + if (sig->wrong_key_usage) + sum |= GPGME_SIGSUM_BAD_POLICY; + + /* Set the valid flag when the signature is unquestionable + valid. */ + if ((sum & GPGME_SIGSUM_GREEN) && !(sum & ~GPGME_SIGSUM_GREEN)) + sum |= GPGME_SIGSUM_VALID; + + sig->summary = sum; +} + + +static gpgme_error_t +parse_new_sig (op_data_t opd, gpgme_status_code_t code, char *args) +{ + gpgme_signature_t sig; + char *end = strchr (args, ' '); + + if (end) + { + *end = '\0'; + end++; + } + + sig = calloc (1, sizeof (*sig)); + if (!sig) + return gpg_error_from_errno (errno); + if (!opd->result.signatures) + opd->result.signatures = sig; + if (opd->current_sig) + opd->current_sig->next = sig; + opd->current_sig = sig; + + /* FIXME: We should set the source of the state. */ + switch (code) + { + case GPGME_STATUS_GOODSIG: + sig->status = gpg_error (GPG_ERR_NO_ERROR); + break; + + case GPGME_STATUS_EXPSIG: + sig->status = gpg_error (GPG_ERR_SIG_EXPIRED); + break; + + case GPGME_STATUS_EXPKEYSIG: + sig->status = gpg_error (GPG_ERR_KEY_EXPIRED); + break; + + case GPGME_STATUS_BADSIG: + sig->status = gpg_error (GPG_ERR_BAD_SIGNATURE); + break; + + case GPGME_STATUS_ERRSIG: + if (end) + { + int i = 0; + /* The return code is the 6th argument, if it is 9, the + problem is a missing key. */ + while (end && i < 4) + { + end = strchr (end, ' '); + if (end) + end++; + i++; + } + if (end && end[0] && (!end[1] || end[1] == ' ')) + { + switch (end[0]) + { + case '4': + sig->status = gpg_error (GPG_ERR_UNSUPPORTED_ALGORITHM); + break; + + case '9': + sig->status = gpg_error (GPG_ERR_NO_PUBKEY); + break; + + default: + sig->status = gpg_error (GPG_ERR_GENERAL); + } + } + } + else + sig->status = gpg_error (GPG_ERR_GENERAL); + break; + + default: + return gpg_error (GPG_ERR_GENERAL); + } + + if (*args) + { + sig->fpr = strdup (args); + if (!sig->fpr) + return gpg_error_from_errno (errno); + } + return 0; +} + + +static gpgme_error_t +parse_valid_sig (gpgme_signature_t sig, char *args) +{ + char *end = strchr (args, ' '); + + if (end) + { + *end = '\0'; + end++; + } + + if (!*args) + /* We require at least the fingerprint. */ + return gpg_error (GPG_ERR_GENERAL); + + if (sig->fpr) + free (sig->fpr); + sig->fpr = strdup (args); + if (!sig->fpr) + return gpg_error_from_errno (errno); + + end = strchr (end, ' '); + if (end) + { + char *tail; + errno = 0; + sig->timestamp = strtol (end, &tail, 0); + if (errno || end == tail || (*tail && *tail != ' ')) + return gpg_error (GPG_ERR_INV_ENGINE); + end = tail; + + sig->exp_timestamp = strtol (end, &tail, 0); + if (errno || end == tail || (*tail && *tail != ' ')) + return gpg_error (GPG_ERR_INV_ENGINE); + } + return 0; +} + + +static gpgme_error_t +parse_notation (gpgme_signature_t sig, gpgme_status_code_t code, char *args) +{ + gpgme_error_t err; + gpgme_sig_notation_t *lastp = &sig->notations; + gpgme_sig_notation_t notation = sig->notations; + char *end = strchr (args, ' '); + + if (end) + *end = '\0'; + + if (code == GPGME_STATUS_NOTATION_NAME || code == GPGME_STATUS_POLICY_URL) + { + /* FIXME: We could keep a pointer to the last notation in the list. */ + while (notation && notation->value) + { + lastp = ¬ation->next; + notation = notation->next; + } + + if (notation) + /* There is another notation name without data for the + previous one. The crypto backend misbehaves. */ + return gpg_error (GPG_ERR_INV_ENGINE); + + notation = malloc (sizeof (*sig)); + if (!notation) + return gpg_error_from_errno (errno); + notation->next = NULL; + + if (code == GPGME_STATUS_NOTATION_NAME) + { + int len = strlen (args) + 1; + + notation->name = malloc (len); + if (!notation->name) + { + int saved_errno = errno; + free (notation); + return gpg_error_from_errno (saved_errno); + } + err = _gpgme_decode_percent_string (args, ¬ation->name, len); + if (err) + { + free (notation->name); + free (notation); + return err; + } + + notation->value = NULL; + } + else + { + int len = strlen (args) + 1; + + notation->name = NULL; + notation->value = malloc (len); + if (!notation->value) + { + int saved_errno = errno; + free (notation); + return gpg_error_from_errno (saved_errno); + } + err = _gpgme_decode_percent_string (args, ¬ation->value, len); + if (err) + { + free (notation->value); + free (notation); + return err; + } + } + *lastp = notation; + } + else if (code == GPGME_STATUS_NOTATION_DATA) + { + int len = strlen (args) + 1; + char *dest; + + /* FIXME: We could keep a pointer to the last notation in the list. */ + while (notation && notation->next) + { + lastp = ¬ation->next; + notation = notation->next; + } + + if (!notation || !notation->name) + /* There is notation data without a previous notation + name. The crypto backend misbehaves. */ + return gpg_error (GPG_ERR_INV_ENGINE); + + if (!notation->value) + { + dest = notation->value = malloc (len); + if (!dest) + return gpg_error_from_errno (errno); + } + else + { + int cur_len = strlen (notation->value); + dest = realloc (notation->value, len + strlen (notation->value)); + if (!dest) + return gpg_error_from_errno (errno); + notation->value = dest; + dest += cur_len; + } + + err = _gpgme_decode_percent_string (args, &dest, len); + if (err) + return err; + } + else + return gpg_error (GPG_ERR_INV_ENGINE); + return 0; +} + + +static gpgme_error_t +parse_trust (gpgme_signature_t sig, gpgme_status_code_t code, char *args) +{ + char *end = strchr (args, ' '); + + if (end) + *end = '\0'; + + switch (code) + { + case GPGME_STATUS_TRUST_UNDEFINED: + default: + sig->validity = GPGME_VALIDITY_UNKNOWN; + break; + + case GPGME_STATUS_TRUST_NEVER: + sig->validity = GPGME_VALIDITY_NEVER; + break; + + case GPGME_STATUS_TRUST_MARGINAL: + sig->validity = GPGME_VALIDITY_MARGINAL; + break; + + case GPGME_STATUS_TRUST_FULLY: + case GPGME_STATUS_TRUST_ULTIMATE: + sig->validity = GPGME_VALIDITY_FULL; + break; + } + + if (*args) + sig->validity_reason = _gpgme_map_gnupg_error (args); + + return 0; +} + + +static gpgme_error_t +parse_error (gpgme_signature_t sig, char *args) +{ + gpgme_error_t err; + char *where = strchr (args, ' '); + char *which; + + if (where) + { + *where = '\0'; + which = where + 1; + + where = strchr (which, ' '); + if (where) + *where = '\0'; + + where = args; + } + else + return gpg_error (GPG_ERR_INV_ENGINE); + + err = _gpgme_map_gnupg_error (which); + + if (!strcmp (where, "verify.findkey")) + sig->status = err; + else if (!strcmp (where, "verify.keyusage") + && gpg_err_code (err) == GPG_ERR_WRONG_KEY_USAGE) + sig->wrong_key_usage = 1; + + return 0; +} + + +gpgme_error_t +_gpgme_verify_status_handler (void *priv, gpgme_status_code_t code, char *args) +{ + gpgme_ctx_t ctx = (gpgme_ctx_t) priv; + gpgme_error_t err; + void *hook; + op_data_t opd; + gpgme_signature_t sig; + + err = _gpgme_op_data_lookup (ctx, OPDATA_VERIFY, &hook, -1, NULL); + opd = hook; + if (err) + return err; + + sig = opd->current_sig; + + switch (code) + { + case GPGME_STATUS_GOODSIG: + case GPGME_STATUS_EXPSIG: + case GPGME_STATUS_EXPKEYSIG: + case GPGME_STATUS_BADSIG: + case GPGME_STATUS_ERRSIG: + if (sig) + calc_sig_summary (sig); + return parse_new_sig (opd, code, args); + + case GPGME_STATUS_VALIDSIG: + return sig ? parse_valid_sig (sig, args) + : gpg_error (GPG_ERR_INV_ENGINE); + + case GPGME_STATUS_NODATA: + if (!sig) + return gpg_error (GPG_ERR_NO_DATA); + sig->status = gpg_error (GPG_ERR_NO_DATA); + break; + + case GPGME_STATUS_UNEXPECTED: + if (!sig) + return gpg_error (GPG_ERR_GENERAL); + sig->status = gpg_error (GPG_ERR_NO_DATA); + break; + + case GPGME_STATUS_NOTATION_NAME: + case GPGME_STATUS_NOTATION_DATA: + case GPGME_STATUS_POLICY_URL: + return sig ? parse_notation (sig, code, args) + : gpg_error (GPG_ERR_INV_ENGINE); + + case GPGME_STATUS_TRUST_UNDEFINED: + case GPGME_STATUS_TRUST_NEVER: + case GPGME_STATUS_TRUST_MARGINAL: + case GPGME_STATUS_TRUST_FULLY: + case GPGME_STATUS_TRUST_ULTIMATE: + return sig ? parse_trust (sig, code, args) + : gpg_error (GPG_ERR_INV_ENGINE); + + case GPGME_STATUS_ERROR: + return sig ? parse_error (sig, args) : gpg_error (GPG_ERR_INV_ENGINE); + + case GPGME_STATUS_EOF: + if (sig) + calc_sig_summary (sig); + break; + + default: + break; + } + return 0; +} + + +static gpgme_error_t +verify_status_handler (void *priv, gpgme_status_code_t code, char *args) +{ + gpgme_error_t err; + + err = _gpgme_progress_status_handler (priv, code, args); + if (!err) + err = _gpgme_verify_status_handler (priv, code, args); + return err; +} + + +gpgme_error_t +_gpgme_op_verify_init_result (gpgme_ctx_t ctx) +{ + void *hook; + op_data_t opd; + + return _gpgme_op_data_lookup (ctx, OPDATA_VERIFY, &hook, + sizeof (*opd), release_op_data); +} + + +static gpgme_error_t +verify_start (gpgme_ctx_t ctx, int synchronous, gpgme_data_t sig, + gpgme_data_t signed_text, gpgme_data_t plaintext) +{ + gpgme_error_t err; + + err = _gpgme_op_reset (ctx, synchronous); + if (err) + return err; + + err = _gpgme_op_verify_init_result (ctx); + if (err) + return err; + + _gpgme_engine_set_status_handler (ctx->engine, verify_status_handler, ctx); + + if (!sig) + return gpg_error (GPG_ERR_NO_DATA); + if (!signed_text && !plaintext) + return gpg_error (GPG_ERR_INV_VALUE); + + return _gpgme_engine_op_verify (ctx->engine, sig, signed_text, plaintext); +} + + +/* Decrypt ciphertext CIPHER and make a signature verification within + CTX and store the resulting plaintext in PLAIN. */ +gpgme_error_t +gpgme_op_verify_start (gpgme_ctx_t ctx, gpgme_data_t sig, + gpgme_data_t signed_text, gpgme_data_t plaintext) +{ + return verify_start (ctx, 0, sig, signed_text, plaintext); +} + + +/* Decrypt ciphertext CIPHER and make a signature verification within + CTX and store the resulting plaintext in PLAIN. */ +gpgme_error_t +gpgme_op_verify (gpgme_ctx_t ctx, gpgme_data_t sig, gpgme_data_t signed_text, + gpgme_data_t plaintext) +{ + gpgme_error_t err; + + err = verify_start (ctx, 1, sig, signed_text, plaintext); + if (!err) + err = _gpgme_wait_one (ctx); + return err; +} + + +/* Compatibility interfaces. */ + +/* Get the key used to create signature IDX in CTX and return it in + R_KEY. */ +gpgme_error_t +gpgme_get_sig_key (gpgme_ctx_t ctx, int idx, gpgme_key_t *r_key) +{ + 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); +} + + +/* Retrieve the signature status of signature IDX in CTX after a + successful verify operation in R_STAT (if non-null). The creation + time stamp of the signature is returned in R_CREATED (if non-null). + The function returns a string containing the fingerprint. */ +const char *gpgme_get_sig_status (gpgme_ctx_t ctx, int idx, + _gpgme_sig_stat_t *r_stat, time_t *r_created) +{ + 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; +} + + +/* Retrieve certain attributes of a signature. IDX is the index + number of the signature after a successful verify operation. WHAT + is an attribute where GPGME_ATTR_EXPIRE is probably the most useful + one. WHATIDX is to be passed as 0 for most attributes . */ +unsigned long gpgme_get_sig_ulong_attr (gpgme_ctx_t ctx, int idx, + _gpgme_attr_t what, int whatidx) +{ + 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 (gpg_err_code (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; +} + + +const char *gpgme_get_sig_string_attr (gpgme_ctx_t ctx, int idx, + _gpgme_attr_t what, int whatidx) +{ + 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; +} diff --git a/tags/gpgme-0-4-3/gpgme/version.c b/tags/gpgme-0-4-3/gpgme/version.c new file mode 100644 index 0000000..e2c4ef8 --- /dev/null +++ b/tags/gpgme-0-4-3/gpgme/version.c @@ -0,0 +1,219 @@ +/* version.c - Version check routines. + Copyright (C) 2000 Werner Koch (dd9jn) + Copyright (C) 2001, 2002, 2003 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 + 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. */ + +#if HAVE_CONFIG_H +#include +#endif +#include +#include +#include + +#include "gpgme.h" +#include "io.h" + +/* For _gpgme_sema_subsystem_init (). */ +#include "sema.h" + + +/* Bootstrap the subsystems needed for concurrent operation. This + must be done once at startup. We can not guarantee this using a + lock, though, because the semaphore subsystem needs to be + initialized itself before it can be used. So we expect that the + user performs the necessary syncrhonization. */ +static void +do_subsystem_inits (void) +{ + static int done = 0; + + if (done) + return; + + _gpgme_sema_subsystem_init (); + _gpgme_io_subsystem_init (); + + done = 1; +} + + +/* Read the next number in the version string STR and return it in + *NUMBER. Return a pointer to the tail of STR after parsing, or + *NULL if the version string was invalid. */ +static const char * +parse_version_number (const char *str, int *number) +{ +#define MAXVAL ((INT_MAX - 10) / 10) + int val = 0; + + /* Leading zeros are not allowed. */ + if (*str == '0' && isdigit(str[1])) + return NULL; + + while (isdigit (*str) && val <= MAXVAL) + { + val *= 10; + val += *(str++) - '0'; + } + *number = val; + return val > MAXVAL ? NULL : str; +} + + +/* Parse the version string STR in the format MAJOR.MINOR.MICRO (for + example, 9.3.2) and return the components in MAJOR, MINOR and MICRO + as integers. The function returns the tail of the string that + follows the version number. This might be te empty string if there + is nothing following the version number, or a patchlevel. The + function returns NULL if the version string is not valid. */ +static const char * +parse_version_string (const char *str, int *major, int *minor, int *micro) +{ + str = parse_version_number (str, major); + if (!str || *str != '.') + return NULL; + str++; + + str = parse_version_number (str, minor); + if (!str || *str != '.') + return NULL; + str++; + + str = parse_version_number (str, micro); + if (!str) + return NULL; + + /* A patchlevel might follow. */ + return str; +} + + +const char * +_gpgme_compare_versions (const char *my_version, + const char *rq_version) +{ + int my_major, my_minor, my_micro; + int rq_major, rq_minor, rq_micro; + const char *my_plvl, *rq_plvl; + + if (!rq_version) + return my_version; + if (!my_version) + return NULL; + + my_plvl = parse_version_string (my_version, &my_major, &my_minor, &my_micro); + if (!my_plvl) + return NULL; + + rq_plvl = parse_version_string (rq_version, &rq_major, &rq_minor, &rq_micro); + if (!rq_plvl) + return NULL; + + if (my_major > rq_major + || (my_major == rq_major && my_minor > rq_minor) + || (my_major == rq_major && my_minor == rq_minor + && my_micro > rq_micro) + || (my_major == rq_major && my_minor == rq_minor + && my_micro == rq_micro && strcmp (my_plvl, rq_plvl) >= 0)) + return my_version; + + return NULL; +} + + +/* Check that the the version of the library is at minimum the + requested one and return the version string; return NULL if the + condition is not met. If a NULL is passed to this function, no + check is done and the version string is simply returned. + + This function must be run once at startup, as it also initializes + some subsystems. Its invocation must be synchronized against + calling any of the other functions in a multi-threaded + environments. */ +const char * +gpgme_check_version (const char *req_version) +{ + do_subsystem_inits (); + return _gpgme_compare_versions (VERSION, req_version); +} + + +#define LINELENGTH 80 + +/* Retrieve the version number from the --version output of the + program FILE_NAME. */ +char * +_gpgme_get_program_version (const char *const file_name) +{ + char line[LINELENGTH] = ""; + int linelen = 0; + char *mark = NULL; + int rp[2]; + int nread; + char *argv[] = {NULL /* file_name */, "--version", 0}; + struct spawn_fd_item_s pfd[] = { {0, -1}, {-1, -1} }; + struct spawn_fd_item_s cfd[] = { {-1, 1 /* STDOUT_FILENO */}, {-1, -1} }; + int status; + + if (!file_name) + return NULL; + argv[0] = (char *) file_name; + + if (_gpgme_io_pipe (rp, 1) < 0) + return NULL; + + pfd[0].fd = rp[1]; + cfd[0].fd = rp[1]; + + status = _gpgme_io_spawn (file_name, argv, cfd, pfd); + if (status < 0) + { + _gpgme_io_close (rp[0]); + _gpgme_io_close (rp[1]); + return NULL; + } + + do + { + nread = _gpgme_io_read (rp[0], &line[linelen], LINELENGTH - linelen - 1); + if (nread > 0) + { + line[linelen + nread] = '\0'; + mark = strchr (&line[linelen], '\n'); + if (mark) + { + *mark = '\0'; + break; + } + linelen += nread; + } + } + while (nread > 0 && linelen < LINELENGTH - 1); + + _gpgme_io_close (rp[0]); + + if (mark) + { + mark = strrchr (line, ' '); + if (!mark) + return NULL; + return strdup (mark + 1); + } + + return NULL; +} diff --git a/tags/gpgme-0-4-3/gpgme/w32-io.c b/tags/gpgme-0-4-3/gpgme/w32-io.c new file mode 100644 index 0000000..24082bd --- /dev/null +++ b/tags/gpgme-0-4-3/gpgme/w32-io.c @@ -0,0 +1,1117 @@ +/* w32-io.c - W32 API I/O functions. + Copyright (C) 2000 Werner Koch (dd9jn) + Copyright (C) 2001, 2002, 2003 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 + 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. */ + +#ifdef HAVE_CONFIG_H +#include +#endif +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include "util.h" +#include "sema.h" +#include "io.h" + + +/* We assume that a HANDLE can be represented by an int which should + be true for all i386 systems (HANDLE is defined as void *) and + these are the only systems for which Windows is available. Further + we assume that -1 denotes an invalid handle. */ + +#define fd_to_handle(a) ((HANDLE)(a)) +#define handle_to_fd(a) ((int)(a)) +#define pid_to_handle(a) ((HANDLE)(a)) +#define handle_to_pid(a) ((int)(a)) + +#define READBUF_SIZE 4096 +#define WRITEBUF_SIZE 4096 +#define MAX_READERS 20 +#define MAX_WRITERS 20 + +static struct { + int inuse; + int fd; + void (*handler)(int,void*); + void *value; +} notify_table[256]; +DEFINE_STATIC_LOCK (notify_table_lock); + + +struct reader_context_s { + HANDLE file_hd; + HANDLE thread_hd; + DECLARE_LOCK (mutex); + + int stop_me; + int eof; + int eof_shortcut; + int error; + int error_code; + + HANDLE have_data_ev; /* manually reset */ + HANDLE have_space_ev; /* auto reset */ + HANDLE stopped; + size_t readpos, writepos; + char buffer[READBUF_SIZE]; +}; + + +static struct { + volatile int used; + int fd; + struct reader_context_s *context; +} reader_table[MAX_READERS]; +static int reader_table_size= MAX_READERS; +DEFINE_STATIC_LOCK (reader_table_lock); + + +struct writer_context_s { + HANDLE file_hd; + HANDLE thread_hd; + DECLARE_LOCK (mutex); + + int stop_me; + int error; + int error_code; + + HANDLE have_data; /* manually reset */ + HANDLE is_empty; + HANDLE stopped; + size_t nbytes; + char buffer[WRITEBUF_SIZE]; +}; + + +static struct { + volatile int used; + int fd; + struct writer_context_s *context; +} writer_table[MAX_WRITERS]; +static int writer_table_size= MAX_WRITERS; +DEFINE_STATIC_LOCK (writer_table_lock); + + + +static HANDLE +set_synchronize (HANDLE h) +{ + HANDLE tmp; + + /* For NT we have to set the sync flag. It seems that the only + * way to do it is by duplicating the handle. Tsss.. */ + if (!DuplicateHandle( GetCurrentProcess(), h, + GetCurrentProcess(), &tmp, + EVENT_MODIFY_STATE|SYNCHRONIZE, FALSE, 0 ) ) { + DEBUG1 ("** Set SYNCRONIZE failed: ec=%d\n", (int)GetLastError()); + } + else { + CloseHandle (h); + h = tmp; + } + return h; +} + + + +static DWORD CALLBACK +reader (void *arg) +{ + struct reader_context_s *c = arg; + int nbytes; + DWORD nread; + + DEBUG2 ("reader thread %p for file %p started", c->thread_hd, c->file_hd ); + for (;;) { + LOCK (c->mutex); + /* leave a 1 byte gap so that we can see whether it is empty or full*/ + if ((c->writepos + 1) % READBUF_SIZE == c->readpos) { + /* wait for space */ + if (!ResetEvent (c->have_space_ev) ) + DEBUG1 ("ResetEvent failed: ec=%d", (int)GetLastError ()); + UNLOCK (c->mutex); + DEBUG1 ("reader thread %p: waiting for space ...", c->thread_hd ); + WaitForSingleObject (c->have_space_ev, INFINITE); + DEBUG1 ("reader thread %p: got space", c->thread_hd ); + LOCK (c->mutex); + } + if ( c->stop_me ) { + UNLOCK (c->mutex); + break; + } + nbytes = (c->readpos + READBUF_SIZE - c->writepos-1) % READBUF_SIZE; + if ( nbytes > READBUF_SIZE - c->writepos ) + nbytes = READBUF_SIZE - c->writepos; + UNLOCK (c->mutex); + + DEBUG2 ("reader thread %p: reading %d bytes", c->thread_hd, nbytes ); + if ( !ReadFile ( c->file_hd, + c->buffer+c->writepos, nbytes, &nread, NULL) ) { + c->error_code = (int)GetLastError (); + if (c->error_code == ERROR_BROKEN_PIPE ) { + c->eof=1; + DEBUG1 ("reader thread %p: got eof (broken pipe)", + c->thread_hd ); + } + else { + c->error = 1; + DEBUG2 ("reader thread %p: read error: ec=%d", + c->thread_hd, c->error_code ); + } + break; + } + if ( !nread ) { + c->eof = 1; + DEBUG1 ("reader thread %p: got eof", c->thread_hd ); + break; + } + DEBUG2 ("reader thread %p: got %d bytes", c->thread_hd, (int)nread ); + + LOCK (c->mutex); + if (c->stop_me) { + UNLOCK (c->mutex); + break; + } + c->writepos = (c->writepos + nread) % READBUF_SIZE; + if ( !SetEvent (c->have_data_ev) ) + DEBUG1 ("SetEvent failed: ec=%d", (int)GetLastError ()); + UNLOCK (c->mutex); + } + /* indicate that we have an error or eof */ + if ( !SetEvent (c->have_data_ev) ) + DEBUG1 ("SetEvent failed: ec=%d", (int)GetLastError ()); + DEBUG1 ("reader thread %p ended", c->thread_hd ); + SetEvent (c->stopped); + + return 0; +} + + +static struct reader_context_s * +create_reader (HANDLE fd) +{ + struct reader_context_s *c; + SECURITY_ATTRIBUTES sec_attr; + DWORD tid; + + DEBUG1 ("creating new read thread for file handle %p", fd ); + memset (&sec_attr, 0, sizeof sec_attr ); + sec_attr.nLength = sizeof sec_attr; + sec_attr.bInheritHandle = FALSE; + + c = calloc (1, sizeof *c ); + if (!c) + return NULL; + + c->file_hd = fd; + c->have_data_ev = CreateEvent (&sec_attr, TRUE, FALSE, NULL); + c->have_space_ev = CreateEvent (&sec_attr, FALSE, TRUE, NULL); + c->stopped = CreateEvent (&sec_attr, TRUE, FALSE, NULL); + if (!c->have_data_ev || !c->have_space_ev || !c->stopped ) { + DEBUG1 ("** CreateEvent failed: ec=%d\n", (int)GetLastError ()); + if (c->have_data_ev) + CloseHandle (c->have_data_ev); + if (c->have_space_ev) + CloseHandle (c->have_space_ev); + if (c->stopped) + CloseHandle (c->stopped); + free (c); + return NULL; + } + + c->have_data_ev = set_synchronize (c->have_data_ev); + INIT_LOCK (c->mutex); + + c->thread_hd = CreateThread (&sec_attr, 0, reader, c, 0, &tid ); + if (!c->thread_hd) { + DEBUG1 ("** failed to create reader thread: ec=%d\n", + (int)GetLastError ()); + DESTROY_LOCK (c->mutex); + if (c->have_data_ev) + CloseHandle (c->have_data_ev); + if (c->have_space_ev) + CloseHandle (c->have_space_ev); + if (c->stopped) + CloseHandle (c->stopped); + free (c); + return NULL; + } + + return c; +} + +static void +destroy_reader (struct reader_context_s *c) +{ + LOCK (c->mutex); + c->stop_me = 1; + if (c->have_space_ev) + SetEvent (c->have_space_ev); + UNLOCK (c->mutex); + + DEBUG1 ("waiting for thread %p termination ...", c->thread_hd ); + WaitForSingleObject (c->stopped, INFINITE); + DEBUG1 ("thread %p has terminated", c->thread_hd ); + + if (c->stopped) + CloseHandle (c->stopped); + if (c->have_data_ev) + CloseHandle (c->have_data_ev); + if (c->have_space_ev) + CloseHandle (c->have_space_ev); + CloseHandle (c->thread_hd); + DESTROY_LOCK (c->mutex); + free (c); +} + + +/* + * Find a reader context or create a new one + * Note that the reader context will last until a io_close. + */ +static struct reader_context_s * +find_reader (int fd, int start_it) +{ + int i; + + for (i=0; i < reader_table_size ; i++ ) { + if ( reader_table[i].used && reader_table[i].fd == fd ) + return reader_table[i].context; + } + if (!start_it) + return NULL; + + LOCK (reader_table_lock); + for (i=0; i < reader_table_size; i++ ) { + if (!reader_table[i].used) { + reader_table[i].fd = fd; + reader_table[i].context = create_reader (fd_to_handle (fd)); + reader_table[i].used = 1; + UNLOCK (reader_table_lock); + return reader_table[i].context; + } + } + UNLOCK (reader_table_lock); + return NULL; +} + + +static void +kill_reader (int fd) +{ + int i; + + LOCK (reader_table_lock); + for (i=0; i < reader_table_size; i++ ) { + if (reader_table[i].used && reader_table[i].fd == fd ) { + destroy_reader (reader_table[i].context); + reader_table[i].context = NULL; + reader_table[i].used = 0; + break; + } + } + UNLOCK (reader_table_lock); +} + + + +int +_gpgme_io_read ( int fd, void *buffer, size_t count ) +{ + int nread; + struct reader_context_s *c = find_reader (fd,1); + + DEBUG2 ("fd %d: about to read %d bytes\n", fd, (int)count ); + if ( !c ) { + DEBUG0 ( "no reader thread\n"); + return -1; + } + if (c->eof_shortcut) { + DEBUG1 ("fd %d: EOF (again)", fd ); + return 0; + } + + LOCK (c->mutex); + if (c->readpos == c->writepos && !c->error) { /*no data avail*/ + UNLOCK (c->mutex); + DEBUG2 ("fd %d: waiting for data from thread %p", fd, c->thread_hd); + WaitForSingleObject (c->have_data_ev, INFINITE); + DEBUG2 ("fd %d: data from thread %p available", fd, c->thread_hd); + LOCK (c->mutex); + } + + if (c->readpos == c->writepos || c->error) { + UNLOCK (c->mutex); + c->eof_shortcut = 1; + if (c->eof) { + DEBUG1 ("fd %d: EOF", fd ); + return 0; + } + if (!c->error) { + DEBUG1 ("fd %d: EOF but eof flag not set", fd ); + return 0; + } + DEBUG1 ("fd %d: read error", fd ); + return -1; + } + + nread = c->readpos < c->writepos? c->writepos - c->readpos + : READBUF_SIZE - c->readpos; + if (nread > count) + nread = count; + memcpy (buffer, c->buffer+c->readpos, nread); + c->readpos = (c->readpos + nread) % READBUF_SIZE; + if (c->readpos == c->writepos && !c->eof) { + if ( !ResetEvent (c->have_data_ev) ) + DEBUG1 ("ResetEvent failed: ec=%d", (int)GetLastError ()); + } + if (!SetEvent (c->have_space_ev)) + DEBUG1 ("SetEvent failed: ec=%d", (int)GetLastError ()); + UNLOCK (c->mutex); + + DEBUG2 ("fd %d: got %d bytes\n", fd, nread ); + + return nread; +} + + + +/* + * The writer does use a simple buffering strategy so that we are + * informed about write errors as soon as possible (i.e. with the the + * next call to the write function + */ +static DWORD CALLBACK +writer (void *arg) +{ + struct writer_context_s *c = arg; + DWORD nwritten; + + DEBUG2 ("writer thread %p for file %p started", c->thread_hd, c->file_hd ); + for (;;) { + LOCK (c->mutex); + if ( !c->nbytes ) { + if (!ResetEvent (c->have_data) ) + DEBUG1 ("ResetEvent failed: ec=%d", (int)GetLastError ()); + UNLOCK (c->mutex); + DEBUG1 ("writer thread %p: idle ...", c->thread_hd ); + WaitForSingleObject (c->have_data, INFINITE); + DEBUG1 ("writer thread %p: got data to send", c->thread_hd ); + LOCK (c->mutex); + } + if ( c->stop_me ) { + UNLOCK (c->mutex); + break; + } + UNLOCK (c->mutex); + + DEBUG2 ("writer thread %p: writing %d bytes", + c->thread_hd, c->nbytes ); + if ( c->nbytes && !WriteFile ( c->file_hd, c->buffer, c->nbytes, + &nwritten, NULL)) { + c->error_code = (int)GetLastError (); + c->error = 1; + DEBUG2 ("writer thread %p: write error: ec=%d", + c->thread_hd, c->error_code ); + break; + } + DEBUG2 ("writer thread %p: wrote %d bytes", + c->thread_hd, (int)nwritten ); + + LOCK (c->mutex); + c->nbytes -= nwritten; + if (c->stop_me) { + UNLOCK (c->mutex); + break; + } + if ( !c->nbytes ) { + if ( !SetEvent (c->is_empty) ) + DEBUG1 ("SetEvent failed: ec=%d", (int)GetLastError ()); + } + UNLOCK (c->mutex); + } + /* indicate that we have an error */ + if ( !SetEvent (c->is_empty) ) + DEBUG1 ("SetEvent failed: ec=%d", (int)GetLastError ()); + DEBUG1 ("writer thread %p ended", c->thread_hd ); + SetEvent (c->stopped); + + return 0; +} + + +static struct writer_context_s * +create_writer (HANDLE fd) +{ + struct writer_context_s *c; + SECURITY_ATTRIBUTES sec_attr; + DWORD tid; + + DEBUG1 ("creating new write thread for file handle %p", fd ); + memset (&sec_attr, 0, sizeof sec_attr ); + sec_attr.nLength = sizeof sec_attr; + sec_attr.bInheritHandle = FALSE; + + c = calloc (1, sizeof *c ); + if (!c) + return NULL; + + c->file_hd = fd; + c->have_data = CreateEvent (&sec_attr, FALSE, FALSE, NULL); + c->is_empty = CreateEvent (&sec_attr, TRUE, TRUE, NULL); + c->stopped = CreateEvent (&sec_attr, TRUE, FALSE, NULL); + if (!c->have_data || !c->is_empty || !c->stopped ) { + DEBUG1 ("** CreateEvent failed: ec=%d\n", (int)GetLastError ()); + if (c->have_data) + CloseHandle (c->have_data); + if (c->is_empty) + CloseHandle (c->is_empty); + if (c->stopped) + CloseHandle (c->stopped); + free (c); + return NULL; + } + + c->is_empty = set_synchronize (c->is_empty); + INIT_LOCK (c->mutex); + + c->thread_hd = CreateThread (&sec_attr, 0, writer, c, 0, &tid ); + if (!c->thread_hd) { + DEBUG1 ("** failed to create writer thread: ec=%d\n", + (int)GetLastError ()); + DESTROY_LOCK (c->mutex); + if (c->have_data) + CloseHandle (c->have_data); + if (c->is_empty) + CloseHandle (c->is_empty); + if (c->stopped) + CloseHandle (c->stopped); + free (c); + return NULL; + } + + return c; +} + +static void +destroy_writer (struct writer_context_s *c) +{ + LOCK (c->mutex); + c->stop_me = 1; + if (c->have_data) + SetEvent (c->have_data); + UNLOCK (c->mutex); + + DEBUG1 ("waiting for thread %p termination ...", c->thread_hd ); + WaitForSingleObject (c->stopped, INFINITE); + DEBUG1 ("thread %p has terminated", c->thread_hd ); + + if (c->stopped) + CloseHandle (c->stopped); + if (c->have_data) + CloseHandle (c->have_data); + if (c->is_empty) + CloseHandle (c->is_empty); + CloseHandle (c->thread_hd); + DESTROY_LOCK (c->mutex); + free (c); +} + + +/* + * Find a writer context or create a new one + * Note that the writer context will last until a io_close. + */ +static struct writer_context_s * +find_writer (int fd, int start_it) +{ + int i; + + for (i=0; i < writer_table_size ; i++ ) { + if ( writer_table[i].used && writer_table[i].fd == fd ) + return writer_table[i].context; + } + if (!start_it) + return NULL; + + LOCK (writer_table_lock); + for (i=0; i < writer_table_size; i++ ) { + if (!writer_table[i].used) { + writer_table[i].fd = fd; + writer_table[i].context = create_writer (fd_to_handle (fd)); + writer_table[i].used = 1; + UNLOCK (writer_table_lock); + return writer_table[i].context; + } + } + UNLOCK (writer_table_lock); + return NULL; +} + + +static void +kill_writer (int fd) +{ + int i; + + LOCK (writer_table_lock); + for (i=0; i < writer_table_size; i++ ) { + if (writer_table[i].used && writer_table[i].fd == fd ) { + destroy_writer (writer_table[i].context); + writer_table[i].context = NULL; + writer_table[i].used = 0; + break; + } + } + UNLOCK (writer_table_lock); +} + + + + +int +_gpgme_io_write ( int fd, const void *buffer, size_t count ) +{ + struct writer_context_s *c = find_writer (fd,1); + + DEBUG2 ("fd %d: about to write %d bytes\n", fd, (int)count ); + if ( !c ) { + DEBUG0 ( "no writer thread\n"); + return -1; + } + + LOCK (c->mutex); + if ( c->nbytes ) { /* bytes are pending for send */ + UNLOCK (c->mutex); + DEBUG2 ("fd %d: waiting for empty buffer in thread %p", + fd, c->thread_hd); + WaitForSingleObject (c->is_empty, INFINITE); + DEBUG2 ("fd %d: thread %p buffer is empty", fd, c->thread_hd); + assert (!c->nbytes); + LOCK (c->mutex); + } + + if ( c->error) { + UNLOCK (c->mutex); + DEBUG1 ("fd %d: write error", fd ); + return -1; + } + + if (count > WRITEBUF_SIZE) + count = WRITEBUF_SIZE; + memcpy (c->buffer, buffer, count); + c->nbytes = count; + if (!SetEvent (c->have_data)) + DEBUG1 ("SetEvent failed: ec=%d", (int)GetLastError ()); + UNLOCK (c->mutex); + + DEBUG2 ("fd %d: copied %d bytes\n", + fd, (int)count ); + return (int)count; +} + + +int +_gpgme_io_pipe ( int filedes[2], int inherit_idx ) +{ + HANDLE r, w; + SECURITY_ATTRIBUTES sec_attr; + + memset (&sec_attr, 0, sizeof sec_attr ); + sec_attr.nLength = sizeof sec_attr; + sec_attr.bInheritHandle = FALSE; + + if (!CreatePipe ( &r, &w, &sec_attr, 0)) + return -1; + /* make one end inheritable */ + if ( inherit_idx == 0 ) { + HANDLE h; + if (!DuplicateHandle( GetCurrentProcess(), r, + GetCurrentProcess(), &h, 0, + TRUE, DUPLICATE_SAME_ACCESS ) ) { + DEBUG1 ("DuplicateHandle failed: ec=%d\n", (int)GetLastError()); + CloseHandle (r); + CloseHandle (w); + return -1; + } + CloseHandle (r); + r = h; + } + else if ( inherit_idx == 1 ) { + HANDLE h; + if (!DuplicateHandle( GetCurrentProcess(), w, + GetCurrentProcess(), &h, 0, + TRUE, DUPLICATE_SAME_ACCESS ) ) { + DEBUG1 ("DuplicateHandle failed: ec=%d\n", (int)GetLastError()); + CloseHandle (r); + CloseHandle (w); + return -1; + } + CloseHandle (w); + w = h; + } + + filedes[0] = handle_to_fd (r); + filedes[1] = handle_to_fd (w); + DEBUG5 ("CreatePipe %p %p %d %d inherit=%d\n", r, w, + filedes[0], filedes[1], inherit_idx ); + return 0; +} + +int +_gpgme_io_close ( int fd ) +{ + int i; + void (*handler)(int, void*) = NULL; + void *value = NULL; + + if ( fd == -1 ) + return -1; + + DEBUG1 ("** closing handle for fd %d\n", fd); + kill_reader (fd); + kill_writer (fd); + LOCK (notify_table_lock); + for ( i=0; i < DIM (notify_table); i++ ) { + if (notify_table[i].inuse && notify_table[i].fd == fd) { + handler = notify_table[i].handler; + value = notify_table[i].value; + notify_table[i].handler = NULL; + notify_table[i].value = NULL; + notify_table[i].inuse = 0; + break; + } + } + UNLOCK (notify_table_lock); + if (handler) + handler (fd, value); + + if ( !CloseHandle (fd_to_handle (fd)) ) { + DEBUG2 ("CloseHandle for fd %d failed: ec=%d\n", + fd, (int)GetLastError ()); + return -1; + } + + return 0; +} + +int +_gpgme_io_set_close_notify (int fd, void (*handler)(int, void*), void *value) +{ + int i; + + assert (fd != -1); + + LOCK (notify_table_lock); + for (i=0; i < DIM (notify_table); i++ ) { + if ( notify_table[i].inuse && notify_table[i].fd == fd ) + break; + } + if ( i == DIM (notify_table) ) { + for (i=0; i < DIM (notify_table); i++ ) { + if ( !notify_table[i].inuse ) + break; + } + } + if ( i == DIM (notify_table) ) { + UNLOCK (notify_table_lock); + return -1; + } + notify_table[i].fd = fd; + notify_table[i].handler = handler; + notify_table[i].value = value; + notify_table[i].inuse = 1; + UNLOCK (notify_table_lock); + DEBUG2 ("set notification for fd %d (idx=%d)", fd, i ); + return 0; +} + + +int +_gpgme_io_set_nonblocking ( int fd ) +{ + return 0; +} + + +static char * +build_commandline ( char **argv ) +{ + int i, n = 0; + char *buf, *p; + + /* FIXME: we have to quote some things because under Windows the + * program parses the commandline and does some unquoting */ + for (i=0; argv[i]; i++) + n += strlen (argv[i]) + 2 + 1; /* 2 extra bytes for possible quoting */ + buf = p = malloc (n); + if ( !buf ) + return NULL; + *buf = 0; + if ( argv[0] ) + p = stpcpy (p, argv[0]); + for (i = 1; argv[i]; i++) { + if (!*argv[i]) + p = stpcpy (p, " \"\""); + else + p = stpcpy (stpcpy (p, " "), argv[i]); + } + + return buf; +} + + +int +_gpgme_io_spawn ( const char *path, char **argv, + struct spawn_fd_item_s *fd_child_list, + struct spawn_fd_item_s *fd_parent_list ) +{ + SECURITY_ATTRIBUTES sec_attr; + PROCESS_INFORMATION pi = { + NULL, /* returns process handle */ + 0, /* returns primary thread handle */ + 0, /* returns pid */ + 0 /* returns tid */ + }; + STARTUPINFO si; + char *envblock = NULL; + int cr_flags = CREATE_DEFAULT_ERROR_MODE + | GetPriorityClass (GetCurrentProcess ()); + int i; + char *arg_string; + int duped_stdin = 0; + int duped_stderr = 0; + HANDLE hnul = INVALID_HANDLE_VALUE; + /* FIXME. */ + int debug_me = 0; + + memset (&sec_attr, 0, sizeof sec_attr ); + sec_attr.nLength = sizeof sec_attr; + sec_attr.bInheritHandle = FALSE; + + arg_string = build_commandline ( argv ); + if (!arg_string ) + return -1; + + memset (&si, 0, sizeof si); + si.cb = sizeof (si); + si.dwFlags = STARTF_USESTDHANDLES | STARTF_USESHOWWINDOW; + si.wShowWindow = debug_me? SW_SHOW : SW_MINIMIZE; + si.hStdInput = GetStdHandle (STD_INPUT_HANDLE); + si.hStdOutput = GetStdHandle (STD_OUTPUT_HANDLE); + si.hStdError = GetStdHandle (STD_ERROR_HANDLE); + + for (i=0; fd_child_list[i].fd != -1; i++ ) { + if (fd_child_list[i].dup_to == 0 ) { + si.hStdInput = fd_to_handle (fd_child_list[i].fd); + DEBUG1 ("using %d for stdin", fd_child_list[i].fd ); + duped_stdin=1; + } + else if (fd_child_list[i].dup_to == 1 ) { + si.hStdOutput = fd_to_handle (fd_child_list[i].fd); + DEBUG1 ("using %d for stdout", fd_child_list[i].fd ); + } + else if (fd_child_list[i].dup_to == 2 ) { + si.hStdError = fd_to_handle (fd_child_list[i].fd); + DEBUG1 ("using %d for stderr", fd_child_list[i].fd ); + duped_stderr = 1; + } + } + + if( !duped_stdin || !duped_stderr ) { + SECURITY_ATTRIBUTES sa; + + memset (&sa, 0, sizeof sa ); + sa.nLength = sizeof sa; + sa.bInheritHandle = TRUE; + hnul = CreateFile ( "nul", + GENERIC_READ|GENERIC_WRITE, + FILE_SHARE_READ|FILE_SHARE_WRITE, + &sa, + OPEN_EXISTING, + FILE_ATTRIBUTE_NORMAL, + NULL ); + if ( hnul == INVALID_HANDLE_VALUE ) { + DEBUG1 ("can't open `nul': ec=%d\n", (int)GetLastError ()); + free (arg_string); + return -1; + } + /* Make sure that the process has a connected stdin */ + if ( !duped_stdin ) { + si.hStdInput = hnul; + DEBUG1 ("using %d for dummy stdin", (int)hnul ); + } + /* We normally don't want all the normal output */ + if ( !duped_stderr ) { + si.hStdError = hnul; + DEBUG1 ("using %d for dummy stderr", (int)hnul ); + } + } + + DEBUG2 ("CreateProcess, path=`%s' args=`%s'", path, arg_string); + cr_flags |= CREATE_SUSPENDED; + if ( !CreateProcessA (path, + arg_string, + &sec_attr, /* process security attributes */ + &sec_attr, /* thread security attributes */ + TRUE, /* inherit handles */ + cr_flags, /* creation flags */ + envblock, /* environment */ + NULL, /* use current drive/directory */ + &si, /* startup information */ + &pi /* returns process information */ + ) ) { + DEBUG1 ("CreateProcess failed: ec=%d\n", (int) GetLastError ()); + free (arg_string); + return -1; + } + + /* close the /dev/nul handle if used */ + if (hnul != INVALID_HANDLE_VALUE ) { + if ( !CloseHandle ( hnul ) ) + DEBUG1 ("CloseHandle(hnul) failed: ec=%d\n", (int)GetLastError()); + } + + /* Close the other ends of the pipes */ + for (i = 0; fd_parent_list[i].fd != -1; i++) + _gpgme_io_close (fd_parent_list[i].fd); + + DEBUG4 ("CreateProcess ready\n" + "- hProcess=%p hThread=%p\n" + "- dwProcessID=%d dwThreadId=%d\n", + pi.hProcess, pi.hThread, + (int) pi.dwProcessId, (int) pi.dwThreadId); + + if ( ResumeThread ( pi.hThread ) < 0 ) { + DEBUG1 ("ResumeThread failed: ec=%d\n", (int)GetLastError ()); + } + + if ( !CloseHandle (pi.hThread) ) { + DEBUG1 ("CloseHandle of thread failed: ec=%d\n", + (int)GetLastError ()); + } + + return handle_to_pid (pi.hProcess); +} + + + + +int +_gpgme_io_waitpid ( int pid, int hang, int *r_status, int *r_signal ) +{ + HANDLE proc = fd_to_handle (pid); + int code, ret = 0; + DWORD exc; + + *r_status = 0; + *r_signal = 0; + code = WaitForSingleObject ( proc, hang? INFINITE : 0 ); + switch (code) { + case WAIT_FAILED: + DEBUG2 ("WFSO pid=%d failed: %d\n", (int)pid, (int)GetLastError () ); + break; + + case WAIT_OBJECT_0: + if (!GetExitCodeProcess (proc, &exc)) { + DEBUG2 ("** GECP pid=%d failed: ec=%d\n", + (int)pid, (int)GetLastError () ); + *r_status = 4; + } + else { + DEBUG2 ("GECP pid=%d exit code=%d\n", (int)pid, exc); + *r_status = exc; + } + ret = 1; + break; + + case WAIT_TIMEOUT: + if (hang) + DEBUG1 ("WFSO pid=%d timed out\n", (int)pid); + break; + + default: + DEBUG2 ("WFSO pid=%d returned %d\n", (int)pid, code ); + break; + } + return ret; +} + +int +_gpgme_io_kill ( int pid, int hard ) +{ + HANDLE proc = fd_to_handle (pid); + + #warning I am not sure how to kill a process + /* fixme: figure out how this can be done */ + return 0; +} + + + +/* + * Select on the list of fds. + * Returns: -1 = error + * 0 = timeout or nothing to select + * >0 = number of signaled fds + */ +int +_gpgme_io_select ( struct io_select_fd_s *fds, size_t nfds, int nonblock ) +{ + HANDLE waitbuf[MAXIMUM_WAIT_OBJECTS]; + int waitidx[MAXIMUM_WAIT_OBJECTS]; + int code, nwait; + int i, any; + int count; + void *dbg_help; + + restart: + DEBUG_BEGIN (dbg_help, 3, "select on [ "); + any = 0; + nwait = 0; + count = 0; + for ( i=0; i < nfds; i++ ) { + if ( fds[i].fd == -1 ) + continue; + fds[i].signaled = 0; + if ( fds[i].for_read || fds[i].for_write ) { + if ( fds[i].frozen ) { + DEBUG_ADD1 (dbg_help, "f%d ", fds[i].fd ); + } + else if ( fds[i].for_read ) { + struct reader_context_s *c = find_reader (fds[i].fd,1); + + if (!c) { + DEBUG1 ("oops: no reader thread for fd %d", fds[i].fd); + } + else { + if ( nwait >= DIM (waitbuf) ) { + DEBUG_END (dbg_help, "oops ]"); + DEBUG0 ("Too many objects for WFMO!" ); + return -1; + } + waitidx[nwait] = i; + waitbuf[nwait++] = c->have_data_ev; + } + DEBUG_ADD1 (dbg_help, "r%d ", fds[i].fd ); + any = 1; + } + else if ( fds[i].for_write ) { + struct writer_context_s *c = find_writer (fds[i].fd,1); + + if (!c) { + DEBUG1 ("oops: no writer thread for fd %d", fds[i].fd); + } + else { + if ( nwait >= DIM (waitbuf) ) { + DEBUG_END (dbg_help, "oops ]"); + DEBUG0 ("Too many objects for WFMO!" ); + return -1; + } + LOCK (c->mutex); + if ( !c->nbytes ) { + waitidx[nwait] = i; + waitbuf[nwait++] = c->is_empty; + DEBUG_ADD1 (dbg_help, "w%d ", fds[i].fd ); + any = 1; + } + else { + DEBUG_ADD1 (dbg_help, "w%d(ignored) ", fds[i].fd ); + } + UNLOCK (c->mutex); + } + } + } + } + DEBUG_END (dbg_help, "]"); + if (!any) + return 0; + + code = WaitForMultipleObjects ( nwait, waitbuf, 0, nonblock ? 0 : 1000); + if ( code >= WAIT_OBJECT_0 && code < WAIT_OBJECT_0 + nwait ) { + /* This WFMO is a really silly function: It does return either + * the index of the signaled object or if 2 objects have been + * signalled at the same time, the index of the object with the + * lowest object is returned - so and how do we find out + * how many objects have been signaled???. + * The only solution I can imagine is to test each object starting + * with the returned index individually - how dull. + */ + any = 0; + for (i=code - WAIT_OBJECT_0; i < nwait; i++ ) { + if (WaitForSingleObject ( waitbuf[i], NULL ) == WAIT_OBJECT_0) { + assert (waitidx[i] >=0 && waitidx[i] < nfds); + fds[waitidx[i]].signaled = 1; + any = 1; + count++; + } + } + if (!any) { + DEBUG0 ("Oops: No signaled objects found after WFMO"); + count = -1; + } + } + else if ( code == WAIT_TIMEOUT ) { + DEBUG0 ("WFMO timed out\n" ); + } + else if (code == WAIT_FAILED ) { + int le = (int)GetLastError (); + if ( le == ERROR_INVALID_HANDLE ) { + int k, j = handle_to_fd (waitbuf[i]); + + DEBUG1 ("WFMO invalid handle %d removed\n", j); + for (k=0 ; k < nfds; i++ ) { + if ( fds[k].fd == j ) { + fds[k].for_read = fds[k].for_write = 0; + goto restart; + } + } + DEBUG0 (" oops, or not???\n"); + } + DEBUG1 ("WFMO failed: %d\n", le ); + count = -1; + } + else { + DEBUG1 ("WFMO returned %d\n", code ); + count = -1; + } + + if ( count ) { + DEBUG_BEGIN (dbg_help, 3, " signaled [ "); + for ( i=0; i < nfds; i++ ) { + if ( fds[i].fd == -1 ) + continue; + if ( (fds[i].for_read || fds[i].for_write) && fds[i].signaled ) { + DEBUG_ADD2 (dbg_help, "%c%d ", + fds[i].for_read? 'r':'w',fds[i].fd ); + } + } + DEBUG_END (dbg_help, "]"); + } + + return count; +} diff --git a/tags/gpgme-0-4-3/gpgme/w32-sema.c b/tags/gpgme-0-4-3/gpgme/w32-sema.c new file mode 100644 index 0000000..f5337bd --- /dev/null +++ b/tags/gpgme-0-4-3/gpgme/w32-sema.c @@ -0,0 +1,113 @@ +/* w32-sema.c + Copyright (C) 2001 Werner Koch (dd9jn) + Copyright (C) 2001, 2002 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 + 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. */ + +#ifdef HAVE_CONFIG_H +#include +#endif +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include "util.h" +#include "sema.h" + +static void +sema_fatal (const char *text) +{ + fprintf (stderr, "sema.c: %s\n", text); + abort (); +} + + +static void +critsect_init (struct critsect_s *s) +{ + CRITICAL_SECTION *mp; + static CRITICAL_SECTION init_lock; + static int initialized; + + if (!initialized) { + /* The very first time we call this function, we assume that + only one thread is running, so that we can bootstrap the + semaphore code. */ + InitializeCriticalSection (&init_lock); + initialized = 1; + } + if (!s) + return; /* we just want to initialize ourself */ + + /* first test whether it is really not initialized */ + EnterCriticalSection (&init_lock); + if ( s->private ) { + LeaveCriticalSection (&init_lock); + return; + } + /* now init it */ + mp = malloc ( sizeof *mp ); + if (!mp) { + LeaveCriticalSection (&init_lock); + sema_fatal ("out of core while creating critical section lock"); + } + InitializeCriticalSection (mp); + s->private = mp; + LeaveCriticalSection (&init_lock); +} + +void +_gpgme_sema_subsystem_init () +{ + /* fixme: we should check that there is only one thread running */ + critsect_init (NULL); +} + + +void +_gpgme_sema_cs_enter ( struct critsect_s *s ) +{ + if (!s->private) + critsect_init (s); + EnterCriticalSection ( (CRITICAL_SECTION*)s->private ); +} + +void +_gpgme_sema_cs_leave (struct critsect_s *s) +{ + if (!s->private) + critsect_init (s); + LeaveCriticalSection ((CRITICAL_SECTION*)s->private); +} + +void +_gpgme_sema_cs_destroy ( struct critsect_s *s ) +{ + if (s && s->private) { + DeleteCriticalSection ((CRITICAL_SECTION*)s->private); + free (s->private); + s->private = NULL; + } +} diff --git a/tags/gpgme-0-4-3/gpgme/w32-util.c b/tags/gpgme-0-4-3/gpgme/w32-util.c new file mode 100644 index 0000000..f01555d --- /dev/null +++ b/tags/gpgme-0-4-3/gpgme/w32-util.c @@ -0,0 +1,144 @@ +/* w32-util.c - Utility functions for the W32 API + Copyright (C) 1999 Free Software Foundation, Inc + Copyright (C) 2001 Werner Koch (dd9jn) + Copyright (C) 2001, 2002, 2003 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 + 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. */ + +#ifdef HAVE_CONFIG_H +#include +#endif +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include "util.h" +#include "sema.h" + +DEFINE_STATIC_LOCK (get_path_lock); + +/* Return a string from the Win32 Registry or NULL in case of error. + Caller must release the return value. A NULL for root is an alias + for HKEY_CURRENT_USER. */ +static char * +read_w32_registry_string (const char *root, const char *dir, const char *name) +{ + HKEY root_key, key_handle; + DWORD n1, nbytes; + char *result = NULL; + + if (!root) + root_key = HKEY_CURRENT_USER; + else if (!strcmp (root, "HKEY_CLASSES_ROOT")) + root_key = HKEY_CLASSES_ROOT; + else if (!strcmp (root, "HKEY_CURRENT_USER")) + root_key = HKEY_CURRENT_USER; + else if (!strcmp (root, "HKEY_LOCAL_MACHINE")) + root_key = HKEY_LOCAL_MACHINE; + else if (!strcmp (root, "HKEY_USERS")) + root_key = HKEY_USERS; + else if (!strcmp (root, "HKEY_PERFORMANCE_DATA")) + root_key = HKEY_PERFORMANCE_DATA; + else if (!strcmp (root, "HKEY_CURRENT_CONFIG")) + root_key = HKEY_CURRENT_CONFIG; + else + return NULL; + + if (RegOpenKeyEx (root_key, dir, 0, KEY_READ, &key_handle)) + return NULL; /* No need for a RegClose, so return directly. */ + + nbytes = 1; + if (RegQueryValueEx (key_handle, name, 0, NULL, NULL, &nbytes)) + goto leave; + n1 = nbytes + 1; + result = malloc (n1); + if (!result) + goto leave; + if (RegQueryValueEx (key_handle, name, 0, NULL, result, &n1)) + { + free (result); + result = NULL; + goto leave; + } + result[nbytes] = 0; /* Make sure it is really a string. */ + + leave: + RegCloseKey (key_handle); + return result; +} + + +static const char * +find_program_in_registry (const char *name) +{ + char *program = NULL; + + program = read_w32_registry_string (NULL, "Software\\GNU\\GnuPG", name); + if (program) + { + int i; + + DEBUG2 ("found %s in registry: `%s'", name, program); + for (i = 0; program[i]; i++) + { + if (program[i] == '/') + program[i] = '\\'; + } + } + return program; +} + + +const char * +_gpgme_get_gpg_path (void) +{ + static char *gpg_program; + + LOCK (get_path_lock); + if (!gpg_program) + gpg_program = find_program_in_registry ("gpgProgram"); +#ifdef GPG_PATH + if (!gpg_program) + gpg_program = GPG_PATH; +#endif + UNLOCK (get_path_lock); + return gpg_program; +} + +const char * +_gpgme_get_gpgsm_path (void) +{ + static char *gpgsm_program; + + LOCK (get_path_lock); + if (!gpgsm_program) + gpgsm_program = find_program_in_registry ("gpgsmProgram"); +#ifdef GPGSM_PATH + if (!gpgsm_program) + gpgsm_program = GPGSM_PATH; +#endif + UNLOCK (get_path_lock); + return gpgsm_program; +} diff --git a/tags/gpgme-0-4-3/gpgme/wait-global.c b/tags/gpgme-0-4-3/gpgme/wait-global.c new file mode 100644 index 0000000..e642251 --- /dev/null +++ b/tags/gpgme-0-4-3/gpgme/wait-global.c @@ -0,0 +1,357 @@ +/* wait-global.c + Copyright (C) 2000 Werner Koch (dd9jn) + Copyright (C) 2001, 2002, 2003 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 + 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. */ + +#if HAVE_CONFIG_H +#include +#endif +#include +#include +#include +#include + +#include "gpgme.h" +#include "sema.h" +#include "util.h" +#include "context.h" +#include "wait.h" +#include "io.h" + +/* The global event loop is used for all asynchronous operations + (except key listing) for which no user I/O callbacks are specified. + + A context sets up its initial I/O callbacks and then sends the + GPGME_EVENT_START event. After that, it is added to the global + list of active contexts. + + The gpgme_wait function contains a select() loop over all file + descriptors in all active contexts. If an error occurs, it closes + all fds in that context and moves the context to the global done + list. Likewise, if a context has removed all I/O callbacks, it is + moved to the global done list. + + All contexts in the global done list are eligible for being + returned by gpgme_wait if requested by the caller. */ + +/* The ctx_list_lock protects the list of active and done contexts. + Insertion into any of these lists is only allowed when the lock is + held. This allows a muli-threaded program to loop over gpgme_wait + and in parallel start asynchronous gpgme operations. + + However, the fd tables in the contexts are not protected by this + lock. They are only allowed to change either before the context is + added to the active list (ie, before the start event is signalled) + or in a callback handler. */ +DEFINE_STATIC_LOCK (ctx_list_lock); + +/* A ctx_list_item is an item in the global list of active or done + contexts. */ +struct ctx_list_item +{ + /* Every ctx_list_item is an element in a doubly linked list. The + list pointers are protected by the ctx_list_lock. */ + struct ctx_list_item *next; + struct ctx_list_item *prev; + + gpgme_ctx_t ctx; + /* The status is set when the ctx is moved to the done list. */ + gpgme_error_t status; +}; + +/* The active list contains all contexts that are in the global event + loop, have active I/O callbacks, and have already seen the start + event. */ +static struct ctx_list_item *ctx_active_list; + +/* The done list contains all contexts that have previously been + active but now are not active any longer, either because they + finished successfully or an I/O callback returned an error. The + status field in the list item contains the error value (or 0 if + successful). */ +static struct ctx_list_item *ctx_done_list; + + +/* Enter the context CTX into the active list. */ +static gpgme_error_t +ctx_active (gpgme_ctx_t ctx) +{ + struct ctx_list_item *li = malloc (sizeof (struct ctx_list_item)); + if (!li) + return gpg_error_from_errno (errno); + li->ctx = ctx; + + LOCK (ctx_list_lock); + /* Add LI to active list. */ + li->next = ctx_active_list; + li->prev = NULL; + if (ctx_active_list) + ctx_active_list->prev = li; + ctx_active_list = li; + UNLOCK (ctx_list_lock); + return 0; +} + + +/* Enter the context CTX into the done list with status STATUS. */ +static void +ctx_done (gpgme_ctx_t ctx, gpgme_error_t status) +{ + struct ctx_list_item *li; + + LOCK (ctx_list_lock); + li = ctx_active_list; + while (li && li->ctx != ctx) + li = li->next; + assert (li); + + /* Remove LI from active list. */ + if (li->next) + li->next->prev = li->prev; + if (li->prev) + li->prev->next = li->next; + else + ctx_active_list = li->next; + + li->status = status; + + /* Add LI to done list. */ + li->next = ctx_done_list; + li->prev = NULL; + if (ctx_done_list) + ctx_done_list->prev = li; + ctx_done_list = li; + UNLOCK (ctx_list_lock); +} + + +/* Find finished context CTX (or any context if CTX is NULL) and + return its status in STATUS after removing it from the done list. + If a matching context could be found, return it. Return NULL if no + context could be found. */ +static gpgme_ctx_t +ctx_wait (gpgme_ctx_t ctx, gpgme_error_t *status) +{ + struct ctx_list_item *li; + + LOCK (ctx_list_lock); + li = ctx_done_list; + if (ctx) + { + /* A specific context is requested. */ + while (li && li->ctx != ctx) + li = li->next; + } + if (li) + { + ctx = li->ctx; + if (status) + *status = li->status; + + /* Remove LI from done list. */ + if (li->next) + li->next->prev = li->prev; + if (li->prev) + li->prev->next = li->next; + else + ctx_done_list = li->next; + free (li); + } + else + ctx = NULL; + UNLOCK (ctx_list_lock); + return ctx; +} + + +/* Internal I/O callback functions. */ + +/* The add_io_cb and remove_io_cb handlers are shared with the private + event loops. */ + +void +_gpgme_wait_global_event_cb (void *data, gpgme_event_io_t type, + void *type_data) +{ + gpgme_ctx_t ctx = (gpgme_ctx_t) data; + + assert (ctx); + + switch (type) + { + case GPGME_EVENT_START: + { + gpgme_error_t err = ctx_active (ctx); + + if (err) + { + /* An error occured. Close all fds in this context, and + send the error in a done event. */ + unsigned int idx; + + for (idx = 0; idx <= ctx->fdt.size; idx++) + if (ctx->fdt.fds[idx].fd != -1) + _gpgme_io_close (ctx->fdt.fds[idx].fd); + _gpgme_engine_io_event (ctx->engine, GPGME_EVENT_DONE, &err); + } + } + break; + + case GPGME_EVENT_DONE: + { + gpgme_error_t *errp = (gpgme_error_t *) type_data; + assert (errp); + ctx_done (ctx, *errp); + } + break; + + case GPGME_EVENT_NEXT_KEY: + assert (!"Unexpected event GPGME_EVENT_NEXT_KEY"); + break; + + case GPGME_EVENT_NEXT_TRUSTITEM: + assert (!"Unexpected event GPGME_EVENT_NEXT_TRUSTITEM"); + break; + + default: + assert (!"Unexpected event"); + break; + } +} + + + +/* Perform asynchronous operations in the global event loop (ie, any + asynchronous operation except key listing and trustitem listing + operations). If CTX is not a null pointer, the function will + return if the asynchronous operation in the context CTX finished. + Otherwise the function will return if any asynchronous operation + finished. If HANG is zero, the function will not block for a long + time. Otherwise the function does not return until an operation + matching CTX finished. + + If a matching context finished, it is returned, and *STATUS is set + to the error value of the operation in that context. Otherwise, if + the timeout expires, NULL is returned and *STATUS is 0. If an + error occurs, NULL is returned and *STATUS is set to the error + value. */ +gpgme_ctx_t +gpgme_wait (gpgme_ctx_t ctx, gpgme_error_t *status, int hang) +{ + do + { + unsigned int i = 0; + struct ctx_list_item *li; + struct fd_table fdt; + int nr; + + /* Collect the active file descriptors. */ + LOCK (ctx_list_lock); + for (li = ctx_active_list; li; li = li->next) + i += li->ctx->fdt.size; + fdt.fds = malloc (i * sizeof (struct io_select_fd_s)); + if (!fdt.fds) + { + int saved_errno = errno; + UNLOCK (ctx_list_lock); + if (status) + *status = gpg_error_from_errno (saved_errno); + return NULL; + } + fdt.size = i; + i = 0; + for (li = ctx_active_list; li; li = li->next) + { + memcpy (&fdt.fds[i], li->ctx->fdt.fds, + li->ctx->fdt.size * sizeof (struct io_select_fd_s)); + i += li->ctx->fdt.size; + } + UNLOCK (ctx_list_lock); + + nr = _gpgme_io_select (fdt.fds, fdt.size, 0); + if (nr < 0) + { + int saved_errno = errno; + free (fdt.fds); + if (status) + *status = gpg_error_from_errno (saved_errno); + return NULL; + } + + for (i = 0; i < fdt.size && nr; i++) + { + if (fdt.fds[i].fd != -1 && fdt.fds[i].signaled) + { + gpgme_ctx_t ictx; + gpgme_error_t err; + struct wait_item_s *item; + + assert (nr); + nr--; + + item = (struct wait_item_s *) fdt.fds[i].opaque; + assert (item); + ictx = item->ctx; + assert (ictx); + + err = item->handler (item->handler_value, fdt.fds[i].fd); + if (err) + { + /* An error occured. Close all fds in this context, + and signal it. */ + unsigned int idx; + + for (idx = 0; idx < ictx->fdt.size; idx++) + if (ictx->fdt.fds[idx].fd != -1) + _gpgme_io_close (ictx->fdt.fds[idx].fd); + _gpgme_engine_io_event (ictx->engine, GPGME_EVENT_DONE, + &err); + } + } + } + free (fdt.fds); + + /* Now some contexts might have finished successfully. */ + LOCK (ctx_list_lock); + for (li = ctx_active_list; li; li = li->next) + { + for (i = 0; i < ctx->fdt.size; i++) + if (ctx->fdt.fds[i].fd != -1) + break; + if (i == ctx->fdt.size) + { + gpgme_error_t err = 0; + _gpgme_engine_io_event (ctx->engine, GPGME_EVENT_DONE, &err); + } + } + UNLOCK (ctx_list_lock); + + { + gpgme_ctx_t dctx = ctx_wait (ctx, status); + + if (dctx) + { + ctx = dctx; + hang = 0; + } + } + } + while (hang); + + return ctx; +} diff --git a/tags/gpgme-0-4-3/gpgme/wait-private.c b/tags/gpgme-0-4-3/gpgme/wait-private.c new file mode 100644 index 0000000..c9c5ce5 --- /dev/null +++ b/tags/gpgme-0-4-3/gpgme/wait-private.c @@ -0,0 +1,150 @@ +/* wait-private.c + Copyright (C) 2000 Werner Koch (dd9jn) + Copyright (C) 2001, 2002, 2003 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 + 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. */ + +#if HAVE_CONFIG_H +#include +#endif +#include +#include + +#include "gpgme.h" +#include "context.h" +#include "wait.h" +#include "ops.h" +#include "io.h" +#include "util.h" + + +/* The private event loops are used for all blocking operations, and + for the key and trust item listing operations. They are completely + separated from each other. */ + + +/* Internal I/O callback functions. */ + +/* The add_io_cb and remove_io_cb handlers are shared with the global + event loops. */ + +void +_gpgme_wait_private_event_cb (void *data, gpgme_event_io_t type, + void *type_data) +{ + switch (type) + { + case GPGME_EVENT_START: + /* Nothing to do here, as the wait routine is called after the + initialization is finished. */ + break; + + case GPGME_EVENT_DONE: + break; + + case GPGME_EVENT_NEXT_KEY: + _gpgme_op_keylist_event_cb (data, type, type_data); + break; + + case GPGME_EVENT_NEXT_TRUSTITEM: + _gpgme_op_trustlist_event_cb (data, type, type_data); + break; + } +} + + +/* If COND is a null pointer, wait until the blocking operation in CTX + finished and return its error value. Otherwise, wait until COND is + satisfied or the operation finished. */ +gpgme_error_t +_gpgme_wait_on_condition (gpgme_ctx_t ctx, volatile int *cond) +{ + gpgme_error_t err = 0; + int hang = 1; + + do + { + int nr = _gpgme_io_select (ctx->fdt.fds, ctx->fdt.size, 0); + unsigned int i; + + if (nr < 0) + { + /* An error occured. Close all fds in this context, and + signal it. */ + unsigned int idx; + + err = gpg_error_from_errno (errno); + for (idx = 0; idx < ctx->fdt.size; idx++) + if (ctx->fdt.fds[idx].fd != -1) + _gpgme_io_close (ctx->fdt.fds[idx].fd); + _gpgme_engine_io_event (ctx->engine, GPGME_EVENT_DONE, &err); + + return err; + } + + for (i = 0; i < ctx->fdt.size && nr; i++) + { + if (ctx->fdt.fds[i].fd != -1 && ctx->fdt.fds[i].signaled) + { + struct wait_item_s *item; + + ctx->fdt.fds[i].signaled = 0; + assert (nr); + nr--; + + item = (struct wait_item_s *) ctx->fdt.fds[i].opaque; + + err = item->handler (item->handler_value, ctx->fdt.fds[i].fd); + if (err) + { + /* An error occured. Close all fds in this context, + and signal it. */ + unsigned int idx; + + for (idx = 0; idx < ctx->fdt.size; idx++) + if (ctx->fdt.fds[idx].fd != -1) + _gpgme_io_close (ctx->fdt.fds[idx].fd); + _gpgme_engine_io_event (ctx->engine, GPGME_EVENT_DONE, &err); + return err; + } + } + } + + for (i = 0; i < ctx->fdt.size; i++) + if (ctx->fdt.fds[i].fd != -1) + break; + if (i == ctx->fdt.size) + { + _gpgme_engine_io_event (ctx->engine, GPGME_EVENT_DONE, &err); + hang = 0; + } + if (cond && *cond) + hang = 0; + } + while (hang); + + return 0; +} + + +/* Wait until the blocking operation in context CTX has finished and + return the error value. */ +gpgme_error_t +_gpgme_wait_one (gpgme_ctx_t ctx) +{ + return _gpgme_wait_on_condition (ctx, NULL); +} diff --git a/tags/gpgme-0-4-3/gpgme/wait-user.c b/tags/gpgme-0-4-3/gpgme/wait-user.c new file mode 100644 index 0000000..1fbe9cb --- /dev/null +++ b/tags/gpgme-0-4-3/gpgme/wait-user.c @@ -0,0 +1,124 @@ +/* wait.c + Copyright (C) 2000 Werner Koch (dd9jn) + Copyright (C) 2001, 2002, 2003 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 + 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. */ + +#if HAVE_CONFIG_H +#include +#endif +#include + +#include "gpgme.h" +#include "context.h" +#include "io.h" +#include "wait.h" + + +/* The user event loops are used for all asynchronous operations for + which a user callback is defined. */ + + +/* Internal I/O Callbacks. */ + +gpgme_error_t +_gpgme_user_io_cb_handler (void *data, int fd) +{ + gpgme_error_t err; + struct tag *tag = (struct tag *) data; + gpgme_ctx_t ctx; + struct wait_item_s *item; + + assert (data); + ctx = tag->ctx; + assert (ctx); + item = (struct wait_item_s *) ctx->fdt.fds[tag->idx].opaque; + assert (item); + + err = (*item->handler) (item->handler_value, fd); + if (err) + { + unsigned int idx; + + for (idx = 0; idx < ctx->fdt.size; idx++) + if (ctx->fdt.fds[idx].fd != -1) + _gpgme_io_close (ctx->fdt.fds[idx].fd); + _gpgme_engine_io_event (ctx->engine, GPGME_EVENT_DONE, &err); + } + else + { + unsigned int i; + + for (i = 0; i < ctx->fdt.size; i++) + if (ctx->fdt.fds[i].fd != -1) + break; + if (i == ctx->fdt.size) + _gpgme_engine_io_event (ctx->engine, GPGME_EVENT_DONE, &err); + } + return 0; +} + + +/* Register the file descriptor FD with the handler FNC (which gets + FNC_DATA as its first argument) for the direction DIR. DATA should + be the context for which the fd is added. R_TAG will hold the tag + that can be used to remove the fd. */ +gpgme_error_t +_gpgme_wait_user_add_io_cb (void *data, int fd, int dir, gpgme_io_cb_t fnc, + void *fnc_data, void **r_tag) +{ + gpgme_ctx_t ctx = (gpgme_ctx_t) data; + struct tag *tag; + gpgme_error_t err; + + assert (ctx); + err = _gpgme_add_io_cb (data, fd, dir, fnc, fnc_data, r_tag); + if (err) + return err; + tag = *r_tag; + assert (tag); + err = (*ctx->io_cbs.add) (ctx->io_cbs.add_priv, fd, dir, + _gpgme_user_io_cb_handler, *r_tag, + &tag->user_tag); + if (err) + _gpgme_remove_io_cb (*r_tag); + return err; +} + + +void +_gpgme_wait_user_remove_io_cb (void *data) +{ + struct tag *tag = (struct tag *) data; + gpgme_ctx_t ctx; + + assert (tag); + ctx = tag->ctx; + + (*ctx->io_cbs.remove) (tag->user_tag); + _gpgme_remove_io_cb (data); +} + + +void +_gpgme_wait_user_event_cb (void *data, gpgme_event_io_t type, void *type_data) +{ + gpgme_ctx_t ctx = data; + + if (ctx->io_cbs.event) + (*ctx->io_cbs.event) (ctx->io_cbs.event_priv, type, type_data); +} diff --git a/tags/gpgme-0-4-3/gpgme/wait.c b/tags/gpgme-0-4-3/gpgme/wait.c new file mode 100644 index 0000000..b874c57 --- /dev/null +++ b/tags/gpgme-0-4-3/gpgme/wait.c @@ -0,0 +1,168 @@ +/* wait.c + Copyright (C) 2000 Werner Koch (dd9jn) + Copyright (C) 2001, 2002, 2003 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 + 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. */ + +#if HAVE_CONFIG_H +#include +#endif +#include +#include +#include +#include +#include + +#include "util.h" +#include "context.h" +#include "ops.h" +#include "wait.h" +#include "sema.h" +#include "io.h" +#include "engine.h" +#include "debug.h" + + +void +_gpgme_fd_table_init (fd_table_t fdt) +{ + fdt->fds = NULL; + fdt->size = 0; +} + +void +_gpgme_fd_table_deinit (fd_table_t fdt) +{ + if (fdt->fds) + free (fdt->fds); +} + + +/* XXX We should keep a marker and roll over for speed. */ +static gpgme_error_t +fd_table_put (fd_table_t fdt, int fd, int dir, void *opaque, int *idx) +{ + unsigned int i, j; + struct io_select_fd_s *new_fds; + + for (i = 0; i < fdt->size; i++) + { + if (fdt->fds[i].fd == -1) + break; + } + if (i == fdt->size) + { +#define FDT_ALLOCSIZE 10 + new_fds = realloc (fdt->fds, (fdt->size + FDT_ALLOCSIZE) + * sizeof (*new_fds)); + if (!new_fds) + return gpg_error_from_errno (errno); + + fdt->fds = new_fds; + fdt->size += FDT_ALLOCSIZE; + for (j = 0; j < FDT_ALLOCSIZE; j++) + fdt->fds[i + j].fd = -1; + } + + fdt->fds[i].fd = fd; + fdt->fds[i].for_read = (dir == 1); + fdt->fds[i].for_write = (dir == 0); + fdt->fds[i].frozen = 0; + fdt->fds[i].signaled = 0; + fdt->fds[i].opaque = opaque; + *idx = i; + return 0; +} + + +/* Register the file descriptor FD with the handler FNC (which gets + FNC_DATA as its first argument) for the direction DIR. DATA should + be the context for which the fd is added. R_TAG will hold the tag + that can be used to remove the fd. */ +gpgme_error_t +_gpgme_add_io_cb (void *data, int fd, int dir, gpgme_io_cb_t fnc, + void *fnc_data, void **r_tag) +{ + gpgme_error_t err; + gpgme_ctx_t ctx = (gpgme_ctx_t) data; + fd_table_t fdt; + struct wait_item_s *item; + struct tag *tag; + + assert (fnc); + assert (ctx); + + fdt = &ctx->fdt; + assert (fdt); + + tag = malloc (sizeof *tag); + if (!tag) + return gpg_error_from_errno (errno); + tag->ctx = ctx; + + /* Allocate a structure to hold information about the handler. */ + item = calloc (1, sizeof *item); + if (!item) + { + int saved_errno = errno; + free (tag); + return gpg_error_from_errno (saved_errno); + } + item->ctx = ctx; + item->dir = dir; + item->handler = fnc; + item->handler_value = fnc_data; + + err = fd_table_put (fdt, fd, dir, item, &tag->idx); + if (err) + { + free (tag); + free (item); + return err; + } + + *r_tag = tag; + return 0; +} + + +void +_gpgme_remove_io_cb (void *data) +{ + struct tag *tag = data; + gpgme_ctx_t ctx; + fd_table_t fdt; + int idx; + + assert (tag); + ctx = tag->ctx; + assert (ctx); + fdt = &ctx->fdt; + assert (fdt); + idx = tag->idx; + + DEBUG2 ("setting fd %d (item=%p) done", fdt->fds[idx].fd, + fdt->fds[idx].opaque); + free (fdt->fds[idx].opaque); + free (tag); + + /* Free the table entry. */ + fdt->fds[idx].fd = -1; + fdt->fds[idx].for_read = 0; + fdt->fds[idx].for_write = 0; + fdt->fds[idx].opaque = NULL; +} diff --git a/tags/gpgme-0-4-3/gpgme/wait.h b/tags/gpgme-0-4-3/gpgme/wait.h new file mode 100644 index 0000000..9cc1722 --- /dev/null +++ b/tags/gpgme-0-4-3/gpgme/wait.h @@ -0,0 +1,79 @@ +/* wait.h - Definitions for the wait queue interface. + Copyright (C) 2000 Werner Koch (dd9jn) + Copyright (C) 2001, 2002, 2003 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 + 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. */ + +#ifndef WAIT_H +#define WAIT_H + +#include "gpgme.h" +#include "sema.h" + +struct fd_table +{ + struct io_select_fd_s *fds; + size_t size; +}; +typedef struct fd_table *fd_table_t; + +/* Wait items are hooked into the io_select_fd_s to connect an fd with + a callback handler. */ +struct wait_item_s +{ + gpgme_ctx_t ctx; + gpgme_io_cb_t handler; + void *handler_value; + int dir; +}; + +/* A registered fd handler is removed later using the tag that + identifies it. */ +struct tag +{ + /* The context for which the fd was registered. */ + gpgme_ctx_t ctx; + + /* The index into the fd table for this context. */ + int idx; + + /* This is used by the wrappers for the user event loop. */ + void *user_tag; +}; + + +void _gpgme_fd_table_init (fd_table_t fdt); +void _gpgme_fd_table_deinit (fd_table_t fdt); + +gpgme_error_t _gpgme_add_io_cb (void *data, int fd, int dir, + gpgme_io_cb_t fnc, void *fnc_data, void **r_tag); +void _gpgme_remove_io_cb (void *tag); +void _gpgme_wait_private_event_cb (void *data, gpgme_event_io_t type, + void *type_data); +void _gpgme_wait_global_event_cb (void *data, gpgme_event_io_t type, + void *type_data); + +gpgme_error_t _gpgme_wait_user_add_io_cb (void *data, int fd, int dir, + gpgme_io_cb_t fnc, void *fnc_data, + void **r_tag); +void _gpgme_wait_user_remove_io_cb (void *tag); +void _gpgme_wait_user_event_cb (void *data, gpgme_event_io_t type, + void *type_data); + +gpgme_error_t _gpgme_wait_one (gpgme_ctx_t ctx); + +#endif /* WAIT_H */ diff --git a/tags/gpgme-0-4-3/tests/ChangeLog b/tags/gpgme-0-4-3/tests/ChangeLog new file mode 100644 index 0000000..8f6a2d7 --- /dev/null +++ b/tags/gpgme-0-4-3/tests/ChangeLog @@ -0,0 +1,597 @@ +2003-10-06 Marcus Brinkmann + + * gpg/t-eventloop.c: Include for old systems. + + * gpgsm/Makefile.am (DISTCLEANFILES): Add random_seed. + + * gpg/t-thread1.c (thread_one): Do not call initialize_gpgme. + Likewise. + +2003-09-14 Marcus Brinkmann + + * gpg/t-thread1.c (main): Call init_gpgme here. + (initialize_gpgme): Function removed. + + * gpg/t-thread1.c: New file. + * gpg/Makefile.am (TESTS): Add t-thread1.c. + (t_thread1_LDADD): New variable. + (LDADD): Remove GPG Error lib. + * gpgsm/Makefile.am (LDADD): Likewise. + + * gpg/t-import.c (main): Likewise. + * gpg/t-keylist-sig.c (main): Likewise. + * gpg/t-keylist.c (main): Likewise. + * gpg/t-sign.c (main): Likewise. + * gpg/t-signers.c (main): Likewise. + * gpg/t-trustlist.c (main): Likewise. + * gpgsm/t-support.h: Include and . + (init_gpgme): New function. + * gpg/t-support.h: Likewise. + * gpgsm/t-verify.c (main): Call init_gpgme. + * gpgsm/t-decrypt.c (main): Likewise. + * gpgsm/t-encrypt.c (main): Likewise. + * gpgsm/t-export.c (main): Likewise. + * gpgsm/t-genkey.c (main): Likewise. + * gpgsm/t-import.c (main): Likewise. + * gpgsm/t-keylist.c (main): Likewise. + * gpgsm/t-sign.c (main): Likewise. + * gpg/t-verify.c (main): Call init_gpgme. + * gpg/t-decrypt-verify.c (main): Likewise. + * gpg/t-decrypt.c (main): Likewise. + * gpg/t-edit.c (main): Likewise. + * gpg/t-encrypt-sign.c (main): Likewise. + * gpg/t-encrypt-sym.c (main): Likewise. + * gpg/t-encrypt.c (main): Likewise. + * gpg/t-eventloop.c (main): Likewise. + * gpg/t-export.c (main): Likewise. + * gpg/t-genkey.c (main): Likewise. + +2003-08-14 Marcus Brinkmann + + * gpg/t-sign.c (check_result): Change output format for signature + class to unsigned int. + * gpg/t-signers.c (check_result): Likewise. + * gpg/t-encrypt-sign.c (check_result): Likewise. + * gpgsm/t-sign.c (check_result): Likewise. + +2003-07-31 Marcus Brinkmann + + * gpg/t-verify.c (check_result): Change type of SUMMARY to + unsigned int. + * gpg/t-decrypt-verify.c (check_verify_result): Likewise. + * gpg/t-keylist-sig.c (keys): Change type of member CLASS to + unsigned int. + * t-data.c (read_cb): Change type of AMOUNT to unsigned int. + * t-version.c (version): Remove unused variable. + +2003-07-22 Marcus Brinkmann + + * Makefile.am (AM_CPPFLAGS): New variable. + (LDADD): Add @GPG_ERROR_LIBS@. + * gpg/Makefile.am (AM_CPPFLAGS): New variable. + (LDADD): Add @GPG_ERROR_LIBS@. + * gpgsm/Makefile.am (AM_CPPFLAGS): New variable. + (LDADD): Add @GPG_ERROR_LIBS@. + +2003-06-06 Marcus Brinkmann + + Everywhere: Use libgpg-error error codes. + + * gpg/Makefile.am (noinst_HEADERS): New variable. + * gpg/t-support.h: New file. + * gpgsm/Makefile.am (noinst_HEADERS): New variable. + * gpgsm/t-support.h: New file. + +2003-05-29 Marcus Brinkmann + + * gpg/t-encrypt-sym.c (main): Adapt to new syntax. + * gpg/t-encrypt.c (main): Likewise. + * gpg/t-eventloop.c (main): Likewise. + * gpg/t-encrypt-sign.c (main): Likewise. + * gpgsm/t-export.c (main): Likewise. + * gpgsm/t-encrypt.c (main): Likewise. + +2003-05-28 Marcus Brinkmann + + * gpg/t-eventloop.c (main): Rewrite recipient management. + * gpg/t-encrypt-sign.c (main): Likewise. + * gpg/t-encrypt.c (main): Likewise. + * gpg/t-export.c (main): Likewise. + * gpgsm/t-encrypt.c (main): Likewise. + * gpgsm/t-export.c (main): Likewise. + +2003-05-27 Marcus Brinkmann + + * gpg/Makefile.am (TESTS): Order t-keylist and t-keylist-sig after + t-import. + * gpg/t-edit.c (edit_fnc): Fix primary UID for keylisting tests. + * gpg/t-keylist.c: Change order of user IDs. + * gpg/t-keylist-sig.c: Likewise. + * gpg/t-import.c: Add support for gpg in CVS. + +2003-05-27 Marcus Brinkmann + + * t-data.c: Remove TEST_OUT_CB. + (main): Likewise. + * gpg/t-trustlist.c (main): Access ITEM directly. + + * (t-decrypt-verify.c, t-decrypt.c, t-edit.c, t-encrypt-sign.c, + t-encrypt-sym.c, t-sign.c, t-signers.c): Include . + (passphrase_cb): Rewritten. + * t-edit.c (edit_fnc): Rewritten. + +2003-05-04 Marcus Brinkmann + + * gpg/t-keylist-sig.c (main): Remove timestamp check. + + * gpgsm/t-keylist.c: Add check for timestamp. + + * gpg/Makefile.am (TESTS): Add t-keylist-sig. + * gpg/t-keylist-sig.c: New file. + +2003-04-30 Marcus Brinkmann + + * gpg/t-eventloop.c (main): Do not call print_op_info. + (print_op_info): Function removed. + + * gpg/t-keylist.c: Rewritten. + * gpgsm/t-keylist.c (main): Rewritten. + * gpg/t-edit.c (main): Do not use gpgme_key_get_as_xml. Use + gpgme_key_unref instead gpgme_key_release. + * gpg/t-signers.c (main): Use gpgme_key_unref instead + gpgme_key_release. + +2003-04-29 Marcus Brinkmann + + * gpg/t-trustlist.c: Rewritten. + + * gpg/t-verify.c (main): Rewritten. + * gpg/t-decrypt-verify.c: Rewritten. + * gpgsm/t-verify.c (main): Rewritten. + +2003-04-28 Marcus Brinkmann + + * gpgsm/t-decrypt.c (main): Rewritten. + + * gpg/t-decrypt.c: Rewritten. + + * gpg/t-signers.c: Rewritten. + +2003-04-27 Marcus Brinkmann + + * gpg/t-encrypt-sign.c (check_result): Rewritten. + + * gpg/t-sign.c: Rewritten. + * gpgsm/t-sign.c: Rewritten. + * gpg/t-encrypt.c: Check for invalid recipients. + * gpgsm/t-encrypt.c: Likewise. + + * gpg/t-import.c (check_result): Really use FPR. + * gpgsm/t-import.c (check_result): Rewritten. + +2003-04-25 Marcus Brinkmann + + * gpg/t-import.c: Rewritten. + + * gpgsm/t-genkey.c: Rewritten. + * gpgsm/Makefile.am (noinst_PROGRAMS): Add t-genkey. + * gpg/t-genkey.c: Include . + (main): Check result->fpr before checking its length. + +2003-04-24 Marcus Brinkmann + + * gpg/t-genkey.c: Rewritten to match new semantics. + +2003-02-06 Marcus Brinkmann + + * gpg/t-decrypt.c (passphrase_cb): Fix to new prototype. + * gpg/t-decrypt-verify.c (passphrase_cb): Likewise. + * gpg/t-edit.c (passphrase_cb): Likewise. + * gpg/t-encrypt-sign.c (passphrase_cb): Likewise. + * gpg/t-encrypt-sym.c (passphrase_cb): Likewise. + * gpg/t-sign.c (passphrase_cb): Likewise. + * gpg/t-signers.c (passphrase_cb): Likewise. + +2003-01-30 Marcus Brinkmann + + * t-engine-info.c: Use file_name instead path throughout. + + * Makefile.am (TESTS): Add t-engine-info. + * t-engine-info.c: New file. + * gpg/t-encrypt.c (main): Don't print engine info. + * gpg/t-eventloop.c (main): Likewise. + * gpg/t-encrypt-sign.c (main): Likewise. + * gpgsm/t-encrypt.c (main): Likewise. + +2002-12-24 Marcus Brinkmann + + * gpgsm/t-verify.c (main): Adjust caller of gpgme_op_verify. + * gpg/t-verify.c (main): Likewise. + * gpg/t-decrypt-verify.c (main): Likewise for + gpgme_op_decrypt_verify. + +2002-12-23 Marcus Brinkmann + + * gpgsm/Makefile.am (./gpgsm.conf): Add a faked system time to + avoid certification's expiry. + * gpgsm/t-encrypt.c (main): Use the short certification name. + +2002-11-19 Marcus Brinkmann + + * gpg/t-genkey.c (main): Add missing argument to gpgme_op_genkey + invocation. + +2002-10-09 Marcus Brinkmann + + * gpg/t-decrypt.c (print_data): Update to new gpgme_data_read + interface, and use gpgme_engine_check_version instead + gpgme_check_version. + * gpg/t-decrypt-verify.c (print_data): Likewise. + * gpg/t-edit.c (main): Likewise. + * gpg/t-encrypt.c (print_data): Likewise. + * gpg/t-encrypt-sign.c (print_data): Likewise. + * gpg/t-encrypt-sym.c (print_data): Likewise. + * gpg/t-eventloop.c (print_data): Likewise. + * gpg/t-export.c (print_data): Likewise. + * gpg/t-sign.c (print_data): Likewise. + * gpg/t-signers.c (print_data): Likewise. + * gpgsm/t-decrypt.c (print_data): Likewise. + * gpgsm/t-encrypt.c (print_data): Likewise. + * gpgsm/t-export.c (print_data): Likewise. + * gpgsm/t-sign.c (print_data): Likewise. + * gpg/t-verify.c (main): Likewise for gpgme_op_verify. + * gpgsm/t-verify.c (main): Likewise for gpgme_op_verify. + * t-data.c (read_once_test): Likewise. + (write_test): Update for new behaviour of data objects. + (main): Remove type test. + +2002-09-30 Werner Koch + + * gpgsm/t-keylist.c (doit): Add arg SECRET. + (main): Add option --secret. + +2002-09-28 Marcus Brinkmann + + * t-version.c: Include . Reported by Stéphane Corthésy. + +2002-09-02 Marcus Brinkmann + + * gpg/t-keylist.c (main): Test PATTERN for NULL before printing. + Reported by Dr. Stefan Dalibor . + +2002-08-01 Marcus Brinkmann + + * gpg/t-edit.c: Also add a test for the expire command (testing + the passphrase callback). + +2002-07-28 Marcus Brinkmann + + * gpg/t-edit.c: New file. + * gpg/Makefile (TESTS): Add t-edit. + +2002-07-25 Marcus Brinkmann + + * gpg/t-encrypt-sym.c (main): Change type of I to size_t and + rename to LEN. + * gpg/t-verify.c (main): Likewise. Submitted by Stéphane + Corthésy. + +2002-07-03 Marcus Brinkmann + + * gpg/t-eventloop.c: New file. + * gpg/Makefile (TESTS): Add t-eventloop. + +2002-06-26 Werner Koch + + * gpgsm/t-import.c (print_op_info): New. + (main): Print operation info. + +2002-06-25 Werner Koch + + * gpgsm/Makefile.am (DISTCLEANFILES): new. + +2002-06-25 Marcus Brinkmann + + * gpgsm/Makefile.am (TESTS): Add t-export. + gpgsm/t-export.c: New file. + +2002-06-20 Werner Koch + + * gpgsm/t-sign.c (main): Also test a normal signature. + + * gpg/Makefile (TESTS_ENVIRONMENT): Set GPG_AGENT_INFO empty. + * gpg/t-signers.c, gpg/t-sign.c, gpg/t-encrypt-sym.c + * gpg/t-encrypt-sign.c, gpg/t-decrypt.c + * gpg/t-decrypt-verify.c (main): Changed the GPG_AGENT_INFO check to + match the one in ../../gpgme/rungpg.c. + +2002-06-12 Werner Koch + + * gpgsm/t-keylist.c (doit): Print operation info if available. + +2002-06-10 Werner Koch + + * gpgsm/t-verify.c (print_sig_stat): Print the error token. + +2002-06-04 Werner Koch + + * gpgsm/t-encrypt.c (main): Add a simple option parser and allow + to specify an encryption key. + +2002-05-26 Marcus Brinkmann + + * gpg/Makefile.am (all-local): Remove dependency on ./secring.gpg. + (./secring.gpg): Remove target, and move all rules for this target + to ... + (./pubring.gpg): ... here. This was necessary because GnuPG 1.0.7 + does create an empty secring.gpg file when importing public keys. + +2002-05-08 Marcus Brinkmann + + * gpgsm/t-verify.c (validity_string): New. + (print_sig_stat): Print expire time and validity. + (status_string): Add new exipred stati. + +2002-05-03 Werner Koch + + * gpg/t-verify.c (validity_string): New. + (print_sig_stat): Print expire time and validity. + (status_string): Add new exipred stati. + +2002-04-05 Marcus Brinkmann + + * gpgsm/Makefile.am (./trustlist.txt): Put more into this file to + prevent use of gpg-agent. + (./gpg-agent.conf): Remove target. + (all-local): Remove ./gpg-agent.conf. + +2002-04-05 Marcus Brinkmann + + * gpgsm/t-keylist.c (main): Use gpgme_engine_check_version instead + gpgme_check_engine. + * gpgsm/t-encrypt.c (main): Likewise. + +2002-03-06 Marcus Brinkmann + + * gpg/t-encrypt-sym.c: New file. + * gpg/Makefile.am (TESTS): Add t-encrypt-sym. + +2002-03-05 Marcus Brinkmann + + * gpg/Makefile.am (CLEANFILES): Remove random_seed, which is now + in DISTCLEANFILES. + +2002-03-04 Werner Koch + + * gpg/Makefile.am (DISTCLEANFILES): Added. + +2002-03-03 Marcus Brinkmann + + * gpg/t-verify.c (main): Add a few more sanity checks, and a check + for normal signatures. + +2002-02-26 Marcus Brinkmann + + * gpg/t-encrypt-sign.c: New file. + * gpg/Makefile.am (TESTS): Add t-encrypt-sign. + +2002-02-13 Werner Koch + + * gpgsm/Makefile.am (private-keys-v1.d): Don't + fail when the directory already exists. + +2002-02-12 Marcus Brinkmann + + * gpg/Makefile.am (CLEANFILES): New target. + (distclean-local): Rename to ... + (clean-local): ... this. + +2002-02-09 Marcus Brinkmann + + * gpgsm/Makefile.am (./private-keys-v1.d/$(key_id).key): Fix rule. + +2002-02-09 Marcus Brinkmann + + * gpgsm/t-genkey.c: New file (not added to Makefile.am because of + gpg-agent bug). + +2002-02-08 Marcus Brinkmann + + * gpgsm/Makefile.am (key_id): Update value. + (all-local): Add .key to keyid filename. + (./private-keys-v1.d/$(key_id)): Renamed to ... + (./private-keys-v1.d/$(key_id).key): ... this. + (all-local): Add ./gpgsm.conf, ./trustlist.txt. + (./gpgsm.conf, ./trustlist.txt): New target. + * gpgsm/567064FE6D14A17B2D811ABB407728BC558AA455: Renamed to ... + * gpgsm/32100C27173EF6E9C4E9A25D3D69F86D37A4F939: ... this. + +2002-01-30 Marcus Brinkmann + + * gpg/t-import.c (print_op_info): New function. + (main): Use it. + +2002-01-22 Marcus Brinkmann + + * gpg/t-signers.c (passphrase_cb): Change type of r_hd to void**. + * gpg/t-sign.c (passphrase_cb): Likewise. + * gpg/t-decrypt-verify.c (passphrase_cb): Likewise. + * gpg/t-decrypt.c (passphrase_cb): Likewise. + +2001-12-19 Marcus Brinkmann + + * gpg/t-decrypt-verify.c: Don't include `mcheck.h'. Reported by + Stéphane Corthésy. + +2001-12-19 Marcus Brinkmann + + * gpg/Makefile.am (EXTRA_DIST): Add missing line continuation. + +2001-12-19 Marcus Brinkmann + + * gpgsm/Makefile.am (EXTRA_DIST): Add $(key_id). + +2001-12-16 Marcus Brinkmann + + * gpgsm/Makefile: Rename `pubcerts.kbx' to `pubring.kbx'. + +2001-12-15 Marcus Brinkmann + + * gpgsm/t-keylist.c (check_two_contexts): Set protocols. + +2001-12-14 Marcus Brinkmann + + * gpgsm/t-sign.c: New file. + * gpgsm/Makefile.am (TESTS): Add t-sign. + +2001-12-14 Marcus Brinkmann + + * gpgsm/t-decrypt.c: New file. + * gpgsm/567064FE6D14A17B2D811ABB407728BC558AA455: Likewise. + * gpgsm/Makefile.am (TESTS): Add t-decrypt. + (key_id): New variable. + (all-local): New target ./private-keys-v1.d/$(key_id) added. + (./private-keys-v1.d/$(key_id)): New target. + +2001-12-14 Marcus Brinkmann + + * gpgsm/t-verify.c: New file. + * gpgsm/Makefile.am (TESTS): Add t-verify. + +2001-12-14 Marcus Brinkmann + + * gpg/Makefile.am (GPG): Set to @GPG_PATH@. + (./pubring.gpg): Use $(GPG) instead gpg. + (./secring.gpg): Likewise. + + * gpgsm/t-import.c (main): Remove third test case. + * gpgsm/Makefile.am (GPGSM): Set to @GPGSM@. + (all-local): New target. + (./pubcerts.kbx): Likewise. + * gpgsm/t-encrypt.c: New file. + * gpgsm/Makefile.am (TESTS): Add t-encrypt. + +2001-12-14 Marcus Brinkmann + + * gpgsm/t-keylist.c: New file. + * gpgsm/Makefile.am (TESTS): Add t-keylist. + +2001-12-13 Marcus Brinkmann + + * gpgsm/cert_dfn_pca01.der: New file. + * gpgsm/cert_dfn_pca15.der: Likewise. + * gpgsm/cert_g10code_test1.der: Likewise. + * gpgsm/t-import.c: Likewise. + * gpgsm/Makefile.am (EXTRADIST): Add new files. + (TESTS): Add t-import. + +2001-11-22 Marcus Brinkmann + + * gpg/: New directory. + * Makefile.am, t-verify.c, t-encrypt.c, t-signers.c, t-trustlist.c, + t-sign.c, t-keylist.c, t-import.c, t-genkey.c, t-export.c, + t-decrypt-verify.c, t-decrypt.c, t-version.c, t-data.c, mkdemodirs. + cipher-1.asc, cipher-2.asc, geheim.txt, pubdemo.asc, pubkey-1.asc, + secdemo.asc, seckey-1.asc): Move to sub directory gpg/. + + * gpg/Makefile.am (INCLUDES): Include gpgme/, not include/ and + intl/. + (LDD): Correct relative path to gpgme library. + (TESTS): Remove t-version and t-data. + * gpg/t-verify.c, gpg/t-encrypt.c, gpg/t-signers.c, gpg/t-trustlist.c, + gpg/t-sign.c, gpg/t-keylist.c, gpg/t-import.c, gpg/t-genkey.c, + gpg/t-export.c, gpg/t-decrypt-verify.c, gpg/t-decrypt.c, + t-version.c, t-data.c): Include gpgme.h, not "../gpgme/gpgme.h". + + * Makefile.am: New file. + * gpgsm/: New directory. + * gpgsm/Makefile.am: New file. + +2001-11-16 Marcus Brinkmann + + * Makefile.am (TESTS): Add t-decrypt-verify. + * t-decrypt-verify.c: New file. + * cipher-2.asc: Likewise. + +2001-11-02 Marcus Brinkmann + + * t-data.c: Include stddef.h. + (read_once_test): Change type of READ to size_t. + (read_test): Likewise. + (write_test): Likewise. + +2001-10-29 Marcus Brinkmann + + * t-signers.c: New file. + * Makefile.am (TESTS): Add t-signers. + +2001-10-22 Marcus Brinkmann + + * Makefile.am (TEST_ENVIRONMENT): Revert last change. + +2001-10-22 Marcus Brinkmann + + * Makefile.am (TEST_ENVIRONMENT): Set environment to $(srcdir), + not current directory. + +2001-10-22 Marcus Brinkmann + + * t-data.c (write_test): New function. + (main): Invoke write_test for all rounds except TEST_OUT_CB. + +2001-10-22 Marcus Brinkmann + + * Makefile.am (INCLUDES): Remove spurious duplicate to silence + automake. + +2001-10-16 Marcus Brinkmann + + * t-version.c: New file. + * t-data.c: Likewise. + * t-data-1.txt: Likewise. + * t-data-2.txt: Likewise. + * Makefile.am (TESTS): Add t-version, t-data. + +2001-09-17 Werner Koch + + * t-keylist.c (check_two_contexts): New. + +2001-09-03 Werner Koch + + * t-encrypt.c (print_op_info): New and use it after each operation.. + +2001-08-28 Werner Koch + + * t-sign.c (print_op_info): New and use it after each operation. + +2001-03-15 Werner Koch + + * t-keylist.c (doit): List subkeys too, show caps. + +2001-02-13 Werner Koch + + * t-verify.c (print_sig_stat): Repaled ulong by unsigned long + because we don't use the config stuff here. + +2001-02-12 Werner Koch + + * tests/t-verify.c (print_sig_stat): Print info about the keys. + + + Copyright 2001 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. + + + + + + + + \ No newline at end of file diff --git a/tags/gpgme-0-4-3/tests/Makefile.am b/tags/gpgme-0-4-3/tests/Makefile.am new file mode 100644 index 0000000..d8b8f85 --- /dev/null +++ b/tags/gpgme-0-4-3/tests/Makefile.am @@ -0,0 +1,47 @@ +# Copyright (C) 2000 Werner Koch (dd9jn) +# Copyright (C) 2001 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 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA + +## Process this file with automake to produce Makefile.in + +TESTS_ENVIRONMENT = GNUPGHOME=. + +TESTS = t-version t-data t-engine-info + +EXTRA_DIST = t-data-1.txt t-data-2.txt + +INCLUDES = -I$(top_srcdir)/gpgme + +AM_CPPFLAGS = @GPG_ERROR_CFLAGS@ +LDADD = ../gpgme/libgpgme.la @GPG_ERROR_LIBS@ + +noinst_PROGRAMS = $(TESTS) + +if RUN_GPG_TESTS +gpgtests = gpg +else +gpgtests = +endif + +if RUN_GPGSM_TESTS +gpgsmtests = gpgsm +else +gpgsmtests = +endif + +SUBDIRS = ${gpgtests} ${gpgsmtests} diff --git a/tags/gpgme-0-4-3/tests/gpg/Makefile.am b/tags/gpgme-0-4-3/tests/gpg/Makefile.am new file mode 100644 index 0000000..82404c6 --- /dev/null +++ b/tags/gpgme-0-4-3/tests/gpg/Makefile.am @@ -0,0 +1,58 @@ +# Copyright (C) 2000 Werner Koch (dd9jn) +# Copyright (C) 2001 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 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA + +## Process this file with automake to produce Makefile.in + +GPG = @GPG@ + +TESTS_ENVIRONMENT = GNUPGHOME=. GPG_AGENT_INFO= + +# The keylist tests must come after the import and the edit test. +noinst_HEADERS = t-support.h +TESTS = t-encrypt t-encrypt-sym t-encrypt-sign t-sign t-signers \ + t-decrypt t-verify t-decrypt-verify \ + t-export t-import t-trustlist t-eventloop t-edit \ + t-keylist t-keylist-sig t-thread1 + +CLEANFILES = secring.gpg pubring.gpg trustdb.gpg +DISTCLEANFILES = pubring.gpg~ random_seed + +EXTRA_DIST = mkdemodirs pubdemo.asc secdemo.asc cipher-1.asc cipher-2.asc \ + geheim.txt pubkey-1.asc seckey-1.asc + +INCLUDES = -I$(top_srcdir)/gpgme + +AM_CPPFLAGS = @GPG_ERROR_CFLAGS@ +LDADD = ../../gpgme/libgpgme.la +t_thread1_LDADD = ../../gpgme/libgpgme-pthread.la + +# We don't run t-genkey in the test suite, because it takes too long +noinst_PROGRAMS = $(TESTS) t-genkey + +clean-local: + $(srcdir)/mkdemodirs --clean + +all-local: ./pubring.gpg + +./pubring.gpg: $(srcdir)/pubdemo.asc ./Alpha/Secret.gpg + $(GPG) --homedir . --import $(srcdir)/pubdemo.asc + $(GPG) --homedir . --allow-secret-key-import --import Alpha/Secret.gpg Zulu/Secret.gpg + +./Alpha/Secret.gpg: secdemo.asc + srcdir=$(srcdir) $(srcdir)/mkdemodirs diff --git a/tags/gpgme-0-4-3/tests/gpg/cipher-1.asc b/tags/gpgme-0-4-3/tests/gpg/cipher-1.asc new file mode 100644 index 0000000..f0a8ca4 --- /dev/null +++ b/tags/gpgme-0-4-3/tests/gpg/cipher-1.asc @@ -0,0 +1,15 @@ +-----BEGIN PGP MESSAGE----- +Version: GnuPG v1.0.4-2 (GNU/Linux) +Comment: For info see http://www.gnupg.org + +hQEOA2rm1+5GqHH4EAP/Tcqiuhvrjj+RFBKnWn2A7f1ztV17U2EngYFy8TbZYGNp +JoMNdpA7GNZs7iqc/x1epaZDKfaQwWEtARZmK/4nlhB48N+oZeKTm7PXIkRPqrCZ +3fxJjCJaU0yrNGuO345DOr0QwDImVhubVEkfgs8yXK2Szx2G8X3LmiaILHAqA2oD +/1ZqjY8k+ovrLL/qe8un/NTwzSjKIPVGR6mhLFXmj8fnp2kSsbo+Bhh4MczTRR6l +SA32z25vcakKu2qn5Wa4yDcx9NcMt8RHXzmfMDLj6UFq99QqKeLK2ywcIpY9p/GL +fQyaf7r3HTVugBSaoOzegLJ+L7MfWohrStkMeLnJQnro0nYBjADVcUQuSS4N3lst +Df3XrxxA/iJvxt4F9K27u4tp5U1HDg1CIxVrkMs92LBri3S6ZtfjdoqQ7QghFwGP +Kw1lKiWayM6NH9rcCKSgk4kl4P/2l3f78XeFgiywN7UGeSoH3BLMSv9gSxl5KrAz +d2imhTMrfEvZ +=y4ng +-----END PGP MESSAGE----- diff --git a/tags/gpgme-0-4-3/tests/gpg/cipher-2.asc b/tags/gpgme-0-4-3/tests/gpg/cipher-2.asc new file mode 100644 index 0000000..210f3e9 --- /dev/null +++ b/tags/gpgme-0-4-3/tests/gpg/cipher-2.asc @@ -0,0 +1,16 @@ +-----BEGIN PGP MESSAGE----- +Version: GnuPG v1.0.6 (GNU/Linux) +Comment: Weitere Infos: siehe http://www.gnupg.org + +hQEOA++dwnahcsiBEAP9HgkC1ElQwZRX1X/MBF54Q28dpXKr84IviO4QcbnnhmYk +2IlaNe6mr8R7kNM1aqJFK3fnobqnSWwM/VBObMqqYnzZSfclCNsy66sojQJxwXcz +DKQKi69BLaC6aTMnX048tOl8pJpR72fkffUOUa5ywDHVVVUClDG3XkIrfM1du3YD +/A6vFSrRylupKhQBxdtSUx5IDmpDYwG2vqqbYKoMaQ4pPSKLYV2zskU+pQWRlk6y +nwPGY5h9eGz0xYHMPxhe9VnwljeTEDwz5U4CHF3wQ8h5WBxOVx5QN/H/UyjpmoJT +ddrIu+8GgajhBVKVYAOqr577exkiSDA60/JrYbKZBvzL0sAJAUu+HoeMPJ+5/RYF +pLSdz/3MbVDRJJqzV2TJnEBvFtPa6urzx99P0u4xr+RJMFmR9/99YXhYz7+Y6d/B +44F6B3YouYxiK39IoOUcYPZTwb5kaudD5a3mU3XxEhSDUpnyvowPiKQO1T8CPd2u +2HsD3KeaOc2VFE0gnvqECvUTQfSCZCk/kil8XVAMHZrEA0bWAYiaHfHEOB8SRCy8 +rW0wsON4uDXmZpUkfOjFoYZdpJI7fDKkb5uYUzFZDasharEaXb1X/5xSAclx +=+eYk +-----END PGP MESSAGE----- diff --git a/tags/gpgme-0-4-3/tests/gpg/geheim.txt b/tags/gpgme-0-4-3/tests/gpg/geheim.txt new file mode 100644 index 0000000..99a5478 --- /dev/null +++ b/tags/gpgme-0-4-3/tests/gpg/geheim.txt @@ -0,0 +1,2 @@ +Wenn Sie dies lesen können, ist es wohl nicht +geheim genug. diff --git a/tags/gpgme-0-4-3/tests/gpg/mkdemodirs b/tags/gpgme-0-4-3/tests/gpg/mkdemodirs new file mode 100755 index 0000000..7c3bd04 --- /dev/null +++ b/tags/gpgme-0-4-3/tests/gpg/mkdemodirs @@ -0,0 +1,44 @@ +#!/bin/sh + +set -e + +GPG="gpg --batch --quiet --no-secmem-warning" +NAMES='Alpha Bravo Charlie Delta Echo Foxtrot Golf Hotel India + Juliet Kilo Lima Mike November Oscar Papa Quebec Romeo + Sierra Tango Uniform Victor Whisky XRay Yankee Zulu' + +if [ "$1" = "--clean" ]; then + (for i in $NAMES; do + [ -d $i ] && rm -r $i || true + done) || true + exit 0 +fi + +[ -z "$srcdir" ] && srcdir="../tests" + + +$GPG --dearmor -o secdemo.gpg --yes $srcdir/secdemo.asc +$GPG --dearmor -o pubdemo.gpg --yes $srcdir/pubdemo.asc +[ -f ./tdb.tmp ] && rm ./tdb.tmp +GPGDEMO="$GPG --homedir . --trustdb-name ./tdb.tmp --no-default-keyring + --keyring pubdemo.gpg --secret-keyring secdemo.gpg" +echo -n "Creating:" +for name in $NAMES; do + echo -n " $name" + [ -d $name ] && rm -r $name + mkdir $name + $GPGDEMO --export-secret-key -o - $name > $name/Secret.gpg + $GPG --homedir $name --allow-secret-key-import --import $name/Secret.gpg + $GPGDEMO --export -o - $name > $name/Public.gpg + $GPG --homedir $name --import $name/Public.gpg + [ -f $name/pubring.gpg~ ] && rm $name/pubring.gpg~ +done +echo "." +[ -f ./tdb.tmp ] && rm ./tdb.tmp +rm pubdemo.gpg secdemo.gpg + + + + + + diff --git a/tags/gpgme-0-4-3/tests/gpg/pubdemo.asc b/tags/gpgme-0-4-3/tests/gpg/pubdemo.asc new file mode 100644 index 0000000..d550f1a --- /dev/null +++ b/tags/gpgme-0-4-3/tests/gpg/pubdemo.asc @@ -0,0 +1,566 @@ +26 demo keys: + +pub 1024D/68697734 1999-03-08 Alpha Test (demo key) +uid Alice (demo key) +uid Alfa Test (demo key) +sub 1024g/46A871F8 1999-03-08 +pub 1024D/1AFDAB6C 1999-03-08 Charlie Test (demo key) +sub 1024g/BC43DA60 1999-03-08 +pub 1024D/FAEF6D1B 1999-03-08 Echo Test (demo key) +uid Eve (demo key) +uid Echelon (demo key) +sub 1024g/7272144D 1999-03-08 +pub 1024D/8FC282E6 1999-03-08 Golf Test (demo key) +sub 1024g/9DCAD354 1999-03-08 +pub 1024D/04259677 1999-03-08 India Test (demo key) +sub 1024g/61F76C73 1999-03-08 +pub 1024D/43C2D0C7 1999-03-08 Kilo Test (demo key) +sub 1024g/9AF64D02 1999-03-08 +pub 1024D/A9E3B0B2 1999-03-08 Bravo Test (demo key) +uid Bob (demo key) +sub 1024g/E29BA37F 1999-03-08 +pub 1024D/EB9DC9E6 1999-03-08 Delta Test (demo key) +sub 1024g/B0C45424 1999-03-08 +pub 1024D/7372E243 1999-03-08 Foxtrot Test (demo key) +sub 1024g/EE45198E 1999-03-08 +pub 1024D/34C6E3F1 1999-03-08 Hotel Test (demo key) +sub 1024g/D622AD0A 1999-03-08 +pub 1024D/D2699313 1999-03-08 Juliet Test (demo key) +sub 1024g/35F8F136 1999-03-08 +pub 1024D/B79103F8 1999-03-08 Lima Test (demo key) +sub 1024g/FE56350C 1999-03-08 +pub 1024D/BE5CF886 1999-03-08 Mike Test (demo key) +uid Mallory (demo key) +sub 1024g/4F31EAE8 1999-03-08 +pub 1024D/30CEC684 1999-03-08 November Test (demo key) +sub 1024g/8B70E472 1999-03-08 +pub 1024D/6D9732AC 1999-03-08 Oscar Test (demo key) +sub 1024g/2681619F 1999-03-08 +pub 1024D/3FF13206 1999-03-08 Papa test (demo key) +sub 1024g/63330D9C 1999-03-08 +pub 1024D/3C661C84 1999-03-08 Quebec Test (demo key) +sub 1024g/A029ACF4 1999-03-08 +pub 1024D/777FBED3 1999-03-08 Romeo Test (demo key) +sub 1024g/11D102EA 1999-03-08 +pub 1024D/A3AE3EA1 1999-03-08 Sierra Test (demo key) +sub 1024g/0F1B50B4 1999-03-08 +pub 1024D/85A81F38 1999-03-08 Tango Test (demo key) +sub 1024g/101C0402 1999-03-08 +pub 1024D/653244D6 1999-03-08 Uniform Test (demo key) +sub 1024g/5522BDB9 1999-03-08 +pub 1024D/61F04784 1999-03-08 Victor Test (demo key) +sub 1024g/07287134 1999-03-08 +pub 1024D/EC67DBDE 1999-03-08 Whisky Test (demo key) +sub 1024g/FD6E27F6 1999-03-08 +pub 1024D/567FB34A 1999-03-08 XRay Test (demo key) +sub 1024g/41E408BE 1999-03-08 +pub 1024D/4B11B25F 1999-03-08 Yankee Test (demo key) +sub 1024g/F7B080AD 1999-03-08 +pub 1024D/54ACD246 1999-03-08 Zulu Test (demo key) +sub 1024g/A172C881 1999-03-08 + +-----BEGIN PGP PUBLIC KEY BLOCK----- +Version: GnuPG v0.9.3 (GNU/Linux) +Comment: For info see http://www.gnupg.org + +mQGiBDbjjp4RBAC2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/ +hjl/7SZvR+MJpVLFPGjj7uOhTwADBQP/Sgv0abeCXVdVXwGEmhdV0VDo833IQRdR +u1yt+QLnWRMGTY1oQapsH6QLwYSZfDJlxbsBA3tfqKStpRSbdGNNTsK+RIehsGdd +i3sWGplRGm5Xt5KpkY/mc/tLFaYJNMqAgfWQcKlZHBp7EoWMgiRiDJUWq0TH1wRD +oPaRc+H5GdqIRgQYEQIABgUCNuO18gAKCRBrxHeAVKzSRn1jAKC5Gp5sHM9sWdZe +M6qfu54F2OwMQACfTjYXfpMApAROPkjhhFNqH0d8x5E= +=1N8S +-----END PGP PUBLIC KEY BLOCK----- diff --git a/tags/gpgme-0-4-3/tests/gpg/pubkey-1.asc b/tags/gpgme-0-4-3/tests/gpg/pubkey-1.asc new file mode 100644 index 0000000..bed1da3 --- /dev/null +++ b/tags/gpgme-0-4-3/tests/gpg/pubkey-1.asc @@ -0,0 +1,26 @@ +-----BEGIN PGP PUBLIC KEY BLOCK----- +Version: GnuPG v1.0.4b (GNU/Linux) +Comment: For info see http://www.gnupg.org + +mQGiBDo41NoRBADSfQazKGYf8nokq6zUKH/6INtV6MypSzSGmX2XErnARkIIPPYj +cQRQ8zCbGV7ZU2ezVbzhFLUSJveE8PZUzzCrLp1O2NSyBTRcR5HVSXW95nJfY8eV +pOvZRAKul0BVLh81kYTsrfzaaCjh9VWNP26LoeN2r+PjZyktXe7gM3C4SwCgoTxK +WUVi9HoT2HCLY7p7oig5hEcEALdCJal0UYomX3nJapIVLVZg3vkidr1RICYMb2vz +58i17h8sxEtobD1vdIKNejulntaRAXs4n0tDYD9z7pRlwG1CLz1R9WxYzeOOqUDr +fnVXdmU8L/oVWABat8v1V7QQhjMMf+41fuzVwDMMGqjVPLhu4X6wp3A8uyM3YDnQ +VMN1A/4n2G5gHoOvjqxn8Ch5tBAdMGfO8gH4RjQOwzm2R1wPQss/yzUN1+tlMZGX +K2dQ2FCWC/hDUSNaEQRlI15wxxBNZ2RQwlzE2A8v113DpvyzOtv0QO95gJ1teCXC +7j/BN9asgHaBBc39JLO/TcpuI7Hf8PQ5VcP2F0UE3lczGhXbLLQ/Sm9lIFJhbmRv +bSBIYWNrZXIgKHRlc3Qga2V5IHdpdGggcGFzc3BocmFzZSAieCIpIDxqb2VAc2V0 +cS5vcmc+iFcEExECABcFAjo41NoFCwcKAwQDFQMCAxYCAQIXgAAKCRCvgiRPnNn9 +VXm9AJ0auCQID9AQ4ic48A05OI4tcvs24ACgjsLML1iIYUtrSP1o6QSIYdnTUZy5 +AQ0EOjjU3RAEAJ50lvtCGbnQlI97VX6tJkosdPmdzeXaTWfv//A2wmSANbYnuych +GMa1LN43Ew+H6FXMWJ3MB/exs6UBFCgGsw88qmcla2bosQN/aVLA7fqXT9ujqoNG +aIVEmgdbK1MkSPFXBFyVW3hteod83D0UqFlltwp4A3ageCYFVJTp50d3AAMFA/44 +YCQQbg9x9JvzHX3VH7CRX+raEDkDL3Pbz0PHas7bwI7gzZ+GFyNKaCvrHQOyuR8R +IKIbjtQYnXr1675ConCTceIXhysY32sTn5V6UFUW2t0xaRfas8sZBbLDyIJkpt4f +yD+6OaRoui9KZqXMNwt7i/XFIto/sWd/OK3SIgZkAYhGBBgRAgAGBQI6ONTdAAoJ +EK+CJE+c2f1VVJoAn36uPWUhCdGXbSLxGibYfBt7et71AJ9JgWeRlTDTIoXYN8J+ +qsPN0YCxtg== +=4+Yp +-----END PGP PUBLIC KEY BLOCK----- diff --git a/tags/gpgme-0-4-3/tests/gpg/secdemo.asc b/tags/gpgme-0-4-3/tests/gpg/secdemo.asc new file mode 100644 index 0000000..343453c --- /dev/null +++ b/tags/gpgme-0-4-3/tests/gpg/secdemo.asc @@ -0,0 +1,737 @@ +26 demo keys (passphrase is "abc"): + +sec 1024D/68697734 1999-03-08 Alpha Test (demo key) +uid Alice (demo key) +uid Alfa Test (demo key) +ssb 1024g/46A871F8 1999-03-08 +sec 1024D/1AFDAB6C 1999-03-08 Charlie Test (demo key) +ssb 1024g/BC43DA60 1999-03-08 +sec 1024D/FAEF6D1B 1999-03-08 Echo Test (demo key) +uid Eve (demo key) +uid Echelon (demo key) +ssb 1024g/7272144D 1999-03-08 +sec 1024D/8FC282E6 1999-03-08 Golf Test (demo key) +ssb 1024g/9DCAD354 1999-03-08 +sec 1024D/04259677 1999-03-08 India Test (demo key) +ssb 1024g/61F76C73 1999-03-08 +sec 1024D/43C2D0C7 1999-03-08 Kilo Test (demo key) +ssb 1024g/9AF64D02 1999-03-08 +sec 1024D/A9E3B0B2 1999-03-08 Bravo Test (demo key) +uid Bob (demo key) +ssb 1024g/E29BA37F 1999-03-08 +sec 1024D/EB9DC9E6 1999-03-08 Delta Test (demo key) +ssb 1024g/B0C45424 1999-03-08 +sec 1024D/7372E243 1999-03-08 Foxtrot Test (demo key) +ssb 1024g/EE45198E 1999-03-08 +sec 1024D/34C6E3F1 1999-03-08 Hotel Test (demo key) +ssb 1024g/D622AD0A 1999-03-08 +sec 1024D/D2699313 1999-03-08 Juliet Test (demo key) +ssb 1024g/35F8F136 1999-03-08 +sec 1024D/B79103F8 1999-03-08 Lima Test (demo key) +ssb 1024g/FE56350C 1999-03-08 +sec 1024D/BE5CF886 1999-03-08 Mike Test (demo key) +uid Mallory (demo key) +ssb 1024g/4F31EAE8 1999-03-08 +sec 1024D/30CEC684 1999-03-08 November Test (demo key) +ssb 1024g/8B70E472 1999-03-08 +sec 1024D/6D9732AC 1999-03-08 Oscar Test (demo key) +ssb 1024g/2681619F 1999-03-08 +sec 1024D/3FF13206 1999-03-08 Papa test (demo key) +ssb 1024g/63330D9C 1999-03-08 +sec 1024D/3C661C84 1999-03-08 Quebec Test (demo key) +ssb 1024g/A029ACF4 1999-03-08 +sec 1024D/777FBED3 1999-03-08 Romeo Test (demo key) +ssb 1024g/11D102EA 1999-03-08 +sec 1024D/A3AE3EA1 1999-03-08 Sierra Test (demo key) +ssb 1024g/0F1B50B4 1999-03-08 +sec 1024D/85A81F38 1999-03-08 Tango Test (demo key) +ssb 1024g/101C0402 1999-03-08 +sec 1024D/653244D6 1999-03-08 Uniform Test (demo key) +ssb 1024g/5522BDB9 1999-03-08 +sec 1024D/61F04784 1999-03-08 Victor Test (demo key) +ssb 1024g/07287134 1999-03-08 +sec 1024D/EC67DBDE 1999-03-08 Whisky Test (demo key) +ssb 1024g/FD6E27F6 1999-03-08 +sec 1024D/567FB34A 1999-03-08 XRay Test (demo key) +ssb 1024g/41E408BE 1999-03-08 +sec 1024D/4B11B25F 1999-03-08 Yankee Test (demo key) +ssb 1024g/F7B080AD 1999-03-08 +sec 1024D/54ACD246 1999-03-08 Zulu Test (demo key) +ssb 1024g/A172C881 1999-03-08 + +-----BEGIN PGP PRIVATE KEY BLOCK----- +Version: GnuPG v0.9.3 (GNU/Linux) +Comment: For info see http://www.gnupg.org + +lQHOBDbjjp4RBAC2ZbFDX0wmJI8yLDYQdIiZeAuHLmfyHsqXaLGUMZtWiAvn/hNp +ctwahmzKm5oXinHUvUkLOQ0s8rOlu15nhw4azc30rTP1LsIkn5zORNnFdgYC6RKy +hOeim/63+/yGtdnTm49lVfaCqwsEmBCEkXaeWDGq+ie1b89J89T6n/JquwCgoQkj +VeVGG+B/SzJ6+yifdHWQVkcD/RXDyLXX4+WHGP2aet51XlKojWGwsZmc9LPPYhwU +/RcUO7ce1QQb0XFlUVFBhY0JQpM/ty/kNi+aGWFzigbQ+HAWZkUvA8+VIAVneN+p ++SHhGIyLTXKpAYTq46AwvllZ5Cpvf02Cp/+W1aVyA0qnBWMyeIxXmR9HOi6lxxn5 +cjajA/9VZufOXWqCXkBvz4Oy3Q5FbjQQ0/+ty8rDn8OTaiPi41FyUnEi6LO+qyBS +09FjnZj++PkcRcXW99SNxmEJRY7MuNHt5wIvEH2jNEOJ9lszzZFBDbuwsjXHK35+ +lPbGEy69xCP26iEafysKKbRXJhE1C+tk8SnK+Gm62sivmK/5av8EAQNuYiCeVh4Q +pF3i4v6LDa82cNBI92zOHLJAu1nbeJ6bl86f/lrm6DuH/SYjOkRTQV9mYWN0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nL1k3E/+QxqS7VGkRz6xnT+la7OVrexXz18ynbpvzJMPe2SAPyqY+RSzW +wf5Z/bgM+A/ftNFfEencn7KIRgQYEQIABgUCNuO18gAKCRBrxHeAVKzSRn1jAJsF +3zuwZ09o7T0yZNm4zWcRGZvteACgroLrVdUuNxbdEllH4BbcvFB06zA= +=P9+G +-----END PGP PRIVATE KEY BLOCK----- diff --git a/tags/gpgme-0-4-3/tests/gpg/seckey-1.asc b/tags/gpgme-0-4-3/tests/gpg/seckey-1.asc new file mode 100644 index 0000000..3934804 --- /dev/null +++ b/tags/gpgme-0-4-3/tests/gpg/seckey-1.asc @@ -0,0 +1,30 @@ +-----BEGIN PGP PRIVATE KEY BLOCK----- +Version: GnuPG v1.0.4b (GNU/Linux) +Comment: For info see http://www.gnupg.org + +lQHPBDo41NoRBADSfQazKGYf8nokq6zUKH/6INtV6MypSzSGmX2XErnARkIIPPYj +cQRQ8zCbGV7ZU2ezVbzhFLUSJveE8PZUzzCrLp1O2NSyBTRcR5HVSXW95nJfY8eV +pOvZRAKul0BVLh81kYTsrfzaaCjh9VWNP26LoeN2r+PjZyktXe7gM3C4SwCgoTxK +WUVi9HoT2HCLY7p7oig5hEcEALdCJal0UYomX3nJapIVLVZg3vkidr1RICYMb2vz +58i17h8sxEtobD1vdIKNejulntaRAXs4n0tDYD9z7pRlwG1CLz1R9WxYzeOOqUDr +fnVXdmU8L/oVWABat8v1V7QQhjMMf+41fuzVwDMMGqjVPLhu4X6wp3A8uyM3YDnQ +VMN1A/4n2G5gHoOvjqxn8Ch5tBAdMGfO8gH4RjQOwzm2R1wPQss/yzUN1+tlMZGX +K2dQ2FCWC/hDUSNaEQRlI15wxxBNZ2RQwlzE2A8v113DpvyzOtv0QO95gJ1teCXC +7j/BN9asgHaBBc39JLO/TcpuI7Hf8PQ5VcP2F0UE3lczGhXbLP8DAwKVpe92I5n5 +JGBjXsTTnVLoJ1hrWTdbLvdbn882m5pHYeqFlvkqKYXJTf0mIzpEU0FfZmFjdG9y +OgAAr0JzPBwQoEmNI3YSC1MwimZ77bpvVKP9JiM6RFNBX2ZhY3RvcjoAAK9/fVBz +g73cYbgeNWbz2uITUwNd9KEN/SYjOkRTQV9mYWN0b3I6AACvWjjITYZwah6NiH6C +YgX52m55Dy5PX7Q/Sm9lIFJhbmRvbSBIYWNrZXIgKHRlc3Qga2V5IHdpdGggcGFz +c3BocmFzZSAieCIpIDxqb2VAc2V0cS5vcmc+iFcEExECABcFAjo41NoFCwcKAwQD +FQMCAxYCAQIXgAAKCRCvgiRPnNn9VXm9AKCFQ/t23GQnQEfnnAnvbRNfRo4zIQCb +BHwILsDBASB1rQzW68UA/XHze0WdAUYEOjjU3RAEAJ50lvtCGbnQlI97VX6tJkos +dPmdzeXaTWfv//A2wmSANbYnuychGMa1LN43Ew+H6FXMWJ3MB/exs6UBFCgGsw88 +qmcla2bosQN/aVLA7fqXT9ujqoNGaIVEmgdbK1MkSPFXBFyVW3hteod83D0UqFll +twp4A3ageCYFVJTp50d3AAMFA/44YCQQbg9x9JvzHX3VH7CRX+raEDkDL3Pbz0PH +as7bwI7gzZ+GFyNKaCvrHQOyuR8RIKIbjtQYnXr1675ConCTceIXhysY32sTn5V6 +UFUW2t0xaRfas8sZBbLDyIJkpt4fyD+6OaRoui9KZqXMNwt7i/XFIto/sWd/OK3S +IgZkAf8DAwKVpe92I5n5JGAHRuEKSSvGU+0my6zTf17bLWPpFPnICNJdaMfyx24Y +RZZa+nDpYrRznJ89vohGBBgRAgAGBQI6ONTeAAoJEK+CJE+c2f1V7iIAn0WsYyUV +Huz4ZZ/WxxN57Ku2Eqs9AJ9Klz9imzvZoUjuE9/Ihr0y56tVng== +=lKvj +-----END PGP PRIVATE KEY BLOCK----- diff --git a/tags/gpgme-0-4-3/tests/gpg/t-decrypt-verify.c b/tags/gpgme-0-4-3/tests/gpg/t-decrypt-verify.c new file mode 100644 index 0000000..5cbfd0d --- /dev/null +++ b/tags/gpgme-0-4-3/tests/gpg/t-decrypt-verify.c @@ -0,0 +1,134 @@ +/* t-decrypt-verify.c - Regression test. + Copyright (C) 2000 Werner Koch (dd9jn) + Copyright (C) 2001, 2002, 2003 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 + 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. */ + +#include +#include +#include +#include +#include + +#include + +#include "t-support.h" + + +static void +check_verify_result (gpgme_verify_result_t result, unsigned int summary, + char *fpr, gpgme_error_t status) +{ + gpgme_signature_t sig; + + sig = result->signatures; + if (!sig || sig->next) + { + fprintf (stderr, "%s:%i: Unexpected number of signatures\n", + __FILE__, __LINE__); + exit (1); + } + if (sig->summary != summary) + { + fprintf (stderr, "%s:%i: Unexpected signature summary: 0x%x\n", + __FILE__, __LINE__, sig->summary); + exit (1); + } + if (strcmp (sig->fpr, fpr)) + { + fprintf (stderr, "%s:%i: Unexpected fingerprint: %s\n", + __FILE__, __LINE__, sig->fpr); + exit (1); + } + if (gpg_err_code (sig->status) != status) + { + fprintf (stderr, "%s:%i: Unexpected signature status: %s\n", + __FILE__, __LINE__, gpgme_strerror (sig->status)); + exit (1); + } + if (sig->notations) + { + fprintf (stderr, "%s:%i: Unexpected notation data\n", + __FILE__, __LINE__); + exit (1); + } + if (sig->wrong_key_usage) + { + fprintf (stderr, "%s:%i: Unexpectedly wrong key usage\n", + __FILE__, __LINE__); + exit (1); + } + if (sig->validity != GPGME_VALIDITY_UNKNOWN) + { + fprintf (stderr, "%s:%i: Unexpected validity: %i\n", + __FILE__, __LINE__, sig->validity); + exit (1); + } + if (gpg_err_code (sig->validity_reason) != GPG_ERR_NO_ERROR) + { + fprintf (stderr, "%s:%i: Unexpected validity reason: %s\n", + __FILE__, __LINE__, gpgme_strerror (sig->validity_reason)); + exit (1); + } +} + + +int +main (int argc, char *argv[]) +{ + gpgme_ctx_t ctx; + gpgme_error_t err; + gpgme_data_t in, out; + gpgme_decrypt_result_t decrypt_result; + gpgme_verify_result_t verify_result; + const char *cipher_2_asc = make_filename ("cipher-2.asc"); + char *agent_info; + + init_gpgme (GPGME_PROTOCOL_OpenPGP); + + err = gpgme_new (&ctx); + fail_if_err (err); + + agent_info = getenv("GPG_AGENT_INFO"); + if (!(agent_info && strchr (agent_info, ':'))) + gpgme_set_passphrase_cb (ctx, passphrase_cb, NULL); + + err = gpgme_data_new_from_file (&in, cipher_2_asc, 1); + fail_if_err (err); + err = gpgme_data_new (&out); + fail_if_err (err); + + err = gpgme_op_decrypt_verify (ctx, in, out); + fail_if_err (err); + decrypt_result = gpgme_op_decrypt_result (ctx); + if (decrypt_result->unsupported_algorithm) + { + fprintf (stderr, "%s:%i: unsupported algorithm: %s\n", + __FILE__, __LINE__, decrypt_result->unsupported_algorithm); + exit (1); + } + print_data (out); + verify_result = gpgme_op_verify_result (ctx); + check_verify_result (verify_result, 0, + "A0FF4590BB6122EDEF6E3C542D727CC768697734", + GPG_ERR_NO_ERROR); + + gpgme_data_release (in); + gpgme_data_release (out); + gpgme_release (ctx); + return 0; +} diff --git a/tags/gpgme-0-4-3/tests/gpg/t-decrypt.c b/tags/gpgme-0-4-3/tests/gpg/t-decrypt.c new file mode 100644 index 0000000..bfe05b2 --- /dev/null +++ b/tags/gpgme-0-4-3/tests/gpg/t-decrypt.c @@ -0,0 +1,72 @@ +/* t-decrypt.c - Regression test. + Copyright (C) 2000 Werner Koch (dd9jn) + Copyright (C) 2001, 2003 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 + 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. */ + +#include +#include +#include +#include +#include + +#include + +#include "t-support.h" + + +int +main (int argc, char *argv[]) +{ + gpgme_ctx_t ctx; + gpgme_error_t err; + gpgme_data_t in, out; + gpgme_decrypt_result_t result; + const char *cipher_1_asc = make_filename ("cipher-1.asc"); + char *agent_info; + + init_gpgme (GPGME_PROTOCOL_OpenPGP); + + err = gpgme_new (&ctx); + fail_if_err (err); + + agent_info = getenv("GPG_AGENT_INFO"); + if (!(agent_info && strchr (agent_info, ':'))) + gpgme_set_passphrase_cb (ctx, passphrase_cb, NULL); + + err = gpgme_data_new_from_file (&in, cipher_1_asc, 1); + fail_if_err (err); + + err = gpgme_data_new (&out); + fail_if_err (err); + + err = gpgme_op_decrypt (ctx, in, out); + fail_if_err (err); + result = gpgme_op_decrypt_result (ctx); + if (result->unsupported_algorithm) + { + fprintf (stderr, "%s:%i: unsupported algorithm: %s\n", + __FILE__, __LINE__, result->unsupported_algorithm); + exit (1); + } + print_data (out); + + gpgme_data_release (in); + gpgme_data_release (out); + gpgme_release (ctx); + return 0; +} diff --git a/tags/gpgme-0-4-3/tests/gpg/t-edit.c b/tags/gpgme-0-4-3/tests/gpg/t-edit.c new file mode 100644 index 0000000..cefcbc4 --- /dev/null +++ b/tags/gpgme-0-4-3/tests/gpg/t-edit.c @@ -0,0 +1,145 @@ +/* t-edit.c - Regression test. + Copyright (C) 2000 Werner Koch (dd9jn) + Copyright (C) 2001, 2002, 2003 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 + 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. */ + +#include +#include +#include +#include +#include +#include +#include + +#include + +#include "t-support.h" + + +static void +flush_data (gpgme_data_t dh) +{ + char buf[100]; + int ret; + + ret = gpgme_data_seek (dh, 0, SEEK_SET); + if (ret) + fail_if_err (gpg_error_from_errno (errno)); + while ((ret = gpgme_data_read (dh, buf, 100)) > 0) + fwrite (buf, ret, 1, stdout); + if (ret < 0) + fail_if_err (gpg_error_from_errno (errno)); +} + + +gpgme_error_t +edit_fnc (void *opaque, gpgme_status_code_t status, const char *args, int fd) +{ + char *result = NULL; + gpgme_data_t out = (gpgme_data_t) opaque; + + fputs ("[-- Response --]\n", stdout); + flush_data (out); + + fprintf (stdout, "[-- Code: %i, %s --]\n", status, args); + + if (fd >= 0) + { + if (!strcmp (args, "keyedit.prompt")) + { + static int step = 0; + + switch (step) + { + case 0: + result = "fpr"; + break; + case 1: + result = "expire"; + break; + + /* This fixes the primary user ID so the keylisting + tests will have predictable output. */ + case 2: + result = "1"; + break; + case 3: + result = "primary"; + break; + + default: + result = "quit"; + break; + } + step++; + } + else if (!strcmp (args, "keyedit.save.okay")) + result = "Y"; + else if (!strcmp (args, "keygen.valid")) + result = "0"; + } + + if (result) + { + write (fd, result, strlen (result)); + write (fd, "\n", 1); + } + return 0; +} + + +int +main (int argc, char **argv) +{ + gpgme_ctx_t ctx; + gpgme_error_t err; + gpgme_data_t out = NULL; + gpgme_key_t key = NULL; + const char *pattern = "Alpha"; + char *agent_info; + + init_gpgme (GPGME_PROTOCOL_OpenPGP); + + err = gpgme_new (&ctx); + fail_if_err (err); + err = gpgme_data_new (&out); + fail_if_err (err); + + agent_info = getenv("GPG_AGENT_INFO"); + if (!(agent_info && strchr (agent_info, ':'))) + gpgme_set_passphrase_cb (ctx, passphrase_cb, 0); + + err = gpgme_op_keylist_start (ctx, pattern, 0); + fail_if_err (err); + err = gpgme_op_keylist_next (ctx, &key); + fail_if_err (err); + err = gpgme_op_keylist_end (ctx); + fail_if_err (err); + + err = gpgme_op_edit (ctx, key, edit_fnc, out, out); + fail_if_err (err); + + fputs ("[-- Last response --]\n", stdout); + flush_data (out); + + gpgme_data_release (out); + gpgme_key_unref (key); + gpgme_release (ctx); + + return 0; +} diff --git a/tags/gpgme-0-4-3/tests/gpg/t-encrypt-sign.c b/tags/gpgme-0-4-3/tests/gpg/t-encrypt-sign.c new file mode 100644 index 0000000..19618c4 --- /dev/null +++ b/tags/gpgme-0-4-3/tests/gpg/t-encrypt-sign.c @@ -0,0 +1,132 @@ +/* t-encrypt.c - Regression test. + Copyright (C) 2000 Werner Koch (dd9jn) + Copyright (C) 2001, 2002, 2003 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 + 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. */ + +#include +#include +#include +#include + +#include + +#include "t-support.h" + + +static void +check_result (gpgme_sign_result_t result, gpgme_sig_mode_t type) +{ + if (result->invalid_signers) + { + fprintf (stderr, "Invalid signer found: %s\n", + result->invalid_signers->fpr); + exit (1); + } + if (!result->signatures || result->signatures->next) + { + fprintf (stderr, "Unexpected number of signatures created\n"); + exit (1); + } + if (result->signatures->type != type) + { + fprintf (stderr, "Wrong type of signature created\n"); + exit (1); + } + if (result->signatures->pubkey_algo != GPGME_PK_DSA) + { + fprintf (stderr, "Wrong pubkey algorithm reported: %i\n", + result->signatures->pubkey_algo); + exit (1); + } + if (result->signatures->hash_algo != GPGME_MD_SHA1) + { + fprintf (stderr, "Wrong hash algorithm reported: %i\n", + result->signatures->hash_algo); + exit (1); + } + if (result->signatures->class != 0) + { + fprintf (stderr, "Wrong signature class reported: %u\n", + result->signatures->class); + exit (1); + } + if (strcmp ("A0FF4590BB6122EDEF6E3C542D727CC768697734", + result->signatures->fpr)) + { + fprintf (stderr, "Wrong fingerprint reported: %s\n", + result->signatures->fpr); + exit (1); + } +} + + +int +main (int argc, char **argv) +{ + gpgme_ctx_t ctx; + gpgme_error_t err; + gpgme_data_t in, out; + gpgme_key_t key[3] = { NULL, NULL, NULL }; + gpgme_encrypt_result_t result; + gpgme_sign_result_t sign_result; + char *agent_info; + + init_gpgme (GPGME_PROTOCOL_OpenPGP); + + err = gpgme_new (&ctx); + fail_if_err (err); + gpgme_set_textmode (ctx, 1); + gpgme_set_armor (ctx, 1); + + agent_info = getenv("GPG_AGENT_INFO"); + if (!(agent_info && strchr (agent_info, ':'))) + gpgme_set_passphrase_cb (ctx, passphrase_cb, NULL); + + err = gpgme_data_new_from_mem (&in, "Hallo Leute\n", 12, 0); + fail_if_err (err); + + err = gpgme_data_new (&out); + fail_if_err (err); + + err = gpgme_get_key (ctx, "A0FF4590BB6122EDEF6E3C542D727CC768697734", + &key[0], 0); + fail_if_err (err); + err = gpgme_get_key (ctx, "D695676BDCEDCC2CDD6152BCFE180B1DA9E3B0B2", + &key[1], 0); + fail_if_err (err); + + err = gpgme_op_encrypt_sign (ctx, key, GPGME_ENCRYPT_ALWAYS_TRUST, in, out); + fail_if_err (err); + result = gpgme_op_encrypt_result (ctx); + if (result->invalid_recipients) + { + fprintf (stderr, "Invalid recipient encountered: %s\n", + result->invalid_recipients->fpr); + exit (1); + } + sign_result = gpgme_op_sign_result (ctx); + check_result (sign_result, GPGME_SIG_MODE_NORMAL); + print_data (out); + + gpgme_key_unref (key[0]); + gpgme_key_unref (key[1]); + gpgme_data_release (in); + gpgme_data_release (out); + gpgme_release (ctx); + return 0; +} diff --git a/tags/gpgme-0-4-3/tests/gpg/t-encrypt-sym.c b/tags/gpgme-0-4-3/tests/gpg/t-encrypt-sym.c new file mode 100644 index 0000000..29a3f47 --- /dev/null +++ b/tags/gpgme-0-4-3/tests/gpg/t-encrypt-sym.c @@ -0,0 +1,91 @@ +/* t-encrypt-sym.c - Regression test. + Copyright (C) 2000 Werner Koch (dd9jn) + Copyright (C) 2001, 2003 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 + 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. */ + +#include +#include +#include +#include +#include + +#include + +#include "t-support.h" + + +int +main (int argc, char *argv[]) +{ + gpgme_ctx_t ctx; + gpgme_error_t err; + gpgme_data_t plain, cipher; + const char *text = "Hallo Leute\n"; + char *text2; + char *p; + size_t len; + + init_gpgme (GPGME_PROTOCOL_OpenPGP); + + err = gpgme_new (&ctx); + fail_if_err (err); + gpgme_set_armor (ctx, 1); + + p = getenv("GPG_AGENT_INFO"); + if (!(p && strchr (p, ':'))) + gpgme_set_passphrase_cb (ctx, passphrase_cb, NULL); + + err = gpgme_data_new_from_mem (&plain, text, strlen (text), 0); + fail_if_err (err); + + err = gpgme_data_new (&cipher); + fail_if_err (err); + + err = gpgme_op_encrypt (ctx, 0, 0, plain, cipher); + fail_if_err (err); + + fflush (NULL); + fputs ("Begin Result Encryption:\n", stdout); + print_data (cipher); + fputs ("End Result.\n", stdout); + + gpgme_data_seek (cipher, 0, SEEK_SET); + + gpgme_data_release (plain); + err = gpgme_data_new (&plain); + fail_if_err (err); + + err = gpgme_op_decrypt (ctx, cipher, plain); + fail_if_err (err); + + fputs ("Begin Result Decryption:\n", stdout); + print_data (plain); + fputs ("End Result.\n", stdout); + + text2 = gpgme_data_release_and_get_mem (plain, &len); + if (strncmp (text, text2, len)) + { + fprintf (stderr, "%s:%d: Wrong plaintext\n", __FILE__, __LINE__); + exit (1); + } + + gpgme_data_release (cipher); + gpgme_release (ctx); + + return 0; +} diff --git a/tags/gpgme-0-4-3/tests/gpg/t-encrypt.c b/tags/gpgme-0-4-3/tests/gpg/t-encrypt.c new file mode 100644 index 0000000..756d216 --- /dev/null +++ b/tags/gpgme-0-4-3/tests/gpg/t-encrypt.c @@ -0,0 +1,75 @@ +/* t-encrypt.c - Regression test. + Copyright (C) 2000 Werner Koch (dd9jn) + Copyright (C) 2001, 2002, 2003 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 + 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. */ + +#include +#include +#include + +#include + +#include "t-support.h" + + +int +main (int argc, char *argv[]) +{ + gpgme_ctx_t ctx; + gpgme_error_t err; + gpgme_data_t in, out; + gpgme_key_t key[3] = { NULL, NULL, NULL }; + gpgme_encrypt_result_t result; + + init_gpgme (GPGME_PROTOCOL_OpenPGP); + + err = gpgme_new (&ctx); + fail_if_err (err); + gpgme_set_armor (ctx, 1); + + err = gpgme_data_new_from_mem (&in, "Hallo Leute\n", 12, 0); + fail_if_err (err); + + err = gpgme_data_new (&out); + fail_if_err (err); + + err = gpgme_get_key (ctx, "A0FF4590BB6122EDEF6E3C542D727CC768697734", + &key[0], 0); + fail_if_err (err); + err = gpgme_get_key (ctx, "D695676BDCEDCC2CDD6152BCFE180B1DA9E3B0B2", + &key[1], 0); + fail_if_err (err); + + err = gpgme_op_encrypt (ctx, key, GPGME_ENCRYPT_ALWAYS_TRUST, in, out); + fail_if_err (err); + result = gpgme_op_encrypt_result (ctx); + if (result->invalid_recipients) + { + fprintf (stderr, "Invalid recipient encountered: %s\n", + result->invalid_recipients->fpr); + exit (1); + } + print_data (out); + + gpgme_key_unref (key[0]); + gpgme_key_unref (key[1]); + gpgme_data_release (in); + gpgme_data_release (out); + gpgme_release (ctx); + return 0; +} diff --git a/tags/gpgme-0-4-3/tests/gpg/t-eventloop.c b/tags/gpgme-0-4-3/tests/gpg/t-eventloop.c new file mode 100644 index 0000000..1ffaea5 --- /dev/null +++ b/tags/gpgme-0-4-3/tests/gpg/t-eventloop.c @@ -0,0 +1,218 @@ +/* t-eventloop.c - regression test + Copyright (C) 2000 Werner Koch (dd9jn) + Copyright (C) 2001, 2002, 2003 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 + 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. */ + +#include +#include +#include +#include +#include +#include +#include + +#include + +#include "t-support.h" + + +/* Stripped down version of gpgme/wait.c. */ + +struct op_result +{ + int done; + gpgme_error_t err; +}; + +struct op_result op_result; + +struct one_fd +{ + int fd; + int dir; + gpgme_io_cb_t fnc; + void *fnc_data; +}; + +#define FDLIST_MAX 32 +struct one_fd fdlist[FDLIST_MAX]; + +gpgme_error_t +add_io_cb (void *data, int fd, int dir, gpgme_io_cb_t fnc, void *fnc_data, + void **r_tag) +{ + struct one_fd *fds = data; + int i; + + for (i = 0; i < FDLIST_MAX; i++) + { + if (fds[i].fd == -1) + { + fds[i].fd = fd; + fds[i].dir = dir; + fds[i].fnc = fnc; + fds[i].fnc_data = fnc_data; + break; + } + } + if (i == FDLIST_MAX) + return gpg_err_make (GPG_ERR_SOURCE_USER_1, GPG_ERR_GENERAL); + *r_tag = &fds[i]; + return 0; +} + +void +remove_io_cb (void *tag) +{ + struct one_fd *fd = tag; + + fd->fd = -1; +} + +void +io_event (void *data, gpgme_event_io_t type, void *type_data) +{ + struct op_result *result = data; + + if (type == GPGME_EVENT_DONE) + { + result->done = 1; + result->err = * (gpgme_error_t *) type_data; + } +} + + +int +do_select (void) +{ + fd_set rfds; + fd_set wfds; + int i, n; + int any = 0; + + FD_ZERO (&rfds); + FD_ZERO (&wfds); + for (i = 0; i < FDLIST_MAX; i++) + if (fdlist[i].fd != -1) + FD_SET (fdlist[i].fd, fdlist[i].dir ? &rfds : &wfds); + + do + { + n = select (FD_SETSIZE, &rfds, &wfds, NULL, 0); + } + while (n < 0 && errno == EINTR); + + if (n < 0) + return n; /* Error or timeout. */ + + for (i = 0; i < FDLIST_MAX && n; i++) + { + if (fdlist[i].fd != -1) + { + if (FD_ISSET (fdlist[i].fd, fdlist[i].dir ? &rfds : &wfds)) + { + assert (n); + n--; + any = 1; + (*fdlist[i].fnc) (fdlist[i].fnc_data, fdlist[i].fd); + } + } + } + return any; +} + +int +my_wait (void) +{ + int n; + + do + { + n = do_select (); + } + while (n >= 0 && !op_result.done); + return 0; +} + + +struct gpgme_io_cbs io_cbs = + { + add_io_cb, + fdlist, + remove_io_cb, + io_event, + &op_result + }; + + +int +main (int argc, char *argv[]) +{ + gpgme_ctx_t ctx; + gpgme_error_t err; + gpgme_data_t in, out; + gpgme_key_t key[3] = { NULL, NULL, NULL }; + int i; + + init_gpgme (GPGME_PROTOCOL_OpenPGP); + + for (i = 0; i < FDLIST_MAX; i++) + fdlist[i].fd = -1; + + err = gpgme_engine_check_version (GPGME_PROTOCOL_OpenPGP); + fail_if_err (err); + + err = gpgme_new (&ctx); + fail_if_err (err); + gpgme_set_armor (ctx, 1); + gpgme_set_io_cbs (ctx, &io_cbs); + op_result.done = 0; + + err = gpgme_data_new_from_mem (&in, "Hallo Leute\n", 12, 0); + fail_if_err (err); + + err = gpgme_data_new (&out); + fail_if_err (err); + + err = gpgme_get_key (ctx, "A0FF4590BB6122EDEF6E3C542D727CC768697734", + &key[0], 0); + fail_if_err (err); + err = gpgme_get_key (ctx, "D695676BDCEDCC2CDD6152BCFE180B1DA9E3B0B2", + &key[1], 0); + fail_if_err (err); + + err = gpgme_op_encrypt_start (ctx, key, GPGME_ENCRYPT_ALWAYS_TRUST, in, out); + fail_if_err (err); + + my_wait (); + fail_if_err (op_result.err); + fail_if_err (err); + + fflush (NULL); + fputs ("Begin Result:\n", stdout); + print_data (out); + fputs ("End Result.\n", stdout); + + gpgme_key_unref (key[0]); + gpgme_key_unref (key[1]); + gpgme_data_release (in); + gpgme_data_release (out); + gpgme_release (ctx); + + return 0; +} diff --git a/tags/gpgme-0-4-3/tests/gpg/t-export.c b/tags/gpgme-0-4-3/tests/gpg/t-export.c new file mode 100644 index 0000000..44c48f9 --- /dev/null +++ b/tags/gpgme-0-4-3/tests/gpg/t-export.c @@ -0,0 +1,60 @@ +/* t-export.c - Regression test. + Copyright (C) 2000 Werner Koch (dd9jn) + Copyright (C) 2001, 2003 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 + 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. */ + +#include +#include +#include +#include + +#include + +#include "t-support.h" + + +int +main (int argc, char **argv) +{ + gpgme_ctx_t ctx; + gpgme_error_t err; + gpgme_data_t out; + const char *pattern[] = { "Alpha", "Bob", NULL }; + + init_gpgme (GPGME_PROTOCOL_OpenPGP); + + err = gpgme_new (&ctx); + fail_if_err (err); + + err = gpgme_data_new (&out); + fail_if_err (err); + + gpgme_set_armor (ctx, 1); + err = gpgme_op_export_ext (ctx, pattern, 0, out); + fail_if_err (err); + + fflush (NULL); + fputs ("Begin Result:\n", stdout); + print_data (out); + fputs ("End Result.\n", stdout); + + gpgme_data_release (out); + gpgme_release (ctx); + + return 0; +} diff --git a/tags/gpgme-0-4-3/tests/gpg/t-genkey.c b/tags/gpgme-0-4-3/tests/gpg/t-genkey.c new file mode 100644 index 0000000..52bb99f --- /dev/null +++ b/tags/gpgme-0-4-3/tests/gpg/t-genkey.c @@ -0,0 +1,115 @@ +/* t-genkey.c - regression test + Copyright (C) 2000 Werner Koch (dd9jn) + Copyright (C) 2001, 2003 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 + 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. */ + +#include +#include +#include + +#include + +#include "t-support.h" + + +/* True if progress function printed something on the screen. */ +static int progress_called; + +static void +progress (void *self, const char *what, int type, int current, int total) +{ + if (!strcmp (what, "primegen") && !current && !total + && (type == '.' || type == '+' || type == '!' + || type == '^' || type == '<' || type == '>')) + { + printf ("%c", type); + fflush (stdout); + progress_called = 1; + } + else + { + fprintf (stderr, "unknown progress `%s' %d %d %d\n", what, type, + current, total); + exit (1); + } +} + + +int +main (int argc, char **argv) +{ + gpgme_ctx_t ctx; + gpgme_error_t err; + const char *parms = "\n" + "Key-Type: DSA\n" + "Key-Length: 1024\n" + "Subkey-Type: ELG-E\n" + "Subkey-Length: 1024\n" + "Name-Real: Joe Tester\n" + "Name-Comment: (pp=abc)\n" + "Name-Email: joe@foo.bar\n" + "Expire-Date: 0\n" + "Passphrase: abc\n" + "\n"; + gpgme_genkey_result_t result; + + init_gpgme (GPGME_PROTOCOL_OpenPGP); + + err = gpgme_new (&ctx); + fail_if_err (err); + + gpgme_set_progress_cb (ctx, progress, NULL); + + err = gpgme_op_genkey (ctx, parms, NULL, NULL); + fail_if_err (err); + + result = gpgme_op_genkey_result (ctx); + if (!result) + { + fprintf (stderr, "%s:%d: gpgme_op_genkey_result returns NULL\n", + __FILE__, __LINE__); + exit (1); + } + if (progress_called) + printf ("\n"); + + printf ("Generated key: %s (%s)\n", result->fpr ? result->fpr : "none", + result->primary ? (result->sub ? "primary, sub" : "primary") + : (result->sub ? "sub" : "none")); + + if (result->fpr && strlen (result->fpr) != 40) + { + fprintf (stderr, "%s:%d: generated key has unexpected fingerprint\n", + __FILE__, __LINE__); + exit (1); + } + if (!result->primary) + { + fprintf (stderr, "%s:%d: primary key was not generated\n", + __FILE__, __LINE__); + exit (1); + } + if (!result->sub) + { + fprintf (stderr, "%s:%d: sub key was not generated\n", + __FILE__, __LINE__); + exit (1); + } + gpgme_release (ctx); + return 0; +} diff --git a/tags/gpgme-0-4-3/tests/gpg/t-import.c b/tags/gpgme-0-4-3/tests/gpg/t-import.c new file mode 100644 index 0000000..22528e0 --- /dev/null +++ b/tags/gpgme-0-4-3/tests/gpg/t-import.c @@ -0,0 +1,231 @@ +/* t-import.c - regression test + Copyright (C) 2000 Werner Koch (dd9jn) + Copyright (C) 2001, 2003 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 + 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. */ + +#include +#include +#include +#include + +#include + +#include "t-support.h" + + +void +check_result (gpgme_import_result_t result, char *fpr, int secret) +{ + if (result->considered != 1) + { + fprintf (stderr, "Unexpected number of considered keys %i\n", + result->considered); + exit (1); + } + if (result->no_user_id != 0) + { + fprintf (stderr, "Unexpected number of user ids %i\n", + result->no_user_id); + exit (1); + } + if ((secret && result->imported != 0) + || (!secret && (result->imported != 0 && result->imported != 1))) + { + fprintf (stderr, "Unexpected number of imported keys %i\n", + result->imported); + exit (1); + } + if (result->imported_rsa != 0) + { + fprintf (stderr, "Unexpected number of imported RSA keys %i\n", + result->imported_rsa); + exit (1); + } + if ((secret && result->unchanged != 0) + || (!secret && ((result->imported == 0 && result->unchanged != 1) + || (result->imported == 1 && result->unchanged != 0)))) + { + fprintf (stderr, "Unexpected number of unchanged keys %i\n", + result->unchanged); + exit (1); + } + if (result->new_user_ids != 0) + { + fprintf (stderr, "Unexpected number of new user IDs %i\n", + result->new_user_ids); + exit (1); + } + if (result->new_sub_keys != 0) + { + fprintf (stderr, "Unexpected number of new sub keys %i\n", + result->new_sub_keys); + exit (1); + } + if ((secret + && ((result->secret_imported == 0 && result->new_signatures != 0) + || (result->secret_imported == 1 && result->new_signatures > 1))) + || (!secret && result->new_signatures != 0)) + { + fprintf (stderr, "Unexpected number of new signatures %i\n", + result->new_signatures); + exit (1); + } + if (result->new_revocations != 0) + { + fprintf (stderr, "Unexpected number of new revocations %i\n", + result->new_revocations); + exit (1); + } + if ((secret && result->secret_read != 1) + || (!secret && result->secret_read != 0)) + { + fprintf (stderr, "Unexpected number of secret keys read %i\n", + result->secret_read); + exit (1); + } + if ((secret && result->secret_imported != 0 && result->secret_imported != 1) + || (!secret && result->secret_imported != 0)) + { + fprintf (stderr, "Unexpected number of secret keys imported %i\n", + result->secret_imported); + exit (1); + } + if ((secret + && ((result->secret_imported == 0 && result->secret_unchanged != 1) + || (result->secret_imported == 1 && result->secret_unchanged != 0))) + || (!secret && result->secret_unchanged != 0)) + { + fprintf (stderr, "Unexpected number of secret keys unchanged %i\n", + result->secret_unchanged); + exit (1); + } + if (result->not_imported != 0) + { + fprintf (stderr, "Unexpected number of secret keys not imported %i\n", + result->not_imported); + exit (1); + } + if (secret) + { + if (!result->imports + || (result->imports->next && result->imports->next->next)) + { + fprintf (stderr, "Unexpected number of status reports\n"); + exit (1); + } + } + else + { + if (!result->imports || result->imports->next) + { + fprintf (stderr, "Unexpected number of status reports\n"); + exit (1); + } + } + if (strcmp (fpr, result->imports->fpr)) + { + fprintf (stderr, "Unexpected fingerprint %s\n", + result->imports->fpr); + exit (1); + } + if (result->imports->next && strcmp (fpr, result->imports->next->fpr)) + { + fprintf (stderr, "Unexpected fingerprint on second status %s\n", + result->imports->next->fpr); + exit (1); + } + if (result->imports->result != 0) + { + fprintf (stderr, "Unexpected status result %s\n", + gpgme_strerror (result->imports->result)); + exit (1); + } + if (secret) + { + if (result->secret_imported == 0) + { + if (result->imports->status != GPGME_IMPORT_SECRET) + { + fprintf (stderr, "Unexpected status %i\n", + result->imports->status); + exit (1); + } + } + else + { + if (result->imports->status + != (GPGME_IMPORT_SECRET | GPGME_IMPORT_NEW) + || (result->imports->next + && result->imports->next->status != GPGME_IMPORT_SIG)) + { + fprintf (stderr, "Unexpected status %i\n", + result->imports->status); + exit (1); + } + } + } + else + { + if ((result->imported == 0 && result->imports->status != 0) + || (result->imported == 1 + && result->imports->status != GPGME_IMPORT_NEW)) + { + fprintf (stderr, "Unexpected status %i\n", + result->imports->status); + exit (1); + } + } +} + + +int +main (int argc, char *argv[]) +{ + gpgme_ctx_t ctx; + gpgme_error_t err; + gpgme_data_t in; + gpgme_import_result_t result; + const char *pubkey_1_asc = make_filename ("pubkey-1.asc"); + const char *seckey_1_asc = make_filename ("seckey-1.asc"); + + init_gpgme (GPGME_PROTOCOL_OpenPGP); + + err = gpgme_new (&ctx); + fail_if_err (err); + + err = gpgme_data_new_from_file (&in, pubkey_1_asc, 1); + fail_if_err (err); + + err = gpgme_op_import (ctx, in); + fail_if_err (err); + result = gpgme_op_import_result (ctx); + check_result (result, "ADAB7FCC1F4DE2616ECFA402AF82244F9CD9FD55", 0); + gpgme_data_release (in); + + err = gpgme_data_new_from_file (&in, seckey_1_asc, 1); + fail_if_err (err); + + err = gpgme_op_import (ctx, in); + fail_if_err (err); + result = gpgme_op_import_result (ctx); + check_result (result, "ADAB7FCC1F4DE2616ECFA402AF82244F9CD9FD55", 1); + gpgme_data_release (in); + + gpgme_release (ctx); + return 0; +} diff --git a/tags/gpgme-0-4-3/tests/gpg/t-keylist-sig.c b/tags/gpgme-0-4-3/tests/gpg/t-keylist-sig.c new file mode 100644 index 0000000..6578eeb --- /dev/null +++ b/tags/gpgme-0-4-3/tests/gpg/t-keylist-sig.c @@ -0,0 +1,623 @@ +/* t-keylist-sig.c - Regression test. + Copyright (C) 2000 Werner Koch (dd9jn) + Copyright (C) 2001, 2003 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 + 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. */ + +#include +#include +#include + +#include + +#include "t-support.h" + + +struct +{ + char *fpr; + char *sec_keyid; + struct + { + char *name; + char *comment; + char *email; + struct + { + gpgme_pubkey_algo_t algo; + char *keyid; + char *name; + char *comment; + char *email; + unsigned int class; + int exportable; + } sig; + } uid[3]; +} +keys[] = + { + { "A0FF4590BB6122EDEF6E3C542D727CC768697734", "6AE6D7EE46A871F8", + { { "Alfa Test", "demo key", "alfa@example.net", + { GPGME_PK_DSA, "2D727CC768697734", + "Alfa Test", "demo key", "alfa@example.net", 19, 1 } }, + { "Alpha Test", "demo key", "alpha@example.net", + { GPGME_PK_DSA, "2D727CC768697734", + "Alfa Test", "demo key", "alfa@example.net", 19, 1 } }, + { "Alice", "demo key", NULL, + { GPGME_PK_DSA, "2D727CC768697734", + "Alfa Test", "demo key", "alfa@example.net", 19, 1 } } } }, + { NULL } + }; + + +int +main (int argc, char **argv) +{ + gpgme_error_t err; + gpgme_ctx_t ctx; + gpgme_key_t key; + gpgme_keylist_result_t result; + int mode; + int i = 0; + + init_gpgme (GPGME_PROTOCOL_OpenPGP); + + err = gpgme_new (&ctx); + fail_if_err (err); + + mode = gpgme_get_keylist_mode (ctx); + mode |= GPGME_KEYLIST_MODE_SIGS; + err = gpgme_set_keylist_mode (ctx, mode); + fail_if_err (err); + + err = gpgme_op_keylist_start (ctx, "Alpha", 0); + fail_if_err (err); + + while (!(err = gpgme_op_keylist_next (ctx, &key))) + { + if (!keys[i].fpr) + { + fprintf (stderr, "More keys returned than expected\n"); + exit (1); + } + + /* Global key flags. */ + if (key->revoked) + { + fprintf (stderr, "Key unexpectedly revoked\n"); + exit (1); + } + if (key->expired) + { + fprintf (stderr, "Key unexpectedly expired\n"); + exit (1); + } + if (key->disabled) + { + fprintf (stderr, "Key unexpectedly disabled\n"); + exit (1); + } + if (key->invalid) + { + fprintf (stderr, "Key unexpectedly invalid\n"); + exit (1); + } + if (!key->can_encrypt) + { + fprintf (stderr, "Key unexpectedly unusable for encryption\n"); + exit (1); + } + if (!key->can_sign) + { + fprintf (stderr, "Key unexpectedly unusable for signing\n"); + exit (1); + } + if (!key->can_certify) + { + fprintf (stderr, "Key unexpectedly unusable for certifications\n"); + exit (1); + } + if (key->secret) + { + fprintf (stderr, "Key unexpectedly secret\n"); + exit (1); + } + if (key->protocol != GPGME_PROTOCOL_OpenPGP) + { + fprintf (stderr, "Key has unexpected protocol: %s\n", + gpgme_get_protocol_name (key->protocol)); + exit (1); + } + if (key->issuer_serial) + { + fprintf (stderr, "Key unexpectedly carries issuer serial: %s\n", + key->issuer_serial); + exit (1); + } + if (key->issuer_name) + { + fprintf (stderr, "Key unexpectedly carries issuer name: %s\n", + key->issuer_name); + exit (1); + } + if (key->chain_id) + { + fprintf (stderr, "Key unexpectedly carries chain ID: %s\n", + key->chain_id); + exit (1); + } + if (key->owner_trust != GPGME_VALIDITY_UNKNOWN) + { + fprintf (stderr, "Key has unexpected owner trust: %i\n", + key->owner_trust); + exit (1); + } + if (!key->subkeys || !key->subkeys->next || key->subkeys->next->next) + { + fprintf (stderr, "Key has unexpected number of subkeys\n"); + exit (1); + } + + /* Primary key. */ + if (key->subkeys->revoked) + { + fprintf (stderr, "Primary key unexpectedly revoked\n"); + exit (1); + } + if (key->subkeys->expired) + { + fprintf (stderr, "Primary key unexpectedly expired\n"); + exit (1); + } + if (key->subkeys->disabled) + { + fprintf (stderr, "Primary key unexpectedly disabled\n"); + exit (1); + } + if (key->subkeys->invalid) + { + fprintf (stderr, "Primary key unexpectedly invalid\n"); + exit (1); + } + if (key->subkeys->can_encrypt) + { + fprintf (stderr, "Primary key unexpectedly usable for encryption\n"); + exit (1); + } + if (!key->subkeys->can_sign) + { + fprintf (stderr, "Primary key unexpectedly unusable for signing\n"); + exit (1); + } + if (!key->subkeys->can_certify) + { + fprintf (stderr, "Primary key unexpectedly unusable for certifications\n"); + exit (1); + } + if (key->subkeys->secret) + { + fprintf (stderr, "Primary key unexpectedly secret\n"); + exit (1); + } + if (key->subkeys->pubkey_algo != GPGME_PK_DSA) + { + fprintf (stderr, "Primary key has unexpected public key algo: %s\n", + gpgme_pubkey_algo_name (key->subkeys->pubkey_algo)); + exit (1); + } + if (key->subkeys->length != 1024) + { + fprintf (stderr, "Primary key has unexpected length: %i\n", + key->subkeys->length); + exit (1); + } + if (strcmp (key->subkeys->keyid, &keys[i].fpr[40 - 16])) + { + fprintf (stderr, "Primary key has unexpected key ID: %s\n", + key->subkeys->keyid); + exit (1); + } + if (strcmp (key->subkeys->fpr, keys[i].fpr)) + { + fprintf (stderr, "Primary key has unexpected fingerprint: %s\n", + key->subkeys->fpr); + exit (1); + } + if (key->subkeys->expires) + { + fprintf (stderr, "Primary key unexpectedly expires: %lu\n", + key->subkeys->expires); + exit (1); + } + + /* Secondary key. */ + if (key->subkeys->next->revoked) + { + fprintf (stderr, "Secondary key unexpectedly revoked\n"); + exit (1); + } + if (key->subkeys->next->expired) + { + fprintf (stderr, "Secondary key unexpectedly expired\n"); + exit (1); + } + if (key->subkeys->next->disabled) + { + fprintf (stderr, "Secondary key unexpectedly disabled\n"); + exit (1); + } + if (key->subkeys->next->invalid) + { + fprintf (stderr, "Secondary key unexpectedly invalid\n"); + exit (1); + } + if (!key->subkeys->next->can_encrypt) + { + fprintf (stderr, "Secondary key unexpectedly unusable for encryption\n"); + exit (1); + } + if (key->subkeys->next->can_sign) + { + fprintf (stderr, "Secondary key unexpectedly usable for signing\n"); + exit (1); + } + if (key->subkeys->next->can_certify) + { + fprintf (stderr, "Secondary key unexpectedly usable for certifications\n"); + exit (1); + } + if (key->subkeys->next->secret) + { + fprintf (stderr, "Secondary key unexpectedly secret\n"); + exit (1); + } + if (key->subkeys->next->pubkey_algo != GPGME_PK_ELG_E) + { + fprintf (stderr, "Secondary key has unexpected public key algo: %s\n", + gpgme_pubkey_algo_name (key->subkeys->next->pubkey_algo)); + exit (1); + } + if (key->subkeys->next->length != 1024) + { + fprintf (stderr, "Secondary key has unexpected length: %i\n", + key->subkeys->next->length); + exit (1); + } + if (strcmp (key->subkeys->next->keyid, keys[i].sec_keyid)) + { + fprintf (stderr, "Secondary key has unexpected key ID: %s\n", + key->subkeys->next->keyid); + exit (1); + } + if (key->subkeys->next->fpr) + { + fprintf (stderr, "Secondary key has unexpectedly a fingerprint: %s\n", + key->subkeys->next->fpr); + exit (1); + } + if (key->subkeys->next->expires) + { + fprintf (stderr, "Secondary key unexpectedly expires: %lu\n", + key->subkeys->next->expires); + exit (1); + } + + /* FIXME: The below test will crash if we want to check for a + name, comment or email that doesn't exist in the key's user + IDs. */ + if (!((!keys[i].uid[0].name && !key->uids) + || (keys[i].uid[0].name && !keys[i].uid[1].name + && key->uids && !key->uids->next) + || (keys[i].uid[0].name && keys[i].uid[1].name + && !keys[i].uid[2].name + && key->uids && key->uids->next && !key->uids->next->next) + || (keys[i].uid[0].name && keys[i].uid[1].name + && keys[i].uid[2].name + && key->uids && key->uids->next && key->uids->next->next + && !key->uids->next->next->next))) + { + fprintf (stderr, "Key has unexpected number of user IDs\n"); + exit (1); + } + if (key->uids && key->uids->revoked) + { + fprintf (stderr, "First user ID unexpectedly revoked\n"); + exit (1); + } + if (key->uids && key->uids->invalid) + { + fprintf (stderr, "First user ID unexpectedly invalid\n"); + exit (1); + } + if (key->uids && key->uids->validity != GPGME_VALIDITY_UNKNOWN) + { + fprintf (stderr, "First user ID has unexpectedly validity: %i\n", + key->uids->validity); + exit (1); + } + if (keys[i].uid[0].name + && strcmp (keys[i].uid[0].name, key->uids->name)) + { + fprintf (stderr, "Unexpected name in first user ID: %s\n", + key->uids->name); + exit (1); + } + if (keys[i].uid[0].comment + && strcmp (keys[i].uid[0].comment, key->uids->comment)) + { + fprintf (stderr, "Unexpected comment in first user ID: %s\n", + key->uids->comment); + exit (1); + } + if (keys[i].uid[0].email + && strcmp (keys[i].uid[0].email, key->uids->email)) + { + fprintf (stderr, "Unexpected email in first user ID: %s\n", + key->uids->email); + exit (1); + } + if (key->uids && (!key->uids->signatures || key->uids->signatures->next)) + { + fprintf (stderr, "First user ID unexpected number of signatures\n"); + exit (1); + } + if (keys[i].uid[0].sig.algo != key->uids->signatures->pubkey_algo) + { + fprintf (stderr, "Unexpected algorithm in first user ID sig: %s\n", + gpgme_pubkey_algo_name (key->uids->signatures->pubkey_algo)); + exit (1); + } + if (strcmp (keys[i].uid[0].sig.keyid, key->uids->signatures->keyid)) + { + fprintf (stderr, "Unexpected key ID in first user ID sig: %s\n", + key->uids->signatures->keyid); + exit (1); + } + if (strcmp (keys[i].uid[0].sig.name, key->uids->signatures->name)) + { + fprintf (stderr, "Unexpected name in first user ID sig: %s\n", + key->uids->signatures->name); + exit (1); + } + if (strcmp (keys[i].uid[0].sig.comment, key->uids->signatures->comment)) + { + fprintf (stderr, "Unexpected comment in first user ID sig: %s\n", + key->uids->signatures->comment); + exit (1); + } + if (strcmp (keys[i].uid[0].sig.email, key->uids->signatures->email)) + { + fprintf (stderr, "Unexpected email in first user ID sig: %s\n", + key->uids->signatures->email); + exit (1); + } + if (keys[i].uid[0].sig.class != key->uids->signatures->class) + { + fprintf (stderr, "Unexpected class in first user ID sig: %i\n", + key->uids->signatures->class); + exit (1); + } + if (keys[i].uid[0].sig.exportable != key->uids->signatures->exportable) + { + fprintf (stderr, "Unexpected exportable stat in first user ID sig: %i\n", + key->uids->signatures->exportable); + exit (1); + } + + if (key->uids && key->uids->next && key->uids->next->revoked) + { + fprintf (stderr, "Second user ID unexpectedly revoked\n"); + exit (1); + } + if (key->uids && key->uids->next && key->uids->next->invalid) + { + fprintf (stderr, "Second user ID unexpectedly invalid\n"); + exit (1); + } + if (key->uids && key->uids->next + && key->uids->next->validity != GPGME_VALIDITY_UNKNOWN) + { + fprintf (stderr, "Second user ID has unexpectedly validity: %i\n", + key->uids->next->validity); + exit (1); + } + if (keys[i].uid[1].name + && strcmp (keys[i].uid[1].name, key->uids->next->name)) + { + fprintf (stderr, "Unexpected name in second user ID: %s\n", + key->uids->next->name); + exit (1); + } + if (keys[i].uid[1].comment + && strcmp (keys[i].uid[1].comment, key->uids->next->comment)) + { + fprintf (stderr, "Unexpected comment in second user ID: %s\n", + key->uids->next->comment); + exit (1); + } + if (keys[i].uid[1].email + && strcmp (keys[i].uid[1].email, key->uids->next->email)) + { + fprintf (stderr, "Unexpected email in second user ID: %s\n", + key->uids->next->email); + exit (1); + } + if (key->uids && (!key->uids->next->signatures || key->uids->next->signatures->next)) + { + fprintf (stderr, "Second user ID unexpected number of signatures\n"); + exit (1); + } + if (keys[i].uid[1].sig.algo != key->uids->next->signatures->pubkey_algo) + { + fprintf (stderr, "Unexpected algorithm in second user ID sig: %s\n", + gpgme_pubkey_algo_name (key->uids->next->signatures->pubkey_algo)); + exit (1); + } + if (strcmp (keys[i].uid[1].sig.keyid, key->uids->next->signatures->keyid)) + { + fprintf (stderr, "Unexpected key ID in second user ID sig: %s\n", + key->uids->next->signatures->keyid); + exit (1); + } + if (strcmp (keys[i].uid[1].sig.name, key->uids->next->signatures->name)) + { + fprintf (stderr, "Unexpected name in second user ID sig: %s\n", + key->uids->next->signatures->name); + exit (1); + } + if (strcmp (keys[i].uid[1].sig.comment, key->uids->next->signatures->comment)) + { + fprintf (stderr, "Unexpected comment in second user ID sig: %s\n", + key->uids->next->signatures->comment); + exit (1); + } + if (strcmp (keys[i].uid[1].sig.email, key->uids->next->signatures->email)) + { + fprintf (stderr, "Unexpected email in second user ID sig: %s\n", + key->uids->next->signatures->email); + exit (1); + } + if (keys[i].uid[1].sig.class != key->uids->next->signatures->class) + { + fprintf (stderr, "Unexpected class in second user ID sig: %i\n", + key->uids->next->signatures->class); + exit (1); + } + if (keys[i].uid[1].sig.exportable != key->uids->next->signatures->exportable) + { + fprintf (stderr, "Unexpected exportable stat in second user ID sig: %i\n", + key->uids->next->signatures->exportable); + exit (1); + } + + if (key->uids && key->uids->next && key->uids->next->next + && key->uids->next->next->revoked) + { + fprintf (stderr, "Third user ID unexpectedly revoked\n"); + exit (1); + } + if (key->uids && key->uids->next && key->uids->next->next + && key->uids->next->next->invalid) + { + fprintf (stderr, "Third user ID unexpectedly invalid\n"); + exit (1); + } + if (key->uids && key->uids->next && key->uids->next->next + && key->uids->next->next->validity != GPGME_VALIDITY_UNKNOWN) + { + fprintf (stderr, "Third user ID has unexpectedly validity: %i\n", + key->uids->next->next->validity); + exit (1); + } + if (keys[i].uid[2].name + && strcmp (keys[i].uid[2].name, key->uids->next->next->name)) + { + fprintf (stderr, "Unexpected name in third user ID: %s\n", + key->uids->next->next->name); + exit (1); + } + if (keys[i].uid[2].comment + && strcmp (keys[i].uid[2].comment, key->uids->next->next->comment)) + { + fprintf (stderr, "Unexpected comment in third user ID: %s\n", + key->uids->next->next->comment); + exit (1); + } + if (keys[i].uid[2].email + && strcmp (keys[i].uid[2].email, key->uids->next->next->email)) + { + fprintf (stderr, "Unexpected email in third user ID: %s\n", + key->uids->next->next->email); + exit (1); + } + if (key->uids && (!key->uids->next->next->signatures + || key->uids->next->next->signatures->next)) + { + fprintf (stderr, "Third user ID unexpected number of signatures\n"); + exit (1); + } + if (keys[i].uid[2].sig.algo != key->uids->next->next->signatures->pubkey_algo) + { + fprintf (stderr, "Unexpected algorithm in third user ID sig: %s\n", + gpgme_pubkey_algo_name (key->uids->next->next->signatures->pubkey_algo)); + exit (1); + } + if (strcmp (keys[i].uid[2].sig.keyid, key->uids->next->next->signatures->keyid)) + { + fprintf (stderr, "Unexpected key ID in third user ID sig: %s\n", + key->uids->next->next->signatures->keyid); + exit (1); + } + if (strcmp (keys[i].uid[2].sig.name, key->uids->next->next->signatures->name)) + { + fprintf (stderr, "Unexpected name in third user ID sig: %s\n", + key->uids->next->next->signatures->name); + exit (1); + } + if (strcmp (keys[i].uid[2].sig.comment, key->uids->next->next->signatures->comment)) + { + fprintf (stderr, "Unexpected comment in third user ID sig: %s\n", + key->uids->next->next->signatures->comment); + exit (1); + } + if (strcmp (keys[i].uid[2].sig.email, key->uids->next->next->signatures->email)) + { + fprintf (stderr, "Unexpected email in third user ID sig: %s\n", + key->uids->next->next->signatures->email); + exit (1); + } + if (keys[i].uid[2].sig.class != key->uids->next->next->signatures->class) + { + fprintf (stderr, "Unexpected class in third user ID sig: %i\n", + key->uids->next->next->signatures->class); + exit (1); + } + if (keys[i].uid[2].sig.exportable != key->uids->next->next->signatures->exportable) + { + fprintf (stderr, "Unexpected exportable stat in third user ID sig: %i\n", + key->uids->next->next->signatures->exportable); + exit (1); + } + + + + + + gpgme_key_unref (key); + i++; + } + if (gpg_err_code (err) != GPG_ERR_EOF) + fail_if_err (err); + err = gpgme_op_keylist_end (ctx); + fail_if_err (err); + + result = gpgme_op_keylist_result (ctx); + if (result->truncated) + { + fprintf (stderr, "Key listing unexpectedly truncated\n"); + exit (1); + } + + if (keys[i].fpr) + { + fprintf (stderr, "Less keys returned than expected\n"); + exit (1); + } + + gpgme_release (ctx); + return 0; +} diff --git a/tags/gpgme-0-4-3/tests/gpg/t-keylist.c b/tags/gpgme-0-4-3/tests/gpg/t-keylist.c new file mode 100644 index 0000000..17c35ed --- /dev/null +++ b/tags/gpgme-0-4-3/tests/gpg/t-keylist.c @@ -0,0 +1,525 @@ +/* t-keylist.c - regression test + Copyright (C) 2000 Werner Koch (dd9jn) + Copyright (C) 2001, 2003 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 + 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. */ + +#include +#include +#include + +#include + +#include "t-support.h" + + +struct +{ + char *fpr; + char *sec_keyid; + struct + { + char *name; + char *comment; + char *email; + } uid[3]; +} +keys[] = + { + { "A0FF4590BB6122EDEF6E3C542D727CC768697734", "6AE6D7EE46A871F8", + { { "Alfa Test", "demo key", "alfa@example.net" }, + { "Alpha Test", "demo key", "alpha@example.net" }, + { "Alice", "demo key", NULL } } }, + { "61EE841A2A27EB983B3B3C26413F4AF31AFDAB6C", "E71E72ACBC43DA60", + { { "Charlie Test", "demo key", "charlie@example.net" } } }, + { "3531152DE293E26A07F504BC318C1FAEFAEF6D1B", "B5C79E1A7272144D", + { { "Echelon", "demo key", NULL }, + { "Echo Test", "demo key", "echo@example.net" }, + { "Eve", "demo key", NULL } } }, + { "C9C07DCC6621B9FB8D071B1D168410A48FC282E6", "247491CC9DCAD354", + { { "Golf Test", "demo key", "golf@example.net" } } }, + { "CD538D6CC9FB3D745ECDA5201FE8FC6F04259677", "C1C8EFDE61F76C73", + { { "India Test", "demo key", "india@example.net" } } }, + { "3FD11083779196C2ECDD9594AD1B0FAD43C2D0C7", "86CBB34A9AF64D02", + { { "Kilo Test", "demo key", "kilo@example.net" } } }, + { "D695676BDCEDCC2CDD6152BCFE180B1DA9E3B0B2", "5381EA4EE29BA37F", + { { "Bob", "demo key", NULL }, + { "Bravo Test", "demo key", "bravo@example.net" } } }, + { "6560C59C43D031C54D7C588EEBA9F240EB9DC9E6", "06F22880B0C45424", + { { "Delta Test", "demo key", "delta@example.net" } } }, + { "56D33268F7FE693FBB594762D4BF57F37372E243", "0A32EE79EE45198E", + { { "Foxtrot Test", "demo key", "foxtrot@example.net" } } }, + { "9E91CBB11E4D4135583EF90513DB965534C6E3F1", "76E26537D622AD0A", + { { "Hotel Test", "demo key", "hotel@example.net" } } }, + { "F8F1EDC73995AB739AD54B380C820C71D2699313", "BD0B108735F8F136", + { { "Juliet Test", "demo key", "juliet@example.net" } } }, + { "1DDD28CEF714F5B03B8C246937CAB51FB79103F8", "0363B449FE56350C", + { { "Lima Test", "demo key", "lima@example.net" } } }, + { "2686AA191A278013992C72EBBE794852BE5CF886", "5F600A834F31EAE8", + { { "Mallory", "demo key", NULL }, + { "Mike Test", "demo key", "mike@example.net" } } }, + { "5AB9D6D7BAA1C95B3BAA3D9425B00FD430CEC684", "4C1D63308B70E472", + { { "November Test", "demo key", "november@example.net" } } }, + { "43929E89F8F79381678CAE515F6356BA6D9732AC", "FF0785712681619F", + { { "Oscar Test", "demo key", "oscar@example.net" } } }, + { "6FAA9C201E5E26DCBAEC39FD5D15E01D3FF13206", "2764E18263330D9C", + { { "Papa test", "demo key", "papa@example.net" } } }, + { "A7969DA1C3297AA96D49843F1C67EC133C661C84", "6CDCFC44A029ACF4", + { { "Quebec Test", "demo key", "quebec@example.net" } } }, + { "38FBE1E4BF6A5E1242C8F6A13BDBEDB1777FBED3", "9FAB805A11D102EA", + { { "Romeo Test", "demo key", "romeo@example.net" } } }, + { "045B2334ADD69FC221076841A5E67F7FA3AE3EA1", "93B88B0F0F1B50B4", + { { "Sierra Test", "demo key", "sierra@example.net" } } }, + { "ECAC774F4EEEB0620767044A58CB9A4C85A81F38", "97B60E01101C0402", + { { "Tango Test", "demo key", "tango@example.net" } } }, + { "0DBCAD3F08843B9557C6C4D4A94C0F75653244D6", "93079B915522BDB9", + { { "Uniform Test", "demo key", "uniform@example.net" } } }, + { "E8143C489C8D41124DC40D0B47AF4B6961F04784", "04071FB807287134", + { { "Victor Test", "demo key", "victor@example.org" } } }, + { "E8D6C90B683B0982BD557A99DEF0F7B8EC67DBDE", "D7FBB421FD6E27F6", + { { "Whisky Test", "demo key", "whisky@example.net" } } }, + { "04C1DF62EFA0EBB00519B06A8979A6C5567FB34A", "5CC6F87F41E408BE", + { { "XRay Test", "demo key", "xray@example.net" } } }, + { "ED9B316F78644A58D042655A9EEF34CD4B11B25F", "5ADFD255F7B080AD", + { { "Yankee Test", "demo key", "yankee@example.net" } } }, + { "23FD347A419429BACCD5E72D6BC4778054ACD246", "EF9DC276A172C881", + { { "Zulu Test", "demo key", "zulu@example.net" } } }, + { "ADAB7FCC1F4DE2616ECFA402AF82244F9CD9FD55", "087DD7E0381701C4", + { { "Joe Random Hacker", "test key with passphrase \"x\"", + "joe@setq.org" } } }, + { NULL } + }; + +int +main (int argc, char **argv) +{ + gpgme_error_t err; + gpgme_ctx_t ctx; + gpgme_key_t key; + gpgme_keylist_result_t result; + int i = 0; + + init_gpgme (GPGME_PROTOCOL_OpenPGP); + + err = gpgme_new (&ctx); + fail_if_err (err); + + err = gpgme_op_keylist_start (ctx, NULL, 0); + fail_if_err (err); + + while (!(err = gpgme_op_keylist_next (ctx, &key))) + { + if (!keys[i].fpr) + { + fprintf (stderr, "More keys returned than expected\n"); + exit (1); + } + + /* Global key flags. */ + if (key->revoked) + { + fprintf (stderr, "Key unexpectedly revoked\n"); + exit (1); + } + if (key->expired) + { + fprintf (stderr, "Key unexpectedly expired\n"); + exit (1); + } + if (key->disabled) + { + fprintf (stderr, "Key unexpectedly disabled\n"); + exit (1); + } + if (key->invalid) + { + fprintf (stderr, "Key unexpectedly invalid\n"); + exit (1); + } + if (!key->can_encrypt) + { + fprintf (stderr, "Key unexpectedly unusable for encryption\n"); + exit (1); + } + if (!key->can_sign) + { + fprintf (stderr, "Key unexpectedly unusable for signing\n"); + exit (1); + } + if (!key->can_certify) + { + fprintf (stderr, "Key unexpectedly unusable for certifications\n"); + exit (1); + } + if (key->secret) + { + fprintf (stderr, "Key unexpectedly secret\n"); + exit (1); + } + if (key->protocol != GPGME_PROTOCOL_OpenPGP) + { + fprintf (stderr, "Key has unexpected protocol: %s\n", + gpgme_get_protocol_name (key->protocol)); + exit (1); + } + if (key->issuer_serial) + { + fprintf (stderr, "Key unexpectedly carries issuer serial: %s\n", + key->issuer_serial); + exit (1); + } + if (key->issuer_name) + { + fprintf (stderr, "Key unexpectedly carries issuer name: %s\n", + key->issuer_name); + exit (1); + } + if (key->chain_id) + { + fprintf (stderr, "Key unexpectedly carries chain ID: %s\n", + key->chain_id); + exit (1); + } + if (key->owner_trust != GPGME_VALIDITY_UNKNOWN) + { + fprintf (stderr, "Key has unexpected owner trust: %i\n", + key->owner_trust); + exit (1); + } + if (!key->subkeys || !key->subkeys->next || key->subkeys->next->next) + { + fprintf (stderr, "Key has unexpected number of subkeys\n"); + exit (1); + } + + /* Primary key. */ + if (key->subkeys->revoked) + { + fprintf (stderr, "Primary key unexpectedly revoked\n"); + exit (1); + } + if (key->subkeys->expired) + { + fprintf (stderr, "Primary key unexpectedly expired\n"); + exit (1); + } + if (key->subkeys->disabled) + { + fprintf (stderr, "Primary key unexpectedly disabled\n"); + exit (1); + } + if (key->subkeys->invalid) + { + fprintf (stderr, "Primary key unexpectedly invalid\n"); + exit (1); + } + if (key->subkeys->can_encrypt) + { + fprintf (stderr, "Primary key unexpectedly usable for encryption\n"); + exit (1); + } + if (!key->subkeys->can_sign) + { + fprintf (stderr, "Primary key unexpectedly unusable for signing\n"); + exit (1); + } + if (!key->subkeys->can_certify) + { + fprintf (stderr, "Primary key unexpectedly unusable for certifications\n"); + exit (1); + } + if (key->subkeys->secret) + { + fprintf (stderr, "Primary key unexpectedly secret\n"); + exit (1); + } + if (key->subkeys->pubkey_algo != GPGME_PK_DSA) + { + fprintf (stderr, "Primary key has unexpected public key algo: %s\n", + gpgme_pubkey_algo_name (key->subkeys->pubkey_algo)); + exit (1); + } + if (key->subkeys->length != 1024) + { + fprintf (stderr, "Primary key has unexpected length: %i\n", + key->subkeys->length); + exit (1); + } + if (strcmp (key->subkeys->keyid, &keys[i].fpr[40 - 16])) + { + fprintf (stderr, "Primary key has unexpected key ID: %s\n", + key->subkeys->keyid); + exit (1); + } + if (strcmp (key->subkeys->fpr, keys[i].fpr)) + { + fprintf (stderr, "Primary key has unexpected fingerprint: %s\n", + key->subkeys->fpr); + exit (1); + } + if (key->subkeys->expires) + { + fprintf (stderr, "Primary key unexpectedly expires: %lu\n", + key->subkeys->expires); + exit (1); + } + + /* Secondary key. */ + if (key->subkeys->next->revoked) + { + fprintf (stderr, "Secondary key unexpectedly revoked\n"); + exit (1); + } + if (key->subkeys->next->expired) + { + fprintf (stderr, "Secondary key unexpectedly expired\n"); + exit (1); + } + if (key->subkeys->next->disabled) + { + fprintf (stderr, "Secondary key unexpectedly disabled\n"); + exit (1); + } + if (key->subkeys->next->invalid) + { + fprintf (stderr, "Secondary key unexpectedly invalid\n"); + exit (1); + } + if (!key->subkeys->next->can_encrypt) + { + fprintf (stderr, "Secondary key unexpectedly unusable for encryption\n"); + exit (1); + } + if (key->subkeys->next->can_sign) + { + fprintf (stderr, "Secondary key unexpectedly usable for signing\n"); + exit (1); + } + if (key->subkeys->next->can_certify) + { + fprintf (stderr, "Secondary key unexpectedly usable for certifications\n"); + exit (1); + } + if (key->subkeys->next->secret) + { + fprintf (stderr, "Secondary key unexpectedly secret\n"); + exit (1); + } + if (key->subkeys->next->pubkey_algo != GPGME_PK_ELG_E) + { + fprintf (stderr, "Secondary key has unexpected public key algo: %s\n", + gpgme_pubkey_algo_name (key->subkeys->next->pubkey_algo)); + exit (1); + } + if (key->subkeys->next->length != 1024) + { + fprintf (stderr, "Secondary key has unexpected length: %i\n", + key->subkeys->next->length); + exit (1); + } + if (strcmp (key->subkeys->next->keyid, keys[i].sec_keyid)) + { + fprintf (stderr, "Secondary key has unexpected key ID: %s\n", + key->subkeys->next->keyid); + exit (1); + } + if (key->subkeys->next->fpr) + { + fprintf (stderr, "Secondary key has unexpectedly a fingerprint: %s\n", + key->subkeys->next->fpr); + exit (1); + } + if (key->subkeys->next->expires) + { + fprintf (stderr, "Secondary key unexpectedly expires: %lu\n", + key->subkeys->next->expires); + exit (1); + } + + /* FIXME: The below test will crash if we want to check for a + name, comment or email that doesn't exist in the key's user + IDs. */ + if (!((!keys[i].uid[0].name && !key->uids) + || (keys[i].uid[0].name && !keys[i].uid[1].name + && key->uids && !key->uids->next) + || (keys[i].uid[0].name && keys[i].uid[1].name + && !keys[i].uid[2].name + && key->uids && key->uids->next && !key->uids->next->next) + || (keys[i].uid[0].name && keys[i].uid[1].name + && keys[i].uid[2].name + && key->uids && key->uids->next && key->uids->next->next + && !key->uids->next->next->next))) + { + fprintf (stderr, "Key has unexpected number of user IDs\n"); + exit (1); + } + if (key->uids && key->uids->revoked) + { + fprintf (stderr, "First user ID unexpectedly revoked\n"); + exit (1); + } + if (key->uids && key->uids->invalid) + { + fprintf (stderr, "First user ID unexpectedly invalid\n"); + exit (1); + } + if (key->uids && key->uids->validity != GPGME_VALIDITY_UNKNOWN) + { + fprintf (stderr, "First user ID has unexpectedly validity: %i\n", + key->uids->validity); + exit (1); + } + if (key->uids && key->uids->signatures) + { + fprintf (stderr, "First user ID unexpectedly signed\n"); + exit (1); + } + if (keys[i].uid[0].name + && strcmp (keys[i].uid[0].name, key->uids->name)) + { + fprintf (stderr, "Unexpected name in first user ID: %s\n", + key->uids->name); + exit (1); + } + if (keys[i].uid[0].comment + && strcmp (keys[i].uid[0].comment, key->uids->comment)) + { + fprintf (stderr, "Unexpected comment in first user ID: %s\n", + key->uids->comment); + exit (1); + } + if (keys[i].uid[0].email + && strcmp (keys[i].uid[0].email, key->uids->email)) + { + fprintf (stderr, "Unexpected email in first user ID: %s\n", + key->uids->email); + exit (1); + } + if (key->uids && key->uids->next && key->uids->next->revoked) + { + fprintf (stderr, "Second user ID unexpectedly revoked\n"); + exit (1); + } + if (key->uids && key->uids->next && key->uids->next->invalid) + { + fprintf (stderr, "Second user ID unexpectedly invalid\n"); + exit (1); + } + if (key->uids && key->uids->next + && key->uids->next->validity != GPGME_VALIDITY_UNKNOWN) + { + fprintf (stderr, "Second user ID has unexpectedly validity: %i\n", + key->uids->next->validity); + exit (1); + } + if (key->uids && key->uids->next && key->uids->next->signatures) + { + fprintf (stderr, "Second user ID unexpectedly signed\n"); + exit (1); + } + if (keys[i].uid[1].name + && strcmp (keys[i].uid[1].name, key->uids->next->name)) + { + fprintf (stderr, "Unexpected name in second user ID: %s\n", + key->uids->next->name); + exit (1); + } + if (keys[i].uid[1].comment + && strcmp (keys[i].uid[1].comment, key->uids->next->comment)) + { + fprintf (stderr, "Unexpected comment in second user ID: %s\n", + key->uids->next->comment); + exit (1); + } + if (keys[i].uid[1].email + && strcmp (keys[i].uid[1].email, key->uids->next->email)) + { + fprintf (stderr, "Unexpected email in second user ID: %s\n", + key->uids->next->email); + exit (1); + } + if (key->uids && key->uids->next && key->uids->next->next + && key->uids->next->next->revoked) + { + fprintf (stderr, "Third user ID unexpectedly revoked\n"); + exit (1); + } + if (key->uids && key->uids->next && key->uids->next->next + && key->uids->next->next->invalid) + { + fprintf (stderr, "Third user ID unexpectedly invalid\n"); + exit (1); + } + if (key->uids && key->uids->next && key->uids->next->next + && key->uids->next->next->validity != GPGME_VALIDITY_UNKNOWN) + { + fprintf (stderr, "Third user ID has unexpectedly validity: %i\n", + key->uids->next->next->validity); + exit (1); + } + if (key->uids && key->uids->next && key->uids->next->next + && key->uids->next->next->signatures) + { + fprintf (stderr, "Third user ID unexpectedly signed\n"); + exit (1); + } + if (keys[i].uid[2].name + && strcmp (keys[i].uid[2].name, key->uids->next->next->name)) + { + fprintf (stderr, "Unexpected name in third user ID: %s\n", + key->uids->next->next->name); + exit (1); + } + if (keys[i].uid[2].comment + && strcmp (keys[i].uid[2].comment, key->uids->next->next->comment)) + { + fprintf (stderr, "Unexpected comment in third user ID: %s\n", + key->uids->next->next->comment); + exit (1); + } + if (keys[i].uid[2].email + && strcmp (keys[i].uid[2].email, key->uids->next->next->email)) + { + fprintf (stderr, "Unexpected email in third user ID: %s\n", + key->uids->next->next->email); + exit (1); + } + + gpgme_key_unref (key); + i++; + } + if (gpg_err_code (err) != GPG_ERR_EOF) + fail_if_err (err); + err = gpgme_op_keylist_end (ctx); + fail_if_err (err); + + result = gpgme_op_keylist_result (ctx); + if (result->truncated) + { + fprintf (stderr, "Key listing unexpectedly truncated\n"); + exit (1); + } + + if (keys[i].fpr) + { + fprintf (stderr, "Less keys returned than expected\n"); + exit (1); + } + + gpgme_release (ctx); + return 0; +} diff --git a/tags/gpgme-0-4-3/tests/gpg/t-sign.c b/tags/gpgme-0-4-3/tests/gpg/t-sign.c new file mode 100644 index 0000000..1b9d06d --- /dev/null +++ b/tags/gpgme-0-4-3/tests/gpg/t-sign.c @@ -0,0 +1,137 @@ +/* t-sign.c - Regression test. + Copyright (C) 2000 Werner Koch (dd9jn) + Copyright (C) 2001, 2003 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 + 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. */ + +#include +#include +#include +#include + +#include + +#include "t-support.h" + + +static void +check_result (gpgme_sign_result_t result, gpgme_sig_mode_t type) +{ + if (result->invalid_signers) + { + fprintf (stderr, "Invalid signer found: %s\n", + result->invalid_signers->fpr); + exit (1); + } + if (!result->signatures || result->signatures->next) + { + fprintf (stderr, "Unexpected number of signatures created\n"); + exit (1); + } + if (result->signatures->type != type) + { + fprintf (stderr, "Wrong type of signature created\n"); + exit (1); + } + if (result->signatures->pubkey_algo != GPGME_PK_DSA) + { + fprintf (stderr, "Wrong pubkey algorithm reported: %i\n", + result->signatures->pubkey_algo); + exit (1); + } + if (result->signatures->hash_algo != GPGME_MD_SHA1) + { + fprintf (stderr, "Wrong hash algorithm reported: %i\n", + result->signatures->hash_algo); + exit (1); + } + if (result->signatures->class != 1) + { + fprintf (stderr, "Wrong signature class reported: %u\n", + result->signatures->class); + exit (1); + } + if (strcmp ("A0FF4590BB6122EDEF6E3C542D727CC768697734", + result->signatures->fpr)) + { + fprintf (stderr, "Wrong fingerprint reported: %s\n", + result->signatures->fpr); + exit (1); + } +} + + +int +main (int argc, char **argv) +{ + gpgme_ctx_t ctx; + gpgme_error_t err; + gpgme_data_t in, out; + gpgme_sign_result_t result; + char *agent_info; + + init_gpgme (GPGME_PROTOCOL_OpenPGP); + + err = gpgme_new (&ctx); + fail_if_err (err); + + agent_info = getenv ("GPG_AGENT_INFO"); + if (!(agent_info && strchr (agent_info, ':'))) + gpgme_set_passphrase_cb (ctx, passphrase_cb, NULL); + + gpgme_set_textmode (ctx, 1); + gpgme_set_armor (ctx, 1); + + err = gpgme_data_new_from_mem (&in, "Hallo Leute\n", 12, 0); + fail_if_err (err); + + /* First a normal signature. */ + err = gpgme_data_new (&out); + fail_if_err (err); + err = gpgme_op_sign (ctx, in, out, GPGME_SIG_MODE_NORMAL); + fail_if_err (err); + result = gpgme_op_sign_result (ctx); + check_result (result, GPGME_SIG_MODE_NORMAL); + print_data (out); + gpgme_data_release (out); + + /* Now a detached signature. */ + gpgme_data_seek (in, 0, SEEK_SET); + err = gpgme_data_new (&out); + fail_if_err (err); + err = gpgme_op_sign (ctx, in, out, GPGME_SIG_MODE_DETACH); + fail_if_err (err); + result = gpgme_op_sign_result (ctx); + check_result (result, GPGME_SIG_MODE_DETACH); + print_data (out); + gpgme_data_release (out); + + /* And finally a cleartext signature. */ + gpgme_data_seek (in, 0, SEEK_SET); + err = gpgme_data_new (&out); + fail_if_err (err); + err = gpgme_op_sign (ctx, in, out, GPGME_SIG_MODE_CLEAR); + fail_if_err (err); + result = gpgme_op_sign_result (ctx); + check_result (result, GPGME_SIG_MODE_CLEAR); + print_data (out); + gpgme_data_release (out); + + gpgme_data_release (in); + gpgme_release (ctx); + return 0; +} diff --git a/tags/gpgme-0-4-3/tests/gpg/t-signers.c b/tags/gpgme-0-4-3/tests/gpg/t-signers.c new file mode 100644 index 0000000..f8288b4 --- /dev/null +++ b/tags/gpgme-0-4-3/tests/gpg/t-signers.c @@ -0,0 +1,167 @@ +/* t-signers.c - Regression tests for the multiple signers interface. + Copyright (C) 2000 Werner Koch (dd9jn) + Copyright (C) 2001, 2003 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 + 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. */ + +#include +#include +#include +#include + +#include + +#include "t-support.h" + + +static void +check_result (gpgme_sign_result_t result, gpgme_sig_mode_t type) +{ + gpgme_new_signature_t signature; + + if (result->invalid_signers) + { + fprintf (stderr, "Invalid signer found: %s\n", + result->invalid_signers->fpr); + exit (1); + } + if (!result->signatures || !result->signatures->next + || result->signatures->next->next) + { + fprintf (stderr, "Unexpected number of signatures created\n"); + exit (1); + } + + signature = result->signatures; + while (signature) + { + if (signature->type != type) + { + fprintf (stderr, "Wrong type of signature created\n"); + exit (1); + } + if (signature->pubkey_algo != GPGME_PK_DSA) + { + fprintf (stderr, "Wrong pubkey algorithm reported: %i\n", + signature->pubkey_algo); + exit (1); + } + if (signature->hash_algo != GPGME_MD_SHA1) + { + fprintf (stderr, "Wrong hash algorithm reported: %i\n", + signature->hash_algo); + exit (1); + } + if (signature->class != 1) + { + fprintf (stderr, "Wrong signature class reported: %u\n", + signature->class); + exit (1); + } + if (strcmp ("A0FF4590BB6122EDEF6E3C542D727CC768697734", + signature->fpr) + && strcmp ("23FD347A419429BACCD5E72D6BC4778054ACD246", + signature->fpr)) + { + fprintf (stderr, "Wrong fingerprint reported: %s\n", + signature->fpr); + exit (1); + } + signature = signature->next; + } +} + + +int +main (int argc, char *argv[]) +{ + gpgme_ctx_t ctx; + gpgme_error_t err; + gpgme_data_t in, out; + gpgme_key_t key[2]; + gpgme_sign_result_t result; + char *agent_info; + + init_gpgme (GPGME_PROTOCOL_OpenPGP); + + err = gpgme_new (&ctx); + fail_if_err (err); + + agent_info = getenv("GPG_AGENT_INFO"); + if (!(agent_info && strchr (agent_info, ':'))) + gpgme_set_passphrase_cb (ctx, passphrase_cb, NULL); + + gpgme_set_textmode (ctx, 1); + gpgme_set_armor (ctx, 1); + + err = gpgme_op_keylist_start (ctx, NULL, 1); + fail_if_err (err); + err = gpgme_op_keylist_next (ctx, &key[0]); + fail_if_err (err); + err = gpgme_op_keylist_next (ctx, &key[1]); + fail_if_err (err); + err = gpgme_op_keylist_end (ctx); + fail_if_err (err); + + err = gpgme_signers_add (ctx, key[0]); + fail_if_err (err); + err = gpgme_signers_add (ctx, key[1]); + fail_if_err (err); + + err = gpgme_data_new_from_mem (&in, "Hallo Leute\n", 12, 0); + fail_if_err (err); + + /* First a normal signature. */ + err = gpgme_data_new (&out); + fail_if_err (err); + err = gpgme_op_sign (ctx, in, out, GPGME_SIG_MODE_NORMAL); + fail_if_err (err); + result = gpgme_op_sign_result (ctx); + check_result (result, GPGME_SIG_MODE_NORMAL); + print_data (out); + gpgme_data_release (out); + + /* Now a detached signature. */ + gpgme_data_seek (in, 0, SEEK_SET); + err = gpgme_data_new (&out); + fail_if_err (err); + err = gpgme_op_sign (ctx, in, out, GPGME_SIG_MODE_DETACH); + fail_if_err (err); + result = gpgme_op_sign_result (ctx); + check_result (result, GPGME_SIG_MODE_DETACH); + print_data (out); + gpgme_data_release (out); + + /* And finally a cleartext signature. */ + gpgme_data_seek (in, 0, SEEK_SET); + err = gpgme_data_new (&out); + fail_if_err (err); + err = gpgme_op_sign (ctx, in, out, GPGME_SIG_MODE_CLEAR); + fail_if_err (err); + result = gpgme_op_sign_result (ctx); + check_result (result, GPGME_SIG_MODE_CLEAR); + print_data (out); + gpgme_data_release (out); + gpgme_data_seek (in, 0, SEEK_SET); + + gpgme_data_release (in); + gpgme_release (ctx); + + gpgme_key_unref (key[0]); + gpgme_key_unref (key[1]); + return 0; +} diff --git a/tags/gpgme-0-4-3/tests/gpg/t-support.h b/tags/gpgme-0-4-3/tests/gpg/t-support.h new file mode 100644 index 0000000..929a5d1 --- /dev/null +++ b/tags/gpgme-0-4-3/tests/gpg/t-support.h @@ -0,0 +1,98 @@ +/* t-support.h - Helper routines for regression tests. + Copyright (C) 2000 Werner Koch (dd9jn) + Copyright (C) 2001, 2002, 2003 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 + 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. */ + +#include +#include +#include +#include + +#include + +#define fail_if_err(err) \ + do \ + { \ + if (err) \ + { \ + fprintf (stderr, "%s:%d: %s: %s\n", \ + __FILE__, __LINE__, gpgme_strsource (err), \ + gpgme_strerror (err)); \ + exit (1); \ + } \ + } \ + while (0) + + +void +print_data (gpgme_data_t dh) +{ +#define BUF_SIZE 512 + char buf[BUF_SIZE + 1]; + int ret; + + ret = gpgme_data_seek (dh, 0, SEEK_SET); + if (ret) + fail_if_err (gpgme_err_code_from_errno (errno)); + while ((ret = gpgme_data_read (dh, buf, BUF_SIZE)) > 0) + fwrite (buf, ret, 1, stdout); + if (ret < 0) + fail_if_err (gpgme_err_code_from_errno (errno)); +} + + +gpgme_error_t +passphrase_cb (void *opaque, const char *uid_hint, const char *passphrase_info, + int last_was_bad, int fd) +{ + write (fd, "abc\n", 4); + return 0; +} + + +char * +make_filename (const char *fname) +{ + const char *srcdir = getenv ("srcdir"); + char *buf; + + if (!srcdir) + srcdir = "."; + buf = malloc (strlen(srcdir) + strlen(fname) + 2); + if (!buf) + exit (8); + strcpy (buf, srcdir); + strcat (buf, "/"); + strcat (buf, fname); + return buf; +} + + +void +init_gpgme (gpgme_protocol_t proto) +{ + gpgme_error_t err; + + gpgme_check_version (NULL); + setlocale (LC_ALL, ""); + gpgme_set_locale (NULL, LC_CTYPE, setlocale (LC_CTYPE, NULL)); + gpgme_set_locale (NULL, LC_MESSAGES, setlocale (LC_MESSAGES, NULL)); + + err = gpgme_engine_check_version (proto); + fail_if_err (err); +} diff --git a/tags/gpgme-0-4-3/tests/gpg/t-thread1.c b/tags/gpgme-0-4-3/tests/gpg/t-thread1.c new file mode 100644 index 0000000..5054974 --- /dev/null +++ b/tags/gpgme-0-4-3/tests/gpg/t-thread1.c @@ -0,0 +1,149 @@ +/* t-thread1.c - Regression test. + Copyright (C) 2000 Werner Koch (dd9jn) + Copyright (C) 2001, 2003 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 + 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. */ + +#include +#include +#include +#include +#include +#include + +#include + +#include "t-support.h" + +#define ROUNDS 20 + + +void * +thread_one (void *name) +{ + int i; + + for (i = 0; i < ROUNDS; i++) + { + gpgme_ctx_t ctx; + gpgme_error_t err; + gpgme_data_t in, out; + gpgme_key_t key[3] = { NULL, NULL, NULL }; + gpgme_encrypt_result_t result; + + err = gpgme_new (&ctx); + fail_if_err (err); + gpgme_set_armor (ctx, 1); + + err = gpgme_data_new_from_mem (&in, "Hallo Leute\n", 12, 0); + fail_if_err (err); + + err = gpgme_data_new (&out); + fail_if_err (err); + + err = gpgme_get_key (ctx, "A0FF4590BB6122EDEF6E3C542D727CC768697734", + &key[0], 0); + fail_if_err (err); + err = gpgme_get_key (ctx, "D695676BDCEDCC2CDD6152BCFE180B1DA9E3B0B2", + &key[1], 0); + fail_if_err (err); + + err = gpgme_op_encrypt (ctx, key, GPGME_ENCRYPT_ALWAYS_TRUST, in, out); + fail_if_err (err); + result = gpgme_op_encrypt_result (ctx); + if (result->invalid_recipients) + { + fprintf (stderr, "Invalid recipient encountered: %s\n", + result->invalid_recipients->fpr); + exit (1); + } + printf ("Encrypt %s %i\n", (char *) name, i); + + gpgme_key_unref (key[0]); + gpgme_key_unref (key[1]); + gpgme_data_release (in); + gpgme_data_release (out); + gpgme_release (ctx); + } + return NULL; +} + + +void * +thread_two (void *name) +{ + int i; + const char *cipher_1_asc = make_filename ("cipher-1.asc"); + char *agent_info; + + agent_info = getenv("GPG_AGENT_INFO"); + + for (i = 0; i < ROUNDS; i++) + { + gpgme_ctx_t ctx; + gpgme_error_t err; + gpgme_data_t in, out; + gpgme_decrypt_result_t result; + + init_gpgme (GPGME_PROTOCOL_OpenPGP); + + err = gpgme_new (&ctx); + fail_if_err (err); + + if (!(agent_info && strchr (agent_info, ':'))) + gpgme_set_passphrase_cb (ctx, passphrase_cb, NULL); + + err = gpgme_data_new_from_file (&in, cipher_1_asc, 1); + fail_if_err (err); + + err = gpgme_data_new (&out); + fail_if_err (err); + + err = gpgme_op_decrypt (ctx, in, out); + fail_if_err (err); + result = gpgme_op_decrypt_result (ctx); + if (result->unsupported_algorithm) + { + fprintf (stderr, "%s:%i: unsupported algorithm: %s\n", + __FILE__, __LINE__, result->unsupported_algorithm); + exit (1); + } + printf ("Decrypt %s %i\n", (char *) name, i); + + gpgme_data_release (in); + gpgme_data_release (out); + gpgme_release (ctx); + } + return NULL; +} + +int +main (int argc, char *argv[]) +{ + pthread_t tone; + pthread_t ttwo; + + init_gpgme (GPGME_PROTOCOL_OpenPGP); + + pthread_create (&tone, NULL, thread_one, "A"); + pthread_create (&ttwo, NULL, thread_two, "B"); + + pthread_join (tone, NULL); + pthread_join (ttwo, NULL); + + return 0; +} diff --git a/tags/gpgme-0-4-3/tests/gpg/t-trustlist.c b/tags/gpgme-0-4-3/tests/gpg/t-trustlist.c new file mode 100644 index 0000000..c8c82f8 --- /dev/null +++ b/tags/gpgme-0-4-3/tests/gpg/t-trustlist.c @@ -0,0 +1,57 @@ +/* t-trustlist.c - Regression test. + Copyright (C) 2000 Werner Koch (dd9jn) + Copyright (C) 2001, 2003 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 + 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. */ + +#include +#include +#include + +#include + +#include "t-support.h" + + +int +main (int argc, char *argv[]) +{ + gpgme_ctx_t ctx; + gpgme_error_t err; + gpgme_trust_item_t item; + + init_gpgme (GPGME_PROTOCOL_OpenPGP); + + err = gpgme_new (&ctx); + fail_if_err (err); + + err = gpgme_op_trustlist_start (ctx, "alice", 0); + fail_if_err (err); + + while (!(err = gpgme_op_trustlist_next (ctx, &item))) + { + printf ("l=%d k=%s t=%d o=%s v=%s u=%s\n", + item->level, item->keyid, item->type, item->owner_trust, + item->validity, item->name); + gpgme_trust_item_unref (item); + } + if (gpg_err_code (err) != GPG_ERR_EOF) + fail_if_err (err); + + gpgme_release (ctx); + return 0; +} diff --git a/tags/gpgme-0-4-3/tests/gpg/t-verify.c b/tags/gpgme-0-4-3/tests/gpg/t-verify.c new file mode 100644 index 0000000..83e942f --- /dev/null +++ b/tags/gpgme-0-4-3/tests/gpg/t-verify.c @@ -0,0 +1,198 @@ +/* t-verify.c - Regression test. + Copyright (C) 2000 Werner Koch (dd9jn) + Copyright (C) 2001, 2002, 2003 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 + 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. */ + +#include +#include +#include + +#include + +#include "t-support.h" + + +static const char test_text1[] = "Just GNU it!\n"; +static const char test_text1f[]= "Just GNU it?\n"; +static const char test_sig1[] = +#if 0 +"-----BEGIN PGP SIGNATURE-----\n" +"\n" +"iEYEABECAAYFAjoKgjIACgkQLXJ8x2hpdzQMSwCeO/xUrhysZ7zJKPf/FyXA//u1\n" +"ZgIAn0204PBR7yxSdQx6CFxugstNqmRv\n" +"=yku6\n" +"-----END PGP SIGNATURE-----\n" +#elif 0 +"-----BEGIN PGP SIGNATURE-----\n" +"Version: GnuPG v1.0.4-2 (GNU/Linux)\n" +"Comment: For info see http://www.gnupg.org\n" +"\n" +"iJcEABECAFcFAjoS8/E1FIAAAAAACAAkZm9vYmFyLjF0aGlzIGlzIGEgbm90YXRp\n" +"b24gZGF0YSB3aXRoIDIgbGluZXMaGmh0dHA6Ly93d3cuZ3Uub3JnL3BvbGljeS8A\n" +"CgkQLXJ8x2hpdzQLyQCbBW/fgU8ZeWSlWPM1F8umHX17bAAAoIfSNDSp5zM85XcG\n" +"iwxMrf+u8v4r\n" +"=88Zo\n" +"-----END PGP SIGNATURE-----\n" +#elif 1 +"-----BEGIN PGP SIGNATURE-----\n" +"\n" +"iN0EABECAJ0FAjoS+i9FFIAAAAAAAwA5YmFyw7bDpMO8w58gZGFzIHdhcmVuIFVt\n" +"bGF1dGUgdW5kIGpldHp0IGVpbiBwcm96ZW50JS1aZWljaGVuNRSAAAAAAAgAJGZv\n" +"b2Jhci4xdGhpcyBpcyBhIG5vdGF0aW9uIGRhdGEgd2l0aCAyIGxpbmVzGhpodHRw\n" +"Oi8vd3d3Lmd1Lm9yZy9wb2xpY3kvAAoJEC1yfMdoaXc0JBIAoIiLlUsvpMDOyGEc\n" +"dADGKXF/Hcb+AKCJWPphZCphduxSvrzH0hgzHdeQaA==\n" +"=nts1\n" +"-----END PGP SIGNATURE-----\n" +#endif +; +static const char test_sig2[] = +"-----BEGIN PGP MESSAGE-----\n" +"\n" +"owGbwMvMwCSoW1RzPCOz3IRxjXQSR0lqcYleSUWJTZOvjVdpcYmCu1+oQmaJIleH\n" +"GwuDIBMDGysTSIqBi1MApi+nlGGuwDeHao53HBr+FoVGP3xX+kvuu9fCMJvl6IOf\n" +"y1kvP4y+8D5a11ang0udywsA\n" +"=Crq6\n" +"-----END PGP MESSAGE-----\n"; + + +static void +check_result (gpgme_verify_result_t result, unsigned int summary, char *fpr, + gpgme_error_t status, int notation) +{ + gpgme_signature_t sig; + + sig = result->signatures; + if (!sig || sig->next) + { + fprintf (stderr, "%s:%i: Unexpected number of signatures\n", + __FILE__, __LINE__); + exit (1); + } + if (sig->summary != summary) + { + fprintf (stderr, "%s:%i: Unexpected signature summary: 0x%x\n", + __FILE__, __LINE__, sig->summary); + exit (1); + } + if (strcmp (sig->fpr, fpr)) + { + fprintf (stderr, "%s:%i: Unexpected fingerprint: %s\n", + __FILE__, __LINE__, sig->fpr); + exit (1); + } + if (gpg_err_code (sig->status) != status) + { + fprintf (stderr, "%s:%i: Unexpected signature status: %s\n", + __FILE__, __LINE__, gpg_strerror (sig->status)); + exit (1); + } + if (notation) + { + if (!sig->notations + || strcmp (sig->notations->name, "bar") + || strcmp (sig->notations->value, "\xc3\xb6\xc3\xa4\xc3\xbc\xc3\x9f" + " das waren Umlaute und jetzt ein prozent%-Zeichen") + || !sig->notations->next + || strcmp (sig->notations->next->name, "foobar.1") + || strcmp (sig->notations->next->value, + "this is a notation data with 2 lines") + || !sig->notations->next->next + || sig->notations->next->next->name != NULL + || strcmp (sig->notations->next->next->value, + "http://www.gu.org/policy/") + || sig->notations->next->next->next) + { + fprintf (stderr, "%s:%i: Unexpected notation data\n", + __FILE__, __LINE__); + exit (1); + } + } + if (sig->wrong_key_usage) + { + fprintf (stderr, "%s:%i: Unexpectedly wrong key usage\n", + __FILE__, __LINE__); + exit (1); + } + if (sig->validity != GPGME_VALIDITY_UNKNOWN) + { + fprintf (stderr, "%s:%i: Unexpected validity: %i\n", + __FILE__, __LINE__, sig->validity); + exit (1); + } + if (gpg_err_code (sig->validity_reason) != GPG_ERR_NO_ERROR) + { + fprintf (stderr, "%s:%i: Unexpected validity reason: %s\n", + __FILE__, __LINE__, gpgme_strerror (sig->validity_reason)); + exit (1); + } +} + + +int +main (int argc, char *argv[]) +{ + gpgme_ctx_t ctx; + gpgme_error_t err; + gpgme_data_t sig, text; + gpgme_verify_result_t result; + + init_gpgme (GPGME_PROTOCOL_OpenPGP); + + err = gpgme_new (&ctx); + fail_if_err (err); + + /* Checking a valid message. */ + err = gpgme_data_new_from_mem (&text, test_text1, strlen (test_text1), 0); + fail_if_err (err); + err = gpgme_data_new_from_mem (&sig, test_sig1, strlen (test_sig1), 0); + fail_if_err (err); + err = gpgme_op_verify (ctx, sig, text, NULL); + fail_if_err (err); + result = gpgme_op_verify_result (ctx); + check_result (result, 0, "A0FF4590BB6122EDEF6E3C542D727CC768697734", + GPG_ERR_NO_ERROR, 1); + + /* Checking a manipulated message. */ + gpgme_data_release (text); + err = gpgme_data_new_from_mem (&text, test_text1f, strlen (test_text1f), 0); + fail_if_err (err); + gpgme_data_seek (sig, 0, SEEK_SET); + err = gpgme_op_verify (ctx, sig, text, NULL); + fail_if_err (err); + result = gpgme_op_verify_result (ctx); + check_result (result, GPGME_SIGSUM_RED, "2D727CC768697734", + GPG_ERR_BAD_SIGNATURE, 0); + + /* Checking a normal signature. */ + gpgme_data_release (sig); + gpgme_data_release (text); + err = gpgme_data_new_from_mem (&sig, test_sig2, strlen (test_sig2), 0); + fail_if_err (err); + err = gpgme_data_new (&text); + fail_if_err (err); + err = gpgme_op_verify (ctx, sig, NULL, text); + fail_if_err (err); + result = gpgme_op_verify_result (ctx); + check_result (result, 0, "A0FF4590BB6122EDEF6E3C542D727CC768697734", + GPG_ERR_NO_ERROR, 0); + + gpgme_data_release (sig); + gpgme_data_release (text); + gpgme_release (ctx); + return 0; +} diff --git a/tags/gpgme-0-4-3/tests/gpgsm/32100C27173EF6E9C4E9A25D3D69F86D37A4F939 b/tags/gpgme-0-4-3/tests/gpgsm/32100C27173EF6E9C4E9A25D3D69F86D37A4F939 new file mode 100644 index 0000000..cf0535f --- /dev/null +++ b/tags/gpgme-0-4-3/tests/gpgsm/32100C27173EF6E9C4E9A25D3D69F86D37A4F939 @@ -0,0 +1,18 @@ +(private-key + (oid.1.2.840.113549.1.1.1 + (n #00e0ce96f90b6c9e02f3922beada93fe50a875eac6bcc18bb9a9cf2e84965caa2d1ff95a7f542465c6c0c19d276e4526ce048868a7a914fd343cc3a87dd74291ffc565506d5bbb25cbac6a0e2dd1f8bcaab0d4a29c2f37c950f363484bf269f7891440464baf79827e03a36e70b814938eebdc63e964247be75dc58b014b7ea251#) + (e #010001#) + (d #046129F2489D71579BE0A75FE029BD6CDB574EBF57EA8A5B0FDA942CAB943B117D7BB95E5D28875E0F9FC5FCC06A72F6D502464DABDED78EF6B716177B83D5BDC543DC5D3FED932E59F5897E92E6F58A0F33424106A3B6FA2CBF877510E4AC21C3EE47851E97D12996222AC3566D4CCB0B83D164074ABF7DE655FC2446DA1781#) + (p #00e861b700e17e8afe6837e7512e35b6ca11d0ae47d8b85161c67baf64377213fe52d772f2035b3ca830af41d8a4120e1c1c70d12cc22f00d28d31dd48a8d424f1#) + (q #00f7a7ca5367c661f8e62df34f0d05c10c88e5492348dd7bddc942c9a8f369f935a07785d2db805215ed786e4285df1658eed3ce84f469b81b50d358407b4ad361#) + (u #304559a9ead56d2309d203811a641bb1a09626bc8eb36fffa23c968ec5bd891eebbafc73ae666e01ba7c8990bae06cc2bbe10b75e69fcacb353a6473079d8e9b#) + ) +) + + + + + + + + diff --git a/tags/gpgme-0-4-3/tests/gpgsm/Makefile.am b/tags/gpgme-0-4-3/tests/gpgsm/Makefile.am new file mode 100644 index 0000000..71984ff --- /dev/null +++ b/tags/gpgme-0-4-3/tests/gpgsm/Makefile.am @@ -0,0 +1,65 @@ +# Copyright (C) 2000 Werner Koch (dd9jn) +# Copyright (C) 2001 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 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA + +## Process this file with automake to produce Makefile.in + +GPGSM = @GPGSM@ + +TESTS_ENVIRONMENT = GNUPGHOME=. + +noinst_HEADERS = t-support.h +TESTS = t-import t-keylist t-encrypt t-verify t-decrypt t-sign t-export + +EXTRA_DIST = cert_dfn_pca01.der cert_dfn_pca15.der cert_g10code_test1.der \ + $(key_id) + +INCLUDES = -I$(top_srcdir)/gpgme + +AM_CPPFLAGS = @GPG_ERROR_CFLAGS@ +LDADD = ../../gpgme/libgpgme.la + +# We don't run t-genkey in the test suite, because it takes too long +# and needs a working pinentry. +noinst_PROGRAMS = $(TESTS) t-genkey + +key_id := 32100C27173EF6E9C4E9A25D3D69F86D37A4F939 + +DISTCLEANFILES = pubring.kbx pubring.kbx~ gpgsm.conf trustlist.txt \ + private-keys-v1.d/$(key_id).key random_seed + + +all-local: ./pubring.kbx ./gpgsm.conf ./private-keys-v1.d/$(key_id).key ./trustlist.txt + +./pubring.kbx: $(srcdir)/cert_g10code_test1.der + $(GPGSM) --homedir . --import $(srcdir)/cert_g10code_test1.der + +./gpgsm.conf: + echo disable-crl-checks > ./gpgsm.conf + echo faked-system-time 1038908198 >> ./gpgsm.conf + +./private-keys-v1.d/$(key_id).key: $(srcdir)/$(key_id) + test -d ./private-keys-v1.d || mkdir ./private-keys-v1.d + cp $(srcdir)/$(key_id) private-keys-v1.d/$(key_id).key + +./trustlist.txt: + echo $(key_id) > ./trustlist.txt + echo >> ./trustlist.txt + echo "# CN=test cert 1,OU=Aegypten Project,O=g10 Code GmbH,L=Düsseldorf,C=DE" >> ./trustlist.txt + echo "3CF405464F66ED4A7DF45BBDD1E4282E33BDB76E S" >> ./trustlist.txt + diff --git a/tags/gpgme-0-4-3/tests/gpgsm/cert_dfn_pca01.der b/tags/gpgme-0-4-3/tests/gpgsm/cert_dfn_pca01.der new file mode 100644 index 0000000..f8b61d3 Binary files /dev/null and b/tags/gpgme-0-4-3/tests/gpgsm/cert_dfn_pca01.der differ diff --git a/tags/gpgme-0-4-3/tests/gpgsm/cert_dfn_pca15.der b/tags/gpgme-0-4-3/tests/gpgsm/cert_dfn_pca15.der new file mode 100644 index 0000000..8d96650 Binary files /dev/null and b/tags/gpgme-0-4-3/tests/gpgsm/cert_dfn_pca15.der differ diff --git a/tags/gpgme-0-4-3/tests/gpgsm/cert_g10code_test1.der b/tags/gpgme-0-4-3/tests/gpgsm/cert_g10code_test1.der new file mode 100644 index 0000000..a2199d2 Binary files /dev/null and b/tags/gpgme-0-4-3/tests/gpgsm/cert_g10code_test1.der differ diff --git a/tags/gpgme-0-4-3/tests/gpgsm/t-decrypt.c b/tags/gpgme-0-4-3/tests/gpgsm/t-decrypt.c new file mode 100644 index 0000000..ca5757d --- /dev/null +++ b/tags/gpgme-0-4-3/tests/gpgsm/t-decrypt.c @@ -0,0 +1,79 @@ +/* t-encrypt.c - Regression test. + Copyright (C) 2000 Werner Koch (dd9jn) + Copyright (C) 2001, 2003 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 + 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. */ + +#include +#include +#include +#include + +#include +#include "t-support.h" + + +static const char test_text1[] = "Hallo Leute!\n"; +static const char test_cip1[] = +"-----BEGIN CMS OBJECT-----\n" +"MIAGCSqGSIb3DQEHA6CAMIACAQAxggEJMIIBBQIBADBwMGsxCzAJBgNVBAYTAkRF\n" +"MRMwEQYDVQQHFApE/HNzZWxkb3JmMRYwFAYDVQQKEw1nMTAgQ29kZSBHbWJIMRkw\n" +"FwYDVQQLExBBZWd5cHRlbiBQcm9qZWN0MRQwEgYDVQQDEwt0ZXN0IGNlcnQgMQIB\n" +"ADALBgkqhkiG9w0BAQEEgYBOFcOfUtAav+XjKGM1RJtF+8JLkbnu46S3T3709Iok\n" +"u+Z9dwpOyfHwxXOmjzkSKQSBBxxi6ar+sKjU/KfPIvaMpARwT+NfIVSCZRWIJ27z\n" +"wbSrav/kcRRDDA0wXV7dHVmSLPUJNCpiFMNZbkYtI+ai15g0PVeDw+szYd9zdsjJ\n" +"2zCABgkqhkiG9w0BBwEwFAYIKoZIhvcNAwcECA8gPQY2NtJToIAECAeoY3MIcz9h\n" +"BAiiytWtOSmqnwAA\n" +"-----END CMS OBJECT-----\n"; + + +int +main (int argc, char *argv[]) +{ + gpgme_ctx_t ctx; + gpgme_error_t err; + gpgme_data_t in, out; + gpgme_decrypt_result_t result; + + init_gpgme (GPGME_PROTOCOL_CMS); + + err = gpgme_new (&ctx); + fail_if_err (err); + gpgme_set_protocol (ctx, GPGME_PROTOCOL_CMS); + + err = gpgme_data_new_from_mem (&in, test_cip1, strlen (test_cip1), 0); + fail_if_err (err); + + err = gpgme_data_new (&out); + fail_if_err (err); + + err = gpgme_op_decrypt (ctx, in, out); + fail_if_err (err); + result = gpgme_op_decrypt_result (ctx); + if (result->unsupported_algorithm) + { + fprintf (stderr, "%s:%i: unsupported algorithm: %s\n", + __FILE__, __LINE__, result->unsupported_algorithm); + exit (1); + } + print_data (out); + + gpgme_data_release (in); + gpgme_data_release (out); + gpgme_release (ctx); + return 0; +} diff --git a/tags/gpgme-0-4-3/tests/gpgsm/t-encrypt.c b/tags/gpgme-0-4-3/tests/gpgsm/t-encrypt.c new file mode 100644 index 0000000..ff61394 --- /dev/null +++ b/tags/gpgme-0-4-3/tests/gpgsm/t-encrypt.c @@ -0,0 +1,71 @@ +/* t-encrypt.c - Regression test. + Copyright (C) 2000 Werner Koch (dd9jn) + Copyright (C) 2001, 2002, 2003 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 + 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. */ + +#include +#include +#include + +#include + +#include "t-support.h" + +int +main (int argc, char **argv) +{ + gpgme_ctx_t ctx; + gpgme_error_t err; + gpgme_data_t in, out; + gpgme_key_t key[] = { NULL, NULL }; + gpgme_encrypt_result_t result; + + init_gpgme (GPGME_PROTOCOL_CMS); + + err = gpgme_new (&ctx); + fail_if_err (err); + gpgme_set_protocol (ctx, GPGME_PROTOCOL_CMS); + gpgme_set_armor (ctx, 1); + + err = gpgme_data_new_from_mem (&in, "Hallo Leute\n", 12, 0); + fail_if_err (err); + + err = gpgme_data_new (&out); + fail_if_err (err); + + err = gpgme_get_key (ctx, "3CF405464F66ED4A7DF45BBDD1E4282E33BDB76E", + &key[0], 0); + fail_if_err (err); + + err = gpgme_op_encrypt (ctx, key, 0, in, out); + fail_if_err (err); + result = gpgme_op_encrypt_result (ctx); + if (result->invalid_recipients) + { + fprintf (stderr, "Invalid recipient encountered: %s\n", + result->invalid_recipients->fpr); + exit (1); + } + print_data (out); + + gpgme_key_unref (key[0]); + gpgme_data_release (in); + gpgme_data_release (out); + gpgme_release (ctx); + return 0; +} diff --git a/tags/gpgme-0-4-3/tests/gpgsm/t-export.c b/tags/gpgme-0-4-3/tests/gpgsm/t-export.c new file mode 100644 index 0000000..ce7dadb --- /dev/null +++ b/tags/gpgme-0-4-3/tests/gpgsm/t-export.c @@ -0,0 +1,60 @@ +/* t-export.c - Regression test. + Copyright (C) 2000 Werner Koch (dd9jn) + Copyright (C) 2001, 2003 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 + 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. */ + +#include +#include +#include +#include + +#include +#include "t-support.h" + + +int +main (int argc, char *argv[]) +{ + gpgme_ctx_t ctx; + gpgme_error_t err; + gpgme_data_t out; + const char *pattern[] = { "DFN Top Level Certification Authority", NULL }; + + init_gpgme (GPGME_PROTOCOL_CMS); + + err = gpgme_new (&ctx); + fail_if_err (err); + gpgme_set_protocol (ctx, GPGME_PROTOCOL_CMS); + + err = gpgme_data_new (&out); + fail_if_err (err); + + gpgme_set_armor (ctx, 1); + err = gpgme_op_export_ext (ctx, pattern, 0, out); + fail_if_err (err); + + fflush (NULL); + fputs ("Begin Result:\n", stdout); + print_data (out); + fputs ("End Result.\n", stdout); + + gpgme_data_release (out); + gpgme_release (ctx); + + return 0; +} diff --git a/tags/gpgme-0-4-3/tests/gpgsm/t-genkey.c b/tags/gpgme-0-4-3/tests/gpgsm/t-genkey.c new file mode 100644 index 0000000..a4d60c1 --- /dev/null +++ b/tags/gpgme-0-4-3/tests/gpgsm/t-genkey.c @@ -0,0 +1,121 @@ +/* t-genkey.c - regression test + Copyright (C) 2000 Werner Koch (dd9jn) + Copyright (C) 2001, 2003 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 + 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. */ + +#include +#include +#include +#include + +#include +#include "t-support.h" + + +/* True if progress function printed something on the screen. */ +static int progress_called; + +static void +progress (void *self, const char *what, int type, int current, int total) +{ + if (!strcmp (what, "primegen") && !current && !total + && (type == '.' || type == '+' || type == '!' + || type == '^' || type == '<' || type == '>')) + { + printf ("%c", type); + fflush (stdout); + progress_called = 1; + } + else + { + fprintf (stderr, "unknown progress `%s' %d %d %d\n", what, type, + current, total); + exit (1); + } +} + + +int +main (int argc, char *argv[]) +{ + gpgme_ctx_t ctx; + gpgme_error_t err; + const char *parms = "\n" + "Key-Type: RSA\n" + "Key-Length: 1024\n" + "Name-DN: C=de,O=g10 code,OU=Testlab,CN=Joe 2 Tester\n" + "Name-Email: joe@foo.bar\n" + "\n"; + gpgme_genkey_result_t result; + gpgme_data_t certreq; + + init_gpgme (GPGME_PROTOCOL_CMS); + + err = gpgme_data_new (&certreq); + fail_if_err (err); + + err = gpgme_new (&ctx); + fail_if_err (err); + + gpgme_set_protocol (ctx, GPGME_PROTOCOL_CMS); + gpgme_set_armor (ctx, 1); + + gpgme_set_progress_cb (ctx, progress, NULL); + + err = gpgme_op_genkey (ctx, parms, certreq, NULL); + fail_if_err (err); + + result = gpgme_op_genkey_result (ctx); + if (!result) + { + fprintf (stderr, "%s:%d: gpgme_op_genkey_result returns NULL\n", + __FILE__, __LINE__); + exit (1); + } + if (progress_called) + printf ("\n"); + + printf ("Generated key: %s (%s)\n", result->fpr ? result->fpr : "none", + result->primary ? (result->sub ? "primary, sub" : "primary") + : (result->sub ? "sub" : "none")); + + if (result->fpr) + { + fprintf (stderr, "%s:%d: generated key has (unexpectdly) a fingerprint\n", + __FILE__, __LINE__); + exit (1); + } + if (!result->primary) + { + fprintf (stderr, "%s:%d: primary key was not generated\n", + __FILE__, __LINE__); + exit (1); + } + if (result->sub) + { + fprintf (stderr, "%s:%d: sub key was (unexpectedly) generated\n", + __FILE__, __LINE__); + exit (1); + } + gpgme_release (ctx); + + print_data (certreq); + gpgme_data_release (certreq); + + return 0; +} diff --git a/tags/gpgme-0-4-3/tests/gpgsm/t-import.c b/tags/gpgme-0-4-3/tests/gpgsm/t-import.c new file mode 100644 index 0000000..4338156 --- /dev/null +++ b/tags/gpgme-0-4-3/tests/gpgsm/t-import.c @@ -0,0 +1,158 @@ +/* t-import.c - Regression test. + Copyright (C) 2000 Werner Koch (dd9jn) + Copyright (C) 2001, 2003 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 + 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. */ + +#include +#include +#include +#include + +#include + +#include "t-support.h" + + +void +check_result (gpgme_import_result_t result, char *fpr, int total) +{ + if (result->considered != total) + { + fprintf (stderr, "Unexpected number of considered keys %i\n", + result->considered); + exit (1); + } + if (result->no_user_id != 0) + { + fprintf (stderr, "Unexpected number of user ids %i\n", + result->no_user_id); + exit (1); + } + if (result->imported != 0 && result->imported != 1) + { + fprintf (stderr, "Unexpected number of imported keys %i\n", + result->imported); + exit (1); + } + if (result->imported_rsa != 0) + { + fprintf (stderr, "Unexpected number of imported RSA keys %i\n", + result->imported_rsa); + exit (1); + } + if ((result->imported == 0 && result->unchanged != total) + || (result->imported == 1 && result->unchanged != total - 1)) + { + fprintf (stderr, "Unexpected number of unchanged keys %i\n", + result->unchanged); + exit (1); + } + if (result->new_user_ids != 0) + { + fprintf (stderr, "Unexpected number of new user IDs %i\n", + result->new_user_ids); + exit (1); + } + if (result->new_sub_keys != 0) + { + fprintf (stderr, "Unexpected number of new sub keys %i\n", + result->new_sub_keys); + exit (1); + } + if (result->new_signatures != 0) + { + fprintf (stderr, "Unexpected number of new signatures %i\n", + result->new_signatures); + exit (1); + } + if (result->new_revocations != 0) + { + fprintf (stderr, "Unexpected number of new revocations %i\n", + result->new_revocations); + exit (1); + } + if (result->secret_read != 0) + { + fprintf (stderr, "Unexpected number of secret keys read %i\n", + result->secret_read); + exit (1); + } + if (result->secret_imported != 0) + { + fprintf (stderr, "Unexpected number of secret keys imported %i\n", + result->secret_imported); + exit (1); + } + if (result->secret_unchanged != 0) + { + fprintf (stderr, "Unexpected number of secret keys unchanged %i\n", + result->secret_unchanged); + exit (1); + } + if (result->not_imported != 0) + { + fprintf (stderr, "Unexpected number of secret keys not imported %i\n", + result->not_imported); + exit (1); + } + if (result->imports) + { + fprintf (stderr, "Unexpected number of status reports\n"); + exit (1); + } +} + + +int +main (int argc, char **argv) +{ + gpgme_ctx_t ctx; + gpgme_error_t err; + gpgme_data_t in; + gpgme_import_result_t result; + const char *cert_1 = make_filename ("cert_dfn_pca01.der"); + const char *cert_2 = make_filename ("cert_dfn_pca15.der"); + + init_gpgme (GPGME_PROTOCOL_CMS); + + err = gpgme_new (&ctx); + fail_if_err (err); + + gpgme_set_protocol (ctx, GPGME_PROTOCOL_CMS); + + err = gpgme_data_new_from_file (&in, cert_1, 1); + fail_if_err (err); + + err = gpgme_op_import (ctx, in); + fail_if_err (err); + result = gpgme_op_import_result (ctx); + check_result (result, "DFA56FB5FC41E3A8921F77AD1622EEFD9152A5AD", 1); + gpgme_data_release (in); + + err = gpgme_data_new_from_file (&in, cert_2, 1); + fail_if_err (err); + + err = gpgme_op_import (ctx, in); + fail_if_err (err); + result = gpgme_op_import_result (ctx); + check_result (result, "2C8F3C356AB761CB3674835B792CDA52937F9285", 2); + gpgme_data_release (in); + + gpgme_release (ctx); + return 0; +} diff --git a/tags/gpgme-0-4-3/tests/gpgsm/t-keylist.c b/tags/gpgme-0-4-3/tests/gpgsm/t-keylist.c new file mode 100644 index 0000000..cf4073f --- /dev/null +++ b/tags/gpgme-0-4-3/tests/gpgsm/t-keylist.c @@ -0,0 +1,347 @@ +/* t-keylist.c - regression test + Copyright (C) 2000 Werner Koch (dd9jn) + Copyright (C) 2001, 2003 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 + 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. */ + +#include +#include +#include + +#include + +#include "t-support.h" + + +struct +{ + char *fpr; + int secret; + long timestamp; + long expires; + char *issuer_serial; + char *issuer_name; + char *chain_id; + char *uid; +} +keys[] = + { + { "3CF405464F66ED4A7DF45BBDD1E4282E33BDB76E", 1, 1007372198, 1038908198, "00", + "CN=test cert 1,OU=Aegypten Project,O=g10 Code GmbH,L=D\xc3\xbcsseldorf,C=DE", + NULL, + "CN=test cert 1,OU=Aegypten Project,O=g10 Code GmbH,L=D\xc3\xbcsseldorf,C=DE" }, + { "DFA56FB5FC41E3A8921F77AD1622EEFD9152A5AD", 0, 909684190, 1009821790, "01", + "1.2.840.113549.1.9.1=#63657274696679407063612E64666E2E6465," + "CN=DFN Top Level Certification Authority,OU=DFN-PCA," + "O=Deutsches Forschungsnetz,C=DE", NULL, + "1.2.840.113549.1.9.1=#63657274696679407063612E64666E2E6465," + "CN=DFN Top Level Certification Authority,OU=DFN-PCA," + "O=Deutsches Forschungsnetz,C=DE" }, + { "2C8F3C356AB761CB3674835B792CDA52937F9285", 0, 973183644, 1009735200, "15", + "1.2.840.113549.1.9.1=#63657274696679407063612E64666E2E6465," + "CN=DFN Top Level Certification Authority,OU=DFN-PCA," + "O=Deutsches Forschungsnetz,C=DE", + "DFA56FB5FC41E3A8921F77AD1622EEFD9152A5AD", + "1.2.840.113549.1.9.1=#63657274696679407063612E64666E2E6465," + "CN=DFN Server Certification Authority,OU=DFN-PCA," + "O=Deutsches Forschungsnetz,C=DE" }, + { NULL } + }; + + +int +main (int argc, char **argv) +{ + gpgme_error_t err; + gpgme_ctx_t ctx; + gpgme_key_t key; + gpgme_keylist_result_t result; + int i = 0; + + init_gpgme (GPGME_PROTOCOL_CMS); + + err = gpgme_new (&ctx); + fail_if_err (err); + gpgme_set_protocol (ctx, GPGME_PROTOCOL_CMS); + + err = gpgme_op_keylist_start (ctx, NULL, 0); + fail_if_err (err); + + while (!(err = gpgme_op_keylist_next (ctx, &key))) + { + if (!keys[i].fpr) + { + fprintf (stderr, "More keys returned than expected\n"); + exit (1); + } + + /* Global key flags. */ + if (key->revoked) + { + fprintf (stderr, "Key unexpectedly revoked\n"); + exit (1); + } + if (key->expired) + { + fprintf (stderr, "Key unexpectedly expired\n"); + exit (1); + } + if (key->disabled) + { + fprintf (stderr, "Key unexpectedly disabled\n"); + exit (1); + } + if (key->invalid) + { + fprintf (stderr, "Key unexpectedly invalid\n"); + exit (1); + } + if (key->can_encrypt != keys[i].secret) + { + fprintf (stderr, "Key unexpectedly%s usable for encryption\n", + key->can_encrypt ? "" : " not"); + exit (1); + } + if (key->can_sign != keys[i].secret) + { + fprintf (stderr, "Key unexpectedly%s usable for signing\n", + key->can_sign ? "" : " not"); + exit (1); + } + if (!key->can_certify) + { + fprintf (stderr, "Key unexpectedly unusable for certifications\n"); + exit (1); + } + if (key->secret != keys[i].secret) + { + fprintf (stderr, "Key unexpectedly%s secret\n", + key->secret ? "" : " not"); + exit (1); + } + if (key->protocol != GPGME_PROTOCOL_CMS) + { + fprintf (stderr, "Key has unexpected protocol: %s\n", + gpgme_get_protocol_name (key->protocol)); + exit (1); + } + if (!key->issuer_serial) + { + fprintf (stderr, "Key unexpectedly misses issuer serial\n"); + exit (1); + } + if (strcmp (key->issuer_serial, keys[i].issuer_serial)) + { + fprintf (stderr, "Key has unexpected issuer serial: %s\n", + key->issuer_serial); + exit (1); + } + if (!key->issuer_name) + { + fprintf (stderr, "Key unexpectedly misses issuer name\n"); + exit (1); + } + if (strcmp (key->issuer_name, keys[i].issuer_name)) + { + fprintf (stderr, "Key has unexpected issuer name: %s\n", + key->issuer_name); + exit (1); + } + if (key->chain_id && !keys[i].chain_id) + { + fprintf (stderr, "Key unexpectedly carries chain ID: %s\n", + key->chain_id); + exit (1); + } + if (!key->chain_id && keys[i].chain_id) + { + fprintf (stderr, "Key unexpectedly carries no chain ID\n"); + exit (1); + } + if (key->chain_id && strcmp (key->chain_id, keys[i].chain_id)) + { + fprintf (stderr, "Key carries unexpected chain ID: %s\n", + key->chain_id); + exit (1); + } + if (key->owner_trust != GPGME_VALIDITY_UNKNOWN) + { + fprintf (stderr, "Key has unexpected owner trust: %i\n", + key->owner_trust); + exit (1); + } + if (!key->subkeys || key->subkeys->next) + { + fprintf (stderr, "Key has unexpected number of subkeys\n"); + exit (1); + } + + /* Primary key. */ + if (key->subkeys->revoked) + { + fprintf (stderr, "Primary key unexpectedly revoked\n"); + exit (1); + } + if (key->subkeys->expired) + { + fprintf (stderr, "Primary key unexpectedly expired\n"); + exit (1); + } + if (key->subkeys->disabled) + { + fprintf (stderr, "Primary key unexpectedly disabled\n"); + exit (1); + } + if (key->subkeys->invalid) + { + fprintf (stderr, "Primary key unexpectedly invalid\n"); + exit (1); + } + if (key->subkeys->can_encrypt != keys[i].secret) + { + fprintf (stderr, "Key unexpectedly%s usable for encryption\n", + key->subkeys->can_encrypt ? "" : " not"); + exit (1); + } + if (key->subkeys->can_sign != keys[i].secret) + { + fprintf (stderr, "Key unexpectedly%s usable for signing\n", + key->subkeys->can_sign ? "" : " not"); + exit (1); + } + if (!key->subkeys->can_certify) + { + fprintf (stderr, "Primary key unexpectedly unusable for certifications\n"); + exit (1); + } + if (key->subkeys->secret) + { + fprintf (stderr, "Primary key unexpectedly secret\n"); + exit (1); + } + if (key->subkeys->pubkey_algo != GPGME_PK_RSA) + { + fprintf (stderr, "Primary key has unexpected public key algo: %s\n", + gpgme_pubkey_algo_name (key->subkeys->pubkey_algo)); + exit (1); + } + if (key->subkeys->length != 1024) + { + fprintf (stderr, "Primary key has unexpected length: %i\n", + key->subkeys->length); + exit (1); + } + if (strcmp (key->subkeys->keyid, &keys[i].fpr[40 - 16])) + { + fprintf (stderr, "Primary key has unexpected key ID: %s\n", + key->subkeys->keyid); + exit (1); + } + if (strcmp (key->subkeys->fpr, keys[i].fpr)) + { + fprintf (stderr, "Primary key has unexpected fingerprint: %s\n", + key->subkeys->fpr); + exit (1); + } + if (key->subkeys->timestamp != keys[i].timestamp) + { + fprintf (stderr, "Primary key unexpected timestamp: %lu\n", + key->subkeys->timestamp); + exit (1); + } + if (key->subkeys->expires != keys[i].expires) + { + fprintf (stderr, "Primary key unexpectedly expires: %lu\n", + key->subkeys->expires); + exit (1); + } + + if (!key->uids || key->uids->next) + { + fprintf (stderr, "Key has unexpected number of user IDs\n"); + exit (1); + } + if (key->uids->revoked) + { + fprintf (stderr, "User ID unexpectedly revoked\n"); + exit (1); + } + if (key->uids->invalid) + { + fprintf (stderr, "User ID unexpectedly invalid\n"); + exit (1); + } + if (key->uids->validity != GPGME_VALIDITY_UNKNOWN) + { + fprintf (stderr, "User ID unexpectedly validity: %i\n", + key->uids->validity); + exit (1); + } + if (key->uids->signatures) + { + fprintf (stderr, "User ID unexpectedly signed\n"); + exit (1); + } + if (!key->uids->name || key->uids->name[0]) + { + fprintf (stderr, "Unexpected name in user ID: %s\n", + key->uids->name); + exit (1); + } + if (!key->uids->comment || key->uids->comment[0]) + { + fprintf (stderr, "Unexpected comment in user ID: %s\n", + key->uids->comment); + exit (1); + } + if (!key->uids->email || key->uids->email[0]) + { + fprintf (stderr, "Unexpected email in user ID: %s\n", + key->uids->email); + exit (1); + } + if (!key->uids->uid || strcmp (key->uids->uid, keys[i].uid)) + { + fprintf (stderr, "Unexpected uid in user ID: %s\n", + key->uids->uid); + exit (1); + } + + gpgme_key_unref (key); + i++; + } + if (gpg_err_code (err) != GPG_ERR_EOF) + fail_if_err (err); + err = gpgme_op_keylist_end (ctx); + fail_if_err (err); + + result = gpgme_op_keylist_result (ctx); + if (result->truncated) + { + fprintf (stderr, "Key listing unexpectedly truncated\n"); + exit (1); + } + + if (keys[i].fpr) + { + fprintf (stderr, "Less keys returned than expected\n"); + exit (1); + } + + gpgme_release (ctx); + return 0; +} diff --git a/tags/gpgme-0-4-3/tests/gpgsm/t-sign.c b/tags/gpgme-0-4-3/tests/gpgsm/t-sign.c new file mode 100644 index 0000000..2cfac7d --- /dev/null +++ b/tags/gpgme-0-4-3/tests/gpgsm/t-sign.c @@ -0,0 +1,120 @@ +/* t-sign.c - Regression test. + Copyright (C) 2000 Werner Koch (dd9jn) + Copyright (C) 2001, 2003 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 + 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. */ + +#include +#include +#include + +#include +#include "t-support.h" + + +static void +check_result (gpgme_sign_result_t result, gpgme_sig_mode_t type) +{ + if (result->invalid_signers) + { + fprintf (stderr, "Invalid signer found: %s\n", + result->invalid_signers->fpr); + exit (1); + } + if (!result->signatures || result->signatures->next) + { + fprintf (stderr, "Unexpected number of signatures created\n"); + exit (1); + } + if (result->signatures->type != type) + { + fprintf (stderr, "Wrong type of signature created\n"); + exit (1); + } + if (result->signatures->pubkey_algo != GPGME_PK_RSA) + { + fprintf (stderr, "Wrong pubkey algorithm reported: %i\n", + result->signatures->pubkey_algo); + exit (1); + } + if (result->signatures->hash_algo != GPGME_MD_SHA1) + { + fprintf (stderr, "Wrong hash algorithm reported: %i\n", + result->signatures->hash_algo); + exit (1); + } + if (result->signatures->class != 0) + { + fprintf (stderr, "Wrong signature class reported: %u\n", + result->signatures->class); + exit (1); + } + if (strcmp ("3CF405464F66ED4A7DF45BBDD1E4282E33BDB76E", + result->signatures->fpr)) + { + fprintf (stderr, "Wrong fingerprint reported: %s\n", + result->signatures->fpr); + exit (1); + } +} + + +int +main (int argc, char *argv[]) +{ + gpgme_ctx_t ctx; + gpgme_error_t err; + gpgme_data_t in, out; + gpgme_sign_result_t result; + + init_gpgme (GPGME_PROTOCOL_CMS); + + err = gpgme_new (&ctx); + fail_if_err (err); + + gpgme_set_protocol (ctx, GPGME_PROTOCOL_CMS); + gpgme_set_textmode (ctx, 1); + gpgme_set_armor (ctx, 1); + + err = gpgme_data_new_from_mem (&in, "Hallo Leute!\n", 13, 0); + fail_if_err (err); + + /* First a normal signature. */ + err = gpgme_data_new (&out); + fail_if_err (err); + err = gpgme_op_sign (ctx, in, out, GPGME_SIG_MODE_NORMAL); + fail_if_err (err); + result = gpgme_op_sign_result (ctx); + check_result (result, GPGME_SIG_MODE_NORMAL); + print_data (out); + gpgme_data_release (out); + + /* Now a detached signature. */ + gpgme_data_seek (in, 0, SEEK_SET); + err = gpgme_data_new (&out); + fail_if_err (err); + err = gpgme_op_sign (ctx, in, out, GPGME_SIG_MODE_DETACH); + fail_if_err (err); + result = gpgme_op_sign_result (ctx); + check_result (result, GPGME_SIG_MODE_DETACH); + print_data (out); + gpgme_data_release (out); + + gpgme_data_release (in); + gpgme_release (ctx); + return 0; +} diff --git a/tags/gpgme-0-4-3/tests/gpgsm/t-support.h b/tags/gpgme-0-4-3/tests/gpgsm/t-support.h new file mode 100644 index 0000000..3199b05 --- /dev/null +++ b/tags/gpgme-0-4-3/tests/gpgsm/t-support.h @@ -0,0 +1,98 @@ +/* t-support.h - Helper routines for regression tests. + Copyright (C) 2000 Werner Koch (dd9jn) + Copyright (C) 2001, 2002, 2003 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 + 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. */ + +#include +#include +#include +#include + +#include + +#define fail_if_err(err) \ + do \ + { \ + if (err) \ + { \ + fprintf (stderr, "%s:%d: %s: %s\n", \ + __FILE__, __LINE__, gpg_strsource (err), \ + gpg_strerror (err)); \ + exit (1); \ + } \ + } \ + while (0) + + +void +print_data (gpgme_data_t dh) +{ +#define BUF_SIZE 512 + char buf[BUF_SIZE + 1]; + int ret; + + ret = gpgme_data_seek (dh, 0, SEEK_SET); + if (ret) + fail_if_err (gpg_error_from_errno (errno)); + while ((ret = gpgme_data_read (dh, buf, BUF_SIZE)) > 0) + fwrite (buf, ret, 1, stdout); + if (ret < 0) + fail_if_err (gpg_error_from_errno (errno)); +} + + +gpgme_error_t +passphrase_cb (void *opaque, const char *uid_hint, const char *passphrase_info, + int last_was_bad, int fd) +{ + write (fd, "abc\n", 4); + return 0; +} + + +char * +make_filename (const char *fname) +{ + const char *srcdir = getenv ("srcdir"); + char *buf; + + if (!srcdir) + srcdir = "."; + buf = malloc (strlen(srcdir) + strlen(fname) + 2); + if (!buf) + exit (8); + strcpy (buf, srcdir); + strcat (buf, "/"); + strcat (buf, fname); + return buf; +} + + +void +init_gpgme (gpgme_protocol_t proto) +{ + gpgme_error_t err; + + gpgme_check_version (NULL); + setlocale (LC_ALL, ""); + gpgme_set_locale (NULL, LC_CTYPE, setlocale (LC_CTYPE, NULL)); + gpgme_set_locale (NULL, LC_MESSAGES, setlocale (LC_MESSAGES, NULL)); + + err = gpgme_engine_check_version (proto); + fail_if_err (err); +} diff --git a/tags/gpgme-0-4-3/tests/gpgsm/t-verify.c b/tags/gpgme-0-4-3/tests/gpgsm/t-verify.c new file mode 100644 index 0000000..304fc2c --- /dev/null +++ b/tags/gpgme-0-4-3/tests/gpgsm/t-verify.c @@ -0,0 +1,143 @@ +/* t-verify.c - Regression test. + Copyright (C) 2000 Werner Koch (dd9jn) + Copyright (C) 2001, 2002, 2003 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 + 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. */ + +#include +#include +#include + +#include + +#include "t-support.h" + + +static const char test_text1[] = "Hallo Leute!\n"; +static const char test_text1f[]= "Hallo Leute?\n"; +static const char test_sig1[] = +"-----BEGIN CMS OBJECT-----\n" +"MIAGCSqGSIb3DQEHAqCAMIACAQExCzAJBgUrDgMCGgUAMIAGCSqGSIb3DQEHAQAA\n" +"MYIBOTCCATUCAQEwcDBrMQswCQYDVQQGEwJERTETMBEGA1UEBxQKRPxzc2VsZG9y\n" +"ZjEWMBQGA1UEChMNZzEwIENvZGUgR21iSDEZMBcGA1UECxMQQWVneXB0ZW4gUHJv\n" +"amVjdDEUMBIGA1UEAxMLdGVzdCBjZXJ0IDECAQAwBwYFKw4DAhqgJTAjBgkqhkiG\n" +"9w0BCQQxFgQU7FC/ibH3lC9GE24RJJxa8zqP7wEwCwYJKoZIhvcNAQEBBIGAA3oC\n" +"DUmKERmD1eoJYFw38y/qnncS/6ZPjWINDIphZeK8mzAANpvpIaRPf3sNBznb89QF\n" +"mRgCXIWcjlHT0DTRLBf192Ve22IyKH00L52CqFsSN3a2sajqRUlXH8RY2D+Al71e\n" +"MYdRclgjObCcoilA8fZ13VR4DiMJVFCxJL4qVWI=\n" +"-----END CMS OBJECT-----\n"; + + +static void +check_result (gpgme_verify_result_t result, int summary, char *fpr, + gpgme_error_t status, gpgme_validity_t validity) +{ + gpgme_signature_t sig; + + sig = result->signatures; + if (!sig || sig->next) + { + fprintf (stderr, "%s:%i: Unexpected number of signatures\n", + __FILE__, __LINE__); + exit (1); + } + if (sig->summary != summary) + { + fprintf (stderr, "%s:%i: Unexpected signature summary: 0x%x\n", + __FILE__, __LINE__, sig->summary); + exit (1); + } + if (strcmp (sig->fpr, fpr)) + { + fprintf (stderr, "%s:%i: Unexpected fingerprint: %s\n", + __FILE__, __LINE__, sig->fpr); + exit (1); + } + if (gpg_err_code (sig->status) != status) + { + fprintf (stderr, "%s:%i: Unexpected signature status: %s\n", + __FILE__, __LINE__, gpgme_strerror (sig->status)); + exit (1); + } + if (sig->notations) + { + fprintf (stderr, "%s:%i: Unexpected notation data\n", + __FILE__, __LINE__); + exit (1); + } + if (sig->wrong_key_usage) + { + fprintf (stderr, "%s:%i: Unexpectedly wrong key usage\n", + __FILE__, __LINE__); + exit (1); + } + if (sig->validity != validity) + { + fprintf (stderr, "%s:%i: Unexpected validity: %i\n", + __FILE__, __LINE__, sig->validity); + exit (1); + } + if (gpg_err_code (sig->validity_reason) != GPG_ERR_NO_ERROR) + { + fprintf (stderr, "%s:%i: Unexpected validity reason: %s\n", + __FILE__, __LINE__, gpgme_strerror (sig->validity_reason)); + exit (1); + } +} + + +int +main (int argc, char **argv) +{ + gpgme_ctx_t ctx; + gpgme_error_t err; + gpgme_data_t sig, text; + gpgme_verify_result_t result; + + init_gpgme (GPGME_PROTOCOL_CMS); + + err = gpgme_new (&ctx); + fail_if_err (err); + gpgme_set_protocol (ctx, GPGME_PROTOCOL_CMS); + + /* Checking a valid message. */ + err = gpgme_data_new_from_mem (&text, test_text1, strlen (test_text1), 0); + fail_if_err (err); + err = gpgme_data_new_from_mem (&sig, test_sig1, strlen (test_sig1), 0); + fail_if_err (err); + err = gpgme_op_verify (ctx, sig, text, NULL); + fail_if_err (err); + result = gpgme_op_verify_result (ctx); + check_result (result, GPGME_SIGSUM_VALID | GPGME_SIGSUM_GREEN, + "3CF405464F66ED4A7DF45BBDD1E4282E33BDB76E", + GPG_ERR_NO_ERROR, GPGME_VALIDITY_FULL); + + /* Checking a manipulated message. */ + gpgme_data_release (text); + err = gpgme_data_new_from_mem (&text, test_text1f, strlen (test_text1f), 0); + fail_if_err (err); + gpgme_data_seek (sig, 0, SEEK_SET); + err = gpgme_op_verify (ctx, sig, text, NULL); + fail_if_err (err); + result = gpgme_op_verify_result (ctx); + check_result (result, GPGME_SIGSUM_RED, + "3CF405464F66ED4A7DF45BBDD1E4282E33BDB76E", + GPG_ERR_BAD_SIGNATURE, GPGME_VALIDITY_UNKNOWN); + + gpgme_release (ctx); + return 0; +} diff --git a/tags/gpgme-0-4-3/tests/t-data-1.txt b/tags/gpgme-0-4-3/tests/t-data-1.txt new file mode 100644 index 0000000..16a15f2 --- /dev/null +++ b/tags/gpgme-0-4-3/tests/t-data-1.txt @@ -0,0 +1 @@ +Just GNU it! diff --git a/tags/gpgme-0-4-3/tests/t-data-2.txt b/tags/gpgme-0-4-3/tests/t-data-2.txt new file mode 100644 index 0000000..9ae851c --- /dev/null +++ b/tags/gpgme-0-4-3/tests/t-data-2.txt @@ -0,0 +1,3 @@ +Just GNU it! +Just GNU it! +Just GNU it! diff --git a/tags/gpgme-0-4-3/tests/t-data.c b/tags/gpgme-0-4-3/tests/t-data.c new file mode 100644 index 0000000..d7950ad --- /dev/null +++ b/tags/gpgme-0-4-3/tests/t-data.c @@ -0,0 +1,279 @@ +/* t-data - Regression tests for the gpgme_data_t abstraction. + * Copyright (C) 2001 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 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA + */ + +#include +#include +#include +#include +#include + +#include + +#define fail_if_err(a) do { if(a) { \ + fprintf (stderr, "%s:%d: (%i) gpgme_error_t " \ + "%s\n", __FILE__, __LINE__, round, \ + gpgme_strerror(a)); \ + exit (1); } \ + } while(0) + +static char * +make_filename (const char *fname) +{ + const char *srcdir = getenv ("srcdir"); + char *buf; + + if (!srcdir) + srcdir = "."; + buf = malloc (strlen(srcdir) + strlen(fname) + 2 ); + if (!buf) + { + fprintf (stderr, "%s:%d: could not allocate string: %s\n", + __FILE__, __LINE__, strerror (errno)); + exit (1); + } + strcpy (buf, srcdir); + strcat (buf, "/"); + strcat (buf, fname); + return buf; +} + +typedef enum + { + TEST_INITIALIZER, + TEST_INVALID_ARGUMENT, + TEST_INOUT_NONE, + TEST_INOUT_MEM_NO_COPY, + TEST_INOUT_MEM_COPY, + TEST_INOUT_MEM_FROM_FILE_COPY, + TEST_INOUT_MEM_FROM_INEXISTANT_FILE, + TEST_INOUT_MEM_FROM_FILE_NO_COPY, + TEST_INOUT_MEM_FROM_FILE_PART_BY_NAME, + TEST_INOUT_MEM_FROM_INEXISTANT_FILE_PART, + TEST_INOUT_MEM_FROM_FILE_PART_BY_FP, + TEST_END + } round_t; + +const char *text = "Just GNU it!\n"; +const char *text2 = "Just GNU it!\nJust GNU it!\n"; + +int +read_cb (void *cb_value, char *buffer, size_t count, size_t *nread) +{ + static int off = 0; + unsigned int amount = strlen (text) - off; + /* round_t round = *((round_t *) cb_value); */ + + if (!buffer && !count && !nread) + { + /* Rewind requested. */ + off = 0; + return 0; + } + if (! buffer || !nread) + return -1; + if (amount <= 0) + { + /* End of file. */ + *nread = 0; + return -1; + } + if (amount > count) + amount = count; + memcpy (buffer, text, amount); + off += amount; + *nread = amount; + return 0; +} + +void +read_once_test (round_t round, gpgme_data_t data) +{ + char buffer[1024]; + size_t read; + + read = gpgme_data_read (data, buffer, sizeof (buffer)); + + if (read != strlen (text) || strncmp (buffer, text, strlen (text))) + { + fprintf (stderr, "%s:%d: (%i) gpgme_data_read returned wrong data\n", + __FILE__, __LINE__, round); + exit (1); + } + + read = gpgme_data_read (data, buffer, sizeof (buffer)); + if (read) + { + fprintf (stderr, "%s:%d: (%i) gpgme_data_read did not signal EOF\n", + __FILE__, __LINE__, round); + exit (1); + } +} + +void +read_test (round_t round, gpgme_data_t data) +{ + char buffer[1024]; + size_t read; + + if (round == TEST_INOUT_NONE) + { + read = gpgme_data_read (data, buffer, sizeof (buffer)); + if (read > 0) + { + fprintf (stderr, "%s:%d: (%i) gpgme_data_read succeded unexpectedly\n", + __FILE__, __LINE__, round); + exit (1); + } + return; + } + + read_once_test (round, data); + gpgme_data_seek (data, 0, SEEK_SET); + read_once_test (round, data); +} + +void +write_test (round_t round, gpgme_data_t data) +{ + char buffer[1024]; + size_t amt; + + amt = gpgme_data_write (data, text, strlen (text)); + if (amt != strlen (text)) + fail_if_err (gpg_error_from_errno (errno)); + + gpgme_data_seek (data, 0, SEEK_SET); + + if (round == TEST_INOUT_NONE) + read_once_test (round, data); + else + { + amt = gpgme_data_read (data, buffer, sizeof (buffer)); + + if (amt != strlen (text2) || strncmp (buffer, text2, strlen (text2))) + { + fprintf (stderr, "%s:%d: (%i) gpgme_data_read returned wrong data\n", + __FILE__, __LINE__, round); + exit (1); + } + + amt = gpgme_data_read (data, buffer, sizeof (buffer)); + if (amt) + { + fprintf (stderr, "%s:%d: (%i) gpgme_data_read did not signal EOF\n", + __FILE__, __LINE__, round); + exit (1); + } + } +} + +int +main (int argc, char **argv) +{ + round_t round = TEST_INITIALIZER; + const char *text_filename = make_filename ("t-data-1.txt"); + const char *longer_text_filename = make_filename ("t-data-2.txt"); + const char *missing_filename = "this-file-surely-does-not-exist"; + gpgme_error_t err = 0; + gpgme_data_t data; + + while (++round) + { + switch (round) + { + case TEST_INVALID_ARGUMENT: + err = gpgme_data_new (NULL); + if (!err) + { + fprintf (stderr, "%s:%d: gpgme_data_new on NULL pointer succeeded " + "unexpectedly\n", __FILE__, __LINE__); + exit (1); + } + continue; + case TEST_INOUT_NONE: + err = gpgme_data_new (&data); + break; + case TEST_INOUT_MEM_NO_COPY: + err = gpgme_data_new_from_mem (&data, text, strlen (text), 0); + break; + case TEST_INOUT_MEM_COPY: + err = gpgme_data_new_from_mem (&data, text, strlen (text), 1); + break; + case TEST_INOUT_MEM_FROM_FILE_COPY: + err = gpgme_data_new_from_file (&data, text_filename, 1); + break; + case TEST_INOUT_MEM_FROM_INEXISTANT_FILE: + err = gpgme_data_new_from_file (&data, missing_filename, 1); + if (!err) + { + fprintf (stderr, "%s:%d: gpgme_data_new_from_file on inexistant " + "file succeeded unexpectedly\n", __FILE__, __LINE__); + exit (1); + } + continue; + case TEST_INOUT_MEM_FROM_FILE_NO_COPY: + err = gpgme_data_new_from_file (&data, text_filename, 0); + /* This is not implemented yet. */ + if (gpg_err_code (err) == GPG_ERR_NOT_IMPLEMENTED + || gpg_err_code (err) == GPG_ERR_INV_VALUE) + continue; + break; + case TEST_INOUT_MEM_FROM_FILE_PART_BY_NAME: + err = gpgme_data_new_from_filepart (&data, longer_text_filename, 0, + strlen (text), strlen (text)); + break; + case TEST_INOUT_MEM_FROM_INEXISTANT_FILE_PART: + err = gpgme_data_new_from_filepart (&data, missing_filename, 0, + strlen (text), strlen (text)); + if (!err) + { + fprintf (stderr, "%s:%d: gpgme_data_new_from_file on inexistant " + "file succeeded unexpectedly\n", __FILE__, __LINE__); + exit (1); + } + continue; + case TEST_INOUT_MEM_FROM_FILE_PART_BY_FP: + { + FILE *fp = fopen (longer_text_filename, "rb"); + if (! fp) + { + fprintf (stderr, "%s:%d: fopen: %s\n", __FILE__, __LINE__, + strerror (errno)); + exit (1); + } + err = gpgme_data_new_from_filepart (&data, 0, fp, + strlen (text), strlen (text)); + } + break; + case TEST_END: + return 0; + case TEST_INITIALIZER: + /* Shouldn't happen. */ + fprintf (stderr, "%s:%d: impossible condition\n", __FILE__, __LINE__); + exit (1); + } + fail_if_err (err); + + read_test (round, data); + write_test (round, data); + gpgme_data_release (data); + } + return 0; +} diff --git a/tags/gpgme-0-4-3/tests/t-engine-info.c b/tags/gpgme-0-4-3/tests/t-engine-info.c new file mode 100644 index 0000000..2705b48 --- /dev/null +++ b/tags/gpgme-0-4-3/tests/t-engine-info.c @@ -0,0 +1,92 @@ +/* t-engine-info.c - Regression test for gpgme_get_engine_info. + Copyright (C) 2003 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 + 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. */ + +#ifdef HAVE_CONFIG_H +#include +#endif + +#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) + + +void +check_engine_info (gpgme_engine_info_t info, gpgme_protocol_t protocol, + const char *file_name, const char *req_version) +{ + if (info->protocol != protocol) + { + fprintf (stderr, "Unexpected protocol %i (expected %i instead)\n", + info->protocol, protocol); + exit (1); + } + if (strcmp (info->file_name, file_name)) + { + fprintf (stderr, "Unexpected file name to executable %s (expected %s instead)", + info->file_name, file_name); + exit (1); + } + if (strcmp (info->req_version, req_version)) + { + fprintf (stderr, "Unexpected required version %s (expected %s instead)", + info->req_version, req_version); + exit (1); + } +} + + +int +main (int argc, char **argv ) +{ + gpgme_engine_info_t info; + gpgme_error_t err; + + err = gpgme_get_engine_info (&info); + fail_if_err (err); + + check_engine_info (info, GPGME_PROTOCOL_OpenPGP, GPG_PATH, NEED_GPG_VERSION); + + info = info->next; +#ifdef GPGSM_PATH + check_engine_info (info, GPGME_PROTOCOL_CMS, GPGSM_PATH, NEED_GPGSM_VERSION); +#else + if (info) + { + fprintf (stderr, "Unexpected engine info.\n"); + exit (1); + } +#endif + + return 0; +} diff --git a/tags/gpgme-0-4-3/tests/t-version.c b/tags/gpgme-0-4-3/tests/t-version.c new file mode 100644 index 0000000..5778b6b --- /dev/null +++ b/tags/gpgme-0-4-3/tests/t-version.c @@ -0,0 +1,45 @@ +/* t-version.c - regression test + * Copyright (C) 2001 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 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA + */ + +#ifdef HAVE_CONFIG_H +#include +#endif + +#include + +#include + +int +main (int argc, char **argv) +{ + const char *null_result; + const char *current_result; + const char *future_result; + + null_result = gpgme_check_version (NULL); + current_result = gpgme_check_version (VERSION); + future_result = gpgme_check_version (VERSION ".1"); + + return !(null_result + && ! strcmp (null_result, VERSION) + && current_result + && ! strcmp (current_result, VERSION) + && ! future_result); +}